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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: 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-09 20:51:01
Message-ID: 1246787.1699563061@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> On Mon, Nov 6, 2023 at 10:39 PM PG Bug reporting form <
> noreply(at)postgresql(dot)org> wrote:
>> ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2

> 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.

Yup, good catch! Fix pushed with a little editorializing on the test
case (mainly to try to ensure cross-platform stability of its plan).

> 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?

It's worrisome I agree. I looked through the other calls of makeVar()
and didn't find any that seemed wrong. (There are a lot of them that
are concerned with cases like manufacturing rowmark Vars, which I
think are OK because we don't support FOR UPDATE on nullable rels.)
Still, I wouldn't be totally surprised if we find a few more.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2023-11-10 01:44:21 Bug with GIN index over JSONB data: "ERROR: buffer 10112 is not owned by resource owner"
Previous Message PG Bug reporting form 2023-11-09 20:26:41 BUG #18188: wrong varnullingrels