Expand description
CREATE TABLE column validation and CREATE TABLE AS result declarations.
Modules§
- checks
- The CHECK constraints of a new table, which
DefineRelationadds once the table’s partitioning is set up.AddRelationNewConstraintstakes 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, andStoreRelCheckrejects 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
transformColumnDefinitionmakes of a column definition oncetransformCreateStmtortransformAlterTableStmthas found the relation: an array of SERIAL before the column’s type is looked up, then the placement of constraint attributes, astransformConstraintAttrschecks 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.
transformIndexConstraintsvalidates the declared keys before the relation exists, andDefineIndexchecks and names each key’s index afterDefineRelationhas cloned the keys of a partition’s parent. - not_
nulls - The NOT NULL constraints of a new table, which
AddRelationNotNullConstraintscreates once the table’s CHECK constraints exist. The declared constraints come first, in the ordertransformCreateStmtcollected 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 followsChooseConstraintName. 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_startupnames them: more names than the query has columns are rejected. - existing_
create_ as_ target CreateTableAsRelExistsreports the written relation’s unqualified name for both CTAS and materialized views.- validate_
create_ table_ as_ columns DefineRelationfor a table whose columns a query defines:MergeAttributesrejects a repeated name,BuildDescForRelationrequiresUSAGEon every column’s type, andCheckAttributeNamesTypesrejects 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.