Syntax:
GET_LOCK(str,timeout)

Tries to obtain a lock with a name given by the string str, using a
timeout of timeout seconds. Before MySQL 5.5.8, a negative timeout
value means infinite timeout on Windows. As of 5.5.8, this behavior
applies on all platforms.

Returns 1 if the lock was obtained successfully, 0 if the attempt timed
out (for example, because another client has previously locked the
name), or NULL if an error occurred (such as running out of memory or
the thread was killed with mysqladmin kill).

A lock obtained with GET_LOCK() is released explicitly by executing
RELEASE_LOCK() or implicitly when your session terminates (either
normally or abnormally).

Locks obtained with GET_LOCK() are not released when transactions
commit or roll back.

*Important*: The behavior of GET_LOCK() changes in MySQL 5.7. In
consideration of future upgrades, limit the str value to 64 characters
or less and do not rely on subsequent calls to GET_LOCK() releasing
previous locks.

GET_LOCK() can be used to implement application locks or to simulate
record locks. Names are locked on a server-wide basis. If a name has
been locked within one session, GET_LOCK() blocks any request by
another session for a lock with the same name. This enables clients
that agree on a given lock name to use the name to perform cooperative
advisory locking. But be aware that it also enables a client that is
not among the set of cooperating clients to lock a name, either
inadvertently or deliberately, and thus prevent any of the cooperating
clients from locking that name. One way to reduce the likelihood of
this is to use lock names that are database-specific or
application-specific. For example, use lock names of the form
db_name.str or app_name.str.

URL: http://dev.mysql.com/doc/refman/5.5/en/miscellaneous-functions.html

