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 1lb317-00065m-QO for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 15:19:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lb316-0002e6-PT for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 15:19:20 +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 1lb316-0002dz-D5 for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 15:19:20 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lb310-0001i6-UZ for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 15:19:19 +0000 Received: by mail-ej1-x62c.google.com with SMTP id ja3so9131402ejc.9 for ; Mon, 26 Apr 2021 08:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=W2ILkkHwA08wN4t7x0xJ1jm3LhKxw98XnPr/vPZdVRE=; b=rivjA4ig01Yv/DnaWHlhwz7VhvJnG+ZiAYYiaixYzf+s3Vwo49qCbiKvkO4RluFp0q qnvcl4bbZ+NzRDwiGxxnIETrPwm528PcM8gZ/kCdFS50FFvIDwakNGuC3yr5pV6xZVfS svYfdoMAHj0JzTccdkYA/TlX/cabu/8EaUORvg6wI8troWGRetV/xEYXnrTqaeY2Zrpf y21ImD6jC0zV/2VxOzAaBv+IXPj9jHRBQZpjVMKP0cNE4hwQjNCtBrwlCqVOUYz80SWi 2vkqSBV46wEZ9nNjc+6SLYoa6GtU0d7k1/pPMKY0Io/HavZLRhtHtUk8bL39W0+8Oa6A Gb8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=W2ILkkHwA08wN4t7x0xJ1jm3LhKxw98XnPr/vPZdVRE=; b=cB3TnfG0ovQrSTxu4WsixaSQIPPfsPEYYr9pG21Uj7/LRswfVTo1e/eGnOEjgjruxC pTPXyXWOFM1K6TZg/gX8r0Ia3fZzWIKDNCzryUa7pVhicfAJb2/J8P/niYpoS6WCBW/J 9WApBH94RxDGYn0UqNZFfOWImqX9uLPyvVGqazQ7TvPxqHjlxxMVIYZ69d2i1HydNdyj w/GtxaVHsTji9adzgumk0B77ygFgX7r3u7SJ4KYjm3vgBrN2QKHMtHOHb6444cezbcYf lD/KHf1yMh6wSxIEYXj3SlZtrwVtqIyOqOSXSOY0WetfmSR6HvE4ipnZt62V9hpXv44v Bi9g== X-Gm-Message-State: AOAM532P8ftTDEG/v16px1abGMO8h2QgI6ZHgQk0LqYZGHv+A0+BIkSS p5qilpu9+Oj4+yShjDfRKwnCuw== X-Google-Smtp-Source: ABdhPJwavlMRKWHX81qXnhNOzR7NfuV8CXCiUrizGy1+K8RRnsoWy3CfDeX2UWbEkAc+5BRqlYrQgg== X-Received: by 2002:a17:906:5fce:: with SMTP id k14mr19460084ejv.9.1619450352916; Mon, 26 Apr 2021 08:19:12 -0700 (PDT) Received: from localhost.localdomain (217-149-165-200.nat.highway.telekom.at. [217.149.165.200]) by smtp.gmail.com with ESMTPSA id v5sm94640edx.87.2021.04.26.08.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 08:19:12 -0700 (PDT) Message-ID: <3762f2cd801291ce2092138dcc8db01f64d60082.camel@cybertec.at> Subject: Re: Invalid byte sequence when importing Oracle BLOB From: Laurenz Albe To: Ron , pgsql-general@lists.postgresql.org Date: Mon, 26 Apr 2021 17:19:12 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2021-04-26 at 06:49 -0500, Ron wrote: > The source is an Oracle 12 db with this encoding: > NLS_LANG = AMERICAN_AMERICA.AL32UTF8 > NLS_NCHAR = AL32UTF8 > > 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 > > Is there anything I can change on the Postgresql side to make these records > import correctly? The "bytea" column is probably a red herring - this error message should be caused by a "text" or "varchar" or other string data column. It is surprisingly easy to enter currupt strings into Oracle - just set client encoding to the same value as server encoding, and it won't check the integrity of your strings. If that is your problem, you must identify and fix the data in Oracle. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com