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

Checks the actions of ALTER TABLE against the kind of the altered relation.

Rule: PG-ALTER-KIND-001. Each action accepts only some kinds of relation (ATPrepCmd / ATSimplePermissions): for example ADD COLUMN, DROP COLUMN, SET DATA TYPE, ADD CONSTRAINT and the trigger actions a base table or a foreign table; ALTER COLUMN ... SET DEFAULT and the identity actions also a view; SET STATISTICS, column SET/RESET and SET STORAGE also a materialized view; SET ( storage parameters ) a base table, a view or a materialized view; SET LOGGED and SET UNLOGGED a base table or a sequence; the OPTIONS actions only a foreign table; ADD CONSTRAINT ... USING INDEX, ALTER CONSTRAINT, OF, NOT OF, the row security and rule actions and the partition actions only a base table; OWNER TO every kind. An action on a relation of another declared kind is reported as ALTER action %s cannot be performed on relation "%s" with the server's name for the action. The parent of INHERIT and NO INHERIT must itself be a base table or a foreign table, and a foreign table takes no primary key, unique, exclusion or foreign key constraint. Source: https://www.postgresql.org/docs/17/sql-altertable.html, tablecmds.c (ATPrepCmd, alter_table_type_to_string, ATExecAddInherit). Termination: one check per action. Status: Implemented.

Methods§

public function check(
    Derivation $derivation,
    ?RelationKind $kind,
    Name $relation,
    list<AlterCommand> $commands,
): void

Reports the actions the declared kind of the relation does not accept.

Parameters

$derivationDerivation
$kind?RelationKind
$relationName
$commandslist<AlterCommand>
Called from 1
Calls 6
public function foreign(Derivation $derivation, list<AlterCommand> $commands): void

Reports the constraints the added columns and constraints would give a foreign table (PG-RELATION-KIND-001).

Parameters

$derivationDerivation
$commandslist<AlterCommand>
Called from 1
Calls 2
public function parent(Derivation $derivation, InheritanceChange $command): void
public function accepted(AlterCommand $command): array{AlterAction, list<RelationKind>}|null

Answers the server's name of an action and the kinds of relation it accepts; null for an action every kind accepts.

Parameters

$commandAlterCommand

Returns

array{AlterAction, list<RelationKind>}|null
Test cases 2
Called from 1
Calls 4
public function relationWide(AlterCommand $command): array{AlterAction, list<RelationKind>}|null

Answers the name and the accepted kinds of the actions on the relation as a whole.

Parameters

$commandAlterCommand

Returns

array{AlterAction, list<RelationKind>}|null
Test cases 1
Called from 1
Calls 22
public function table(TableActionKind $kind): array{AlterAction, list<RelationKind>}

Answers the name and the accepted kinds of an action on the relation without operand.

Parameters

Returns

Test cases 1
Called from 1
Calls 31
public function named(NamedActionKind $kind): array{AlterAction, list<RelationKind>}

Answers the name and the accepted kinds of an action on a named object of the relation.

Parameters

Returns

Test cases 1
Called from 1
Calls 25

Private surface 5§

Implementation details, listed for orientation only.

private const TABLE = [\SqlSemantics\Platform\PostgreSql\Model\Statement\Declaration\RelationKind::Ba…
private const TABLE_OR_FOREIGN = [\SqlSemantics\Platform\PostgreSql\Model\Statement\Declaration\RelationKind::Ba…
private const TABLE_VIEW_OR_FOREIGN = [\SqlSemantics\Platform\PostgreSql\Model\Statement\Declaration\RelationKind::Ba…
private const TABLE_OR_MATERIALIZED = [\SqlSemantics\Platform\PostgreSql\Model\Statement\Declaration\RelationKind::Ba…
private const TABLE_MATERIALIZED_OR_FOREIGN = [\SqlSemantics\Platform\PostgreSql\Model\Statement\Declaration\RelationKind::Ba…

Test cases 6§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 6

Relations§

Instantiated in 2
Method calls 2