Skip to content

Commit 4ad0f6a

Browse files
committed
a little bit of documentation
1 parent e39e60e commit 4ad0f6a

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

core/vdbe/mod.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,37 @@ pub enum TxnCleanup {
275275

276276
#[derive(Debug, Clone, Copy, PartialEq)]
277277
pub enum ProgramExecutionState {
278+
/// No steps of the program was executed
278279
Init,
279-
Run,
280+
/// Program started execution but didn't reach any terminal state
281+
Running,
282+
/// Interrupt requested for the program
280283
Interrupting,
284+
/// Terminal state: program interrupted
281285
Interrupted,
286+
/// Terminal state: program finished successfully
282287
Done,
288+
/// Terminal state: program failed with error
283289
Failed,
284290
}
285291

292+
impl ProgramExecutionState {
293+
pub fn is_running(&self) -> bool {
294+
matches!(
295+
self,
296+
ProgramExecutionState::Interrupting | ProgramExecutionState::Running
297+
)
298+
}
299+
pub fn is_terminal(&self) -> bool {
300+
matches!(
301+
self,
302+
ProgramExecutionState::Interrupted
303+
| ProgramExecutionState::Failed
304+
| ProgramExecutionState::Done
305+
)
306+
}
307+
}
308+
286309
/// The program state describes the environment in which the program executes.
287310
pub struct ProgramState {
288311
pub io_completions: Option<IOCompletions>,
@@ -656,7 +679,7 @@ impl Program {
656679
query_mode: QueryMode,
657680
waker: Option<&Waker>,
658681
) -> Result<StepResult> {
659-
state.execution_state = ProgramExecutionState::Run;
682+
state.execution_state = ProgramExecutionState::Running;
660683
let result = match query_mode {
661684
QueryMode::Normal => self.normal_step(state, mv_store, pager, waker),
662685
QueryMode::Explain => self.explain_step(state, mv_store, pager),

sqlite3/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub unsafe extern "C" fn sqlite3_prepare_v2(
327327

328328
unsafe fn stmt_run_to_completion(stmt: *mut sqlite3_stmt) -> ffi::c_int {
329329
let stmt_ref = &mut *stmt;
330-
while stmt_ref.stmt.execution_state() == ProgramExecutionState::Run {
330+
while stmt_ref.stmt.execution_state().is_running() {
331331
let result = sqlite3_step(stmt);
332332
if result != SQLITE_DONE && result != SQLITE_ROW {
333333
return result;

0 commit comments

Comments
 (0)