postgresql/src/test/regress
Tom Lane 00011a6ae9 Fix failure in WHERE CURRENT OF after rewinding the referenced cursor.
In a case where we have multiple relation-scan nodes in a cursor plan,
such as a scan of an inheritance tree, it's possible to fetch from a
given scan node, then rewind the cursor and fetch some row from an
earlier scan node.  In such a case, execCurrent.c mistakenly thought
that the later scan node was still active, because ExecReScan hadn't
done anything to make it look not-active.  We'd get some sort of
failure in the case of a SeqScan node, because the node's scan tuple
slot would be pointing at a HeapTuple whose t_self gets reset to
invalid by heapam.c.  But it seems possible that for other relation
scan node types we'd actually return a valid tuple TID to the caller,
resulting in updating or deleting a tuple that shouldn't have been
considered current.  To fix, forcibly clear the ScanTupleSlot in
ExecScanReScan.

Another issue here, which seems only latent at the moment but could
easily become a live bug in future, is that rewinding a cursor does
not necessarily lead to *immediately* applying ExecReScan to every
scan-level node in the plan tree.  Upper-level nodes will think that
they can postpone that call if their child node is already marked
with chgParam flags.  I don't see a way for that to happen today in
a plan tree that's simple enough for execCurrent.c's search_plan_tree
to understand, but that's one heck of a fragile assumption.  So, add
some logic in search_plan_tree to detect chgParam flags being set on
nodes that it descended to/through, and assume that that means we
should consider lower scan nodes to be logically reset even if their
ReScan call hasn't actually happened yet.

Per bug #15395 from Matvey Arye.  This has been broken for a long time,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/153764171023.14986.280404050547008575@wrigleys.postgresql.org
2018-09-23 16:05:46 -04:00
..
data Fix GIN to support null keys, empty and null items, and full index scans. 2011-01-07 19:16:24 -05:00
expected Fix failure in WHERE CURRENT OF after rewinding the referenced cursor. 2018-09-23 16:05:46 -04:00
input Remove regression tests' CREATE FUNCTION commands for unused C functions. 2018-02-27 15:04:58 -05:00
output Remove regression tests' CREATE FUNCTION commands for unused C functions. 2018-02-27 15:04:58 -05:00
sql Fix failure in WHERE CURRENT OF after rewinding the referenced cursor. 2018-09-23 16:05:46 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
GNUmakefile Fix regression test parallel-make hazard. 2016-08-12 20:51:59 -04:00
Makefile Fix non-GNU makefiles for AIX make. 2017-11-30 00:57:32 -08:00
parallel_schedule Merge large_object.sql test into largeobject.source. 2017-07-17 15:28:17 -04:00
pg_regress.c Clean up assorted misuses of snprintf()'s result value. 2018-08-15 16:29:32 -04:00
pg_regress.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
pg_regress_main.c Clean up assorted misuses of snprintf()'s result value. 2018-08-15 16:29:32 -04:00
README Don't generate plain-text HISTORY and src/test/regress/README anymore. 2014-02-10 20:48:12 -05:00
regress.c Prevent dangling-pointer access when update trigger returns old tuple. 2018-02-27 13:27:38 -05:00
regressplans.sh Tweak regressplans.sh to use any already-set PGOPTIONS. 2000-12-18 02:45:47 +00:00
resultmap Enable compiling with the mingw-w64 32 bit compiler. 2011-12-10 15:35:41 -05:00
serial_schedule Merge large_object.sql test into largeobject.source. 2017-07-17 15:28:17 -04:00
standby_schedule Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00

Documentation concerning how to run these regression tests and interpret
the results can be found in the PostgreSQL manual, in the chapter
"Regression Tests".