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 1q1qa3-0003if-S4 for pgsql-hackers@arkaria.postgresql.org; Wed, 24 May 2023 15:39:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q1qa2-0000aK-Na for pgsql-hackers@arkaria.postgresql.org; Wed, 24 May 2023 15:39:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q1qa2-0000aB-Ah for pgsql-hackers@lists.postgresql.org; Wed, 24 May 2023 15:39:14 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q1qZy-001tZq-GV for pgsql-hackers@lists.postgresql.org; Wed, 24 May 2023 15:39:13 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2533d74895bso329773a91.0 for ; Wed, 24 May 2023 08:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20221208.gappssmtp.com; s=20221208; t=1684942749; x=1687534749; 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=1Y4+2nC3kxTxTFz8KbXWSbW1GN4pKrn/xdyuUJfQh4s=; b=o3cOsR5zMLcc9dVPi5yeTxW5lqUGil64aHdyJ/FRV/Np17C/rLeBP1+fU1kYGCe3OM C0OA7Yw/oTRTEmJXp1ddbKxlBMgqhRg5dFRNggD1PF8c78uRfCO4MMkSI5qfHI0ovawI TY3ZJmGL9GGT5jcLxyBf/WrpbJF6Ei3PTptnkNUAab6A24yEeMqR4d7duUi4HGhviK3P LSUer6am3kuyzaADSiHRcpLR322lADtxGeVn6RNWuNM25yys0/z3qrMvdTBdyAoKHpIL YnS4Cpf/+CGCqTPxzUKHRDACUhZCFrSus3spLerGyk00TSwmk0alPIFLX8rPitNyvOjK vTVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942749; x=1687534749; 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=1Y4+2nC3kxTxTFz8KbXWSbW1GN4pKrn/xdyuUJfQh4s=; b=XghoWvnDoCZU2U8fBF0nVk33t/5wmRwA/OHUMCn/Mf+nxf0xeGT0Bjgk8XKIP4npSq KpLD5ILU8aknAEkY9kVtu0Bsw4NHEIoegsKk5wUgNuK9F3CnTIp7TSres7F69D7ouwnV 4BFFLw6ez6E4EYI/jOZhGE1055AZHPhnU4o3onifHNSr64W71+adhfI3VettvcI5MQWG KFpWAjd8tNi7aWuAk/voeeW4fpgKFNt3H1wjMupx5v49uP5FFlm7vfcV/1CzlLI/yal7 EM9PEJ+ZpFwz3sawDAohIfH6vkp0QEKn9qiuTzjVlTcjt+CQfWwwtw0wpT0SLoOtifkk sQBw== X-Gm-Message-State: AC+VfDzkhUeC9RsAYioznw8dQaZHUIib+B7ry7BM0GeHeXnQZiybLbH+ Pb3MGkduTmMmpLY+f5yZ2XgGRg== X-Google-Smtp-Source: ACHHUZ5xq8J9+3YfdOxZJ2vfdRqM36wzGHPfByhlvktQ5wmzy2Pp9zhx6j0LKgXKe7kUwjmdPmAQsg== X-Received: by 2002:a17:90b:90c:b0:255:5a12:36d3 with SMTP id bo12-20020a17090b090c00b002555a1236d3mr11184135pjb.36.1684942748980; Wed, 24 May 2023 08:39:08 -0700 (PDT) Received: from jeff-laptop.lan (c-73-170-46-202.hsd1.ca.comcast.net. [73.170.46.202]) by smtp.gmail.com with ESMTPSA id ft6-20020a17090b0f8600b00250d670306esm1491591pjb.35.2023.05.24.08.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:39:08 -0700 (PDT) Message-ID: <660e18263897e046e9104cc60c1cea14dc9e7551.camel@j-davis.com> Subject: Re: Order changes in PG16 since ICU introduction From: Jeff Davis To: Daniel Verite Cc: Matthias van de Meent , Andrew Gierth , Peter Eisentraut , Sandro Santilli , Tom Lane , Regina Obe , pgsql-hackers@lists.postgresql.org Date: Wed, 24 May 2023 08:39:07 -0700 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-05-22 at 22:09 +0200, Daniel Verite wrote: > While I agree that the LOCALE option in CREATE DATABASE is > counter-intuitive, I think it's more than that. As Andreww Gierth pointed out: $ initdb --locale=3Dfr_FR ... ICU locale: en-US ... Is more than just counter-intuitive. I don't think we can ship 16 that way. > I find it questionable that blending ICU > and libc locales into it helps that much with the user experience. Thank you for going through some examples here. I agree that it's not perfect, but we need some path to a reasonable ICU user experience, and I think we'll have to accept some rough edges to avoid the worst cases, like above. > initdb: >=20 > =C2=A0 Using default ICU locale "fr". > =C2=A0 Using language tag "fr" for ICU locale "fr". >=20 ... > #1 >=20 > postgres=3D# create database test1 locale=3D'fr_FR.UTF-8'; > NOTICE:=C2=A0 using standard form "fr-FR" for ICU locale "fr_FR.UTF-8" > ERROR:=C2=A0=C2=A0new ICU locale (fr-FR) is incompatible with the ICU loc= ale of I don't see a problem here. If you specify LOCALE to CREATE DATABASE, you should either be using "TEMPLATE template0", or you should be expecting an error if the LOCALE doesn't match exactly. What would you like to see happen here? > #2 >=20 > postgres=3D# create database test2 locale=3D'C.UTF-8' > template=3D'template0'; > NOTICE:=C2=A0 using standard form "en-US-u-va-posix" for ICU locale > "C.UTF-8" > CREATE DATABASE >=20 >=20 > en-US-u-va-posix does not sort like C.UTF-8 in glibc 2.35, so > this interpretation is arguably not what a user would expect. As you pointed out, this is not settled in libc either: https://www.postgresql.org/message-id/8a3dc06f-9b9d-4ed7-9a12-2070d8b0165f%= 40manitou-mail.org We really can't expect a particular order for a particular locale name, unless we handle it specially like "C" or "POSIX". If we pass it to the provider, we have to trust the provider to match our conceptual expectations for that locale (and ideally version it properly). > I would expect the ICU warning or error (icu_validation_level) to > kick > in instead of that transliteration. Earlier versions of ICU (<=3D 63) do this transformation automatically, and I don't see a reason to throw an error if ICU considers it valid. The language tag en-US-u-va-posix will be stored in the catalog, and that will be considered valid in later versions of ICU. Later versions of ICU (>=3D 64) consider locales with a language name of "C" to be obsolete and no longer valid. I added code to do the transformation without error in these later versions, but I think we have agreement to remove it. If a user specifies the locale as "C.UTF-8", we can either pass it to ICU and see whether that version accepts it or not (and if not, throw a warning/error); or if we decide that "C.UTF-8" really means "C", we can handle it in the memcmp() path like C and never send it to ICU. > #3 >=20 > $ grep french /etc/locale.alias > french=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fr_FR.I= SO-8859-1 >=20 > postgres=3D# create database test3 locale=3D'french' template=3D'template= 0' > encoding=3D'LATIN1'; > WARNING:=C2=A0 ICU locale "french" has unknown language "french" > HINT:=C2=A0 To disable ICU locale validation, set parameter > icu_validation_level > to DISABLED. > CREATE DATABASE >=20 >=20 > In practice we're probably getting the "und" ICU locale whereas "fr" > would > be appropriate. This is a good point and illustrates that ICU is not a drop-in replacement for libc in all cases. I don't see a solution here that doesn't involve some rough edges, though. "Locale" is a generic term, and if we continue to insist that it really means a libc locale, then ICU will never be on an equal footing with libc, let alone the preferred provider. Regards, Jeff Davis