Re: BUG #18184: ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2 - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18184: ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2
Date
Msg-id 1246787.1699563061@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #18184: ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2  (Richard Guo <guofenglinux@gmail.com>)
List pgsql-bugs
Richard Guo <guofenglinux@gmail.com> writes:
> On Mon, Nov 6, 2023 at 10:39 PM PG Bug reporting form <
> noreply@postgresql.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



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18188: wrong varnullingrels
Next
From: Jeff Janes
Date:
Subject: Bug with GIN index over JSONB data: "ERROR: buffer 10112 is not owned by resource owner"