pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: WR <wolle321@freenet.de>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Differences in Escaped bytea's when creating a plain pg_dump
Date: Mon, 27 Jun 2022 08:44:59 +0200
Message-ID: <28b43f01-6fa0-e424-73e7-c6ba8435dd31@freenet.de> (raw)

I'm back at my problem today:



> 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)

I made some test with pgadmin. Pgadmin (5.2) also reports this error 
now. And it doesn't matter if standard_conforming_strings is on or off.


SET standard_conforming_strings = off;

INSERT INTO public.oned_figures VALUES (1, 'Figure_Wolle1', 476, -476, 
2000, 2400, 2400, '\000', 500, 0, 'sinus(0|0|0;30;5;0;0,5;0)', 
'2021-08-31 11:53:22.442801', 0, 1);

And

SET standard_conforming_strings = on;

INSERT INTO public.oned_figures VALUES (1, 'Figure_Wolle1', 476, -476, 
2000, 2400, 2400, '\000', 500, 0, 'sinus(0|0|0;30;5;0;0,5;0)', 
'2021-08-31 11:53:22.442801', 0, 1);


Both do report:

WARNUNG:  nicht standardkonforme Verwendung von Escape in 
Zeichenkettenkonstante
LINE 8: ...(1, 'Figure_Wolle1', 476, -476, 2000, 2400, 2400, '\000\000&...
                                                              ^
HINT:  Verwenden Sie die Syntax für Escape-Zeichenketten, z.B. E'\r\n'.

ERROR: FEHLER:  ungültige Byte-Sequenz für Kodierung »UTF8«: 0x00


The warning can be avoided by adding the E before the string constant.

The only solution to avoid the error is, to double-backslash.

INSERT INTO public.oned_figures VALUES (1, 'Figure_Wolle1', 476, -476, 
2000, 2400, 2400, E'\\000', 500, 0, 'sinus(0|0|0;30;5;0;0,5;0)', 
'2021-08-31 11:53:22.442801', 0, 1);

I also  dumped the table again after INSERT, and the data was correct 
(but again without E and with single backslash)

What I cant understand: why does pg_dump produce the string without the 
E and without double-backslash, when it is needed? Now I have to write a 
correction routine in c++, what fixes the dumps, before using them.


-- 
May the source be with you





view thread (9+ messages)  latest in thread

Message-ID: <28b43f01-6fa0-e424-73e7-c6ba8435dd31@freenet.de>
Permalink:  ../28b43f01-6fa0-e424-73e7-c6ba8435dd31@freenet.de/
Also on:    postgresql.org/message-id/28b43f01-6fa0-e424-73e7-c6ba8435dd31@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: wolle321@freenet.de, daniel@manitou-mail.org
  Subject: Re: Differences in Escaped bytea's when creating a plain pg_dump
  In-Reply-To: <28b43f01-6fa0-e424-73e7-c6ba8435dd31@freenet.de>
  References: <28b43f01-6fa0-e424-73e7-c6ba8435dd31@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