Skip to main content

pgevolve_core/ir/
mod.rs

1//! In-memory representation of a Postgres schema.
2//!
3//! The IR is the contract between every other component. Both the source-side
4//! parser and the catalog reader produce these types; the differ, dependency
5//! analyzer, and planner consume them.
6
7pub mod canon;
8pub mod catalog;
9pub mod cluster;
10pub mod column;
11pub mod column_type;
12pub mod constraint;
13pub mod default_expr;
14pub mod default_privileges;
15pub mod difference;
16pub mod eq;
17pub mod extension;
18pub mod function;
19pub mod grant;
20pub mod index;
21pub mod partition;
22pub mod policy;
23pub mod publication;
24pub mod reloptions;
25pub mod schema;
26pub mod sequence;
27pub mod subscription;
28pub mod table;
29pub use function::*;
30pub mod procedure;
31pub use procedure::*;
32pub mod trigger;
33pub mod user_type;
34pub use user_type::*;
35pub mod view;
36pub use view::*;
37
38use thiserror::Error;
39
40/// Errors raised when constructing IR values.
41#[derive(Debug, Error)]
42pub enum IrError {
43    /// An identifier did not satisfy validation rules.
44    #[error("invalid identifier: {0}")]
45    InvalidIdentifier(String),
46
47    /// A type definition was not representable in our IR.
48    #[error("invalid column type: {0}")]
49    InvalidColumnType(String),
50
51    /// A required field was missing or empty.
52    #[error("missing required field: {0}")]
53    MissingField(&'static str),
54
55    /// A `PublicationScope::Selective` had no schemas and no tables.
56    #[error("publication {0:?}: empty Selective scope (no tables, no schemas)")]
57    EmptyPublication(crate::identifier::Identifier),
58    /// A `PublishedTable.columns` was `Some(vec![])`.
59    #[error("publication {0:?} table {1:?}: empty column list (use None to publish all columns)")]
60    EmptyColumnList(
61        crate::identifier::Identifier,
62        crate::identifier::QualifiedName,
63    ),
64    /// A `PublishKinds` had all four DML flags false.
65    #[error("publication {0:?}: empty publish bitset (must enable at least one DML kind)")]
66    EmptyPublishBitset(crate::identifier::Identifier),
67    /// A `PublishedTable.columns` contained a duplicate column name.
68    #[error("publication {0:?} table {1:?}: duplicate column {2:?} in column list")]
69    DuplicateColumnInPublication(
70        crate::identifier::Identifier,
71        crate::identifier::QualifiedName,
72        crate::identifier::Identifier,
73    ),
74
75    /// A `Subscription.publications` was empty.
76    #[error("subscription {0:?}: empty publication list (PG requires at least one)")]
77    EmptySubscriptionPublications(crate::identifier::Identifier),
78    /// A `Subscription.connection` was empty or whitespace-only.
79    #[error("subscription {0:?}: empty connection string")]
80    EmptyConnection(crate::identifier::Identifier),
81}