From e0b099f5ad8eb9af450c420dd7182ae84e428772 Mon Sep 17 00:00:00 2001 From: Diego Reis Date: Tue, 29 Jul 2025 15:02:09 -0300 Subject: [PATCH] refactor: Implement conversion between InsnFunctionStepResult and StepResult --- core/vdbe/execute.rs | 32 ++++++++++++++++++-------------- core/vdbe/mod.rs | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index a9f21431e..d793f7b74 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -123,6 +123,18 @@ pub enum InsnFunctionStepResult { Step, } +impl From for InsnFunctionStepResult { + fn from(value: StepResult) -> Self { + match value { + super::StepResult::Done => Self::Done, + super::StepResult::IO => Self::IO, + super::StepResult::Row => Self::Row, + super::StepResult::Interrupt => Self::Interrupt, + super::StepResult::Busy => Self::Busy, + } + } +} + pub fn op_init( _program: &Program, state: &mut ProgramState, @@ -2035,13 +2047,9 @@ pub fn op_auto_commit( }; let conn = program.connection.clone(); if state.commit_state == CommitState::Committing { - return match program.commit_txn(pager.clone(), state, mv_store, *rollback)? { - super::StepResult::Done => Ok(InsnFunctionStepResult::Done), - super::StepResult::IO => Ok(InsnFunctionStepResult::IO), - super::StepResult::Row => Ok(InsnFunctionStepResult::Row), - super::StepResult::Interrupt => Ok(InsnFunctionStepResult::Interrupt), - super::StepResult::Busy => Ok(InsnFunctionStepResult::Busy), - }; + return program + .commit_txn(pager.clone(), state, mv_store, *rollback) + .map(Into::into); } let schema_did_change = if let TransactionState::Write { schema_did_change } = conn.transaction_state.get() { @@ -2071,13 +2079,9 @@ pub fn op_auto_commit( "cannot commit - no transaction is active".to_string(), )); } - match program.commit_txn(pager.clone(), state, mv_store, *rollback)? { - super::StepResult::Done => Ok(InsnFunctionStepResult::Done), - super::StepResult::IO => Ok(InsnFunctionStepResult::IO), - super::StepResult::Row => Ok(InsnFunctionStepResult::Row), - super::StepResult::Interrupt => Ok(InsnFunctionStepResult::Interrupt), - super::StepResult::Busy => Ok(InsnFunctionStepResult::Busy), - } + program + .commit_txn(pager.clone(), state, mv_store, *rollback) + .map(Into::into) } pub fn op_goto( diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index 600da9ce6..4f15705b5 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -9,7 +9,7 @@ //! The instruction set of the VDBE is similar to SQLite's instruction set, //! but with the exception that bytecodes that perform I/O operations are //! return execution back to the caller instead of blocking. This is because -//! Limbo is designed for applications that need high concurrency such as +//! Turso is designed for applications that need high concurrency such as //! serverless runtimes. In addition, asynchronous I/O makes storage //! disaggregation easier. //!