pgsql: Install infrastructure to manage psql's hidden query labels bett

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Install infrastructure to manage psql's hidden query labels bett
Date: 2026-10-15 18:45:37
Message-ID: E1xHQSP-00000001loc-21kz@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Install infrastructure to manage psql's hidden query labels better.

Commit 41d69e6dc added labels to psql's internally-generated queries,
which are sent to the server and possibly recorded in the server log.
In that commit we always attempted to translate the labels per psql's
NLS environment, but that is hazardous: non-ASCII labels might fail
to be translatable to the server's encoding, rendering some or all of
these operations unusable since the server will throw an error and
not execute the query. Hence, we need some gating checks to decide
whether it's safe to translate a label.

To allow that to be managed in just one place, invent a new function
addQueryComment() that is responsible for outputting these labels.
(Probably it should have been done that way to start with, but better
late than never.)

This commit just does the heavy lifting of creating that function and
fixing all the call sites. The actual choice of whether to translate
is stubbed out, so that this commit in itself changes no behavior.
Once we've settled on the correct gating checks to use, a much smaller
follow-on commit will install them.

Author: shihao zhong <zhong950419(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAGRkXqRv7yhBOhF0YvSr6ZB7rvsPCjnXSPj8=3bKcSJuYvNrBA@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5b5e072ef8ae9e76cdcc2eee05db8dd6c08f910b

Modified Files
--------------
src/bin/psql/command.c | 8 +-
src/bin/psql/common.c | 22 ++++++
src/bin/psql/common.h | 2 +
src/bin/psql/describe.c | 191 ++++++++++++++++++++----------------------------
src/bin/psql/nls.mk | 3 +-
5 files changed, 110 insertions(+), 116 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-10-15 21:09:36 pgsql: Avoid dangling shared memory pointers in parallel vacuum.
Previous Message Masahiko Sawada 2026-10-15 17:34:00 pgsql: Fix DROP DATABASE FORCE failing on parallel autovacuum workers.