List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:December 13 1999 5:58am
Subject:Re: How does get_lock() simulate row-level locking?
View as plain text  
At 9:10 PM -0800 1999-12-12, Joshua Chamas wrote:
>Andy wrote:
>>  Hi,
>>  I read in the manual that I can use get_lock to simulate row-level locking.
>>  But I don't see how that would work. I thought mysql automatically lock the
>>  whole table on selects & updates, so even if I do a get_lock("row_id", 10)
>>  for every select & update, mysql will still acquire table lock and that
>>  would defeat the whole purpose.
>If you need to lock a row across more than one query, get_lock()
>does simulate row level locking.  It doesn't do anything for you
>if you are just looking for the row level locking performance
>for a single select statement.
>>  Also, what type of lock does get_lock() acquire? shared or exclusive?

It's exclusive only for applications that cooperate in its use.
In other words, it doesn't lock anything, if another application
decides to simply not check for the lock.

GET_LOCK() implements advisory, cooperative locks.

>>  Can someoone help me out? Anyone has used get_lock for this purpose? I'd
>>  love to learn about your eperience.
>Yes I have used it, and it works well.  If I want to do a set of SQL
>operations based on a row, then I acquire a get_lock() on a key
>built of that rows'd unique id & maybe table name or some other

Paul DuBois, paul@stripped
How does get_lock() simulate row-level locking?Andy13 Dec
  • Re: How does get_lock() simulate row-level locking?Joshua Chamas13 Dec
    • Re: How does get_lock() simulate row-level locking?Paul DuBois13 Dec