Skip to main content

uqa_execution/schema/
types.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! The lifecycle of user-defined types after creation: rename, schema moves, ownership and `USAGE` privileges of enums and domains, whose generated array types follow them.
8
9use super::namespaces::{
10    relations::RelationCreationContext, NamespaceCatalogChanges, SchemaStatementWriter,
11};
12use crate::catalog::{identity::CatalogIdentityReservationContext, notices::CatalogNotices};
13use uqa_core::RelationIdentity;
14use uqa_sql::{
15    catalog::security::ownership::RelationOwnerSchemas,
16    schema::domains::removal::TypeObjectBinding, SQLError,
17};
18
19pub mod arrays;
20mod lifecycle;
21mod privileges;
22pub mod relation_arrays;
23
24pub(crate) use lifecycle::lock_named_type;
25pub use lifecycle::{alter_type_object, relocate_type_object};
26pub use privileges::grant_type;
27
28/// Stored definitions outside the type registries that embed a user-defined type's catalog name: table and foreign table columns and view output types. A rename or schema move rewrites them in the caller's transaction.
29pub trait TypeReferenceDependents {
30    fn rewrite_type_references(
31        &self,
32        oid: u32,
33        identity: &RelationIdentity,
34    ) -> Result<(), SQLError>;
35}
36
37pub struct TypeLifecycleContext<'a> {
38    pub composite_attributes: super::composites::alteration::CompositeAlterationContext<'a>,
39    pub creation: RelationCreationContext<'a>,
40    pub identities: CatalogIdentityReservationContext<'a>,
41    pub writer: &'a dyn SchemaStatementWriter,
42    pub binding: TypeObjectBinding<'a>,
43    pub registries: arrays::UserTypeRegistries<'a>,
44    pub owner_schemas: &'a dyn RelationOwnerSchemas,
45    pub changes: &'a dyn NamespaceCatalogChanges,
46    pub notices: &'a dyn CatalogNotices,
47    pub dependents: &'a dyn TypeReferenceDependents,
48}