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: zuming.jiang@inf.ethz.ch
Subject: BUG #17978: Unexpected error: "wrong varnullingrels (b) (expected (b 5)) for Var 6/2" triggered by JOIN
Date: Thu, 15 Jun 2023 08:20:39 +0000
Message-ID: <17978-12f3d93a55297266@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      17978
Logged by:          Zuming Jiang
Email address:      zuming.jiang@inf.ethz.ch
PostgreSQL version: 16beta1
Operating system:   Ubuntu 20.04
Description:        

My fuzzer finds a bug in Postgres, which triggers an unexpected error in
Postgres.

--- Set up database ---
CREATE TABLE t0 (vkey integer, c1 timestamp);
CREATE TABLE t1 (vkey integer, pkey integer);
CREATE TABLE t2 (c11 timestamp, c14 timestamp);
CREATE VIEW t3 AS
 SELECT ref_0.vkey AS c_0
   FROM (t0 ref_0
     LEFT JOIN t2 ref_1 ON ((ref_0.c1 = ref_1.c11)))
  WHERE ((false < ( SELECT (ref_0.c1 <> ref_1.c14) AS c_0
           FROM t2 ref_6
         ORDER BY ref_0.c1, ref_1.c14
        LIMIT 1)));
CREATE VIEW t6 AS SELECT 1 AS c_0, 2 AS c_1, 3 AS c_2;
INSERT INTO t1 VALUES (80, 90000);
ALTER TABLE ONLY t1 ADD CONSTRAINT t1_pkey PRIMARY KEY (pkey);
------------------------

The fuzzer generates Test case:

--- Test case ---
select  
    ref_38.c_0 as c_10 
  from 
    ((t3 as ref_38
        full outer join t6 as ref_39
        on (ref_38.c_0 = ref_39.c_1))
      right outer join t1 as ref_40
      on (ref_38.c_0 = ref_40.vkey));
------------------------

--- Expected behavior ---
The test case should not trigger any error.

--- Actual behavior ---
The test case trigger an error: 

ERROR:  wrong varnullingrels (b) (expected (b 5)) for Var 6/2

--- Postgres version ---
Github commit: 3f1aaaa180689f2015e7f7bd01c9be6d7a993b42
Version: PostgreSQL 16beta1 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit

--- Platform information ---
Platform: Ubuntu 20.04
Kernel: Linux 5.4.0-147-generic



view thread (7+ messages)  latest in thread

Message-ID: <17978-12f3d93a55297266@postgresql.org>
Permalink:  ../17978-12f3d93a55297266@postgresql.org/
Also on:    postgresql.org/message-id/17978-12f3d93a55297266@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, zuming.jiang@inf.ethz.ch
  Subject: Re: BUG #17978: Unexpected error: "wrong varnullingrels (b) (expected (b 5)) for Var 6/2" triggered by JOIN
  In-Reply-To: <17978-12f3d93a55297266@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