pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Verite <daniel@manitou-mail.org>
To: WR <wolle321@freenet.de>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Differences in Escaped bytea's when creating a plain pg_dump
Date: Thu, 23 Jun 2022 23:14:27 +0200
Message-ID: <488f2958-2417-4086-b138-eafb22e0a3f7@manitou-mail.org> (raw)
In-Reply-To: <a25ed480-5bf0-a9a1-5e97-30471ea023b3@freenet.de>

	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





view thread (9+ messages)  latest in thread

Message-ID: <488f2958-2417-4086-b138-eafb22e0a3f7@manitou-mail.org>
Permalink:  ../488f2958-2417-4086-b138-eafb22e0a3f7@manitou-mail.org/
Also on:    postgresql.org/message-id/488f2958-2417-4086-b138-eafb22e0a3f7@manitou-mail.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: daniel@manitou-mail.org, wolle321@freenet.de
  Subject: Re: Differences in Escaped bytea's when creating a plain pg_dump
  In-Reply-To: <488f2958-2417-4086-b138-eafb22e0a3f7@manitou-mail.org>
  References: <a25ed480-5bf0-a9a1-5e97-30471ea023b3@freenet.de> <488f2958-2417-4086-b138-eafb22e0a3f7@manitou-mail.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox