Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQMql-006Ntm-1k for pgsql-admin@arkaria.postgresql.org; Tue, 02 Dec 2025 09:39:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQMqk-0070fx-29 for pgsql-admin@arkaria.postgresql.org; Tue, 02 Dec 2025 09:39:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with utf8esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQMqk-0070fo-0l for pgsql-admin@lists.postgresql.org; Tue, 02 Dec 2025 09:39:10 +0000 Received: from facteur.thefreecat.org ([2a01:4f8:222:794::2]) by makus.postgresql.org with utf8esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQMqh-002ity-0b for pgsql-admin@lists.postgresql.org; Tue, 02 Dec 2025 09:39:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thefreecat.org; s=thefreecat; t=1764668345; bh=JpNAPX6zwlcCy7TcOmXNOuAaYr6IW2WmPJKj2DqQ9eE=; h=Date:Subject:To:References:From:In-Reply-To; b=D2fMr45zSC8UhkPxAj87IGoEhfRCbUe3ZauBFsA1VpZs8CV6IQkGDZKZuwm3g8v7m D+wwddhpMs9i8Rv2kVle8AgdN0JT7A6bmN6L0CeT4JEtjiK1f9JQ1lO8j2Qjp7gvK3 o4gZzxJ9SQgVVdeHTaEeEVD9PZe2lGRcsUgP85aHfIvBUarfuLK9loVQc1VxL Original-Subject: Re: Importing a Windows database (in en_GB.CP1252) to linux Original-From: Jean-Christophe BOGGIO Received: from [192.168.1.182] (91-167-190-143.subs.proxad.net [::ffff:91.167.190.143]) (AUTH: LOGIN cat, TLS: TLS1.3,128bits,ECDHE_RSA_AES_128_GCM_SHA256) by facteur.thefreecat.org with ESMTPSA id 000000000DA25CF1.00000000692EB3B9.001224D0; Tue, 02 Dec 2025 10:39:05 +0100 Content-Type: multipart/alternative; boundary="------------0RmP1pywMXtW7pL0X1AUtDNb" Message-ID: <74bbf2e7-0120-4b77-96a6-e5d6f4d75619@thefreecat.org> Date: Tue, 2 Dec 2025 10:39:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Importing a Windows database (in en_GB.CP1252) to linux To: Laurenz Albe , "pgsql-admin@lists.postgresql.org" References: <5d7b5d51-a7c7-4cf2-943c-49b93441b8fa@thefreecat.org> From: Jean-Christophe BOGGIO Content-Language: en-US, fr In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------0RmP1pywMXtW7pL0X1AUtDNb Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Laurenz, > That looks like pg_restore sets a wrong client_encoding, which is weird. > > What do you get for > > pg_restore -p 5433 -t csakafl -s -f - imlocal20251127.backup | grep client_encoding SET client_encoding = 'UTF8'; > If the dump was taken from a WINDOWS-1252 encoded database, that line should > read > > SET client_encoding = 'WIN1252'; > > and everything should work fine. But apparently, the client_encoding is set to > UTF-8 in your case. Yes, exactly. > How did that happen? How exactly did you take that dump? This backup is a transfer from an iSeries DB2 database. It has been a nightmare to get this working (and took around 10 days to finalize). We set up a FDW Server using odbc_fdw, recreated all the tables (around 2k) and INSERTed the DB2 data to the PG tables. Then we used PgAdmin that came with PostgreSQL 17 on the Windows machine. I double-checked with the client: the database is in en_GB.CP1252. BTW, if I try to import the same backup on a UTF8 database I get the exact same error (invalid byte sequence 0x92) > Did you do anything (like an encoding conversion) with the dump after you took it? No, the backup is in custom format so I can't touch it (or at least I don't know how I could). Where can I go from here? --------------0RmP1pywMXtW7pL0X1AUtDNb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Laurenz,

That looks like pg_restore sets a wrong client_encoding, which is weird.

What do you get for

  pg_restore -p 5433 -t csakafl -s -f - imlocal20251127.backup | grep client_encoding

SET client_encoding = 'UTF8';

If the dump was taken from a WINDOWS-1252 encoded database, that line should
read

  SET client_encoding = 'WIN1252';

and everything should work fine.  But apparently, the client_encoding is set to
UTF-8 in your case.

Yes, exactly.

How did that happen?  How exactly did you take that dump?

This backup is a transfer from an iSeries DB2 database. It has been a nightmare to get this working (and took around 10 days to finalize). We set up a FDW Server using odbc_fdw, recreated all the tables (around 2k) and INSERTed the DB2 data to the PG tables.

Then we used PgAdmin that came with PostgreSQL 17 on the Windows machine.

I double-checked with the client: the database is in en_GB.CP1252.

BTW, if I try to import the same backup on a UTF8 database I get the exact same error (invalid byte sequence 0x92)

Did you do anything (like an encoding conversion) with the dump after you took it?

No, the backup is in custom format so I can't touch it (or at least I don't know how I could).

Where can I go from here?


--------------0RmP1pywMXtW7pL0X1AUtDNb--