Dont assume the rowid is the second column - it's the last

This commit is contained in:
jussisaurio
2024-10-05 17:13:43 +03:00
parent db0e2ea54f
commit d2233d69d3

View File

@@ -166,8 +166,8 @@ impl BTreeCursor {
BTreeCell::IndexLeafCell(IndexLeafCell { payload, .. }) => {
mem_page.advance();
let record = crate::storage::sqlite3_ondisk::read_record(payload)?;
let rowid = match record.values[1] {
OwnedValue::Integer(rowid) => rowid as u64,
let rowid = match record.values.last() {
Some(OwnedValue::Integer(rowid)) => *rowid as u64,
_ => unreachable!("index cells should have an integer rowid"),
};
return Ok(CursorResult::Ok((Some(rowid), Some(record))));