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

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-04-21 09:34:18
Message-ID: CAMbWs49H5ObtEdg-65gkXvmnHSedHpwa0rdQrjoOh7iWCLRgXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Apr 20, 2023 at 1:06 PM Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
wrote:

> I have passed through your patch and the
> 'postpone-adding-pushed-down-ojrelid-to-relids' patch step-by-step. It
> looks logically correct.
> Honestly, I don't happy with the top patch, because it looks a bit
> peculiar, but the sqlancer long test (which detected the problem before)
> didn't show any problems here.

Thanks for testing the patches.

Currently in the patch the pushed down outer joins are collected in
add_outer_joins_to_relids() and then passed in build_joinrel_tlist()
where their relids might need to be added to Var's nulling bitmap.
Alternatively their relids can be calculated by removing
both_input_relids as well as sjinfo->ojrelid from joinrel->relids. But
in this way we'd have to loop over the whole join_info_list to get the
pushed down joins, which is less efficient than what the patch does.

> But one thought is bugging me: do we have a guarantee, what with these
> Identity 3 transformations and 'delaying up to completely performed'
> technique we don't lose some joininfo clauses?

Are you worried about upper clauses who reference to C vars? In the
second form when we've formed A/B join, which would have both outer
joins' relids in its relid set, the upper clause will be able to be
applied there, and it is the correct join level.

BTW, cfbot reminds that a rebase is needed. So re-attach the two
patches. Now I think it should be in 'Needs review' again in CF. I'll
go and do the change.

Thanks
Richard

Attachment Content-Type Size
v2-0001-Adjust-outer-join-s-target-list.patch application/octet-stream 11.8 KB
postpone-adding-pushed-down-ojrelid-to-relids.patch application/octet-stream 16.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-04-21 10:19:03 BUG #17906: Segmentation fault and database crash during procedure call
Previous Message PG Bug reporting form 2023-04-21 03:09:57 BUG #17905: phpPgAdmin 7.13.0 is not updated to support PHP 8.1.16