IS_FREE_LOCK()¶
Reports whether a named user-level advisory lock is currently available.
Syntax¶
IS_FREE_LOCK(name)
Arguments¶
Argument |
Description |
|---|---|
|
Case-insensitive lock name to inspect. |
Return Value¶
Returns
1when the named lock is free.Returns
0when any session holds the lock.Returns
NULLfor invalid input or an execution error.
Usage Notes¶
The check does not acquire the lock and its result can change immediately because of another session.
Source evidence:
test/distributed/cases/function/user_lock.sql.
Examples¶
DROP DATABASE IF EXISTS is_free_lock_demo;
CREATE DATABASE is_free_lock_demo;
USE is_free_lock_demo;
SELECT IS_FREE_LOCK('nightly_job') AS initially_free;
SELECT GET_LOCK('nightly_job', 0);
SELECT IS_FREE_LOCK('nightly_job') AS held;
SELECT RELEASE_LOCK('nightly_job');
SELECT IS_FREE_LOCK('nightly_job') AS free_again;
DROP DATABASE is_free_lock_demo;