On 14.06.23 23:24, Jeff Davis wrote:
On Mon, 2023-06-12 at 23:04 +0200, Peter Eisentraut wrote:
Patch 0003:

Makes LOCALE apply to all providers. The overall feel after this
patch
is that "locale" now means the collation locale, and
LC_COLLATE/LC_CTYPE are for the server environment. When using
libc,
LC_COLLATE and LC_CTYPE still work as they did before, but their
relationship to database collation feels more like a special case
of
the libc provider. I believe most people favor this patch and I
haven't
seen recent objections.

This seems reasonable.

Attached a clean patch for this.

It seems to have widespread agreement so I plan to commit to v16 soon.

To clarify, this affects both initdb and CREATE DATABASE.

This looks good to me.

Attached is small fixup patch with some documentation tweaks and simplifying some test code (also includes pgperltidy).
From 0cd2154f364999091aba52136a139df75f58d1b7 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Fri, 16 Jun 2023 16:46:36 +0200
Subject: [PATCH] fixup! CREATE DATABASE: make LOCALE apply to all collation
 providers.

---
 doc/src/sgml/ref/create_database.sgml | 12 ++++++------
 src/test/icu/t/010_database.pl        | 23 +++++++++++++----------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/doc/src/sgml/ref/create_database.sgml 
b/doc/src/sgml/ref/create_database.sgml
index dab05950ed..b2c8aef1ad 100644
--- a/doc/src/sgml/ref/create_database.sgml
+++ b/doc/src/sgml/ref/create_database.sgml
@@ -147,9 +147,9 @@ <title>Parameters</title>
        <para>
         Sets the default collation order and character classification in the
         new database.  Collation affects the sort order applied to strings,
-        e.g., in queries with ORDER BY, as well as the order used in indexes
+        e.g., in queries with <literal>ORDER BY</literal>, as well as the 
order used in indexes
         on text columns.  Character classification affects the categorization
-        of characters, e.g., lower, - upper and digit.  Also sets the
+        of characters, e.g., lower, upper, and digit.  Also sets the
         associated aspects of the operating system environment,
         <literal>LC_COLLATE</literal> and <literal>LC_CTYPE</literal>.  The
         default is the same setting as the template database.  See <xref
@@ -180,7 +180,7 @@ <title>Parameters</title>
        <para>
         Sets <literal>LC_COLLATE</literal> in the database server's operating
         system environment.  The default is the setting of <xref
-        linkend="create-database-locale"/> if specified; otherwise the same
+        linkend="create-database-locale"/> if specified, otherwise the same
         setting as the template database.  See below for additional
         restrictions.
        </para>
@@ -198,7 +198,7 @@ <title>Parameters</title>
        <para>
         Sets <literal>LC_CTYPE</literal> in the database server's operating
         system environment.  The default is the setting of <xref
-        linkend="create-database-locale"/> if specified; otherwise the same
+        linkend="create-database-locale"/> if specified, otherwise the same
         setting as the template database.  See below for additional
         restrictions.
        </para>
@@ -218,8 +218,8 @@ <title>Parameters</title>
         Specifies the ICU locale (see <xref
         linkend="collation-managing-create-icu"/>) for the database default
         collation order and character classification, overriding the setting
-        <xref linkend="create-database-locale"/>.  The <xref
-        linkend="create-database-locale-provider"/> must be ICU.  The default
+        <xref linkend="create-database-locale"/>.  The <link
+        linkend="create-database-locale-provider">locale provider</link> must 
be ICU.  The default
         is the setting of <xref linkend="create-database-locale"/> if
         specified; otherwise the same setting as the template database.
        </para>
diff --git a/src/test/icu/t/010_database.pl b/src/test/icu/t/010_database.pl
index b417b1a409..cbe5467f3c 100644
--- a/src/test/icu/t/010_database.pl
+++ b/src/test/icu/t/010_database.pl
@@ -52,27 +52,30 @@
 
 
 # Test that LOCALE='C' works for ICU
-my $ret1 = $node1->psql('postgres',
-       q{CREATE DATABASE dbicu1 LOCALE_PROVIDER icu LOCALE 'C' TEMPLATE 
template0 ENCODING UTF8}
-);
-is($ret1, 0,
+is( $node1->psql(
+               'postgres',
+               q{CREATE DATABASE dbicu1 LOCALE_PROVIDER icu LOCALE 'C' 
TEMPLATE template0 ENCODING UTF8}
+       ),
+       0,
        "C locale works for ICU");
 
 # Test that LOCALE works for ICU locales if LC_COLLATE and LC_CTYPE
 # are specified
-my $ret2 = $node1->psql('postgres',
-       q{CREATE DATABASE dbicu2 LOCALE_PROVIDER icu LOCALE 
'@colStrength=primary'
+is( $node1->psql(
+               'postgres',
+               q{CREATE DATABASE dbicu2 LOCALE_PROVIDER icu LOCALE 
'@colStrength=primary'
       LC_COLLATE='C' LC_CTYPE='C' TEMPLATE template0 ENCODING UTF8}
-);
-is($ret2, 0,
+       ),
+       0,
        "LOCALE works for ICU locales if LC_COLLATE and LC_CTYPE are 
specified");
 
 # Test that ICU-specific LOCALE without LC_COLLATE and LC_CTYPE must
 # be specified with ICU_LOCALE
-my ($ret3, $stdout, $stderr) = $node1->psql('postgres',
+my ($ret, $stdout, $stderr) = $node1->psql(
+       'postgres',
        q{CREATE DATABASE dbicu3 LOCALE_PROVIDER icu LOCALE 
'@colStrength=primary'
       TEMPLATE template0 ENCODING UTF8});
-isnt($ret3, 0,
+isnt($ret, 0,
        "ICU-specific locale must be specified with ICU_LOCALE: exit code not 
0");
 like(
        $stderr,
-- 
2.41.0

Reply via email to