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 <ayushtiwari.slg01@gmail.com>
Backpatch-through: 17
This commit is contained in:
Jeff Davis 2026-06-08 13:10:40 -07:00
parent f52c44ce48
commit 1c77203c15

View file

@ -1192,7 +1192,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