]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix assertion failure in CREATE DATABASE
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 22 Aug 2022 13:31:50 +0000 (15:31 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 22 Aug 2022 13:31:50 +0000 (15:31 +0200)
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

src/backend/commands/dbcommands.c
src/bin/scripts/t/020_createdb.pl

index 6f836865e15f0e4d32020d52536fec5724d309f0..e2c1ac0df73daaf7a91dd8442578e2c9199e8c99 100644 (file)
@@ -1011,10 +1011,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))
index 78733f64d2517f42aff25ffe0ccdacd81ddb4eb2..e91c1d013d08d8bd1e3a92f2aba958c5c7713ca6 100644 (file)
@@ -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
 {