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 OPCLASS_CLASS: u32 = 2616;
18pub const CONSTRAINT_CLASS: u32 = 2606;
20pub const ATTRIBUTE_DEFAULT_CLASS: u32 = 2604;
22pub const REWRITE_CLASS: u32 = 2618;
24pub const TRIGGER_CLASS: u32 = 2620;
26pub const NAMESPACE_CLASS: u32 = 2615;
28pub const COLLATION_CLASS: u32 = 3456;
30pub const LANGUAGE_CLASS: u32 = 2612;
32pub const EXTENSION_CLASS: u32 = 3079;
34pub const ROLE_CLASS: u32 = 1260;
36pub const ROLE_MEMBERSHIP_CLASS: u32 = 1261;
38pub const FOREIGN_WRAPPER_CLASS: u32 = 2328;
40
41pub const FOREIGN_SERVER_CLASS: u32 = 1417;
43pub const DATABASE_CLASS: u32 = 1262;
45
46#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct ObjectAddress {
49 pub class_id: u32,
50 pub object_id: u32,
51 pub sub_id: i32,
52}
53
54impl ObjectAddress {
55 #[must_use]
56 pub const fn whole(class_id: u32, object_id: u32) -> Self {
57 Self {
58 class_id,
59 object_id,
60 sub_id: 0,
61 }
62 }
63
64 #[must_use]
66 pub const fn column(relation: u32, column_number: i32) -> Self {
67 Self {
68 class_id: RELATION_CLASS,
69 object_id: relation,
70 sub_id: column_number,
71 }
72 }
73
74 #[must_use]
76 pub const fn whole_object(self) -> Self {
77 Self::whole(self.class_id, self.object_id)
78 }
79
80 pub(super) const fn same_object(self, other: Self) -> bool {
81 self.class_id == other.class_id && self.object_id == other.object_id
82 }
83
84 pub(super) fn deletion_order(&self, other: &Self) -> Ordering {
86 other
87 .object_id
88 .cmp(&self.object_id)
89 .then(self.class_id.cmp(&other.class_id))
90 .then(
91 self.sub_id
92 .cast_unsigned()
93 .cmp(&other.sub_id.cast_unsigned()),
94 )
95 }
96}