pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add missing EPQ recheck for TID Scan
Date: Tue, 16 Sep 2025 23:49:16 +0000
Message-ID: <E1uyfQC-0014pq-16@gemulon.postgresql.org> (raw)

Add missing EPQ recheck for TID Scan

The EvalPlanQual recheck for TID Scan wasn't rechecking the TID qual
still passed after following update chains.  This could result in tuples
being updated or deleted by plans using TID Scans where the ctid of the
new (updated) tuple no longer matches the clause of the scan.  This isn't
desired behavior, and isn't consistent with what would happen if the
chosen plan had used an Index or Seq Scan, and that could lead to hard to
predict behavior for scans that contain TID quals and other quals as the
planner has freedom to choose TID or some other scan method for such
queries, and the chosen plan could change at any moment.

Here we fix this by properly implementing the recheck function for TID
Scans.

Backpatch to 13, oldest supported version

Reported-by: Sophie Alpert <pg@sophiebits.com>
Author: Sophie Alpert <pg@sophiebits.com>
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/4a6268ff-3340-453a-9bf5-c98d51a6f729@app.fastmail.com
Backpatch-through: 13

Branch
------
master

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

Modified Files
--------------
src/backend/executor/nodeTidscan.c             | 19 +++++--
src/test/isolation/expected/eval-plan-qual.out | 71 ++++++++++++++++++++++++++
src/test/isolation/specs/eval-plan-qual.spec   | 11 ++++
3 files changed, 97 insertions(+), 4 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1uyfQC-0014pq-16@gemulon.postgresql.org>
Permalink:  ../E1uyfQC-0014pq-16@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uyfQC-0014pq-16@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add missing EPQ recheck for TID Scan
  In-Reply-To: <E1uyfQC-0014pq-16@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