]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add missing EPQ recheck for TID Scan
authorDavid Rowley <drowley@postgresql.org>
Tue, 16 Sep 2025 23:51:21 +0000 (11:51 +1200)
committerDavid Rowley <drowley@postgresql.org>
Tue, 16 Sep 2025 23:51:21 +0000 (11:51 +1200)
commit940f3cd5df57df41bb3d71f7f91fe0c713699e4d
treee23f7e3caa2b6eb909a7757e4d88902dc9c3366a
parenta685c057ad4cacfb5648903adcb940edeffdefc4
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
src/backend/executor/nodeTidscan.c
src/test/isolation/expected/eval-plan-qual.out
src/test/isolation/specs/eval-plan-qual.spec