Re: pgsql: createdb: Fix quoting of --encoding, --lc-ctype and--lc-collate - Mailing list pgsql-committers

From Michael Paquier
Subject Re: pgsql: createdb: Fix quoting of --encoding, --lc-ctype and--lc-collate
Date
Msg-id 20200227051112.GA280980@paquier.xyz
Whole thread Raw
In response to Re: pgsql: createdb: Fix quoting of --encoding, --lc-ctype and --lc-collate  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: pgsql: createdb: Fix quoting of --encoding, --lc-ctype and--lc-collate  (Michael Paquier <michael@paquier.xyz>)
Re: pgsql: createdb: Fix quoting of --encoding, --lc-ctype and--lc-collate  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-committers
On Thu, Feb 27, 2020 at 09:43:14AM +0530, Robert Haas wrote:
> Buildfarm member curculio just failed with this complaint:

Thanks, I missed this report.

> #   Failed test 'createdb with incorrect --lc-ctype stderr
> /(?^s:^createdb: error: database creation failed: ERROR:  invalid
> locale name)/'
> #   at t/020_createdb.pl line 43.
> #                   'createdb: error: database creation failed: ERROR:
>  new LC_CTYPE (foo'; SELECT '1) is incompatible with the LC_CTYPE of
> the template database (C)
> # HINT:  Use the same LC_CTYPE as in the template database, or use
> template0 as template.

Now that's interesting.  The error I would have expected to find is
from createdb() so as we should actually bump on a failure for
setlocale(LC_CTYPE).  But this means that setlocale() with an
incorrect value actually succeeded, and that the fallback became "C".
Oh, actually, this behavior is mentioned here:
https://man.openbsd.org/setlocale.3

The best thing I can think of is just to remove the test case for
--lc-ctype.  Now looking at the code of OpenBSD there could be an
alternative: using a string longer than 256 characters if I read
lib/libc/locale/setlocale.c correctly, but I'd rather not rely on
that.

Thoughts?
--
Michael

Attachment

pgsql-committers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pgsql: createdb: Fix quoting of --encoding, --lc-ctype and --lc-collate
Next
From: Michael Paquier
Date:
Subject: pgsql: Skip foreign tablespaces when running pg_checksums/pg_verify_che