classModifyingCommonTables
final class ModifyingCommonTables
Reports data-modifying common table expressions that are not in the WITH clause of the statement itself.
Rule: PG-MODIFYING-CTE-001. A common table computed by INSERT, UPDATE, DELETE or MERGE is allowed only in the WITH clause that belongs to the top level of a statement: the WITH of a query statement (through grouping parentheses) or of a data-modifying statement. In a subquery, in a set operation operand or in the statement of another common table it is reported once per WITH clause. Terminates: one pass over the finite value graph. Source: https://www.postgresql.org/docs/17/queries-with.html#QUERIES-WITH-MODIFYING. Status: Implemented.
Methods§
public function check(Node $root, WithClause|null $top, Derivation $derivation): voidReports every WITH clause of a statement other than its top-level one that holds a data-modifying common table.
Parameters
$root | Node | The statement root |
$top | WithClause|null | The WITH clause that belongs to the top level of the statement |
$derivation | Derivation |
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::modifying() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:98
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Roots::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/Roots.php:34
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\QueryRoots::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/QueryRoots.php:49
Calls 5
- method-call ValueGraph::objects() line 40
- new ValueGraph line 40
- method-call Derivation::report() line 46
- new QueryMisuse line 46
- class-const QueryMisuseRule::NestedModification() line 46
public function top(Node $query): ?WithClauseAnswers the WITH clause that belongs to the top level of a query statement: the one written before its body, inside grouping parentheses.
Parameters
$query | Node |
Returns
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::modifying() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:96
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\QueryRoots::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/QueryRoots.php:49
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 4
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::modifying() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:96
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::modifying() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:98
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Roots::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/Roots.php:34
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\QueryRoots::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/QueryRoots.php:48
Method calls 5
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::modifying() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:96
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::modifying() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:98
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Roots::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/Roots.php:34
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\QueryRoots::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/QueryRoots.php:49
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\QueryRoots::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/QueryRoots.php:49