BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: marko(at)joh(dot)to
Subject: BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1
Date: 2025-02-11 14:15:51
Message-ID: 18803-27d209f78dff2d2b@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: 18803
Logged by: Marko Tiikkaja
Email address: marko(at)joh(dot)to
PostgreSQL version: 16.6
Operating system: Linux
Description:

Given this schema:

BEGIN;
CREATE TABLE Users();
CREATE TABLE Orders(MessageID text);
CREATE TABLE Transfers (TransferID bigint);
COMMIT;

Running this query:

DO $$
BEGIN

EXECUTE $SQL$
SELECT
CASE WHEN $1 < 1
THEN 1
ELSE sum(1) OVER ()
END AS Total,
MessageID
FROM (
SELECT
coalesce(
ECR.MessageID,
Orders.MessageID
) AS MessageID
FROM Orders
LEFT JOIN LATERAL (
SELECT
Transfers.TransferID || Orders.MessageID AS MessageID
FROM Transfers
) ECR ON TRUE
) Txn
$SQL$
USING 1;

END
$$;

produces the following error:

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

(where the "1" seems to correspond to the pg_attribute.attnum of
Orders.MessageID)

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Laurenz Albe 2025-02-11 14:20:24 Re: Major Version Upgrade failure due to orphan roles entries in catalog
Previous Message Virender Singla 2025-02-11 10:02:42 Major Version Upgrade failure due to orphan roles entries in catalog