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 1lb1WK-00035R-15 for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 13:43:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lb1WI-0007bz-Vx for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 13:43:26 +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 1lb1WI-0007bq-Lb for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 13:43:26 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lb1WG-0006LC-OB for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 13:43:26 +0000 Received: by mail-oi1-x22a.google.com with SMTP id m13so56436362oiw.13 for ; Mon, 26 Apr 2021 06:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=TIrLzMmF2ny4yPtgi19GAXquF99PkK8WSVnwOQuyyTY=; b=A/YZN8n0p6+BVFF1o3VnXQ6Dow3LDAQA6AhofmE73V6XrfNTm7L04OmftjgT/bTsA4 lCwOi5zmxvJDAClpTjsrvEq+yNVJBw1LrpxOTvTZ3zg6UWYUpm7+dIex/5Dmd3khXrZn s/d3IOVepq77v09yi2/I+iNES2A+6n4xMBlo0jRzbjxQBLYHHEU5CvmQ4fhKhNI6hGaV zAFffE4fT2UDx5flkgCGSPX/CzPeFhfe9UQM4gVs6n4Rb52y8xgbJAyao3qvd58k4Tuu zLpEfVGBEyto3SoSGmPxHULuLyjMz88i1D67rEZ4EqlH4WI2hz+l0sdn3KXLTd5Ay2zY izQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=TIrLzMmF2ny4yPtgi19GAXquF99PkK8WSVnwOQuyyTY=; b=TS/FsMsAcSEgDDlo5OffxaMLb96hjxvIgViBWGQ/v98gZ6FuGoSBVWLuu6Jr/zyv5l kSWPQD6ZIvn2qt3bT8K+ZWoQ+srgyIfTNqimQZzbxF0rig3tCor9IbfOybrYaZs/lsep /nR7cMgvGnnrYMHHoai5QdbkirChpZA5ZDCLNhCJcvK3tEIcT7XnO48U3ZHl7xNhUgjv FMpAMLxDkcDUCEWQJQ++iSfNLg9S9T0UwqzEMkE8htCLvUdgYbaJ/l2Iyeev0G40R/8i sQvrnG6TcTg3ErOQ3+OBSGsng0FhT7dTMklJVfGSJZLFwH8I/A8QamhrUV/W0MoUiyfO ps4g== X-Gm-Message-State: AOAM530djXjvjKbnrpaANKsLbigWr4z++8tBiGdFGS5dnK8o8geSx8jh +0RdNukgz7OgCsc5gOtx72DlBlPJ3Sk= X-Google-Smtp-Source: ABdhPJwaiJxOVnE0PLxv3ejNVu5Nxh5ENtJgN2eR8ABqT6dvCJD9cGzYdTVUy4s5+XSYlxrho+4zAg== X-Received: by 2002:aca:c74c:: with SMTP id x73mr12313586oif.100.1619444602321; Mon, 26 Apr 2021 06:43:22 -0700 (PDT) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id g5sm3061702oiy.24.2021.04.26.06.43.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 06:43:21 -0700 (PDT) Subject: Re: Invalid byte sequence when importing Oracle BLOB To: pgsql-general@lists.postgresql.org References: <20210426123259.GB26434@hjp.at> <20210426125834.GC26434@hjp.at> From: Ron Message-ID: <5f0a7a66-0df5-2dda-8e20-de4a67330d2b@gmail.com> Date: Mon, 26 Apr 2021 08:43:20 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210426125834.GC26434@hjp.at> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/26/21 7:58 AM, Peter J. Holzer wrote: > 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 is being >>>> loaded through COPY commands generated by ora2pg. >>>> >>>> The source table has a BLOB column (I think they are scanned images) which >>>> I'm loading into a Postgresql bytea column. >>>> >>>> Seven times out of about 60M rows, I get this error: >>>> Psql:909242: ERROR:  invalid byte sequence for encoding "UTF8": 0xed 0xaf 0xbf >>> Decoding UTF8 doesn't make sense for a bytea column. How does that data >>> look like in the file generated by ora2pg? >> 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,employer_response_id,attachment_id_code,file_type,attachment_desc,attachment_size,file_name,partition_date,prior_incident_id,part_date) >> FROM STDIN; >> 1583201 \\x255044462d312e330d25e2e3cfd30d0a31362030206f... > ... 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. That's a good idea.  Thanks. -- Angular momentum makes the world go 'round.