Purpose
This function checks whether a lock named by the string str is free, that is, whether the lock is held by another session.
Syntax
IS_FREE_LOCK('str')
Purpose
Parameters
str: the name of the lock to be checked. This parameter is of the string type.
Return value
1: the lock is free, that is, no session holds the lock.
0: the lock is held by a session, that is, the lock is not free.
Examples
Check whether the lock named my_lock is free.
obclient [(none)]> SELECT IS_FREE_LOCK('my_lock');
The return result is as follows:
+-------------------------+
| IS_FREE_LOCK('my_lock') |
+-------------------------+
| 0 |
+-------------------------+
1 row in set
The return value is 0, indicating that the lock my_lock is held by a session. You can execute IS_USED_LOCK() to query the connection identifier (session ID) of the session that holds the lock. Here is an example:
obclient [(none)]> SELECT IS_USED_LOCK('my_lock');
The return result is as follows:
+-------------------------+
| IS_USED_LOCK('my_lock') |
+-------------------------+
| 3221487701 |
+-------------------------+
1 row in set
