Ensure dummy paths have correct required_outer if rel is parameterized.
authorTom Lane
Thu, 14 Mar 2019 16:16:09 +0000 (12:16 -0400)
committerTom Lane
Thu, 14 Mar 2019 16:16:09 +0000 (12:16 -0400)
commitd4b754c876d3338f314c9610e424083cfaff0717
tree6dec5ae5ea16dac5b34d95653631f54958ffa61c
parent0ca982a6d7489cea81909b672f96b947a3862cbc
Ensure dummy paths have correct required_outer if rel is parameterized.

The assertions added by commits 34ea1ab7f et al found another problem:
set_dummy_rel_pathlist and mark_dummy_rel were failing to label
the dummy paths they create with the correct outer_relids, in case
the relation is necessarily parameterized due to having lateral
references in its tlist.  It's likely that this has no user-visible
consequences in production builds, at the moment; but still an assertion
failure is a bad thing, so back-patch the fix.

Per bug #15694 from Roman Zharkov (via Alexander Lakhin)
and an independent report by Tushar Ahuja.

Discussion: https://postgr.es/m/15694-74f2ca97e7044f7f@postgresql.org
Discussion: https://postgr.es/m/7d72ab20-c725-3ce2-f99d-4e64dd8a0de6@enterprisedb.com
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/joinrels.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql