简体   繁体   中英

MySQL: Can Tables Be Locked Recursively?

Can MySQL (InnoDB) tables be locked recursively ?

Can't find any mention of nesting or recursion in the LOCK TABLES documentation.

The default behavior seems to be (based on what I've observed) that the second lock implicitly UNlocks the first lock.

Is there any way to make it function recursively?

If by recursively , you mean calling LOCK TABLES repeatedly, creating a series of nested locks, then the answer is "no". Calling LOCK TABLES on a table implicitly releases any current locks held on that table by that thread.

From the MySQL LOCK TABLES syntax documentation :

UNLOCK TABLES explicitly releases any table locks held by the current session. LOCK TABLES implicitly releases any table locks held by the current session before acquiring new locks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM