classChangeFacts
final class ChangeFacts
Derives the facts of UPDATE and DELETE.
Rule: MYSQL-UPDATE-001 and MYSQL-DELETE-001. The common tables of WITH are bound first and are visible in every query of the statement. The table references are derived as a FROM clause is (MYSQL-FROM-001), each later reference seeing the earlier ones for LATERAL. The columns of the assignments, their values, WHERE and ORDER BY see every table of the references; the value DEFAULT is the default of its column; LIMIT sees none. An UPDATE whose references hold more than one table is a multiple-table UPDATE, which takes neither ORDER BY nor LIMIT. A single- table DELETE sees its table under its correlation name, or its table name when it has none. Each table a multiple-table DELETE deletes from must name a table of its references. A column an UPDATE assigns, and a table a multiple-table DELETE deletes from, must belong to a table or view; a derived table, a table function or a common table is not updatable (ER_NON_UPDATABLE_TABLE); a generated column takes only DEFAULT (MYSQL-GENERATED-WRITE-001). The statements return no rows. Terminates: one pass over the finite parts. Source: https://dev.mysql.com/doc/refman/8.4/en/update.html, https://dev.mysql.com/doc/refman/8.4/en/delete.html, https://dev.mysql.com/doc/refman/8.4/en/with.html. Status: Implemented.
Methods§
public function update(Update $update, Derivation $derivation, Environment $outer): voidDerives UPDATE.
Parameters
$update | Update | |
$derivation | Derivation | |
$outer | Environment |
Called from 1
Calls 15
- method-call ChangeFacts::base() line 61
- method-call ChangeFacts::references() line 62
- new Environment line 63
- method-call WriteScope::assign() line 64
- new WriteScope line 64
- method-call GeneratedWrites::assignments() line 65
- new GeneratedWrites line 65
- method-call ChangeFacts::updatable() line 67
- method-call Derivation::report() line 68
- new WriteMisuse line 68
- class-const WriteRule::NonUpdatableTarget() line 68
- method-call ChangeFacts::clauses() line 71
- function-call
countline 72 - class-const WriteRule::OrderedMultipleUpdate() line 73
- class-const WriteRule::LimitedMultipleUpdate() line 76
public function delete(Delete $delete, Derivation $derivation, Environment $outer): voidDerives a single-table DELETE.
Parameters
$delete | Delete | |
$derivation | Derivation | |
$outer | Environment |
Called from 1
Calls 5
- method-call ChangeFacts::base() line 85
- method-call Derivation::relation() line 86
- new Environment line 87
- new VisibleRelation line 87
- method-call ChangeFacts::clauses() line 88
public function deleteMultiple(
MultipleDelete $delete,
Derivation $derivation,
Environment $outer,
): voidDerives a multiple-table DELETE.
Parameters
$delete | MultipleDelete | |
$derivation | Derivation | |
$outer | Environment |
Called from 1
Calls 11
- method-call ChangeFacts::base() line 96
- method-call ChangeFacts::references() line 97
- new Projection line 98
- method-call Projection::admits() line 102
- method-call Derivation::report() line 105
- new UnknownDeleteTable line 105
- method-call ChangeFacts::updatable() line 106
- new WriteMisuse line 107
- class-const WriteRule::NonUpdatableTarget() line 107
- method-call ChangeFacts::clauses() line 110
- new Environment line 110
public function updatable(Relation $relation, Derivation $derivation): boolTells whether rows of a relation occurrence can be changed: a table or view, not a derived table, a table function or a common table.
Parameters
$relation | Relation | |
$derivation | Derivation |
Returns
boolCalled from 2
Calls 1
- method-call Derivation::facts() line 122
public function base(?WithClause $with, Derivation $derivation, Environment $outer): EnvironmentBinds the common tables of WITH, when there is one.
Parameters
$with | ?WithClause | |
$derivation | Derivation | |
$outer | Environment |
Returns
Called from 3
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::update() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:61
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::delete() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:85
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::deleteMultiple() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:96
public function references(
list<Relation> $tables,
Derivation $derivation,
Environment $base,
): list<VisibleRelation>Derives the table references and answers the relations they make visible.
Parameters
$tables | list<Relation> | |
$derivation | Derivation | |
$base | Environment |
Returns
list<VisibleRelation>Called from 2
Calls 3
- new FromScope line 142
- function-call
array_pushline 144 - method-call FromScope::open() line 144
public function clauses(
?Scalar $where,
list<OrderItem> $orderBy,
?Limit $limit,
Derivation $derivation,
Environment $base,
Environment $environment,
): voidDerives WHERE and ORDER BY where the tables are visible, and LIMIT where they are not.
Parameters
$where | ?Scalar | |
$orderBy | list<OrderItem> | |
$limit | ?Limit | |
$derivation | Derivation | |
$base | Environment | |
$environment | Environment |
Called from 3
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::update() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:71
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::delete() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:88
- method-call SqlSemantics\Platform\MySql\Rules\Dml\ChangeFacts::deleteMultiple() packages/sql-semantics-mysql/src/Rules/Dml/ChangeFacts.php:110
Calls 3
- method-call Derivation::scalar() line 158
- method-call TailFacts::limit() line 163
- new TailFacts line 163
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
ChangeFactsTestcalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Statement\Dml\Delete::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Delete.php:68
- new SqlSemantics\Platform\MySql\Statement\Dml\MultipleDelete::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/MultipleDelete.php:81
- new SqlSemantics\Platform\MySql\Statement\Dml\Update::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Update.php:83
Method calls 3
- method-call SqlSemantics\Platform\MySql\Statement\Dml\Delete::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Delete.php:68
- method-call SqlSemantics\Platform\MySql\Statement\Dml\MultipleDelete::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/MultipleDelete.php:81
- method-call SqlSemantics\Platform\MySql\Statement\Dml\Update::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Update.php:83