1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

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
This commit is contained in:
Peter Eisentraut
2022-03-20 10:21:45 +01:00
parent 3c0c5cc5e6
commit 3a671e1f7c
7 changed files with 37 additions and 40 deletions

View File

@ -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