Skip to content

Unexpected result when using BETWEEN in INNER JOIN #7447

Description

@suyZhong

Describe the bug
Consider the test cases below. It is unexpected that the third query returns empty table, since the second query returns true, which means that the WHERE clause in the third query should be evaluated to true and thus return the in the table after join.

To Reproduce

DROP TABLE t0 CASCADE;
DROP TABLE t1 CASCADE;

CREATE TABLE t0(c0 INTEGER, c1 BOOLEAN, PRIMARY KEY(c0));
CREATE TABLE t1(c1 INTEGER);
INSERT INTO t1 (c1) VALUES (null);
INSERT INTO t0 (c0, c1) VALUES (-1, false);


SELECT t0.c0 FROM t0 INNER  JOIN t1 ON (t0.c1 NOT BETWEEN t1.c1 AND t0.c0); -- -1
SELECT (t1.c1>1) IS NULL FROM t0 INNER  JOIN t1 ON (t0.c1 NOT BETWEEN t1.c1 AND t0.c0); -- true
SELECT t0.c0 FROM t0 INNER  JOIN t1 ON (t0.c1 NOT BETWEEN t1.c1 AND t0.c0) WHERE (t1.c1>1) IS NULL;
-- expected: -1
-- actual: empty table

Expected behavior
As mentioned above

Screenshots
N/A

Software versions
Build from source:

> docker exec monetdb-test mserver5 --version --dbname=monetdb
MonetDB 5 server 11.50.0 (hg id: 25da4f1) (64-bit, 128-bit integers)
This is an unreleased version
Copyright (c) 1993 - July 2008 CWI
Copyright (c) August 2008 - 2023 MonetDB B.V., all rights reserved
Visit https://www.monetdb.org/ for further information
Found 503.5GiB available memory, 128 available cpu cores
Libraries:
Compiled by: @08cc21708292 (x86_64-pc-linux-gnu)
Compilation: /usr/bin/cc 
Linking    : /usr/bin/ld

Issue labeling
Bug

Additional context
Add any other context about the problem here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions