Re: PQescapeBytea is not multibyte aware

From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PQescapeBytea is not multibyte aware
Date: 2002-04-05 16:16:01
Message-ID: 3CADCDC1.1020908@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-04-05 16:19:04 Re: timeout implementation issues
Previous Message Oleg Bartunov 2002-04-05 16:11:01 Re: [Fwd: AW: UB-Tree's and patents]

Browse pgsql-patches by date

  From Date Subject
Next Message Josh Berkus 2002-04-05 16:30:08 Re: 16 parameter limit
Previous Message Tom Lane 2002-04-05 15:18:58 Re: PQescapeBytea is not multibyte aware