postgresql/src/include/commands
Tom Lane 8ebdf41c26 Harden _int_matchsel() against being attached to the wrong operator.
While the preceding commit prevented such attachments from occurring
in future, this one aims to prevent further abuse of any already-
created operator that exposes _int_matchsel to the wrong data types.
(No other contrib module has a vulnerable selectivity estimator.)

We need only check that the Const we've found in the query is indeed
of the type we expect (query_int), but there's a difficulty: as an
extension type, query_int doesn't have a fixed OID that we could
hard-code into the estimator.

Therefore, the bulk of this patch consists of infrastructure to let
an extension function securely look up the OID of a datatype
belonging to the same extension.  (Extension authors have requested
such functionality before, so we anticipate that this code will
have additional non-security uses, and may soon be extended to allow
looking up other kinds of SQL objects.)

This is done by first finding the extension that owns the calling
function (there can be only one), and then thumbing through the
objects owned by that extension to find a type that has the desired
name.  This is relatively expensive, especially for large extensions,
so a simple cache is put in front of these lookups.

Reported-by: Daniel Firer as part of zeroday.cloud
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Noah Misch <noah@leadboat.com>
Security: CVE-2026-2004
Backpatch-through: 14
2026-02-09 10:14:22 -05:00
..
alter.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
async.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
cluster.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
collationcmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
comment.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
conversioncmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
copy.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
copyapi.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
copyfrom_internal.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
createas.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
dbcommands.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
dbcommands_xlog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
defrem.h Include error location in errors from ComputeIndexAttrs(). 2026-01-04 14:16:20 -05:00
discard.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
event_trigger.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
explain.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
explain_dr.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
explain_format.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
explain_state.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
extension.h Harden _int_matchsel() against being attached to the wrong operator. 2026-02-09 10:14:22 -05:00
lockcmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
matview.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
policy.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
portalcmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
prepare.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
proclang.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
progress.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
publicationcmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
schemacmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
seclabel.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sequence.h Fix typos and inconsistencies in code and comments 2026-01-05 09:19:15 +09:00
sequence_xlog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
subscriptioncmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tablecmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tablespace.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
trigger.h Fix trigger transition table capture for MERGE in CTE queries. 2026-01-24 11:30:48 +00:00
typecmds.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
user.h Add new GUC createrole_self_grant. 2023-01-10 12:44:49 -05:00
vacuum.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
view.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
wait.h Update copyright for 2026 2026-01-01 13:24:10 -05:00