Skip to main content

Module referential

Module referential 

Source
Expand description

Prepare referential actions and partition rewrites before publishing row changes.

Modules§

checks
The foreign key checks and referential actions that PostgreSQL queues as internal AFTER ROW triggers of a written row and runs once the statement has written its rows: RI_FKey_check_ins and RI_FKey_check_upd on a referencing row, the NO ACTION and RESTRICT checks of a referenced key that a delete or an update removed, and the CASCADE, SET NULL and SET DEFAULT actions that write the rows referencing such a key. A check therefore sees every row of the statement: a row may reference a row that the same statement writes later, and a later row’s unique or NOT NULL violation is reported first.

Structs§

ReferencingChildLock
Lock one referencing child row for a referential action and refetch it after the wait. Returns None when the child vanished or its foreign-key columns no longer reference the parent key that triggered the action, so the action skips it exactly like PostgreSQL after an EvalPlanQual recheck of the referencing row.
ReferentialContext

Enums§

PartitionUpdateRoute

Traits§

ReferentialDeferrals
The deferral of the checks a change to a referenced row fires, under the constraint derived names when the foreign key derives one on the firing partition.
ReferentialReadSnapshot
Retained latest row images used only for referential checks under a fixed transaction snapshot.
ReferentialSnapshots

Functions§

apply_set_action_to_child
defer_deleted_key_checks
Leave for the transaction the checks of the referenced keys that a delete of the row parent_document of parent_table removes, under a deferred NO ACTION foreign key: the key’s event, and each row that references the key, which the transaction checks again when the constraint becomes immediate. A row in root_deletes, which the same statement deletes, needs no check.
defer_updated_key_checks
Leave for the transaction the checks of the referenced keys that an update of the row old_doc of table to new_doc removes, under a deferred NO ACTION foreign key: the key’s event, and each row that references the key, which the transaction checks again when the constraint becomes immediate. referenced_relation is the relation whose constraints the change fires: the row’s table, or the relation an UPDATE names when the row moves to another partition.
lock_referencing_child
prepare_document_delete
Lock the row that table holds at doc_id and prepare its delete, firing its BEFORE ROW triggers when fire_row_triggers holds, and leave for the transaction the checks of the deferred NO ACTION keys it removes. root_deletes holds the rows the same statement deletes. None when the row is gone or a BEFORE ROW trigger skipped it.
prepare_document_rewrite
Lock one row for its rewrite while the backend transaction is still deferred, and leave for the transaction the checks of the deferred NO ACTION keys the rewrite removes. referenced_relation is the relation whose constraints a change to the row’s referenced key fires: the row’s table, or the relation an UPDATE names when the row moves to another partition.
prepare_partition_update_route
prepare_referential_document_rewrite
Prepare the rewrite that a referential action makes of a referencing row: its BEFORE ROW triggers fire, and a partitioned table routes the new row.
prepare_routed_document_rewrite
referencing_rows
refresh_updated_generated_columns
Finish the UPDATE row after its BEFORE triggers, using PostgreSQL’s relation trigger descriptor and statement target columns.
reject_partition_rewrite
An ON CONFLICT DO UPDATE may not move the row it updates to another partition, which it would when the new row fails the partition constraint of the row’s partition (ExecCrossPartitionUpdate).