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 <[email protected]> Reviewed-by: Fujii Masao <[email protected]> Reviewed-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/CAGRkXqRv7yhBOhF0YvSr6ZB7rvsPCjnXSPj8=3bkcsjuyvn...@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(-)
