pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Jeff Davis <pgsql@j-davis.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: ICU locale validation / canonicalization
Date: Thu, 9 Mar 2023 09:46:46 +0100
Message-ID: <899ab44a-4307-064f-0945-412723d57c02@enterprisedb.com> (raw)
In-Reply-To: <4eebea80f528b1b5e381d6e834497bd6983e4e93.camel@j-davis.com>
References: <11b1eeb7e7667fdd4178497aeb796c48d26e69b9.camel@j-davis.com>
	<CA+Tgmob6mDjCCA-BL2oFOpdRdijkkVrQ09DuMBi0rV_2omPVmA@mail.gmail.com>
	<fccd3064fa38285d2b71c2cc46a3eae8e5c6d4fb.camel@j-davis.com>
	<CA+TgmoYJ7usps=Ln6fBisgGyVcgjwXxDxYhFyc=b+iZ1XRaU6A@mail.gmail.com>
	<33acfc3a772224d668042bd2cbef88e91704ce25.camel@j-davis.com>
	<6f32de82-88e2-480a-8421-07add8f5dee5@enterprisedb.com>
	<8c7af6820aed94dc7bc259d2aa7f9663518e6137.camel@j-davis.com>
	<4eebea80f528b1b5e381d6e834497bd6983e4e93.camel@j-davis.com>

On 28.02.23 06:57, Jeff Davis wrote:
> On Mon, 2023-02-20 at 15:23 -0800, Jeff Davis wrote:
>>
>> New patch attached. The new patch also includes a GUC that (when
>> enabled) validates that the collator is actually found.
> 
> New patch attached.
> 
> Now it always preserves the exact locale string during pg_upgrade, and
> does not attempt to canonicalize it. Before it was trying to be clever
> by determining if the language tag was finding the same collator as the
> original string -- I didn't find a problem with that, but it just
> seemed a bit too clever. So, only newly-created locales and databases
> have the ICU locale string canonicalized to a language tag.
> 
> Also, I added a SQL function pg_icu_language_tag() that can convert
> locale strings to language tags, and check whether they exist or not.

This patch appears to do about three things at once, and it's not clear 
exactly where the boundaries are between them and which ones we might 
actually want.  And I think the terminology also gets mixed up a bit, 
which makes following this harder.

1. Canonicalizing the locale string.  This is presumably what 
uloc_canonicalize() does, which the patch doesn't actually use.  What 
are examples of what this does?  Does the patch actually do this?

2. Converting the locale string to BCP 47 format.  This converts 
'de@collation=phonebook' to 'de-u-co-phonebk'.  This is what 
uloc_getLanguageTag() does.

3. Validating the locale string, to reject faulty input.

What are the relationships between these?

I don't understand how the validation actually happens in your patch. 
Does uloc_getLanguageTag() do the validation also?

Can you do canonicalization without converting to language tag?

Can you do validation of un-canonicalized locale names?

What is the guidance for the use of the icu_locale_validation GUC?

The description throws in yet another term: "validates that ICU locale 
strings are well-formed".  What is "well-formed"?  How does that relate 
to the other concepts?

Personally, I'm not on board with this behavior:

=> CREATE COLLATION test (provider = icu, locale = 
'de@collation=phonebook');
NOTICE:  00000: using language tag "de-u-co-phonebk" for locale 
"de@collation=phonebook"

I mean, maybe that is a thing we want to do somehow sometime, to migrate 
people to the "new" spellings, but the old ones aren't wrong.  So this 
should be a separate consideration, with an option, and it would require 
various updates in the documentation.  It also doesn't appear to address 
how to handle ICU before version 54.

But, see earlier questions, are these three things all connected somehow?






view thread (46+ messages)  latest in thread

Message-ID: <899ab44a-4307-064f-0945-412723d57c02@enterprisedb.com>
Permalink:  ../899ab44a-4307-064f-0945-412723d57c02@enterprisedb.com/
Also on:    postgresql.org/message-id/899ab44a-4307-064f-0945-412723d57c02@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@enterprisedb.com, pgsql@j-davis.com, robertmhaas@gmail.com
  Subject: Re: ICU locale validation / canonicalization
  In-Reply-To: <899ab44a-4307-064f-0945-412723d57c02@enterprisedb.com>
  References: <11b1eeb7e7667fdd4178497aeb796c48d26e69b9.camel@j-davis.com> <CA+Tgmob6mDjCCA-BL2oFOpdRdijkkVrQ09DuMBi0rV_2omPVmA@mail.gmail.com> <fccd3064fa38285d2b71c2cc46a3eae8e5c6d4fb.camel@j-davis.com> <CA+TgmoYJ7usps=Ln6fBisgGyVcgjwXxDxYhFyc=b+iZ1XRaU6A@mail.gmail.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>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox