Fix EvalPlanQual bug when query contains both locked and not-locked rels.
authorTom Lane <[email protected]>
Tue, 22 Mar 2016 21:56:06 +0000 (17:56 -0400)
committerTom Lane <[email protected]>
Tue, 22 Mar 2016 21:56:06 +0000 (17:56 -0400)
commitd8d5a00b182009f6fdb426a40ac677c4fda56be7
tree4e634798873e471253ad1c68f83f3d3c00d17f30
parent2f38b3e7dda4c3532b6bbc8676a8d30d528cd74e
Fix EvalPlanQual bug when query contains both locked and not-locked rels.

In commit afb9249d06f47d7a, we (probably I) made ExecLockRows assign
null test tuples to all relations of the query while setting up to do an
EvalPlanQual recheck for a newly-updated locked row.  This was sheerest
brain fade: we should only set test tuples for relations that are lockable
by the LockRows node, and in particular empty test tuples are only sensible
for inheritance child relations that weren't the source of the current
tuple from their inheritance tree.  Setting a null test tuple for an
unrelated table causes it to return NULLs when it should not, as exhibited
in bug #14034 from Bronislav Houdek.  To add insult to injury, doing it the
wrong way required two loops where one would suffice; so the corrected code
is even a bit shorter and faster.

Add a regression test case based on his example, and back-patch to 9.5
where the bug was introduced.
src/backend/executor/nodeLockRows.c
src/test/isolation/expected/eval-plan-qual.out
src/test/isolation/specs/eval-plan-qual.spec