Skip to content
Snippets Groups Projects
Commit 7a4211eb authored by Tom Lane's avatar Tom Lane
Browse files

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.
parent 18935145
No related branches found
No related tags found
No related merge requests found
...@@ -51,7 +51,7 @@ const char *progname; ...@@ -51,7 +51,7 @@ const char *progname;
static void startup_hacks(const char *progname); static void startup_hacks(const char *progname);
static void init_locale(int category, const char *locale); static void init_locale(const char *categoryname, int category, const char *locale);
static void help(const char *progname); static void help(const char *progname);
static void check_root(const char *progname); static void check_root(const char *progname);
static char *get_current_username(const char *progname); static char *get_current_username(const char *progname);
...@@ -125,31 +125,31 @@ main(int argc, char *argv[]) ...@@ -125,31 +125,31 @@ main(int argc, char *argv[])
char *env_locale; char *env_locale;
if ((env_locale = getenv("LC_COLLATE")) != NULL) if ((env_locale = getenv("LC_COLLATE")) != NULL)
init_locale(LC_COLLATE, env_locale); init_locale("LC_COLLATE", LC_COLLATE, env_locale);
else else
init_locale(LC_COLLATE, ""); init_locale("LC_COLLATE", LC_COLLATE, "");
if ((env_locale = getenv("LC_CTYPE")) != NULL) if ((env_locale = getenv("LC_CTYPE")) != NULL)
init_locale(LC_CTYPE, env_locale); init_locale("LC_CTYPE", LC_CTYPE, env_locale);
else else
init_locale(LC_CTYPE, ""); init_locale("LC_CTYPE", LC_CTYPE, "");
} }
#else #else
init_locale(LC_COLLATE, ""); init_locale("LC_COLLATE", LC_COLLATE, "");
init_locale(LC_CTYPE, ""); init_locale("LC_CTYPE", LC_CTYPE, "");
#endif #endif
#ifdef LC_MESSAGES #ifdef LC_MESSAGES
init_locale(LC_MESSAGES, ""); init_locale("LC_MESSAGES", LC_MESSAGES, "");
#endif #endif
/* /*
* We keep these set to "C" always, except transiently in pg_locale.c; see * We keep these set to "C" always, except transiently in pg_locale.c; see
* that file for explanations. * that file for explanations.
*/ */
init_locale(LC_MONETARY, "C"); init_locale("LC_MONETARY", LC_MONETARY, "C");
init_locale(LC_NUMERIC, "C"); init_locale("LC_NUMERIC", LC_NUMERIC, "C");
init_locale(LC_TIME, "C"); init_locale("LC_TIME", LC_TIME, "C");
/* /*
* Now that we have absorbed as much as we wish to from the locale * Now that we have absorbed as much as we wish to from the locale
...@@ -303,11 +303,12 @@ startup_hacks(const char *progname) ...@@ -303,11 +303,12 @@ startup_hacks(const char *progname)
* category's environment variable. * category's environment variable.
*/ */
static void static void
init_locale(int category, const char *locale) init_locale(const char *categoryname, int category, const char *locale)
{ {
if (pg_perm_setlocale(category, locale) == NULL && if (pg_perm_setlocale(category, locale) == NULL &&
pg_perm_setlocale(category, "C") == NULL) pg_perm_setlocale(category, "C") == NULL)
elog(FATAL, "could not adopt C locale"); elog(FATAL, "could not adopt \"%s\" locale nor C locale for %s",
locale, categoryname);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment