final class Derivation
Restricted visibility: declared "@visibility SqlSemantics". Code outside that scope must not name this declaration.

The one-time recorder of the facts of a statement under construction.

Each node derives its own facts and asks the derivation to derive its children, which records exactly one fact per node. The recorder lives for one construction and is unreachable from the published operation.

Properties§

public AnalysisContext $context

Methods§

public function __construct(public AnalysisContext $context)

Parameters

$contextAnalysisContextThe fixed declaration context every part is derived against
public function within(AnalysisContext $context, Statement $node): void

Derives a nested statement that the database reads with other name-search settings.

The statement sees the declarations of the same profile under the search settings of the given context, as the elements of a schema definition are read with that schema searched first. The context may add only declarations this statement has already provided, as the elements of one schema definition see each other.

Parameters

Throws

InvalidConstruction When the context holds other declarations or another profile
Calls 2
public function admit(AnalysisContext $context): void

Refuses a nested context that differs from this one other than in search settings and own declarations.

Parameters

Throws

InvalidConstruction When the context holds other declarations or another profile
Called from 2
Calls 2
public function environment(): Environment

Answers the environment of a statement position that sees no relation.

Test cases 95
Called from 58
Calls 1
public function statement(Statement $node): void
public function member(Statement $node): void

Derives one member of a script.

The member's declarations and diagnostics are kept; the rows it would return are not: a script of several statements returns no single row set of its own.

Parameters

Called from 1
Calls 1
public function inspected(Statement $node, ?Environment $environment = null): void

Derives a statement whose request is only inspected or stored, such as the operand of EXPLAIN or a routine body.

Every part of the statement receives its facts, and its diagnostics are kept, but the rows it would return and the declarations it would provide are discarded: inspecting or storing a statement neither executes it nor declares anything. An environment, when given, is the position the statement is read at instead of a statement root, such as the variables of a routine body or the search settings of EXPLAIN FOR DATABASE; its context follows the rule of within().

Parameters

$nodeStatement
$environment?Environment

Throws

InvalidConstruction When the environment holds other declarations or another profile
Called from 3
Calls 2
public function scalar(Scalar $node, Environment $environment): ScalarFact

Derives and records the facts of a scalar expression at its position.

Parameters

$nodeScalar
$environmentEnvironment

Returns

Test cases 63
Called from 123
Calls 1
public function relation(Relation $node, Environment $environment): RelationFact

Derives and records the facts of a relation occurrence.

Parameters

$nodeRelation
$environmentEnvironment
Test cases 1
Called from 13
Calls 2
public function target(Node $node, RelationFact $fact): RelationFact

Records the facts of a table use that is not an input relation, such as a write target.

Parameters

Called from 17
public function query(Query $node, Environment $outer): QueryFact

Derives and records the output of a query used at a position.

Parameters

$nodeQuery
$outerEnvironment

Returns

Test cases 2
Called from 23
Calls 1
public function table(QualifiedName $name, Environment $environment): TableResolution

Resolves a relation name: the nearest common table of the environment, then the context.

Parameters

$nameQualifiedName
$environmentEnvironment
Called from 9
Calls 4
public function output(QueryFact $fact): void

Records the rows the root statement returns.

Parameters

Called from 19
Calls 1
public function report(Diagnostic $diagnostic): void

Records a semantic problem that is not a resolution outcome.

Parameters

$diagnosticDiagnostic
Called from 131
public function facts(): Facts

Freezes the recorded facts.

Returns

Test cases 36
Called from 4
Calls 1

Private surface 7§

Implementation details, listed for orientation only.

private list<array{Scalar, ScalarFact}> $scalars = []
private list<array{Node, RelationFact}> $relations = []
private list<array{Query, QueryFact}> $queries = []
private list<Table> $declarations = []
private list<Diagnostic> $diagnostics = []
private ?QueryFact $output = null
private ?Environment $base = null

Test cases 121§

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

Other tests reaching this symbol 121

Relations§

Instantiated in 1
Method calls 404
Type declarations 569