Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2de12e

Browse files
committed
Don't choke during startup if the environment offers an invalid value
for LC_MESSAGES; instead, just press forward, leaving the effective settingat 'C'. There is not any very good reason to complain when we are goingto replace the value soon with whatever postgresql.conf says. This changeshould solve the occasionally-reported problem of initdb failing with'failed to initialize lc_messages'; the current theory is that that isa reflection of either wrong LANG/LC_MESSAGES or completely broken localesupport.
1 parent84e741f commitf2de12e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 2002-2006, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.35 2006/03/05 15:58:43 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.36 2006/06/03 17:36:10 tgl Exp $
88
*
99
*-----------------------------------------------------------------------
1010
*/
@@ -182,6 +182,10 @@ pg_perm_setlocale(int category, const char *locale)
182182
* This is common code for several locale categories. This doesn't
183183
* actually set the locale permanently, it only tests if the locale is
184184
* valid. (See explanation at the top of this file.)
185+
*
186+
* Note: we accept value = "" as selecting the postmaster's environment
187+
* value, whatever it was (so long as the environment setting is legal).
188+
* This will have been locked down by an earlier call to pg_perm_setlocale.
185189
*/
186190
staticconstchar*
187191
locale_xxx_assign(intcategory,constchar*value,booldoit,GucSourcesource)
@@ -230,10 +234,20 @@ locale_time_assign(const char *value, bool doit, GucSource source)
230234

231235
/*
232236
* We allow LC_MESSAGES to actually be set globally.
237+
*
238+
* Note: we normally disallow value = "" because it wouldn't have consistent
239+
* semantics (it'd effectively just use the previous value). However, this
240+
* is the value passed for PGC_S_DEFAULT, so don't complain in that case,
241+
* not even if the attempted setting fails due to invalid environment value.
242+
* The idea there is just to accept the environment setting *if possible*
243+
* during startup, until we can read the proper value from postgresql.conf.
233244
*/
234245
constchar*
235246
locale_messages_assign(constchar*value,booldoit,GucSourcesource)
236247
{
248+
if (*value=='\0'&&source!=PGC_S_DEFAULT)
249+
returnNULL;
250+
237251
/*
238252
* LC_MESSAGES category does not exist everywhere, but accept it anyway
239253
*
@@ -244,7 +258,8 @@ locale_messages_assign(const char *value, bool doit, GucSource source)
244258
if (doit)
245259
{
246260
if (!pg_perm_setlocale(LC_MESSAGES,value))
247-
returnNULL;
261+
if (source!=PGC_S_DEFAULT)
262+
returnNULL;
248263
}
249264
#ifndefWIN32
250265
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp