aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2022-09-21 10:28:40 -0400
committerPeter Eisentraut <peter@eisentraut.org>2022-09-21 10:41:27 -0400
commit865b52af61049719e0a289419a0eceded6ea7bae (patch)
tree3017fee6cd480fa273a7afd5a7a994d0497455e3
parentab7032b3a8fec281db71acfc37c5c92fc65b08ae (diff)
downloadpostgresql-865b52af61049719e0a289419a0eceded6ea7bae.tar.gz
postgresql-865b52af61049719e0a289419a0eceded6ea7bae.zip
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
-rw-r--r--src/backend/commands/dbcommands.c11
-rw-r--r--src/bin/scripts/t/020_createdb.pl4
2 files changed, 11 insertions, 4 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index cba929b7f99..5dfec5c6b05 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -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
diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl
index b87d8fc63b5..8ed8628db11 100644
--- a/src/bin/scripts/t/020_createdb.pl
+++ b/src/bin/scripts/t/020_createdb.pl
@@ -71,6 +71,10 @@ if ($ENV{with_icu} eq 'yes')
$node2->command_ok(
[ 'createdb', '-T', 'template0', '--locale-provider=libc', 'foobar55' ],
'create database with libc provider from template database with icu provider');
+
+ $node2->command_ok(
+ [ 'createdb', '-T', 'template0', '--icu-locale', 'en-US', 'foobar56' ],
+ 'create database with icu locale from template database with icu provider');
}
else
{