diff options
author | Jeff Davis <jdavis@postgresql.org> | 2024-07-28 13:07:25 -0700 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2024-07-28 13:07:25 -0700 |
commit | 1c461a8d8d3c7a4655fdb944ffca94b1e49e5b3d (patch) | |
tree | dac5da64d9684260c24d8fe601be2b97b14da083 /src/backend/utils/init/postinit.c | |
parent | 005c6b833f7866b71b50a5382e30d6c3f695306e (diff) | |
download | postgresql-1c461a8d8d3c7a4655fdb944ffca94b1e49e5b3d.tar.gz postgresql-1c461a8d8d3c7a4655fdb944ffca94b1e49e5b3d.zip |
Refactor: make default_locale internal to pg_locale.c.
Discussion: https://postgr.es/m/2228884bb1f1a02614b39f71a90c94d2cc8a3a2f.camel@j-davis.com
Reviewed-by: Peter Eisentraut, Andreas Karlsson
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r-- | src/backend/utils/init/postinit.c | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 25867c8bd5b..fe703e4f19f 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -318,7 +318,6 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect bool isnull; char *collate; char *ctype; - char *datlocale; /* Fetch our pg_database row normally, via syscache */ tup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId)); @@ -423,42 +422,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect strcmp(ctype, "POSIX") == 0) database_ctype_is_c = true; - if (dbform->datlocprovider == COLLPROVIDER_BUILTIN) - { - datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_datlocale); - datlocale = TextDatumGetCString(datum); - - builtin_validate_locale(dbform->encoding, datlocale); - - default_locale.info.builtin.locale = MemoryContextStrdup( - TopMemoryContext, datlocale); - } - else if (dbform->datlocprovider == COLLPROVIDER_ICU) - { - char *icurules; - - datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_datlocale); - datlocale = TextDatumGetCString(datum); - - datum = SysCacheGetAttr(DATABASEOID, tup, Anum_pg_database_daticurules, &isnull); - if (!isnull) - icurules = TextDatumGetCString(datum); - else - icurules = NULL; - - make_icu_collator(datlocale, icurules, &default_locale); - } - else - datlocale = NULL; - - default_locale.provider = dbform->datlocprovider; - - /* - * Default locale is currently always deterministic. Nondeterministic - * locales currently don't support pattern matching, which would break a - * lot of things if applied globally. - */ - default_locale.deterministic = true; + init_database_collation(); /* * Check collation version. See similar code in @@ -478,7 +442,10 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect if (dbform->datlocprovider == COLLPROVIDER_LIBC) locale = collate; else - locale = datlocale; + { + datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_datlocale); + locale = TextDatumGetCString(datum); + } actual_versionstr = get_collation_actual_version(dbform->datlocprovider, locale); if (!actual_versionstr) |