Re: Importing a Windows database (in en_GB.CP1252) to linux - Mailing list pgsql-admin

From Jean-Christophe BOGGIO
Subject Re: Importing a Windows database (in en_GB.CP1252) to linux
Date
Msg-id 4856dd3a-f42b-48ce-8837-7792a1114206@thefreecat.org
Whole thread Raw
In response to Re: Importing a Windows database (in en_GB.CP1252) to linux  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-admin
Laurenz,

Thanks a lot for your quick reply.

Le 02/12/2025 à 12:26, Laurenz Albe a écrit :
>> I double-checked with the client: the database is in en_GB.CP1252.
> The DB2 database or the PostgreSQL database?
>
> It must be the DB2 database, because otherwise the dump would contain

No: the PostgreSQL one. I guess the DB2 is encoded (internally) in 
EBCDIC... Yes... At least that's what CSV exports directly made from the 
DB shows.

> My best guess is that odbc_fdw has a bug that does not check if the strings are
> properly encoded, and you somehow got corrupted data in your PostgreSQL database.
> But I am not sure.

I don't know really but I could have the client do some tests on tables 
that we know contain invalid byte sequences. Maybe I could try doing 
manual pg_dumps with different -E parameter to verify that it's not 
something enforced by pgAdmin.

> You can try the following:
>
> - convert the custom format dump into an SQL script with
>
>    pg_restore -f script.sql imlocal20251127.backup
>
> - edit script.sql and change the line to read
>
>    SET client_encoding = 'WIN1252';
>
> - restore that dump with "psql":
>
>    psql -f script.sql -d newdb
>
> That should work if *all* the strings are in WINDOWS-1252 encoding.

Thanks a lot for the proposal. It seems to be doing the job!

It's running right now and so far no "bad encoding" error appeared (it's 
a 311Gb backup so it will take some time). I'll let you know.

Gratefully,

JC





pgsql-admin by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Importing a Windows database (in en_GB.CP1252) to linux
Next
From: Raj
Date:
Subject: Re: Migration from MSSQL to POSTGRESQL