diff options
author | Jeff Davis <jdavis@postgresql.org> | 2025-07-16 14:13:18 -0700 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2025-07-16 14:13:18 -0700 |
commit | 5e6e42e44fe10cab616b4fbe9725df03c987c90a (patch) | |
tree | be4845346e0c2b474c6f49fa4994cb6d5acad703 /src/backend/utils/init/postinit.c | |
parent | 0858f0f96ebb891c8960994f023ed5a17b758a38 (diff) | |
download | postgresql-5e6e42e44fe10cab616b4fbe9725df03c987c90a.tar.gz postgresql-5e6e42e44fe10cab616b4fbe9725df03c987c90a.zip |
Force LC_COLLATE to C in postmaster.
Avoid dependence on setlocale().
strcoll(), etc., are not called directly; all collation-sensitive
calls should go through pg_locale.c and use the appropriate
provider. By setting LC_COLLATE to C, we avoid accidentally depending
on libc behavior when using a different provider.
No behavior change in the backend, but it's possible that some
extensions will be affected. Such extensions should be updated to use
the pg_locale_t APIs.
Discussion: https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c162@eisentraut.org
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r-- | src/backend/utils/init/postinit.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index c86ceefda94..641e535a73c 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -417,12 +417,11 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_datctype); ctype = TextDatumGetCString(datum); - if (pg_perm_setlocale(LC_COLLATE, collate) == NULL) - ereport(FATAL, - (errmsg("database locale is incompatible with operating system"), - errdetail("The database was initialized with LC_COLLATE \"%s\", " - " which is not recognized by setlocale().", collate), - errhint("Recreate the database with another locale or install the missing locale."))); + /* + * Historcally, we set LC_COLLATE from datcollate, as well. That's no + * longer necessary because all collation behavior is handled through + * pg_locale_t. + */ if (pg_perm_setlocale(LC_CTYPE, ctype) == NULL) ereport(FATAL, |