pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: ICU locale validation / canonicalization
Date: Thu, 23 Mar 2023 10:16:45 -0700
Message-ID: <4efdd7bdf9c811e1a32b8d10524bae8040367068.camel@j-davis.com> (raw)
In-Reply-To: <7ee414ad-deb5-1144-8a0e-b34ae3b71cd5@enterprisedb.com>
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>
	<c15981f01fba3c0cbcdb49a6d43cdf0a90cd77ff.camel@j-davis.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>
	<b29cdc9b-1176-4456-e909-8fd64af03af8@enterprisedb.com>
	<c6dd63de8267ad8267ce4ec939f72c43f1fc2020.camel@j-davis.com>
	<7ee414ad-deb5-1144-8a0e-b34ae3b71cd5@enterprisedb.com>

On Thu, 2023-03-23 at 07:27 +0100, Peter Eisentraut wrote:
> So, does uloc_canonicalize() always convert to ICU locale IDs?  What
> if 
> you pass a language tag, does it convert it to ICU locale ID as well?

Yes.

The documentation is not clear on that point, but my testing shows that
it does. And this is only for old versions of the code, so we don't
need to worry about later versions of ICU changing that.

I thought about using uloc_forLanguageTag(), but the documentation for
that is not clear what formats it accepts as an input, so it doesn't
seem like a win. If wanted to be paranoid we could use
uloc_toLanguageTag() followed by uloc_forLanguageTag(), but that seemed
excessive.

> > 
> 0002 and 0003 look ok to me now.

Thank you, committed 0002 and 0003.

> In 0002, the error "opening default collator is not supported",
> should 
> that be an assert or an elog?  Is it reachable by the user?

It's not reachable by the user, but could catch a bug if we
accidentally read a NULL field from the catalog or something like that.
It seemed a worthwhile check to leave in production builds.

> You might want to check the declarations at the top of
> pg_ucol_open(). 
> 0003 reformats them after they were just added in 0002.  Maybe check 
> that they are pgindent'ed in 0002 properly.

They seem to be pgindented fine in 0002, it was unnecessarily
reindented in 0003 and I fixed that.

I use emacs "align-current" and generally that does the right thing,
but I'll rely more on pgindent in the future.

> I don't understand patch 0004.  It seems to do two things, handle 
> C/POSIX locale specifications and add an SQL-callable function.  Are 
> those connected?

It's hard to test (or even exercise) the former without the latter.

I could get rid of the SQL-callable function and move the rest of the
changes into 0006. I'll see if that arrangement works better, and that
way we can add the SQL-callable function later (or perhaps not at all
if it's not desired).

Regards,
	Jeff Davis






view thread (46+ messages)  latest in thread

Message-ID: <4efdd7bdf9c811e1a32b8d10524bae8040367068.camel@j-davis.com>
Permalink:  ../4efdd7bdf9c811e1a32b8d10524bae8040367068.camel@j-davis.com/
Also on:    postgresql.org/message-id/4efdd7bdf9c811e1a32b8d10524bae8040367068.camel@j-davis.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: pgsql@j-davis.com, peter.eisentraut@enterprisedb.com, robertmhaas@gmail.com
  Subject: Re: ICU locale validation / canonicalization
  In-Reply-To: <4efdd7bdf9c811e1a32b8d10524bae8040367068.camel@j-davis.com>
  References: <11b1eeb7e7667fdd4178497aeb796c48d26e69b9.camel@j-davis.com> <8c7af6820aed94dc7bc259d2aa7f9663518e6137.camel@j-davis.com> <4eebea80f528b1b5e381d6e834497bd6983e4e93.camel@j-davis.com> <899ab44a-4307-064f-0945-412723d57c02@enterprisedb.com> <c15981f01fba3c0cbcdb49a6d43cdf0a90cd77ff.camel@j-davis.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> <b29cdc9b-1176-4456-e909-8fd64af03af8@enterprisedb.com> <c6dd63de8267ad8267ce4ec939f72c43f1fc2020.camel@j-davis.com> <7ee414ad-deb5-1144-8a0e-b34ae3b71cd5@enterprisedb.com> <4efdd7bdf9c811e1a32b8d10524bae8040367068.camel@j-davis.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