Re: BUG #18634: Wrong varnullingrels with merge ... when not matched by source - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18634: Wrong varnullingrels with merge ... when not matched by source
Date
Msg-id 374420.1727390489@sss.pgh.pa.us
Whole thread Raw
In response to BUG #18634: Wrong varnullingrels with merge ... when not matched by source  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18634: Wrong varnullingrels with merge ... when not matched by source
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.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



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18634: Wrong varnullingrels with merge ... when not matched by source
Next
From: PG Bug reporting form
Date:
Subject: BUG #18635: " $libdir/adminpack could not be loaded" error with pg_upgrade to PostgreSQL17