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

Commit e7da27c

Browse files
committed
Report more information if pg_perm_setlocale() fails at startup.
We don't know why a few Windows users have seen this fail, but the taciturnity of the error message certainly isn't helping debug it. Let's at least find out which LC category isn't working.
1 parent 82f81ba commit e7da27c

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/backend/main/main.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const char *progname;
4848

4949

5050
static void startup_hacks(const char *progname);
51-
static void init_locale(int category, const char *locale);
51+
static void init_locale(const char *categoryname, int category, const char *locale);
5252
static void help(const char *progname);
5353
static void check_root(const char *progname);
5454
static char *get_current_username(const char *progname);
@@ -122,31 +122,31 @@ main(int argc, char *argv[])
122122
char *env_locale;
123123

124124
if ((env_locale = getenv("LC_COLLATE")) != NULL)
125-
init_locale(LC_COLLATE, env_locale);
125+
init_locale("LC_COLLATE", LC_COLLATE, env_locale);
126126
else
127-
init_locale(LC_COLLATE, "");
127+
init_locale("LC_COLLATE", LC_COLLATE, "");
128128

129129
if ((env_locale = getenv("LC_CTYPE")) != NULL)
130-
init_locale(LC_CTYPE, env_locale);
130+
init_locale("LC_CTYPE", LC_CTYPE, env_locale);
131131
else
132-
init_locale(LC_CTYPE, "");
132+
init_locale("LC_CTYPE", LC_CTYPE, "");
133133
}
134134
#else
135-
init_locale(LC_COLLATE, "");
136-
init_locale(LC_CTYPE, "");
135+
init_locale("LC_COLLATE", LC_COLLATE, "");
136+
init_locale("LC_CTYPE", LC_CTYPE, "");
137137
#endif
138138

139139
#ifdef LC_MESSAGES
140-
init_locale(LC_MESSAGES, "");
140+
init_locale("LC_MESSAGES", LC_MESSAGES, "");
141141
#endif
142142

143143
/*
144144
* We keep these set to "C" always, except transiently in pg_locale.c; see
145145
* that file for explanations.
146146
*/
147-
init_locale(LC_MONETARY, "C");
148-
init_locale(LC_NUMERIC, "C");
149-
init_locale(LC_TIME, "C");
147+
init_locale("LC_MONETARY", LC_MONETARY, "C");
148+
init_locale("LC_NUMERIC", LC_NUMERIC, "C");
149+
init_locale("LC_TIME", LC_TIME, "C");
150150

151151
/*
152152
* Now that we have absorbed as much as we wish to from the locale
@@ -301,11 +301,12 @@ startup_hacks(const char *progname)
301301
* category's environment variable.
302302
*/
303303
static void
304-
init_locale(int category, const char *locale)
304+
init_locale(const char *categoryname, int category, const char *locale)
305305
{
306306
if (pg_perm_setlocale(category, locale) == NULL &&
307307
pg_perm_setlocale(category, "C") == NULL)
308-
elog(FATAL, "could not adopt C locale");
308+
elog(FATAL, "could not adopt \"%s\" locale nor C locale for %s",
309+
locale, categoryname);
309310
}
310311

311312

0 commit comments

Comments
 (0)