ERROR: wrong varnullingrels (b 5 7) (expected (b)) for Var 3/3

Started by tender wangover 2 years ago4 messages
#1tender wang
tndrwang@gmail.com

Hi hackers,
I found $subject problem when using SQLancer.

How to repeat:
CREATE TEMP TABLE t0(c0 inet, c1 money, c2 TEXT);
CREATE TEMP TABLE IF NOT EXISTS t1(LIKE t0); CREATE TEMP TABLE t2(c0
boolean , c1 DECIMAL NOT NULL UNIQUE); CREATE TEMPORARY TABLE t3(LIKE t1);
CREATE VIEW v0(c0) AS (SELECT DISTINCT 0 FROM t3); SELECT SUM(count) FROM
(SELECT
(((t1.c2)LIKE(((((t0.c2)||(((103556691)-(v0.c0)))))||(v0.c0)))))::INT as
count FROM t0, ONLY t1 RIGHT OUTER JOIN ONLY t2 ON t2.c0 RIGHT OUTER JOIN
v0 ON ((t2.c1)=(0.08182310538090898))) as res;

psql (16devel)
Type "help" for help.

postgres=# \d
Did not find any relations.
postgres=# CREATE TEMP TABLE t0(c0 inet, c1 money, c2 TEXT);
CREATE TABLE
postgres=# CREATE TEMP TABLE IF NOT EXISTS t1(LIKE t0);
CREATE TABLE
postgres=# CREATE TEMP TABLE t2(c0 boolean , c1 DECIMAL NOT NULL UNIQUE);
CREATE TABLE
postgres=# CREATE TEMPORARY TABLE t3(LIKE t1);
CREATE TABLE
postgres=# CREATE VIEW v0(c0) AS (SELECT DISTINCT 0 FROM t3);
NOTICE: view "v0" will be a temporary view
CREATE VIEW
postgres=# SELECT SUM(count) FROM (SELECT
(((t1.c2)LIKE(((((t0.c2)||(((103556691)-(v0.c0)))))||(v0.c0)))))::INT as
count FROM t0, ONLY t1 RIGHT OUTER JOIN ONLY t2 ON t2.c0 RIGHT OUTER JOIN
v0 ON ((t2.c1)=(0.08182310538090898))) as res;
ERROR: wrong varnullingrels (b 5 7) (expected (b)) for Var 3/3

regards, tender wang

#2Michael Paquier
michael@paquier.xyz
In reply to: tender wang (#1)
Re: ERROR: wrong varnullingrels (b 5 7) (expected (b)) for Var 3/3

On Fri, May 19, 2023 at 09:42:35AM +0800, tender wang wrote:

postgres=# \d
Did not find any relations.
postgres=# CREATE TEMP TABLE t0(c0 inet, c1 money, c2 TEXT);
CREATE TABLE
postgres=# CREATE TEMP TABLE IF NOT EXISTS t1(LIKE t0);
CREATE TABLE
postgres=# CREATE TEMP TABLE t2(c0 boolean , c1 DECIMAL NOT NULL UNIQUE);
CREATE TABLE
postgres=# CREATE TEMPORARY TABLE t3(LIKE t1);
CREATE TABLE
postgres=# CREATE VIEW v0(c0) AS (SELECT DISTINCT 0 FROM t3);
NOTICE: view "v0" will be a temporary view
CREATE VIEW
postgres=# SELECT SUM(count) FROM (SELECT
(((t1.c2)LIKE(((((t0.c2)||(((103556691)-(v0.c0)))))||(v0.c0)))))::INT as
count FROM t0, ONLY t1 RIGHT OUTER JOIN ONLY t2 ON t2.c0 RIGHT OUTER JOIN
v0 ON ((t2.c1)=(0.08182310538090898))) as res;
ERROR: wrong varnullingrels (b 5 7) (expected (b)) for Var 3/3

Thanks for the test case, issue reproduced here on HEAD and not v15.
This causes an assertion failure here:
#4 0x000055a6f8faa776 in ExceptionalCondition (conditionName=0x55a6f915ac60 "bms_equal(rel->relids, root->all_query_rels)", fileName=0x55a6f915ac3d "allpaths.c",
lineNumber=234) at assert.c:66
#5 0x000055a6f8c55b6d in make_one_rel (root=0x55a6fa814ea8, joinlist=0x55a6fa83f758) at allpaths.c:234
#6 0x000055a6f8c95c45 in query_planner (root=0x55a6fa814ea8, qp_callback=0x55a6f8c9c373 <standard_qp_callback>, qp_extra=0x7ffc98138570) at planmain.c:278
#7 0x000055a6f8c9860a in grouping_planner (root=0x55a6fa814ea8, tuple_fraction=0) at planner.c:1493

I am adding an open item.
--
Michael

#3Richard Guo
guofenglinux@gmail.com
In reply to: Michael Paquier (#2)
Re: ERROR: wrong varnullingrels (b 5 7) (expected (b)) for Var 3/3

On Fri, May 19, 2023 at 1:57 PM Michael Paquier <michael@paquier.xyz> wrote:

Thanks for the test case, issue reproduced here on HEAD and not v15.
This causes an assertion failure here:
#4 0x000055a6f8faa776 in ExceptionalCondition
(conditionName=0x55a6f915ac60 "bms_equal(rel->relids,
root->all_query_rels)", fileName=0x55a6f915ac3d "allpaths.c",
lineNumber=234) at assert.c:66
#5 0x000055a6f8c55b6d in make_one_rel (root=0x55a6fa814ea8,
joinlist=0x55a6fa83f758) at allpaths.c:234
#6 0x000055a6f8c95c45 in query_planner (root=0x55a6fa814ea8,
qp_callback=0x55a6f8c9c373 <standard_qp_callback>, qp_extra=0x7ffc98138570)
at planmain.c:278
#7 0x000055a6f8c9860a in grouping_planner (root=0x55a6fa814ea8,
tuple_fraction=0) at planner.c:1493

I am adding an open item.

Thanks for testing. I looked into it and figured out that it is the
same issue discussed at the end of this thread:
/messages/by-id/CAMbWs4-EU9uBGSP7G-iTwLBhRQ=rnZKvFDhD+n+xhajokyPCKg@mail.gmail.com

Thanks
Richard

#4Michael Paquier
michael@paquier.xyz
In reply to: Richard Guo (#3)
Re: ERROR: wrong varnullingrels (b 5 7) (expected (b)) for Var 3/3

On Fri, May 19, 2023 at 03:46:26PM +0800, Richard Guo wrote:

Thanks for testing. I looked into it and figured out that it is the
same issue discussed at the end of this thread:
/messages/by-id/CAMbWs4-EU9uBGSP7G-iTwLBhRQ=rnZKvFDhD+n+xhajokyPCKg@mail.gmail.com

OK, thanks for confirming.
--
Michael