Skip to main content

Module table_creation

Module table_creation 

Source
Expand description

CREATE TABLE column validation and CREATE TABLE AS result declarations.

Modules§

checks
The CHECK constraints of a new table, which DefineRelation adds once the table’s partitioning is set up. AddRelationNewConstraints takes them in written order: it transforms each expression, then rejects a name an earlier CHECK took, merges a named CHECK with the inherited constraint of its name or rejects a name another constraint of the table holds, or else chooses a name, and StoreRelCheck rejects a NO INHERIT constraint on a partitioned table before it creates the constraint row with its OID; a merged CHECK keeps the inherited row.
column_declarations
The checks transformColumnDefinition makes of a column definition once transformCreateStmt or transformAlterTableStmt has found the relation: an array of SERIAL before the column’s type is looked up, then the placement of constraint attributes, as transformConstraintAttrs checks it, and each clause against the clauses written before it.
declaration
Bind complete table declarations around their sequence and catalog publication boundaries.
foreign_keys
Define each foreign key in written order after the table and all its unique keys exist.
keys
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.
not_nulls
The NOT NULL constraints of a new table, which AddRelationNotNullConstraints creates once the table’s CHECK constraints exist. The declared constraints come first, in the order transformCreateStmt collected them, one constraint per column: a later declaration of a column must agree with the earlier one on NO INHERIT and may name the constraint the earlier one left unnamed. A declaration names a column of the relation, a NO INHERIT declaration cannot stand on a column whose parents give a constraint, a given name is new among the relation’s constraints, and a chosen name follows ChooseConstraintName. The constraints only parents give follow, each keeping its first parent’s name unless the relation holds it already.

Functions§

create_table_as_columns
The columns of a table that a query defines, named by the column list and then by the query, as intorel_startup names them: more names than the query has columns are rejected.
existing_create_as_target
CreateTableAsRelExists reports the written relation’s unqualified name for both CTAS and materialized views.
validate_create_table_as_columns
DefineRelation for a table whose columns a query defines: MergeAttributes rejects a repeated name, BuildDescForRelation requires USAGE on every column’s type, and CheckAttributeNamesTypes rejects system column names and pseudo-types.
validate_create_table_columns
CheckAttributeNamesTypes: no column may take a system column’s name, and then no column may have a pseudo-type.