classAlterations
final class Alterations
Derives ALTER TABLE and the other commands built on AlterTableStmt.
Rule: PG-ALTER-TABLE-001. The altered relation is resolved (PG-TABLE-TARGET-001) and is the relation fact of the statement; the statement changes no declaration ("ALTER ... does not change the
- context"). Each action is derived where the relation is the only visible
relation, its system columns included; the expressions of an added column also see that column. A column an action names must be a column of a relation whose column list is complete, unless IF EXISTS is written. The kind the relation is written with and the actions must fit its declared kind (PG-RELATION-KIND-001, PG-ALTER-KIND-001). An identity can be added only to a column that is NOT NULL, as declared or made by SET NOT NULL or a primary key in the same statement ("must be declared NOT NULL before
- identity can be added", ATExecAddIdentity). The column actions must fit
the generated columns of the relation (PG-ALTER-GENERATED-001). Source: https://www.postgresql.org/docs/17/sql-altertable.html. Termination: one pass over the actions. Status: Implemented.
Methods§
public function derive(AlterTable $alter, Derivation $derivation): voidResolves the relation and derives the actions.
Parameters
$alter | AlterTable | |
$derivation | Derivation |
Called from 1
Calls 17
- new Targets line 66
- method-call Derivation::relation() line 67
- method-call Derivation::environment() line 67
- method-call Targets::scope() line 68
- method-call Targets::implicit() line 68
- new RelationKinds line 69
- method-call RelationKinds::altered() line 70
- static-call ObjectKind::from() line 70
- method-call AlterKinds::check() line 71
- new AlterKinds line 71
- method-call RelationKinds::of() line 71
- class-const RelationKind::ForeignTable() line 73
- method-call AlterKinds::foreign() line 74
- method-call Alterations::identity() line 78
- method-call GeneratedChanges::check() line 81
- new GeneratedChanges line 81
- method-call Alterations::widened() line 83
public function identity(
Derivation $derivation,
RowShape $shape,
AlterTable $alter,
Name $column,
): voidReports an identity added to a column the declaration lets be NULL.
The column must be NOT NULL when the identity is added; a SET NOT NULL or a primary key on the column in the same statement runs first.
Parameters
$derivation | Derivation | |
$shape | RowShape | |
$alter | AlterTable | |
$column | Name |
Called from 1
Calls 8
- method-call RowShape::complete() line 95
- method-call KeyColumns::position() line 95
- new KeyColumns line 95
- class-const Nullability::Nullable() line 96
- class-const ColumnActionKind::SetNotNull() line 106
- method-call Derivation::report() line 115
- new DefinitionProblem line 115
- class-const DefinitionRule::IdentityNullable() line 115
public function widened(
Environment $scope,
AddColumn $command,
Derivation $derivation,
): EnvironmentAnswers the scope of an added column: the relation with that column after its columns.
Parameters
$scope | Environment | |
$command | AddColumn | |
$derivation | Derivation |
Returns
Called from 1
Calls 12
- method-call ColumnTyping::descriptor() line 125
- new ColumnTyping line 125
- new OutputSlot line 126
- method-call DeclaredTyping::fact() line 128
- new DeclaredTyping line 128
- method-call Declarations::notNull() line 129
- new Declarations line 129
- class-const Nullability::NotNull() line 129
- class-const Nullability::Nullable() line 129
- new VisibleRelation line 132
- new RowShape line 132
- new Environment line 135
public function column(
Derivation $derivation,
Environment $environment,
Name|IntegerConstant $column,
): voidReports a column the action names that the complete row shape of the relation lacks.
Parameters
$derivation | Derivation | |
$environment | Environment | |
$column | Name|IntegerConstant |
Called from 11
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\AddIdentity::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/AddIdentity.php:58
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\AlterIdentity::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/AlterIdentity.php:51
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnAction::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnAction.php:45
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnAttributes::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnAttributes.php:53
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnStatistics::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnStatistics.php:46
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnStorageChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnStorageChange.php:45
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\DefaultChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/DefaultChange.php:44
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\DropColumn::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/DropColumn.php:50
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\SetExpression::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/SetExpression.php:46
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\TypeChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/TypeChange.php:54
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Option\ColumnForeignOptions::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Option/ColumnForeignOptions.php:51
Calls 5
- method-call KeyColumns::position() line 147
- new KeyColumns line 147
- method-call Derivation::report() line 148
- new DefinitionProblem line 148
- class-const DefinitionRule::MissingColumn() line 148
public function admits(list<AlterCommand> $commands): boolTells whether the actions of a command list may stand together: a partition action stands alone.
Parameters
$commands | list<AlterCommand> |
Returns
boolTest cases 1
Called from 1
Calls 1
- function-call
countline 160
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 13
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\AlterTable::__construct() packages/sql-semantics-postgres/src/Statement/Table/Alter/AlterTable.php:55
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\AlterTable::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/Alter/AlterTable.php:64
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\AddIdentity::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/AddIdentity.php:58
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\AlterIdentity::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/AlterIdentity.php:51
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnAction::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnAction.php:45
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnAttributes::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnAttributes.php:53
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnStatistics::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnStatistics.php:46
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnStorageChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnStorageChange.php:45
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\DefaultChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/DefaultChange.php:44
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\DropColumn::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/DropColumn.php:50
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\SetExpression::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/SetExpression.php:46
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\TypeChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/TypeChange.php:54
- new SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Option\ColumnForeignOptions::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Option/ColumnForeignOptions.php:51
Method calls 13
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\AlterTable::__construct() packages/sql-semantics-postgres/src/Statement/Table/Alter/AlterTable.php:55
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\AlterTable::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/Alter/AlterTable.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\AddIdentity::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/AddIdentity.php:58
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\AlterIdentity::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/AlterIdentity.php:51
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnAction::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnAction.php:45
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnAttributes::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnAttributes.php:53
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnStatistics::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnStatistics.php:46
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnStorageChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnStorageChange.php:45
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\DefaultChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/DefaultChange.php:44
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\DropColumn::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/DropColumn.php:50
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\SetExpression::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/SetExpression.php:46
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\TypeChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/TypeChange.php:54
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Option\ColumnForeignOptions::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Alter/Option/ColumnForeignOptions.php:51