Re: PQescapeBytea* version for parameters - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: PQescapeBytea* version for parameters
Date
Msg-id 87hcod8dgv.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: PQescapeBytea* version for parameters  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
"Tom Lane" <tgl@sss.pgh.pa.us> writes:

> Gregory Stark <stark@enterprisedb.com> writes:
>> Do we want something like this which provides a PQescapeByteaParam for
>> escaping bytea strings before passing them as text-mode parameters in
>> PQexecParam?
>
> Seems a lot easier and more efficient to just pass out-of-line bytea
> parameters as binary mode.

Well that's definitely true. The case in hand was a PHP where the PHP driver
doesn't seem to automatically use binary mode and doesn't provide any way for
the application to select it either. 

It expects the user code to handle the escaping for all parameters using
PQEscape* functions. But there is no candidate function to handle bytea ascii
parameters. I'm sure it can be done in PHP directly though.

Incidentally it seems even using PQEscapeBytea with standard conforming
strings set is still corrupting the byteas so there may be an actual bug
somewhere. Haven't had a chance to look into it yet though.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: psql/pg_dump vs. dollar signs in identifiers
Next
From: "Florian G. Pflug"
Date:
Subject: ReadRecord, EndRecPtr and XLOG_SWITCH