Simplify LATERAL-related calculations within add_paths_to_joinrel().
authorTom Lane
Wed, 9 Dec 2015 23:54:25 +0000 (18:54 -0500)
committerTom Lane
Wed, 9 Dec 2015 23:54:25 +0000 (18:54 -0500)
commit54497807b3941b5e30bfe77ca6136a6163d4f199
tree920aeee44c2b97031e7c4394ff0f009c5e315709
parent0a34ff7e9a3a232d675fe03dba00d010c689f33c
Simplify LATERAL-related calculations within add_paths_to_joinrel().

While convincing myself that commit 7e19db0c09719d79 would solve both of
the problems recently reported by Andreas Seltenreich, I realized that
add_paths_to_joinrel's handling of LATERAL restrictions could be made
noticeably simpler and faster if we were to retain the minimum possible
parameterization for each joinrel (that is, the set of relids supplying
unsatisfied lateral references in it).  We already retain that for
baserels, in RelOptInfo.lateral_relids, so we can use that field for
joinrels too.

This is a back-port of commit edca44b1525b3d591263d032dc4fe500ea771e0e.
I originally intended not to back-patch that, but additional hacking
in this area turns out to be needed, making it necessary not optional
to compute lateral_relids for joinrels.  In preparation for those fixes,
sync the relevant code with HEAD as much as practical.  (I did not risk
rearranging fields of RelOptInfo in released branches, however.)
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/util/relnode.c
src/include/nodes/relation.h