Skip to content

Commit f6e9cbf

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 21187cf commit f6e9cbf

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
@@ -43,7 +43,7 @@ const char *progname;
4343

4444

4545
static void startup_hacks(const char *progname);
46-
static void init_locale(int category, const char *locale);
46+
static void init_locale(const char *categoryname, int category, const char *locale);
4747
static void help(const char *progname);
4848
static void check_root(const char *progname);
4949

@@ -116,31 +116,31 @@ main(int argc, char *argv[])
116116
char *env_locale;
117117

118118
if ((env_locale = getenv("LC_COLLATE")) != NULL)
119-
init_locale(LC_COLLATE, env_locale);
119+
init_locale("LC_COLLATE", LC_COLLATE, env_locale);
120120
else
121-
init_locale(LC_COLLATE, "");
121+
init_locale("LC_COLLATE", LC_COLLATE, "");
122122

123123
if ((env_locale = getenv("LC_CTYPE")) != NULL)
124-
init_locale(LC_CTYPE, env_locale);
124+
init_locale("LC_CTYPE", LC_CTYPE, env_locale);
125125
else
126-
init_locale(LC_CTYPE, "");
126+
init_locale("LC_CTYPE", LC_CTYPE, "");
127127
}
128128
#else
129-
init_locale(LC_COLLATE, "");
130-
init_locale(LC_CTYPE, "");
129+
init_locale("LC_COLLATE", LC_COLLATE, "");
130+
init_locale("LC_CTYPE", LC_CTYPE, "");
131131
#endif
132132

133133
#ifdef LC_MESSAGES
134-
init_locale(LC_MESSAGES, "");
134+
init_locale("LC_MESSAGES", LC_MESSAGES, "");
135135
#endif
136136

137137
/*
138138
* We keep these set to "C" always, except transiently in pg_locale.c; see
139139
* that file for explanations.
140140
*/
141-
init_locale(LC_MONETARY, "C");
142-
init_locale(LC_NUMERIC, "C");
143-
init_locale(LC_TIME, "C");
141+
init_locale("LC_MONETARY", LC_MONETARY, "C");
142+
init_locale("LC_NUMERIC", LC_NUMERIC, "C");
143+
init_locale("LC_TIME", LC_TIME, "C");
144144

145145
/*
146146
* Now that we have absorbed as much as we wish to from the locale
@@ -280,11 +280,12 @@ startup_hacks(const char *progname)
280280
* category's environment variable.
281281
*/
282282
static void
283-
init_locale(int category, const char *locale)
283+
init_locale(const char *categoryname, int category, const char *locale)
284284
{
285285
if (pg_perm_setlocale(category, locale) == NULL &&
286286
pg_perm_setlocale(category, "C") == NULL)
287-
elog(FATAL, "could not adopt C locale");
287+
elog(FATAL, "could not adopt \"%s\" locale nor C locale for %s",
288+
locale, categoryname);
288289
}
289290

290291

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy