Re: Clause accidentally pushed down ( Possible bug in Making Vars outer-join aware)

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Clause accidentally pushed down ( Possible bug in Making Vars outer-join aware)
Date: 2023-03-30 07:01:52
Message-ID: CAMbWs4_Bt2YV-geNmLHyS6hmEbkX4C7rV4miaiMUK7+e2-gJfQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Mar 21, 2023 at 2:23 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

> On Tue, Mar 21, 2023 at 12:21 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> So the idea that I had was to, once we detect that X commutes with Y,
>> immediately call a function that recurses through the relevant parts
>> of root->parse and performs the required nullingrels updates.
>
>
> So IIUC the idea is that if we are given the first form of identity 3,
> we update all upper C Vars so that they are marked with both OJ relids.
> It seems that this may have nullingrels mis-match issue because of how
> we form outer join's target list.
>

I do have a try coding along this idea to update all upper C Vars being
marked with both OJ relids if the two OJs commute according to identity
3. And then I realize there are several other adjustments needed to
make it work.

* As I imagined before, we need to revise how we form outer join's
target list to avoid nullingrels mismatch. Currently the outer join's
target list is built in a way that the output Vars have the same nulling
bitmaps that they would if the two joins had been done in syntactic
order. And now we need to change that to always marking the output C
Vars with both joins.

* We need to revise how we check if identity 3 applies and if so how we
adjust min_lefthand in make_outerjoininfo. Consider

A leftjoin B on (Pab) leftjoin C on (Pbc) leftjoin D on (Pcd)

So now the C Vars in Pcd are marked with A/B join and B/C join since the
two joins can commute. When it comes to check if C/D join can commute
with B/C join, the A/B join from C Vars' nullingrels would make us think
that C/D join cannot commute with B/C join, which is not correct.
Besides, C/D join's min_lefthand including A/B join is also problematic.

* We need to adjust how we generate multiple versions for LEFT JOIN
quals in deconstruct_distribute_oj_quals, to cope with any new added
nulling rel. But I haven't figured out this point clearly yet.

So it seems there is some work involved. I begin to wonder if this is
the way we want.

Thanks
Richard

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Mats Kindahl 2023-03-30 07:54:51 Re: BUG #17876: Function width_bucket() for float8 input returns value out of range
Previous Message prasad kumbhar 2023-03-30 06:29:23 Re: Failed Upgrade during 11 to 15