postgresql/src/backend
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
..
access Delay updating control file to "in production" 2016-09-21 12:00:00 -04:00
bootstrap Fix a bunch of places that called malloc and friends with no NULL check. 2016-08-30 18:22:43 -04:00
catalog Improve parser's and planner's handling of set-returning functions. 2016-09-13 13:54:24 -04:00
commands Clarify policy on marking inherited constraints as valid. 2016-09-15 17:24:54 -04:00
executor Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes. 2016-09-22 11:35:03 -04:00
foreign Remove GetUserMappingId() and GetUserMappingById(). 2016-07-22 11:32:23 -04:00
lib Clarify the new Red-Black post-order traversal code a bit. 2016-09-04 15:02:06 +03:00
libpq Fix building with LibreSSL. 2016-09-15 22:52:51 +03:00
main Repair a bit of pgindent damage. 2016-06-09 18:09:17 -04:00
nodes Add debugging aid "bmsToString(Bitmapset *bms)". 2016-09-16 09:36:24 -04:00
optimizer Improve parser's and planner's handling of set-returning functions. 2016-09-13 13:54:24 -04:00
parser Improve parser's and planner's handling of set-returning functions. 2016-09-13 13:54:24 -04:00
po Translation updates 2016-08-08 11:08:00 -04:00
port Fix a bunch of places that called malloc and friends with no NULL check. 2016-08-30 18:22:43 -04:00
postmaster Use PostmasterRandom(), not random(), for DSM control segment ID. 2016-09-20 12:26:29 -04:00
regex Make locale-dependent regex character classes work for large char codes. 2016-09-05 17:06:29 -04:00
replication Identify walsenders in pg_stat_activity 2016-09-12 08:57:14 +01:00
rewrite Improve parser's and planner's handling of set-returning functions. 2016-09-13 13:54:24 -04:00
snowball Update copyright for 2016 2016-01-02 13:33:40 -05:00
storage Use PostmasterRandom(), not random(), for DSM control segment ID. 2016-09-20 12:26:29 -04:00
tcop Add location field to DefElem 2016-09-06 12:00:00 -04:00
tsearch Add macros to make AllocSetContextCreate() calls simpler and safer. 2016-08-27 17:50:38 -04:00
utils pg_ctl: Detect current standby state from pg_control 2016-09-21 12:00:00 -04:00
.gitignore
common.mk
Makefile Provide and use a makefile target to build all generated headers. 2016-07-01 15:09:02 -04:00
nls.mk Remove trailing slashes from directories in find command 2015-09-18 22:06:54 -04:00