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;
20pub mod comments;
21mod lifecycle;
22mod privileges;
23pub mod relation_arrays;
24
25pub(crate) use lifecycle::lock_named_type;
26pub use lifecycle::{alter_type_object, relocate_type_object};
27pub use privileges::grant_type;
28
29/// 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.
30pub trait TypeReferenceDependents {
31    fn rewrite_type_references(
32        &self,
33        oid: u32,
34        identity: &RelationIdentity,
35    ) -> Result<(), SQLError>;
36}
37
38pub struct TypeLifecycleContext<'a> {
39    pub comments: &'a dyn crate::catalog::comments::CommentPublication,
40    pub composite_attributes: super::composites::alteration::CompositeAlterationContext<'a>,
41    pub creation: RelationCreationContext<'a>,
42    pub identities: CatalogIdentityReservationContext<'a>,
43    pub writer: &'a dyn SchemaStatementWriter,
44    pub binding: TypeObjectBinding<'a>,
45    pub registries: arrays::UserTypeRegistries<'a>,
46    pub shells: &'a dyn crate::catalog::shell_type::ShellRegistryPublication,
47    pub owner_schemas: &'a dyn RelationOwnerSchemas,
48    pub changes: &'a dyn NamespaceCatalogChanges,
49    pub notices: &'a dyn CatalogNotices,
50    pub dependents: &'a dyn TypeReferenceDependents,
51}