Skip to main content

uqa_engine/capabilities/
statement_transactions.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Bind statement validation and failure cleanup to the live transaction stack.
8
9use crate::Engine;
10use uqa_execution::statement::transactions::StatementTransactions;
11use uqa_sql::{ast::TransactionStmt, SQLError};
12
13impl uqa_execution::statement::batch::context::BatchTransactions for Engine {
14    fn begin_simple_query_transaction(&self) -> Result<(), SQLError> {
15        Engine::begin_simple_query_transaction(self)
16    }
17    fn promote_simple_query_transaction(&self) -> Result<(), SQLError> {
18        Engine::promote_simple_query_transaction(self)
19    }
20    fn run_transaction_statement(&self, statement: TransactionStmt) -> Result<(), SQLError> {
21        Engine::run_transaction_statement(self, statement)
22    }
23    fn ensure_transaction_usable(&self) -> Result<(), SQLError> {
24        Engine::ensure_transaction_usable(self)
25    }
26    fn prepare_explicit_statement_snapshot(&self, sets_snapshot: bool) -> Result<(), SQLError> {
27        Engine::prepare_explicit_statement_snapshot(self, sets_snapshot)
28    }
29    fn prepare_explicit_transaction_writer(&self) -> Result<bool, SQLError> {
30        Engine::prepare_explicit_transaction_writer(self)
31    }
32    fn begin_implicit_statement_transaction(&self, read_only: bool) -> Result<(), SQLError> {
33        Engine::begin_implicit_statement_transaction(self, read_only)
34    }
35}
36
37impl StatementTransactions for Engine {
38    fn transaction_depth(&self) -> usize {
39        Engine::transaction_depth(self)
40    }
41    fn commit_resolution_pending(&self) -> bool {
42        self.pending_transaction_completion().is_some()
43    }
44    fn current_transaction_is_read_only(&self) -> bool {
45        Engine::current_transaction_is_read_only(self)
46    }
47    fn mark_transaction_snapshot_set(&self) {
48        Engine::mark_transaction_snapshot_set(self);
49    }
50    fn retain_completed_statement_snapshot(&self) {
51        self.retain_completed_statement_catalog();
52    }
53    fn abort_after_error(&self, error: SQLError) -> SQLError {
54        self.abort_sql_transaction_after_error(error)
55    }
56    fn rollback(&self) -> Result<(), SQLError> {
57        self.run_transaction_statement(TransactionStmt::Rollback)
58    }
59}