Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qygae-00AFIE-Me for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2023 22:55:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qygac-00G3OA-25 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2023 22:55:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qygab-00G3O2-DF for pgsql-hackers@lists.postgresql.org; Thu, 02 Nov 2023 22:55:01 +0000 Received: from buffalo.tulip.relay.mailchannels.net ([23.83.218.24]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qygaV-004Ocf-OI for pgsql-hackers@postgresql.org; Thu, 02 Nov 2023 22:55:00 +0000 X-Sender-Id: dreamhost|x-authsender|nico@cryptonector.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5CD4490244F; Thu, 2 Nov 2023 22:54:53 +0000 (UTC) Received: from pdx1-sub0-mail-a250.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0DAC99023FB; Thu, 2 Nov 2023 22:54:53 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1698965693; a=rsa-sha256; cv=none; b=xk7wn3fS+DsJB+td53zoTk17jV26nAXOkUYyqGMx95UherYzLo1/x0J3Ip2Cc6s2ChleKU bAufgmLP28jLX98oXDSXXo5tbWnZHGJD6K4qYMSvgch6j4fecs90r1jXctmEdPLkxwM97h t13mONytoNjGr0M4sAiMOshiTq1B295QmAGp7PmMApvVfxoRfyyJxumDsHijBrDQVtE5Xv WEWMLl7WCv3iiID02uGfrxucI+wL3rPzE6UDUpbZ9kxaVNcQZMw0imlYOe8Er9jdicAU7c vj1/TsqTCqncdCLupxRYiDfanCR+7CJlUInbkXLWQfunM6jpJlhqeDMWyzZPbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1698965693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=d9FwUHPmJrScNcZK/9t75/IBCuRaFEeWyLl8uZfwmDU=; b=aB9d0p9JGyZAQdrqr5Ce9l1ETLeTWzBDgXtcFVGhywBtM9s14PktPeWe9mLcrxdAo00jUE jM0uowSYWBKfN+OiYiPNKK1BWyW3+4vtc1SDVZvbkb6QNnOmpWroIvgx3+dVC/BNCxs8wo KgIQGWwRoZpxKjCqmR+zNGnVnlEUZRF1J0mY2p25zd849BhTzAM7M6JohCSvCQ8xUzZrOj 8adE782Tx6qI03+PFujVmvHVzA1hyH/kz4zq829dlRxcgLmRUti+najyD4bmrTHkFIObKB 2HiwSVs44pYXacb/Gs7dF+2ihVaqNHIgDqyn+wudfaQUGafkfWqDD6qgBJ3oJg== ARC-Authentication-Results: i=1; rspamd-79d8cddc67-54gqb; auth=pass smtp.auth=dreamhost smtp.mailfrom=nico@cryptonector.com X-Sender-Id: dreamhost|x-authsender|nico@cryptonector.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|nico@cryptonector.com X-MailChannels-Auth-Id: dreamhost X-Broad-Broad: 042b55204f33dc3a_1698965693200_2368678030 X-MC-Loop-Signature: 1698965693200:3783492257 X-MC-Ingress-Time: 1698965693200 Received: from pdx1-sub0-mail-a250.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.112.106.209 (trex/6.9.2); Thu, 02 Nov 2023 22:54:53 +0000 Received: from ubby21 (075-081-095-064.res.spectrum.com [75.81.95.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by pdx1-sub0-mail-a250.dreamhost.com (Postfix) with ESMTPSA id 4SLzj80kH2z6d; Thu, 2 Nov 2023 15:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cryptonector.com; s=dreamhost; t=1698965692; bh=d9FwUHPmJrScNcZK/9t75/IBCuRaFEeWyLl8uZfwmDU=; h=Date:From:To:Cc:Subject:Content-Type; b=GQRWTf5YR7lZPR96hzsd7TJMCS5dCKUBFh6PBi+k2B9Mr3/W8yhQ7Mp8QWeRL/PXN Ch8xS850L1AcwDWZoT/VyC4GfQJad3WUh/IUxJvxIjYUwrb6w9K/U5OR5qXyh0TTlL UsiAFHjlKKwb4dI+y2pl0dRbwbuNlqdQ7F/1Oj53LvVx+riu+uPZajsbxMvxEPoyJR 3L+qmY7c8UTORxzyQQuSa1mBzTr+zZZr/5WCencjxFmqqavtk1X9e4m296ZJGYch1P SsGU/+HYecaYqD1StT5WCe/2DJLrDwdlpebYJFbXmuBzA+mnhqxWNWopV+HNp+a27E svodSncWxiDMg== Date: Thu, 2 Nov 2023 17:54:49 -0500 From: Nico Williams To: Robert Haas Cc: Jeff Davis , Peter Eisentraut , pgsql-hackers@postgresql.org Subject: Re: Pre-proposal: unicode normalized text Message-ID: References: <33a31c45-2e80-1270-771a-b75f3920a5ec@eisentraut.org> <3941663a8e2f185d6acbbbc4f172c41dd3cfb6fe.camel@j-davis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Oct 04, 2023 at 01:16:22PM -0400, Robert Haas wrote: > There's a very popular commercial database where, or so I have been > led to believe, any byte sequence at all is accepted when you try to > put values into the database. [...] In other circles we call this "just-use-8". ZFS, for example, has an option to require that filenames be valid UTF-8 or not, and if not it will accept any garbage (other than ASCII NUL and /, for obvious reasons). For filesystems the situation is a bit dire because: - strings at the system call boundary have never been tagged with a codeset (in the beginning there was only ASCII) - there has never been a standard codeset to use at the system call boundary, - there have been multiple codesets in use for decades so filesystems have to be prepared to be tolerant of garbage, at least until only Unicode is left (UTF-16 on Windows filesystems, UTF-8 for most others). This is another reason that ZFS has form-insensitive/form-preserving behavior: if you want to use non-UTF-8 filenames then names or substrings thereof that look like valid UTF-8 won't accidentally be broken by normalization. If PG never tagged strings with codesets on the wire then PG has the same problem, especially since there's multiple implementations of the PG wire protocol. So I can see why a "popular database" might want to take this approach. For the longer run though, either move to supporting only UTF-8, or allow multiple text types each with a codeset specified in its type. > At any rate, if we were to go in the direction of rejecting code > points that aren't yet assigned, or aren't yet known to the collation > library, that's another way for data loading to fail. Which feels like > very defensible behavior, but not what everyone wants, or is used to. Yes. See points about ZFS. I do think ZFS struck a good balance. PG could take the ZFS approach and add functions for use in CHECK constraints that enforce valid UTF-8, valid Unicode (no use of unassigned codepoints, no use of private use codepoints not configured into the database), etc. Coming back to the "just-use-8" thing, a database could have a text type where the codeset is not specified, one or more text types where the codeset is specified, manual or automatic codeset conversions, and whatever enforcement functions make sense. Provided that the type information is not lost at the edges. > > Whether we ever get to a core data type -- and more importantly, > > whether anyone uses it -- I'm not sure. > > Same here. A TEXTutf8 type (whatever name you want to give it) could be useful as a way to a) opt into heavier enforcement w/o having to write CHECK constraints, b) documentation of intent, all provided that the type is not lost on the wire nor in memory. Support for other codesets is less important. Nico --