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.

Reading a locking clausedoctest
$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> $relations
public LockStrength $strength
public LockWait|null $wait = null

Methods§

public function __construct(
    public LockStrength $strength,
    list<QualifiedName> $relations = [],
    public LockWait|null $wait = null,
)

Parameters

$strengthLockStrengthThe lock taken
$relationslist<QualifiedName>The FROM items locked; empty for every table
$waitLockWait|nullWhat to do with rows locked by another transaction; null to wait
Calls 2
public function render(Output $out): void

Writes FOR, the strength, the relations after OF and the wait policy.

Parameters

$outOutput
Calls 5

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 1
Constant reads 1