postgresql/src/include/nodes
Tom Lane 6ea364e7e7 Prevent overly-aggressive collapsing of joins to RTE_RESULT relations.
The RTE_RESULT simplification logic added by commit 4be058fe9 had a
flaw: it would collapse out a RTE_RESULT that is due to compute a
PlaceHolderVar, and reassign the PHV to the parent join level, even if
another input relation of the join contained a lateral reference to
the PHV.  That can't work because the PHV would be computed too late.
In practice it led to failures of internal sanity checks later in
planning (either assertion failures or errors such as "failed to
construct the join relation").

To fix, add code to check for the presence of such PHVs in relevant
portions of the query tree.  Notably, this required refactoring
range_table_walker so that a caller could ask to walk individual RTEs
not the whole list.  (It might be a good idea to refactor
range_table_mutator in the same way, if only to keep those functions
looking similar; but I didn't do so here as it wasn't necessary for
the bug fix.)

This exercise also taught me that find_dependent_phvs(), as it stood,
could only safely be used on the entire Query, not on subtrees.
Adjust its API to reflect that; which in passing allows it to have
a fast path for the common case of no PHVs anywhere.

Per report from Will Leinweber.  Back-patch to v12 where the bug
was introduced.

Discussion: https://postgr.es/m/CALLb-4xJMd4GZt2YCecMC95H-PafuWNKcmps4HLRx2NHNBfB4g@mail.gmail.com
2019-12-14 13:49:15 -05:00
..
bitmapset.h Add support for multivariate MCV lists 2019-03-27 18:32:18 +01:00
execnodes.h Allow executor startup pruning to prune all child nodes. 2019-12-11 17:05:30 -05:00
extensible.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
lockoptions.h Don't include heapam.h from others headers. 2019-01-14 16:24:41 -08:00
makefuncs.h Fix handling of expressions and predicates in REINDEX CONCURRENTLY 2019-07-29 09:58:49 +09:00
memnodes.h Use Size instead of int64 to track allocated memory 2019-10-04 16:10:56 +02:00
nodeFuncs.h Prevent overly-aggressive collapsing of joins to RTE_RESULT relations. 2019-12-14 13:49:15 -05:00
nodes.h Allow setting statistics target for extended statistics 2019-09-11 00:25:51 +02:00
params.h Emit parameter values during query bind/execute errors 2019-12-11 18:03:35 -03:00
parsenodes.h Introduce the 'force' option for the Drop Database command. 2019-11-13 08:25:33 +05:30
pathnodes.h Further adjust EXPLAIN's choices of table alias names. 2019-12-11 17:05:18 -05:00
pg_list.h Rationalize use of list_concat + list_copy combinations. 2019-08-12 11:20:18 -04:00
plannodes.h Further adjust EXPLAIN's choices of table alias names. 2019-12-11 17:05:18 -05:00
primnodes.h Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
print.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
readfuncs.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
replnodes.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
supportnodes.h Allow extensions to generate lossy index conditions. 2019-02-11 21:26:14 -05:00
tidbitmap.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
value.h Update copyright for 2019 2019-01-02 12:44:25 -05:00