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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #18634: Wrong varnullingrels with merge ... when not matched by source
Date: 2024-09-26 18:00:01
Message-ID: 18634-db5299c937877f2b@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18634
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 17.0
Operating system: Ubuntu 22.04
Description:

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

At the same time,
MERGE INTO v USING (SELECT * FROM generate_series(1,1)) AS s(a)
ON s.a = v.a WHEN MATCHED THEN DELETE;
planned and executed with no error.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2024-09-26 22:41:29 Re: BUG #18634: Wrong varnullingrels with merge ... when not matched by source
Previous Message Fujii Masao 2024-09-26 14:19:33 Re: vacuumdb: permission denied for schema "pg_temp_7"