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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-committers <pgsql-committers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: createdb: Fix quoting of --encoding, --lc-ctype and --lc-collate
Date: 2020-02-27 05:11:12
Message-ID: 20200227051112.GA280980@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2020-02-27 06:39:07 pgsql: Skip foreign tablespaces when running pg_checksums/pg_verify_che
Previous Message Robert Haas 2020-02-27 04:13:14 Re: pgsql: createdb: Fix quoting of --encoding, --lc-ctype and --lc-collate