Fix RewindAwait branching when cursor is empty

Even if we have a page, the cursor can still be empty if there are no
records.
This commit is contained in:
Pekka Enberg
2024-05-07 06:45:48 -03:00
parent 5ebf51ae5a
commit 40e5d58cea
3 changed files with 2 additions and 7 deletions

View File

@@ -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<CursorResult<()>> {
@@ -147,8 +147,4 @@ impl Cursor for BTreeCursor {
fn record(&self) -> Result<Ref<Option<OwnedRecord>>> {
Ok(self.record.borrow())
}
fn has_record(&self) -> bool {
self.record.borrow().is_some()
}
}

View File

@@ -87,5 +87,4 @@ pub trait Cursor {
fn wait_for_completion(&mut self) -> Result<()>;
fn rowid(&self) -> Result<Ref<Option<u64>>>;
fn record(&self) -> Result<Ref<Option<OwnedRecord>>>;
fn has_record(&self) -> bool;
}

View File

@@ -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;