Syntax:
GET_LOCK(str,timeout)

Tries to obtain a lock with a name given by the string str, using a
timeout of timeout seconds. A negative timeout value means infinite
timeout.

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). If you have a lock
obtained with GET_LOCK(), it is released when you execute
RELEASE_LOCK(), execute a new GET_LOCK(), or your connection terminates
(either normally or abnormally). Locks obtained with GET_LOCK() do not
interact with transactions. That is, committing a transaction does not
release any such locks obtained during the transaction.

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.6/en/miscellaneous-functions.html

