mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
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
This commit is contained in:
@ -1285,6 +1285,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));
|
||||
}
|
||||
@ -3740,6 +3741,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, "USER", PQuser(pset.db));
|
||||
SetVariable(pset.vars, "HOST", PQhost(pset.db));
|
||||
|
Reference in New Issue
Block a user