From 26bd362655bc16e2f86eedb87a7d7c37a1d553d3 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Mon, 8 Jun 2026 13:10:40 -0700 Subject: [PATCH] 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 --- src/backend/utils/adt/pg_locale.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index cb1744f4d69..78243b2c795 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -1199,7 +1199,13 @@ pg_newlocale_from_collation(Oid collid) bool found; if (collid == DEFAULT_COLLATION_OID) + { + /* should not happen: init_database_collation() not yet run */ + if (default_locale == NULL) + elog(ERROR, "default locale not initialized"); + return default_locale; + } /* * Some callers expect C_COLLATION_OID to succeed even without catalog