Bug #2376 CREATE TABLE LIKE not blocked by FLUSH TABLES WITH READ LOCK
Submitted: 13 Jan 2004 11:04 Modified: 14 Jan 2004 7:24
Reporter: Guilhem Bichot Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1 OS:Any (all)
Assigned to: Assigned Account CPU Architecture:Any

[13 Jan 2004 11:04] Guilhem Bichot
Description:
A few months ago, mysqld was changed so that when a connection has issued FLUSH TABLES WITH READ LOCK, it blocks CREATE TABLE. This is so that the one which issued FLUSH TABLES WITH READ LOCK can do a consistent backup.
I have tested, and indeed
CREATE TABLE and CREATE TABLE SELECT are blocked,
but not CREATE TABLE LIKE.

How to repeat:
thread1:
FLUSH TABLES WITH READ LOCK;
thread2:
CREATE TABLE u LIKE t;
it's not blocked.

Suggested fix:
take inspiration from any of the 2 other CREATE forms; the model could be CREATE TABLE SELECT, as
CREATE TABLE u LIKE t
is almost (except indices) like
CREATE TABLE u SELECT * FROM t LIMIT 0;
[14 Jan 2004 7:24] Guilhem Bichot
BUG#2385 "CREATE TABLE LIKE lacks locking on source and destination table" is a superset of this, so I mark this one a duplicate of 2385.