pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wolfgang Rißler <wolfgang.rissler@freenet.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: Differences in Escaped bytea's when creating a plain pg_dump
Date: Mon, 27 Jun 2022 13:00:45 +0200
Message-ID: <b08ea140-4678-1fee-ed80-38740e009440@freenet.de> (raw)
In-Reply-To: <f15fa1a1-7a06-4124-aa23-5ec5731542a7@manitou-mail.org>
References: <f15fa1a1-7a06-4124-aa23-5ec5731542a7@manitou-mail.org>

Am 27.06.2022 um 12:12 schrieb Daniel Verite:
> 	WR wrote:
> 
>> First run worked.
>> Second run worked.
>> Then I changed to SET standard_conforming_strings = off;
>> Third run worked.
>> Fourth run throw the error
>> Then I changed back to  SET standard_conforming_strings = on;
>> Fifth run throw the error too.
>> And only adding E and second backslash helped.
> 
> This kind of unstable behavior can be seen if the SET may not be
> executed by the same session (same connection to the server) as the
> subsequent queries.
> SET affects only the session it's being run in.
> 
> For instance a connection pooler configured in statement mode may
> produce that behavior. The solution in the case of a connection pooler
> is to group related statements into a transaction.
> 
> Maybe pgAdmin has a pooler like that, but if you're issuing the statements
> in the same SQL window, I would find it quite surprising that it doesn't
> run them by the same session.
> Or maybe you're mixing queries from different SQL windows that each
> have their own connection, and in some cases you do the SET
> in a window and the INSERT in another window.
> Or maybe it's a pgAdmin bug.
> 
> 

Ok, thank you Daniel,

in all tests I put the SET statement before the INSERT in the same query 
tool and run it as a whole. (no statement was marked by mouse for single 
execution). So I agree with you, that one transmission is used by 
pgAdmin to run SET and INSERT.
I always had a SET before each INSERT, so there could be no unknown 
state of standard_conforming_strings, no matter if pdAdmin uses 
different connections for each run of the script or the same again.

The supplement of the second backslash in the c++ code costs me some 
nerves. Sending an statement std::string without doublebackslashes to 
pqxx::transaction results in the "0x00 is not a valid UTF8 sequence" 
error 21020 (as I wrote already). I'm afraid, I can't simply replace all 
backslashes in the whole dumptext with two of them.
Since I found out now, that psql works nice with my dumpfiles, maybe its 
easier, to call psql from my code and not to use a pqxx::transaction. So 
I can also save myself loading the dump from the sql-file. The more I 
think about it, the more I love this idea.

Thanks a lot, Wolfgang


-- 

Wolfgang Rißler
mailto: wolfgang.rissler@freenet.de
mobil: +49 1520 9191759
- may the source be with you -





view thread (9+ messages)

Message-ID: <b08ea140-4678-1fee-ed80-38740e009440@freenet.de>
Permalink:  ../b08ea140-4678-1fee-ed80-38740e009440@freenet.de/
Also on:    postgresql.org/message-id/b08ea140-4678-1fee-ed80-38740e009440@freenet.de

 · 

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: wolfgang.rissler@freenet.de
  Subject: Re: Differences in Escaped bytea's when creating a plain pg_dump
  In-Reply-To: <b08ea140-4678-1fee-ed80-38740e009440@freenet.de>
  References: <f15fa1a1-7a06-4124-aa23-5ec5731542a7@manitou-mail.org> <b08ea140-4678-1fee-ed80-38740e009440@freenet.de>

* 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