Purpose
This function releases the named lock (namely, the lock named str) acquired by using the GET_LOCK() function for the current session.
Syntax
RELEASE_LOCK('str')
Description
Parameters
str: The name of the lock to be released, in string format.
Return value
- Return 1: The current session holds the lock and the lock has been successfully released.
- Return 0: The current session is not the lock holder, and the lock has not been released by the current session.
- Return
NULL: The lock does not exist, either because the lock was not acquired usingGET_LOCK(), or because the lock has already been released.
Examples
Release the lock named my_lock.
obclient [(none)]> SELECT RELEASE_LOCK('my_lock');
The return result is as follows:
+-------------------------+
| RELEASE_LOCK('my_lock') |
+-------------------------+
| 0 |
+-------------------------+
1 row in set
A return value of 0 indicates that the current session is not the holder of lock my_lock, and that the lock has not been released by the current session.