2023-03-08 06:38:11 +11:00
|
|
|
-- name: AcquireLock :exec
|
|
|
|
|
-- Blocks until the lock is acquired.
|
|
|
|
|
--
|
|
|
|
|
-- This must be called from within a transaction. The lock will be automatically
|
|
|
|
|
-- released when the transaction ends.
|
|
|
|
|
SELECT pg_advisory_xact_lock($1);
|
|
|
|
|
|
|
|
|
|
-- name: TryAcquireLock :one
|
|
|
|
|
-- Non blocking lock. Returns true if the lock was acquired, false otherwise.
|
|
|
|
|
--
|
|
|
|
|
-- This must be called from within a transaction. The lock will be automatically
|
|
|
|
|
-- released when the transaction ends.
|
|
|
|
|
SELECT pg_try_advisory_xact_lock($1);
|
2026-10-01 16:42:51 +02:00
|
|
|
|
|
|
|
|
-- name: SetTransactionLockTimeout :exec
|
|
|
|
|
-- Bounds how long later lock waits in the current transaction may block.
|
|
|
|
|
-- A wait longer than lock_timeout_ms fails with lock_not_available
|
|
|
|
|
-- instead of blocking. The setting reverts when the transaction ends.
|
|
|
|
|
SELECT set_config('lock_timeout', format('%sms', @lock_timeout_ms::bigint), true);
|