Bug #653: Unable to insert binary data into BYTEA column in UTF8 DB

Started by PostgreSQL Bugs Listalmost 24 years ago4 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

Peter Vicen (vicen@pv2c.sk) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Unable to insert binary data into BYTEA column in UTF8 DB

Long Description
After creating an UTF8 database ("createdb --encoding "UTF8" ...) containing BYTEA columns the parser rejects insert queries with binary data because they're not UTF8 encoded (escaping doesn't help ;-).

Sample Code

No file was uploaded with this report

#2Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: PostgreSQL Bugs List (#1)
Re: Bug #653: Unable to insert binary data into BYTEA

After creating an UTF8 database ("createdb --encoding "UTF8" ...) containing BYTEA columns the parser rejects insert queries with binary data because they're not UTF8 encoded (escaping doesn't help ;-).

I don't kno how exactly escaped them, but you need to escape bytes >
0x7f (PQescapebytea has been fixed in that way in current). Or you
could cast them as bytea.
--
Tatsuo Ishii

#3Bruce Momjian
bruce@momjian.us
In reply to: PostgreSQL Bugs List (#1)
Re: Bug #653: Unable to insert binary data into BYTEA column

This seems unusual. Would you send us a sample of a string that is
rejected?

---------------------------------------------------------------------------

pgsql-bugs@postgresql.org wrote:

Peter Vicen (vicen@pv2c.sk) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description Unable to insert binary data into BYTEA column
in UTF8 DB

Long Description After creating an UTF8 database ("createdb
--encoding "UTF8" ...) containing BYTEA columns the parser
rejects insert queries with binary data because they're not UTF8
encoded (escaping doesn't help ;-).

Sample Code

No file was uploaded with this report

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#4Bruce Momjian
bruce@momjian.us
In reply to: Tatsuo Ishii (#2)
Re: Bug #653: Unable to insert binary data into BYTEA

Tatsuo Ishii wrote:

After creating an UTF8 database ("createdb --encoding "UTF8" ...) containing BYTEA columns the parser rejects insert queries with binary data because they're not UTF8 encoded (escaping doesn't help ;-).

I don't kno how exactly escaped them, but you need to escape bytes >
0x7f (PQescapebytea has been fixed in that way in current). Or you
could cast them as bytea.

Oh, that is interesting. I didn't realize the interaction between
encodings and bytea, I guess because bytea usage is only recently
popular. Do we document this bytea limitation properly?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026