Add checks for cross-rowtype deforming and conversions The previously added attribute versioning checks prevent cases of deforming a datum tuple with an incompatible tuple descriptor for the same type. However, we have a number of cases where we deform a datum tuple with a descriptor for a different relation. The additional checks introduces here add verification for such cases, by checking that the tuple descriptors are compatible.
The following cases are now checked during deforming: - Deforming a versioned tuple with a RECORDOID tupledesc This can happen with triggers and EvalPlanQual rechecks of function scans. - Deforming a versioned tuple with a tupledesc for another relation This happens a bunch for partitioned tables. Additionally, when changing the type of a tuple, the old and new types are compared for compatibility. This currently happens in: - heap_copy_tuple_as_datum() and via that in places like ExecEvalConvertRowtype(), ExecFetchSlotHeapTupleDatum(), ... - plpgsql's coerce_function_result_tuple() In a perfect world these extra checks would not be needed. But... It is perhaps worth noting that this knowingly emits error messages in an untranslatable way. That was considered acceptable for now, these error checks should not normally be hit. Note that these checks do add nontrivial overhead. This is ameliorated by the fact that the common ways to reach the checks are part of already expensive operations (like trigger invocations during DML into a partitioned table), which are expensive enough to make the added overhead comparatively small. Reviewed-by: Melanie Plageman <[email protected]> Reviewed-by: Tomas Vondra <[email protected]> Reviewed-by: Noah Misch <[email protected]> Security: CVE-2026-6460 Backpatch-through: 14 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/825e1bd41df633995098818d11b0189f79139a8e Author: Andres Freund <[email protected]> Modified Files -------------- src/backend/access/common/heaptuple.c | 296 ++++++++++++++++++++- .../expected/eval-plan-qual-rowtype-alter.out | 14 +- src/test/regress/expected/rowtypes_alter.out | 17 +- 3 files changed, 294 insertions(+), 33 deletions(-)
