classGeneratedColumns
final class GeneratedColumns
Reports the definitions PostgreSQL rejects because a column is, or is not, a generated column.
Rule: PG-GENERATED-COLUMN-001. A generation expression may not use a generated column (cannot use generated column "b" in column generation expression, check_nested_generated, heap.c); a partition key, by name or in an expression, may not use one (cannot use generated column in partition key, ComputePartitionAttrs, tablecmds.c); a foreign key whose referencing columns include one may not have ON UPDATE SET NULL, SET DEFAULT or CASCADE, nor ON DELETE SET NULL or SET DEFAULT (invalid ON UPDATE action for foreign key constraint containing generated column, ATAddForeignKeyConstraint). A table column inherited by several parents must be generated in all or none (inherited column "b" has a generation conflict); a column definition, or the options of a partition column, merged into an inherited generated column may not have a default or an identity, and one merged into an inherited column that is not generated may not have a generation clause (child column "b" specifies generation expression; MergeAttributes). A column counts as generated when the expression resolves it to a declared generated column, or the declaration of the table or parent says so; the first such column is reported, in written order. Source: https://www.postgresql.org/docs/17/ddl-generated-columns.html, https://www.postgresql.org/docs/16/ddl-generated-columns.html, https://github.com/postgres/postgres/blob/REL_17_2/src/backend/commands/tablecmds.c, https://github.com/postgres/postgres/blob/REL_17_2/src/backend/catalog/heap.c. Termination: one pass over the expression, the parents and the elements. Status: Implemented.
Methods§
public function referenced(Derivation $derivation, Scalar $expression): ?NameAnswers the first generated column, in written order, that an expression derived so far resolves to, or null when it uses none.
Parameters
$derivation | Derivation | |
$expression | Scalar |
Returns
?NameCalled from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\GeneratedColumns::expression() packages/sql-semantics-postgres/src/Rules/Table/Definition/GeneratedColumns.php:84
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\GeneratedColumns::partitionKey() packages/sql-semantics-postgres/src/Rules/Table/Definition/GeneratedColumns.php:95
Calls 4
- method-call Derivation::facts() line 67
- function-call
array_reverseline 68 - method-call ValueGraph::objects() line 68
- new ValueGraph line 68
public function expression(Derivation $derivation, Scalar $expression): voidReports a generation expression, derived before, that uses a generated column.
Parameters
$derivation | Derivation | |
$expression | Scalar |
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Statement\Constraint\Column\Generated::deriveClause() packages/sql-semantics-postgres/src/Statement/Constraint/Column/Generated.php:63
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\SetExpression::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/SetExpression.php:48
Calls 4
- method-call GeneratedColumns::referenced() line 84
- method-call Derivation::report() line 86
- new DefinitionProblem line 86
- class-const DefinitionRule::GeneratedInGeneration() line 86
public function partitionKey(Derivation $derivation, Scalar $key): voidReports a partition key, derived before, that uses a generated column.
Parameters
$derivation | Derivation | |
$key | Scalar |
Called from 1
Calls 4
- method-call GeneratedColumns::referenced() line 95
- method-call Derivation::report() line 96
- new DefinitionProblem line 96
- class-const DefinitionRule::GeneratedPartitionKey() line 96
public function among(
Derivation $derivation,
Environment $environment,
list<Name> $columns,
): boolTells whether the relation of an environment has a generated column among the named columns.
Parameters
$derivation | Derivation | |
$environment | Environment | |
$columns | list<Name> |
Returns
boolCalled from 1
Calls 2
- new KeyColumns line 107
- method-call KeyColumns::position() line 110
public function keyActions(Derivation $derivation, list<ReferentialAction> $actions): voidReports a referential action that a foreign key containing a generated column cannot have.
Parameters
$derivation | Derivation | |
$actions | list<ReferentialAction> |
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\GeneratedColumns::columnKeys() packages/sql-semantics-postgres/src/Rules/Table/Definition/GeneratedColumns.php:154
- method-call SqlSemantics\Platform\PostgreSql\Statement\Constraint\Table\ForeignKey::deriveClause() packages/sql-semantics-postgres/src/Statement/Constraint/Table/ForeignKey.php:97
Calls 10
- class-const ReferenceEvent::Update() line 128
- class-const ReferenceAction::SetNull() line 128
- class-const ReferenceAction::SetDefault() line 128
- class-const ReferenceAction::Cascade() line 128
- class-const ReferenceEvent::Delete() line 129
- function-call
in_arrayline 133 - method-call Derivation::report() line 134
- new DefinitionProblem line 134
- class-const DefinitionRule::GeneratedKeyAction() line 134
- new Name line 134
public function columnKeys(Derivation $derivation, list<Clause> $qualifiers): voidReports the referential actions of the REFERENCES constraints of a generated column definition.
Parameters
$derivation | Derivation | |
$qualifiers | list<Clause> | The qualifiers of the column definition |
Called from 1
Calls 2
- function-call
array_filterline 149 - method-call GeneratedColumns::keyActions() line 154
public function inherited(Derivation $derivation, TableForm $form): voidReports the columns of a table definition whose generation does not fit the columns they inherit.
Parameters
$derivation | Derivation | |
$form | TableForm |
Called from 1
Calls 8
- function-call
array_mapline 165 - method-call Derivation::table() line 171
- method-call Derivation::environment() line 171
- method-call Derivation::report() line 175
- new DefinitionProblem line 175
- class-const DefinitionRule::InheritedGenerationConflict() line 175
- method-call TableForm::elements() line 180
- method-call GeneratedColumns::merged() line 182
public function merged(
Derivation $derivation,
Name $column,
list<Clause> $qualifiers,
bool $generated,
): voidReports a column definition merged into an inherited column whose generation it does not fit.
Parameters
$derivation | Derivation | |
$column | Name | |
$qualifiers | list<Clause> | |
$generated | bool | Whether the inherited column is generated |
Called from 1
Calls 10
- function-call
array_mapline 195 - function-call
in_arrayline 197 - class-const DefaultExpression::class() line 197
- class-const Generated::class() line 197
- class-const DefinitionRule::GeneratedInheritsDefault() line 197
- class-const Identity::class() line 198
- class-const DefinitionRule::GeneratedInheritsIdentity() line 198
- class-const DefinitionRule::ChildGeneration() line 199
- method-call Derivation::report() line 203
- new DefinitionProblem line 203
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
GeneratedColumnsTestcalls
Relations§
Instantiated in 6
- new SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:68
- new SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Qualifiers::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Qualifiers.php:88
- new SqlSemantics\Platform\PostgreSql\Statement\Constraint\Column\Generated::deriveClause() packages/sql-semantics-postgres/src/Statement/Constraint/Column/Generated.php:63
- new SqlSemantics\Platform\PostgreSql\Statement\Constraint\Table\ForeignKey::deriveClause() packages/sql-semantics-postgres/src/Statement/Constraint/Table/ForeignKey.php:95
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\SetExpression::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/SetExpression.php:48
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Partition\PartitionSpec::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Partition/PartitionSpec.php:57
Method calls 7
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:68
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Qualifiers::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Qualifiers.php:88
- method-call SqlSemantics\Platform\PostgreSql\Statement\Constraint\Column\Generated::deriveClause() packages/sql-semantics-postgres/src/Statement/Constraint/Column/Generated.php:63
- method-call SqlSemantics\Platform\PostgreSql\Statement\Constraint\Table\ForeignKey::deriveClause() packages/sql-semantics-postgres/src/Statement/Constraint/Table/ForeignKey.php:96
- method-call SqlSemantics\Platform\PostgreSql\Statement\Constraint\Table\ForeignKey::deriveClause() packages/sql-semantics-postgres/src/Statement/Constraint/Table/ForeignKey.php:97
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\SetExpression::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/SetExpression.php:48
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Partition\PartitionSpec::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Partition/PartitionSpec.php:60