Skip to content

Unexpected result when using BETWEEN with BOOLEAN values #7455

Description

@suyZhong

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

To Reproduce

DROP TABLE t0 CASCADE;

CREATE TABLE t0(c0 VARCHAR, c1 VARCHAR(500));
CREATE VIEW v0(c0) AS SELECT true FROM t0;
INSERT INTO t0 (c0, c1) VALUES ('', 0);
INSERT INTO t0 (c0) VALUES ('a');
INSERT INTO t0 (c0) VALUES ('b');

SELECT * FROM v0, t0; -- 9 rows
SELECT (t0.c0||true BETWEEN v0.c0 AND v0.c0) FROM v0, t0; -- 3 true, 6 false
SELECT * FROM v0, t0 WHERE (t0.c0||true BETWEEN v0.c0 AND v0.c0); 
-- Expected: 3 rows
-- Actual: 9 rows

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: 2b40c2c) (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: @70bf17df2bbc (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. self-assigned this
    on Feb 10, 2024
  2. added this to the NEXTRELEASE milestone on Feb 10, 2024
  3. njnes commented on Feb 10, 2024

    @njnes
    Contributor

    fixed in Dec2023, sortedness was set incorrectly in the concat operator

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