]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add pg_database_locale() to retrieve database default locale.
authorJeff Davis <jdavis@postgresql.org>
Sat, 18 Oct 2025 23:25:23 +0000 (16:25 -0700)
committerJeff Davis <jdavis@postgresql.org>
Sat, 18 Oct 2025 23:25:23 +0000 (16:25 -0700)
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/0151ad01239e2cc7b3139644358cf8f7b9622ff7.camel@j-davis.com

src/backend/utils/adt/pg_locale.c
src/include/utils/pg_locale.h

index 3860ada19052b811c80a28ea5167901e948fa138..00d1e03147243e6bb26f5430083882b93cbb15d5 100644 (file)
@@ -1162,6 +1162,15 @@ init_database_collation(void)
        default_locale = result;
 }
 
+/*
+ * Get database default locale.
+ */
+pg_locale_t
+pg_database_locale(void)
+{
+       return pg_newlocale_from_collation(DEFAULT_COLLATION_OID);
+}
+
 /*
  * Create a pg_locale_t from a collation OID.  Results are cached for the
  * lifetime of the backend.  Thus, do not free the result with freelocale().
index 29c21d4413ccafc99f4febe5a5d716ff42cb3b12..86c48c34f2646b04c7fa863a7b1bd4dd8edf2945 100644 (file)
@@ -176,6 +176,7 @@ struct pg_locale_struct
 };
 
 extern void init_database_collation(void);
+extern pg_locale_t pg_database_locale(void);
 extern pg_locale_t pg_newlocale_from_collation(Oid collid);
 
 extern char *get_collation_actual_version(char collprovider, const char *collcollate);