Skip to main content

Executor

Struct Executor 

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

SQL Query Executor

The executor is the main entry point for executing SQL statements. It coordinates between the parser, storage engine, and function registry.

Implementations§

Source§

impl Executor

Source

pub fn install_application_relations( &self, ) -> Result<ApplicationRelationIdentity>

Install both relation contracts in one ordinary transaction.

Existing names are accepted only when owner and ordered schema match exactly. Opening a database never invokes this method implicitly.

Source

pub fn application_relation_identity( &self, ) -> Result<ApplicationRelationIdentity>

Resolve and validate the durable catalog identity without mutating it.

Source

pub fn append_audit_event( &self, context: &ExecutionContext, event: AuditEvent, ) -> Result<[u8; 16]>

Append one immutable audit success record to the caller transaction. Parameter values are never captured implicitly.

Source

pub fn append_outbox_message(&self, message: OutboxMessage) -> Result<[u8; 16]>

Append one typed external side-effect intent to the caller transaction.

Source

pub fn claim_outbox( &self, worker_id: &str, now: DateTime<Utc>, lease_duration: Duration, limit: usize, max_attempts: u32, ) -> Result<Vec<OutboxClaim>>

Atomically claim pending or expired-lease messages for one worker.

The scan and returned batch are both bounded. A conflicting claimant loses at the ordinary MVCC write-claim/commit boundary and receives no unpublished lease records.

Source

pub fn complete_outbox( &self, message_id: [u8; 16], lease_token: [u8; 16], completed_at: DateTime<Utc>, ) -> Result<OutboxCompletion>

Durably mark delivery complete. Repeating the same token is idempotent.

Source

pub fn retry_outbox( &self, message_id: [u8; 16], lease_token: [u8; 16], failed_at: DateTime<Utc>, retry_at: DateTime<Utc>, error: &str, max_attempts: u32, ) -> Result<OutboxRetryDisposition>

Release a failed delivery for retry or move it to the dead-letter state.

Source

pub fn prune_application_history( &self, now: DateTime<Utc>, policy: ApplicationRetentionPolicy, ) -> Result<ApplicationRetentionOutcome>

Delete only expired immutable audit history and terminal outbox rows.

Source§

impl Executor

Source

pub fn authenticate_principal( &self, login: &str, password: &str, ) -> Result<ObjectId>

Resolve and verify a durable catalog Principal for a network session. The returned stable ID is the only identity accepted by later request contexts; credentials never leave this boundary.

Source

pub fn new(engine: Arc<MVCCEngine>) -> Self

Create a new executor with the given storage engine

Source

pub fn with_function_registry( engine: Arc<MVCCEngine>, function_registry: Arc<FunctionRegistry>, ) -> Self

Create a new executor with a custom function registry

Source

pub fn with_cache_size(engine: Arc<MVCCEngine>, cache_size: usize) -> Self

Create a new executor with a custom cache size

Source

pub fn has_active_transaction(&self) -> bool

Check if there is an active explicit transaction

Source

pub fn set_default_isolation_level(&self, level: IsolationLevel)

Set the default isolation level for new transactions

Source

pub fn default_isolation_level(&self) -> IsolationLevel

Return this connection’s default isolation for future transactions.

Source

pub fn engine(&self) -> &Arc<MVCCEngine>

Get the storage engine

Source

pub fn function_registry(&self) -> &Arc<FunctionRegistry>

Get the function registry

Source

pub fn execute(&self, sql: &str) -> Result<ExecutionResult>

Execute a SQL query string

This is the main entry point for executing SQL statements. It parses the query and executes each statement in order. Uses the query cache to avoid re-parsing identical queries.

Source

pub fn execute_with_params( &self, sql: &str, params: ParamVec, ) -> Result<ExecutionResult>

Execute a SQL query with positional parameters

Parameters are substituted for $1, $2, etc. placeholders in the query. Uses the query cache and selects any eligible borrowed-parameter fast path internally, so public facades do not own execution policy.

Source

pub fn try_fast_path_with_params( &self, sql: &str, params: &[Value], ) -> Option<Result<ExecutionResult>>

Try fast path execution with borrowed params slice Returns None if fast path doesn’t apply, Some(result) otherwise

Source

pub fn execute_with_named_params( &self, sql: &str, params: FxHashMap<String, Value>, ) -> Result<ExecutionResult>

Execute a SQL query with named parameters

Parameters are substituted for :name placeholders in the query. Uses the query cache for efficient re-execution of parameterized queries.

Source

pub fn execute_with_context( &self, sql: &str, ctx: &ExecutionContext, ) -> Result<ExecutionResult>

Execute a SQL query with a full execution context Uses the query cache for efficient re-execution.

Source

pub fn query_cache(&self) -> &QueryCache

Get the query cache

Source

pub fn cache_stats(&self) -> CacheStats

Get query cache statistics

Source

pub fn clear_cache(&self)

Clear the query cache

Source

pub fn semantic_cache(&self) -> &SemanticCache

Get the semantic cache

Source

pub fn semantic_cache_stats(&self) -> SemanticCacheStatsSnapshot

Get semantic cache statistics

Source

pub fn clear_semantic_cache(&self)

Clear the semantic cache

Source

pub fn invalidate_semantic_cache(&self, table_name: &str)

Invalidate semantic cache for a specific table

Call this after INSERT, UPDATE, DELETE, or TRUNCATE on a table.

Source

pub fn execute_program(&self, program: &Program) -> Result<ExecutionResult>

Execute a parsed program

Source

pub fn execute_program_with_context( &self, program: &Program, ctx: &ExecutionContext, ) -> Result<ExecutionResult>

Execute a parsed program with context

Source

pub fn execute_statement( &self, statement: &Statement, ctx: &ExecutionContext, ) -> Result<ExecutionResult>

Execute a single statement

Source

pub fn begin_transaction(&self) -> Result<Box<dyn Transaction>>

Begin a new transaction

Source

pub fn begin_transaction_with_isolation( &self, isolation: IsolationLevel, ) -> Result<Box<dyn Transaction>>

Begin a new transaction with a specific isolation level

Source

pub fn get_or_create_plan(&self, sql: &str) -> Result<CachedPlanRef>

Get or create a cached plan for a SQL statement.

Parses the SQL and caches the plan if not already cached. Returns a lightweight CachedPlanRef that can be stored and reused for repeated execution without re-parsing or cache lookup overhead.

Source

pub fn execute_with_cached_plan( &self, plan: &CachedPlanRef, ctx: &ExecutionContext, ) -> Result<ExecutionResult>

Execute a pre-cached plan directly, skipping cache lookup.

This is the fast path for prepared statements: the caller holds a CachedPlanRef obtained from get_or_create_plan() and passes it here on every execution, avoiding normalize + hash + RwLock read per call.

Source§

impl Executor

Source

pub fn execute_procedure( &self, routine: ObjectId, arguments: Vec<RuntimeValue>, context: &ExecutionContext, principals: PrincipalContext, results: &mut dyn ProceduralResultStage, ) -> ProceduralResult<ProceduralCallOutcome>

Resolve and execute one durable Procedure from the transaction-visible catalog generation. Source and typed metadata are verified after the call boundary pins that generation.

Source

pub fn execute_procedural_program( &self, program: &VerifiedProgram, arguments: Vec<RuntimeValue>, context: &ExecutionContext, principals: PrincipalContext, policy: ResourcePolicy, results: &mut dyn ProceduralResultStage, ) -> ProceduralResult<ProceduralCallOutcome>

Execute one verified procedural program as one atomic engine operation.

Source§

impl Executor

Trait Implementations§

Source§

impl AggregationHost for Executor

Source§

impl CteHost for Executor

Source§

impl NavigationHost for Executor

Source§

fn navigation_engine(&self) -> &Arc<MVCCEngine>

Source§

fn navigation_active_transaction(&self) -> &Mutex<Option<ActiveTransaction>>

Source§

fn navigation_execute_select( &self, statement: &SelectStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn navigation_project_rows_with_alias( &self, select_expressions: &[Expression], rows: RowVec, columns: &[String], columns_lower: Option<&[String]>, context: &ExecutionContext, table_alias: Option<&str>, ) -> Result<RowVec>

Source§

fn navigation_source_materialized( &self, plan: &ReferenceExpandPlan, context: &ExecutionContext, )

Source§

impl StatementDispatchHost for Executor

Source§

type NavigationPlan = ReferenceExpandPlan

Source§

fn dispatch_ddl_fence_already_held(&self) -> bool

Source§

fn dispatch_authorize_statement( &self, statement: &Statement, context: &ExecutionContext, ) -> Result<()>

Source§

fn dispatch_bind_navigation( &self, statement: &Statement, ) -> Result<Option<Self::NavigationPlan>>

Source§

fn dispatch_select( &self, statement: &SelectStatement, navigation: Option<&Self::NavigationPlan>, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_call( &self, statement: &CallStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_set( &self, statement: &SetStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_show_tables( &self, statement: &ShowTablesStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_show_views( &self, statement: &ShowViewsStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_show_create_table( &self, statement: &ShowCreateTableStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_show_create_view( &self, statement: &ShowCreateViewStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_show_indexes( &self, statement: &ShowIndexesStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_describe( &self, statement: &DescribeStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_pragma( &self, statement: &PragmaStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_expression( &self, statement: &ExpressionStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_explain( &self, statement: &ExplainStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_analyze( &self, statement: &AnalyzeStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn dispatch_vacuum( &self, statement: &VacuumStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

impl SubqueryHost for Executor

Source§

impl WindowHost for Executor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregationExecutorExt for T
where T: AggregationHost + ?Sized,

Source§

fn execute_select_with_aggregation( &self, statement: &SelectStatement, context: &ExecutionContext, rows: RowVec, columns: &[String], ) -> Result<Box<dyn QueryResult>>

Source§

fn execute_aggregation_for_window( &self, statement: &SelectStatement, context: &ExecutionContext, rows: &[(i64, Row)], columns: &[String], ) -> Result<(Vec<String>, RowVec)>

Source§

fn try_aggregation_pushdown( &self, table: &dyn Table, statement: &SelectStatement, context: &ExecutionContext, classification: &Arc<QueryClassification>, ) -> Result<Option<Box<dyn QueryResult>>>

Source§

fn try_filtered_aggregation_pushdown( &self, table: &dyn Table, statement: &SelectStatement, context: &ExecutionContext, classification: &Arc<QueryClassification>, columns: &[String], ) -> Result<Option<Box<dyn QueryResult>>>

Source§

fn try_streaming_global_aggregation( &self, table: &dyn Table, statement: &SelectStatement, context: &ExecutionContext, classification: &Arc<QueryClassification>, ) -> Result<Option<Box<dyn QueryResult>>>

Source§

fn try_streaming_derived_table_aggregation( &self, source: Box<dyn QueryResult>, statement: &SelectStatement, classification: &Arc<QueryClassification>, context: &ExecutionContext, ) -> Result<DerivedAggregationAttempt>

Source§

fn try_storage_aggregation( &self, table: &dyn Table, statement: &SelectStatement, context: &ExecutionContext, columns: &[String], classification: &QueryClassification, ) -> Option<Box<dyn QueryResult>>

Source§

fn try_fast_count_distinct_compiled( &self, statement: &SelectStatement, compiled: &RwLock<CompiledExecution>, ) -> Option<Result<Box<dyn QueryResult>>>

Source§

fn try_fast_count_star_compiled( &self, statement: &SelectStatement, compiled: &RwLock<CompiledExecution>, ) -> Option<Result<Box<dyn QueryResult>>>

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> CompactArcDrop for T

Source§

unsafe fn drop_and_dealloc(ptr: *mut u8)

Drop the contained data and deallocate the header+data allocation. Read more
Source§

impl<T> CteExecutorExt for T
where T: CteHost + ?Sized,

Source§

fn execute_select_with_ctes( &self, statement: &SelectStatement, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn execute_query_on_cte_result( &self, statement: &SelectStatement, context: &ExecutionContext, columns: Vec<String>, rows: RowVec, ) -> Result<(Vec<String>, RowVec)>

Source§

fn execute_query_on_cte_result_inner( &self, statement: &SelectStatement, context: &ExecutionContext, columns: Vec<String>, rows: RowVec, skip_order_limit: bool, ) -> Result<(Vec<String>, RowVec, bool)>

Source§

fn has_cte(&self, statement: &SelectStatement) -> bool

Source§

fn try_inline_ctes( &self, statement: &SelectStatement, with_clause: &WithClause, ) -> Option<SelectStatement>

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> NavigationExecutorExt for T
where T: NavigationHost + ?Sized,

Source§

fn execute_reference_projection( &self, select: &SelectStatement, plan: &ReferenceExpandPlan, context: &ExecutionContext, ) -> Result<Box<dyn QueryResult>>

Source§

fn execute_reference_projection_with_metrics( &self, select: &SelectStatement, plan: &ReferenceExpandPlan, context: &ExecutionContext, ) -> Result<(Box<dyn QueryResult>, ReferenceExpandMetrics)>

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SubqueryExecutorExt for T
where T: SubqueryHost + ?Sized,

Source§

fn process_where_subqueries( &self, expression: &Expression, context: &ExecutionContext, ) -> Result<Expression>

Source§

fn execute_exists_subquery( &self, statement: &SelectStatement, context: &ExecutionContext, ) -> Result<bool>

Source§

fn try_process_select_subqueries( &self, columns: &[Expression], context: &ExecutionContext, ) -> Result<Option<Vec<Expression>>>

Source§

fn process_correlated_expression( &self, expression: &Expression, context: &ExecutionContext, ) -> Result<Expression>

Source§

fn process_correlated_where( &self, expression: &Expression, context: &ExecutionContext, ) -> Result<Expression>

Source§

fn should_use_index_nested_loop_for_anti_join( &self, info: &SemiJoinInfo, outer_limit: Option<i64>, ) -> bool

Source§

fn execute_semi_join_optimization( &self, info: &SemiJoinInfo, context: &ExecutionContext, ) -> Result<CompactArc<ValueSet>>

Source§

fn execute_anti_join( &self, info: &SemiJoinInfo, outer_rows: CompactArc<Vec<Row>>, outer_columns: &[String], context: &ExecutionContext, ) -> Result<RowVec>

Source§

fn try_optimize_exists_to_semi_join( &self, expression: &Expression, context: &ExecutionContext, outer_tables: &[String], outer_limit: Option<i64>, ) -> Result<Option<Expression>>

Source§

fn try_optimize_in_to_semi_join( &self, expression: &Expression, context: &ExecutionContext, outer_tables: &[String], ) -> Result<Option<Expression>>

Source§

fn has_subqueries(expression: &Expression) -> bool
where Self: Sized,

Source§

fn has_correlated_subqueries(expression: &Expression) -> bool
where Self: Sized,

Source§

fn has_correlated_select_subqueries(columns: &[Expression]) -> bool
where Self: Sized,

Source§

fn is_subquery_correlated(statement: &SelectStatement) -> bool
where Self: Sized,

Source§

fn try_extract_not_exists_info( expression: &Expression, outer_tables: &[String], ) -> Option<SemiJoinInfo>
where Self: Sized,

Source§

fn collect_outer_table_names(table: &Option<Box<Expression>>) -> Vec<String>
where Self: Sized,

Source§

impl<T> TransactionControlExt for T
where T: MutationHost + ?Sized,

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> WindowExecutorExt for T
where T: WindowHost + ?Sized,

Source§

fn execute_select_with_window_functions( &self, stmt: &SelectStatement, ctx: &ExecutionContext, base_rows: &[(i64, Row)], base_columns: &[String], ) -> Result<Box<dyn QueryResult>>

Source§

fn execute_select_with_window_functions_presorted( &self, stmt: &SelectStatement, ctx: &ExecutionContext, base_rows: &[(i64, Row)], base_columns: &[String], pre_sorted: Option<WindowPreSortedState>, ) -> Result<Box<dyn QueryResult>>

Source§

fn execute_select_with_window_functions_pregrouped( &self, stmt: &SelectStatement, ctx: &ExecutionContext, base_rows: &[(i64, Row)], base_columns: &[String], pre_grouped: WindowPreGroupedState, ) -> Result<Box<dyn QueryResult>>

Source§

fn execute_select_with_window_functions_lazy_partition( &self, stmt: &SelectStatement, ctx: &ExecutionContext, table: &dyn Table, base_columns: &[String], partition_col: &str, limit: usize, ) -> Result<Box<dyn QueryResult>>