classLockingClause
final class LockingClause
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.One locking clause: FOR UPDATE, FOR NO KEY UPDATE, FOR SHARE or FOR KEY SHARE, optionally limited to some FROM items.
Mirrors PostgreSQL's LockingClause. The names refer to FROM items of the query by their alias or table name; without names every table of the query is locked. Source: https://www.postgresql.org/docs/17/sql-select.html#SQL-FOR-UPDATE-SHARE.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1 FROM t FOR SHARE OF t SKIP LOCKED');
[$query->statement->options->locking[0]->strength->value, $query->statement->options->locking[0]->relations[0]->name->value, $query->statement->options->locking[0]->wait->value] // => ['SHARE', 't', 'SKIP LOCKED']Properties§
public list<QualifiedName> $relationspublic LockStrength $strengthpublic LockWait|null $wait = nullMethods§
public function __construct(
public LockStrength $strength,
list<QualifiedName> $relations = [],
public LockWait|null $wait = null,
)Parameters
$strength | LockStrength | The lock taken |
$relations | list<QualifiedName> | The FROM items locked; empty for every table |
$wait | LockWait|null | What to do with rows locked by another transaction; null to wait |
Calls 2
- static-call Check::listOf() line 43
- class-const QualifiedName::class() line 43
public function render(Output $out): voidWrites FOR, the strength, the relations after OF and the wait policy.
Parameters
$out | Output |
Calls 5
- method-call Output::keyword() line 51
- function-call
explodeline 51 - method-call Output::symbol() line 56
- method-call Spelling::qualified() line 58
- new Spelling line 58
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
LockingClauseTestcalls