GET_LOCK()
GET_LOCK(string,seconds)
This function attempts to get a lock on the name given in the
first argument. The number of seconds to attempt the lock is given in
the second argument. If successful, it returns 1. If the function is
unsuccessful because the attempt times out, it returns 0. If the lock
fails due to an error of any kind, NULL is returned. The function
RELEASE_LOCK() may be used to release a lock. A lock is
also released when the same client issues another
GET_LOCK() or when the client’s connection is
terminated. Here is an example:
SELECT GET_LOCK('my_lock', 10);
+-------------------------+
| GET_LOCK('my_lock', 10) |
+-------------------------+
| 1 |
+-------------------------+