aboutsummaryrefslogtreecommitdiff
path: root/src/bin/scripts/common.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2025-02-10 10:03:39 -0500
committerAndres Freund <andres@anarazel.de>2025-02-10 10:03:39 -0500
commitb1756da7541323eae07fe23eaad17ce12f20a56b (patch)
treec10f1ac41bc9a3ddeb3f84b1fd4846830c35930a /src/bin/scripts/common.c
parent703b3fd5de5d7bfe9cb3948601bc165da024256d (diff)
downloadpostgresql-b1756da7541323eae07fe23eaad17ce12f20a56b.tar.gz
postgresql-b1756da7541323eae07fe23eaad17ce12f20a56b.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/scripts/common.c')
-rw-r--r--src/bin/scripts/common.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index 9e38b60a655..e92b586c96b 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -112,8 +112,9 @@ appendQualifiedRelation(PQExpBuffer buf, const char *spec,
exit(1);
}
appendPQExpBufferStr(buf,
- fmtQualifiedId(PQgetvalue(res, 0, 1),
- PQgetvalue(res, 0, 0)));
+ fmtQualifiedIdEnc(PQgetvalue(res, 0, 1),
+ PQgetvalue(res, 0, 0),
+ PQclientEncoding(conn)));
appendPQExpBufferStr(buf, columns);
PQclear(res);
termPQExpBuffer(&sql);