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

Checks the kind of the relation a command names against the kinds the command accepts.

Rule: PG-RELATION-KIND-001. A relation declaration states whether it is a base table (a partitioned table included), a view, a materialized view, a foreign table or a sequence. A command that names a relation of a kind it does not accept is the server's error, reported in its words: DROP, COMMENT and ALTER EXTENSION written with one kind accept only that kind (DROP TABLE of a view: "v" is not a table; nothing the context declares is an index); ALTER, RENAME and SET SCHEMA written with VIEW, MATERIALIZED VIEW, FOREIGN TABLE, SEQUENCE or INDEX accept only that kind, while ALTER TABLE accepts every kind and ALTER INDEX ... RENAME any relation (RangeVarCallbackForAlterRelation); a column or constraint of a sequence cannot be renamed (cannot rename columns of relation). The commands with their own lists of accepted kinds apply them where they resolve the relation. A relation the context does not declare, or declares without stating a kind it can know, is never reported. Source: https://www.postgresql.org/docs/17/sql-droptable.html, https://www.postgresql.org/docs/17/sql-alterview.html, tablecmds.c and objectaddress.c (get_relation_by_qualified_name). Termination: one lookup per relation. Status: Implemented.

Constants§

public const COLUMNED = [\SqlSemantics\Platform\PostgreSql\Model\Statement\Declaration\RelationKind::Ba…

The kinds of relation whose columns and constraints can be renamed (renameatt_check).

Methods§

public function of(RelationFact $fact): ?RelationKind

Answers the kind the declaration a relation fact resolved to states, or null when it resolved to none.

Parameters

Returns

Test cases 1
Called from 18
public function declared(
    Derivation $derivation,
    QualifiedName $name,
    ?Environment $environment = null,
): ?RelationKind

Answers the kind of the relation a name resolves to, or null when it resolves to no declaration.

Parameters

$derivationDerivation
$nameQualifiedName
$environment?Environment

Returns

Called from 8
Calls 2
public function require(
    Derivation $derivation,
    ?RelationKind $kind,
    Name $relation,
    list<RelationKind> $accepted,
    KindRule $rule,
): bool

Reports the rule when the declared kind is known and is not one of the accepted kinds; tells whether it reported.

Parameters

$derivationDerivation
$kind?RelationKind
$relationName
$acceptedlist<RelationKind>
$ruleKindRule

Returns

bool
Called from 19
Calls 3
public function altered(
    Derivation $derivation,
    ObjectKind $kind,
    QualifiedName $name,
    bool $rename,
): bool
public function renamed(
    Derivation $derivation,
    ObjectKind $kind,
    ObjectReference $object,
    bool $rename,
    bool $member,
): void
public function modified(
    Derivation $derivation,
    ?RelationKind $kind,
    Name $relation,
    bool $merge,
): void

Reports the target of INSERT, UPDATE, DELETE or MERGE when its declared kind cannot be changed.

A sequence or a materialized view cannot be changed (CheckValidResultRel); whether a view or a foreign table can depends on its definition, its triggers or its wrapper. MERGE accepts only a table and, from PostgreSQL 17, a view (transformMergeStmt).

Parameters

$derivationDerivation
$kind?RelationKind
$relationName
$mergebool
Called from 1
Calls 11
public function foreign(Derivation $derivation, list<Clause> $elements): void
public function triggered(
    Derivation $derivation,
    ?RelationKind $kind,
    Name $relation,
    TriggerTiming $timing,
    bool $row,
    bool $truncate,
    bool $constraint,
    bool $transitions = false,
): void

Reports a trigger the kind of its relation cannot have (CreateTriggerFiringOn).

A table or a foreign table has no INSTEAD OF trigger, a view no row trigger other than INSTEAD OF and no TRUNCATE trigger, a foreign table no constraint trigger, neither a view nor a foreign table a trigger with transition tables; a materialized view and a sequence have no trigger.

Parameters

$derivationDerivation
$kind?RelationKind
$relationName
$timingTriggerTiming
$rowbool
$truncatebool
$constraintbool
$transitionsbool
Called from 2
Calls 12
public function expected(ObjectKind $kind): array{RelationKind|null, KindRule}|null

Answers the kind a relation kind keyword accepts and the rule a relation of another kind breaks; null for the kinds that name no relation.

Parameters

Returns

array{RelationKind|null, KindRule}|null
Test cases 1
Called from 3
Calls 17

Test cases 3§

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

Dedicated tests 3

Relations§

Instantiated in 30
Method calls 50