Bug #10919 Unable to use the AS keyword inside LOCK TABLES; ...; UNLOCK TABLES
Submitted: 27 May 2005 15:54 Modified: 28 May 2005 10:27
Reporter: Jaco Kroon Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:4.0.24 OS:GNU/Linux (Gentoo)
Assigned to: CPU Architecture:Any

[27 May 2005 15:54] Jaco Kroon
Description:
The following interaction with the MySQL client illustrates

mysql> LOCK TABLES module READ, application_marks READ;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM module AS the_module;
ERROR 1100: Table 'the_module' was not locked with LOCK TABLES
mysql> UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)

mysql> LOCK TABLES module READ, application_marks READ, the_module READ;
ERROR 1146: Table 'csweb.the_module' doesn't exist
mysql> 

The above is obviously watered down, the real query cannot work without using AS and it really needs to be inside a LOCK.

Thanks for the immediate attention.

How to repeat:
The bug can be repeated by using MySQL 4.0.24 (and possibly other versions).  The table I'm using can be created using:

CREATE TABLE module (
  code varchar(20) default NULL,
  name varchar(255) NOT NULL default '',
  lecturerUid int(11) NOT NULL default '0',
  descript_long text,
  semester smallint(6) NOT NULL default '0',
  mod_id int(11) NOT NULL auto_increment,
  hasWebCt tinyint(4) default NULL,
  yg_id int(11) default NULL,
  protect_uploads tinyint(1) default '1',
  descript_short text NOT NULL,
  hidden tinyint(3) unsigned NOT NULL default '0',
  last_updated int(10) unsigned NOT NULL default '0',
  group_id int(11) default NULL,
  PRIMARY KEY  (mod_id),
  KEY mod_id (mod_id),
  KEY group_id (group_id)
) TYPE=MyISAM;

Then simply run the queries as shown above.
[28 May 2005 10:27] Alexander Keremidarski
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php