Fix assertion failure in CREATE DATABASE

An assertion would fail when creating a database with libc locale
provider from a template database with icu locale provider.

Reported-by: Marina Polyakova <m.polyakova@postgrespro.ru>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/f385ba25e7f8be427b8c582e5cca7d79%40postgrespro.ru#515a31c5429d6d37ad1d5c9d66962a1e
pull/102/head
Peter Eisentraut 3 years ago
parent e2fe0aedd0
commit 36f729e2bc
  1. 4
      src/backend/commands/dbcommands.c
  2. 9
      src/bin/scripts/t/020_createdb.pl

@ -1012,10 +1012,10 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
dbcollate = src_collate;
if (dbctype == NULL)
dbctype = src_ctype;
if (dbiculocale == NULL)
dbiculocale = src_iculocale;
if (dblocprovider == '\0')
dblocprovider = src_locprovider;
if (dbiculocale == NULL && dblocprovider == COLLPROVIDER_ICU)
dbiculocale = src_iculocale;
/* Some encodings are client only */
if (!PG_VALID_BE_ENCODING(encoding))

@ -49,6 +49,15 @@ if ($ENV{with_icu} eq 'yes')
'--icu-locale=@colNumeric=lower', 'foobarX'
],
'fails for invalid ICU locale');
# additional node, which uses the icu provider
my $node2 = PostgreSQL::Test::Cluster->new('icu');
$node2->init(extra => ['--locale-provider=icu', '--icu-locale=en']);
$node2->start;
$node2->command_ok(
[ 'createdb', '-T', 'template0', '--locale-provider=libc', 'foobar55' ],
'create database with libc provider from template database with icu provider');
}
else
{

Loading…
Cancel
Save