BUG #17978: Unexpected error: "wrong varnullingrels (b) (expected (b 5)) for Var 6/2" triggered by JOIN

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: zuming(dot)jiang(at)inf(dot)ethz(dot)ch
Subject: BUG #17978: Unexpected error: "wrong varnullingrels (b) (expected (b 5)) for Var 6/2" triggered by JOIN
Date: 2023-06-15 08:20:39
Message-ID: 17978-12f3d93a55297266@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: 17978
Logged by: Zuming Jiang
Email address: zuming(dot)jiang(at)inf(dot)ethz(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2023-06-15 10:00:00 Re: BUG #17888: Incorrect memory access in gist__int_ops for an input array with many elements
Previous Message Dmitry Dolgov 2023-06-15 07:29:28 Re: BUG #17949: Adding an index introduces serialisation anomalies.