Re: BUG #18634: Wrong varnullingrels with merge ... when not matched by source

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: exclusion(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18634: Wrong varnullingrels with merge ... when not matched by source
Date: 2024-09-26 22:41:29
Message-ID: 374420.1727390489@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> The following script:
> CREATE TABLE t (a int);
> INSERT INTO t VALUES(1), (2);
> CREATE VIEW v AS SELECT a FROM t WHERE EXISTS (SELECT 1 FROM t);

> MERGE INTO v USING (SELECT * FROM generate_series(1,1)) AS s(a)
> ON s.a = v.a WHEN NOT MATCHED BY SOURCE THEN DELETE;

> produces:
> ERROR: XX000: wrong varnullingrels (b) (expected (b 4)) for Var 5/1
> LOCATION: search_indexed_tlist_for_var, setrefs.c:2847

I haven't run this fully to ground, but what it looks like
is that preprocess_targetlist is generating row identity
Vars that lack required varnullingrels. I don't understand
though why this only seems to affect MERGE.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2024-09-27 00:45:12 Re: BUG #18630: Incorrect memory access inside ReindexIsProcessingIndex() on VACUUM
Previous Message PG Bug reporting form 2024-09-26 18:00:01 BUG #18634: Wrong varnullingrels with merge ... when not matched by source