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
Test cases 2
Calls 2
public function admit(AnalysisContext $context): void
public function environment(): Environment

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

Test cases 60
Called from 25
Calls 1
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

Test cases 1
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
Test cases 3
Called from 1
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 1
Called from 65
Calls 1
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 1
Called from 15
Calls 1
public function output(QueryFact $fact): void

Records the rows the root statement returns.

Parameters

Test cases 2
Called from 10
Calls 1
public function report(Diagnostic $diagnostic): void

Records a semantic problem that is not a resolution outcome.

Parameters

$diagnosticDiagnostic
Test cases 1
Called from 56
public function facts(): Facts

Freezes the recorded facts.

Returns

Test cases 75
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 126§

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

Dedicated tests 20
Other tests reaching this symbol 106

Relations§

Instantiated in 1
Method calls 198
Type declarations 153