Re: BUG #18184: ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: marian(dot)krucina(at)linuxbox(dot)cz, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18184: ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2
Date: 2023-11-07 03:06:30
Message-ID: CAMbWs4-zNHy3GAjiK7vnTEpU8eWiFRtHUB9s5mpo1Edhs=0Dfw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Nov 6, 2023 at 10:39 PM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

> Hi,
> We found a bug in PostgreSQL 16. I have simplified the case:
>
> SELECT
> function1(table1)
> FROM table2
> LEFT JOIN table1 ON table1_id = table2_id
> LEFT JOIN LATERAL (SELECT 1 FROM table3) AS tx3 ON (true)
> LIMIT 5;
>
> ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2

Thanks for the report! This is an error message that hasn't been seen
in a long time.

It seems that when we optimize field selection from a whole-row Var into
a simple Var while simplifying functions, we fail to propagate the
nullingrels into the new Var.

Attached is a hotfix for this error. But I'm wondering if there are
other similar cases where we have mismatched nullingrels that we haven't
discovered yet. Any thoughts?

Thanks
Richard

Attachment Content-Type Size
v1-0001-Fix-mismatched-nullingrels-when-inlining-functions.patch application/octet-stream 3.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Laurenz Albe 2023-11-07 07:32:01 Re: BUG #18185: Error when calling whoami at the beginning of the installation
Previous Message David Rowley 2023-11-06 22:38:07 Re: BUG #18177: certain queries under certain contexts take multiple orders of magnitude longer compared to v10