Re: pgsql: Avoid mislabeling of lateral references when pulling up a subque

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Avoid mislabeling of lateral references when pulling up a subque
Date: 2024-11-29 21:31:24
Message-ID: 590235.1732915884@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

I wrote:
> The ideas I'd been toying with last night involved a pre-scan over
> the join tree to calculate the potential nullingrels of each leaf RTE
> (same idea as RelOptInfo.nulling_relids, but of course we don't have
> any RelOptInfos yet). That seems painful though because we'd have to
> update the data structure somehow after each subquery pullup.

I realized that we can make that work by doing the pre-calculation
at the start of each pull_up_simple_subquery. We only have to do
it for subqueries marked LATERAL, so this doesn't seem too horribly
inefficient. Draft patch attached. I didn't spend effort on
devising test cases, but it works for your example.

regards, tom lane

Attachment Content-Type Size
v2-0001-Fix-wrong-varnullingrels.patch text/x-diff 7.9 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Richard Guo 2024-11-30 03:09:18 Re: pgsql: Avoid mislabeling of lateral references when pulling up a subque
Previous Message Tom Lane 2024-11-29 19:17:29 Re: pgsql: Avoid mislabeling of lateral references when pulling up a subque