diff options
author | Jeff Davis <jdavis@postgresql.org> | 2024-03-09 14:48:18 -0800 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2024-03-09 14:48:18 -0800 |
commit | f696c0cd5f299f1b51e214efc55a22a782cc175d (patch) | |
tree | f834ff70d179f4d21f3def9ee8e4c4f1fe4922ad /src/backend/commands | |
parent | 81d13a8dc066e571dca032da0a5fc1d81214d2bb (diff) | |
download | postgresql-f696c0cd5f299f1b51e214efc55a22a782cc175d.tar.gz postgresql-f696c0cd5f299f1b51e214efc55a22a782cc175d.zip |
Catalog changes preparing for builtin collation provider.
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
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/collationcmds.c | 34 | ||||
-rw-r--r-- | src/backend/commands/dbcommands.c | 68 |
2 files changed, 51 insertions, 51 deletions
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index 106e696da8d..59d7e17804b 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -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); diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index b256d6d0f7d..0f27d7b14cf 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -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) { |