Re: BUG #18429: Inconsistent results on similar queries with join lateral
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Benoit Ryder <b.ryder@ateme.com>,
"David G. Johnston" <david.g.johnston@gmail.com>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2024-04-14T08:59:06Z
Lists: pgsql-bugs
On Sun, Apr 14, 2024 at 6:59 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > So this seems like a bit of a mess. We can fix the submitted bug with > the kluge of only testing the nullable_relids condition, as I've done > in the attached patch for v15. (As join_clause_is_movable_into says, > this condition is conservative and might sometimes reject a clause > that could be evaluated safely, but that's fine for > get_baserel_parampathinfo's purposes.) I wondered that we could fix this issue by checking em_nullable_relids in generate_join_implied_equalities_normal when we determine if an EC member is computable at the join. Then I realize that this is not easy to achieve without knowing the exact join(s) where the nulling would happen, which is exactly what the nullingrel stuff introduced in v16 does. So your proposed fix seems the right way to go. Now that we've learned that join_clause_is_movable_into's heuristic about physically referencing the target rel can fail for EC-derived clauses, I'm kind of concerned that we may end up with duplicate clauses in the final plan, since we do not check EC-derived clauses against join_clause_is_movable_into in get_baserel_parampathinfo while we do in create_nestloop_path. What if we have an EC-derived clause that in get_baserel_parampathinfo it is put into ppi_clauses while in create_nestloop_path it does not pass the movability checking? Is it possible to occur, or is it just my illusion? Thanks Richard
Commits
-
Ensure generated join clauses for child rels have correct relids.
- 03107b4eda7f 17.0 landed
- 91800af13710 16.3 landed
-
Fix generation of EC join conditions at the wrong plan level.
- f502849d49a4 12.19 landed
- d9e4ee74f48c 13.15 landed
- ab2402268c04 14.12 landed
- 5aacfa64e5da 15.7 landed
-
Make Vars be outer-join-aware.
- 2489d76c4906 16.0 cited