diff options
author | Andres Freund <andres@anarazel.de> | 2025-02-10 10:03:40 -0500 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2025-02-10 10:03:40 -0500 |
commit | 2ae54ae17eaad592991e7459140b2cad2e82745c (patch) | |
tree | a8789377b7a2b68e37c1c441f07732349edf980a /src/bin/scripts/reindexdb.c | |
parent | 5bc33cbeae0e5cb8ecb410f8e47efb92811380fd (diff) |
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/reindexdb.c')
-rw-r--r-- | src/bin/scripts/reindexdb.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index db1d7f07fc0..3a3461af084 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -533,7 +533,8 @@ run_reindex_command(PGconn *conn, ReindexType type, const char *name, if (tablespace) { - appendPQExpBuffer(&sql, "%sTABLESPACE %s", sep, fmtId(tablespace)); + appendPQExpBuffer(&sql, "%sTABLESPACE %s", sep, + fmtIdEnc(tablespace, PQclientEncoding(conn))); sep = comma; } @@ -573,7 +574,8 @@ run_reindex_command(PGconn *conn, ReindexType type, const char *name, { case REINDEX_DATABASE: case REINDEX_SYSTEM: - appendPQExpBufferStr(&sql, fmtId(name)); + appendPQExpBufferStr(&sql, + fmtIdEnc(name, PQclientEncoding(conn))); break; case REINDEX_INDEX: case REINDEX_TABLE: @@ -743,8 +745,9 @@ get_parallel_object_list(PGconn *conn, ReindexType type, for (i = 0; i < ntups; i++) { appendPQExpBufferStr(&buf, - fmtQualifiedId(PQgetvalue(res, i, 1), - PQgetvalue(res, i, 0))); + fmtQualifiedIdEnc(PQgetvalue(res, i, 1), + PQgetvalue(res, i, 0), + PQclientEncoding(conn))); simple_string_list_append(tables, buf.data); resetPQExpBuffer(&buf); |