fix: index seek wrong

This commit is contained in:
Kould
2025-01-02 11:11:44 +08:00
parent 1bc1f38737
commit e5d0ad044e
2 changed files with 13 additions and 3 deletions

View File

@@ -464,9 +464,15 @@ impl BTreeCursor {
};
let record = crate::storage::sqlite3_ondisk::read_record(payload)?;
let found = match op {
SeekOp::GT => record > *index_key,
SeekOp::GE => record >= *index_key,
SeekOp::EQ => record == *index_key,
SeekOp::GT => {
&record.values[..record.values.len() - 1] > &index_key.values
}
SeekOp::GE => {
&record.values[..record.values.len() - 1] >= &index_key.values
}
SeekOp::EQ => {
&record.values[..record.values.len() - 1] == &index_key.values
}
};
self.stack.advance();
if found {

View File

@@ -318,6 +318,10 @@ do_execsql_test where-age-index-seek-regression-test-2 {
select count(1) from users where age > 0;
} {10000}
do_execsql_test where-age-index-seek-regression-test-3 {
select age from users where age > 90 limit 1;
} {91}
do_execsql_test where-simple-between {
SELECT * FROM products WHERE price BETWEEN 70 AND 100;
} {1|hat|79.0