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 1qnlTt-00Btad-N0 for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Oct 2023 19:54:57 +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 1qnlTr-008PXY-5N for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Oct 2023 19:54:55 +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 1qnlTq-008PXL-RP for pgsql-hackers@lists.postgresql.org; Tue, 03 Oct 2023 19:54:55 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qnlTk-00827a-BN for pgsql-hackers@postgresql.org; Tue, 03 Oct 2023 19:54:53 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-692d2e8c003so144650b3a.1 for ; Tue, 03 Oct 2023 12:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1696362887; x=1696967687; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=8mEW82DSgtPM+MK4DTi8DRh3pFDDaKzszSaw8rr0pvk=; b=mqQowEbja2G1rDp6NPNndtmORO8vIBQw08NJ+QtYPHR2elvomRAJXOdXuW0CtrQb8T NuVNAq2YMn04qf2eU54Ie/Lu8xRP7AkqCbnCtUHm4pJ3l5voV6j/EFIumxwn63C3saQX 0S1jFA5G7jhbiAzH2SjL78H8XVO4mcbRu4MfU8Bv1PAZ8jEqMoqaGU6L4uUHAW/4KVqI rLTBLlZAYKFJBNeAntPdDBlV4tCC0FUM7kem3hvfObKgFGxOAX4y/cthcO5jfWchMVuB 6zJWLukh+Qk2UNofY1OpDnBwztc+ZqYf7ru7BvEKWvtVEa6DJQZI1diDYBk4mgKRD06N CWLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696362887; x=1696967687; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=8mEW82DSgtPM+MK4DTi8DRh3pFDDaKzszSaw8rr0pvk=; b=lrx07moREvZKgrwGTSM67+qvN+k/Va00oo+4Ubp2iJSMtdnPoslaKF0VYLSfK32cvQ 5qJOIErWefS45FXYg1XszU6XjTr7RKdbxEW6ISga80OAnvqRSovYUfUefuC+qUbLiP20 LNMjgYzzPrw1auwGkclfs1kA885AW4Nw5RGQkuAJGOIMgIZcUM1p1asIESYZ7LeqJvGn S4RQFLWrCvpRvtSdP+YQ9F6KE6y3dkYB+hHp99Cs7E0bmiGRn9L5NleS63B3Q/8+hqVQ 65S2P5qoAZmhBwc5jMem2KBOU8JbVvBMHKc9vJZLhWMeGnTdgvIXIP7EFxcGKxgNiyuU GJwA== X-Gm-Message-State: AOJu0YxLBTsfJwNz7FvoZcr5MJWmIzti5TwZ2vlOCXCGpSuXsiASysbA 6IegryKB5J+dRF0Vw4D6gnEE3A== X-Google-Smtp-Source: AGHT+IERHLQQlHS+s+4IiYjBLSmm/mx9Hdr92/XCrsK2cAiPakfoDyh3cRaS+Fg3OMKfgojE5A0Lrw== X-Received: by 2002:a05:6a20:9187:b0:149:97e4:8ae4 with SMTP id v7-20020a056a20918700b0014997e48ae4mr506093pzd.0.1696362887357; Tue, 03 Oct 2023 12:54:47 -0700 (PDT) Received: from [172.18.10.34] ([12.126.244.130]) by smtp.gmail.com with ESMTPSA id j8-20020aa78008000000b0068a46cd4120sm1760664pfi.199.2023.10.03.12.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 12:54:46 -0700 (PDT) Message-ID: <3941663a8e2f185d6acbbbc4f172c41dd3cfb6fe.camel@j-davis.com> Subject: Re: Pre-proposal: unicode normalized text From: Jeff Davis To: Robert Haas , Peter Eisentraut Cc: pgsql-hackers@postgresql.org Date: Tue, 03 Oct 2023 12:54:46 -0700 In-Reply-To: References: <33a31c45-2e80-1270-771a-b75f3920a5ec@eisentraut.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-10-02 at 16:06 -0400, Robert Haas wrote: > It seems to me that this overlooks one of the major points of Jeff's > proposal, which is that we don't reject text input that contains > unassigned code points. That decision turns out to be really painful. Yeah, because we lose forward-compatibility of some useful operations. > Here, Jeff mentions normalization, but I think it's a major issue > with > collation support. If new code points are added, users can put them > into the database before they are known to the collation library, and > then when they become known to the collation library the sort order > changes and indexes break. The collation version number may reflect the change in understanding about assigned code points that may affect collation -- though I'd like to understand whether this is guaranteed or not. Regardless, given that (a) we don't have a good story for migrating to new collation versions; and (b) it would be painful to rebuild indexes even if we did; then you are right that it's a problem. > Would we endorse a proposal to make > pg_catalog.text with encoding UTF-8 reject code points that aren't > yet > known to the collation library? To do so would be tighten things up > considerably from where they stand today, and the way things stand > today is already rigid enough to cause problems for some users. What problems exist today due to the rigidity of text? I assume you mean because we reject invalid byte sequences? Yeah, I'm sure that causes a problem for some (especially migrations), but it's difficult for me to imagine a database working well with no rules at all for the the basic data types. > Now, there is still the question of whether such a data type would > properly belong in core or even contrib rather than being an > out-of-core project. It's not obvious to me that such a data type > would get enough traction that we'd want it to be part of PostgreSQL > itself. At minimum I think we need to have some internal functions to check for unassigned code points. That belongs in core, because we generate the unicode tables from a specific version. I also think we should expose some SQL functions to check for unassigned code points. That sounds useful, especially since we already expose normalization functions. One could easily imagine a domain with CHECK(NOT contains_unassigned(a)). Or an extension with a data type that uses the internal functions. Whether we ever get to a core data type -- and more importantly, whether anyone uses it -- I'm not sure. > But at the same time I can certainly understand why Jeff finds > the status quo problematic. Yeah, I am looking for a better compromise between: * everything is memcmp() and 'a=CC=81' sometimes doesn't equal 'a=CC=81' (depending on code point sequence) * everything is constantly changing, indexes break, and text comparisons are slow A stable idea of unicode normalization based on using only assigned code points is very tempting. Regards, Jeff Davis