RELEASE_LOCK
Description
This function is used to release a named lock (i.e., a lock named str) previously obtained by the current session using the GET_LOCK() function.
Syntax
RELEASE_LOCK('str')
Description
Parameters
str: The name of the lock to be released. It is a string.
Return Value
- Returns 1: Indicates that the current session holds the lock and it has been successfully released.
- Returns 0: Indicates that the current session does not hold the lock, and the lock has not been released by the current session.
- Returns
NULL: Indicates that the lock does not exist, i.e., it was not obtained by theGET_LOCK()function, or it was released earlier.
Examples
Release the lock named my_lock.
SELECT RELEASE_LOCK('my_lock');
The return result is as follows:
+-------------------------+
| RELEASE_LOCK('my_lock') |
+-------------------------+
| 0 |
+-------------------------+
1 row in set (0.001 sec)
The return value of 0 indicates that the current session does not hold the lock my_lock, and the lock has not been released by the current session.