Merge 'Cursor cleanups' from Pekka Enberg

Clean up the cursor lookup code in VDBE in preparation for multi-version
cursor support.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1090
This commit is contained in:
Pekka Enberg
2025-03-04 15:38:58 +02:00
2 changed files with 464 additions and 381 deletions

View File

@@ -619,20 +619,15 @@ impl Record {
}
pub enum Cursor {
Table(BTreeCursor),
Index(BTreeCursor),
BTree(BTreeCursor),
Pseudo(PseudoCursor),
Sorter(Sorter),
Virtual(VTabOpaqueCursor),
}
impl Cursor {
pub fn new_table(cursor: BTreeCursor) -> Self {
Self::Table(cursor)
}
pub fn new_index(cursor: BTreeCursor) -> Self {
Self::Index(cursor)
pub fn new_btree(cursor: BTreeCursor) -> Self {
Self::BTree(cursor)
}
pub fn new_pseudo(cursor: PseudoCursor) -> Self {
@@ -643,17 +638,10 @@ impl Cursor {
Self::Sorter(cursor)
}
pub fn as_table_mut(&mut self) -> &mut BTreeCursor {
pub fn as_btree_mut(&mut self) -> &mut BTreeCursor {
match self {
Self::Table(cursor) => cursor,
_ => panic!("Cursor is not a table"),
}
}
pub fn as_index_mut(&mut self) -> &mut BTreeCursor {
match self {
Self::Index(cursor) => cursor,
_ => panic!("Cursor is not an index"),
Self::BTree(cursor) => cursor,
_ => panic!("Cursor is not a btree"),
}
}

File diff suppressed because it is too large Load Diff