Name

IS_USED_LOCK()

Synopsis

IS_USED_LOCK(string)

This function determines whether the name given is already in use as a lock name. If the lock name is in use, it returns the connection identifier of the client holding the lock. It returns NULL if it is not in use. Locks are created by GET_LOCK(). This function is available as of version 4.1.0 of MySQL. Here is an example:

SELECT IS_USED_LOCK('my_lock');

+-------------------------+
| IS_USED_LOCK('my_lock') |
+-------------------------+
|                       1 |
+-------------------------+

The results here indicate that the lock is in use and the connection identifier of the client is 1.

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.