ERROR: wrong varnullingrels (b 3) (expected (b)) for Var 2/1

From: Markus Winand <markus(dot)winand(at)winand(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ERROR: wrong varnullingrels (b 3) (expected (b)) for Var 2/1
Date: 2023-05-30 14:47:39
Message-ID: DFBB2D25-DE97-49CA-A60E-07C881EA59A7@winand.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I found an error similar to others before ([1]) that is still persists as of head right now (0bcb3ca3b9).

CREATE TABLE t (
n INTEGER
);

SELECT *
FROM (VALUES (1)) t(c)
LEFT JOIN t ljl1 ON true
LEFT JOIN LATERAL (WITH cte AS (SELECT * FROM t WHERE t.n = ljl1.n) SELECT * FROM cte) ljl2 ON ljl1.n = 1;

ERROR: wrong varnullingrels (b 3) (expected (b)) for Var 2/1

Note that the error does **not** occur if the CTE is unwrapped like this:

SELECT *
FROM (VALUES (1)) t(c)
LEFT JOIN t ljl1 ON true
LEFT JOIN LATERAL (SELECT * FROM t WHERE t.n = ljl1.n) ljl2 ON ljl1.n = 1;

-markus

[1] https://www.postgresql.org/message-id/CAHewXNnu7u1aT==WjnCRa+SzKb6s80hvwPP_9eMvvvtdyFdqjw@mail.gmail.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2023-05-30 14:58:28 Re: [PoC] pg_upgrade: allow to upgrade publisher node
Previous Message Tristan Partin 2023-05-30 14:42:37 Re: Make pgbench exit on SIGINT more reliably