Skip to main content

SessionHook

Trait SessionHook 

Source
pub trait SessionHook: Send + Sync {
    // Provided methods
    fn on_parse(&self, _ctx: &ParseContext<'_>) -> HookOutcome { ... }
    fn on_analyze(&self, _ctx: &AnalyzeContext<'_>) -> HookOutcome { ... }
    fn on_plan(&self, _ctx: &PlanContext<'_>) -> HookOutcome { ... }
    fn on_execute_start(&self, _ctx: &ExecuteContext<'_>) -> HookOutcome { ... }
    fn on_execute_end(&self, _ctx: &ExecuteContext<'_>, _metrics: &QueryMetrics) { ... }
    fn before_commit(&self, _ctx: &CommitContext<'_>) -> HookOutcome { ... }
    fn after_commit(&self, _ctx: &CommitContext<'_>) { ... }
    fn on_abort(&self, _ctx: &AbortContext<'_>) { ... }
}
Expand description

Session-lifecycle hook plugin.

Every method has a default that does nothing; implementations override only the phases they need. Phased dispatch lets a hook plugin perform audit at on_execute_end without paying parse-time cost, etc.

Provided Methods§

Source

fn on_parse(&self, _ctx: &ParseContext<'_>) -> HookOutcome

Called after the query source is parsed; the hook may reject parse failures or annotate the parse for downstream phases.

Source

fn on_analyze(&self, _ctx: &AnalyzeContext<'_>) -> HookOutcome

Called after semantic analysis. Useful for row-level security predicate injection.

Source

fn on_plan(&self, _ctx: &PlanContext<'_>) -> HookOutcome

Called after logical planning; the hook may rewrite the plan.

Source

fn on_execute_start(&self, _ctx: &ExecuteContext<'_>) -> HookOutcome

Called immediately before physical execution begins.

Source

fn on_execute_end(&self, _ctx: &ExecuteContext<'_>, _metrics: &QueryMetrics)

Called once execution finishes with the collected metrics.

Source

fn before_commit(&self, _ctx: &CommitContext<'_>) -> HookOutcome

Called before commit; may reject the transaction.

Source

fn after_commit(&self, _ctx: &CommitContext<'_>)

Called after a successful commit.

Source

fn on_abort(&self, _ctx: &AbortContext<'_>)

Called when a transaction aborts (by rollback or error).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§