Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e5bb0f0

Browse files
committed
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.
1 parent 53e7229 commit e5bb0f0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/backend/utils/init/postinit.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.191 2009/06/11 14:49:05 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.192 2009/07/08 17:53:29 heikki Exp $
1212
*
1313
*
1414
*-------------------------------------------------------------------------
@@ -44,6 +44,7 @@
4444
#include "utils/acl.h"
4545
#include "utils/flatfiles.h"
4646
#include "utils/guc.h"
47+
#include "utils/pg_locale.h"
4748
#include "utils/plancache.h"
4849
#include "utils/portal.h"
4950
#include "utils/relcache.h"
@@ -247,14 +248,14 @@ CheckMyDatabase(const char *name, bool am_superuser)
247248
collate = NameStr(dbform->datcollate);
248249
ctype = NameStr(dbform->datctype);
249250

250-
if (setlocale(LC_COLLATE, collate) == NULL)
251+
if (pg_perm_setlocale(LC_COLLATE, collate) == NULL)
251252
ereport(FATAL,
252253
(errmsg("database locale is incompatible with operating system"),
253254
errdetail("The database was initialized with LC_COLLATE \"%s\", "
254255
" which is not recognized by setlocale().", collate),
255256
errhint("Recreate the database with another locale or install the missing locale.")));
256257

257-
if (setlocale(LC_CTYPE, ctype) == NULL)
258+
if (pg_perm_setlocale(LC_CTYPE, ctype) == NULL)
258259
ereport(FATAL,
259260
(errmsg("database locale is incompatible with operating system"),
260261
errdetail("The database was initialized with LC_CTYPE \"%s\", "

0 commit comments

Comments
 (0)