mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
CREATE DATABASE: make LOCALE apply to all collation providers.
For CREATE DATABASE, make LOCALE parameter apply regardless of the provider used. Also affects initdb and createdb --locale arguments. Previously, LOCALE (and --locale) only affected the database default collation when using the libc provider. Discussion: https://postgr.es/m/1a63084d-221e-4075-619e-6b3e590f673e@enterprisedb.com Reviewed-by: Peter Eisentraut
This commit is contained in:
@ -1017,7 +1017,12 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
if (dblocprovider == '\0')
|
||||
dblocprovider = src_locprovider;
|
||||
if (dbiculocale == NULL && dblocprovider == COLLPROVIDER_ICU)
|
||||
dbiculocale = src_iculocale;
|
||||
{
|
||||
if (dlocale && dlocale->arg)
|
||||
dbiculocale = defGetString(dlocale);
|
||||
else
|
||||
dbiculocale = src_iculocale;
|
||||
}
|
||||
if (dbicurules == NULL && dblocprovider == COLLPROVIDER_ICU)
|
||||
dbicurules = src_icurules;
|
||||
|
||||
@ -1031,12 +1036,14 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
if (!check_locale(LC_COLLATE, dbcollate, &canonname))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("invalid locale name: \"%s\"", dbcollate)));
|
||||
errmsg("invalid LC_COLLATE locale name: \"%s\"", dbcollate),
|
||||
errhint("If the locale name is specific to ICU, use ICU_LOCALE.")));
|
||||
dbcollate = canonname;
|
||||
if (!check_locale(LC_CTYPE, dbctype, &canonname))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("invalid locale name: \"%s\"", dbctype)));
|
||||
errmsg("invalid LC_CTYPE locale name: \"%s\"", dbctype),
|
||||
errhint("If the locale name is specific to ICU, use ICU_LOCALE.")));
|
||||
dbctype = canonname;
|
||||
|
||||
check_encoding_locale_matches(encoding, dbcollate, dbctype);
|
||||
@ -1056,7 +1063,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
if (!dbiculocale)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("ICU locale must be specified")));
|
||||
errmsg("LOCALE or ICU_LOCALE must be specified")));
|
||||
|
||||
/*
|
||||
* During binary upgrade, or when the locale came from the template
|
||||
@ -1071,7 +1078,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
if (langtag && strcmp(dbiculocale, langtag) != 0)
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("using standard form \"%s\" for locale \"%s\"",
|
||||
(errmsg("using standard form \"%s\" for ICU locale \"%s\"",
|
||||
langtag, dbiculocale)));
|
||||
|
||||
dbiculocale = langtag;
|
||||
|
Reference in New Issue
Block a user