Skip to main content

Module keys

Module keys 

Source
Expand description

The PRIMARY KEY and UNIQUE constraints of a new table. transformIndexConstraints validates the declared keys before the relation exists, and DefineIndex checks and names each key’s index after DefineRelation has cloned the keys of a partition’s parent.

Structs§

InheritedDefinitions
What a new table takes from its parents before its own definitions: the columns whose expressions the parents give, and the keys and foreign keys a partition clones from its parent.

Functions§

clone_parent_keys
The keys a partition clones from its parent, which DefineRelation creates before the table’s CHECK constraints: each unique index cloned from the parent is checked against the table’s own partition key, and each cloned key’s index is named, a name the CHECKs the table inherits hold being taken, and takes its OIDs; then CloneForeignKeyConstraints creates the partition’s copies of the parent’s foreign keys. The namer goes on to name the declared keys.
declare_primary_key_not_null
A declared primary key makes each of its columns NOT NULL through a constraint of the new table: an inherited NOT NULL becomes local and takes the name generated for the new table, as AddRelationNotNullConstraints merges the declaration with the inherited constraint.
define_declared_keys
Define the keys the table declares as DefineIndex does once the table’s CHECK and NOT NULL constraints exist: each key, primary key first, against an inherited primary key, the partition key and its index attributes. Each key’s index is named after its checks, so a later key’s errors follow an earlier key’s name conflict, and no index takes a name a constraint of the table holds; the index then takes its OID and the constraint its own.
transform_declared_keys
Validate the keys a CREATE TABLE declares, in declaration order, then order them as transformIndexConstraints does: the primary key first, and a key whose index would repeat an earlier key’s index dropped, giving its name to that key when the earlier key has none.