Bug #11936 Lock table failing create table ....select
Submitted: 14 Jul 2005 12:46 Modified: 17 Jul 2005 18:36
Reporter: Disha Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S2 (Serious)
Version:5.0.7-beta-nt/5.0.10 BK OS:Any (any)
Assigned to: Igor Babaev CPU Architecture:Any

[14 Jul 2005 12:46] Disha
Description:
Lock table function is not support to create table...select

How to repeat:
1. delimiter//
2. Execute following statments
	drop table res_t8//
	create table res_t8 (f1 char(1))//
	insert into res_t8 values ('a')//
	unlock tables//

	LOCK TABLE res_t8 read, res_t8 AS t1 WRITE//
	create table res_t9 select f1 from t1//
	unlock tables//

	LOCK TABLE res_t8 write, res_t8 AS t1 read//
	create table res_t9 select f1 from res_t8//
	unlock tables//

	LOCK TABLE res_t8 read//
	lock table res_t8 WRITE//
	create table res_t9 select f1 from res_t8//
	unlock tables//

	LOCK TABLE res_t8 read//
	create table res_t9 select f1 from res_t8//
	unlock tables//

	lock table res_t8 WRITE//
	create table res_t9 select f1 from res_t8//
	unlock tables//

Expected Results: 
	Table creation sucessfully

Actual Results: 
	ERROR 1100 (HY000): Table 'res_t9' was not locked with LOCK TABLES
[14 Jul 2005 14:15] MySQL Verification Team
Verified also on Linux and updating version.
[17 Jul 2005 18:36] Igor Babaev
The manual (13.4.6) says:
When you use LOCK TABLES, you must lock all tables that you are going to use in your queries. While the locks obtained with a LOCK TABLES statement are in effect, you cannot access any tables that were not locked by the statement. Also, you cannot use a locked table multiple times in one query --- use aliases for that. Note that in that case, you must get a lock for each alias separately.

Apprently you can't use CREATE TABLE after LOCK TABLES as the created table will not be locked.

So the reported case cannot be qualified as a bug.