pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: plpgsql: Check compatibility of source/target ERHs
4+ messages / 1 participants
[nested] [flat]

* pgsql: plpgsql: Check compatibility of source/target ERHs
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0f86e57d614dad6d3e9eec3fcfe75c8fc40cacb6
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(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: plpgsql: Check compatibility of source/target ERHs
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/86e2e8fbad41226363ef4900c770bb1b4d1eb677
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(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: plpgsql: Check compatibility of source/target ERHs
@ 2026-11-09 14:22 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Noah Misch @ 2026-11-09 14:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/edcd260d9e31de73d0f3db572a9e3ce66d9fcf9e
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(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: plpgsql: Check compatibility of source/target ERHs
@ 2026-11-09 14:22 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Noah Misch @ 2026-11-09 14:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-11-09 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 14:21 pgsql: plpgsql: Check compatibility of source/target ERHs Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: plpgsql: Check compatibility of source/target ERHs Noah Misch <noah@leadboat.com>
2026-11-09 14:22 pgsql: plpgsql: Check compatibility of source/target ERHs Noah Misch <noah@leadboat.com>
2026-11-09 14:22 pgsql: plpgsql: Check compatibility of source/target ERHs Noah Misch <noah@leadboat.com>

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