uqa_sql/ast/referenced_partition.rs
1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! The constraints `PostgreSQL` derives from a foreign key on the partitions of the partitioned table it references.
8
9use serde::{Deserialize, Serialize};
10
11use super::ConstraintCatalogIdentity;
12
13/// The constraint `PostgreSQL` derives from a foreign key on one partition of the partitioned table it references, whose `pg_constraint.conparentid` names the constraint it derives from. It names the partition's share of the referenced rows in `pg_constraint`, in errors about those rows and in `DETACH PARTITION`, and keeps the name chosen when the partition joined the referenced table, whatever later happens to the name of the foreign key.
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
15pub struct ReferencedPartitionConstraint {
16 /// Object identity of the referenced partition.
17 pub partition: [u8; 16],
18 /// Object identity of the partitioned partition whose derived constraint this one derives from, or `None` when it derives from the foreign key itself, which references the partition's parent.
19 #[serde(default, skip_serializing_if = "Option::is_none")]
20 pub parent: Option<[u8; 16]>,
21 pub name: String,
22 pub catalog_identity: ConstraintCatalogIdentity,
23 /// Whether the referenced partition's share of the referencing rows is known to hold. It follows the foreign key, except that `VALIDATE CONSTRAINT` of an unvalidated foreign key's derived constraint validates that constraint and the ones deriving from it alone.
24 pub validated: bool,
25}