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>
impl<'db> Transaction<'db>
Sourcepub fn mode(&self) -> TransactionMode
pub fn mode(&self) -> TransactionMode
Transaction mode chosen at begin time.
Sourcepub fn execute(
&mut self,
query: &str,
options: Option<ExecuteOptions>,
) -> Result<QueryResult>
pub fn execute( &mut self, query: &str, options: Option<ExecuteOptions>, ) -> Result<QueryResult>
Execute a query inside the transaction and return a materialized
QueryResult.
Sourcepub fn execute_with_timeout(
&mut self,
query: &str,
options: Option<ExecuteOptions>,
timeout: Duration,
) -> Result<QueryResult>
pub fn execute_with_timeout( &mut self, query: &str, options: Option<ExecuteOptions>, timeout: Duration, ) -> Result<QueryResult>
Execute a query inside the transaction with a cooperative deadline.
Sourcepub fn execute_with_params(
&mut self,
query: &str,
options: Option<ExecuteOptions>,
params: BTreeMap<String, LoraValue>,
) -> Result<QueryResult>
pub fn execute_with_params( &mut self, query: &str, options: Option<ExecuteOptions>, params: BTreeMap<String, LoraValue>, ) -> Result<QueryResult>
Execute a parameterised query inside the transaction.
Sourcepub fn execute_with_params_timeout(
&mut self,
query: &str,
options: Option<ExecuteOptions>,
params: BTreeMap<String, LoraValue>,
timeout: Duration,
) -> Result<QueryResult>
pub fn execute_with_params_timeout( &mut self, query: &str, options: Option<ExecuteOptions>, params: BTreeMap<String, LoraValue>, timeout: Duration, ) -> Result<QueryResult>
Execute a parameterised query inside the transaction with a cooperative deadline.
Sourcepub fn execute_rows(&mut self, query: &str) -> Result<Vec<Row>>
pub fn execute_rows(&mut self, query: &str) -> Result<Vec<Row>>
Execute a query inside the transaction and return hydrated rows before final result-format projection.
Sourcepub fn execute_rows_with_params(
&mut self,
query: &str,
params: BTreeMap<String, LoraValue>,
) -> Result<Vec<Row>>
pub fn execute_rows_with_params( &mut self, query: &str, params: BTreeMap<String, LoraValue>, ) -> Result<Vec<Row>>
Execute a parameterised query inside the transaction and return hydrated rows before final result-format projection.
Sourcepub fn stream(&mut self, query: &str) -> Result<QueryStream<'static>>
pub fn stream(&mut self, query: &str) -> Result<QueryStream<'static>>
Execute a query inside the transaction and return an owning row stream.
Sourcepub fn stream_with_params(
&mut self,
query: &str,
params: BTreeMap<String, LoraValue>,
) -> Result<QueryStream<'static>>
pub fn stream_with_params( &mut self, query: &str, params: BTreeMap<String, LoraValue>, ) -> Result<QueryStream<'static>>
Execute a parameterised query inside the transaction and return an owning row stream.