aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2025-02-10 10:03:37 -0500
committerAndres Freund <andres@anarazel.de>2025-02-10 10:03:37 -0500
commit3e98c8ce50e46d58b91bf3ea806e995296dc5b91 (patch)
tree4d7ed8b78f036de2a857c1d13134e0afc6ce22ff /src/bin/psql/command.c
parent4dc28963533704fc7dd922b9447467466a233d89 (diff)
downloadpostgresql-3e98c8ce50e46d58b91bf3ea806e995296dc5b91.tar.gz
postgresql-3e98c8ce50e46d58b91bf3ea806e995296dc5b91.zip
Specify the encoding of input to fmtId()
This commit adds fmtIdEnc() and fmtQualifiedIdEnc(), which allow to specify the encoding as an explicit argument. Additionally setFmtEncoding() is provided, which defines the encoding when no explicit encoding is provided, to avoid breaking all code using fmtId(). All users of fmtId()/fmtQualifiedId() are either converted to the explicit version or a call to setFmtEncoding() has been added. This commit does not yet utilize the now well-defined encoding, that will happen in a subsequent commit. Reviewed-by: Noah Misch <noah@leadboat.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Backpatch-through: 13 Security: CVE-2025-1094
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 6c75c8da6da..26dfdde195a 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1450,6 +1450,7 @@ exec_command_encoding(PsqlScanState scan_state, bool active_branch)
/* save encoding info into psql internal data */
pset.encoding = PQclientEncoding(pset.db);
pset.popt.topt.encoding = pset.encoding;
+ setFmtEncoding(pset.encoding);
SetVariable(pset.vars, "ENCODING",
pg_encoding_to_char(pset.encoding));
}
@@ -4135,6 +4136,8 @@ SyncVariables(void)
pset.popt.topt.encoding = pset.encoding;
pset.sversion = PQserverVersion(pset.db);
+ setFmtEncoding(pset.encoding);
+
SetVariable(pset.vars, "DBNAME", PQdb(pset.db));
SetVariable(pset.vars, "SERVICE", PQservice(pset.db));
SetVariable(pset.vars, "USER", PQuser(pset.db));