1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00

Address more review comments on commit 2d819a08a1.

Based on comments from Peter Eisentraut.

 * Document CREATE DATABASE ... BUILTIN_LOCALE.
 * Determine required encoding based on locale name for CREATE
   COLLATION. Use -1 for "C" (requires catversion bump).
 * initdb output fixups.
 * Make ctype_is_c a constant true for now.
 * Fixups to ICU 010_create_database.pl test.

Discussion: https://postgr.es/m/4135cf11-206d-40ed-96c0-9363c1232379@eisentraut.org
This commit is contained in:
Jeff Davis
2024-03-18 11:56:45 -07:00
parent 66ab9371a2
commit 846311051e
8 changed files with 58 additions and 14 deletions

View File

@@ -1270,14 +1270,8 @@ lookup_collation_cache(Oid collation, bool set_flags)
if (collform->collprovider == COLLPROVIDER_BUILTIN)
{
Datum datum;
const char *colllocale;
datum = SysCacheGetAttrNotNull(COLLOID, tp, Anum_pg_collation_colllocale);
colllocale = TextDatumGetCString(datum);
cache_entry->collate_is_c = true;
cache_entry->ctype_is_c = (strcmp(colllocale, "C") == 0);
cache_entry->ctype_is_c = true;
}
else if (collform->collprovider == COLLPROVIDER_LIBC)
{
@@ -2501,6 +2495,26 @@ pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src,
return result;
}
/*
* Return required encoding ID for the given locale, or -1 if any encoding is
* valid for the locale.
*
* The only supported locale for the builtin provider is "C", and it's
* available for any encoding.
*/
int
builtin_locale_encoding(const char *locale)
{
if (strcmp(locale, "C") == 0)
return -1;
else
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("invalid locale name \"%s\" for builtin provider",
locale)));
}
/*
* Validate the locale and encoding combination, and return the canonical form
* of the locale name.