pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix rowmark handling for non-relation RTEs during executor init
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix rowmark handling for non-relation RTEs during executor init
@ 2026-01-16 05:56 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Amit Langote @ 2026-01-16 05:56 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix rowmark handling for non-relation RTEs during executor init

Commit cbc127917e introduced tracking of unpruned relids to skip
processing of pruned partitions. PlannedStmt.unprunableRelids is
computed as the difference between PlannerGlobal.allRelids and
prunableRelids, but allRelids only contains RTE_RELATION entries.
This means non-relation RTEs (VALUES, subqueries, CTEs, etc.) are
never included in unprunableRelids, and consequently not in
es_unpruned_relids at runtime.

As a result, rowmarks attached to non-relation RTEs were incorrectly
skipped during executor initialization. This affects any DML statement
that has rowmarks on such RTEs, including MERGE with a VALUES or
subquery source, and UPDATE/DELETE with joins against subqueries or
CTEs. When a concurrent update triggers an EPQ recheck, the missing
rowmark leads to incorrect results.

Fix by restricting the es_unpruned_relids membership check to
RTE_RELATION entries only, since partition pruning only applies to
actual relations. Rowmarks for other RTE kinds are now always
processed.

Bug: #19355
Reported-by: Bihua Wang <wangbihua.cn@gmail.com>
Diagnosed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Diagnosed-by: Tender Wang <tndrwang@gmail.com>
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/19355-57d7d52ea4980dc6@postgresql.org
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/889676a0d553974d8f46816844e80e5c9deacd0e

Modified Files
--------------
src/backend/executor/execMain.c                | 14 +++++++++-----
src/backend/executor/nodeLockRows.c            | 10 +++++++---
src/backend/executor/nodeModifyTable.c         | 10 +++++++---
src/test/isolation/expected/eval-plan-qual.out | 20 ++++++++++++++++++++
src/test/isolation/specs/eval-plan-qual.spec   | 13 +++++++++++++
5 files changed, 56 insertions(+), 11 deletions(-)



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

* pgsql: Fix rowmark handling for non-relation RTEs during executor init
@ 2026-01-16 06:00 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Amit Langote @ 2026-01-16 06:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix rowmark handling for non-relation RTEs during executor init

Commit cbc127917e introduced tracking of unpruned relids to skip
processing of pruned partitions. PlannedStmt.unprunableRelids is
computed as the difference between PlannerGlobal.allRelids and
prunableRelids, but allRelids only contains RTE_RELATION entries.
This means non-relation RTEs (VALUES, subqueries, CTEs, etc.) are
never included in unprunableRelids, and consequently not in
es_unpruned_relids at runtime.

As a result, rowmarks attached to non-relation RTEs were incorrectly
skipped during executor initialization. This affects any DML statement
that has rowmarks on such RTEs, including MERGE with a VALUES or
subquery source, and UPDATE/DELETE with joins against subqueries or
CTEs. When a concurrent update triggers an EPQ recheck, the missing
rowmark leads to incorrect results.

Fix by restricting the es_unpruned_relids membership check to
RTE_RELATION entries only, since partition pruning only applies to
actual relations. Rowmarks for other RTE kinds are now always
processed.

Bug: #19355
Reported-by: Bihua Wang <wangbihua.cn@gmail.com>
Diagnosed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Diagnosed-by: Tender Wang <tndrwang@gmail.com>
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/19355-57d7d52ea4980dc6@postgresql.org
Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f335457e8adb32ce2e506e0d2b62c7f6f4bb98d1

Modified Files
--------------
src/backend/executor/execMain.c                | 14 +++++++++-----
src/backend/executor/nodeLockRows.c            | 10 +++++++---
src/backend/executor/nodeModifyTable.c         | 10 +++++++---
src/test/isolation/expected/eval-plan-qual.out | 20 ++++++++++++++++++++
src/test/isolation/specs/eval-plan-qual.spec   | 13 +++++++++++++
5 files changed, 56 insertions(+), 11 deletions(-)



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


end of thread, other threads:[~2026-01-16 06:00 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-01-16 05:56 pgsql: Fix rowmark handling for non-relation RTEs during executor init Amit Langote <amitlan@postgresql.org>
2026-01-16 06:00 pgsql: Fix rowmark handling for non-relation RTEs during executor init Amit Langote <amitlan@postgresql.org>

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