classQueryRoots
final class QueryRoots
Derives a query that is a whole statement: its rows, or the table SELECT INTO creates.
Rule: PG-SELECT-INTO-001. A query statement returns its rows. When the first selection of the statement (the one reached through parentheses, WITH clauses and the first operands of set operations) has an INTO clause, the statement returns no rows and declares the new table instead: one column per output field, of the type the field gives a defined column (PG-DECLARED-TYPE-001) and able to be NULL; a table with an output whose name or position is not known (an open row) or whose type is invalid is declared incomplete up to that output. INTO anywhere else is reported. Data-modifying common tables outside the top-level WITH clause are reported (PG-MODIFYING-CTE-001). Source: https://www.postgresql.org/docs/17/sql-selectinto.html. Status: Implemented.
Methods§
public function derive(Query $root, Derivation $derivation): voidDerives the statement and records its rows or its declaration.
Parameters
$root | Query | |
$derivation | Derivation |
Called from 6
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\ParenthesizedQuery::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/ParenthesizedQuery.php:57
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\QueryExpression::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/QueryExpression.php:72
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Select::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/Select.php:127
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\SetOperation::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/SetOperation.php:77
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\TableQuery::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/TableQuery.php:73
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\ValuesList::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/ValuesList.php:63
Calls 14
- method-call Derivation::query() line 47
- method-call Derivation::environment() line 47
- new ModifyingCommonTables line 48
- method-call ModifyingCommonTables::check() line 49
- method-call ModifyingCommonTables::top() line 49
- method-call QueryRoots::first() line 50
- method-call ValueGraph::objects() line 51
- new ValueGraph line 51
- method-call Derivation::report() line 53
- new QueryMisuse line 53
- class-const QueryMisuseRule::IntoNotAllowed() line 53
- method-call Derivation::output() line 58
- method-call Derivation::declare() line 62
- method-call QueryRoots::table() line 62
Answers the first selection of a statement, whose INTO clause the statement may have.
Parameters
$query | Query |
Returns
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:106
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\QueryRoots::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/QueryRoots.php:50
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:68
public function table(IntoClause $into, QueryFact $fact, Derivation $derivation): TableAnswers the table SELECT INTO declares.
Parameters
$into | IntoClause | |
$fact | QueryFact | |
$derivation | Derivation |
Returns
Called from 1
Calls 5
- new DeclaredTyping line 88
- method-call DeclaredTyping::defined() line 90
- new Column line 95
- class-const Nullability::Nullable() line 95
- new Table line 98
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 8
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:106
- new SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:68
- new SqlSemantics\Platform\PostgreSql\Statement\Query\ParenthesizedQuery::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/ParenthesizedQuery.php:57
- new SqlSemantics\Platform\PostgreSql\Statement\Query\QueryExpression::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/QueryExpression.php:72
- new SqlSemantics\Platform\PostgreSql\Statement\Query\Select::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/Select.php:127
- new SqlSemantics\Platform\PostgreSql\Statement\Query\SetOperation::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/SetOperation.php:77
- new SqlSemantics\Platform\PostgreSql\Statement\Query\TableQuery::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/TableQuery.php:73
- new SqlSemantics\Platform\PostgreSql\Statement\Query\ValuesList::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/ValuesList.php:63
Method calls 8
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:106
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:68
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\ParenthesizedQuery::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/ParenthesizedQuery.php:57
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\QueryExpression::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/QueryExpression.php:72
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\Select::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/Select.php:127
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\SetOperation::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/SetOperation.php:77
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\TableQuery::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/TableQuery.php:73
- method-call SqlSemantics\Platform\PostgreSql\Statement\Query\ValuesList::deriveStatement() packages/sql-semantics-postgres/src/Statement/Query/ValuesList.php:63