Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction<'db> { /* private fields */ }
Expand description

Explicit transaction over the in-memory graph.

The implementation is conservative: read-only transactions hold a database read lock, and read-write transactions hold the database write lock. Read-write transactions lazily create a cloned staging graph on the first mutating statement, then either swap that graph into place on commit or drop it on rollback. Explicit mutating statements capture a graph + WAL-buffer savepoint so a failed or dropped streaming statement only rolls back its own effects, not the transaction as a whole.

When a WAL is attached, mutation events fire into a tx-local buffer rather than the durable log. The buffer is replayed into the WAL exactly once at commit, so recovery never observes partial / aborted / dropped statements.

Implementations§

Source§

impl<'db> Transaction<'db>

Source

pub fn mode(&self) -> TransactionMode

Transaction mode chosen at begin time.

Source

pub fn execute( &mut self, query: &str, options: Option<ExecuteOptions>, ) -> Result<QueryResult, LoraError>

Execute a query inside the transaction and return a materialized QueryResult.

Source

pub fn execute_with_timeout( &mut self, query: &str, options: Option<ExecuteOptions>, timeout: Duration, ) -> Result<QueryResult, LoraError>

Execute a query inside the transaction with a cooperative deadline.

Source

pub fn execute_with_params( &mut self, query: &str, options: Option<ExecuteOptions>, params: BTreeMap<String, LoraValue>, ) -> Result<QueryResult, LoraError>

Execute a parameterised query inside the transaction.

Source

pub fn execute_with_params_timeout( &mut self, query: &str, options: Option<ExecuteOptions>, params: BTreeMap<String, LoraValue>, timeout: Duration, ) -> Result<QueryResult, LoraError>

Execute a parameterised query inside the transaction with a cooperative deadline.

Source

pub fn execute_rows(&mut self, query: &str) -> Result<Vec<Row>, LoraError>

Execute a query inside the transaction and return hydrated rows before final result-format projection.

Source

pub fn execute_rows_with_params( &mut self, query: &str, params: BTreeMap<String, LoraValue>, ) -> Result<Vec<Row>, LoraError>

Execute a parameterised query inside the transaction and return hydrated rows before final result-format projection.

Source

pub fn explain( &self, query: &str, _params: Option<BTreeMap<String, LoraValue>>, ) -> Result<QueryPlan, LoraError>

Compile query against the transaction’s view of the graph and return the plan that would run. Never executes the query, so running explain on a mutating statement leaves the transaction’s staged graph untouched.

Source

pub fn profile( &mut self, query: &str, params: Option<BTreeMap<String, LoraValue>>, ) -> Result<QueryProfile, LoraError>

Execute query inside the transaction and return the plan plus runtime metrics.

PROFILE executes the query for real. Mutating statements affect the transaction’s staged graph and are persisted at the usual commit point. Use Transaction::explain to inspect a plan without running it.

Source

pub fn stream(&mut self, query: &str) -> Result<QueryStream<'static>, LoraError>

Execute a query inside the transaction and return an owning row stream.

Source

pub fn stream_with_params( &mut self, query: &str, params: BTreeMap<String, LoraValue>, ) -> Result<QueryStream<'static>, LoraError>

Execute a parameterised query inside the transaction and return an owning row stream.

Source

pub fn commit(self) -> Result<(), LoraError>

Commit the transaction and publish staged changes.

When WAL is attached the buffered tx-local mutation log is replayed into the durable WAL as a single committed transaction; recovery therefore observes either every write in this transaction or none.

Source

pub fn rollback(self) -> Result<(), LoraError>

Roll back the transaction. Staged graph changes and buffered mutations are discarded; the WAL is never armed.

Trait Implementations§

Source§

impl Drop for Transaction<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'db> Freeze for Transaction<'db>

§

impl<'db> !RefUnwindSafe for Transaction<'db>

§

impl<'db> !Send for Transaction<'db>

§

impl<'db> Sync for Transaction<'db>

§

impl<'db> Unpin for Transaction<'db>

§

impl<'db> UnsafeUnpin for Transaction<'db>

§

impl<'db> !UnwindSafe for Transaction<'db>

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> 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> 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, 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