Skip to content

Unexpected result when using BETWEEN operator #7428

Closed

Description

@suyZhong

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

To Reproduce

CREATE TABLE t0(c0 INTEGER, c1 BOOL, PRIMARY KEY(c0));
CREATE TABLE t1(c0 INTEGER, PRIMARY KEY(c0));
INSERT INTO t0 (c0) VALUES (0);
INSERT INTO t1 (c0) VALUES (1);
INSERT INTO t1 (c0) VALUES (2);

SELECT t0.c1 FROM t0, t1; -- null, null
SELECT (((true BETWEEN t0.c1 AND t1.c0)) IS NULL) FROM t0, t1; -- true, true
SELECT t0.c1 FROM t0, t1 WHERE (((true BETWEEN t0.c1 AND t1.c0)) IS NULL);
-- Expected: null, null (two rows)
-- Actual: null (one row)

Expected behavior
As mentioned above

Screenshots
N/A

Software versions
Build from source:

root@035e0b00c896:/app# mserver5 --version --dbname=monetdb
MonetDB 5 server 11.50.0 (hg id: 3bb73c2) (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: @897761d12f5d (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

  1. lrpereira commented on Jan 24, 2024

    @lrpereira
    Member

    Fixed in Dec2023 branch.

  2. added this to the NEXTRELEASE milestone on Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions