Skip to content

Unexpected result when comparing IP #16690

Closed

Description

@suyZhong

CrateDB version

CrateDB 5.9.0-SNAPSHOT built 1064365

CrateDB setup information

Manual build following the instructions here: https://github.com/crate/crate/blob/master/devs/docs/basics.rst

Problem description

Consider the test case below. The third query could be unexpected since if the second query is evaluated to TRUE, which shows that the expression t0.c0 <= '41.119.195.181' is TRUE, thus the third query should return the row in the table. Otherwise the second query is unexpected.

Steps to Reproduce

DROP TABLE IF EXISTS t0;

CREATE  TABLE  t0(c0 IP);
INSERT INTO t0(c0) VALUES ('192.168.0.1');
REFRESH TABLE t0;


SELECT * FROM t0; -- 192.168.0.1
SELECT (t0.c0 <= '41.119.195.181' ) FROM t0; -- TRUE
SELECT * FROM t0 WHERE (t0.c0 <= '41.119.195.181' );
-- Expected: 192.168.0.1
-- Actual: 0 rows


-- original query:
SELECT * FROM t0 WHERE (NOT (t0.c0 BETWEEN CAST(695714741 AS IP) AND t0.c0)) UNION ALL SELECT * FROM t0 WHERE (NOT (NOT (t0.c0 BETWEEN CAST(695714741 AS IP) AND t0.c0))) UNION ALL SELECT * FROM t0 WHERE (((NOT (t0.c0 BETWEEN CAST(695714741 AS IP) AND t0.c0))) IS NULL); -- empty set

Actual Result

As mentioned above.

Expected Result

As mentioned above.

Activity

  1. added
    triageAn issue that needs to be triaged by a maintainer
    on Sep 29, 2024
  2. added
    bugClear identification of incorrect behaviour
    and removed
    triageAn issue that needs to be triaged by a maintainer
    on Sep 30, 2024
  3. self-assigned this
    on Sep 30, 2024
  4. added 3 commits that reference this issue on Sep 30, 2024
    39d3c78
    33c683d
    3532de7
  5. added 2 commits that reference this issue on Sep 30, 2024
    6bd90b8
    77b041d
  6. matriv commented on Oct 1, 2024

    @matriv
    Contributor

    Thanks for reporting this issue @suyZhong ! The fix will be available with the next hotfix release.

  7. added a commit that references this issue on Oct 2, 2024
    b88d0cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugClear identification of incorrect behaviour

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions