postgresql/src
Tom Lane 96dd77d349 Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes.
ExecInitCteScan supposed that it didn't have to do anything to the extra
tuplestore read pointer it gets from tuplestore_alloc_read_pointer.
However, it needs this read pointer to be positioned at the start of the
tuplestore, while tuplestore_alloc_read_pointer is actually defined as
cloning the current position of read pointer 0.  In normal situations
that accidentally works because we initialize the whole plan tree at once,
before anything gets read.  But it fails in an EvalPlanQual recheck, as
illustrated in bug #14328 from Dima Pavlov.  To fix, just forcibly rewind
the pointer after tuplestore_alloc_read_pointer.  The cost of doing so is
negligible unless the tuplestore is already in TSS_READFILE state, which
wouldn't happen in normal cases.  We could consider altering tuplestore's
API to make that case cheaper, but that would make for a more invasive
back-patch and it doesn't seem worth it.

This has been broken probably for as long as we've had CTEs, so back-patch
to all supported branches.

Discussion: <32468.1474548308@sss.pgh.pa.us>
2016-09-22 11:35:03 -04:00
..
backend Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. 2016-09-22 11:35:03 -04:00
bin Add tests for various connection string issues 2016-09-22 12:00:00 -04:00
common pg_ctl: Detect current standby state from pg_control 2016-09-21 12:00:00 -04:00
fe_utils Teach appendShellString() to not quote strings containing "-". 2016-09-06 14:53:31 -04:00
include pg_ctl: Detect current standby state from pg_control 2016-09-21 12:00:00 -04:00
interfaces Fix ecpg -? option on Windows, add -V alias for --version. 2016-09-18 13:46:32 +03:00
makefiles
pl Improve parser's and planner's handling of set-returning functions. 2016-09-13 13:54:24 -04:00
port Re-add translation markers that were lost 2016-09-20 12:00:00 -04:00
template
test Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. 2016-09-22 11:35:03 -04:00
timezone Add regression test coverage for non-default timezone abbreviation sets. 2016-09-04 20:02:16 -04:00
tools MSVC: Include pg_recvlogical in client-only install. 2016-09-19 14:25:57 -04:00
tutorial
.gitignore
bcc32.mak
DEVELOPERS
Makefile
Makefile.global.in
Makefile.shlib
nls-global.mk
win32.mak