BUG #15261: Insert binary data in bytea rejected due to UTF-8 encoding errors

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: brice(at)famille-andre(dot)be
Subject: BUG #15261: Insert binary data in bytea rejected due to UTF-8 encoding errors
Date: 2018-07-04 11:02:26
Message-ID: 153070214603.13259.8727718773496971274@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15261
Logged by: Brice André
Email address: brice(at)famille-andre(dot)be
PostgreSQL version: 9.6.7
Operating system: debian stretch
Description:

Dears,

I have a database using UTF-8 encoding and, in which I have bytea columns
where I store binary data.

I followed instructions in
https://www.postgresql.org/docs/9.6/static/datatype-binary.html to encode
the binary data, but it is still rejected due to a "ERROR: invalid byte
sequence for encoding "UTF8"" error.

I wrote a small script that reproduces the problem in a small database. The
script can be simply copy-pasted in a psql session:

CREATE DATABASE test WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE
= 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
\connect test;
CREATE TABLE test (test bytea);
insert into test (test) values (E'\xC744'::bytea);

Regards,

Brice

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message gpd 2018-07-04 11:13:39 RE: BUG #15261: Insert binary data in bytea rejected due to UTF-8 encoding errors
Previous Message Jeff Janes 2018-07-04 01:42:31 Re: NOTIFY does not work as expected