Skip to content

Commit 7fb87bb

Browse files
committed
fix: special mapping of row ids
1 parent 84106d0 commit 7fb87bb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

core/translate/emitter.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,12 @@ fn try_index_cover(
11661166
let (pos, _) = table.get_column(&index_column.name).unwrap();
11671167
index_column_map.insert(pos, i);
11681168
}
1169-
for pk_name in table.primary_key_column_names.iter() {
1170-
// SAFETY: the primary key column must exist in the table
1171-
let (pos, _) = table.get_column(pk_name).unwrap();
1169+
if table.has_rowid {
1170+
let pos = table
1171+
.columns
1172+
.iter()
1173+
.position(|column| column.is_rowid_alias)
1174+
.unwrap();
11721175
index_column_map.insert(pos, index_column_map.len());
11731176
}
11741177

testing/where.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ do_execsql_test where-age-index-seek-regression-test-2 {
318318
select count(1) from users where age > 0;
319319
} {10000}
320320

321+
do_execsql_test where-age-index-cover-seek {
322+
select id, age from users where age > 90;
323+
} {120|90}
324+
321325
do_execsql_test where-simple-between {
322326
SELECT * FROM products WHERE price BETWEEN 70 AND 100;
323327
} {1|hat|79.0

0 commit comments

Comments
 (0)