Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Subject: Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding
Date: 2026-10-14 03:33:18
Message-ID: CAGRkXqQ3r2hqCLeOhicYcqUzvAsmL=ja8-pdrr6B7Rvq8t4Vrw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Looks like we agree on the three-way rule, with the API Tom suggested.

v3 attached, done the way Tom suggested. addQueryComment() uses the
translation only if it is plain ASCII, or if gettext's output
encoding, client_encoding and server_encoding are known to match.
Otherwise it uses the English label.

> Matching all three encodings may not be sufficient, since, e.g.,
> OUTPUT_CHARSET can also affect the locale encoding?

Yes. psql never calls bind_textdomain_codeset(), so OUTPUT_CHARSET is
the only override. With all three UTF8 and OUTPUT_CHARSET=EUC-JP,
19rc1 fails with invalid byte sequence. v3 uses English whenever
OUTPUT_CHARSET is set.

> I'm also not sure whether matching all three is sufficient on Windows.

I can’t test there. psql and libintl work out the code page in different
ways on
Windows, and I could not convince myself they always agree. So on Windows
v3 uses the English label whenever the translation is not plain ASCII.

We may lose a little since the CJK code pages map to SJIS, GBK, BIG5
and UHC, which can never be server_encoding.

Thanks,
Shihao

Attachment Content-Type Size
v3-0001-psql-Fall-back-to-English-for-unsafe-hidden-query-REL_19_STABLE.patch.txt text/plain 35.7 KB
v3-0001-psql-Fall-back-to-English-for-unsafe-hidden-query.patch application/octet-stream 35.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-10-14 03:40:58 Re: [PG19] btree_gin misses rows for a timestamptz bound in the repeated DST hour
Previous Message Sho Ito 2026-10-14 03:32:06 Re: PG19: flat-copied RelOptInfos share extension_state with the original rel