Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4U9x-00048d-7R for pgsql-general@arkaria.postgresql.org; Thu, 23 Jun 2022 21:14:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o4U9v-0000Jt-Sa for pgsql-general@arkaria.postgresql.org; Thu, 23 Jun 2022 21:14:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4U9v-0000JT-Hj for pgsql-general@lists.postgresql.org; Thu, 23 Jun 2022 21:14:39 +0000 Received: from mail.verite.pro ([185.16.44.216]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4U9o-00066d-Kk for pgsql-general@lists.postgresql.org; Thu, 23 Jun 2022 21:14:38 +0000 Received: by mail.verite.pro (Postfix, from userid 1000) id 52FB78C00EB; Thu, 23 Jun 2022 23:14:29 +0200 (CEST) Content-Type: text/plain; charset="iso-8859-15" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "Daniel Verite" Subject: Re: Differences in Escaped bytea's when creating a plain pg_dump To: "WR" Cc: "pgsql-general" In-Reply-To: Date: Thu, 23 Jun 2022 23:14:27 +0200 Message-Id: <488f2958-2417-4086-b138-eafb22e0a3f7@manitou-mail.org> X-Mailer: Manitou v1.7.3 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk WR wrote: > But one question is left. >=20 > When I read this valid data into a c++ std::string (and I checked that=20 > the single backslashes are still there). Why can't I put this=20 > SQL-command to a pqxx-transaction and execute it. It looks like the=20 > pqxx-transaction unescapes the bytea-string and then it finds the 0x00=20 > bytes, which are not allowed in text-strings but should be in bytea-strin= gs. 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=3D# set standard_conforming_strings to off; SET postgres=3D# set escape_string_warning to off; SET postgres=3D# select '\000'::bytea; ERROR: invalid byte sequence for encoding "UTF8": 0x00 postgres=3D# select '\\000'::bytea; bytea=20 ------- \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, --=20 Daniel V=E9rit=E9 https://postgresql.verite.pro/ Twitter: @DanielVerite