The MySQL documentation (5.5) for Lock tables states:
Let's say that I'm trying to lock
table2 in a single query, but
table2 is already locked. Will MySQL hold onto a lock on
table1 and block until it can lock
table2 or will it only hold onto a lock on
table1 when it can get a lock on both tables?
In case it matters, assume the InnoDB storage engine.
Update I just found the following statement on the same page:
When the session has gotten the WRITE lock and is waiting to get the lock for the next table in the lock table list, all other sessions wait for the WRITE lock to be released.
Is this confirming that MySQL will block whilst holding the lock on
table1? If that is the case, is there a way to query MySQL such that it will immediately return with a failure rather than block if it fails to grab all of the table locks?