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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: marian.krucina@linuxbox.cz, pgsql-bugs@lists.postgresql.org
Date: 2023-11-09T20:51:01Z
Lists: 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



Commits

  1. Fix computation of varnullingrels when const-folding field selection.