Skip to content

Title: Index Scan Returns Incorrect Results for Not Equal Operator (<>) #620

Description

@haomingbai

output.txt

Describe the bug
When using indexes with the not equal operator (<>), the query returns incorrect results. After creating an index, SELECT * FROM id_table WHERE id <> 1 returns empty results instead of all rows where id is not equal to 1.

Fast Reproduce Steps(Required)

  1. Create table: CREATE TABLE id_table(id int);
  2. Insert test data:
    INSERT INTO id_table VALUES (1);
    INSERT INTO id_table VALUES (2);
    INSERT INTO id_table VALUES (3);
    INSERT INTO id_table VALUES (10);
    INSERT INTO id_table VALUES (6);
    INSERT INTO id_table VALUES (7);
    INSERT INTO id_table VALUES (8);
  3. Verify query without index: SELECT * FROM id_table WHERE id <> 1; (returns 2,3,10,6,7,8)
  4. Create index: CREATE INDEX index_id on id_table(id);
  5. Execute same query with index: SELECT * FROM id_table WHERE id <> 1; (incorrectly returns empty)

Expected behavior
The query should either:

  • Return the correct results (2,3,10,6,7,8) when using the index, OR
  • Return FAILURE if the not equal operator with indexes is not implemented

Actual Behavior
The query returns empty results but shows SUCCESS, indicating incorrect data is returned without proper error indication.

Additional context

  • Equality queries (id = 1) and range queries (id > 1) work correctly with indexes
  • The issue is specific to the not equal operator (<>) when indexes are used
  • The system incorrectly handles index scanning for non-equality conditions

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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions