Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jICEa-0000XK-M8 for pgsql-general@arkaria.postgresql.org; Sat, 28 Mar 2020 14:14:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jIC8u-0003db-2R for pgsql-general@arkaria.postgresql.org; Sat, 28 Mar 2020 14:08:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jIC8t-0003b3-LB for pgsql-general@lists.postgresql.org; Sat, 28 Mar 2020 14:08:55 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jIC8q-0001Re-ML for pgsql-general@lists.postgresql.org; Sat, 28 Mar 2020 14:08:54 +0000 Received: from [192.168.127.1] (port=48103 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1jIC8l-000HRi-Rz; Sat, 28 Mar 2020 14:08:47 +0000 Received: from localhost ([127.0.0.1]:18832 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1jIC8l-0009Ig-9E; Sat, 28 Mar 2020 14:08:47 +0000 From: Andrew Gierth To: Matthias Apitz Cc: Thomas Munro , Tom Lane , "pgsql-generallists.postgresql.org" Subject: Re: \COPY to accept non UTF-8 chars in CHAR columns In-Reply-To: <20200328094011.GA2961@c720-r342378> (Matthias Apitz's message of "Sat, 28 Mar 2020 10:40:11 +0100") Message-ID: <87bloga8ce.fsf@news-spur.riddles.org.uk> References: <20200327153623.GA32266@sh4-5.1blu.de> <8922.1585323994@sss.pgh.pa.us> <20200328094011.GA2961@c720-r342378> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (berkeley-unix) Date: Sat, 28 Mar 2020 14:08:47 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Matthias" == Matthias Apitz writes: Matthias> i.e. 0xc3 is translated to 0xc383 and the 2nd half, the Matthias> 0xbc to 0xc2bc, both translations have nothing to do with Matthias> the original split 0xc3bc, and perhaps in this case it Matthias> would be better to spill out a blank 0x40 for each of the Matthias> bytes which formed the 0xc3bc. If the only malformed sequences are there as a result of splitting up valid sequences, then you could do something like convert all invalid sequences to (sequences of) noncharacters, then once the data is imported, fix it up by adjusting how the data is split and regenerating the correct sequence (assuming your application allows this). For example you could encode an arbitrary byte xy as a sequence of two codepoints U+FDDx U+FDEy (the range FDD0-FDEF are all defined as noncharacters). -- Andrew (irc:RhodiumToad)