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-14 10:32:54
Message-ID: CAMbWs4-sZzwdOhhvX1KoQc5HXwkSKoRbcOg4eTtc_dn2sV+ndg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Mar 2, 2023 at 11:27 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> What's feeling like it might be the best thing is to go ahead and
> syntactically convert to the second form of identity 3 as soon as
> we've determined it's applicable, so that upper C Vars are always
> marked with both OJ relids. Not sure how much work is involved
> there.

I'm thinking something that once we've determined identity 3 applies in
make_outerjoininfo we record information about how to adjust relids for
upper quals and store this info in all upper JoinTreeItems. Then
afterwards in distribute_qual_to_rels we check all this info stored in
current JoinTreeItem and adjust relids for the qual accordingly.

The info we record should consist of two parts, target_relids and
added_relids. Vars and PHVs in quals that belong to target_relids
should be adjusted to include added_relids.

Following this idea I come up with attached patch (no comments and test
cases yet). It fixes the presented case and passes check-world. Before
finishing it I'd like to know whether this idea works. Any comments are
appreciated.

Thanks
Richard

Attachment Content-Type Size
v1-0001-Draft-adjust-upper-quals.patch application/octet-stream 4.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2023-03-14 11:13:41 Re: BUG #17826: An assert failed in /src/backend/optimizer/util/var.c
Previous Message Richard Guo 2023-03-14 06:08:23 Re: ERROR: PlaceHolderVar found where not expected