| From: | wenhui qiu <qiuwenhuifx(at)gmail(dot)com> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | Re: ERROR: failed to apply nullingrels to a non-Var |
| Date: | 2026-10-12 02:55:48 |
| Message-ID: | CAGjGUALzE=xw+t5G3na9o34BZ=tfNJQoZ9Mqi5j7U10-KpXYdA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
HI Richard
> Thanks for reporting this and tracking it down to lateral PHVs.
>
> Between the two approaches you mentioned, I'm personally more inclined
> towards your second thought (checking lateral_referencers).
>
> My slight concern with switching to required_relids is that
> required_relids and nulling_relids serve slightly different purposes
> conceptually. While checking required_relids happens to catch the issue
> here, I wonder if that might be an indirect effect of how PHV's ph_eval_at
> tracks outer joins. For instance, if s were involved in an inner join
> instead of a left join, rel->nulling_relids would be empty, but we
> probably still wouldn't want to push down a qual that references s's
> lateral referencers into the child relations.
>
> In that sense, checking rel->lateral_referencers seems to capture the root
> of the problem more naturally: the qual references something (ss) that
> topologically depends on s, so it shouldn't be pushed down to s's child
> relations in the first place. That also aligns very well with the
> reasoning already used in join_clause_is_movable_to().
>
> So perhaps something like this would be a bit more robust:
>
> diff
> - if (!bms_overlap(rinfo->clause_relids, rel->nulling_relids))
> + if (!bms_overlap(rinfo->clause_relids, rel->nulling_relids) &&
> + !bms_overlap(rinfo->clause_relids, rel->lateral_referencers))
>
> What do you think?
>
>
>
Regards
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Osama Abdul Qader | 2026-10-12 02:58:17 | Re: Fix UNIQUE WITHOUT OVERLAPS + NULLS NOT DISTINCT + multiranges |
| Previous Message | John Naylor | 2026-10-12 02:50:05 | Re: Improving scalability of Parallel Bitmap Heap/Index Scan |