postgresql/src/include
Jeff Davis ea1db8ae70 Canonicalize ICU locale names to language tags.
Convert to BCP47 language tags before storing in the catalog, except
during binary upgrade or when the locale comes from an existing
collation or template database.

The resulting language tags can vary slightly between ICU
versions. For instance, "@colBackwards=yes" is converted to
"und-u-kb-true" in older versions of ICU, and to the simpler (but
equivalent) "und-u-kb" in newer versions.

The process of canonicalizing to a language tag also understands more
input locale string formats than ucol_open(). For instance,
"fr_CA.UTF-8" is misinterpreted by ucol_open() and the region is
ignored; effectively treating it the same as the locale "fr" and
opening the wrong collator. Canonicalization properly interprets the
language and region, resulting in the language tag "fr-CA", which can
then be understood by ucol_open().

This commit fixes a problem in prior versions due to ucol_open()
misinterpreting locale strings as described above. For instance,
creating an ICU collation with locale "fr_CA.UTF-8" would store that
string directly in the catalog, which would later be passed to (and
misinterpreted by) ucol_open(). After this commit, the locale string
will be canonicalized to language tag "fr-CA" in the catalog, which
will be properly understood by ucol_open(). Because this fix affects
the resulting collator, we cannot change the locale string stored in
the catalog for existing databases or collations; otherwise we'd risk
corrupting indexes. Therefore, only canonicalize locales for
newly-created (not upgraded) collations/databases. For similar
reasons, do not backport.

Discussion: https://postgr.es/m/8c7af6820aed94dc7bc259d2aa7f9663518e6137.camel@j-davis.com
Reviewed-by: Peter Eisentraut
2023-04-04 10:38:58 -07:00
..
access Recycle deleted nbtree pages more aggressively. 2023-04-03 11:31:43 -07:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Update copyright for 2023 2023-01-02 15:00:37 -05:00
bootstrap Update copyright for 2023 2023-01-02 15:00:37 -05:00
catalog Add a run_as_owner option to subscriptions. 2023-04-04 12:03:03 -04:00
commands Perform logical replication actions as the table owner. 2023-04-04 11:25:23 -04:00
common Make SCRAM iteration count configurable 2023-03-27 09:46:29 +02:00
datatype Code review for commit 05a7be935. 2023-01-26 12:51:00 -05:00
executor Revert 11470f544e 2023-04-03 16:54:31 +03:00
fe_utils Update copyright for 2023 2023-01-02 15:00:37 -05:00
foreign Update copyright for 2023 2023-01-02 15:00:37 -05:00
jit Update copyright for 2023 2023-01-02 15:00:37 -05:00
lib Fix various typos in code and tests 2023-02-09 14:43:53 +09:00
libpq Copy and store addrinfo in libpq-owned private memory 2023-03-29 21:41:27 +02:00
mb Update copyright for 2023 2023-01-02 15:00:37 -05:00
nodes SQL/JSON: support the IS JSON predicate 2023-03-31 22:34:04 +02:00
optimizer Fix mis-handling of outer join quals generated by EquivalenceClasses. 2023-02-23 11:05:58 -05:00
parser SQL/JSON: support the IS JSON predicate 2023-03-31 22:34:04 +02:00
partitioning Fix various typos in code and tests 2023-02-09 14:43:53 +09:00
pch Update copyright for 2023 2023-01-02 15:00:37 -05:00
port Don't leak descriptors into subprograms. 2023-03-03 10:43:33 +13:00
portability instr_time: Represent time as an int64 on all platforms 2023-01-20 21:16:47 -08:00
postmaster Redesign archive modules 2023-02-17 14:26:42 +09:00
regex Update copyright for 2023 2023-01-02 15:00:37 -05:00
replication Add new predefined role pg_create_subscription. 2023-03-30 11:37:19 -04:00
rewrite Make Vars be outer-join-aware. 2023-01-30 13:16:20 -05:00
snowball Update copyright for 2023 2023-01-02 15:00:37 -05:00
statistics Update copyright for 2023 2023-01-02 15:00:37 -05:00
storage Track shared buffer hits in pg_stat_io 2023-03-30 19:24:21 -07:00
tcop Update copyright for 2023 2023-01-02 15:00:37 -05:00
tsearch Fix ts_headline() to handle ORs and phrase queries more honestly. 2023-01-19 16:21:44 -05:00
utils Canonicalize ICU locale names to language tags. 2023-04-04 10:38:58 -07:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
Makefile Include headers of archive/ in installation 2023-03-10 20:08:10 +09:00
c.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
fmgr.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
funcapi.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
getopt_long.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
meson.build Include headers of archive/ in installation 2023-03-10 20:08:10 +09:00
miscadmin.h Fix outdated references to guc.c 2023-03-02 13:49:39 +01:00
pg_config.h.in libpq: Add sslcertmode option to control client certificates 2023-03-24 13:34:26 +09:00
pg_config_ext.h.in
pg_config_ext.h.meson meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
pg_config_manual.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_getopt.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_trace.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pgstat.h Bump PGSTAT_FILE_FORMAT_ID, omitted in 8aaa04b32d 2023-03-30 19:48:01 -07:00
pgtar.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pgtime.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
port.h Add SHELL_ERROR and SHELL_EXIT_CODE magic variables to psql. 2023-03-21 13:03:56 -04:00
postgres.h New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00
postgres_ext.h Move RelFileNumber declarations to common/relpath.h. 2022-09-27 12:01:57 -04:00
postgres_fe.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
varatt.h New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00
windowapi.h Update copyright for 2023 2023-01-02 15:00:37 -05:00