use std::cmp::Ordering;
pub const RELATION_CLASS: u32 = 1259;
pub const TYPE_CLASS: u32 = 1247;
pub const PROCEDURE_CLASS: u32 = 1255;
pub const CONSTRAINT_CLASS: u32 = 2606;
pub const ATTRIBUTE_DEFAULT_CLASS: u32 = 2604;
pub const REWRITE_CLASS: u32 = 2618;
pub const TRIGGER_CLASS: u32 = 2620;
pub const NAMESPACE_CLASS: u32 = 2615;
pub const LANGUAGE_CLASS: u32 = 2612;
pub const ROLE_CLASS: u32 = 1260;
pub const ROLE_MEMBERSHIP_CLASS: u32 = 1261;
pub const FOREIGN_WRAPPER_CLASS: u32 = 2328;
pub const FOREIGN_SERVER_CLASS: u32 = 1417;
pub const DATABASE_CLASS: u32 = 1262;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ObjectAddress {
pub class_id: u32,
pub object_id: u32,
pub sub_id: i32,
}
impl ObjectAddress {
#[must_use]
pub const fn whole(class_id: u32, object_id: u32) -> Self {
Self {
class_id,
object_id,
sub_id: 0,
}
}
#[must_use]
pub const fn column(relation: u32, column_number: i32) -> Self {
Self {
class_id: RELATION_CLASS,
object_id: relation,
sub_id: column_number,
}
}
#[must_use]
pub const fn whole_object(self) -> Self {
Self::whole(self.class_id, self.object_id)
}
pub(super) const fn same_object(self, other: Self) -> bool {
self.class_id == other.class_id && self.object_id == other.object_id
}
pub(super) fn deletion_order(&self, other: &Self) -> Ordering {
other
.object_id
.cmp(&self.object_id)
.then(self.class_id.cmp(&other.class_id))
.then(
self.sub_id
.cast_unsigned()
.cmp(&other.sub_id.cast_unsigned()),
)
}
}