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 1vQOX6-006hJp-27 for pgsql-admin@arkaria.postgresql.org; Tue, 02 Dec 2025 11:27:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQOX4-007QNg-1c for pgsql-admin@arkaria.postgresql.org; Tue, 02 Dec 2025 11:26:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQOX4-007QNJ-0L for pgsql-admin@lists.postgresql.org; Tue, 02 Dec 2025 11:26:58 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vQOX2-002iqb-1S for pgsql-admin@lists.postgresql.org; Tue, 02 Dec 2025 11:26:57 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b725ead5800so708992966b.1 for ; Tue, 02 Dec 2025 03:26:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1764674815; x=1765279615; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=zl4XTOtgDgqk+wGCJkBVgK3ecVKY2+9jU+ilvJCdCEc=; b=TnR5S4oLpuwc7D2+N+MYL8itRaCrr9E2bMfPChpeJuM+mvybS8N1EG7igkyOq0RhTj t+IEaVwIk3ce9ZdqF3BoS7ORiDod0ly7QFz++IrrhzJqa4AIzZdXG6zYQDM1H7TLOqJ2 sr7SwYCshSw7d8UXN933j7+JyOgrTqF/GKuQ0y8QIMCn9e0E9AGY+fN+Ui77pkkO0eE6 W1IB6bo1n4qvJtEoDO5OzP7qrzG2iPh/yVkdi1yxTiAybSa7HnkvvMgtpj51bzVdurmD McquZN7w+E6JMqDoeKg/ijhDSXf87agHCROkq4H4iijbsRJ/rrEPCIjSzOV3dMPZmuJy iJ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764674815; x=1765279615; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zl4XTOtgDgqk+wGCJkBVgK3ecVKY2+9jU+ilvJCdCEc=; b=gxcwB1cjRdW8WylBOPdAnf/IhZl2M2J62sZFHa1R0froAAl5ZBjHB/g1nO1QmhpfNs rOg0UGEui+WfmdsX1qHThvSCchDRoNjwgixBkaEhQ0TC0vqtxezABN8QVdS/XXx0F78O 1bcj1uBwDdIcN38SID+9H3Nwat4keA1NEBsmK3FoNY8BCpttu5YBaBbyL8gbl784O1cE RQ4FI/mtDM40S3SHt6ogawMyCh/YqYB1tagRb/1YxaL96v9VtjJPsNSTEGdblWBHRZnC zHj3vrnxSDG1UbHof8uCRC++ruxXNO6WL8G95EyeZf/YF9kD+gVINS6Atv8i1Ddk3H7z KReg== X-Forwarded-Encrypted: i=1; AJvYcCXbG287uvvMF9ERjLKPdjVsGqoKW1KHsyVSTvXcOYlsgls6YrWdyCmzNmkWBX5bC8CeprZ7G25F+iW7Tw==@lists.postgresql.org X-Gm-Message-State: AOJu0Yz1PBMMHr1aPYdAQ3OA9DF4UO85WTnbLP31MPpCzz5sbRLShM9T GiBA1Z4XXfVRoWYZHRnht5BeDDCcrHAKpB2EUJei1U6h4MvybaAUsQ0dUX5NKu49d+U= X-Gm-Gg: ASbGncvaxsQ3zVnUBB+LHALEgo3Pqk/rJIGt/RBus0uuKFzFDyhh0aeSk+/kv8DTLXt mM0bY/7cdJ87hAiNw3RFCQ0Yvpy7yp1qm4fdgq8lKfcu/cUPZf0Fq7f1uGKF1I6rOMv2nCrN15k iApqhpj7kdJG/Ss8PvtzYgolBDl/HFVsxNyXmS8L9H2BQtpHjeA3UiOOZLxbI9PJhRy5Xpckc7G sovZgDRLTHXAXh586818AJvDmz+qlGr8SaCaINuiHc/JUcHwBOqjxJGDm64//I6/2DG6bsDeeuU z6d59FbG5GHABDU+u2k0DfTNG4lVo3RzP0o0u4i3osHYYMD/tz5SUklqXXobi6iS63Um8T1PKl+ u7vnvsdb5phXMWXeZYvfdtSTDTSiY0fh47pb1S7pxudjirA4CQGlF9eZvAvQ/foPziHXNEgwLuK 9VeqxPrePrkL7w1nOML7d2ZQG/RQBNCnWioU7yeENn X-Google-Smtp-Source: AGHT+IFMlR/wYfeMTWKLsum93tGB5bFbvk6rAkbsFSmCrz14B5iSuqahOjk765AxnOTYuJZBQMi5xw== X-Received: by 2002:a17:907:a09:b0:b76:7b8c:a6a2 with SMTP id a640c23a62f3a-b76c5513f0amr3324182866b.30.1764674815273; Tue, 02 Dec 2025 03:26:55 -0800 (PST) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:4d50:82d5:e2a3:8d7d:8548]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b76f5162d3esm1511483966b.8.2025.12.02.03.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Dec 2025 03:26:55 -0800 (PST) Message-ID: Subject: Re: Importing a Windows database (in en_GB.CP1252) to linux From: Laurenz Albe To: Jean-Christophe BOGGIO , "pgsql-admin@lists.postgresql.org" Date: Tue, 02 Dec 2025 12:26:54 +0100 In-Reply-To: <74bbf2e7-0120-4b77-96a6-e5d6f4d75619@thefreecat.org> References: <5d7b5d51-a7c7-4cf2-943c-49b93441b8fa@thefreecat.org> <74bbf2e7-0120-4b77-96a6-e5d6f4d75619@thefreecat.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-12-02 at 10:39 +0100, Jean-Christophe BOGGIO wrote: > > That looks like pg_restore sets a wrong client_encoding, which is weird= . > >=20 > > What do you get for > >=20 > > =C2=A0=C2=A0pg_restore -p 5433 -t csakafl -s -f - imlocal20251127.backu= p | grep client_encoding >=20 > SET client_encoding =3D 'UTF8'; >=20 >=20 > > How did that happen? How exactly did you take that dump? >=20 > This backup is a transfer from an iSeries DB2 database. It has been a nig= htmare to > get this working (and took around 10 days to finalize). We set up a FDW S= erver using > odbc_fdw, recreated all the tables (around 2k) and INSERTed the DB2 data = to the PG tables. >=20 > Then we used PgAdmin that came with PostgreSQL 17 on the Windows machine. >=20 > 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 SET client_encoding =3D 'WIN1252'; That is, unless you created the dump with pg_dump --encoding=3DUTF8 But then, the dump couldn't contain non-UTF-8 characters. Having used pgAdmin, you probably don't know the pg_dump command line that = was used. 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 dat= abase. But I am not sure. > > Did you do anything (like an encoding conversion) with the dump after y= ou took it? >=20 > No, the backup is in custom format so I can't touch it (or at least I don= 't know how I could). >=20 > Where can I go from here? 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 =3D 'WIN1252'; - restore that dump with "psql": psql -f script.sql -d newdb That should work if *all* the strings are in WINDOWS-1252 encoding. Yours, Laurenz Albe