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: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding
Date: 2026-10-13 11:41:06
Message-ID: CAGRkXqRVeaYiM8drdUBKQOmhnq7kCXWTvbTYO6tiGbzMxhiFww@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Fujii,

Thanks for looking into this

> I'm not sure how useful it is to translate query labels. Isn't it simpler
and
> safer to leave them untranslated, ensuring that they contain only ASCII
> characters?

Yes, it is. v2-A does that. It drops the translation at all 84 call
sites, so a label can only be ASCII. The cost is that -E shows the
English label.

> For example, with a Japanese UTF-8 locale and client_encoding=UTF8,
> the patch would still send a Japanese label to a LATIN1 database, where
> conversion to the database encoding would fail.

I missed that the server converts the query once more. If we want to
keep the translation, v2-B fixes v1 for this. It sends a label that is
not plain ASCII only when the locale encoding, client_encoding and
server_encoding are all the same.

Thanks,
Shihao

Attachment Content-Type Size
v2-A-0001-Don-t-translate-psql-s-hidden-query-labels-REL_19_STABLE.patch.txt text/plain 31.9 KB
v2-B-0001-psql-Don-t-send-hidden-query-labels-the-server-co.patch application/octet-stream 3.7 KB
v2-A-0001-Don-t-translate-psql-s-hidden-query-labels.patch application/octet-stream 32.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-10-13 11:43:06 Re: [PATCH] numeric: canonicalize wide digit accumulation
Previous Message Hayato Kuroda (Fujitsu) 2026-10-13 11:27:36 RE: Test publication.sql racing with subscription.sql might fail due to cache lookup error