diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-03-20 10:21:45 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-03-20 10:21:45 +0100 |
commit | 3a671e1f7cb8b29ad77b08f891b8f22621f490a3 (patch) | |
tree | cbf5c62be3c78836a8d50c81994ab3a740fb0d45 /src/backend/commands/dbcommands.c | |
parent | 3c0c5cc5e65906bad6abe6bb8c2d9f6669870f33 (diff) | |
download | postgresql-3a671e1f7cb8b29ad77b08f891b8f22621f490a3.tar.gz postgresql-3a671e1f7cb8b29ad77b08f891b8f22621f490a3.zip |
Fix global ICU collations for ICU < 54
createdb() didn't check for collation attributes validity, which has
to be done explicitly on ICU < 54. It also forgot to close the ICU collator
opened during the check which leaks some memory.
To fix both, add a new check_icu_locale() that does all the appropriate
verification and close the ICU collator.
initdb also had some partial check for ICU < 54. To have consistent error
reporting across major ICU versions, and get rid of the need to include ucol.h,
remove the partial check there. The backend will report an error if needed
during the post-boostrap iniitialization phase.
Author: Julien Rouhaud <julien.rouhaud@free.fr>
Discussion: https://www.postgresql.org/message-id/20220319041459.qqqiqh335sga5ezj@jrouhaud
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r-- | src/backend/commands/dbcommands.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 962e11dd8f4..623e5ec7789 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -458,23 +458,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt) } if (dblocprovider == COLLPROVIDER_ICU) - { -#ifdef USE_ICU - UErrorCode status; - - status = U_ZERO_ERROR; - ucol_open(dbiculocale, &status); - if (U_FAILURE(status)) - ereport(ERROR, - (errmsg("could not open collator for locale \"%s\": %s", - dbiculocale, u_errorName(status)))); -#else - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("ICU is not supported in this build"), \ - errhint("You need to rebuild PostgreSQL using %s.", "--with-icu"))); -#endif - } + check_icu_locale(dbiculocale); /* * Check that the new encoding and locale settings match the source |