Not known to be reachable after dbf217c1c7, but defend against similar
issues in the future. For instance, an extension might encounter the
problem by calling pg_newlocale_from_collation(DEFAULT_COLLATION_OID)
from _PG_init(), and end up with a NULL pointer dereference.
Backport through 17, though patch is different in 17 (also attached).
Regards,
Jeff Davis
From 025a759ff37046dac7864bedc16fcf0b1d1ae9b8 Mon Sep 17 00:00:00 2001
From: Jeff Davis <[email protected]>
Date: Wed, 22 Apr 2026 15:09:27 -0700
Subject: [PATCH v1.19] Guard against uninitialized default locale.
No known problem today, but defend against issues like dbf217c1c7 in
the future.
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 6c5c1019e1e..7cd1a060759 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1192,7 +1192,13 @@ pg_newlocale_from_collation(Oid collid)
bool found;
if (collid == DEFAULT_COLLATION_OID)
+ {
+ /* should not happen */
+ if (default_locale == NULL)
+ elog(ERROR, "default locale not initialized");
+
return default_locale;
+ }
/*
* Some callers expect C_COLLATION_OID to succeed even without catalog
--
2.43.0
From 4d4c837371fc66850b9499d30dcad43b1f5a764d Mon Sep 17 00:00:00 2001
From: Jeff Davis <[email protected]>
Date: Wed, 22 Apr 2026 15:09:27 -0700
Subject: [PATCH v1.17] Guard against uninitialized default locale.
No known problem today, but defend against issues like dbf217c1c7 in
the future.
Backpatch-through: 17
---
src/backend/utils/adt/pg_locale.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index aa0114ce120..7a51b953f0a 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 */
+ 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 */
+ 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 */
+ if (default_locale.provider == '\0')
+ elog(ERROR, "default locale not initialized");
+
if (default_locale.provider == COLLPROVIDER_LIBC)
return (pg_locale_t) 0;
else
--
2.43.0