dimitri / pgcopydb

Copy a Postgres database to a target Postgres server (pg_dump | pg_restore on steroids)
Other
1.19k stars 78 forks source link

Invalid byte sequence for encoding "UTF8" #874

Open VaibhaveS opened 2 months ago

VaibhaveS commented 2 months ago

pgcopydb assumes that the data is in UTF-8. With a setup like below pgcopydb clone would fail while COPYing.

1. CREATE DATABASE source with encoding 'SQL_ASCII' WITH template0;
2. \c source 
3. CREATE TABLE foo(t TEXT);
4. SET CLIENT_ENCODING = 'SQL_ASCII';
5. INSERT INTO foo VALUES(E'\377');

Since client_encoding is given as utf8 in the COMMON_GUC_SETTINGS, we need to change it according to the one in source.

source=# set client_encoding = 'utf8';
SET
source=# select * from foo;
ERROR:  invalid byte sequence for encoding "UTF8": 0xf