From 40e5d58cea73886461475f780732aa35c5d29d2b Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Tue, 7 May 2024 06:45:48 -0300 Subject: [PATCH] Fix RewindAwait branching when cursor is empty Even if we have a page, the cursor can still be empty if there are no records. --- core/btree.rs | 6 +----- core/types.rs | 1 - core/vdbe.rs | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/btree.rs b/core/btree.rs index b360cd0aa..a353e81eb 100644 --- a/core/btree.rs +++ b/core/btree.rs @@ -108,7 +108,7 @@ impl BTreeCursor { impl Cursor for BTreeCursor { fn is_empty(&self) -> bool { - self.page.borrow().is_none() + self.record.borrow().is_none() } fn rewind(&mut self) -> Result> { @@ -147,8 +147,4 @@ impl Cursor for BTreeCursor { fn record(&self) -> Result>> { Ok(self.record.borrow()) } - - fn has_record(&self) -> bool { - self.record.borrow().is_some() - } } diff --git a/core/types.rs b/core/types.rs index 6d712037f..b4d55ca62 100644 --- a/core/types.rs +++ b/core/types.rs @@ -87,5 +87,4 @@ pub trait Cursor { fn wait_for_completion(&mut self) -> Result<()>; fn rowid(&self) -> Result>>; fn record(&self) -> Result>>; - fn has_record(&self) -> bool; } diff --git a/core/vdbe.rs b/core/vdbe.rs index 7c85361f6..1d7524059 100644 --- a/core/vdbe.rs +++ b/core/vdbe.rs @@ -288,7 +288,7 @@ impl Program { } => { let cursor = cursors.get_mut(cursor_id).unwrap(); cursor.wait_for_completion()?; - if cursor.has_record() { + if !cursor.is_empty() { state.pc = *pc_if_next; } else { state.pc += 1;