pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Kiran K V <kirankv.1982@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: ERROR: invalid byte sequence for encoding UTF8: 0x00
Date: Tue, 09 Jan 2024 10:48:28 -0500
Message-ID: <2186784.1704815308@sss.pgh.pa.us> (raw)
In-Reply-To: <2f91c83c9529ad677091b3c167292eb5967bbb6e.camel@cybertec.at>
References: <CAGv0ivqrbg6qphPbU-YyKuAb31dVGRWrZC_R8Zdhj3TWbiB=GA@mail.gmail.com>
	<2f91c83c9529ad677091b3c167292eb5967bbb6e.camel@cybertec.at>

Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Tue, 2024-01-09 at 17:48 +0530, Kiran K V wrote:
>> I have a table with bytea column and trying to load the data using copy command.
>> But Copy command is failing with
>> "ERROR: invalid byte sequence for encoding UTF8: 0x00.
>> Why postgresql is failing to load when data contains 0x00.
>> How to resolve this error ? any workaround to load the data with 0x00 values ?

> This is not about loading data into a "bytea", but into a "text", "varchar" or
> "char" column.  Check again.

I am guessing that the OP tried to put a literal NUL character
into the COPY data.  A bytea value in COPY data needs to be
text-encoded as per one of the alternatives explained in the
manual.  Alternatively, you could jump through the hoops involved
in sending binary COPY data.

			regards, tom lane





view thread (19+ messages)

Message-ID: <2186784.1704815308@sss.pgh.pa.us>
Permalink:  ../2186784.1704815308@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2186784.1704815308@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, laurenz.albe@cybertec.at, kirankv.1982@gmail.com
  Subject: Re: ERROR: invalid byte sequence for encoding UTF8: 0x00
  In-Reply-To: <2186784.1704815308@sss.pgh.pa.us>
  References: <CAGv0ivqrbg6qphPbU-YyKuAb31dVGRWrZC_R8Zdhj3TWbiB=GA@mail.gmail.com> <2f91c83c9529ad677091b3c167292eb5967bbb6e.camel@cybertec.at> <2186784.1704815308@sss.pgh.pa.us>

* 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