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 1qo9UI-000KCd-GO for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Oct 2023 21:32:58 +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 1qo9UG-005Wsb-6C for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Oct 2023 21:32:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qo9UF-005WsG-Sp for pgsql-hackers@lists.postgresql.org; Wed, 04 Oct 2023 21:32:56 +0000 Received: from anastigmatix.net ([68.171.216.17]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qo9UE-0002jo-Bj for pgsql-hackers@postgresql.org; Wed, 04 Oct 2023 21:32:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=V0F6SDb6BegOrdt52vUAzVu/33TwZBeyHrCA+QrZ8oI=; b=ZlnjoQuOmMGcsKX7HQGsryQNjX yFVt3vH36NNZ2zVJf4ykor3F6MbvH0muz/8gQQCF/tq1xQow+UnroVlxe+lcVq9/DKGNNSpOgn5l5 jnJxTl/Ti3xsBvDYTg7bZi5XYIiU3euRhdrwCaZE+UUtK/nKhJA3oorIslP0Hh4/KoHu3S6Vsxkdw kx4EfjALlntzA9+GFbiudTpSKpbX/+khnTcVI90BVTPbTdwqyULkgw/GApKbdot+wlMpNtXJMj5a4 8rKpjj9fETcL34nFAtnypDH6bRCusaOQQ/SqQcfNx7w20Q302//B7W/5PHk/psc0RT6XLVw83p+cN DQ7g/Tbw==; Received: from [::1] (port=39338 helo=adam.ace-host.net) by adam.ace-host.net with esmtpa (Exim 4.96.1) (envelope-from ) id 1qo9UB-00E6Tr-1o; Wed, 04 Oct 2023 17:32:51 -0400 MIME-Version: 1.0 Date: Wed, 04 Oct 2023 17:32:50 -0400 From: Chapman Flack To: Jeff Davis Cc: Robert Haas , Nico Williams , pgsql-hackers@postgresql.org Subject: Re: Pre-proposal: unicode normalized text In-Reply-To: References: <43864caecd65d02081d623d05ccc1683@anastigmatix.net> User-Agent: Roundcube Webmail/1.6.0 Message-ID: <02d05bc98ca5b2d8ab38fec5fe5b7625@anastigmatix.net> X-Sender: chap@anastigmatix.net Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - adam.ace-host.net X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: adam.ace-host.net: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: adam.ace-host.net: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-10-04 16:38, Jeff Davis wrote: > On Wed, 2023-10-04 at 14:02 -0400, Chapman Flack wrote: >> The SQL standard would have me able to: >> >> CREATE TABLE foo ( >>    a CHARACTER VARYING CHARACTER SET UTF8, >>    b CHARACTER VARYING CHARACTER SET LATIN1 >> ) >> >> and so on > > Is there a use case for that? UTF-8 is able to encode any unicode code > point, it's relatively compact, and it's backwards-compatible with 7- > bit ASCII. If you have a variety of text data in your system (and in > many cases even if not), then UTF-8 seems like the right solution. Well, for what reason does anybody run PG now with the encoding set to anything besides UTF-8? I don't really have my finger on that pulse. Could it be that it bloats common strings in their local script, and with enough of those to store, it could matter to use the local encoding that stores them more economically? Also, while any Unicode transfer format can encode any Unicode code point, I'm unsure whether it's yet the case that {any Unicode code point} is a superset of every character repertoire associated with every non-Unicode encoding. The cheap glaring counterexample is SQL_ASCII. Half those code points are *nobody knows what Unicode character* (or even *whether*). I'm not insisting that's a good thing, but it is a thing. It might be a very tidy future to say all text is Unicode and all server encodings are UTF-8, but I'm not sure it wouldn't still be a good step on the way to be able to store some things in their own encodings. We have JSON and XML now, two data types that are *formally defined* to accept any Unicode content, and we hedge and mumble and say (well, as long as it goes in the server encoding) and that makes me sad. Things like that should be easy to handle even without declaring UTF-8 as a server-wide encoding ... they already are their own distinct data types, and could conceivably know their own encodings. But there again, it's possible that going with unconditional UTF-8 for JSON or XML documents could, in some regions, bloat them. Regards, -Chap