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

Binds the common table expressions of a WITH clause.

Rule: MYSQL-WITH-001. The expressions are bound in written order; each sees the expressions before it and the enclosing scope, and a name defined twice is reported. Under RECURSIVE an expression whose query refers to its own name also sees itself: its query is a set operation whose leading operands do not refer to it, and the columns are those of these operands, all nullable (MYSQL-SET-FACTS-001 derives the later operands with that shape). A recursive expression whose query is no such set operation is reported, and a reference to it sees columns that depend on the missing nonrecursive part. The shape of every expression is that of its query under its column list (MYSQL-DERIVED-SHAPES-001). The bindings extend the enclosing scope without opening a query level. Terminates: every expression is derived once. Source: https://dev.mysql.com/doc/refman/8.4/en/with.html ("The types of the CTE result columns are inferred from the column types of the nonrecursive SELECT part only, and the columns are all nullable"). Status: Implemented.

Methods§

public function bind(With $with, Derivation $derivation, Environment $outer): Environment
public function pending(
    Environment $outer,
    Query $right,
    Derivation $derivation,
): ?CommonBinding

Answers the recursive expression whose self reference a set operand is derived for: a binding of the scope that still waits for its nonrecursive part and that the right operand of a set operation refers to.

Parameters

$outerEnvironment
$rightQuery
$derivationDerivation
Test cases 1
Called from 1
Calls 2
public function anchored(
    Environment $outer,
    CommonBinding $pending,
    QueryFact $anchor,
    Derivation $derivation,
): Environment

Answers the scope with a waiting recursive expression bound to the columns of the nonrecursive part.

Parameters

$outerEnvironment
$pendingCommonBinding
$anchorQueryFact
$derivationDerivation
Test cases 1
Called from 1
Calls 3
public function shape(
    CommonBinding $pending,
    QueryFact $anchor,
    Derivation $derivation,
): RowShape

Answers the columns a recursive expression sees itself with: those of the nonrecursive part under its column list, all nullable.

Parameters

$pendingCommonBinding
$anchorQueryFact
$derivationDerivation

Returns

Test cases 1
Called from 1
Calls 3
public function operands(Query $query): non-empty-list<Query>

Answers the operands of the set operation chain a query is, in written order, or the query itself.

Parameters

$queryQuery

Returns

non-empty-list<Query>
Test cases 2
Called from 1
Calls 1

Test cases 8§

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

Dedicated tests 8

Relations§

Instantiated in 2
Method calls 4