From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add checks for cross-rowtype deforming and conversions
Date: Mon, 09 Nov 2026 14:22:05 +0000
Message-ID: <E1xQQG5-000000003r3-1CDh@gemulon.postgresql.org> (raw)
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 <melanieplageman@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Noah Misch <noah@leadboat.com>
Security: CVE-2026-6460
Backpatch-through: 14
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/d0b52be9b1191423d8b601fb1c7c1dee96c9c038
Author: Andres Freund <andres@anarazel.de>
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(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: noah@leadboat.com
Subject: Re: pgsql: Add checks for cross-rowtype deforming and conversions
In-Reply-To: <E1xQQG5-000000003r3-1CDh@gemulon.postgresql.org>
References: <E1xQQG5-000000003r3-1CDh@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox