postgresql/src
Tom Lane 89deca582a Fix planner error (or assert trap) with nested set operations.
As reported by Sean Johnston in bug #14614, since 9.6 the planner can fail
due to trying to look up the referent of a Var with varno 0.  This happens
because we generate such Vars in generate_append_tlist, for lack of any
better way to describe the output of a SetOp node.  In typical situations
nothing really cares about that, but given nested set-operation queries
we will call estimate_num_groups on the output of the subquery, and that
wants to know what a Var actually refers to.  That logic used to look at
subquery->targetList, but in commit 3fc6e2d7f I'd switched it to look at
subroot->processed_tlist, ie the actual output of the subquery plan not the
parser's idea of the result.  It seemed like a good idea at the time :-(.
As a band-aid fix, change it back.

Really we ought to have an honest way of naming the outputs of SetOp steps,
which suggests that it'd be a good idea for the parser to emit an RTE
corresponding to each one.  But that's a task for another day, and it
certainly wouldn't yield a back-patchable fix.

Report: https://postgr.es/m/20170407115808.25934.51866@wrigleys.postgresql.org
2017-04-07 12:18:38 -04:00
..
backend Fix planner error (or assert trap) with nested set operations. 2017-04-07 12:18:38 -04:00
bin pg_dump: Rename some typedefs to avoid name conflicts 2017-04-06 14:16:54 -04:00
common Use SASLprep to normalize passwords for SCRAM authentication. 2017-04-07 14:56:05 +03:00
fe_utils Allow psql variable substitution to occur in backtick command strings. 2017-04-01 21:44:54 -04:00
include Use SASLprep to normalize passwords for SCRAM authentication. 2017-04-07 14:56:05 +03:00
interfaces Use SASLprep to normalize passwords for SCRAM authentication. 2017-04-07 14:56:05 +03:00
makefiles Try to fix non-MSVC Windows builds in the wake of logical replication. 2017-01-20 12:51:31 -05:00
pl Capitalize names of PLs consistently 2017-04-05 00:38:25 -04:00
port Fix and simplify check for whether we're running as Windows service. 2017-03-17 11:14:01 +02:00
template Remove "sco" and "unixware" ports. 2016-10-11 11:26:04 -04:00
test Fix planner error (or assert trap) with nested set operations. 2017-04-07 12:18:38 -04:00
timezone Remove useless duplicate inclusions of system header files. 2017-02-25 16:12:55 -05:00
tools Use SASLprep to normalize passwords for SCRAM authentication. 2017-04-07 14:56:05 +03:00
tutorial Recommend wrappers of PG_DETOAST_DATUM_PACKED(). 2017-03-12 19:35:33 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Remove redundant coverage target 2017-02-17 08:56:57 -05:00
Makefile.global.in Remove use of Jade and DSSSL 2017-04-06 22:09:11 -04:00
Makefile.shlib Fix typos in comments. 2017-02-06 11:33:58 +02:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00