uqa_sql/catalog/dependencies/
address.rs1use std::cmp::Ordering;
10
11pub const RELATION_CLASS: u32 = 1259;
13pub const TYPE_CLASS: u32 = 1247;
15pub const PROCEDURE_CLASS: u32 = 1255;
17pub const CONSTRAINT_CLASS: u32 = 2606;
19pub const ATTRIBUTE_DEFAULT_CLASS: u32 = 2604;
21pub const REWRITE_CLASS: u32 = 2618;
23pub const TRIGGER_CLASS: u32 = 2620;
25pub const NAMESPACE_CLASS: u32 = 2615;
27pub const LANGUAGE_CLASS: u32 = 2612;
29pub const ROLE_CLASS: u32 = 1260;
31pub const ROLE_MEMBERSHIP_CLASS: u32 = 1261;
33pub const FOREIGN_WRAPPER_CLASS: u32 = 2328;
35
36pub const FOREIGN_SERVER_CLASS: u32 = 1417;
38pub const DATABASE_CLASS: u32 = 1262;
40
41#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct ObjectAddress {
44 pub class_id: u32,
45 pub object_id: u32,
46 pub sub_id: i32,
47}
48
49impl ObjectAddress {
50 #[must_use]
51 pub const fn whole(class_id: u32, object_id: u32) -> Self {
52 Self {
53 class_id,
54 object_id,
55 sub_id: 0,
56 }
57 }
58
59 #[must_use]
61 pub const fn column(relation: u32, column_number: i32) -> Self {
62 Self {
63 class_id: RELATION_CLASS,
64 object_id: relation,
65 sub_id: column_number,
66 }
67 }
68
69 #[must_use]
71 pub const fn whole_object(self) -> Self {
72 Self::whole(self.class_id, self.object_id)
73 }
74
75 pub(super) const fn same_object(self, other: Self) -> bool {
76 self.class_id == other.class_id && self.object_id == other.object_id
77 }
78
79 pub(super) fn deletion_order(&self, other: &Self) -> Ordering {
81 other
82 .object_id
83 .cmp(&self.object_id)
84 .then(self.class_id.cmp(&other.class_id))
85 .then(
86 self.sub_id
87 .cast_unsigned()
88 .cmp(&other.sub_id.cast_unsigned()),
89 )
90 }
91}