Skip to main content

Session

Struct Session 

Source
pub struct Session<'g> { /* private fields */ }
Expand description

Caller-owned executor session bound to one shared graph.

Implementations§

Source§

impl<'g> Session<'g>

Source

pub const fn new(graph: &'g SharedGraph) -> Self

Create a session without commit-principal bytes.

Source

pub fn with_principal(graph: &'g SharedGraph, principal: Arc<[u8]>) -> Self

Create a session that forwards opaque principal bytes to commits.

Source

pub fn with_cancellation_token(self, token: CancellationToken) -> Self

Attach a cooperative cancellation token to subsequent statements.

Cancellation is cooperative: statements observe the token at executor, built-in-procedure, and algorithm checkpoints. If a statement inside an explicit transaction returns Cancelled, the transaction enters the failed state until ROLLBACK.

Source

pub fn with_deadline(self, deadline: Instant) -> Self

Attach an absolute per-statement deadline to subsequent statements.

The deadline is compared with Instant::now() at the same cooperative checkpoints as cancellation. Expiry returns Timeout; inside an explicit transaction that also marks the transaction failed until ROLLBACK.

Source

pub fn with_max_nodes_scanned(self, max_nodes: usize) -> Self

Attach a deterministic per-statement node-scan budget.

Scan-heavy graph and procedure loops debit this budget at batch boundaries. Exceeding it returns GQLSTATUS 5GQL1 (program-limit-exceeded); inside an explicit transaction that also marks the transaction failed until ROLLBACK.

Source

pub fn with_impl_defined_caps(self, caps: ImplDefinedCaps) -> Self

Set the implementation-defined planning/runtime caps for subsequent statements (ISO IL013/IL015/IL018 limit surfaces — e.g. max_quantifier, set-op / GROUP BY key caps, optimizer-iteration, string/byte-string concat length, path-length, and list-cardinality bounds).

The caps are baked into every plan lowered for this session, so they are honored by both the plan-time variable-length quantifier gate and the runtime/optimizer cap checks. Defaults to ImplDefinedCaps::DEFAULT.

Source

pub fn with_row_cap(self, max_rows: usize) -> Self

Attach an outermost result-row cap to subsequent statements.

The cap is enforced only at the statement output boundary. Intermediate rows produced by scans, joins, FOR, or other pipeline operators do not count against it. Exceeding the cap returns RowCapExceeded; inside an explicit transaction that marks the transaction failed until ROLLBACK.

Source

pub fn with_warning_sink(self, sink: impl WarningSink + 'static) -> Self

Attach an opt-in runtime warning sink to subsequent statements.

Sessions without a sink silently discard warnings. The sink currently receives ISO warning records such as 01G11 for aggregate NULL elimination and 01N01 for relaxed validation-mode writes; see docs/embedding-guide.md for an embedder-side collection example.

Source

pub fn bind_parameter(&mut self, name: DbString, value: Value) -> Option<Value>

Bind or replace a session-local query parameter.

Parameters are named without the leading $ and are resolved by $name references during statement execution. Binding is an upsert: rebinding a name replaces the prior value and affects subsequent statements only. Parameters are session-level metadata, so transaction boundaries and Self::abort preserve the map. Parameters not referenced by a statement are ignored. Session plan-cache keys remain source-only; parameter values and runtime types are checked during each execution.

Runtime positions that require a specific type validate strictly; for example, LIMIT $n accepts only non-negative integer values and returns ExecutorError::InvalidParameterType for mismatches.

If name previously held a table binding, the table is replaced and None is returned. Use Self::bind_table_parameter when callers need table-aware replacement information.

Source

pub fn bind_table_parameter( &mut self, name: DbString, table: BindingTable, ) -> Option<SessionParameterValue>

Bind or replace a session-local query parameter with a binding table.

The table is stored at session scope and materialized into a fresh request-scoped table reference for each statement execution.

Source

pub fn clear_parameter(&mut self, name: &DbString) -> Option<Value>

Remove one session-local query parameter and return its prior scalar value.

If name held a table binding, the table is removed and None is returned.

Source

pub fn clear_parameters(&mut self)

Remove all session-local query parameters.

Source

pub const fn is_closed(&self) -> bool

True when SESSION CLOSE has terminated this session.

Source

pub const fn without_index_selection(self) -> Self

Disable optimizer index selection; all scans fall back to ScanAccess::Linear.

With index selection off, execute_source skips the optimizer entirely and lowers the byte-identical Linear plan (and EXPLAIN output) of pre-optimizer-wiring HEAD. This is the escape hatch for committed perf-baseline reproduction and access-path debugging.

Source

pub const fn with_index_selection(self) -> Self

(Re-)enable optimizer index selection (the default).

When enabled, execute_source builds a snapshot-pinned LiveIndexCatalog per cache-miss statement and runs the optimizer so label / typed / composite index access paths are selected. Linear remains the always-correct fallback inside every rule, so results are byte-identical to the disabled path.

Source

pub fn with_plan_cache(self, capacity: NonZeroUsize) -> Self

Enable this session’s source-string plan cache with the given capacity.

The cache is Session-local and invalidates entries when the backing graph’s schema-version epoch changes.

Source

pub fn with_shared_plan_cache(self, cache: Arc<SharedPlanCache>) -> Self

Enable this session’s shared non-CALL source-string plan cache.

Embedders should pass one shared cache per graph so short-lived sessions can reuse read and write plans across requests. The cache key includes graph ID, schema-version epoch, procedure-registry version, source text, implementation-defined caps, and optimizer index-selection mode.

Source

pub fn with_call_plan_cache(self, cache: Arc<CallPlanCache>) -> Self

Enable this session’s shared procedure-CALL plan cache.

Embedders should pass one shared cache per graph so short-lived sessions can reuse procedure-call plans across requests. The cache key includes the graph ID, schema-version epoch, and procedure-registry version.

Source

pub fn plan_cache_stats(&self) -> Option<PlanCacheStats>

Return this session’s plan-cache counters, if caching is enabled.

Source

pub fn clear_plan_cache(&mut self)

Clear this session’s cached plans without resetting counters.

Source

pub const fn has_active_txn(&self) -> bool

Return true when the session owns an explicit write transaction.

Source

pub const fn is_aborted(&self) -> bool

Return true when the active explicit transaction is aborted.

Source

pub fn start_transaction(&mut self) -> Result<(), ExecutorError>

Open an explicit write transaction.

Subsequent non-control statements executed through this session run inside the transaction until Self::commit_transaction or Self::rollback_transaction closes it.

§Errors

Returns ExecutorError::TransactionAlreadyActive when this session already owns an explicit transaction.

Source

pub fn commit_transaction( &mut self, ) -> Result<TransactionOutcome, ExecutorError>

Commit the open explicit transaction.

§Errors

Returns ExecutorError::NoActiveTransaction when no explicit transaction is open, ExecutorError::InFailedTransaction when the transaction has been aborted by a failed statement, or ExecutorError::GraphMutation when the graph commit is rejected.

Source

pub fn rollback_transaction(&mut self) -> Result<RollbackOutcome, ExecutorError>

Roll back the open explicit transaction.

§Errors

Returns ExecutorError::NoActiveTransaction when no explicit transaction is open.

Source

pub fn flush(&self) -> Result<Option<u64>, ExecutorError>

Flush every commit-critical durable provider registered on this graph.

Returns the highest durable sequence reported by providers, or None when the graph has no durable providers.

§Errors

Returns ExecutorError::Flush when any provider-owned flush fails.

Source

pub fn abort(&mut self)

Roll back and clear the explicit transaction, when one is active.

Source§

impl Session<'_>

Source

pub fn execute_source( &mut self, source: &str, registry: &dyn ProcedureRegistry, ) -> Result<StatementOutput, ExecutorError>

Parse, plan, and execute one source-string statement through this session.

When the session has a plan cache, source strings whose cached plan was prepared against the current graph schema version skip parse, analyze, and plan. Short-lived sessions can additionally use the opt-in shared non-CALL source-plan cache, keyed by graph ID, schema version, registry version, source text, caps, and optimizer mode. Procedure-call-rooted statements use the separate opt-in shared CALL plan cache, keyed by graph ID, schema version, registry version, and formatter-canonical source. Embedded in-pipeline CALL remains uncached. If an active explicit transaction has uncommitted schema changes, both caches bypass lookup and insert so analysis sees transaction-local schema.

Auto Trait Implementations§

§

impl<'g> !Freeze for Session<'g>

§

impl<'g> !RefUnwindSafe for Session<'g>

§

impl<'g> !Send for Session<'g>

§

impl<'g> !Sync for Session<'g>

§

impl<'g> !UnwindSafe for Session<'g>

§

impl<'g> Unpin for Session<'g>

§

impl<'g> UnsafeUnpin for Session<'g>

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
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> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more