pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: marko@joh.to
Subject: BUG #18803: ERROR:  wrong varnullingrels (b) (expected (b 4)) for Var 2/1
Date: Tue, 11 Feb 2025 14:15:51 +0000
Message-ID: <18803-27d209f78dff2d2b@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18803
Logged by:          Marko Tiikkaja
Email address:      marko@joh.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)



view thread (3+ messages)  latest in thread

Message-ID: <18803-27d209f78dff2d2b@postgresql.org>
Permalink:  ../18803-27d209f78dff2d2b@postgresql.org/
Also on:    postgresql.org/message-id/18803-27d209f78dff2d2b@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, marko@joh.to
  Subject: Re: BUG #18803: ERROR:  wrong varnullingrels (b) (expected (b 4)) for Var 2/1
  In-Reply-To: <18803-27d209f78dff2d2b@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox