pub struct Statement { /* private fields */ }Implementations§
Source§impl Statement
impl Statement
pub fn new( program: Program, pager: Arc<Pager>, query_mode: QueryMode, tail_offset: usize, ) -> Self
pub fn tail_offset(&self) -> usize
pub fn get_trigger(&self) -> Option<Arc<Trigger>>
pub fn get_query_mode(&self) -> QueryMode
pub fn get_program(&self) -> &Program
pub fn get_pager(&self) -> &Arc<Pager> ⓘ
pub fn n_change(&self) -> i64
pub fn n_total_change(&self) -> i64
pub fn set_mv_tx(&mut self, mv_tx: Option<(u64, TransactionMode)>)
pub fn interrupt(&mut self)
Sourcepub fn set_query_timeout_override(&mut self, timeout: Option<Option<Duration>>)
pub fn set_query_timeout_override(&mut self, timeout: Option<Option<Duration>>)
Sets a per-execution timeout override for this statement.
None: use connection defaultSome(Some(duration)): use query-specific timeoutSome(None): disable timeout for this execution
pub fn execution_state(&self) -> ProgramExecutionState
Sourcepub fn metrics(&self) -> StatementMetrics
pub fn metrics(&self) -> StatementMetrics
Statement metrics accumulated across executions of this prepared statement. Includes subprogram work.
pub fn reset_metrics(&mut self)
pub fn stmt_status(&self, counter: StatementStatusCounter) -> u64
pub fn reset_stmt_status(&mut self, counter: StatementStatusCounter)
pub fn mv_store( &self, ) -> impl Deref<Target = Option<Arc<MvStore<MvccClock, DynAllocator>>>>
Sourcepub fn take_io_completions(&mut self) -> Option<IOCompletions>
pub fn take_io_completions(&mut self) -> Option<IOCompletions>
Take the pending IO completions from this statement. Returns None if no IO is pending. This is used by async state machines that need to yield the completions.
pub fn step(&mut self) -> Result<StepResult>
pub fn step_with_waker(&mut self, waker: &Waker) -> Result<StepResult>
Sourcepub fn step_subprogram(&mut self) -> Result<StepResult>
pub fn step_subprogram(&mut self) -> Result<StepResult>
Fast step for trigger/FK subprograms: skips reprepare checks, timeout arming, busy handler, metrics recording, and schema retry. The parent statement handles all of those concerns.
pub fn run_ignore_rows(&mut self) -> Result<()>
pub fn run_collect_rows(&mut self) -> Result<Vec<Vec<Value>>>
Sourcepub fn run_with_row_callback(
&mut self,
func: impl FnMut(&Row) -> Result<()>,
) -> Result<()>
pub fn run_with_row_callback( &mut self, func: impl FnMut(&Row) -> Result<()>, ) -> Result<()>
Blocks execution, advances IO, and runs to completion of the statement
Sourcepub fn run_ignore_rows_nonblock(&mut self) -> Result<IOResult<()>>
pub fn run_ignore_rows_nonblock(&mut self) -> Result<IOResult<()>>
Non-blocking counterpart of Self::run_ignore_rows: drives the
statement to completion, ignoring rows, but instead of pumping IO
synchronously it yields the pending completion to the caller. Re-invoke
after the yielded completion finishes; the program resumes at the same
pc. Rows are discarded.
Used by engine-internal callers that must stay non-blocking (MVCC
bootstrap/recovery) so they don’t call io.step() on backends that have
no synchronous IO pump (e.g. WASM).
Sourcepub fn run_with_row_callback_nonblock(
&mut self,
func: impl FnMut(&Row) -> Result<()>,
) -> Result<IOResult<()>>
pub fn run_with_row_callback_nonblock( &mut self, func: impl FnMut(&Row) -> Result<()>, ) -> Result<IOResult<()>>
Non-blocking counterpart of Self::run_with_row_callback: drives the
statement to completion, invoking func once per emitted row, but
yields the pending completion to the caller instead of pumping IO
synchronously.
Re-entrancy: on an IO yield the program is paused mid-opcode (never
between emitting a row and this loop observing it), so on re-invocation
stepping resumes without replaying the last row — every row’s func
runs exactly once. Because the runner restarts from the top on each
re-entry, func must append to caller-owned state that persists across
yields (e.g. a field in the driving state machine), not to a local.
Sourcepub fn run_one_step_blocking(
&mut self,
pre_io_func: impl FnMut() -> Result<()>,
post_io_func: impl FnMut() -> Result<()>,
) -> Result<Option<&Row>>
pub fn run_one_step_blocking( &mut self, pre_io_func: impl FnMut() -> Result<()>, post_io_func: impl FnMut() -> Result<()>, ) -> Result<Option<&Row>>
Blocks execution, advances IO, and stops at any StepResult except IO You can optionally pass a handler to run after IO is advanced
pub fn num_columns(&self) -> usize
pub fn get_column_name(&self, idx: usize) -> Cow<'_, str>
pub fn get_column_table_name(&self, idx: usize) -> Option<Cow<'_, str>>
Sourcepub fn get_column_decltype(&self, idx: usize) -> Option<String>
pub fn get_column_decltype(&self, idx: usize) -> Option<String>
Returns the declared type of a result column.
This behaves similarly to SQLite’s sqlite3_column_decltype():
If the Nth column of the returned result set of a SELECT is a table column
(not an expression or subquery) then the declared type of the table column
is returned. If the Nth column of the result set is an expression or subquery,
then None is returned. The returned string is always UTF-8 encoded.
Sourcepub fn get_column_type_info(&self, idx: usize) -> Result<Option<ColumnTypeInfo>>
pub fn get_column_type_info(&self, idx: usize) -> Result<Option<ColumnTypeInfo>>
Returns rich type information for a result column.
This is Turso’s single entry point for “what is the type of this column?” — covering both direct table-column references (where the schema carries declared name, array depth, custom-type kind, and the resolved primitive) and computed expressions (where the SQLite- style affinity machinery infers a primitive type from the expression shape). One call, one shape, regardless of which path applies.
§Return value
Err(_)when this connection does not have the experimental custom-types feature enabled. This API is the public surface of the custom-types system; callers must opt in by enabling--experimental-custom-types(orDatabaseOpts::with_custom_types) before they can rely on it.Ok(None)when the statement is in EXPLAIN mode, whenidxis out of bounds, when the result column has no schema column behind it AND the affinity machinery returnsBLOB(i.e. “no determined affinity”), or when a join/CTE reference can’t be resolved.Ok(Some(info))otherwise. For a table-column reference,infocarries the declared name verbatim; for an expression,declared_nameis the inferred-affinity primitive ("INTEGER","TEXT","REAL", or"NUMERIC") andkindisBuiltin.
This is a Turso-specific API; it has no sqlite3_* counterpart. The
returned struct is #[non_exhaustive] so additional metadata can be
added over time without breaking callers.
Sourcepub fn get_column_type_name(&self, idx: usize) -> Option<String>
pub fn get_column_type_name(&self, idx: usize) -> Option<String>
Returns the type affinity name of a result column (e.g., “INTEGER”, “TEXT”, “REAL”, “BLOB”, “NUMERIC”).
Unlike get_column_decltype which returns the original declared type string,
this method returns the normalized SQLite type affinity name.
pub fn parameters(&self) -> &Parameters
pub fn parameters_count(&self) -> usize
pub fn parameter_index(&self, name: &str) -> Option<NonZero<usize>>
pub fn bind_at(&mut self, index: NonZero<usize>, value: Value) -> Result<()>
pub fn clear_bindings(&mut self)
pub fn reset(&mut self) -> Result<()>
pub fn reset_best_effort(&mut self)
Sourcepub fn reset_for_subprogram_reuse(&mut self)
pub fn reset_for_subprogram_reuse(&mut self)
Lightweight reset for reusing a cached subprogram statement. Skips transaction handling and abort(): the caller (op_program) has already handled trigger execution tracking. Only resets ProgramState fields so the subprogram can run again from the beginning.
pub fn row(&self) -> Option<&Row>
pub fn get_sql(&self) -> &str
pub fn is_busy(&self) -> bool
Sourcepub fn _io(&self) -> &dyn IO
pub fn _io(&self) -> &dyn IO
Internal method to get IO from a statement. Used by select internal crate
Avoid using this method for advancing IO while iteration over step.
Prefer to use helper methods instead such as Self::run_with_row_callback
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Statement
impl !RefUnwindSafe for Statement
impl !UnwindSafe for Statement
impl Send for Statement
impl Sync for Statement
impl Unpin for Statement
impl UnsafeUnpin for Statement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more