pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #18803: ERROR:  wrong varnullingrels (b) (expected (b 4)) for Var 2/1
3+ messages / 3 participants
[nested] [flat]

* BUG #18803: ERROR:  wrong varnullingrels (b) (expected (b 4)) for Var 2/1
@ 2025-02-11 14:15 PG Bug reporting form <noreply@postgresql.org>
  2025-02-11 15:33 ` Re: BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2025-02-11 14:15 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: marko@joh.to

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)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1
  2025-02-11 14:15 BUG #18803: ERROR:  wrong varnullingrels (b) (expected (b 4)) for Var 2/1 PG Bug reporting form <noreply@postgresql.org>
@ 2025-02-11 15:33 ` Tom Lane <tgl@sss.pgh.pa.us>
  2025-02-11 20:55   ` Re: BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1 Marko Tiikkaja <marko@joh.to>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2025-02-11 15:33 UTC (permalink / raw)
  To: marko@joh.to; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> Given this schema:
> ...
> Running this query:
> ...
> produces the following error:
> ERROR:  wrong varnullingrels (b) (expected (b 4)) for Var 2/1

Thanks for the clear report!  We've seen a few variants of this,
and apparently yours is among the cases that are recently fixed.
Trying this example on a fresh 16-tip build (more or less 16.7)
just emits

DO

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1
  2025-02-11 14:15 BUG #18803: ERROR:  wrong varnullingrels (b) (expected (b 4)) for Var 2/1 PG Bug reporting form <noreply@postgresql.org>
  2025-02-11 15:33 ` Re: BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1 Tom Lane <tgl@sss.pgh.pa.us>
@ 2025-02-11 20:55   ` Marko Tiikkaja <marko@joh.to>
  0 siblings, 0 replies; 3+ messages in thread

From: Marko Tiikkaja @ 2025-02-11 20:55 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs@lists.postgresql.org

Hi Tom,

On Tue, Feb 11, 2025 at 5:33 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thanks for the clear report!  We've seen a few variants of this,
> and apparently yours is among the cases that are recently fixed.
> Trying this example on a fresh 16-tip build (more or less 16.7)
> just emits

That would be my bad.  I git grep'd the 16 branch but I thought it was
unrelated.  Thanks for the confirmation!


.m





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-02-11 20:55 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-02-11 14:15 BUG #18803: ERROR:  wrong varnullingrels (b) (expected (b 4)) for Var 2/1 PG Bug reporting form <noreply@postgresql.org>
2025-02-11 15:33 ` Re: BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1 Tom Lane <tgl@sss.pgh.pa.us>
2025-02-11 20:55   ` Re: BUG #18803: ERROR: wrong varnullingrels (b) (expected (b 4)) for Var 2/1 Marko Tiikkaja <marko@joh.to>

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