Purpose
IS_FREE_LOCK() checks whether the lock with the name given by str is free, that is, not held by other sessions.
Syntax
IS_FREE_LOCK('str')
Description
Parameters
str: the name of the lock to be checked. The value is a string.
Return value
1: indicates that the lock is free, that is, no session is holding the lock.0: indicates that the lock is not free, that is, a session is holding the lock.
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
0 is returned, indicating that the lock my_lock is held by a session. You can use 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