Inconsistent behavior with locale definition in initdb/pg_ctl init

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Inconsistent behavior with locale definition in initdb/pg_ctl init
Date: 2023-05-17 20:38:37
Message-ID: CAEze2WiZFQyyb-DcKwayUmE4rY42Bo6kuK9nBjvqRHYxUYJ-DA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I was working on setting up a PG16.devel(375407f4) test database with
UTF8 but C locale, and found the following strange behaviour:

plain initdb:
[...]
Using default ICU locale "en_US".
Using language tag "en-US" for ICU locale "en_US".
The database cluster will be initialized with this locale configuration:
provider: icu
ICU locale: en-US
LC_*: en_US.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

initdb --no-locale: (documented as "equivalent to --locale=C")
[...]
The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

initdb --locale=C
[...]
Using default ICU locale "en_US".
Using language tag "en-US" for ICU locale "en_US".
The database cluster will be initialized with this locale configuration:
provider: icu
ICU locale: en-US
LC_*: C
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Notably; if initdb chooses the C locale from --no-locale, it uses
SQL_ASCII through libc, but when the C locale is specified through
--locale=C, it somehow defaults to the ICU locale en-US and uses UTF8
as encoding.

In my view that's very unexpected behaviour.

Kind regards,

Matthias van de Meent
Neon (neon.tech)

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-05-17 20:55:56 Re: walsender performance regression due to logical decoding on standby changes
Previous Message Andres Freund 2023-05-17 19:53:15 Re: walsender performance regression due to logical decoding on standby changes