PQexecParams

Started by Christopher Kings-Lynnealmost 21 years ago6 messages
#1Christopher Kings-Lynne
chriskl@familyhealth.com.au

Will PQexecParams automatically escape bytea data as it goes in, or must
one run it through PQescapeBytea first?

Chris

#2Alvaro Herrera
alvherre@dcc.uchile.cl
In reply to: Christopher Kings-Lynne (#1)
Re: PQexecParams

On Tue, Mar 15, 2005 at 02:02:58PM +0800, Christopher Kings-Lynne wrote:

Will PQexecParams automatically escape bytea data as it goes in, or must
one run it through PQescapeBytea first?

Neither. The data does not need escaping (assuming you pass it as a
parameter, of course.)

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"Los dioses no protegen a los insensatos. �stos reciben protecci�n de
otros insensatos mejor dotados" (Luis Wu, Mundo Anillo)

#3Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Alvaro Herrera (#2)
Re: PQexecParams

Will PQexecParams automatically escape bytea data as it goes in, or must
one run it through PQescapeBytea first?

Neither. The data does not need escaping (assuming you pass it as a
parameter, of course.)

Even binary data? ie. You could upload a binary string straight into
PQexecParams with no octal conversion?

Chris

#4Merlin Moncure
merlin.moncure@rcsonline.com
In reply to: Christopher Kings-Lynne (#3)
Re: PQexecParams

Will PQexecParams automatically escape bytea data as it goes in, or

must

one run it through PQescapeBytea first?

Neither. The data does not need escaping (assuming you pass it as a
parameter, of course.)

Even binary data? ie. You could upload a binary string straight into
PQexecParams with no octal conversion?

Well, what it means you do not have to escape data at the protocol level
you don't have to be concerned about formatting the query string.
However the server still may still need to interpret the data for
storage...meaning for the bytea type at least you have to do octal
encoding (at least that's what I do, I'd like nothing better than to be
corrected on this point).

Merlin

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Merlin Moncure (#4)
Re: PQexecParams

"Merlin Moncure" <merlin.moncure@rcsonline.com> writes:

Even binary data? ie. You could upload a binary string straight into
PQexecParams with no octal conversion?

Well, what it means you do not have to escape data at the protocol level
you don't have to be concerned about formatting the query string.
However the server still may still need to interpret the data for
storage...meaning for the bytea type at least you have to do octal
encoding (at least that's what I do, I'd like nothing better than to be
corrected on this point).

Not if you send the bytea parameter in binary format. If you send it in
text format that's true.

regards, tom lane

#6Merlin Moncure
merlin.moncure@rcsonline.com
In reply to: Tom Lane (#5)
Re: PQexecParams

"Merlin Moncure" <merlin.moncure@rcsonline.com> writes:

Even binary data? ie. You could upload a binary string straight

into

PQexecParams with no octal conversion?

Well, what it means you do not have to escape data at the protocol

level

you don't have to be concerned about formatting the query string.
However the server still may still need to interpret the data for
storage...meaning for the bytea type at least you have to do octal
encoding (at least that's what I do, I'd like nothing better than to

be

corrected on this point).

Not if you send the bytea parameter in binary format. If you send it

in

text format that's true.

Whoops! In fact, my ISAM driver does exactly this. However, it is
still interpreting octal codes returned from the server. This is
because liqpq's restriction to ask for the result in all text/all
binary. However IIRC this is not a restriction of the protocol.

Merlin