classGeneratedChanges
final class GeneratedChanges
Reports the ALTER TABLE column actions that do not fit whether the column is a generated column.
Rule: PG-ALTER-GENERATED-001. SET DEFAULT and DROP DEFAULT refuse a generated column (column "b" of relation "t" is a generated column, ATExecColumnDefault; the server hints at SET EXPRESSION or DROP EXPRESSION), unless the same statement drops its generation expression, which runs first. DROP EXPRESSION without IF EXISTS refuses a column that is not a stored generated column (column "a" of relation "t" is not a stored generated column, ATExecDropExpression); with IF EXISTS the server only notices it. SET EXPRESSION, from PostgreSQL 17, refuses a column that is not a generated column (ATExecSetExpression). SET DATA TYPE with USING refuses a generated column (cannot specify USING when altering type of generated column, ATPrepAlterColumnType). A column counts when the declared column list of the relation is complete and holds it. Source: https://www.postgresql.org/docs/17/sql-altertable.html, https://www.postgresql.org/docs/16/sql-altertable.html, https://github.com/postgres/postgres/blob/REL_17_2/src/backend/commands/tablecmds.c. Termination: one pass over the commands. Status: Implemented.
Methods§
public function check(Derivation $derivation, RowShape $shape, AlterTable $alter): voidReports the column actions of the statement that do not fit the generated columns of the relation.
Parameters
$derivation | Derivation | |
$shape | RowShape | |
$alter | AlterTable |
Called from 1
Calls 6
- method-call GeneratedChanges::generated() line 50
- method-call Derivation::report() line 51
- new DefinitionProblem line 51
- class-const DefinitionRule::GeneratedTypeUsing() line 51
- method-call GeneratedChanges::rule() line 56
- method-call GeneratedChanges::dropped() line 56
public function rule(
DefaultChange|ColumnAction|SetExpression $command,
bool|null $generated,
bool $dropped,
): ?DefinitionRuleAnswers the rule a column action breaks, or null.
Parameters
$command | DefaultChange|ColumnAction|SetExpression | |
$generated | bool|null | Whether the column is generated, or null when the relation does not tell |
$dropped | bool | Whether the statement drops the generation expression of the column |
Returns
Called from 1
Calls 5
- class-const ColumnActionKind::DropDefault() line 72
- class-const DefinitionRule::GeneratedColumnDefault() line 73
- class-const DefinitionRule::NotGenerated() line 79
- class-const ColumnActionKind::DropExpression() line 82
- class-const DefinitionRule::NotStoredGenerated() line 82
public function generated(Derivation $derivation, RowShape $shape, Name $column): ?boolTells whether the relation declares a column as generated, or null when the complete column list does not hold it.
Parameters
$derivation | Derivation | |
$shape | RowShape | |
$column | Name |
Returns
?boolCalled from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Command\GeneratedChanges::check() packages/sql-semantics-postgres/src/Rules/Table/Command/GeneratedChanges.php:50
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Command\GeneratedChanges::check() packages/sql-semantics-postgres/src/Rules/Table/Command/GeneratedChanges.php:56
Calls 3
- method-call RowShape::complete() line 90
- method-call KeyColumns::position() line 90
- new KeyColumns line 90
public function dropped(Derivation $derivation, AlterTable $alter, Name $column): boolTells whether the statement drops the generation expression of a column.
Parameters
$derivation | Derivation | |
$alter | AlterTable | |
$column | Name |
Returns
boolCalled from 1
Calls 2
- class-const ColumnActionKind::DropExpression() line 101
- class-const ColumnActionKind::DropExpressionIfExists() line 101
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
GeneratedChangesTestcalls