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
impl ExecutionContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty execution context Uses static defaults for empty collections to avoid allocations
Sourcepub fn with_params(params: ParamVec) -> Self
pub fn with_params(params: ParamVec) -> Self
Create an execution context with positional parameters
Sourcepub fn with_named_params(named_params: FxHashMap<String, Value>) -> Self
pub fn with_named_params(named_params: FxHashMap<String, Value>) -> Self
Create an execution context with named parameters
Sourcepub fn get_param(&self, index: usize) -> Option<&Value>
pub fn get_param(&self, index: usize) -> Option<&Value>
Get a positional parameter by index (1-based)
Sourcepub fn get_named_param(&self, name: &str) -> Option<&Value>
pub fn get_named_param(&self, name: &str) -> Option<&Value>
Get a named parameter by name
Sourcepub fn params_arc(&self) -> &CompactArc<ParamVec>
pub fn params_arc(&self) -> &CompactArc<ParamVec>
Get the params Arc for zero-copy sharing. Used by evaluator bridge to avoid cloning params.
Sourcepub fn named_params(&self) -> &FxHashMap<String, Value>
pub fn named_params(&self) -> &FxHashMap<String, Value>
Get all named parameters
Sourcepub fn named_params_arc(&self) -> &Arc<FxHashMap<String, Value>> ⓘ
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.
Sourcepub fn param_count(&self) -> usize
pub fn param_count(&self) -> usize
Get the number of positional parameters
Sourcepub fn set_params(&mut self, params: ParamVec)
pub fn set_params(&mut self, params: ParamVec)
Set positional parameters
Sourcepub fn set_named_param(&mut self, name: impl Into<String>, value: Value)
pub fn set_named_param(&mut self, name: impl Into<String>, value: Value)
Set a named parameter
Sourcepub fn auto_commit(&self) -> bool
pub fn auto_commit(&self) -> bool
Check if auto-commit is enabled
Sourcepub fn set_auto_commit(&mut self, auto_commit: bool)
pub fn set_auto_commit(&mut self, auto_commit: bool)
Set auto-commit mode
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the query has been cancelled
Sourcepub fn cancellation_handle(&self) -> CancellationHandle
pub fn cancellation_handle(&self) -> CancellationHandle
Get a cancellation handle that can be used from another thread
Sourcepub fn current_database(&self) -> Option<&str>
pub fn current_database(&self) -> Option<&str>
Get the current database/schema name
Sourcepub fn set_current_database(&mut self, database: impl Into<String>)
pub fn set_current_database(&mut self, database: impl Into<String>)
Set the current database/schema name
Sourcepub fn get_session_var(&self, name: &str) -> Option<&Value>
pub fn get_session_var(&self, name: &str) -> Option<&Value>
Get a session variable
Sourcepub fn set_session_var(&mut self, name: impl Into<String>, value: Value)
pub fn set_session_var(&mut self, name: impl Into<String>, value: Value)
Set a session variable
Sourcepub fn timeout_ms(&self) -> u64
pub fn timeout_ms(&self) -> u64
Get the query timeout in milliseconds
Sourcepub fn set_timeout_ms(&mut self, timeout_ms: u64)
pub fn set_timeout_ms(&mut self, timeout_ms: u64)
Set the query timeout in milliseconds
Sourcepub fn has_timeout(&self) -> bool
pub fn has_timeout(&self) -> bool
Check if a timeout has been set
Sourcepub fn view_depth(&self) -> usize
pub fn view_depth(&self) -> usize
Get the current view nesting depth
Sourcepub fn with_incremented_view_depth(&self) -> Self
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.
Sourcepub fn with_incremented_query_depth(&self) -> Self
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.
Sourcepub fn outer_row(&self) -> Option<&FxHashMap<CompactArc<str>, Value>>
pub fn outer_row(&self) -> Option<&FxHashMap<CompactArc<str>, Value>>
Get the outer row context for correlated subqueries
Sourcepub fn outer_columns(&self) -> Option<&[String]>
pub fn outer_columns(&self) -> Option<&[String]>
Get the outer row columns for correlated subqueries
Sourcepub fn with_outer_row(
&self,
outer_row: FxHashMap<CompactArc<str>, Value>,
outer_columns: CompactArc<Vec<String>>,
) -> Self
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
Sourcepub fn get_cte(
&self,
name: &str,
) -> Option<&(CompactArc<Vec<String>>, CompactArc<Vec<(i64, Row)>>)>
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
Sourcepub fn get_cte_by_lower(
&self,
name_lower: &str,
) -> Option<&(CompactArc<Vec<String>>, CompactArc<Vec<(i64, Row)>>)>
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.
Sourcepub fn has_cte_by_lower(&self, name_lower: &str) -> bool
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.
Sourcepub fn with_cte_data(
&self,
cte_data: Arc<StringMap<(CompactArc<Vec<String>>, CompactArc<Vec<(i64, Row)>>)>>,
) -> Self
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
Sourcepub fn transaction_id(&self) -> Option<u64>
pub fn transaction_id(&self) -> Option<u64>
Get the current transaction ID
Sourcepub fn set_transaction_id(&mut self, txn_id: u64)
pub fn set_transaction_id(&mut self, txn_id: u64)
Set the transaction ID
Sourcepub fn with_transaction_id(&self, txn_id: u64) -> Self
pub fn with_transaction_id(&self, txn_id: u64) -> Self
Create a new context with a transaction ID
Sourcepub fn check_cancelled(&self) -> Result<()>
pub fn check_cancelled(&self) -> Result<()>
Check for cancellation and return an error if cancelled
Trait Implementations§
Source§impl Clone for ExecutionContext
impl Clone for ExecutionContext
Source§fn clone(&self) -> ExecutionContext
fn clone(&self) -> ExecutionContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExecutionContext
impl Debug for ExecutionContext
Auto Trait Implementations§
impl Freeze for ExecutionContext
impl RefUnwindSafe for ExecutionContext
impl Send for ExecutionContext
impl Sync for ExecutionContext
impl Unpin for ExecutionContext
impl UnwindSafe for ExecutionContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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