oceanbase / oceanbase/miniob

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

Open
#620 2 comments 0 reactions 1 assignee View on GitHub

@zywoote3ture is already working on this.

Since Nov 4, 2025.

bug
Dominant language
C++
Stars
4.4k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.