Re: PQescapeBytea is not multibyte aware - Mailing list pgsql-hackers

From Joe Conway
Subject Re: PQescapeBytea is not multibyte aware
Date
Msg-id 3CADCDC1.1020908@joeconway.com
Whole thread Raw
In response to PQescapeBytea is not multibyte aware  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Responses Re: PQescapeBytea is not multibyte aware  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> 
>>PQescapebytea() is not multibyte aware and will produce bad multibyte
>>character sequences. Example:
>>I think 0x89 should be converted to '\\211' since 0x89 of 0x8950 is
>>considered as "non printable characters".
> 
> 
> Hmm, so essentially we'd have to convert all codes >= 0x80 to prevent
> them from being mistaken for parts of multibyte sequences?  Ugh, but
> you're probably right.  It looks to me like byteaout does the reverse
> already.
> 

But the error comes from pg_verifymbstr. Since bytea has no encoding 
(it's just an array of bytes afterall), why does pg_verifymbstr get 
applied at all to bytea data?

pg_verifymbstr is called by textin, bpcharin, and varcharin. Would it 
help to rewrite this as:

INSERT INTO t1(bytea_col) VALUES('characters produced by
PQescapebytea'::bytea);
?

Joe





pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: [Fwd: AW: UB-Tree's and patents]
Next
From: Tom Lane
Date:
Subject: Re: timeout implementation issues