Ye olde "failed to initialize lc_messages" gotcha - Mailing list pgsql-hackers

From Tom Lane
Subject Ye olde "failed to initialize lc_messages" gotcha
Date
Msg-id 11543.1149290465@sss.pgh.pa.us
Whole thread Raw
List pgsql-hackers
We got another report of this failure today:
http://archives.postgresql.org/pgsql-novice/2006-06/msg00020.php
which I found particularly interesting because it happened on a Fedora
machine, and I had thought Fedora impervious because it considers
glibc-common a standard component.  Seems it can happen anyway.

I did some experimentation with the problem by the expedient of
renaming /usr/share/locale and /usr/lib/locale out of the way,
and found that:

1. glibc's setlocale() does in fact fail for setlocale(LC_MESSAGES, "")
if it can't find any locale files, but only if LANG is not C
(I used LANG=en_US to provoke the failure).

2. It fails in the same way for other LC_xxx settings too, but it turns
out that LC_MESSAGES is the only one where we actually pay any attention.

What I propose we do about this is tweak locale_messages_assign() to not
fail if value == "" and source == PGC_S_DEFAULT.  Since value == "" is
really a no-op during startup anyway, there is no harm in doing this;
and by restricting it to source == PGC_S_DEFAULT, we can avoid the error
of accepting explicit attempts to set lc_messages to "".

Any objections?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Rod Taylor
Date:
Subject: Re: More thoughts about planner's cost estimates
Next
From: Tom Lane
Date:
Subject: Re: More thoughts about planner's cost estimates