IS_USED_LOCK( )

This MySQL function determines whether the name given is already in use as a lock name.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

IS_USED_LOCK(string)

Explanation

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.

Examples

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.