Catalog changes preparing for builtin collation provider.
authorJeff Davis <jdavis@postgresql.org>
Sat, 9 Mar 2024 22:48:18 +0000 (14:48 -0800)
committerJeff Davis <jdavis@postgresql.org>
Sat, 9 Mar 2024 22:48:18 +0000 (14:48 -0800)
Rename pg_collation.colliculocale to colllocale, and
pg_database.daticulocale to datlocale. These names reflects that the
fields will be useful for the upcoming builtin provider as well, not
just for ICU.

This is purely a rename; no changes to the meaning of the fields.

Discussion: https://postgr.es/m/ff4c2f2f9c8fc7ca27c1c24ae37ecaeaeaff6b53.camel%40j-davis.com
Reviewed-by: Peter Eisentraut
22 files changed:
doc/src/sgml/bki.sgml
doc/src/sgml/catalogs.sgml
src/backend/catalog/pg_collation.c
src/backend/commands/collationcmds.c
src/backend/commands/dbcommands.c
src/backend/utils/adt/pg_locale.c
src/backend/utils/init/postinit.c
src/bin/initdb/initdb.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_upgrade/info.c
src/bin/pg_upgrade/pg_upgrade.c
src/bin/pg_upgrade/pg_upgrade.h
src/bin/pg_upgrade/t/002_pg_upgrade.pl
src/bin/psql/describe.c
src/include/catalog/catversion.h
src/include/catalog/pg_collation.dat
src/include/catalog/pg_collation.h
src/include/catalog/pg_database.dat
src/include/catalog/pg_database.h
src/test/regress/expected/collate.icu.utf8.out
src/test/regress/expected/psql.out
src/test/regress/sql/collate.icu.utf8.sql

index 315ba81951484a550972914dfbdbd589f299ab32..3cd5bee7ffaf40cc683781a4094d6ebcf6f5d0e2 100644 (file)
   datlocprovider => 'LOCALE_PROVIDER', datistemplate => 't',
   datallowconn => 't', dathasloginevt => 'f', datconnlimit => '-1', datfrozenxid => '0',
   datminmxid => '1', dattablespace => 'pg_default', datcollate => 'LC_COLLATE',
-  datctype => 'LC_CTYPE', daticulocale => 'ICU_LOCALE', datacl => '_null_' },
+  datctype => 'LC_CTYPE', datlocale => 'DATLOCALE', datacl => '_null_' },
 
 ]
 ]]></programlisting>
index 0ae97d1adaa797de61b459caf17317d19848c0dc..387a14b18691bf3f3096be590b529fd873fceb38 100644 (file)
@@ -2407,7 +2407,10 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
        <structfield>collcollate</structfield> <type>text</type>
       </para>
       <para>
-       <symbol>LC_COLLATE</symbol> for this collation object
+       <symbol>LC_COLLATE</symbol> for this collation object. If the provider is
+       not <literal>libc</literal>, <structfield>collcollate</structfield> is
+       <literal>NULL</literal> and <structfield>colllocale</structfield> is
+       used instead.
       </para></entry>
      </row>
 
@@ -2416,16 +2419,23 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
        <structfield>collctype</structfield> <type>text</type>
       </para>
       <para>
-       <symbol>LC_CTYPE</symbol> for this collation object
+       <symbol>LC_CTYPE</symbol> for this collation object. If the provider is
+       not <literal>libc</literal>, <structfield>collctype</structfield> is
+       <literal>NULL</literal> and <structfield>colllocale</structfield> is
+       used instead.
       </para></entry>
      </row>
 
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>colliculocale</structfield> <type>text</type>
+       <structfield>colllocale</structfield> <type>text</type>
       </para>
       <para>
-       ICU locale ID for this collation object
+       Collation provider locale name for this collation object. If the
+       provider is <literal>libc</literal>,
+       <structfield>colllocale</structfield> is <literal>NULL</literal>;
+       <structfield>collcollate</structfield> and
+       <structfield>collctype</structfield> are used instead.
       </para></entry>
      </row>
 
@@ -3131,10 +3141,14 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
 
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>daticulocale</structfield> <type>text</type>
+       <structfield>datlocale</structfield> <type>text</type>
       </para>
       <para>
-       ICU locale ID for this database
+       Collation provider locale name for this database. If the
+       provider is <literal>libc</literal>,
+       <structfield>datlocale</structfield> is <literal>NULL</literal>;
+       <structfield>datcollate</structfield> and
+       <structfield>datctype</structfield> are used instead.
       </para></entry>
      </row>
 
index 7bce19bd83a73b241c489a088c1a9ba300716be8..e42f2afccbc350ce4cc925ecfa6e37dab1727ad4 100644 (file)
@@ -45,7 +45,7 @@ CollationCreate(const char *collname, Oid collnamespace,
                                bool collisdeterministic,
                                int32 collencoding,
                                const char *collcollate, const char *collctype,
-                               const char *colliculocale,
+                               const char *colllocale,
                                const char *collicurules,
                                const char *collversion,
                                bool if_not_exists,
@@ -64,7 +64,7 @@ CollationCreate(const char *collname, Oid collnamespace,
        Assert(collname);
        Assert(collnamespace);
        Assert(collowner);
-       Assert((collcollate && collctype) || colliculocale);
+       Assert((collcollate && collctype) || colllocale);
 
        /*
         * Make sure there is no existing collation of same name & encoding.
@@ -187,10 +187,10 @@ CollationCreate(const char *collname, Oid collnamespace,
                values[Anum_pg_collation_collctype - 1] = CStringGetTextDatum(collctype);
        else
                nulls[Anum_pg_collation_collctype - 1] = true;
-       if (colliculocale)
-               values[Anum_pg_collation_colliculocale - 1] = CStringGetTextDatum(colliculocale);
+       if (colllocale)
+               values[Anum_pg_collation_colllocale - 1] = CStringGetTextDatum(colllocale);
        else
-               nulls[Anum_pg_collation_colliculocale - 1] = true;
+               nulls[Anum_pg_collation_colllocale - 1] = true;
        if (collicurules)
                values[Anum_pg_collation_collicurules - 1] = CStringGetTextDatum(collicurules);
        else
index 106e696da8d745e58e6632e7918e46a93dbd6cee..59d7e17804b0e6b6711e855eb56552804cd29f3e 100644 (file)
@@ -66,7 +66,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
        DefElem    *versionEl = NULL;
        char       *collcollate;
        char       *collctype;
-       char       *colliculocale;
+       char       *colllocale;
        char       *collicurules;
        bool            collisdeterministic;
        int                     collencoding;
@@ -157,11 +157,11 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
                else
                        collctype = NULL;
 
-               datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_colliculocale, &isnull);
+               datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_colllocale, &isnull);
                if (!isnull)
-                       colliculocale = TextDatumGetCString(datum);
+                       colllocale = TextDatumGetCString(datum);
                else
-                       colliculocale = NULL;
+                       colllocale = NULL;
 
                /*
                 * When the ICU locale comes from an existing collation, do not
@@ -194,7 +194,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
 
                collcollate = NULL;
                collctype = NULL;
-               colliculocale = NULL;
+               colllocale = NULL;
                collicurules = NULL;
 
                if (providerEl)
@@ -234,7 +234,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
                                collctype = defGetString(localeEl);
                        }
                        else
-                               colliculocale = defGetString(localeEl);
+                               colllocale = defGetString(localeEl);
                }
 
                if (lccollateEl)
@@ -259,7 +259,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
                }
                else if (collprovider == COLLPROVIDER_ICU)
                {
-                       if (!colliculocale)
+                       if (!colllocale)
                                ereport(ERROR,
                                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
                                                 errmsg("parameter \"%s\" must be specified",
@@ -271,20 +271,20 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
                         */
                        if (!IsBinaryUpgrade)
                        {
-                               char       *langtag = icu_language_tag(colliculocale,
+                               char       *langtag = icu_language_tag(colllocale,
                                                                                                           icu_validation_level);
 
-                               if (langtag && strcmp(colliculocale, langtag) != 0)
+                               if (langtag && strcmp(colllocale, langtag) != 0)
                                {
                                        ereport(NOTICE,
                                                        (errmsg("using standard form \"%s\" for ICU locale \"%s\"",
-                                                                       langtag, colliculocale)));
+                                                                       langtag, colllocale)));
 
-                                       colliculocale = langtag;
+                                       colllocale = langtag;
                                }
                        }
 
-                       icu_validate_locale(colliculocale);
+                       icu_validate_locale(colllocale);
                }
 
                /*
@@ -332,7 +332,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
        }
 
        if (!collversion)
-               collversion = get_collation_actual_version(collprovider, collprovider == COLLPROVIDER_ICU ? colliculocale : collcollate);
+               collversion = get_collation_actual_version(collprovider, collprovider == COLLPROVIDER_ICU ? colllocale : collcollate);
 
        newoid = CollationCreate(collName,
                                                         collNamespace,
@@ -342,7 +342,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
                                                         collencoding,
                                                         collcollate,
                                                         collctype,
-                                                        colliculocale,
+                                                        colllocale,
                                                         collicurules,
                                                         collversion,
                                                         if_not_exists,
@@ -433,7 +433,7 @@ AlterCollation(AlterCollationStmt *stmt)
        datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion, &isnull);
        oldversion = isnull ? NULL : TextDatumGetCString(datum);
 
-       datum = SysCacheGetAttrNotNull(COLLOID, tup, collForm->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate);
+       datum = SysCacheGetAttrNotNull(COLLOID, tup, collForm->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colllocale : Anum_pg_collation_collcollate);
        newversion = get_collation_actual_version(collForm->collprovider, TextDatumGetCString(datum));
 
        /* cannot change from NULL to non-NULL or vice versa */
@@ -500,7 +500,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
 
                datum = SysCacheGetAttrNotNull(DATABASEOID, dbtup,
                                                                           provider == COLLPROVIDER_ICU ?
-                                                                          Anum_pg_database_daticulocale : Anum_pg_database_datcollate);
+                                                                          Anum_pg_database_datlocale : Anum_pg_database_datcollate);
 
                locale = TextDatumGetCString(datum);
 
@@ -521,7 +521,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
                Assert(provider != COLLPROVIDER_DEFAULT);
                datum = SysCacheGetAttrNotNull(COLLOID, colltp,
                                                                           provider == COLLPROVIDER_ICU ?
-                                                                          Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate);
+                                                                          Anum_pg_collation_colllocale : Anum_pg_collation_collcollate);
 
                locale = TextDatumGetCString(datum);
 
index b256d6d0f7df24cd59ed1d4835ea00edc789ee57..0f27d7b14cfc8de5eaef9db1a99b231da40b4621 100644 (file)
@@ -117,7 +117,7 @@ static bool get_db_info(const char *name, LOCKMODE lockmode,
                                                Oid *dbIdP, Oid *ownerIdP,
                                                int *encodingP, bool *dbIsTemplateP, bool *dbAllowConnP, bool *dbHasLoginEvtP,
                                                TransactionId *dbFrozenXidP, MultiXactId *dbMinMultiP,
-                                               Oid *dbTablespace, char **dbCollate, char **dbCtype, char **dbIculocale,
+                                               Oid *dbTablespace, char **dbCollate, char **dbCtype, char **dbLocale,
                                                char **dbIcurules,
                                                char *dbLocProvider,
                                                char **dbCollversion);
@@ -674,7 +674,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
        int                     src_encoding = -1;
        char       *src_collate = NULL;
        char       *src_ctype = NULL;
-       char       *src_iculocale = NULL;
+       char       *src_locale = NULL;
        char       *src_icurules = NULL;
        char            src_locprovider = '\0';
        char       *src_collversion = NULL;
@@ -712,7 +712,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
        const char *dbtemplate = NULL;
        char       *dbcollate = NULL;
        char       *dbctype = NULL;
-       char       *dbiculocale = NULL;
+       char       *dblocale = NULL;
        char       *dbicurules = NULL;
        char            dblocprovider = '\0';
        char       *canonname;
@@ -902,7 +902,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
        if (dctype && dctype->arg)
                dbctype = defGetString(dctype);
        if (diculocale && diculocale->arg)
-               dbiculocale = defGetString(diculocale);
+               dblocale = defGetString(diculocale);
        if (dicurules && dicurules->arg)
                dbicurules = defGetString(dicurules);
        if (dlocprovider && dlocprovider->arg)
@@ -970,7 +970,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
                                         &src_dboid, &src_owner, &src_encoding,
                                         &src_istemplate, &src_allowconn, &src_hasloginevt,
                                         &src_frozenxid, &src_minmxid, &src_deftablespace,
-                                        &src_collate, &src_ctype, &src_iculocale, &src_icurules, &src_locprovider,
+                                        &src_collate, &src_ctype, &src_locale, &src_icurules, &src_locprovider,
                                         &src_collversion))
                ereport(ERROR,
                                (errcode(ERRCODE_UNDEFINED_DATABASE),
@@ -1026,12 +1026,12 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
                dbctype = src_ctype;
        if (dblocprovider == '\0')
                dblocprovider = src_locprovider;
-       if (dbiculocale == NULL && dblocprovider == COLLPROVIDER_ICU)
+       if (dblocale == NULL && dblocprovider == COLLPROVIDER_ICU)
        {
                if (dlocale && dlocale->arg)
-                       dbiculocale = defGetString(dlocale);
+                       dblocale = defGetString(dlocale);
                else
-                       dbiculocale = src_iculocale;
+                       dblocale = src_locale;
        }
        if (dbicurules == NULL && dblocprovider == COLLPROVIDER_ICU)
                dbicurules = src_icurules;
@@ -1070,7 +1070,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
                 * This would happen if template0 uses the libc provider but the new
                 * database uses icu.
                 */
-               if (!dbiculocale)
+               if (!dblocale)
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                         errmsg("LOCALE or ICU_LOCALE must be specified")));
@@ -1080,26 +1080,26 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
                 * database, preserve locale string. Otherwise, canonicalize to a
                 * language tag.
                 */
-               if (!IsBinaryUpgrade && dbiculocale != src_iculocale)
+               if (!IsBinaryUpgrade && dblocale != src_locale)
                {
-                       char       *langtag = icu_language_tag(dbiculocale,
+                       char       *langtag = icu_language_tag(dblocale,
                                                                                                   icu_validation_level);
 
-                       if (langtag && strcmp(dbiculocale, langtag) != 0)
+                       if (langtag && strcmp(dblocale, langtag) != 0)
                        {
                                ereport(NOTICE,
                                                (errmsg("using standard form \"%s\" for ICU locale \"%s\"",
-                                                               langtag, dbiculocale)));
+                                                               langtag, dblocale)));
 
-                               dbiculocale = langtag;
+                               dblocale = langtag;
                        }
                }
 
-               icu_validate_locale(dbiculocale);
+               icu_validate_locale(dblocale);
        }
        else
        {
-               if (dbiculocale)
+               if (dblocale)
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
                                         errmsg("ICU locale cannot be specified unless locale provider is ICU")));
@@ -1156,13 +1156,13 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
                        char       *val1;
                        char       *val2;
 
-                       Assert(dbiculocale);
-                       Assert(src_iculocale);
-                       if (strcmp(dbiculocale, src_iculocale) != 0)
+                       Assert(dblocale);
+                       Assert(src_locale);
+                       if (strcmp(dblocale, src_locale) != 0)
                                ereport(ERROR,
                                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                                 errmsg("new ICU locale (%s) is incompatible with the ICU locale of the template database (%s)",
-                                                               dbiculocale, src_iculocale),
+                                                               dblocale, src_locale),
                                                 errhint("Use the same ICU locale as in the template database, or use template0 as template.")));
 
                        val1 = dbicurules;
@@ -1196,7 +1196,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
        {
                char       *actual_versionstr;
 
-               actual_versionstr = get_collation_actual_version(dblocprovider, dblocprovider == COLLPROVIDER_ICU ? dbiculocale : dbcollate);
+               actual_versionstr = get_collation_actual_version(dblocprovider, dblocprovider == COLLPROVIDER_ICU ? dblocale : dbcollate);
                if (!actual_versionstr)
                        ereport(ERROR,
                                        (errmsg("template database \"%s\" has a collation version, but no actual collation version could be determined",
@@ -1224,7 +1224,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
         * collation version, which is normally only the case for template0.
         */
        if (dbcollversion == NULL)
-               dbcollversion = get_collation_actual_version(dblocprovider, dblocprovider == COLLPROVIDER_ICU ? dbiculocale : dbcollate);
+               dbcollversion = get_collation_actual_version(dblocprovider, dblocprovider == COLLPROVIDER_ICU ? dblocale : dbcollate);
 
        /* Resolve default tablespace for new database */
        if (dtablespacename && dtablespacename->arg)
@@ -1363,8 +1363,8 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
         * block on the unique index, and fail after we commit).
         */
 
-       Assert((dblocprovider == COLLPROVIDER_ICU && dbiculocale) ||
-                  (dblocprovider != COLLPROVIDER_ICU && !dbiculocale));
+       Assert((dblocprovider == COLLPROVIDER_ICU && dblocale) ||
+                  (dblocprovider != COLLPROVIDER_ICU && !dblocale));
 
        /* Form tuple */
        new_record[Anum_pg_database_oid - 1] = ObjectIdGetDatum(dboid);
@@ -1382,10 +1382,10 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
        new_record[Anum_pg_database_dattablespace - 1] = ObjectIdGetDatum(dst_deftablespace);
        new_record[Anum_pg_database_datcollate - 1] = CStringGetTextDatum(dbcollate);
        new_record[Anum_pg_database_datctype - 1] = CStringGetTextDatum(dbctype);
-       if (dbiculocale)
-               new_record[Anum_pg_database_daticulocale - 1] = CStringGetTextDatum(dbiculocale);
+       if (dblocale)
+               new_record[Anum_pg_database_datlocale - 1] = CStringGetTextDatum(dblocale);
        else
-               new_record_nulls[Anum_pg_database_daticulocale - 1] = true;
+               new_record_nulls[Anum_pg_database_datlocale - 1] = true;
        if (dbicurules)
                new_record[Anum_pg_database_daticurules - 1] = CStringGetTextDatum(dbicurules);
        else
@@ -2471,7 +2471,7 @@ AlterDatabaseRefreshColl(AlterDatabaseRefreshCollStmt *stmt)
        datum = heap_getattr(tuple, Anum_pg_database_datcollversion, RelationGetDescr(rel), &isnull);
        oldversion = isnull ? NULL : TextDatumGetCString(datum);
 
-       datum = heap_getattr(tuple, datForm->datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_daticulocale : Anum_pg_database_datcollate, RelationGetDescr(rel), &isnull);
+       datum = heap_getattr(tuple, datForm->datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_datlocale : Anum_pg_database_datcollate, RelationGetDescr(rel), &isnull);
        if (isnull)
                elog(ERROR, "unexpected null in pg_database");
        newversion = get_collation_actual_version(datForm->datlocprovider, TextDatumGetCString(datum));
@@ -2669,7 +2669,7 @@ pg_database_collation_actual_version(PG_FUNCTION_ARGS)
 
        datlocprovider = ((Form_pg_database) GETSTRUCT(tp))->datlocprovider;
 
-       datum = SysCacheGetAttrNotNull(DATABASEOID, tp, datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_daticulocale : Anum_pg_database_datcollate);
+       datum = SysCacheGetAttrNotNull(DATABASEOID, tp, datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_datlocale : Anum_pg_database_datcollate);
        version = get_collation_actual_version(datlocprovider, TextDatumGetCString(datum));
 
        ReleaseSysCache(tp);
@@ -2696,7 +2696,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
                        Oid *dbIdP, Oid *ownerIdP,
                        int *encodingP, bool *dbIsTemplateP, bool *dbAllowConnP, bool *dbHasLoginEvtP,
                        TransactionId *dbFrozenXidP, MultiXactId *dbMinMultiP,
-                       Oid *dbTablespace, char **dbCollate, char **dbCtype, char **dbIculocale,
+                       Oid *dbTablespace, char **dbCollate, char **dbCtype, char **dbLocale,
                        char **dbIcurules,
                        char *dbLocProvider,
                        char **dbCollversion)
@@ -2807,13 +2807,13 @@ get_db_info(const char *name, LOCKMODE lockmode,
                                        datum = SysCacheGetAttrNotNull(DATABASEOID, tuple, Anum_pg_database_datctype);
                                        *dbCtype = TextDatumGetCString(datum);
                                }
-                               if (dbIculocale)
+                               if (dbLocale)
                                {
-                                       datum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_daticulocale, &isnull);
+                                       datum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datlocale, &isnull);
                                        if (isnull)
-                                               *dbIculocale = NULL;
+                                               *dbLocale = NULL;
                                        else
-                                               *dbIculocale = TextDatumGetCString(datum);
+                                               *dbLocale = TextDatumGetCString(datum);
                                }
                                if (dbIcurules)
                                {
index 8e6822ee5927c44d7f4eaa1f3c79475086d03bc6..77d5752dc8eb15bbfd561887c4eaedbe1605029a 100644 (file)
@@ -1605,7 +1605,7 @@ pg_newlocale_from_collation(Oid collid)
                        const char *iculocstr;
                        const char *icurules;
 
-                       datum = SysCacheGetAttrNotNull(COLLOID, tp, Anum_pg_collation_colliculocale);
+                       datum = SysCacheGetAttrNotNull(COLLOID, tp, Anum_pg_collation_colllocale);
                        iculocstr = TextDatumGetCString(datum);
 
                        datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collicurules, &isnull);
@@ -1626,7 +1626,7 @@ pg_newlocale_from_collation(Oid collid)
 
                        collversionstr = TextDatumGetCString(datum);
 
-                       datum = SysCacheGetAttrNotNull(COLLOID, tp, collform->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate);
+                       datum = SysCacheGetAttrNotNull(COLLOID, tp, collform->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colllocale : Anum_pg_collation_collcollate);
 
                        actual_versionstr = get_collation_actual_version(collform->collprovider,
                                                                                                                         TextDatumGetCString(datum));
index 16f3659fd903c984891356b95ae04dd540efb31b..2875bc97d3b5df02d21dad8d98223111f98d88b4 100644 (file)
@@ -318,7 +318,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
        bool            isnull;
        char       *collate;
        char       *ctype;
-       char       *iculocale;
+       char       *datlocale;
 
        /* Fetch our pg_database row normally, via syscache */
        tup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
@@ -427,8 +427,8 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
        {
                char       *icurules;
 
-               datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_daticulocale);
-               iculocale = TextDatumGetCString(datum);
+               datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_datlocale);
+               datlocale = TextDatumGetCString(datum);
 
                datum = SysCacheGetAttr(DATABASEOID, tup, Anum_pg_database_daticurules, &isnull);
                if (!isnull)
@@ -436,10 +436,10 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
                else
                        icurules = NULL;
 
-               make_icu_collator(iculocale, icurules, &default_locale);
+               make_icu_collator(datlocale, icurules, &default_locale);
        }
        else
-               iculocale = NULL;
+               datlocale = NULL;
 
        default_locale.provider = dbform->datlocprovider;
 
@@ -464,7 +464,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
 
                collversionstr = TextDatumGetCString(datum);
 
-               actual_versionstr = get_collation_actual_version(dbform->datlocprovider, dbform->datlocprovider == COLLPROVIDER_ICU ? iculocale : collate);
+               actual_versionstr = get_collation_actual_version(dbform->datlocprovider, dbform->datlocprovider == COLLPROVIDER_ICU ? datlocale : collate);
                if (!actual_versionstr)
                        /* should not happen */
                        elog(WARNING,
index 200b2e8e3170b81b34fec92367a5d388c1ab2feb..de58002a5d4284826c48fb4b2292fd656a65461e 100644 (file)
@@ -145,7 +145,7 @@ static char *lc_numeric = NULL;
 static char *lc_time = NULL;
 static char *lc_messages = NULL;
 static char locale_provider = COLLPROVIDER_LIBC;
-static char *icu_locale = NULL;
+static char *datlocale = NULL;
 static char *icu_rules = NULL;
 static const char *default_text_search_config = NULL;
 static char *username = NULL;
@@ -1520,8 +1520,8 @@ bootstrap_template1(void)
        bki_lines = replace_token(bki_lines, "LC_CTYPE",
                                                          escape_quotes_bki(lc_ctype));
 
-       bki_lines = replace_token(bki_lines, "ICU_LOCALE",
-                                                         icu_locale ? escape_quotes_bki(icu_locale) : "_null_");
+       bki_lines = replace_token(bki_lines, "DATLOCALE",
+                                                         datlocale ? escape_quotes_bki(datlocale) : "_null_");
 
        bki_lines = replace_token(bki_lines, "ICU_RULES",
                                                          icu_rules ? escape_quotes_bki(icu_rules) : "_null_");
@@ -2352,7 +2352,7 @@ setlocales(void)
 {
        char       *canonname;
 
-       /* set empty lc_* and iculocale values to locale config if set */
+       /* set empty lc_* and datlocale values to locale config if set */
 
        if (locale)
        {
@@ -2368,8 +2368,8 @@ setlocales(void)
                        lc_monetary = locale;
                if (!lc_messages)
                        lc_messages = locale;
-               if (!icu_locale && locale_provider == COLLPROVIDER_ICU)
-                       icu_locale = locale;
+               if (!datlocale && locale_provider == COLLPROVIDER_ICU)
+                       datlocale = locale;
        }
 
        /*
@@ -2400,17 +2400,17 @@ setlocales(void)
                char       *langtag;
 
                /* acquire default locale from the environment, if not specified */
-               if (icu_locale == NULL)
+               if (datlocale == NULL)
                        pg_fatal("ICU locale must be specified");
 
                /* canonicalize to a language tag */
-               langtag = icu_language_tag(icu_locale);
+               langtag = icu_language_tag(datlocale);
                printf(_("Using language tag \"%s\" for ICU locale \"%s\".\n"),
-                          langtag, icu_locale);
-               pg_free(icu_locale);
-               icu_locale = langtag;
+                          langtag, datlocale);
+               pg_free(datlocale);
+               datlocale = langtag;
 
-               icu_validate_locale(icu_locale);
+               icu_validate_locale(datlocale);
 
                /*
                 * In supported builds, the ICU locale ID will be opened during
@@ -2604,14 +2604,14 @@ setup_locale_encoding(void)
                strcmp(lc_ctype, lc_numeric) == 0 &&
                strcmp(lc_ctype, lc_monetary) == 0 &&
                strcmp(lc_ctype, lc_messages) == 0 &&
-               (!icu_locale || strcmp(lc_ctype, icu_locale) == 0))
+               (!datlocale || strcmp(lc_ctype, datlocale) == 0))
                printf(_("The database cluster will be initialized with locale \"%s\".\n"), lc_ctype);
        else
        {
                printf(_("The database cluster will be initialized with this locale configuration:\n"));
                printf(_("  provider:    %s\n"), collprovider_name(locale_provider));
-               if (icu_locale)
-                       printf(_("  ICU locale:  %s\n"), icu_locale);
+               if (datlocale)
+                       printf(_("  ICU locale:  %s\n"), datlocale);
                printf(_("  LC_COLLATE:  %s\n"
                                 "  LC_CTYPE:    %s\n"
                                 "  LC_MESSAGES: %s\n"
@@ -3282,7 +3282,7 @@ main(int argc, char *argv[])
                                        pg_fatal("unrecognized locale provider: %s", optarg);
                                break;
                        case 16:
-                               icu_locale = pg_strdup(optarg);
+                               datlocale = pg_strdup(optarg);
                                break;
                        case 17:
                                icu_rules = pg_strdup(optarg);
@@ -3317,7 +3317,7 @@ main(int argc, char *argv[])
                exit(1);
        }
 
-       if (icu_locale && locale_provider != COLLPROVIDER_ICU)
+       if (datlocale && locale_provider != COLLPROVIDER_ICU)
                pg_fatal("%s cannot be specified unless locale provider \"%s\" is chosen",
                                 "--icu-locale", "icu");
 
index 10cbf02bebdd6f6232095d32c4c7c3f9037ea389..23e6217b73fd090524c07176957b6ca50c7fe5c9 100644 (file)
@@ -2984,7 +2984,7 @@ dumpDatabase(Archive *fout)
                                i_datlocprovider,
                                i_collate,
                                i_ctype,
-                               i_daticulocale,
+                               i_datlocale,
                                i_daticurules,
                                i_frozenxid,
                                i_minmxid,
@@ -3003,7 +3003,7 @@ dumpDatabase(Archive *fout)
                           *datlocprovider,
                           *collate,
                           *ctype,
-                          *iculocale,
+                          *locale,
                           *icurules,
                           *datistemplate,
                           *datconnlimit,
@@ -3027,10 +3027,12 @@ dumpDatabase(Archive *fout)
                appendPQExpBufferStr(dbQry, "datminmxid, ");
        else
                appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
-       if (fout->remoteVersion >= 150000)
-               appendPQExpBufferStr(dbQry, "datlocprovider, daticulocale, datcollversion, ");
+       if (fout->remoteVersion >= 170000)
+               appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
+       else if (fout->remoteVersion >= 150000)
+               appendPQExpBufferStr(dbQry, "datlocprovider, daticulocale AS datlocale, datcollversion, ");
        else
-               appendPQExpBufferStr(dbQry, "'c' AS datlocprovider, NULL AS daticulocale, NULL AS datcollversion, ");
+               appendPQExpBufferStr(dbQry, "'c' AS datlocprovider, NULL AS datlocale, NULL AS datcollversion, ");
        if (fout->remoteVersion >= 160000)
                appendPQExpBufferStr(dbQry, "daticurules, ");
        else
@@ -3051,7 +3053,7 @@ dumpDatabase(Archive *fout)
        i_datlocprovider = PQfnumber(res, "datlocprovider");
        i_collate = PQfnumber(res, "datcollate");
        i_ctype = PQfnumber(res, "datctype");
-       i_daticulocale = PQfnumber(res, "daticulocale");
+       i_datlocale = PQfnumber(res, "datlocale");
        i_daticurules = PQfnumber(res, "daticurules");
        i_frozenxid = PQfnumber(res, "datfrozenxid");
        i_minmxid = PQfnumber(res, "datminmxid");
@@ -3070,10 +3072,10 @@ dumpDatabase(Archive *fout)
        datlocprovider = PQgetvalue(res, 0, i_datlocprovider);
        collate = PQgetvalue(res, 0, i_collate);
        ctype = PQgetvalue(res, 0, i_ctype);
-       if (!PQgetisnull(res, 0, i_daticulocale))
-               iculocale = PQgetvalue(res, 0, i_daticulocale);
+       if (!PQgetisnull(res, 0, i_datlocale))
+               locale = PQgetvalue(res, 0, i_datlocale);
        else
-               iculocale = NULL;
+               locale = NULL;
        if (!PQgetisnull(res, 0, i_daticurules))
                icurules = PQgetvalue(res, 0, i_daticurules);
        else
@@ -3138,11 +3140,12 @@ dumpDatabase(Archive *fout)
                        appendStringLiteralAH(creaQry, ctype, fout);
                }
        }
-       if (iculocale)
+       if (locale)
        {
                appendPQExpBufferStr(creaQry, " ICU_LOCALE = ");
-               appendStringLiteralAH(creaQry, iculocale, fout);
+               appendStringLiteralAH(creaQry, locale, fout);
        }
+
        if (icurules)
        {
                appendPQExpBufferStr(creaQry, " ICU_RULES = ");
@@ -13756,12 +13759,12 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
        int                     i_collisdeterministic;
        int                     i_collcollate;
        int                     i_collctype;
-       int                     i_colliculocale;
+       int                     i_colllocale;
        int                     i_collicurules;
        const char *collprovider;
        const char *collcollate;
        const char *collctype;
-       const char *colliculocale;
+       const char *colllocale;
        const char *collicurules;
 
        /* Do nothing in data-only dump */
@@ -13793,12 +13796,15 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
                appendPQExpBufferStr(query,
                                                         "true AS collisdeterministic, ");
 
-       if (fout->remoteVersion >= 150000)
+       if (fout->remoteVersion >= 170000)
+               appendPQExpBufferStr(query,
+                                                        "colllocale, ");
+       else if (fout->remoteVersion >= 150000)
                appendPQExpBufferStr(query,
-                                                        "colliculocale, ");
+                                                        "colliculocale AS colllocale, ");
        else
                appendPQExpBufferStr(query,
-                                                        "NULL AS colliculocale, ");
+                                                        "NULL AS colllocale, ");
 
        if (fout->remoteVersion >= 160000)
                appendPQExpBufferStr(query,
@@ -13820,7 +13826,7 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
        i_collisdeterministic = PQfnumber(res, "collisdeterministic");
        i_collcollate = PQfnumber(res, "collcollate");
        i_collctype = PQfnumber(res, "collctype");
-       i_colliculocale = PQfnumber(res, "colliculocale");
+       i_colllocale = PQfnumber(res, "colllocale");
        i_collicurules = PQfnumber(res, "collicurules");
 
        collprovider = PQgetvalue(res, 0, i_collprovider);
@@ -13847,10 +13853,10 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
                        collctype = NULL;
        }
 
-       if (!PQgetisnull(res, 0, i_colliculocale))
-               colliculocale = PQgetvalue(res, 0, i_colliculocale);
+       if (!PQgetisnull(res, 0, i_colllocale))
+               colllocale = PQgetvalue(res, 0, i_colllocale);
        else
-               colliculocale = NULL;
+               colllocale = NULL;
 
        if (!PQgetisnull(res, 0, i_collicurules))
                collicurules = PQgetvalue(res, 0, i_collicurules);
@@ -13880,7 +13886,7 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
 
        if (collprovider[0] == 'd')
        {
-               if (collcollate || collctype || colliculocale || collicurules)
+               if (collcollate || collctype || colllocale || collicurules)
                        pg_log_warning("invalid collation \"%s\"", qcollname);
 
                /* no locale -- the default collation cannot be reloaded anyway */
@@ -13889,16 +13895,16 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
        {
                if (fout->remoteVersion >= 150000)
                {
-                       if (collcollate || collctype || !colliculocale)
+                       if (collcollate || collctype || !colllocale)
                                pg_log_warning("invalid collation \"%s\"", qcollname);
 
                        appendPQExpBufferStr(q, ", locale = ");
-                       appendStringLiteralAH(q, colliculocale ? colliculocale : "",
+                       appendStringLiteralAH(q, colllocale ? colllocale : "",
                                                                  fout);
                }
                else
                {
-                       if (!collcollate || !collctype || colliculocale ||
+                       if (!collcollate || !collctype || colllocale ||
                                strcmp(collcollate, collctype) != 0)
                                pg_log_warning("invalid collation \"%s\"", qcollname);
 
@@ -13914,7 +13920,7 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
        }
        else if (collprovider[0] == 'c')
        {
-               if (colliculocale || collicurules || !collcollate || !collctype)
+               if (colllocale || collicurules || !collcollate || !collctype)
                        pg_log_warning("invalid collation \"%s\"", qcollname);
 
                if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
index 183c2f84eb45ce7fd3ddc9dbe68fe0485f20a3b9..b5b8d116027c8de36eaaed9d76e4fb85efa27d79 100644 (file)
@@ -328,18 +328,24 @@ get_template0_info(ClusterInfo *cluster)
        int                     i_datlocprovider;
        int                     i_datcollate;
        int                     i_datctype;
-       int                     i_daticulocale;
+       int                     i_datlocale;
 
-       if (GET_MAJOR_VERSION(cluster->major_version) >= 1500)
+       if (GET_MAJOR_VERSION(cluster->major_version) >= 1700)
                dbres = executeQueryOrDie(conn,
                                                                  "SELECT encoding, datlocprovider, "
-                                                                 "       datcollate, datctype, daticulocale "
+                                                                 "       datcollate, datctype, datlocale "
+                                                                 "FROM pg_catalog.pg_database "
+                                                                 "WHERE datname='template0'");
+       else if (GET_MAJOR_VERSION(cluster->major_version) >= 1500)
+               dbres = executeQueryOrDie(conn,
+                                                                 "SELECT encoding, datlocprovider, "
+                                                                 "       datcollate, datctype, daticulocale AS datlocale "
                                                                  "FROM pg_catalog.pg_database "
                                                                  "WHERE datname='template0'");
        else
                dbres = executeQueryOrDie(conn,
                                                                  "SELECT encoding, 'c' AS datlocprovider, "
-                                                                 "       datcollate, datctype, NULL AS daticulocale "
+                                                                 "       datcollate, datctype, NULL AS datlocale "
                                                                  "FROM pg_catalog.pg_database "
                                                                  "WHERE datname='template0'");
 
@@ -353,16 +359,16 @@ get_template0_info(ClusterInfo *cluster)
        i_datlocprovider = PQfnumber(dbres, "datlocprovider");
        i_datcollate = PQfnumber(dbres, "datcollate");
        i_datctype = PQfnumber(dbres, "datctype");
-       i_daticulocale = PQfnumber(dbres, "daticulocale");
+       i_datlocale = PQfnumber(dbres, "datlocale");
 
        locale->db_encoding = atoi(PQgetvalue(dbres, 0, i_datencoding));
        locale->db_collprovider = PQgetvalue(dbres, 0, i_datlocprovider)[0];
        locale->db_collate = pg_strdup(PQgetvalue(dbres, 0, i_datcollate));
        locale->db_ctype = pg_strdup(PQgetvalue(dbres, 0, i_datctype));
-       if (PQgetisnull(dbres, 0, i_daticulocale))
-               locale->db_iculocale = NULL;
+       if (PQgetisnull(dbres, 0, i_datlocale))
+               locale->db_locale = NULL;
        else
-               locale->db_iculocale = pg_strdup(PQgetvalue(dbres, 0, i_daticulocale));
+               locale->db_locale = pg_strdup(PQgetvalue(dbres, 0, i_datlocale));
 
        cluster->template0 = locale;
 
@@ -392,12 +398,15 @@ get_db_infos(ClusterInfo *cluster)
 
        snprintf(query, sizeof(query),
                         "SELECT d.oid, d.datname, d.encoding, d.datcollate, d.datctype, ");
-       if (GET_MAJOR_VERSION(cluster->major_version) < 1500)
+       if (GET_MAJOR_VERSION(cluster->major_version) >= 1700)
+               snprintf(query + strlen(query), sizeof(query) - strlen(query),
+                                "datlocprovider, datlocale, ");
+       else if (GET_MAJOR_VERSION(cluster->major_version) >= 1500)
                snprintf(query + strlen(query), sizeof(query) - strlen(query),
-                                "'c' AS datlocprovider, NULL AS daticulocale, ");
+                                "datlocprovider, daticulocale AS datlocale, ");
        else
                snprintf(query + strlen(query), sizeof(query) - strlen(query),
-                                "datlocprovider, daticulocale, ");
+                                "'c' AS datlocprovider, NULL AS datlocale, ");
        snprintf(query + strlen(query), sizeof(query) - strlen(query),
                         "pg_catalog.pg_tablespace_location(t.oid) AS spclocation "
                         "FROM pg_catalog.pg_database d "
index 10c94a6c1fc82ce07756768ea6772cbb9a58232d..bb261353bdd177c46a885942d78a831b77c5f571 100644 (file)
@@ -391,7 +391,7 @@ setup(char *argv0, bool *live_check)
  * Copy locale and encoding information into the new cluster's template0.
  *
  * We need to copy the encoding, datlocprovider, datcollate, datctype, and
- * daticulocale. We don't need datcollversion because that's never set for
+ * datlocale. We don't need datcollversion because that's never set for
  * template0.
  */
 static void
@@ -400,7 +400,7 @@ set_locale_and_encoding(void)
        PGconn     *conn_new_template1;
        char       *datcollate_literal;
        char       *datctype_literal;
-       char       *daticulocale_literal = NULL;
+       char       *datlocale_literal = NULL;
        DbLocaleInfo *locale = old_cluster.template0;
 
        prep_status("Setting locale and encoding for new cluster");
@@ -414,15 +414,29 @@ set_locale_and_encoding(void)
        datctype_literal = PQescapeLiteral(conn_new_template1,
                                                                           locale->db_ctype,
                                                                           strlen(locale->db_ctype));
-       if (locale->db_iculocale)
-               daticulocale_literal = PQescapeLiteral(conn_new_template1,
-                                                                                          locale->db_iculocale,
-                                                                                          strlen(locale->db_iculocale));
+       if (locale->db_locale)
+               datlocale_literal = PQescapeLiteral(conn_new_template1,
+                                                                                       locale->db_locale,
+                                                                                       strlen(locale->db_locale));
        else
-               daticulocale_literal = pg_strdup("NULL");
+               datlocale_literal = pg_strdup("NULL");
 
        /* update template0 in new cluster */
-       if (GET_MAJOR_VERSION(new_cluster.major_version) >= 1500)
+       if (GET_MAJOR_VERSION(new_cluster.major_version) >= 1700)
+               PQclear(executeQueryOrDie(conn_new_template1,
+                                                                 "UPDATE pg_catalog.pg_database "
+                                                                 "  SET encoding = %d, "
+                                                                 "      datlocprovider = '%c', "
+                                                                 "      datcollate = %s, "
+                                                                 "      datctype = %s, "
+                                                                 "      datlocale = %s "
+                                                                 "  WHERE datname = 'template0' ",
+                                                                 locale->db_encoding,
+                                                                 locale->db_collprovider,
+                                                                 datcollate_literal,
+                                                                 datctype_literal,
+                                                                 datlocale_literal));
+       else if (GET_MAJOR_VERSION(new_cluster.major_version) >= 1500)
                PQclear(executeQueryOrDie(conn_new_template1,
                                                                  "UPDATE pg_catalog.pg_database "
                                                                  "  SET encoding = %d, "
@@ -435,7 +449,7 @@ set_locale_and_encoding(void)
                                                                  locale->db_collprovider,
                                                                  datcollate_literal,
                                                                  datctype_literal,
-                                                                 daticulocale_literal));
+                                                                 datlocale_literal));
        else
                PQclear(executeQueryOrDie(conn_new_template1,
                                                                  "UPDATE pg_catalog.pg_database "
@@ -449,7 +463,7 @@ set_locale_and_encoding(void)
 
        PQfreemem(datcollate_literal);
        PQfreemem(datctype_literal);
-       PQfreemem(daticulocale_literal);
+       PQfreemem(datlocale_literal);
 
        PQfinish(conn_new_template1);
 
index 857d715049ee01d48df5bc4b65e044620b86aeb2..c0bfb002d2d3a61c227b7d5e9e764963d7cee65e 100644 (file)
@@ -208,7 +208,7 @@ typedef struct
        char       *db_collate;
        char       *db_ctype;
        char            db_collprovider;
-       char       *db_iculocale;
+       char       *db_locale;
        int                     db_encoding;
 } DbLocaleInfo;
 
index fa836e83e57851382db35a3d49457e74878be350..78fa319fa71563145f670b339edf5e76b14d7c44 100644 (file)
@@ -92,6 +92,10 @@ my $oldnode =
   PostgreSQL::Test::Cluster->new('old_node',
        install_path => $ENV{oldinstall});
 
+# Numeric major version of old cluster, ignoring "devel" suffix.
+# Needed for testing upgrades from development version to itself.
+my $old_major_version = int($oldnode->pg_version =~ s/devel//rg);
+
 my %node_params = ();
 
 # To increase coverage of non-standard segment size and group access without
@@ -111,15 +115,22 @@ if ($oldnode->pg_version >= 11)
 my $original_encoding = "6";    # UTF-8
 my $original_provider = "c";
 my $original_locale = "C";
-my $original_iculocale = "";
+my $original_datlocale = "";
 my $provider_field = "'c' AS datlocprovider";
-my $iculocale_field = "NULL AS daticulocale";
-if ($oldnode->pg_version >= 15 && $ENV{with_icu} eq 'yes')
+my $old_datlocale_field = "NULL AS datlocale";
+if ($old_major_version >= 15 && $ENV{with_icu} eq 'yes')
 {
        $provider_field = "datlocprovider";
-       $iculocale_field = "daticulocale";
+       if ($old_major_version >= 17)
+       {
+               $old_datlocale_field = "datlocale";
+       }
+       else
+       {
+               $old_datlocale_field = "daticulocale AS datlocale";
+       }
        $original_provider = "i";
-       $original_iculocale = "fr-CA";
+       $original_datlocale = "fr-CA";
 }
 
 my @initdb_params = @custom_opts;
@@ -139,10 +150,10 @@ $oldnode->start;
 my $result;
 $result = $oldnode->safe_psql(
        'postgres',
-       "SELECT encoding, $provider_field, datcollate, datctype, $iculocale_field
+       "SELECT encoding, $provider_field, datcollate, datctype, $old_datlocale_field
                  FROM pg_database WHERE datname='template0'");
 is( $result,
-       "$original_encoding|$original_provider|$original_locale|$original_locale|$original_iculocale",
+       "$original_encoding|$original_provider|$original_locale|$original_locale|$original_datlocale",
        "check locales in original cluster");
 
 # The default location of the source code is the root of this directory.
@@ -426,10 +437,10 @@ if (-d $log_path)
 # Test that upgraded cluster has original locale settings.
 $result = $newnode->safe_psql(
        'postgres',
-       "SELECT encoding, $provider_field, datcollate, datctype, $iculocale_field
+       "SELECT encoding, $provider_field, datcollate, datctype, datlocale
                  FROM pg_database WHERE datname='template0'");
 is( $result,
-       "$original_encoding|$original_provider|$original_locale|$original_locale|$original_iculocale",
+       "$original_encoding|$original_provider|$original_locale|$original_locale|$original_datlocale",
        "check that locales in new cluster match original cluster");
 
 # Second dump from the upgraded instance.
index c05befbb6f2430f5ba016cb4a358a729447c9a9c..68b2ea8872a430e5e40f445b557cbbad75e07876 100644 (file)
@@ -937,14 +937,18 @@ listAllDbs(const char *pattern, bool verbose)
                                          "  d.datctype as \"%s\",\n",
                                          gettext_noop("Collate"),
                                          gettext_noop("Ctype"));
-       if (pset.sversion >= 150000)
+       if (pset.sversion >= 170000)
+               appendPQExpBuffer(&buf,
+                                                 "  d.datlocale as \"%s\",\n",
+                                                 gettext_noop("Locale"));
+       else if (pset.sversion >= 150000)
                appendPQExpBuffer(&buf,
                                                  "  d.daticulocale as \"%s\",\n",
-                                                 gettext_noop("ICU Locale"));
+                                                 gettext_noop("Locale"));
        else
                appendPQExpBuffer(&buf,
                                                  "  NULL as \"%s\",\n",
-                                                 gettext_noop("ICU Locale"));
+                                                 gettext_noop("Locale"));
        if (pset.sversion >= 160000)
                appendPQExpBuffer(&buf,
                                                  "  d.daticurules as \"%s\",\n",
@@ -4983,14 +4987,18 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
                                          gettext_noop("Collate"),
                                          gettext_noop("Ctype"));
 
-       if (pset.sversion >= 150000)
+       if (pset.sversion >= 170000)
+               appendPQExpBuffer(&buf,
+                                                 "  c.colllocale AS \"%s\",\n",
+                                                 gettext_noop("Locale"));
+       else if (pset.sversion >= 150000)
                appendPQExpBuffer(&buf,
                                                  "  c.colliculocale AS \"%s\",\n",
-                                                 gettext_noop("ICU Locale"));
+                                                 gettext_noop("Locale"));
        else
                appendPQExpBuffer(&buf,
                                                  "  c.collcollate AS \"%s\",\n",
-                                                 gettext_noop("ICU Locale"));
+                                                 gettext_noop("Locale"));
 
        if (pset.sversion >= 160000)
                appendPQExpBuffer(&buf,
index e8dad22597b4fb37478a3051978d7a1b86047728..f085221155653b55d3eb1e658cd269953c4335fd 100644 (file)
@@ -57,6 +57,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     202403071
+#define CATALOG_VERSION_NO     202403091
 
 #endif
index 10c363d2ee51a05dfad1f81363c590028365fa16..7396ff10c45dea27be4380d4263460c578f332c0 100644 (file)
@@ -29,6 +29,6 @@
 { oid => '963',
   descr => 'sorts using the Unicode Collation Algorithm with default settings',
   collname => 'unicode', collprovider => 'i', collencoding => '-1',
-  colliculocale => 'und' },
+  colllocale => 'und' },
 
 ]
index 5f08eb0a4afb25d24b145536047164783543aba6..a3e196fb53d6df0ce1a387c5fa87e709c646b022 100644 (file)
@@ -42,7 +42,7 @@ CATALOG(pg_collation,3456,CollationRelationId)
 #ifdef CATALOG_VARLEN                  /* variable-length fields start here */
        text            collcollate BKI_DEFAULT(_null_);        /* LC_COLLATE setting */
        text            collctype BKI_DEFAULT(_null_);  /* LC_CTYPE setting */
-       text            colliculocale BKI_DEFAULT(_null_);      /* ICU locale ID */
+       text            colllocale BKI_DEFAULT(_null_); /* locale ID */
        text            collicurules BKI_DEFAULT(_null_);       /* ICU collation rules */
        text            collversion BKI_DEFAULT(_null_);        /* provider-dependent
                                                                                                         * version of collation
@@ -94,7 +94,7 @@ extern Oid    CollationCreate(const char *collname, Oid collnamespace,
                                                        bool collisdeterministic,
                                                        int32 collencoding,
                                                        const char *collcollate, const char *collctype,
-                                                       const char *colliculocale,
+                                                       const char *colllocale,
                                                        const char *collicurules,
                                                        const char *collversion,
                                                        bool if_not_exists,
index 4306e8a3e8a96c9bb449405978f53592f7fa54e5..c2ba636f8d9c92fa8855aa97a0ec8a2e0cc46113 100644 (file)
@@ -18,7 +18,7 @@
   datlocprovider => 'LOCALE_PROVIDER', datistemplate => 't',
   datallowconn => 't', dathasloginevt => 'f', datconnlimit => '-1', datfrozenxid => '0',
   datminmxid => '1', dattablespace => 'pg_default', datcollate => 'LC_COLLATE',
-  datctype => 'LC_CTYPE', daticulocale => 'ICU_LOCALE',
+  datctype => 'LC_CTYPE', datlocale => 'DATLOCALE',
   daticurules => 'ICU_RULES', datacl => '_null_' },
 
 ]
index 014baa7babac7433f0be0b3bb79962a5cf5ce46c..dbd4379ffa5b743fcc49234996078c86c5cce59b 100644 (file)
@@ -75,7 +75,7 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
        text            datctype BKI_FORCE_NOT_NULL;
 
        /* ICU locale ID */
-       text            daticulocale;
+       text            datlocale;
 
        /* ICU collation rules */
        text            daticurules;
index 7a05c75967f5df99e0cc4662db3b235cb62c076e..8ca93f4deaf78b65c3db861c68d81b54f7909c93 100644 (file)
@@ -1024,7 +1024,7 @@ SET icu_validation_level = disabled;
 do $$
 BEGIN
   EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||
-          quote_literal((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
+          quote_literal((SELECT CASE WHEN datlocprovider='i' THEN datlocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
 END
 $$;
 CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@@ -1032,7 +1032,7 @@ ERROR:  collation "test0" already exists
 do $$
 BEGIN
   EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' ||
-          quote_literal((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
+          quote_literal((SELECT CASE WHEN datlocprovider='i' THEN datlocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
 END
 $$;
 RESET icu_validation_level;
index ad027725624b7ba1d02e5f69d12bce2d83dc20b6..69060fe3c003af03a08cb230eded485cee38ae31 100644 (file)
@@ -6221,9 +6221,9 @@ List of schemas
 (0 rows)
 
 \dO "no.such.collation"
-                                  List of collations
- Schema | Name | Provider | Collate | Ctype | ICU Locale | ICU Rules | Deterministic? 
---------+------+----------+---------+-------+------------+-----------+----------------
+                                List of collations
+ Schema | Name | Provider | Collate | Ctype | Locale | ICU Rules | Deterministic? 
+--------+------+----------+---------+-------+--------+-----------+----------------
 (0 rows)
 
 \dp "no.such.access.privilege"
@@ -6410,9 +6410,9 @@ cross-database references are not implemented: "no.such.schema"."no.such.languag
 (0 rows)
 
 \dO "no.such.schema"."no.such.collation"
-                                  List of collations
- Schema | Name | Provider | Collate | Ctype | ICU Locale | ICU Rules | Deterministic? 
---------+------+----------+---------+-------+------------+-----------+----------------
+                                List of collations
+ Schema | Name | Provider | Collate | Ctype | Locale | ICU Rules | Deterministic? 
+--------+------+----------+---------+-------+--------+-----------+----------------
 (0 rows)
 
 \dp "no.such.schema"."no.such.access.privilege"
@@ -6553,9 +6553,9 @@ List of text search templates
 (0 rows)
 
 \dO regression."no.such.schema"."no.such.collation"
-                                  List of collations
- Schema | Name | Provider | Collate | Ctype | ICU Locale | ICU Rules | Deterministic? 
---------+------+----------+---------+-------+------------+-----------+----------------
+                                List of collations
+ Schema | Name | Provider | Collate | Ctype | Locale | ICU Rules | Deterministic? 
+--------+------+----------+---------+-------+--------+-----------+----------------
 (0 rows)
 
 \dp regression."no.such.schema"."no.such.access.privilege"
index 3db9e2591380cd646f408bfa5846032cb356c1f2..03837de846bdaefb71509ccac6eb76bdd234af0e 100644 (file)
@@ -363,14 +363,14 @@ SET icu_validation_level = disabled;
 do $$
 BEGIN
   EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||
-          quote_literal((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
+          quote_literal((SELECT CASE WHEN datlocprovider='i' THEN datlocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
 END
 $$;
 CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
 do $$
 BEGIN
   EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' ||
-          quote_literal((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
+          quote_literal((SELECT CASE WHEN datlocprovider='i' THEN datlocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
 END
 $$;