1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

Arrange to set the LC_XXX environment variables to match our locale

setup.  This protects against undesired changes in locale behavior
if someone carelessly does setlocale(LC_ALL, "") (and we know who
you are, perl guys).
This commit is contained in:
Tom Lane
2005-12-28 23:22:51 +00:00
parent b6c881ce62
commit ab51bbaa06
4 changed files with 146 additions and 51 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.223 2005/11/22 18:17:07 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.224 2005/12/28 23:22:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -45,6 +45,7 @@
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/nabstime.h"
#include "utils/pg_locale.h"
#include "utils/relcache.h"
@ -3619,14 +3620,14 @@ ReadControlFile(void)
" but the server was compiled with LOCALE_NAME_BUFLEN %d.",
ControlFile->localeBuflen, LOCALE_NAME_BUFLEN),
errhint("It looks like you need to recompile or initdb.")));
if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL)
if (pg_perm_setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL)
ereport(FATAL,
(errmsg("database files are incompatible with operating system"),
errdetail("The database cluster was initialized with LC_COLLATE \"%s\","
" which is not recognized by setlocale().",
ControlFile->lc_collate),
errhint("It looks like you need to initdb or install locale support.")));
if (setlocale(LC_CTYPE, ControlFile->lc_ctype) == NULL)
if (pg_perm_setlocale(LC_CTYPE, ControlFile->lc_ctype) == NULL)
ereport(FATAL,
(errmsg("database files are incompatible with operating system"),
errdetail("The database cluster was initialized with LC_CTYPE \"%s\","