1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Improve ICU option handling in CREATE DATABASE

We check that the ICU locale is only specified if the ICU locale
provider is selected.  But we did that too early.  We need to wait
until we load the settings of the template database, since that could
also set what the locale provider is.

Reported-by: Marina Polyakova <m.polyakova@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/9ba4cd1ea6ed6b7b15c0ff15e6f540cd@postgrespro.ru
This commit is contained in:
Peter Eisentraut
2022-09-21 10:28:40 -04:00
parent ab7032b3a8
commit 865b52af61
2 changed files with 11 additions and 4 deletions

View File

@ -907,10 +907,6 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
errmsg("unrecognized locale provider: %s",
locproviderstr)));
}
if (diculocale && dblocprovider != COLLPROVIDER_ICU)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("ICU locale cannot be specified unless locale provider is ICU")));
if (distemplate && distemplate->arg)
dbistemplate = defGetBoolean(distemplate);
if (dallowconnections && dallowconnections->arg)
@ -1050,6 +1046,13 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
check_icu_locale(dbiculocale);
}
else
{
if (dbiculocale)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("ICU locale cannot be specified unless locale provider is ICU")));
}
/*
* Check that the new encoding and locale settings match the source