Skip to main content

uqa_execution/row_locks/
shared_objects.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Typed shared-catalog addresses use the existing transaction lock lifecycle.
8
9use super::{RelationLockMode, ScopedRelationLock};
10use uqa_sql::SQLError;
11
12#[derive(Clone, Copy, Debug)]
13pub enum SharedCatalogLock<'a> {
14    Object {
15        class_id: u32,
16        oid: u32,
17    },
18    Name {
19        class_id: u32,
20        name: &'a str,
21    },
22    MemberName {
23        class_id: u32,
24        owner_class_id: u32,
25        owner_object_id: [u8; 16],
26        name: &'a str,
27    },
28    Tuple {
29        class_id: u32,
30        oid: u32,
31    },
32}
33
34pub trait SharedObjectLockSession {
35    fn acquire_shared_catalog(
36        &self,
37        target: SharedCatalogLock<'_>,
38        mode: RelationLockMode,
39    ) -> Result<ScopedRelationLock<'_>, SQLError>;
40    fn refresh_shared_catalog(&self) -> Result<(), SQLError>;
41    /// The next OID of the database's counter, as [`crate::catalog::identity::CatalogOidCounter::next_oid`] advances it.
42    fn next_catalog_oid(&self) -> Result<u32, SQLError>;
43}
44
45#[cfg(test)]
46mod tests;