From: Jeff Davis Date: Mon, 8 Jun 2026 20:11:59 +0000 (-0700) Subject: Guard against uninitialized default locale. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1d76927469d35f8dd6d90509618fda3e6bc3b7d6;p=thirdparty%2Fpostgresql.git Guard against uninitialized default locale. No known problem today, but defend against issues like dbf217c1c7 in the future. Discussion: https://postgr.es/m/d080287d8d2d14c246c86be2e9eb611fb6b27b11.camel@j-davis.com Reviewed-by: Ayush Tiwari Backpatch-through: 17 --- diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 276d78d07c0..31c35c48e38 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -1361,6 +1361,10 @@ lc_collate_is_c(Oid collation) if (result >= 0) return (bool) result; + /* should not happen: CheckMyDatabase() not yet run */ + if (default_locale.provider == '\0') + elog(ERROR, "default locale not initialized"); + if (default_locale.provider == COLLPROVIDER_BUILTIN) { result = true; @@ -1428,6 +1432,10 @@ lc_ctype_is_c(Oid collation) if (result >= 0) return (bool) result; + /* should not happen: CheckMyDatabase() not yet run */ + if (default_locale.provider == '\0') + elog(ERROR, "default locale not initialized"); + if (default_locale.provider == COLLPROVIDER_BUILTIN) { localeptr = default_locale.info.builtin.locale; @@ -1586,6 +1594,10 @@ pg_newlocale_from_collation(Oid collid) if (collid == DEFAULT_COLLATION_OID) { + /* should not happen: CheckMyDatabase() not yet run */ + if (default_locale.provider == '\0') + elog(ERROR, "default locale not initialized"); + if (default_locale.provider == COLLPROVIDER_LIBC) return (pg_locale_t) 0; else