postgresql/src/backend
Tom Lane e11b6488e5 Fix misbehavior of CTE-used-in-a-subplan during EPQ rechecks.
An updating query that reads a CTE within an InitPlan or SubPlan could get
incorrect results if it updates rows that are concurrently being modified.
This is caused by CteScanNext supposing that nothing inside its recursive
ExecProcNode call could change which read pointer is selected in the CTE's
shared tuplestore.  While that's normally true because of scoping
considerations, it can break down if an EPQ plan tree gets built during the
call, because EvalPlanQualStart builds execution trees for all subplans
whether they're going to be used during the recheck or not.  And it seems
like a pretty shaky assumption anyway, so let's just reselect our own read
pointer here.

Per bug #14870 from Andrei Gorita.  This has been broken since CTEs were
implemented, so back-patch to all supported branches.

Discussion: https://postgr.es/m/20171024155358.1471.82377@wrigleys.postgresql.org
2018-02-19 16:00:18 -05:00
..
access Change some bogus PageGetLSN calls to BufferGetLSNAtomic 2018-01-09 17:07:24 -03:00
bootstrap Protect against multixact members wraparound 2015-04-28 11:32:53 -03:00
catalog Rethink the dependencies recorded for FieldSelect/FieldStore nodes. 2017-10-27 12:18:57 -04:00
commands Fix StoreCatalogInheritance1 to use 32bit inhseqno 2018-01-19 10:15:08 -03:00
executor Fix misbehavior of CTE-used-in-a-subplan during EPQ rechecks. 2018-02-19 16:00:18 -05:00
foreign Update copyright for 2014 2014-01-07 16:05:30 -05:00
lib Misc comment typo fixes. 2014-12-16 16:38:20 +02:00
libpq Fix some null pointer dereferences in LDAP auth code 2017-11-10 14:30:34 -05:00
main Install Windows crash dump handler before all else. 2017-11-12 14:31:04 -08:00
nodes Fix improper repetition of previous results from a hashed aggregate. 2016-08-24 14:37:51 -04:00
optimizer Add stack-overflow guards in set-operation planning. 2018-01-28 13:39:07 -05:00
parser Dept of second thoughts: keep aliasp_item in sync with tlistitem. 2017-10-27 18:16:25 -04:00
po Translation updates 2018-02-05 12:45:45 -05:00
port Avoid depending on non-POSIX behavior of fcntl(2). 2017-04-21 15:55:56 -04:00
postmaster Report failure to start a background worker. 2017-12-06 09:08:30 -05:00
regex Fix regexport.c to behave sanely with lookaround constraints. 2017-04-13 17:18:35 -04:00
replication Fix failure to delete spill files of aborted transactions 2018-01-05 12:17:10 -03:00
rewrite Fix multiple assignments to a column of a domain type. 2017-07-11 16:48:59 -04:00
snowball Fix ancient encoding error in hungarian.stop. 2014-06-10 22:48:31 -04:00
storage Make XactLockTableWait work for transactions that are not yet self-locked 2018-01-03 14:38:39 -03:00
tcop Unify SIGHUP handling between normal and walsender backends. 2017-06-05 19:18:16 -07:00
tsearch Reduce memory usage of tsvector type analyze function. 2017-07-12 22:04:03 +03:00
utils Fix pruning of locked and updated tuples. 2017-12-14 18:20:48 -08:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
Makefile AIX: Link the postgres executable with -Wl,-brtllib. 2015-07-15 21:00:30 -04:00
nls.mk Translation updates 2015-02-01 23:18:42 -05:00