classDeclarations
final class Declarations
Derives the declaration a table definition provides.
Rule: PG-TABLE-DECLARATION-001. The columns of a table defined by a column list are, in order: the columns of the INHERITS parents (a column of the same name in several parents, or in the list, is merged into one), then each column definition and the columns each LIKE clause copies at its position. A partition has the columns of its parent; a typed table the attributes of its type. Each column has the type of PG-COLUMN-TYPE-001. A column is NOT NULL when it is declared NOT NULL, is a serial or identity column, belongs to a PRIMARY KEY, or is copied from a NOT NULL column of a parent, a LIKE source or the partitioned table ("Not-null constraints are
- always copied to the new table"); every other column can be NULL. A
column of a type the context cannot identify is declared with the type its name denotes on the search path. The declaration is complete only up to the first column whose type name is an error or whose parent, LIKE source or composite type the context does not declare. A column is generated when its definition has a generation clause, when it is inherited from a generated column of a parent or of the partitioned table, or when a LIKE clause copies a generated column and its options include GENERATED (INCLUDING GENERATED or INCLUDING ALL, applied in order with the EXCLUDING options; without it the copy is a regular column). An identity column is not generated in this sense. Source of the inheritance rule: MergeAttributes, tablecmds.c; https://www.postgresql.org/docs/17/ddl-generated-columns.html. The system columns are implicit (PG-SYSTEM-COLUMNS-001). A foreign table is declared as one, every other definition as a base table (PG-RELATION-KIND-001). Source: https://www.postgresql.org/docs/17/sql-createtable.html, https://www.postgresql.org/docs/17/ddl-inherit.html. Termination: one pass over the parents and the elements. Status: Implemented.
Methods§
public function table(
TableForm $form,
Derivation $derivation,
QualifiedName $name,
RelationKind $kind = RelationKind::BaseTable,
): TableBuilds the declaration of a table definition under its name.
Parameters
$form | TableForm | |
$derivation | Derivation | |
$name | QualifiedName | |
$kind | RelationKind |
Returns
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:62
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::fact() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:88
Calls 12
- class-const RelationKind::BaseTable() line 63
- new ColumnSet line 65
- method-call Declarations::listed() line 67
- method-call Declarations::copy() line 69
- method-call ColumnSet::close() line 71
- method-call TableForm::elements() line 73
- method-call Declarations::constrain() line 74
- new Table line 77
- method-call ColumnSet::columns() line 77
- method-call SystemColumns::implicit() line 77
- new SystemColumns line 77
- method-call ColumnSet::closed() line 77
public function listed(ListedColumns $form, Derivation $derivation, ColumnSet $set): voidAdds the inherited columns, the column definitions and the LIKE columns of a column list.
Parameters
$form | ListedColumns | |
$derivation | Derivation | |
$set | ColumnSet |
Called from 1
Calls 9
- method-call Declarations::copy() line 86
- new ColumnTyping line 88
- method-call ColumnTyping::descriptor() line 93
- method-call ColumnSet::close() line 95
- method-call ColumnTyping::serial() line 97
- method-call Declarations::notNull() line 97
- method-call ColumnSet::add() line 98
- method-call Declarations::generated() line 98
- method-call ColumnSet::require() line 99
public function copy(
QualifiedName $source,
Derivation $derivation,
ColumnSet $set,
LikeClause|null $like,
): voidCopies the columns of a parent or LIKE source, or closes the set when the context does not declare its columns.
Parameters
$source | QualifiedName | |
$derivation | Derivation | |
$set | ColumnSet | |
$like | LikeClause|null | The LIKE clause that copies the columns, or null for a parent |
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::table() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:69
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:86
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:91
Calls 7
- method-call Derivation::table() line 112
- method-call Derivation::environment() line 112
- method-call ColumnSet::close() line 114
- method-call Declarations::includesGenerated() line 118
- method-call ColumnSet::inherit() line 121
- method-call ColumnSet::add() line 123
- class-const Nullability::NotNull() line 123
public function includesGenerated(LikeClause $like): boolTells whether the options of a LIKE clause, applied in order, include the generation expressions.
Parameters
$like | LikeClause |
Returns
boolCalled from 1
Calls 2
- class-const LikeOptionKind::Generated() line 135
- class-const LikeOptionKind::All() line 135
public function generated(list<Clause> $qualifiers): boolTells whether column qualifiers hold a generation clause.
Parameters
$qualifiers | list<Clause> |
Returns
boolApplies the NOT NULL facts of column options and primary keys.
Called from 1
Calls 2
- method-call Declarations::notNull() line 164
- method-call ColumnSet::require() line 165
public function notNull(list<Clause> $qualifiers): boolTells whether column qualifiers make the column NOT NULL: NOT NULL, PRIMARY KEY or an identity.
Parameters
$qualifiers | list<Clause> |
Returns
boolCalled from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Command\Alterations::widened() packages/sql-semantics-postgres/src/Rules/Table/Command/Alterations.php:129
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::listed() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:97
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::constrain() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:164
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
DeclarationsTestcalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\PostgreSql\Rules\Table\Command\Alterations::widened() packages/sql-semantics-postgres/src/Rules/Table/Command/Alterations.php:129
- new SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:62
- new SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::fact() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:88
Method calls 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Command\Alterations::widened() packages/sql-semantics-postgres/src/Rules/Table/Command/Alterations.php:129
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:62
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::fact() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:88