Skip to content

Commit abdeb35

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 0db10d4 commit abdeb35

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

5151

5252
static void startup_hacks(const char *progname);
53-
static void init_locale(int category, const char *locale);
53+
static void init_locale(const char *categoryname, int category, const char *locale);
5454
static void help(const char *progname);
5555
static void check_root(const char *progname);
5656

@@ -123,31 +123,31 @@ main(int argc, char *argv[])
123123
char *env_locale;
124124

125125
if ((env_locale = getenv("LC_COLLATE")) != NULL)
126-
init_locale(LC_COLLATE, env_locale);
126+
init_locale("LC_COLLATE", LC_COLLATE, env_locale);
127127
else
128-
init_locale(LC_COLLATE, "");
128+
init_locale("LC_COLLATE", LC_COLLATE, "");
129129

130130
if ((env_locale = getenv("LC_CTYPE")) != NULL)
131-
init_locale(LC_CTYPE, env_locale);
131+
init_locale("LC_CTYPE", LC_CTYPE, env_locale);
132132
else
133-
init_locale(LC_CTYPE, "");
133+
init_locale("LC_CTYPE", LC_CTYPE, "");
134134
}
135135
#else
136-
init_locale(LC_COLLATE, "");
137-
init_locale(LC_CTYPE, "");
136+
init_locale("LC_COLLATE", LC_COLLATE, "");
137+
init_locale("LC_CTYPE", LC_CTYPE, "");
138138
#endif
139139

140140
#ifdef LC_MESSAGES
141-
init_locale(LC_MESSAGES, "");
141+
init_locale("LC_MESSAGES", LC_MESSAGES, "");
142142
#endif
143143

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

152152
/*
153153
* Now that we have absorbed as much as we wish to from the locale
@@ -308,11 +308,12 @@ startup_hacks(const char *progname)
308308
* category's environment variable.
309309
*/
310310
static void
311-
init_locale(int category, const char *locale)
311+
init_locale(const char *categoryname, int category, const char *locale)
312312
{
313313
if (pg_perm_setlocale(category, locale) == NULL &&
314314
pg_perm_setlocale(category, "C") == NULL)
315-
elog(FATAL, "could not adopt C locale");
315+
elog(FATAL, "could not adopt \"%s\" locale nor C locale for %s",
316+
locale, categoryname);
316317
}
317318

318319

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