uqa_sql/catalog/dependencies/edge.rs
1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! One `pg_depend` row: a dependent object, the object it references, and how deleting the referenced object treats it.
8
9use super::ObjectAddress;
10
11/// `pg_depend.deptype`.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub enum DependencyKind {
14 /// `n`: dropping the referenced object requires `CASCADE`, which drops the dependent.
15 Normal,
16 /// `a`: the dependent is dropped with the referenced object even without `CASCADE`.
17 Auto,
18 /// `i`: the dependent is part of the referenced object's implementation and can only be dropped with it.
19 Internal,
20 /// `P`: a partition's object depends on its parent's.
21 PartitionPrimary,
22 /// `S`: a partition's object depends on its partition.
23 PartitionSecondary,
24 /// `e`: the dependent is a member of an extension.
25 Extension,
26 /// `x`: the dependent needs an extension and is dropped with it.
27 AutoExtension,
28}
29
30impl DependencyKind {
31 /// The `pg_depend.deptype` letter.
32 #[must_use]
33 pub const fn code(self) -> char {
34 match self {
35 Self::Normal => 'n',
36 Self::Auto => 'a',
37 Self::Internal => 'i',
38 Self::PartitionPrimary => 'P',
39 Self::PartitionSecondary => 'S',
40 Self::Extension => 'e',
41 Self::AutoExtension => 'x',
42 }
43 }
44}
45
46#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
47pub struct Dependency {
48 pub dependent: ObjectAddress,
49 pub referenced: ObjectAddress,
50 pub kind: DependencyKind,
51}