From 0fee588bcabdc19b1b1609f3546ae07788f1fb46 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Tue, 21 Oct 2025 13:40:29 +0200 Subject: [PATCH] core/mvcc/cursor: add record cursor --- core/mvcc/cursor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/mvcc/cursor.rs b/core/mvcc/cursor.rs index b100f0051..f766b2808 100644 --- a/core/mvcc/cursor.rs +++ b/core/mvcc/cursor.rs @@ -28,6 +28,7 @@ pub struct MvccLazyCursor { reusable_immutable_record: RefCell>, _btree_cursor: Box, null_flag: bool, + record_cursor: RefCell, } impl MvccLazyCursor { @@ -52,6 +53,7 @@ impl MvccLazyCursor { reusable_immutable_record: RefCell::new(None), _btree_cursor: btree_cursor, null_flag: false, + record_cursor: RefCell::new(RecordCursor::new()), } pub fn current_row(&self) -> Result> { @@ -111,6 +113,7 @@ impl CursorTrait for MvccLazyCursor { } else { self.current_pos.replace(CursorPosition::BeforeFirst); } + self.invalidate_record(); Ok(IOResult::Done(())) } @@ -216,6 +219,7 @@ impl CursorTrait for MvccLazyCursor { SeekOp::LT => (Bound::Excluded(&rowid), false), SeekOp::LE { eq_only: _ } => (Bound::Included(&rowid), false), }; + self.invalidate_record(); let rowid = self.db.seek_rowid(bound, lower_bound, self.tx_id); if let Some(rowid) = rowid { self.current_pos.replace(CursorPosition::Loaded(rowid)); @@ -263,6 +267,7 @@ impl CursorTrait for MvccLazyCursor { self.current_pos.replace(CursorPosition::BeforeFirst); })?; } + self.invalidate_record(); Ok(IOResult::Done(())) } @@ -272,6 +277,7 @@ impl CursorTrait for MvccLazyCursor { }; let rowid = RowID::new(self.table_id, rowid); self.db.delete(self.tx_id, rowid)?; + self.invalidate_record(); Ok(IOResult::Done(())) } @@ -369,6 +375,7 @@ impl CursorTrait for MvccLazyCursor { .as_mut() .unwrap() .invalidate(); + self.record_cursor.borrow_mut().invalidate(); } fn has_rowid(&self) -> bool { @@ -376,7 +383,7 @@ impl CursorTrait for MvccLazyCursor { } fn record_cursor_mut(&self) -> std::cell::RefMut<'_, crate::types::RecordCursor> { - todo!() + self.record_cursor.borrow_mut() } fn get_pager(&self) -> Arc {