Re: Ignored join clause
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Andreas Karlsson <andreas@proxel.se>, pgsql-bugs@lists.postgresql.org
Date: 2018-04-19T16:58:47Z
Lists: pgsql-bugs
Attachments
- parameterization-filter-clause-fix.patch (text/x-diff) patch
Andrew Gierth <andrew@tao11.riddles.org.uk> writes: > I think I was wrong, and that in fact this is a much more general > problem which amounts to a lack of communication between > get_joinrel_parampathinfo and extract_actual_join_clauses. Yeah, I think you're right. The rules about moving clauses down into a parameterized path may require something that had been a regular outer join clause to be moved to a join below its syntactic level. If we'd done that because the clause was actually degenerate (not mentioning the outer join's LHS), we'd have marked it is_pushed_down, but that doesn't seem practical in this situation since the RestrictInfo probably is also referenced in other paths where it's not pushed down. And I don't want to start making multiple RestrictInfos for the same clause --- that'll break some other stuff. So the only practical answer seems to be to teach extract_actual_join_clauses to check the clause's syntactic level along with is_pushed_down, as per the attached patch. Out of curiosity, I put Assert(bms_is_subset(rinfo->required_relids, joinrelids)); in there, and verified that we have no existing regression test that hits the assertion, though of course Andreas' example does. I've been pretty dissatisfied with the squishiness of is_pushed_down for some time (cf comments in initsplan.c around line 1770), and this bug seems like a sufficient reason to write it out of existence entirely. But that's surely not going to lead to a back-patchable change, so it's likely something for v12. regards, tom lane
Commits
-
Tweak a couple of planner APIs to save recalculating join relids.
- ec38dcd363cd 11.0 landed
-
Change more places to be less trusting of RestrictInfo.is_pushed_down.
- 9680c120e5b2 9.3.23 landed
- 80e12a621876 9.5.13 landed
- 64ad85860ce6 9.6.9 landed
- 58fec95268dc 9.4.18 landed
- c792c7db4146 11.0 landed
- 8b6294c7a560 10.4 landed
-
Fix broken extract_actual_join_clauses call in 9.6 postgres_fdw.
- 306d6e59f751 9.6.9 cited
-
Fix incorrect handling of join clauses pushed into parameterized paths.
- e5d83995e9f8 11.0 landed
- e4e43a16b250 9.5.13 landed
- e1d4398c0a5b 9.3.23 landed
- a347d5210ef0 9.4.18 landed
- 68fab04f7c2a 10.4 landed
- 0c141fcaa7dd 9.6.9 landed
-
Handle restriction clause lists more uniformly in postgres_fdw.
- 28b047875554 10.0 cited