Fix corner case where SELECT FOR UPDATE could return a row twice.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: f5e4e92fbe2fd655d8b1ec30b523cfb134e66bf0
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2014-12-12T00:37:17Z
Releases: 9.0.19
Fix corner case where SELECT FOR UPDATE could return a row twice.

In READ COMMITTED mode, if a SELECT FOR UPDATE discovers it has to redo
WHERE-clause checking on rows that have been updated since the SELECT's
snapshot, it invokes EvalPlanQual processing to do that.  If this first
occurs within a non-first child table of an inheritance tree, the previous
coding could accidentally re-return a matching row from an earlier,
already-scanned child table.  (And, to add insult to injury, I think this
could make it miss returning a row that should have been returned, if the
updated row that this happens on should still have passed the WHERE qual.)
Per report from Kyotaro Horiguchi; the added isolation test is based on his
test case.

This has been broken for quite awhile, so back-patch to all supported
branches.

Files

PathChange+/−
src/backend/executor/nodeLockRows.c modified +22 −0