PG_TRY_ADVISORY_LOCK
Obtain an exclusive session-level advisory lock without waiting for the lock to
become available. This function either obtains the lock immediately and returns
true
, or returns false
if the lock cannot be
acquired immediately.
PG_TRY_ADVISORY_LOCK(lock_id)
where lock_id
is a BIGINT
value.
This function returns a
BOOLEAN
data type. For example:
premdb=# select pg_try_advisory_lock(32451240);
pg_try_advisory_lock
----------------------
t
(1 row)
Note: Advisory lock functions are not supported in queries with table references in
the
FROM
clause.