Re: wrong query result due to wang plan
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: tender wang <tndrwang@gmail.com>, pgsql-hackers@postgresql.org
Date: 2023-02-20T09:51:30Z
Lists: pgsql-hackers
On Mon, Feb 20, 2023 at 3:01 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > We still have to fix process_implied_equality though, and in that > context we do have all the SpecialJoinInfos, so the strip-the-outer-joins > fix seems to work. See attached. Yeah, process_implied_equality is also broken for variable-free clause. I failed to notice that :-(. I'm looking at the strip-the-outer-joins codes. At first I wondered why it only removes JOIN_LEFT outer joins from below a JoinDomain's relids. After a second thought I think it's no problem here since only left outer joins have chance to commute with joins outside the JoinDomain. I'm thinking that maybe we can do the strip-the-outer-joins work only when it's not the top JoinDomain. When we are in the top JoinDomain, it seems to me that it's safe to push the qual to the top of the tree. - /* eval at join domain level */ - relids = bms_copy(qualscope); + /* eval at join domain's safe level */ + if (!bms_equal(qualscope, + ((JoinDomain *) linitial(root->join_domains))->jd_relids)) + relids = get_join_domain_min_rels(root, qualscope); + else + relids = bms_copy(qualscope); Thanks Richard
Commits
-
Fix some issues with wrong placement of pseudo-constant quals.
- a75ff55c8334 16.0 landed