Name
GET_LOCK( )
Synopsis
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, 1 is returned. If the function is
unsuccessful due to the attempt timing out, 0 is returned. 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. It’s also released when the same client issues
another GET_LOCK( )
or when the
client’s connection is terminated.
SELECT GET_LOCK('my_lock', 10); +-------------------------+ | GET_LOCK('my_lock', 10) | +-------------------------+ | 1 | +-------------------------+
Get MySQL in a Nutshell 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.