Bug #72345 Documentation does not list "LOCK TABLES" statement as been affected by MDL
Submitted: 14 Apr 2014 14:43 Modified: 16 May 2014 16:05
Reporter: Ovais Tariq Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[14 Apr 2014 14:43] Ovais Tariq
Description:
The metadata locking description in the MySQL manual does not list LOCK TABLES statement as been affected by the MDL locks. It only lists DDL statements.

A LOCK TABLES statement also waits on MDL locks acquired by a transaction or a running query and should be listed in the manual page.

How to repeat:
-- session 1
CREATE TABLE `t1` (
  `a` int(11) NOT NULL,
  `b` varchar(1000) DEFAULT NULL,
  PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

mysql [localhost] {msandbox} (test) > start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql [localhost] {msandbox} (test) > select * from t1;
...
2 rows in set (0.00 sec)

-- session 2
mysql [localhost] {msandbox} (test) > lock tables t1 write;

-- session 3
mysql [localhost] {msandbox} (test) > select * from t1;

-- session 4
mysql [localhost] {msandbox} (test) > show processlist;
+----+----------+-----------+------+---------+------+---------------------------------+----------------------+
| Id | User     | Host      | db   | Command | Time | State                           | Info                 |
+----+----------+-----------+------+---------+------+---------------------------------+----------------------+
|  1 | msandbox | localhost | test | Sleep   |  125 |                                 | NULL                 |
|  2 | msandbox | localhost | test | Query   |  101 | Waiting for table metadata lock | lock tables t1 write |
|  3 | msandbox | localhost | test | Query   |   14 | Waiting for table metadata lock | select * from t1     |
|  4 | msandbox | localhost | test | Query   |    0 | NULL                            | show processlist     |
+----+----------+-----------+------+---------+------+---------------------------------+----------------------+
4 rows in set (0.00 sec)
[14 Apr 2014 15:44] MySQL Verification Team
Thank you for the bug report.
[16 May 2014 16:05] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly.

I've added LOCK TABLES ... WRITE to the list of statements.