Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lb0p0-0001mp-A6 for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 12:58:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lb0oz-0002UK-2W for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 12:58:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lb0oy-0002UD-QW for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 12:58:40 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lb0ow-0005vu-9o for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 12:58:40 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id D6DCD4A0F; Mon, 26 Apr 2021 14:58:34 +0200 (CEST) Date: Mon, 26 Apr 2021 14:58:34 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Invalid byte sequence when importing Oracle BLOB Message-ID: <20210426125834.GC26434@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <20210426123259.GB26434@hjp.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jousvV0MzM2p6OtC" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --jousvV0MzM2p6OtC Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-04-26 07:45:26 -0500, Ron wrote: > On 4/26/21 7:32 AM, Peter J. Holzer wrote: > > On 2021-04-26 06:49:18 -0500, Ron wrote: > > > The destination is an (RDS) Postgresql 12.5 with encoding UTF8, and i= s being > > > loaded through COPY commands generated by ora2pg. > > >=20 > > > The source table has a BLOB column (I think they are scanned images) = which > > > I'm loading into a Postgresql bytea column. > > >=20 > > > Seven times out of about 60M rows, I get this error: > > > Psql:909242: ERROR:=A0 invalid byte sequence for encoding "UTF8": 0xe= d 0xaf 0xbf > > Decoding UTF8 doesn't make sense for a bytea column. How does that data > > look like in the file generated by ora2pg? >=20 > I thought it was weird, too, but COPY has to read text, no? Yes, but data for a bytea column would normally be encoded in hex or something like that ... > COPY mv_response_attachment_old (response_attachement_id,binary_data,empl= oyer_response_id,attachment_id_code,file_type,attachment_desc,attachment_si= ze,file_name,partition_date,prior_incident_id,part_date) > FROM STDIN; > 1583201 \\x255044462d312e330d25e2e3cfd30d0a31362030206f... =2E.. Yes, like this. There are only hex digits (plus \ and x) in the column, nothing which would require decoding UTF-8. My guess is that the error is actually in the data for another column. I'd try to identify the broken records and check whether they contain some other strange content. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --jousvV0MzM2p6OtC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmCGuPYACgkQ8g5IURL+ KF2EPA//RPRxhszXqqdIkN/ZCXXlmB2GaTRTpJGekMkaA1GkbFJt43nykdk1cTzN nAfdeW3a/JcK2DxJMTzm6Pot9OsleElznLkkmhIQZFvOwZYbkgKEBtIhc1NBSmUW 1orJuiMJ/WHQGk1Cg58VDj2ucCdL2LNiSYAycjXdXDeWEl67Q+NTJjZN4TCFMclO xuN33H+6g+O3sMTPbXKH+hzf8HQfSqN2daQ37soJyBl17NhOwG/9O0rgBtg6oGQc iTRnyMtKjnSTIWXt1u+w54F1lspMpl/9jEY/5KoTYkinJHFuAEaotmMV9ULdszuz A0+xoWTVQhn0UwlrhwWguFxsWDdnFQoBiu2TQ5SJVMCOi24Py2YNeRQjiOPBvpOK hKiGils7fSn++omD7JCuLQA97DS1VsRpNch0Z9b0r4CLwgx+4AE5v0LVYytUCjDy hlBUN85ZlIpmysvKLQncl692iBH6yjrQNNJktx06XR4BPEWRFWQEWaSU3l6Hp351 s9C0YOY1+n4SpuNEtgUPu1Q7nEPskTRbGnbIvXhAmnHWF2/AuNCzDER40WLVzjDb U+XvIhhQ/zik9jbvwc+dm7mqn0BxQhPvCqiidtrKEJVoJlD+ybgJ6slpCBa3MBdj AtQit6BeQH3NKFUSEaDI4iyM3cH1EpMbL5VUyPE70xbeTQPd04A= =abaV -----END PGP SIGNATURE----- --jousvV0MzM2p6OtC--