final class QueryStatement
    implements Statement, Query
    uses Snapshot
Public API: explicitly declared with @visibility public.

INTO and locking clauses written after a set operation, a parenthesized query or another query that is not a single query block.

After a single query block, also one with a WITH clause, the clauses belong to the block, so such a query is refused here. INTO after the query is written before the locking clauses or after them.

Rule: MYSQL-QUERY-STATEMENT-001. The rows are those of the query; the INTO targets and the locking clauses are derived by MYSQL-TAIL-FACTS-001. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html, https://dev.mysql.com/doc/refman/8.4/en/select-into.html. Status: Implemented.

Reading the INTO destination of a uniondoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t UNION SELECT b FROM u INTO @x');
    $query->statement->into->targets[0]->name->value // => 'x'
Refusing a query statement without clausesdoctest
$one = new \SqlSemantics\Platform\MySql\Statement\Query\Select([], [new \SqlSemantics\Platform\MySql\Statement\Query\SelectExpression(new \SqlSemantics\Platform\MySql\Statement\Literal\NumberLiteral('1'))]);
    new \SqlSemantics\Platform\MySql\Statement\Query\QueryStatement(new \SqlSemantics\Platform\MySql\Statement\Query\ParenthesizedQuery($one)) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public list<LockingClause> $locking
public Query $query
public IntoDestination|null $into = null
public IntoPosition|null $intoPosition = null

Methods§

public function __construct(
    public Query $query,
    list<LockingClause> $locking = [],
    public IntoDestination|null $into = null,
    public IntoPosition|null $intoPosition = null,
)

Parameters

$queryQueryThe query the clauses follow
$lockinglist<LockingClause>The locking clauses
$intoIntoDestination|nullThe INTO destination
$intoPositionIntoPosition|nullWhere INTO is written: after the query or after the locking clauses; given exactly when there is a destination
Calls 5
public function deriveStatement(Derivation $derivation): void

Derives the query as a statement root and records its rows as the output.

Parameters

$derivationDerivation
Calls 3
public function deriveQuery(Derivation $derivation, Environment $outer): QueryFact

Derives the query, the INTO targets and the locking clauses.

Parameters

$derivationDerivation
$outerEnvironment

Returns

Calls 3
public function render(Output $out): void

Writes the query and the clauses in written order.

Parameters

$outOutput
Calls 4

Test cases 8§

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

Dedicated tests 5
Other tests reaching this symbol 3

Relations§

Instantiated in 1
Type checks 7