Re: pg9.4b1: unhelpful error message when creating a collation

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg9.4b1: unhelpful error message when creating a collation
Date: 2014-05-25 15:45:11
Message-ID: 20140525154511.GA21233@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2014-05-25 09:17:24 +0200, Fabien COELHO wrote:
> sql> CREATE COLLATION "french" (locale='fr_FR.utf8');
> ERROR: could not create locale "fr_FR.utf8": Success
>
> The collation creation fails, not sure why yet. However, the "error ..
> success" message is especially unhelpful.

This seems to be a glibc bug. If a nonexistant locale has already been
asked for errno is set to 0 instead of something sensible.

Using a debugger it's possible to see that in an earlier setlocale()
call errno is set correctly, but newlocale() then fails without setting
errno. The culprit seems to be some caching in glibc's _nl_find_locale().

I am not entirely sure why it's not reliably triggered < 9.4.

Searching for that error turned up:
https://sourceware.org/bugzilla/show_bug.cgi?id=14247
https://bugzilla.redhat.com/show_bug.cgi?id=827510

The latter by Tom Lane ;). Unfortunately not much seems to have happened
since.

Except badgering the glibc guys a bit, the only thing I can think of is
to fudge errno = 0 into errno = ENOENT. Not nice.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-05-25 15:53:45 Re: Could not finish anti-wraparound VACUUM when stop limit is reached
Previous Message Heikki Linnakangas 2014-05-25 15:40:09 Could not finish anti-wraparound VACUUM when stop limit is reached