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
impl Executor
Sourcepub fn install_application_relations(
&self,
) -> Result<ApplicationRelationIdentity>
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.
Sourcepub fn application_relation_identity(
&self,
) -> Result<ApplicationRelationIdentity>
pub fn application_relation_identity( &self, ) -> Result<ApplicationRelationIdentity>
Resolve and validate the durable catalog identity without mutating it.
Sourcepub fn append_audit_event(
&self,
context: &ExecutionContext,
event: AuditEvent,
) -> Result<[u8; 16]>
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.
Sourcepub fn append_outbox_message(&self, message: OutboxMessage) -> Result<[u8; 16]>
pub fn append_outbox_message(&self, message: OutboxMessage) -> Result<[u8; 16]>
Append one typed external side-effect intent to the caller transaction.
Sourcepub fn claim_outbox(
&self,
worker_id: &str,
now: DateTime<Utc>,
lease_duration: Duration,
limit: usize,
max_attempts: u32,
) -> Result<Vec<OutboxClaim>>
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.
Sourcepub fn complete_outbox(
&self,
message_id: [u8; 16],
lease_token: [u8; 16],
completed_at: DateTime<Utc>,
) -> Result<OutboxCompletion>
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.
Sourcepub 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>
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.
Sourcepub fn prune_application_history(
&self,
now: DateTime<Utc>,
policy: ApplicationRetentionPolicy,
) -> Result<ApplicationRetentionOutcome>
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
impl Executor
Sourcepub fn authenticate_principal(
&self,
login: &str,
password: &str,
) -> Result<ObjectId>
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.
Sourcepub fn new(engine: Arc<MVCCEngine>) -> Self
pub fn new(engine: Arc<MVCCEngine>) -> Self
Create a new executor with the given storage engine
Sourcepub fn with_function_registry(
engine: Arc<MVCCEngine>,
function_registry: Arc<FunctionRegistry>,
) -> Self
pub fn with_function_registry( engine: Arc<MVCCEngine>, function_registry: Arc<FunctionRegistry>, ) -> Self
Create a new executor with a custom function registry
Sourcepub fn with_cache_size(engine: Arc<MVCCEngine>, cache_size: usize) -> Self
pub fn with_cache_size(engine: Arc<MVCCEngine>, cache_size: usize) -> Self
Create a new executor with a custom cache size
Sourcepub fn has_active_transaction(&self) -> bool
pub fn has_active_transaction(&self) -> bool
Check if there is an active explicit transaction
Sourcepub fn set_default_isolation_level(&self, level: IsolationLevel)
pub fn set_default_isolation_level(&self, level: IsolationLevel)
Set the default isolation level for new transactions
Sourcepub fn default_isolation_level(&self) -> IsolationLevel
pub fn default_isolation_level(&self) -> IsolationLevel
Return this connection’s default isolation for future transactions.
Sourcepub fn engine(&self) -> &Arc<MVCCEngine> ⓘ
pub fn engine(&self) -> &Arc<MVCCEngine> ⓘ
Get the storage engine
Sourcepub fn function_registry(&self) -> &Arc<FunctionRegistry> ⓘ
pub fn function_registry(&self) -> &Arc<FunctionRegistry> ⓘ
Get the function registry
Sourcepub fn execute(&self, sql: &str) -> Result<ExecutionResult>
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.
Sourcepub fn execute_with_params(
&self,
sql: &str,
params: ParamVec,
) -> Result<ExecutionResult>
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.
Sourcepub fn try_fast_path_with_params(
&self,
sql: &str,
params: &[Value],
) -> Option<Result<ExecutionResult>>
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
Sourcepub fn execute_with_named_params(
&self,
sql: &str,
params: FxHashMap<String, Value>,
) -> Result<ExecutionResult>
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.
Sourcepub fn execute_with_context(
&self,
sql: &str,
ctx: &ExecutionContext,
) -> Result<ExecutionResult>
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.
Sourcepub fn query_cache(&self) -> &QueryCache
pub fn query_cache(&self) -> &QueryCache
Get the query cache
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Get query cache statistics
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the query cache
Sourcepub fn semantic_cache(&self) -> &SemanticCache
pub fn semantic_cache(&self) -> &SemanticCache
Get the semantic cache
Sourcepub fn semantic_cache_stats(&self) -> SemanticCacheStatsSnapshot
pub fn semantic_cache_stats(&self) -> SemanticCacheStatsSnapshot
Get semantic cache statistics
Sourcepub fn clear_semantic_cache(&self)
pub fn clear_semantic_cache(&self)
Clear the semantic cache
Sourcepub fn invalidate_semantic_cache(&self, table_name: &str)
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.
Sourcepub fn execute_program(&self, program: &Program) -> Result<ExecutionResult>
pub fn execute_program(&self, program: &Program) -> Result<ExecutionResult>
Execute a parsed program
Sourcepub fn execute_program_with_context(
&self,
program: &Program,
ctx: &ExecutionContext,
) -> Result<ExecutionResult>
pub fn execute_program_with_context( &self, program: &Program, ctx: &ExecutionContext, ) -> Result<ExecutionResult>
Execute a parsed program with context
Sourcepub fn execute_statement(
&self,
statement: &Statement,
ctx: &ExecutionContext,
) -> Result<ExecutionResult>
pub fn execute_statement( &self, statement: &Statement, ctx: &ExecutionContext, ) -> Result<ExecutionResult>
Execute a single statement
Sourcepub fn begin_transaction(&self) -> Result<Box<dyn Transaction>>
pub fn begin_transaction(&self) -> Result<Box<dyn Transaction>>
Begin a new transaction
Sourcepub fn begin_transaction_with_isolation(
&self,
isolation: IsolationLevel,
) -> Result<Box<dyn Transaction>>
pub fn begin_transaction_with_isolation( &self, isolation: IsolationLevel, ) -> Result<Box<dyn Transaction>>
Begin a new transaction with a specific isolation level
Sourcepub fn get_or_create_plan(&self, sql: &str) -> Result<CachedPlanRef>
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.
Sourcepub fn execute_with_cached_plan(
&self,
plan: &CachedPlanRef,
ctx: &ExecutionContext,
) -> Result<ExecutionResult>
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
impl Executor
Sourcepub fn execute_procedure(
&self,
routine: ObjectId,
arguments: Vec<RuntimeValue>,
context: &ExecutionContext,
principals: PrincipalContext,
results: &mut dyn ProceduralResultStage,
) -> ProceduralResult<ProceduralCallOutcome>
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.
Sourcepub fn execute_procedural_program(
&self,
program: &VerifiedProgram,
arguments: Vec<RuntimeValue>,
context: &ExecutionContext,
principals: PrincipalContext,
policy: ResourcePolicy,
results: &mut dyn ProceduralResultStage,
) -> ProceduralResult<ProceduralCallOutcome>
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.