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

Binds the common table expressions of a WITH clause.

Rule: PG-COMMON-TABLE-001. Without RECURSIVE a common table is visible to the common tables after it and to the statement; with RECURSIVE it is visible to every common table of the clause, which are derived after the tables they refer to, and to itself. A table that refers to itself must be a UNION of a non-recursive and a recursive part (PG-SET-OPERATION-001 binds the recursive part); two tables that refer to each other are reported. The columns of a table are the output columns of its statement, renamed by its column list; more names than columns are reported. SEARCH adds its sequence column (a record, an array of records for depth-first) and CYCLE its mark column (boolean, or the common type of the TO and DEFAULT values, which see no column) and path column (an array of records); their columns must be columns of the table, and both require a recursive table. A repeated name is reported, and so is MERGE as the statement of a common table before release 17. The bindings join the environment of the holder at its own query level. Terminates: each table is derived once. Source: https://www.postgresql.org/docs/17/queries-with.html. Status: Implemented.

Methods§

public function uses(CommonTableExpression $table, Derivation $derivation): array<string, true>

Answers the folded names of the unqualified relations a table's statement reads.

Parameters

Returns

array<string, true>
Test cases 1
Called from 1
Calls 2
public function order(
    WithClause $with,
    array<int, array<string, true>> $uses,
    Derivation $derivation,
): list<int>

Answers the order the tables are derived in: written order, or with RECURSIVE every table after the tables it refers to.

Parameters

$withWithClause
$usesarray<int, array<string, true>>
$derivationDerivation

Returns

list<int>
Called from 1
Calls 6
public function recursiveForm(CommonTableExpression $table): bool

Tells whether a recursive table has the form non-recursive part UNION [ALL] recursive part.

Parameters

Returns

bool
Called from 1
Calls 3
public function member(
    RowShape $shape,
    list<Name> $columns,
    QueryMisuseRule $rule,
    Derivation $derivation,
): void

Test cases 2§

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

Dedicated tests 2

Relations§

Instantiated in 1
Method calls 1