From 025a759ff37046dac7864bedc16fcf0b1d1ae9b8 Mon Sep 17 00:00:00 2001
From: Jeff Davis <jeff@j-davis.com>
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

