postgresql/src/backend
Tom Lane e5d83995e9 Fix incorrect handling of join clauses pushed into parameterized paths.
In some cases a clause attached to an outer join can be pushed down into
the outer join's RHS even though the clause is not degenerate --- this
can happen if we choose to make a parameterized path for the RHS.  If
the clause ends up attached to a lower outer join, we'd misclassify it
as being a "join filter" not a plain "filter" condition at that node,
leading to wrong query results.

To fix, teach extract_actual_join_clauses to examine each join clause's
required_relids, not just its is_pushed_down flag.  (The latter now
seems vestigial, or at least in need of rethinking, but we won't do
anything so invasive as redefining it in a bug-fix patch.)

This has been wrong since we introduced parameterized paths in 9.2,
though it's evidently hard to hit given the lack of previous reports.
The test case used here involves a lateral function call, and I think
that a lateral reference may be required to get the planner to select
a broken plan; though I wouldn't swear to that.  In any case, even if
LATERAL is needed to trigger the bug, it still affects all supported
branches, so back-patch to all.

Per report from Andreas Karlsson.  Thanks to Andrew Gierth for
preliminary investigation.

Discussion: https://postgr.es/m/f8128b11-c5bf-3539-48cd-234178b2314d@proxel.se
2018-04-19 15:49:30 -04:00
..
access Adjust _bt_insertonpg() comments 2018-04-19 11:08:45 +03:00
bootstrap Rationalize handling of array type names in bootstrap data. 2018-04-17 18:29:11 -04:00
catalog Improve error detection/reporting in Catalog.pm and genbki.pl. 2018-04-18 18:17:02 -04:00
commands Better fix for deadlock hazard in CREATE INDEX CONCURRENTLY. 2018-04-18 12:07:37 -04:00
executor Remove quick path in ExecInitPartitionInfo for equal tupdescs 2018-04-19 16:46:53 -03:00
foreign
jit Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
lib Fix non-portable use of round(). 2018-03-31 20:26:47 -07:00
libpq Make be-secure-common.c more consistent for future SSL implementations 2018-04-02 11:37:40 -04:00
main
nodes Revert MERGE patch 2018-04-12 11:22:56 +01:00
optimizer Fix incorrect handling of join clauses pushed into parameterized paths. 2018-04-19 15:49:30 -04:00
parser Reorganize partitioning code 2018-04-14 21:12:14 -03:00
partitioning Plural of modulus is moduli 2018-04-19 12:39:13 -03:00
po
port Fix and improve pg_atomic_flag fallback implementation. 2018-04-06 19:55:32 -07:00
postmaster Allocate enough shared string memory for stats of auxiliary processes. 2018-04-11 23:39:49 +03:00
regex
replication Don't attempt to verify checksums on new pages 2018-04-15 14:05:56 +02:00
rewrite Simplify view-expansion code in rewriteHandler.c. 2018-04-14 21:01:03 -04:00
snowball
statistics
storage Fix incorrect close() call in dsm_impl_mmap(). 2018-04-10 18:34:54 -04:00
tcop Reorganize partitioning code 2018-04-14 21:12:14 -03:00
tsearch Improve regression test coverage for src/backend/tsearch/spell.c. 2018-04-13 13:49:52 -04:00
utils Plural of modulus is moduli 2018-04-19 12:39:13 -03:00
.gitignore
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
nls.mk