Skip to main content

uqa_engine/transactions/
lock_execution.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Bind execution lock requests to the active engine transaction.
8
9use crate::Engine;
10use std::sync::Arc;
11use uqa_core::DocId;
12use uqa_execution::row_locks::{
13    session::RowLockSession, LockAcquire, PhysicalRowChangeTarget, RowChangeTarget, RowLockManager,
14};
15use uqa_sql::{
16    ast::{LockStrength, LockWait},
17    SQLError,
18};
19
20impl RowLockSession for Engine {
21    fn lock_manager(&self) -> Arc<RowLockManager> {
22        self.row_lock_manager()
23    }
24    fn lock_row(
25        &self,
26        table: &str,
27        doc_id: DocId,
28        strength: LockStrength,
29        wait: LockWait,
30        display_name: &str,
31    ) -> Result<LockAcquire, SQLError> {
32        Engine::lock_row(self, table, doc_id, strength, wait, display_name)
33    }
34    fn uses_fixed_snapshot(&self) -> bool {
35        self.current_transaction_uses_fixed_snapshot()
36    }
37    fn committed_row_successor(
38        &self,
39        table: &str,
40        doc_id: DocId,
41    ) -> Result<RowChangeTarget, SQLError> {
42        Engine::committed_row_successor(self, table, doc_id)
43    }
44    fn committed_physical_row_successor(
45        &self,
46        table: &str,
47        doc_id: DocId,
48    ) -> Result<PhysicalRowChangeTarget, SQLError> {
49        Engine::committed_physical_row_successor(self, table, doc_id)
50    }
51    fn table_for_lock_hash(&self, table_hash: u64) -> Result<String, SQLError> {
52        self.row_lock_table_for_hash(table_hash)
53    }
54}