Skip to main content

Catalog

Struct Catalog 

Source
pub struct Catalog {
Show 20 fields pub scope: CatalogScope, pub schemas: Vec<Schema>, pub tables: Vec<Table>, pub views: Vec<View>, pub types: Vec<CustomType>, pub domains: Vec<Domain>, pub collations: Vec<Collation>, pub functions: Vec<Function>, pub aggregates: Vec<Aggregate>, pub operators: Vec<Operator>, pub casts: Vec<Cast>, pub sequences: Vec<Sequence>, pub indexes: Vec<Index>, pub constraints: Vec<Constraint>, pub triggers: Vec<Trigger>, pub policies: Vec<Policy>, pub extensions: Vec<Extension>, pub grants: Vec<Grant>, pub forward_deps: BTreeMap<DbObjectId, Vec<DbObjectId>>, pub reverse_deps: BTreeMap<DbObjectId, Vec<DbObjectId>>,
}

Fields§

§scope: CatalogScope

Which world this catalog describes. Set by whatever produced it; see CatalogScope.

§schemas: Vec<Schema>§tables: Vec<Table>§views: Vec<View>§types: Vec<CustomType>§domains: Vec<Domain>§collations: Vec<Collation>§functions: Vec<Function>§aggregates: Vec<Aggregate>§operators: Vec<Operator>§casts: Vec<Cast>§sequences: Vec<Sequence>§indexes: Vec<Index>§constraints: Vec<Constraint>§triggers: Vec<Trigger>§policies: Vec<Policy>§extensions: Vec<Extension>§grants: Vec<Grant>§forward_deps: BTreeMap<DbObjectId, Vec<DbObjectId>>§reverse_deps: BTreeMap<DbObjectId, Vec<DbObjectId>>

Implementations§

Source§

impl Catalog

Source

pub async fn load_managed(pool: &PgPool, filter: &ObjectFilter) -> Result<Self>

Load only the objects pgmt manages: the physical catalog scoped by the objects config. This is what diff/render/validate consumers should use — comparing or rendering an unfiltered catalog leaks image-provided substrate (the shadow branch legitimately contains it).

Source

pub async fn load_unfiltered(pool: &PgPool) -> Result<Self>

Load the raw physical catalog, including objects outside pgmt’s managed universe. Only for callers that genuinely need the physical world (substrate detection, init import before scoping is decided) or that provably filter downstream.

Source

pub async fn load_with_file_dependencies( pool: &PgPool, file_augmentation: Option<&FileDependencyAugmentation>, ) -> Result<Self>

Load catalog with optional file-based dependency augmentation

Source

pub fn with_file_dependencies_augmented( self, augmentation: FileDependencyAugmentation, ) -> Self

Create a new catalog with file-based dependencies augmented

Source

pub fn find_view(&self, schema: &str, name: &str) -> Option<&View>

Source

pub fn find_table(&self, schema: &str, name: &str) -> Option<&Table>

Source

pub fn find_policy( &self, schema: &str, table: &str, name: &str, ) -> Option<&Policy>

Source

pub fn find_constraint( &self, schema: &str, table: &str, name: &str, ) -> Option<&Constraint>

Source

pub fn find_function( &self, schema: &str, name: &str, arguments: &str, ) -> Option<&Function>

Source

pub fn find_function_by_signature( &self, reference: &Function, ) -> Option<&Function>

Find a function by signature (schema, name, and parameter types). Unlike find_function, this ignores parameter names and only matches on types. This is needed because PostgreSQL considers functions with the same parameter types but different parameter names to be the same function.

Source

pub fn find_custom_type(&self, schema: &str, name: &str) -> Option<&CustomType>

Source

pub fn find_trigger( &self, schema: &str, table: &str, name: &str, ) -> Option<&Trigger>

Source

pub fn find_index(&self, schema: &str, name: &str) -> Option<&Index>

Source

pub fn find_domain(&self, schema: &str, name: &str) -> Option<&Domain>

Source

pub fn find_collation(&self, schema: &str, name: &str) -> Option<&Collation>

Source

pub fn find_sequence(&self, schema: &str, name: &str) -> Option<&Sequence>

Source

pub fn find_aggregate( &self, schema: &str, name: &str, arguments: &str, ) -> Option<&Aggregate>

Source

pub fn find_operator( &self, schema: &str, name: &str, arguments: &str, ) -> Option<&Operator>

Source

pub fn find_cast(&self, source: &str, target: &str) -> Option<&Cast>

Source

pub fn attached_objects(&self) -> Vec<&dyn Attached>

Every object that carries attached state (comments). Enumerated in ONE place via an exhaustive destructure: adding a field to Catalog fails to compile here until you decide whether the new object type is Attached.

Source

pub fn synthesize_drop_create( &self, id: &DbObjectId, new_catalog: &Catalog, ) -> Option<Vec<MigrationStep>>

Synthesize DROP + CREATE steps for cascading a dependent object.

Returns None if the object type doesn’t support cascading or doesn’t exist in both catalogs. Only the structural DROP/CREATE (and comments) are emitted here — the object’s ACL is reapplied centrally for every recreated object by crate::diff::cascade::reapply_acl_for_recreated_objects, since a DROP discards all privileges regardless of what triggered the recreate.

Source

pub fn empty() -> Self

Create an empty catalog for baseline generation

Source

pub fn contains_id(&self, id: &DbObjectId) -> bool

Check if the catalog contains an object with the given ID

Source

pub fn object_ids(&self) -> HashSet<DbObjectId>

The identity of every object the catalog stores.

Self::contains_id answers one containment question by scanning the matching vector, so a caller asking it once per element of another collection is quadratic. Such a caller builds this set once and asks Self::id_present_in instead.

Sub-object ids (comments, columns) are NOT members: they have no stored object of their own and resolve through their parent, which is id_present_in’s job.

Source

pub fn id_present_in(ids: &HashSet<DbObjectId>, id: &DbObjectId) -> bool

Self::contains_id’s verdict, answered against a set from Self::object_ids.

The two MUST agree for every id — sub-object resolution is spelled out in both places (a comment is present iff its target is; a column iff its table is), and test_id_present_in_agrees_with_contains_id pins that.

Trait Implementations§

Source§

impl Clone for Catalog

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Catalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more