Re: PQunescapebytea not reverse of PQescapebytea?

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: PQunescapebytea not reverse of PQescapebytea?
Дата
Msg-id
15482.1393730391@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
PQunescapebytea not reverse of PQescapebytea? Karthik Segpi <karthik.segpi@gmail.com>
Re: PQunescapebytea not reverse of PQescapebytea? Tom Lane <tgl@sss.pgh.pa.us>
Karthik Segpi  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

В списке pgsql-general по дате отправления
От: Steve Atkins
Дата:
Сообщение: Re: Replacing Ordinal Suffixes
От: George Weaver
Дата:
Сообщение: Re: Replacing Ordinal Suffixes
FAQ