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 1lb0cm-0001NB-VW for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 12:46:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lb0cG-000188-9U for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 12:45:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lb0cF-000180-VQ for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 12:45:32 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lb0cD-0000QA-5g for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 12:45:30 +0000 Received: by mail-ot1-x331.google.com with SMTP id 35-20020a9d05260000b029029c82502d7bso20505301otw.2 for ; Mon, 26 Apr 2021 05:45:29 -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=nD5xNA76dZxxp1PBRRVs2z09Vc79f2GyPakd0HVwojQ=; b=KA1uTRfQwbt2psXRIMHslgx4nOuHcSmX2PNwICEFPczkb0EODM1PkrHMwaq9fFCSPt Qu7/1sSy1xpGN6oRlutAFQFhjiBtGjg/jHP9yNXHH6D3NuRqV1MNOgXgExCqtHZPknrb 618TTkVgXewzPGmBRpwxQivi5Xgm/wIX6xvAuaDVHFJdseWrlv26Vyc1xjKbc7X4JHKb XzB1f9a9cql6EEeDxsdaPc/jGrU584el6ELB/Jfry58WWroHdeNFOMaxukR6ycUJugLm Tdl4X0qFSLOy+vhzxI1G7+PNdCv+hezdQv9STips/Zhctc+isfqF2rH/ccIkNMSK9g+x wBpQ== 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=nD5xNA76dZxxp1PBRRVs2z09Vc79f2GyPakd0HVwojQ=; b=AoWxTatq+1eoSdB4atEXsQTHCVsilbJQ9Mlw9iVnVx2oOQCCZzvE9ftN0YWjLFBgcv I1twK/qMtp+REZg4stiw6p/NI8t+A/YXtNd1Wj+GUj6KEdofNEaClxZYFFwRjS1WE9pm eMDbxsuk+71W526rKvnXF+IndUtxptFOLR/3JlqKORBZ0Jr1bXDdl9SbnSMILc0QorYn O1eQA3CSDofg2NV/T6cPIoZppvMi/Oby4dXJtnRpz/vrHx+IzmFc91URhdH8ThaNkfye DVUGugdHVJwdA/3janxYNp2WRMZ9FwKqHEK0t1CodFVFXBDdX13o7TW0vcoXfooI4gxl PZGA== X-Gm-Message-State: AOAM532JYfGWEbqnVgSiSHxzCoPlUX5cZKi517rcqCHE4Etcp9gFXcuy sykxP+FWDX56D1k1Ayyhai8UOa4YXU4= X-Google-Smtp-Source: ABdhPJwPfqYD1g0rlpZN3Z4Ig99zIICCjXLuuxrx4LUaHkQdrF3WU0jQK5sd5/EPcWTztnoqICwjaw== X-Received: by 2002:a05:6830:1d6:: with SMTP id r22mr4573032ota.43.1619441127980; Mon, 26 Apr 2021 05:45:27 -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 b12sm3444852oti.17.2021.04.26.05.45.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 05:45:27 -0700 (PDT) Subject: Re: Invalid byte sequence when importing Oracle BLOB To: pgsql-general@lists.postgresql.org References: <20210426123259.GB26434@hjp.at> From: Ron Message-ID: Date: Mon, 26 Apr 2021 07:45:26 -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: <20210426123259.GB26434@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: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? Anyway, here are the first 8 lines (beware line wrapping) of the input file: SET client_encoding TO 'UTF8'; SET synchronous_commit TO off; SET search_path = strans,public; TRUNCATE TABLE mv_response_attachment_old; 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... It looks like a bog-standard COPY command, with which I've imported a lot of data. -- Angular momentum makes the world go 'round.