Skip to main content

Statement

Struct Statement 

Source
pub struct Statement { /* private fields */ }

Implementations§

Source§

impl Statement

Source

pub fn new( program: Program, pager: Arc<Pager>, query_mode: QueryMode, tail_offset: usize, ) -> Self

Source

pub fn tail_offset(&self) -> usize

Source

pub fn get_trigger(&self) -> Option<Arc<Trigger>>

Source

pub fn get_query_mode(&self) -> QueryMode

Source

pub fn get_program(&self) -> &Program

Source

pub fn get_pager(&self) -> &Arc<Pager>

Source

pub fn n_change(&self) -> i64

Source

pub fn n_total_change(&self) -> i64

Source

pub fn set_mv_tx(&mut self, mv_tx: Option<(u64, TransactionMode)>)

Source

pub fn interrupt(&mut self)

Source

pub fn set_query_timeout_override(&mut self, timeout: Option<Option<Duration>>)

Sets a per-execution timeout override for this statement.

  • None: use connection default
  • Some(Some(duration)): use query-specific timeout
  • Some(None): disable timeout for this execution
Source

pub fn execution_state(&self) -> ProgramExecutionState

Source

pub fn metrics(&self) -> StatementMetrics

Statement metrics accumulated across executions of this prepared statement. Includes subprogram work.

Source

pub fn reset_metrics(&mut self)

Source

pub fn stmt_status(&self, counter: StatementStatusCounter) -> u64

Source

pub fn reset_stmt_status(&mut self, counter: StatementStatusCounter)

Source

pub fn mv_store( &self, ) -> impl Deref<Target = Option<Arc<MvStore<MvccClock, DynAllocator>>>>

Source

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.

Source

pub fn step(&mut self) -> Result<StepResult>

Source

pub fn step_with_waker(&mut self, waker: &Waker) -> Result<StepResult>

Source

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.

Source

pub fn run_ignore_rows(&mut self) -> Result<()>

Source

pub fn run_collect_rows(&mut self) -> Result<Vec<Vec<Value>>>

Source

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

Source

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).

Source

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.

Source

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

Source

pub fn num_columns(&self) -> usize

Source

pub fn get_column_name(&self, idx: usize) -> Cow<'_, str>

Source

pub fn get_column_table_name(&self, idx: usize) -> Option<Cow<'_, str>>

Source

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.

See: https://sqlite.org/c3ref/column_decltype.html

Source

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 (or DatabaseOpts::with_custom_types) before they can rely on it.
  • Ok(None) when the statement is in EXPLAIN mode, when idx is out of bounds, when the result column has no schema column behind it AND the affinity machinery returns BLOB (i.e. “no determined affinity”), or when a join/CTE reference can’t be resolved.
  • Ok(Some(info)) otherwise. For a table-column reference, info carries the declared name verbatim; for an expression, declared_name is the inferred-affinity primitive ("INTEGER", "TEXT", "REAL", or "NUMERIC") and kind is Builtin.

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.

Source

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.

Source

pub fn parameters(&self) -> &Parameters

Source

pub fn parameters_count(&self) -> usize

Source

pub fn parameter_index(&self, name: &str) -> Option<NonZero<usize>>

Source

pub fn bind_at(&mut self, index: NonZero<usize>, value: Value) -> Result<()>

Source

pub fn clear_bindings(&mut self)

Source

pub fn reset(&mut self) -> Result<()>

Source

pub fn reset_best_effort(&mut self)

Source

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.

Source

pub fn row(&self) -> Option<&Row>

Source

pub fn get_sql(&self) -> &str

Source

pub fn is_busy(&self) -> bool

Source

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§

Source§

impl Debug for Statement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Statement

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more