Skip to main content

Module referenced_partitions

Module referenced_partitions 

Source
Expand description

The constraints a foreign key derives on the partitions of the partitioned table it references, named and identified as PostgreSQL’s addFkRecurseReferenced and CloneFkReferenced create them and removed as DetachPartitionFinalize and AttachPartitionForeignKey remove them.

Structs§

FiringConstraint
The constraint whose triggers a change to a referenced row fires, and the relation that holds it.
ReferencedPartition
A referenced partition and the partitioned partition it belongs to, or None when it belongs to the foreign key’s referenced table.
ReferencingConstraint
The state of the foreign key that its derived constraints follow.

Traits§

ReferencedPartitionSource
What derivation reads from the catalog.

Functions§

firing_constraint
The constraint of foreign_key whose triggers a change to a referenced row of relation, the partition that holds it, fires: the constraint it derives on relation, or the foreign key’s own when the foreign key references relation. A row that moves to another partition fires the constraint at moved_through, the relation the UPDATE names, when the foreign key references it or a table it is a partition of, as PostgreSQL fires the update triggers of the update’s root for a moved row.
reconcile_referenced_partition_constraints
Make constraints hold one derived constraint for each of partitions, the referenced table’s partition tree in order, keeping the constraints of partitions that remain under the same parent. The partitions that joined below one constraint since the constraints were last derived take their names from that constraint and its validity, as PostgreSQL recurses into a new partition subtree with the name of the constraint it joins: the foreign key’s own for a partition of the referenced table, else the derived constraint of the partition’s parent. A valid foreign key validates every derived constraint, and one that is not enforced validates none. Reports whether the constraints changed.
reconcile_table_referenced_partition_constraints
Reconcile the derived constraints of every foreign key a table declares with the current partition trees of the tables they reference. A copy of a foreign key that the table’s partitioned parent declares derives none, as only the constraint without a parent derives constraints in PostgreSQL; a copy that became the table’s own when the table was detached derives them under its own name. Reports whether any foreign key changed.