pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Inconsistent "ICU Locale" output on older server versions
3+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2022-04-15 7129a9791e  psql: fix \l display for pre-v15 databases.
* Inconsistent "ICU Locale" output on older server versions
@ 2022-04-15 14:58  Christoph Berg <myon@debian.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Christoph Berg @ 2022-04-15 14:58 UTC (permalink / raw)
  To: Peter Eisentraut <peter@eisentraut.org>; +Cc: pgsql-hackers@lists.postgresql.org

Re: To Peter Eisentraut
> This hardly fits in normal-size terminals:
> 
> =# \l
>                                              List of databases
>    Name    │ Owner │ Encoding │  Collate   │   Ctype    │ ICU Locale │ Locale Provider │ Access privileges
> ───────────┼───────┼──────────┼────────────┼────────────┼────────────┼─────────────────┼───────────────────
>  postgres  │ myon  │ UTF8     │ de_DE.utf8 │ de_DE.utf8 │            │ libc            │
>  template0 │ myon  │ UTF8     │ de_DE.utf8 │ de_DE.utf8 │            │ libc            │ =c/myon          ↵
>            │       │          │            │            │            │                 │ myon=CTc/myon
>  template1 │ myon  │ UTF8     │ de_DE.utf8 │ de_DE.utf8 │            │ libc            │ =c/myon          ↵
>            │       │          │            │            │            │                 │ myon=CTc/myon
> (3 rows)

Another gripe here: The above is the output when run against a PG15
cluster, created without an ICU locale set.

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.

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"

Christoph





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Inconsistent "ICU Locale" output on older server versions
@ 2022-04-15 15:48  Euler Taveira <euler@eulerto.com>
  parent: Christoph Berg <myon@debian.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Euler Taveira @ 2022-04-15 15:48 UTC (permalink / raw)
  To: Christoph Berg <myon@debian.org>; Peter Eisentraut <peter@eisentraut.org>; +Cc: pgsql-hackers@lists.postgresql.org

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/

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Inconsistent "ICU Locale" output on older server versions
@ 2022-04-15 16:47  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Euler Taveira <euler@eulerto.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2022-04-15 16:47 UTC (permalink / raw)
  To: Euler Taveira <euler@eulerto.com>; +Cc: Christoph Berg <myon@debian.org>; Peter Eisentraut <peter@eisentraut.org>; pgsql-hackers@lists.postgresql.org

"Euler Taveira" <euler@eulerto.com> writes:
> On Fri, Apr 15, 2022, at 11:58 AM, Christoph Berg wrote:
>> When running psql 15 against PG 14, the output is this:
>> The "ICU Locale" column is now populated, that seems wrong.

> Good catch!

Indeed.

> 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.

Yeah, I agree.  We should make the pre-v15 output match what you'd see
if looking at a non-ICU v15 database.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-04-15 16:47 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15 14:58 Inconsistent "ICU Locale" output on older server versions Christoph Berg <myon@debian.org>
2022-04-15 15:48 ` Euler Taveira <euler@eulerto.com>
2022-04-15 16:47   ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox