| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | Markus Winand <markus(dot)winand(at)winand(dot)at>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: ERROR: wrong varnullingrels (b 3) (expected (b)) for Var 2/1 |
| Date: | 2023-06-19 19:37:24 |
| Message-ID: | 3139165.1687203444@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
I wrote:
> Richard Guo <guofenglinux(at)gmail(dot)com> writes:
>> So it seems that we need to do nullingrel adjustments in a more common
>> place.
> I agree: this suggests that we fixed it in the wrong place.
So pursuant to that, 0001 attached reverts the code changes from bfd332b3f
and 63e4f13d2 (keeping the test cases and some unrelated comment fixes).
Then the question is what to do instead. I've not come up with a better
idea than to hack it in identify_current_nestloop_params (per 0002), as
you proposed upthread. I don't like this too much, as it's on the hairy
edge of making setrefs.c's nullingrel cross-checks completely useless for
NestLoopParams; but the alternatives aren't attractive either.
>> I think it exposes a new issue. It seems that we extract a problematic
>> lateral_relids from lateral references within PlaceHolderVars in
>> create_lateral_join_info. I doubt that we should use ph_lateral
>> directly. It seems more reasonable to me that we strip outer-join
>> relids from ph_lateral and then use that for lateral_relids.
I experimented with that (0003) and it fixes your example query.
I think it is functionally okay, because the lateral_relids just need
to be a sufficient subset of the lateral references' requirements to
ensure we can evaluate them where needed; other mechanisms should ensure
that the right sorts of joins happen. It seems a bit unsatisfying
though, especially given that we just largely lobotomized setrefs.c's
cross-checks for these same references. I don't have a better idea
however, and beta2 is fast approaching.
regards, tom lane
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-partial-revert-bfd332b3f-63e4f13d.patch | text/x-diff | 6.6 KB |
| 0002-fix-it-in-identify_current_nestloop_params.patch | text/x-diff | 5.7 KB |
| 0003-fix-lateral_relids.patch | text/x-diff | 3.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Haas | 2023-06-19 20:03:36 | Re: pgsql: Fix search_path to a safe value during maintenance operations. |
| Previous Message | Tomas Vondra | 2023-06-19 19:27:46 | Re: index prefetching |