Ye olde "failed to initialize lc_messages" gotcha

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Ye olde "failed to initialize lc_messages" gotcha
Date: 2006-06-02 23:21:05
Message-ID: 11543.1149290465@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-06-02 23:38:57 Re: More thoughts about planner's cost estimates
Previous Message Rod Taylor 2006-06-02 23:05:15 Re: More thoughts about planner's cost estimates