Search Postgresql Archives

Re: Differences in Escaped bytea's when creating a plain pg_dump

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	WR wrote:

> But one question is left.
> 
> When I read this valid data into a c++ std::string (and I checked that 
> the single backslashes are still there). Why can't I put this 
> SQL-command to a pqxx-transaction and execute it. It looks like the 
> pqxx-transaction unescapes the bytea-string and then it finds the 0x00 
> bytes, which are not allowed in text-strings but should be in bytea-strings.

You may check your server logs. They would have the error messages
with the queries as received by the server.

Note that passing '\000'::bytea with a single backslash can be
incorrect if standard_conforming_strings if set to off (not
recommended since version 8.1).
In that case the backslashes need to be doubled.

Example:

postgres=# set standard_conforming_strings to off;
SET

postgres=# set escape_string_warning to off;
SET

postgres=# select '\000'::bytea;
ERROR:	invalid byte sequence for encoding "UTF8": 0x00

postgres=# select '\\000'::bytea;
 bytea 
-------
 \x00
(1 row)


There might also be a problem with how the string is being fed with
the C++ code, but you'd need to show us the code to get feedback
on it.


Best regards,
-- 
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux