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

Commit f696c0c

Browse files
committed
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
1 parent 81d13a8 commit f696c0c

22 files changed

+231
-169
lines changed

doc/src/sgml/bki.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
datlocprovider => 'LOCALE_PROVIDER', datistemplate => 't',
187187
datallowconn => 't', dathasloginevt => 'f', datconnlimit => '-1', datfrozenxid => '0',
188188
datminmxid => '1', dattablespace => 'pg_default', datcollate => 'LC_COLLATE',
189-
datctype => 'LC_CTYPE', daticulocale => 'ICU_LOCALE', datacl => '_null_' },
189+
datctype => 'LC_CTYPE', datlocale => 'DATLOCALE', datacl => '_null_' },
190190

191191
]
192192
]]></programlisting>

doc/src/sgml/catalogs.sgml

+20-6
Original file line numberDiff line numberDiff line change
@@ -2407,7 +2407,10 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
24072407
<structfield>collcollate</structfield> <type>text</type>
24082408
</para>
24092409
<para>
2410-
<symbol>LC_COLLATE</symbol> for this collation object
2410+
<symbol>LC_COLLATE</symbol> for this collation object. If the provider is
2411+
not <literal>libc</literal>, <structfield>collcollate</structfield> is
2412+
<literal>NULL</literal> and <structfield>colllocale</structfield> is
2413+
used instead.
24112414
</para></entry>
24122415
</row>
24132416

@@ -2416,16 +2419,23 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
24162419
<structfield>collctype</structfield> <type>text</type>
24172420
</para>
24182421
<para>
2419-
<symbol>LC_CTYPE</symbol> for this collation object
2422+
<symbol>LC_CTYPE</symbol> for this collation object. If the provider is
2423+
not <literal>libc</literal>, <structfield>collctype</structfield> is
2424+
<literal>NULL</literal> and <structfield>colllocale</structfield> is
2425+
used instead.
24202426
</para></entry>
24212427
</row>
24222428

24232429
<row>
24242430
<entry role="catalog_table_entry"><para role="column_definition">
2425-
<structfield>colliculocale</structfield> <type>text</type>
2431+
<structfield>colllocale</structfield> <type>text</type>
24262432
</para>
24272433
<para>
2428-
ICU locale ID for this collation object
2434+
Collation provider locale name for this collation object. If the
2435+
provider is <literal>libc</literal>,
2436+
<structfield>colllocale</structfield> is <literal>NULL</literal>;
2437+
<structfield>collcollate</structfield> and
2438+
<structfield>collctype</structfield> are used instead.
24292439
</para></entry>
24302440
</row>
24312441

@@ -3131,10 +3141,14 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
31313141

31323142
<row>
31333143
<entry role="catalog_table_entry"><para role="column_definition">
3134-
<structfield>daticulocale</structfield> <type>text</type>
3144+
<structfield>datlocale</structfield> <type>text</type>
31353145
</para>
31363146
<para>
3137-
ICU locale ID for this database
3147+
Collation provider locale name for this database. If the
3148+
provider is <literal>libc</literal>,
3149+
<structfield>datlocale</structfield> is <literal>NULL</literal>;
3150+
<structfield>datcollate</structfield> and
3151+
<structfield>datctype</structfield> are used instead.
31383152
</para></entry>
31393153
</row>
31403154

src/backend/catalog/pg_collation.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ CollationCreate(const char *collname, Oid collnamespace,
4545
bool collisdeterministic,
4646
int32 collencoding,
4747
const char *collcollate, const char *collctype,
48-
const char *colliculocale,
48+
const char *colllocale,
4949
const char *collicurules,
5050
const char *collversion,
5151
bool if_not_exists,
@@ -64,7 +64,7 @@ CollationCreate(const char *collname, Oid collnamespace,
6464
Assert(collname);
6565
Assert(collnamespace);
6666
Assert(collowner);
67-
Assert((collcollate && collctype) || colliculocale);
67+
Assert((collcollate && collctype) || colllocale);
6868

6969
/*
7070
* Make sure there is no existing collation of same name & encoding.
@@ -187,10 +187,10 @@ CollationCreate(const char *collname, Oid collnamespace,
187187
values[Anum_pg_collation_collctype - 1] = CStringGetTextDatum(collctype);
188188
else
189189
nulls[Anum_pg_collation_collctype - 1] = true;
190-
if (colliculocale)
191-
values[Anum_pg_collation_colliculocale - 1] = CStringGetTextDatum(colliculocale);
190+
if (colllocale)
191+
values[Anum_pg_collation_colllocale - 1] = CStringGetTextDatum(colllocale);
192192
else
193-
nulls[Anum_pg_collation_colliculocale - 1] = true;
193+
nulls[Anum_pg_collation_colllocale - 1] = true;
194194
if (collicurules)
195195
values[Anum_pg_collation_collicurules - 1] = CStringGetTextDatum(collicurules);
196196
else

src/backend/commands/collationcmds.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
6666
DefElem *versionEl = NULL;
6767
char *collcollate;
6868
char *collctype;
69-
char *colliculocale;
69+
char *colllocale;
7070
char *collicurules;
7171
bool collisdeterministic;
7272
int collencoding;
@@ -157,11 +157,11 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
157157
else
158158
collctype = NULL;
159159

160-
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_colliculocale, &isnull);
160+
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_colllocale, &isnull);
161161
if (!isnull)
162-
colliculocale = TextDatumGetCString(datum);
162+
colllocale = TextDatumGetCString(datum);
163163
else
164-
colliculocale = NULL;
164+
colllocale = NULL;
165165

166166
/*
167167
* 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
194194

195195
collcollate = NULL;
196196
collctype = NULL;
197-
colliculocale = NULL;
197+
colllocale = NULL;
198198
collicurules = NULL;
199199

200200
if (providerEl)
@@ -234,7 +234,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
234234
collctype = defGetString(localeEl);
235235
}
236236
else
237-
colliculocale = defGetString(localeEl);
237+
colllocale = defGetString(localeEl);
238238
}
239239

240240
if (lccollateEl)
@@ -259,7 +259,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
259259
}
260260
else if (collprovider == COLLPROVIDER_ICU)
261261
{
262-
if (!colliculocale)
262+
if (!colllocale)
263263
ereport(ERROR,
264264
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
265265
errmsg("parameter \"%s\" must be specified",
@@ -271,20 +271,20 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
271271
*/
272272
if (!IsBinaryUpgrade)
273273
{
274-
char *langtag = icu_language_tag(colliculocale,
274+
char *langtag = icu_language_tag(colllocale,
275275
icu_validation_level);
276276

277-
if (langtag && strcmp(colliculocale, langtag) != 0)
277+
if (langtag && strcmp(colllocale, langtag) != 0)
278278
{
279279
ereport(NOTICE,
280280
(errmsg("using standard form \"%s\" for ICU locale \"%s\"",
281-
langtag, colliculocale)));
281+
langtag, colllocale)));
282282

283-
colliculocale = langtag;
283+
colllocale = langtag;
284284
}
285285
}
286286

287-
icu_validate_locale(colliculocale);
287+
icu_validate_locale(colllocale);
288288
}
289289

290290
/*
@@ -332,7 +332,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
332332
}
333333

334334
if (!collversion)
335-
collversion = get_collation_actual_version(collprovider, collprovider == COLLPROVIDER_ICU ? colliculocale : collcollate);
335+
collversion = get_collation_actual_version(collprovider, collprovider == COLLPROVIDER_ICU ? colllocale : collcollate);
336336

337337
newoid = CollationCreate(collName,
338338
collNamespace,
@@ -342,7 +342,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
342342
collencoding,
343343
collcollate,
344344
collctype,
345-
colliculocale,
345+
colllocale,
346346
collicurules,
347347
collversion,
348348
if_not_exists,
@@ -433,7 +433,7 @@ AlterCollation(AlterCollationStmt *stmt)
433433
datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion, &isnull);
434434
oldversion = isnull ? NULL : TextDatumGetCString(datum);
435435

436-
datum = SysCacheGetAttrNotNull(COLLOID, tup, collForm->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate);
436+
datum = SysCacheGetAttrNotNull(COLLOID, tup, collForm->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colllocale : Anum_pg_collation_collcollate);
437437
newversion = get_collation_actual_version(collForm->collprovider, TextDatumGetCString(datum));
438438

439439
/* cannot change from NULL to non-NULL or vice versa */
@@ -500,7 +500,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
500500

501501
datum = SysCacheGetAttrNotNull(DATABASEOID, dbtup,
502502
provider == COLLPROVIDER_ICU ?
503-
Anum_pg_database_daticulocale : Anum_pg_database_datcollate);
503+
Anum_pg_database_datlocale : Anum_pg_database_datcollate);
504504

505505
locale = TextDatumGetCString(datum);
506506

@@ -521,7 +521,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
521521
Assert(provider != COLLPROVIDER_DEFAULT);
522522
datum = SysCacheGetAttrNotNull(COLLOID, colltp,
523523
provider == COLLPROVIDER_ICU ?
524-
Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate);
524+
Anum_pg_collation_colllocale : Anum_pg_collation_collcollate);
525525

526526
locale = TextDatumGetCString(datum);
527527

0 commit comments

Comments
 (0)