pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: plpgsql: Check compatibility of source/target ERHs
Date: Mon, 09 Nov 2026 14:22:12 +0000
Message-ID: <E1xQQGC-0000000046r-0tIc@gemulon.postgresql.org> (raw)

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@vondra.me>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Security: CVE-2026-6460
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/17a138be4763c82d42e1ff3b3fe55a57e06e58e7
Author: Andres Freund <andres@anarazel.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(-)



view thread (4+ messages)

Message-ID: <E1xQQGC-0000000046r-0tIc@gemulon.postgresql.org>
Permalink:  ../E1xQQGC-0000000046r-0tIc@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xQQGC-0000000046r-0tIc@gemulon.postgresql.org

 · 

reply

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: plpgsql: Check compatibility of source/target ERHs
  In-Reply-To: <E1xQQGC-0000000046r-0tIc@gemulon.postgresql.org>
  References: <E1xQQGC-0000000046r-0tIc@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