| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: plpgsql: Check compatibility of source/target ERHs |
| Date: | 2026-11-09 14:22:12 |
| Message-ID: | E1xQQGC-0000000046r-0tIc@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
plpgsql: Check compatibility of source/target ERHs
Otherwise we can assign tuples not matching the target tupledescriptor,
e.g. because one of the tuple descriptors has been acquired before/after
some DDL.
It may seem tempting to just not enter the surrounding "if" if the
er_tupdesc_id doesn't match (in fact both Heikki and I (Andres) were
previously tempted), but the fieldwise-assignment path differs
behaviorally, due to not copying the ctid along. As the tupdesc_id can
increment due to invalidation processing, that would lead to
unpredictable behavior. Tests were added in previous commits that would
show that behavior.
Note that there are some cases where this will cause failures that are
not required for correctness, when assigning a variable of a changed
type to a previously used variable. It'd add more complexity to make
that work; for a bugfix this seems good enough.
As also noted in a comment, this perhaps should be done in the expanded
record layer. But that'd require a few more changes and would make it
harder to emit a somewhat understandable error message.
Reviewed-by: Tomas Vondra <tomas(at)vondra(dot)me>
Reviewed-by: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Security: CVE-2026-6460
Backpatch-through: 14
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/17a138be4763c82d42e1ff3b3fe55a57e06e58e7
Author: Andres Freund <andres(at)anarazel(dot)de>
Modified Files
--------------
src/pl/plpgsql/src/expected/plpgsql_record.out | 8 +++--
src/pl/plpgsql/src/pl_exec.c | 46 ++++++++++++++++++++++++++
src/test/regress/expected/rowtypes_alter.out | 25 +++++++++-----
3 files changed, 68 insertions(+), 11 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:22:13 | pgsql: Handle composite type changes in ExecEvalFieldStore[De]Form |
| Previous Message | Noah Misch | 2026-11-09 14:22:11 | pgsql: plpgsql: recheck record field's type after casting value. |