Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a2caf18

Browse files
committed
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
1 parent 3725b7f commit a2caf18

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/backend/commands/dbcommands.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,10 +1011,10 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
10111011
dbcollate = src_collate;
10121012
if (dbctype == NULL)
10131013
dbctype = src_ctype;
1014-
if (dbiculocale == NULL)
1015-
dbiculocale = src_iculocale;
10161014
if (dblocprovider == '\0')
10171015
dblocprovider = src_locprovider;
1016+
if (dbiculocale == NULL && dblocprovider == COLLPROVIDER_ICU)
1017+
dbiculocale = src_iculocale;
10181018

10191019
/* Some encodings are client only */
10201020
if (!PG_VALID_BE_ENCODING(encoding))

src/bin/scripts/t/020_createdb.pl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@
4949
'--icu-locale=@colNumeric=lower', 'foobarX'
5050
],
5151
'fails for invalid ICU locale');
52+
53+
# additional node, which uses the icu provider
54+
my $node2 = PostgreSQL::Test::Cluster->new('icu');
55+
$node2->init(extra => ['--locale-provider=icu', '--icu-locale=en']);
56+
$node2->start;
57+
58+
$node2->command_ok(
59+
[ 'createdb', '-T', 'template0', '--locale-provider=libc', 'foobar55' ],
60+
'create database with libc provider from template database with icu provider');
5261
}
5362
else
5463
{

0 commit comments

Comments
 (0)