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

A request to report how SQLite would run a statement instead of running it.

Rule: SQLITE-EXPLAIN-001. EXPLAIN reports the virtual machine program of the statement, EXPLAIN QUERY PLAN the strategy of its queries; they are two different requests. The wrapped statement is inspected, not executed: every part of it is derived as usual, so its name resolutions and diagnostics are facts of the operation, but the rows it would return and the declaration a wrapped CREATE would provide are discarded. The operation returns the rows of the report (SQLITE-EXPLAIN-ROWS-001) and provides no declaration. Source: https://sqlite.org/lang_explain.html, https://sqlite.org/eqp.html. Status: Implemented.

Reading the columns of a query plan reportdoctest
$explain = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('EXPLAIN QUERY PLAN SELECT 1');
    [count($explain->fields()), $explain->field(3)->name?->value, $explain->toString()] // => [4, 'detail', 'EXPLAIN QUERY PLAN SELECT 1']
Inspecting a definition without declaring itdoctest
$explain = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('EXPLAIN CREATE TABLE t (a)');
    [$explain->declarations(), count($explain->fields())] // => [[], 8]

Properties§

public ExplainMode $mode
public Statement $statement

Methods§

public function __construct(public ExplainMode $mode, public Statement $statement)

Parameters

$modeExplainModeWhich report is requested
$statementStatementThe statement to report on
public function deriveStatement(Derivation $derivation): void

Inspects the wrapped statement and records the rows of the report as the output.

Parameters

$derivationDerivation
Calls 4
public function render(Output $out): void

Writes the prefix and the wrapped statement.

Parameters

$outOutput
Calls 3

Test cases 4§

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

Dedicated tests 2
Other tests reaching this symbol 2

Relations§

Instantiated in 2