mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Need to use pg_perm_setlocale when setting LC_CTYPE and LC_COLLATE at startup.
Otherwise, the LC_CTYPE/COLLATE setting gets reverted when using plperl, which leads to incorrect query results and index corruption. This was accidentally broken in the per-database locale patch in 8.4. Pointed out by Andrew Gierth.
This commit is contained in:
parent
53e7229258
commit
e5bb0f04db
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.191 2009/06/11 14:49:05 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.192 2009/07/08 17:53:29 heikki Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
@ -44,6 +44,7 @@
|
|||||||
#include "utils/acl.h"
|
#include "utils/acl.h"
|
||||||
#include "utils/flatfiles.h"
|
#include "utils/flatfiles.h"
|
||||||
#include "utils/guc.h"
|
#include "utils/guc.h"
|
||||||
|
#include "utils/pg_locale.h"
|
||||||
#include "utils/plancache.h"
|
#include "utils/plancache.h"
|
||||||
#include "utils/portal.h"
|
#include "utils/portal.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
@ -247,14 +248,14 @@ CheckMyDatabase(const char *name, bool am_superuser)
|
|||||||
collate = NameStr(dbform->datcollate);
|
collate = NameStr(dbform->datcollate);
|
||||||
ctype = NameStr(dbform->datctype);
|
ctype = NameStr(dbform->datctype);
|
||||||
|
|
||||||
if (setlocale(LC_COLLATE, collate) == NULL)
|
if (pg_perm_setlocale(LC_COLLATE, collate) == NULL)
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errmsg("database locale is incompatible with operating system"),
|
(errmsg("database locale is incompatible with operating system"),
|
||||||
errdetail("The database was initialized with LC_COLLATE \"%s\", "
|
errdetail("The database was initialized with LC_COLLATE \"%s\", "
|
||||||
" which is not recognized by setlocale().", collate),
|
" which is not recognized by setlocale().", collate),
|
||||||
errhint("Recreate the database with another locale or install the missing locale.")));
|
errhint("Recreate the database with another locale or install the missing locale.")));
|
||||||
|
|
||||||
if (setlocale(LC_CTYPE, ctype) == NULL)
|
if (pg_perm_setlocale(LC_CTYPE, ctype) == NULL)
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errmsg("database locale is incompatible with operating system"),
|
(errmsg("database locale is incompatible with operating system"),
|
||||||
errdetail("The database was initialized with LC_CTYPE \"%s\", "
|
errdetail("The database was initialized with LC_CTYPE \"%s\", "
|
||||||
|
Loading…
Reference in New Issue
Block a user