Skip to content

Unexpected results when matching empty string with indexing disabled #16567

Closed

Description

@suyZhong

CrateDB version

CrateDB 5.9.0-SNAPSHOT built a97d13e

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. It is unexpected that the last query returns an empty result, because the result of the second query is TRUE, which means that the WHERE clause in the last query should be evaluated to TRUE and thus return the row in the table.

Steps to Reproduce

DROP TABLE IF EXISTS t0;

CREATE  TABLE  t0(c0 VARCHAR(500) INDEX OFF, PRIMARY KEY(c0)); -- INDEX OFF is important
INSERT INTO t0(c0) VALUES ('');
REFRESH TABLE t0;

SELECT t0.c0 FROM t0; -- ''
SELECT (t0.c0 LIKE '') FROM t0; -- TRUE
SELECT t0.c0 FROM t0 WHERE (t0.c0 LIKE '');
-- Expected: ''
-- Actual: empty table

Actual Result

empty table

Expected Result

one row

Activity

  1. added
    triageAn issue that needs to be triaged by a maintainer
    on Sep 3, 2024
  2. added
    bugClear identification of incorrect behaviour
    and removed
    triageAn issue that needs to be triaged by a maintainer
    on Sep 4, 2024
  3. matriv commented on Sep 4, 2024

    @matriv
    Contributor

    It also returns 0 rows without defining c0 as PRIMARY KEY.

  4. self-assigned this
    on Sep 4, 2024
  5. added 2 commits that reference this issue on Sep 4, 2024
    e7402bd
    9e7bbe0
  6. added a commit that references this issue on Sep 4, 2024
    409b396
  7. matriv commented on Sep 4, 2024

    @matriv
    Contributor

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

  8. added 2 commits that reference this issue on Sep 4, 2024
    5cdcb06
    fe6a722
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