Bug #9462 can drop table, even if read locked
Submitted: 29 Mar 2005 17:42 Modified: 24 May 2005 19:27
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.10 OS:Any (*)
Assigned to: CPU Architecture:Any

[29 Mar 2005 17:42] Martin Friebe
Description:
according to the documentation, if a read lockis obtained on a table, the thread holding the lock and all other threads are restricted to read operations on this table.

however the thread holding the lock can drop the table (which will also release the lock)

How to repeat:
create table a2 (a int );
lock table a2 read;
drop table a2;

Suggested fix:
ensure drop table checks for locks.

Just a note: create table also doesnt check for locks, unless you include a select statement with a table ref. Not sure if that wants to change at all, but might want to be documented along with the above (or fixed above) behaviour.
[29 Mar 2005 17:58] Jorge del Conde
mysql> create table a2 (a int );
Query OK, 0 rows affected (0.01 sec)

mysql> lock table a2 read;
Query OK, 0 rows affected (0.00 sec)

mysql> drop table a2;
Query OK, 0 rows affected (0.00 sec)
[23 May 2005 14:05] Michael Widenius
This is a documentation issue and we will update the documentation with more information regarding this.
The table lock only protects against insert/update/delete/truncate but not against DLL statements.

It's intentional (but agree that maybe not obvious) that one should be able to DROP, ALTER and RENAME a table even if it's locked by the same thread.
[24 May 2005 19:27] Paul Dubois
I've noted that you can drop a locked table in the
section on LOCK TABLES.

Monty, I don't find that ALTER or RENAME are allowed
on a read-locked table, so I didn't noted those as being
allowed for locked tables.