final class ColumnChanges
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.

Applies the column actions of one ALTER TABLE to the row shape of its table.

Rule: MYSQL-COLUMN-CHANGES-001. The server applies the actions to the existing table as a whole: DROP COLUMN, CHANGE, MODIFY and RENAME COLUMN name a column of the existing table, each such column at most once; ALTER COLUMN names a column of the existing table or one the statement adds; ADD COLUMN adds at the end, FIRST or AFTER a column of the result. The resulting shape is the existing slots without the dropped ones, a renamed slot under its new name re-exposing the existing slot, a changed slot replaced by the declared type and NULL fact of its new definition (MYSQL-COLUMN-DEFINITION-001 through ElementFacts::declaration), and the added columns; a shape that was open stays open. An invisible column (an implicit column of the declaration that aliases no declared column, an added or changed column declared INVISIBLE, or one that ALTER COLUMN … SET INVISIBLE hides) takes part in every check but is found only by name, as an implicit slot, and is not in the row shape. When the table is a declaration with a complete column list, a named column that is not there (or no longer there) is the diagnostic UnknownColumn and a name the result has twice is the diagnostic DuplicateColumn, reported at its later occurrence; nothing is reported for an open shape. Column names compare by the context's column name comparison. Terminates: one pass over the actions, each scanning the finite column list. Source: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html, https://github.com/mysql/mysql-server/blob/mysql-8.4.7/sql/sql_table.cc (mysql_prepare_alter_table). Status: Implemented.

Methods§

public function apply(
    RelationFact $table,
    list<AlterCommand> $commands,
    Derivation $derivation,
    bool $report,
): RowShape

Answers the row shape of the visible columns after the actions, and reports the column problems of a completely known table when asked to.

Parameters

$tableRelationFact
$commandslist<AlterCommand>The actions in order
$derivationDerivation
$reportboolWhether to report the column problems

Returns

Called from 2
Calls 7
public function implicit(): list<ImplicitSlot>

Answers the invisible columns after the actions, which a name finds but a star does not.

Returns

Called from 1
Calls 1
public function command(AlterCommand $command, list<Name> $added): list<Name>

Applies one action and answers the names of the columns it adds.

Parameters

$commandAlterCommand
$addedlist<Name>The names of the columns the earlier actions added

Returns

list<Name>
Called from 1
Calls 9
public function change(ChangeColumn $command): void

Replaces the existing column a CHANGE or MODIFY names by its new definition.

Parameters

$commandChangeColumn
Called from 1
Calls 7
public function drop(Name $column): void

Removes the existing column a DROP COLUMN names.

Parameters

$columnName
Called from 1
Calls 3
public function rename(Name $column, Name $name): void

Gives the existing column a RENAME COLUMN names its new name.

Parameters

$columnName
$nameName
Called from 1
Calls 3
public function altered(Name $column, list<Name> $added): void

Reports an ALTER COLUMN of a name that is neither an existing nor an added column.

Parameters

$columnName
$addedlist<Name>The names of the columns the earlier actions added
Called from 2
Calls 2
public function show(ColumnVisibility $command): void

Makes the columns an ALTER COLUMN … SET VISIBLE or INVISIBLE names visible or invisible.

Parameters

Called from 1
Calls 1

Private surface 6§

Implementation details, listed for orientation only.

private list<array{OutputSlot, int|null, bool}> $columns = []
private array<int, true> $used = []
private list<Name|null> $existing = []
private bool $decided = false
private bool $reporting = false
private ?Derivation $derivation = null

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 2
Method calls 3