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 1peYPa-0006DV-De for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Mar 2023 09:36:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1peYPZ-0006Ns-8I for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Mar 2023 09:36:09 +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 1peYPY-0006Nj-3u for pgsql-hackers@lists.postgresql.org; Tue, 21 Mar 2023 09:36:08 +0000 Received: from new4-smtp.messagingengine.com ([66.111.4.230]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1peYPS-0004Lz-NP for pgsql-hackers@postgresql.org; Tue, 21 Mar 2023 09:36:07 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 4E78E582154; Tue, 21 Mar 2023 05:35:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 21 Mar 2023 05:35:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1679391358; x=1679398558; bh=TRSy5tlPCprWwrK7AZ9k4T+4iSLAZfqf0r/ 4V1xAQvc=; b=avU8mIhDJeVV8cqlUuSnlTzj4Y6lwRX/UD9Oy47XBX69R88x5Tw E8FHiXaPVUAYmAVPj26p8H4QuMTk9T0og5FWAjYxL5qnH8xVX+ZO4+BiuW1qNqjS 8TxNCYkeS+TF5UJPQvXp40v1xwoOrvq5y5bG186bLVXXK/PjvSDEAJdkbdRqzpH2 UJ/SXqgBgrSHEbJjvEIe5mHLF9WWqHzcRPX/GCH9c02zhMOXWQklLZc7Bw3UnkBc w3TzxVzKrqbeR4Ena2p4xA2aLUNDm10kJrG6nTQ00OJw50pSlgXz2xVJBKGYT/+I ws1VCE0xuBuw59Y27soo1UxCLaiQOqglxRg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdegtddgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnth gvrhhprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeehleffgeegudejteei hfelteduvdeifffhffdvjedvffegjeekudeludehudeifeenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghu thesvghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 Mar 2023 05:35:57 -0400 (EDT) Message-ID: Date: Tue, 21 Mar 2023 10:35:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: ICU locale validation / canonicalization Content-Language: en-US To: Jeff Davis , Robert Haas Cc: pgsql-hackers@postgresql.org References: <11b1eeb7e7667fdd4178497aeb796c48d26e69b9.camel@j-davis.com> <33acfc3a772224d668042bd2cbef88e91704ce25.camel@j-davis.com> <6f32de82-88e2-480a-8421-07add8f5dee5@enterprisedb.com> <8c7af6820aed94dc7bc259d2aa7f9663518e6137.camel@j-davis.com> <4eebea80f528b1b5e381d6e834497bd6983e4e93.camel@j-davis.com> <899ab44a-4307-064f-0945-412723d57c02@enterprisedb.com> <857da8b1-2a1e-a2be-7df9-7f5e85a3bcb7@enterprisedb.com> <0d7c4115e3dd3581cec125207cbd72cab677c238.camel@j-davis.com> <1569fa4c-aded-57c4-eb07-3bcf03c5e423@enterprisedb.com> <60da0cecfb512a78b8666b31631a636215d8ce73.camel@j-davis.com> <20a2f13f652e6252531a449508e8a8be31d7664f.camel@j-davis.com> <7d77abd7767baaf30445e83415b428aa3eb54631.camel@j-davis.com> <9afa6dbe0d31053ad265aeba488fde784fd5b7ab.camel@j-davis.com> From: Peter Eisentraut In-Reply-To: <9afa6dbe0d31053ad265aeba488fde784fd5b7ab.camel@j-davis.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 17.03.23 18:55, Jeff Davis wrote: > On Wed, 2023-03-15 at 15:18 -0700, Jeff Davis wrote: >> I left out the validation patch for now, and I'm evaluating a >> different >> approach that will attempt to match to the locales retrieved with >> uloc_countAvailable()/uloc_getAvailable(). > > I like this approach, attached new patch series with that included as > 0006. I have looked at the first three patches. I think we want what those patches do. [PATCH v6 1/6] Support language tags in older ICU versions (53 and earlier). In pg_import_system_collations(), this is now redundant and can be simplified: - if (!pg_is_ascii(langtag) || !pg_is_ascii(iculocstr)) + if (!pg_is_ascii(langtag) || !pg_is_ascii(langtag)) icu_set_collation_attributes() needs more commenting about what is going on. My guess is that uloc_canonicalize() converts from language tag to ICU locale ID, and then the existing logic to parse that apart would apply. Is that how it works? [PATCH v6 2/6] Wrap ICU ucol_open(). It makes sense to try to unify some of this. But I find the naming confusing. If I see pg_ucol_open(), then I would expect that all calls to ucol_open() would be replaced by this. But here it's only a few, without explanation. (pg_ucol_open() has no explanation at all AFAICT.) I have in my notes that check_icu_locale() and make_icu_collator() should be combined into a single function. I think that would be a better way to slice it. Btw., I had intentionally not written code like this +#if U_ICU_VERSION_MAJOR_NUM < 54 + icu_set_collation_attributes(collator, loc_str); +#endif The disadvantage of doing it that way is that you then need to dig out an old version of ICU in order to check whether the code compiles at all. With the current code, you can be sure that that code compiles if you make changes elsewhere. [PATCH v6 3/6] Handle the "und" locale in ICU versions 54 and older. This makes sense, but the same comment about not #if'ing out code for old ICU versions applies here. The +#ifdef USE_ICU + before pg_ucol_open() probably belongs in patch 2.