classPlacement
final class Placement
Checks the values that only some positions of a statement admit: DEFAULT, MERGE_ACTION() and SELECT INTO.
Rule: PG-PLACEMENT-001. DEFAULT is a value only where a statement assigns it to a column: a value of the VALUES rows of an INSERT or of the INSERT action of MERGE, the value of a SET item, or a field of the row constructor of a multiple-column SET item; anywhere else in the statement it is reported. MERGE_ACTION() is admitted only in the RETURNING list of MERGE, subqueries included. A data-modifying statement checks its own parts; a data-modifying statement nested in it checks its own. A selection with INTO inside a statement that is not a query statement is reported. A WITH clause holding a data-modifying statement is reported anywhere but at the top level of the query a statement runs (PG-MODIFYING-CTE-001). Termination: the structure is a finite tree walked with a stack. Source: https://www.postgresql.org/docs/17/sql-insert.html, https://www.postgresql.org/docs/17/functions-merge-support.html, https://www.postgresql.org/docs/17/sql-selectinto.html. Status: Implemented.
Methods§
public function objects(object $root, bool $nested): list<object>Answers the structure objects reachable from a root, the root included; data-modifying statements below the root are entered only when asked.
Parameters
$root | object | |
$nested | bool |
Returns
list<object>Test cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::values() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:77
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::values() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:81
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::into() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:108
public function values(
Node $statement,
list<DefaultRequest> $defaults,
list<object> $actions,
Derivation $derivation,
): voidReports the DEFAULT values and MERGE_ACTION() calls of a statement that stand where they are not admitted.
Parameters
$statement | Node | |
$defaults | list<DefaultRequest> | The DEFAULT values at admitted positions |
$actions | list<object> | The objects inside which MERGE_ACTION() is admitted |
$derivation | Derivation |
Called from 11
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:41
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:55
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::table() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:67
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:119
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CursorFacts::declare() packages/sql-semantics-postgres/src/Rules/Manipulation/CursorFacts.php:49
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::rows() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:80
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::select() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:107
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:120
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:72
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Execute::deriveParameters() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Execute.php:74
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:67
Calls 6
- method-call Placement::objects() line 77
- function-call
in_arrayline 82 - method-call Derivation::report() line 83
- new ManipulationMisuse line 83
- class-const ManipulationMisuseRule::DefaultPlacement() line 83
- class-const ManipulationMisuseRule::MergeActionPlacement() line 86
public function modifying(Node $root, Query $query, Derivation $derivation): ?WithClauseReports the WITH clauses holding a data-modifying statement inside a statement, except the top-level one of the query it runs, and answers that one.
Parameters
$root | Node | |
$query | Query | |
$derivation | Derivation |
Returns
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:121
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CursorFacts::declare() packages/sql-semantics-postgres/src/Rules/Manipulation/CursorFacts.php:43
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:69
Calls 4
- method-call Query::commonTables() line 96
- method-call ModifyingCommonTables::top() line 96
- new ModifyingCommonTables line 96
- method-call ModifyingCommonTables::check() line 98
public function into(Node $root, Derivation $derivation, ?Select $admitted = null): voidReports every selection with INTO inside a statement, except the one the statement admits.
Parameters
$root | Node | |
$derivation | Derivation | |
$admitted | ?Select |
Called from 6
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::table() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:68
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:120
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CursorFacts::declare() packages/sql-semantics-postgres/src/Rules/Manipulation/CursorFacts.php:50
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Roots::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/Roots.php:32
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Execute::deriveParameters() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Execute.php:75
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:68
Calls 4
- method-call Placement::objects() line 108
- method-call Derivation::report() line 110
- new QueryMisuse line 110
- class-const QueryMisuseRule::IntoNotAllowed() line 110
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 12
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:41
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:55
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::table() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:66
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:118
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CursorFacts::declare() packages/sql-semantics-postgres/src/Rules/Manipulation/CursorFacts.php:42
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::rows() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:80
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::select() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:107
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:120
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:72
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Roots::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/Roots.php:32
- new SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Execute::deriveParameters() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Execute.php:73
- new SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:66
Method calls 20
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:41
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:55
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::table() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:67
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::table() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:68
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:119
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:120
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:121
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CursorFacts::declare() packages/sql-semantics-postgres/src/Rules/Manipulation/CursorFacts.php:43
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CursorFacts::declare() packages/sql-semantics-postgres/src/Rules/Manipulation/CursorFacts.php:49
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CursorFacts::declare() packages/sql-semantics-postgres/src/Rules/Manipulation/CursorFacts.php:50
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::rows() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:80
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::select() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:107
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:120
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:72
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Roots::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/Roots.php:32
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Execute::deriveParameters() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Execute.php:74
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Execute::deriveParameters() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Execute.php:75
- method-call SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:67
- 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\Manipulation\Prepared\Prepare::deriveStatement() packages/sql-semantics-postgres/src/Statement/Manipulation/Prepared/Prepare.php:69