classLockingClause
final class LockingClause
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.One locking clause of a query: FOR UPDATE|SHARE [OF tables] [NOWAIT|SKIP LOCKED] or LOCK IN SHARE MODE.
The tables are names of tables of the query, by correlation name when they have one; the query that holds the clause reports a name that names none. A table may be written t.*, which names the same table; the form is kept, since a locking clause of a subquery is part of the text MySQL names an unaliased select list expression after. Source: https://dev.mysql.com/doc/refman/8.4/en/innodb-locking-reads.html, https://dev.mysql.com/doc/refman/8.4/en/select.html.
$clause = new \SqlSemantics\Platform\MySql\Statement\Query\Locking\LockingClause(\SqlSemantics\Platform\MySql\Statement\Query\Locking\LockStrength::Update, [new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('t'))], \SqlSemantics\Platform\MySql\Statement\Query\Locking\LockedRowAction::Nowait);
[$clause->tables[0]->name->value, $clause->action] // => ['t', \SqlSemantics\Platform\MySql\Statement\Query\Locking\LockedRowAction::Nowait]new \SqlSemantics\Platform\MySql\Statement\Query\Locking\LockingClause(\SqlSemantics\Platform\MySql\Statement\Query\Locking\LockStrength::ShareMode, [new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('t'))]) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstructionProperties§
public list<QualifiedName> $tablespublic list<OptionalWords> $wildcardspublic LockStrength $strengthpublic LockedRowAction|null $action = nullMethods§
public function __construct(
public LockStrength $strength,
list<QualifiedName> $tables = [],
public LockedRowAction|null $action = null,
list<OptionalWords> $wildcards = [],
)Parameters
$strength | LockStrength | The lock taken |
$tables | list<QualifiedName> | The locked tables; empty for every table of the query |
$action | LockedRowAction|null | What to do with a row locked elsewhere |
$wildcards | list<OptionalWords> | For each locked table, whether it is written with `.*`; empty when none is |
Calls 8
- static-call Check::listOf() line 54
- class-const QualifiedName::class() line 54
- class-const OptionalWords::class() line 55
- static-call Check::input() line 56
- function-call
countline 56 - function-call
array_fillline 57 - class-const OptionalWords::Omitted() line 57
- class-const LockStrength::ShareMode() line 58
public function render(Output $out): voidWrites the clause.
Parameters
$out | Output |
Test cases 2
Calls 10
- class-const LockStrength::ShareMode() line 69
- method-call Output::keyword() line 70
- class-const LockStrength::Update() line 74
- method-call Output::symbol() line 79
- method-call Output::name() line 82
- class-const NameUse::Qualifier() line 82
- class-const NameUse::Relation() line 84
- class-const OptionalWords::Written() line 85
- class-const LockedRowAction::Nowait() line 89
- class-const LockedRowAction::SkipLocked() line 91
Test cases 17§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
LockingClauseTest::testACatalogQualifiedTableIsRejectedcallsLockingClauseTest::testATableListOnShareModeIsRejectedcallsLockingClauseTest::testAWildcardListOfAnotherLengthIsRejectedcallsLockingClauseTest::testRenderWritesTheClausescallsLockingClauseTest::testRenderWritesTheStarOfATableWrittenWithItcalls
Other tests reaching this symbol 12
ChainTest::testQueryKeepsTheOwnClausesOfAMiddleSelectInALeadingUnioncallsChainTest::testQueryOrdersAUnionAfterTheClausesOfItsLastBlockcallsBlockTest::testFinishKeepsALaterOrderingAfterTheLockingClausesAsTheBlocksOwncallsTrailerTest::testThenAccumulatesLockingClausescallsTrailerTest::testThenCombinesTheClausesOfBothTrailerscallsTrailerTest::testWrapPutsTheOrderingAndTheLockingAroundAQuerycallsTailFactsTest::testDeriveReportsAnUnknownLockedTablecallsQueryStatementTest::testTheClausesOfASingleBlockAreRejectedcallsLeadingUnionTest::testRenderNeedsMySql5ForTheFormAndMySql56ForAnOwnLimitcallsOrderedSetOperationTest::testDeriveQueryNeedsMySql56callsOrderedSetOperationTest::testRejectsAsAnOperandOfAnotherSetOperationcallsSetOperationTest::testAQueryStatementAsAnOperandIsRejectedcalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Lowering\Query\Shared\TailRule::locking() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TailRule.php:226
- new SqlSemantics\Platform\MySql\Lowering\Query\Shared\TailRule::lock() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TailRule.php:248
- new SqlSemantics\Platform\MySql\Lowering\Query\Shared\TailRule::lock() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TailRule.php:271