Libpq: PQunescapeBytea

From: "CN" <cnliou9(at)fastmail(dot)fm>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Libpq: PQunescapeBytea
Date: 2007-03-22 13:36:28
Message-ID: 1174570588.12521.1180808513@webmail.messagingengine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi!

I write binary strings to bytea column by calling PQexecParams and
passing "1" indicating a binary data to parameter paramFormats. This
function is handy of course because there is no need to escape the
to-write binary strings before calling PQexecParams.

Now I notice that in order to restore the string to its original form
(the binary string without escaped), I will call PQgetvalue and pass its
returned value to PQunescapeBytea.

What I don't understand are these two parts of manual (Chapter 29. libpq
- C Library):

[quote]
PQunescapeBytea

Converts a string representation of binary data into binary data — the
reverse of PQescapeBytea. This is needed when retrieving bytea data in
text format, but not when retrieving it in binary format.
[end quote]

Question: Does it mean that there exist some functions being able to
retrieve bytea columns in "binary format"? My understanding of its
meaning is that these functions will automatically restore the data read
from database to their original unescaped binary strings and thus
PQescapeBytea needs not to be called. If it does, what are these
functions? PQgetvalue appears to be not one of them I think.

[quote]
This conversion is not exactly the inverse of PQescapeBytea, because the
string is not expected to be "escaped" when received from PQgetvalue.
[end quote]

Question: Would someone kindly help me understand the above sentence?

TIA
CN

--
http://www.fastmail.fm - Choose from over 50 domains or use your own

Browse pgsql-interfaces by date

  From Date Subject
Next Message CN 2007-03-23 13:11:17 Re: Libpq: PQunescapeBytea
Previous Message Devrim GÜNDÜZ 2007-03-22 07:00:34 Re: Postgres 8.1.4