Skip to main content

uqa_execution/row_locks/
session.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Transaction-scoped row-lock services consumed by mutation execution.
8
9use super::{LockAcquire, PhysicalRowChangeTarget, RowChangeTarget, RowLockManager};
10use std::sync::Arc;
11use uqa_core::DocId;
12use uqa_sql::{
13    ast::{LockStrength, LockWait},
14    SQLError,
15};
16
17/// Lock acquisition and committed-chain visibility within the caller's transaction.
18pub trait RowLockSession {
19    fn lock_manager(&self) -> Arc<RowLockManager>;
20    fn lock_row(
21        &self,
22        table: &str,
23        doc_id: DocId,
24        strength: LockStrength,
25        wait: LockWait,
26        display_name: &str,
27    ) -> Result<LockAcquire, SQLError>;
28    fn uses_fixed_snapshot(&self) -> bool;
29    fn committed_row_successor(
30        &self,
31        table: &str,
32        doc_id: DocId,
33    ) -> Result<RowChangeTarget, SQLError>;
34    fn committed_physical_row_successor(
35        &self,
36        table: &str,
37        doc_id: DocId,
38    ) -> Result<PhysicalRowChangeTarget, SQLError>;
39    fn table_for_lock_hash(&self, table_hash: u64) -> Result<String, SQLError>;
40}