diff options
author | Jeff Davis <jdavis@postgresql.org> | 2023-03-28 16:15:59 -0700 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2023-03-28 16:34:29 -0700 |
commit | 1671f990dd669c0b72e45c7bef0fd579a10676ed (patch) | |
tree | 002e9ca8c4cd35b2f641de6c308f78b701f3b21a /src/include/utils/pg_locale.h | |
parent | b7cea58822c67724effc711ae28e4077a01a7cd6 (diff) | |
download | postgresql-1671f990dd669c0b72e45c7bef0fd579a10676ed.tar.gz postgresql-1671f990dd669c0b72e45c7bef0fd579a10676ed.zip |
Validate ICU locales.
For ICU collations, ensure that the locale's language exists in ICU,
and that the locale can be opened.
Basic validation helps avoid minor mistakes and misspellings, which
often fall back to the root locale instead of the intended
locale. It's even more important to avoid such mistakes in ICU
versions 54 and earlier, where the same (misspelled) locale string
could fall back to different locales depending on the environment.
Discussion: https://postgr.es/m/11b1eeb7e7667fdd4178497aeb796c48d26e69b9.camel@j-davis.com
Discussion: https://postgr.es/m/df2efad0cae7c65180df8e5ebb709e5eb4f2a82b.camel@j-davis.com
Reviewed-by: Peter Eisentraut
Diffstat (limited to 'src/include/utils/pg_locale.h')
-rw-r--r-- | src/include/utils/pg_locale.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h index dd822a68be1..c2754279760 100644 --- a/src/include/utils/pg_locale.h +++ b/src/include/utils/pg_locale.h @@ -40,6 +40,7 @@ extern PGDLLIMPORT char *locale_messages; extern PGDLLIMPORT char *locale_monetary; extern PGDLLIMPORT char *locale_numeric; extern PGDLLIMPORT char *locale_time; +extern PGDLLIMPORT int icu_validation_level; /* lc_time localization cache */ extern PGDLLIMPORT char *localized_abbrev_days[]; @@ -118,11 +119,12 @@ extern size_t pg_strxfrm_prefix(char *dest, const char *src, size_t destsize, extern size_t pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src, size_t srclen, pg_locale_t locale); +extern void icu_validate_locale(const char *loc_str); + #ifdef USE_ICU extern int32_t icu_to_uchar(UChar **buff_uchar, const char *buff, size_t nbytes); extern int32_t icu_from_uchar(char **result, const UChar *buff_uchar, int32_t len_uchar); #endif -extern void check_icu_locale(const char *icu_locale); /* These functions convert from/to libc's wchar_t, *not* pg_wchar_t */ extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen, |