From ae709f04fe73a595bb69cc511b7d66dace2f21b9 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sat, 2 Sep 2023 13:26:44 +0300 Subject: [PATCH] Make some opcodes wait for completion --- core/btree.rs | 13 +++++++++---- core/vdbe.rs | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/btree.rs b/core/btree.rs index e8e38a6d3..6dfcac01a 100644 --- a/core/btree.rs +++ b/core/btree.rs @@ -26,6 +26,10 @@ impl Cursor { } } + pub fn is_empty(&self) -> bool { + self.page.borrow().is_none() + } + pub fn rewind(&mut self) -> Result<()> { self.page .replace(Some(self.pager.read_page(self.root_page)?)); @@ -34,10 +38,6 @@ impl Cursor { Ok(()) } - pub fn is_empty(&self) -> bool { - self.page.borrow().is_none() - } - pub fn next(&mut self) -> Result> { let result = self.record.take(); let next = self.get_next_record()?; @@ -45,6 +45,11 @@ impl Cursor { Ok(result) } + pub fn wait_for_completion(&mut self) -> Result<()> { + // TODO: Wait for pager I/O to complete + Ok(()) + } + pub fn record(&self) -> Result>> { Ok(self.record.borrow()) } diff --git a/core/vdbe.rs b/core/vdbe.rs index ae1a0f57b..8cb5c0bc3 100644 --- a/core/vdbe.rs +++ b/core/vdbe.rs @@ -216,6 +216,7 @@ impl Program { pc_if_empty, } => { let cursor = state.cursors.get_mut(cursor_id).unwrap(); + cursor.wait_for_completion()?; if cursor.is_empty() { state.pc = *pc_if_empty; } else { @@ -256,6 +257,7 @@ impl Program { pc_if_next, } => { let cursor = state.cursors.get_mut(cursor_id).unwrap(); + cursor.wait_for_completion()?; if cursor.has_record() { state.pc = *pc_if_next; } else {