Title: Index Scan Returns Incorrect Results for Not Equal Operator (<>)
Open
@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
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)
- Create table:
CREATE TABLE id_table(id int); - 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); - Verify query without index:
SELECT * FROM id_table WHERE id <> 1;(returns 2,3,10,6,7,8) - Create index:
CREATE INDEX index_id on id_table(id); - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.