ExecutionContext

Struct ExecutionContext 

Source
pub struct ExecutionContext { /* private fields */ }
Expand description

Execution context for SQL queries

The execution context carries state and configuration for query execution, including parameters, transaction state, and cancellation support.

Note: This struct uses Arc for immutable shared data to make cloning cheap during correlated subquery processing where context is cloned per row.

Implementations§

Source§

impl ExecutionContext

Source

pub fn new() -> Self

Create a new empty execution context Uses static defaults for empty collections to avoid allocations

Source

pub fn with_params(params: ParamVec) -> Self

Create an execution context with positional parameters

Source

pub fn with_named_params(named_params: FxHashMap<String, Value>) -> Self

Create an execution context with named parameters

Source

pub fn get_param(&self, index: usize) -> Option<&Value>

Get a positional parameter by index (1-based)

Source

pub fn get_named_param(&self, name: &str) -> Option<&Value>

Get a named parameter by name

Source

pub fn params(&self) -> &[Value]

Get all positional parameters

Source

pub fn params_arc(&self) -> &CompactArc<ParamVec>

Get the params Arc for zero-copy sharing. Used by evaluator bridge to avoid cloning params.

Source

pub fn named_params(&self) -> &FxHashMap<String, Value>

Get all named parameters

Source

pub fn named_params_arc(&self) -> &Arc<FxHashMap<String, Value>>

Get the named_params Arc for zero-copy sharing. Used by evaluator bridge to avoid cloning params.

Source

pub fn param_count(&self) -> usize

Get the number of positional parameters

Source

pub fn set_params(&mut self, params: ParamVec)

Set positional parameters

Source

pub fn add_param(&mut self, value: Value)

Add a positional parameter

Source

pub fn set_named_param(&mut self, name: impl Into<String>, value: Value)

Set a named parameter

Source

pub fn auto_commit(&self) -> bool

Check if auto-commit is enabled

Source

pub fn set_auto_commit(&mut self, auto_commit: bool)

Set auto-commit mode

Source

pub fn is_cancelled(&self) -> bool

Check if the query has been cancelled

Source

pub fn cancel(&self)

Cancel the query

Source

pub fn cancellation_handle(&self) -> CancellationHandle

Get a cancellation handle that can be used from another thread

Source

pub fn current_database(&self) -> Option<&str>

Get the current database/schema name

Source

pub fn set_current_database(&mut self, database: impl Into<String>)

Set the current database/schema name

Source

pub fn get_session_var(&self, name: &str) -> Option<&Value>

Get a session variable

Source

pub fn set_session_var(&mut self, name: impl Into<String>, value: Value)

Set a session variable

Source

pub fn timeout_ms(&self) -> u64

Get the query timeout in milliseconds

Source

pub fn set_timeout_ms(&mut self, timeout_ms: u64)

Set the query timeout in milliseconds

Source

pub fn has_timeout(&self) -> bool

Check if a timeout has been set

Source

pub fn view_depth(&self) -> usize

Get the current view nesting depth

Source

pub fn with_incremented_view_depth(&self) -> Self

Create a new context with incremented view depth. Used when executing nested views to track recursion depth. Also increments query_depth since views are nested queries.

Source

pub fn with_incremented_query_depth(&self) -> Self

Create a new context with incremented query depth. Used when executing subqueries to ensure TimeoutGuard is only created at the top level.

Source

pub fn outer_row(&self) -> Option<&FxHashMap<CompactArc<str>, Value>>

Get the outer row context for correlated subqueries

Source

pub fn outer_columns(&self) -> Option<&[String]>

Get the outer row columns for correlated subqueries

Source

pub fn with_outer_row( &self, outer_row: FxHashMap<CompactArc<str>, Value>, outer_columns: CompactArc<Vec<String>>, ) -> Self

Create a new context with outer row context for correlated subqueries. The outer_row maps lowercase column names (as CompactArc) to their values. NOTE: This is now cheap to clone due to Arc wrapping of immutable fields.

Source

pub fn get_cte( &self, name: &str, ) -> Option<&(CompactArc<Vec<String>>, CompactArc<Vec<(i64, Row)>>)>

Get CTE data by name (case-insensitive) Returns Arc references to enable zero-copy sharing with joins

Source

pub fn get_cte_by_lower( &self, name_lower: &str, ) -> Option<&(CompactArc<Vec<String>>, CompactArc<Vec<(i64, Row)>>)>

Get CTE data by name that is already lowercase. Use this when the name is known to be lowercase (e.g., from value_lower fields) to avoid redundant to_lowercase() allocation.

Source

pub fn has_cte(&self, name: &str) -> bool

Check if context has CTE data

Source

pub fn has_cte_by_lower(&self, name_lower: &str) -> bool

Check if context has CTE data by name that is already lowercase. Use this when the name is known to be lowercase to avoid allocation.

Source

pub fn with_cte_data( &self, cte_data: Arc<StringMap<(CompactArc<Vec<String>>, CompactArc<Vec<(i64, Row)>>)>>, ) -> Self

Create a new context with CTE data for subqueries to reference Takes an Arc to avoid cloning large CTE datasets

Source

pub fn transaction_id(&self) -> Option<u64>

Get the current transaction ID

Source

pub fn set_transaction_id(&mut self, txn_id: u64)

Set the transaction ID

Source

pub fn with_transaction_id(&self, txn_id: u64) -> Self

Create a new context with a transaction ID

Source

pub fn check_cancelled(&self) -> Result<()>

Check for cancellation and return an error if cancelled

Trait Implementations§

Source§

impl Clone for ExecutionContext

Source§

fn clone(&self) -> ExecutionContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExecutionContext

Source§

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

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

impl Default for ExecutionContext

Source§

fn default() -> Self

Returns the “default value” for a type. 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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