classModificationScope
final class ModificationScope
Derives the parts that INSERT, UPDATE, DELETE and MERGE share: common tables, the target, other inputs and RETURNING.
Rule: PG-MODIFICATION-SCOPE-001. The common tables of the statement are bound first, in the outer environment, and every query of the statement sees them. The target follows PG-TARGET-TABLE-001. The FROM items of UPDATE, the USING items of DELETE and the source of MERGE follow PG-FROM-SCOPE-001 in the environment of the common tables; they do not see the target. A FROM item that the same name qualifies as the target is reported, unless neither has a correlation name and the two names differ. RETURNING sees the target and the other inputs; its items follow PG-TARGET-001 and PG-STAR-001 and are the rows of the statement, which has no columns without RETURNING. Source: https://www.postgresql.org/docs/17/sql-update.html, https://www.postgresql.org/docs/17/sql-delete.html, https://www.postgresql.org/docs/17/dml-returning.html. Status: Implemented.
Methods§
public function open(
?CommonTables $with,
TargetTable $target,
Derivation $derivation,
Environment $outer,
bool $merge = false,
): array{Environment, VisibleRelation}Binds the common tables and derives the target.
Parameters
$with | ?CommonTables | |
$target | TargetTable | |
$derivation | Derivation | |
$outer | Environment | |
$merge | bool |
Returns
array{Environment, VisibleRelation} The environment of the common tables, and the target as a visible relationCalled from 6
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:35
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:52
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::rows() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:58
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::select() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:91
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:118
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:50
Calls 6
- method-call Derivation::relation() line 49
- new RelationKinds line 50
- method-call RelationKinds::modified() line 51
- method-call RelationKinds::of() line 51
- method-call Targets::visible() line 53
- new Targets line 53
public function inputs(
?Relation $items,
VisibleRelation $target,
Derivation $derivation,
Environment $base,
): list<VisibleRelation>Derives the other inputs of the statement and answers the relations they make visible.
Parameters
$items | ?Relation | |
$target | VisibleRelation | |
$derivation | Derivation | |
$base | Environment |
Returns
list<VisibleRelation>Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:36
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:53
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:51
Calls 7
- method-call FromScope::open() line 66
- new FromScope line 66
- method-call ModificationScope::conflicts() line 67
- new Locking line 68
- method-call Locking::kinds() line 69
- function-call
array_columnline 69 - method-call Locking::tables() line 69
public function conflicts(
VisibleRelation $target,
list<VisibleRelation> $others,
Derivation $derivation,
): voidReports the visible relations that the name of the target also qualifies.
Parameters
$target | VisibleRelation | |
$others | list<VisibleRelation> | |
$derivation | Derivation |
Called from 1
Calls 3
- method-call Derivation::report() line 96
- new ManipulationMisuse line 96
- class-const ManipulationMisuseRule::RepeatedRelationName() line 96
public function returning(
list<Target> $returning,
list<VisibleRelation> $visible,
Derivation $derivation,
Environment $base,
): QueryFactDerives RETURNING and answers the rows of the statement.
Parameters
$returning | list<Target> | |
$visible | list<VisibleRelation> | |
$derivation | Derivation | |
$base | Environment |
Returns
Called from 6
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:43
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:57
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::rows() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:82
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::select() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:109
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:122
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:74
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
ModificationScopeTestcalls
Relations§
Instantiated in 6
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:34
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:51
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::rows() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:57
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::select() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:90
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:117
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:49
Method calls 15
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:35
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:36
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::update() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:43
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:52
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:53
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ChangeFacts::delete() packages/sql-semantics-postgres/src/Rules/Manipulation/ChangeFacts.php:57
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::rows() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:58
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::rows() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:82
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::select() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:91
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::select() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:109
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:118
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\InsertFacts::defaults() packages/sql-semantics-postgres/src/Rules/Manipulation/InsertFacts.php:122
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:50
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:51
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\MergeFacts::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/MergeFacts.php:74