MySQL Forums
Forum List  »  Docs

Re: GET_LOCK/RELEASE_LOCK - Active Lock Holders
Posted by: Stefan Hinz
Date: March 17, 2009 02:13AM

You can find if a table is locked, and how many locks a table has, by issuing the SHOW OPEN TABLES statement. Here's an example:

mysql> SHOW OPEN TABLES;
Empty set (0.00 sec)

mysql> DESCRIBE tbl_a;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| i | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> SHOW OPEN TABLES;
+----------+-------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+-------+--------+-------------+
| test | tbl_a | 0 | 0 |
+----------+-------+--------+-------------+
1 row in set (0.00 sec)

mysql> LOCK TABLE tbl_a READ;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW OPEN TABLES;
+----------+-------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+-------+--------+-------------+
| test | tbl_a | 1 | 0 |
+----------+-------+--------+-------------+
1 row in set (0.00 sec)

If there are no open tables SHOW OPEN TABLES will return nothing, otherwise it will return a list of tables that are open. The In_use column indicates whether there are no locks (0) or the number of locks (any value greater than 0).

See http://dev.mysql.com/doc/refman/5.1/en/show-open-tables.html for more information.

Stefan Hinz, MySQL Documentation, Berlin, Germany

Options: ReplyQuote


Subject
Views
Written By
Posted
22186
September 05, 2007 10:36AM
Re: GET_LOCK/RELEASE_LOCK - Active Lock Holders
9296
March 17, 2009 02:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.