Re: Inconsistent "ICU Locale" output on older server versions
Euler Taveira <euler@eulerto.com>
From: "Euler Taveira" <euler@eulerto.com>
To: "Christoph Berg" <myon@debian.org>,
"Peter Eisentraut" <peter@eisentraut.org>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2022-04-15T15:48:30Z
Lists: pgsql-hackers
On Fri, Apr 15, 2022, at 11:58 AM, Christoph Berg wrote:
> When running psql 15 against PG 14, the output is this:
>
> $ psql -l
> List of databases
> Name │ Owner │ Encoding │ Collate │ Ctype │ ICU Locale │ Locale Provider │ Access privileges
> ───────────┼──────────┼──────────┼────────────┼────────────┼────────────┼─────────────────┼───────────────────────
> postgres │ postgres │ UTF8 │ de_DE.utf8 │ de_DE.utf8 │ de_DE.utf8 │ libc │
> template0 │ postgres │ UTF8 │ de_DE.utf8 │ de_DE.utf8 │ de_DE.utf8 │ libc │ =c/postgres ↵
> │ │ │ │ │ │ │ postgres=CTc/postgres
> template1 │ postgres │ UTF8 │ de_DE.utf8 │ de_DE.utf8 │ de_DE.utf8 │ libc │ =c/postgres ↵
> │ │ │ │ │ │ │ postgres=CTc/postgres
> (3 rows)
>
> The "ICU Locale" column is now populated, that seems wrong.
Good catch!
> The problem is in the else branch in src/bin/psql/describe.c around
> line 900:
>
> + if (pset.sversion >= 150000)
> + appendPQExpBuffer(&buf,
> + " d.daticulocale as \"%s\",\n"
> + " CASE d.datlocprovider WHEN 'c' THEN 'libc' WHEN 'i' THEN 'icu' END AS \"%s\",\
> + gettext_noop("ICU Locale"),
> + gettext_noop("Locale Provider"));
> + else
> + appendPQExpBuffer(&buf,
> + " d.datcollate as \"%s\",\n" <--- there
> + " 'libc' AS \"%s\",\n",
> + gettext_noop("ICU Locale"),
> + gettext_noop("Locale Provider"));
>
> I'd think this should rather be
>
> + " '' as \"%s\",\n"
Since dataiculocale allows NULL, my suggestion is to use NULL instead of an
empty string. It is consistent with a cluster whose locale provider is libc.
--
Euler Taveira
EDB https://www.enterprisedb.com/
Commits
-
psql: fix \l display for pre-v15 databases.
- 7129a9791eaf 15.0 landed
-
Fix global ICU collations for ICU < 54
- 3a671e1f7cb8 15.0 landed
-
Add option to use ICU as global locale provider
- f2553d43060e 15.0 cited
-
Add support for collation attributes on older ICU versions
- b8f9a2a69a27 12.0 cited