From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Karthik Segpi <karthik(dot)segpi(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PQunescapebytea not reverse of PQescapebytea? |
Date: | 2014-03-02 03:19:51 |
Message-ID: | 15482.1393730391@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Karthik Segpi <karthik(dot)segpi(at)gmail(dot)com> writes:
> I have a 'bytea' column in the database, onto which my custom C application
> is inserting encrypted data. Before inserting, I am calling
> 'PQescapebytea()' to escape the ciphertext. However, after SELECT, the data
> needs to be 'un-escaped' before attempting to decrypt. I am trying to
> 'un-escape' using 'PQunescapebytea'. However, I am finding that
> 'PQunescapebytea' is not exact inverse of 'PQescapebytea'.
It's not supposed to be, as the fine manual points out:
This conversion is not exactly the inverse of PQescapeBytea, because the
string is not expected to be "escaped" when received from PQgetvalue. In
particular this means there is no need for string quoting considerations,
and so no need for a PGconn parameter.
If you're having problems, it's probably because you are misusing one
function or the other. A likely bet is that you're passing the output
of PQescapeBytea through some additional processing rather than just
sticking it into an INSERT statement with single quotes around it.
But it's impossible to be sure without seeing a detailed example of
what you're doing, on both the insertion and extraction sides.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | George Weaver | 2014-03-02 04:08:56 | Re: Replacing Ordinal Suffixes |
Previous Message | Steve Atkins | 2014-03-02 01:31:20 | Re: Replacing Ordinal Suffixes |