Bug #393 User variables do not work with CREATE TALBE or DROP TABLE
Submitted: 7 May 2003 18:39 Modified: 22 May 2003 11:05
Reporter: Steve Maze Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:4.0.12-nt OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[7 May 2003 18:39] Steve Maze
Description:
Using a user variable for the table name in CREATE TABLE or DROP TABLE statement results in a 1064 error.  The same result occurs using a variable for the table or file name in LOAD DATA INFILE although this is not reproduced in the attached script.

How to repeat:
use test;

SET @table = 'src_db';

CREATE TABLE src_cd (
  `Src_Cd` char(3) NOT NULL default '',
  `SrcCd_Desc` varchar(60) NOT NULL default '',
  PRIMARY KEY  (`Src_Cd`)
) TYPE=InnoDB; 
DROP TABLE src_cd;

-- All works well to here --

CREATE TABLE src_cd (
  `Src_Cd` char(3) NOT NULL default '',
  `SrcCd_Desc` varchar(60) NOT NULL default '',
  PRIMARY KEY  (`Src_Cd`)
) TYPE=InnoDB; 
DROP TABLE @table;
DROP TABLE IF EXISTS `src_cd`;

-- The above DROP TABLE statement causes a 1064 error --

CREATE TABLE @table (
  `Src_Cd` char(3) NOT NULL default '',
  `SrcCd_Desc` varchar(60) NOT NULL default '',
  PRIMARY KEY  (`Src_Cd`)
) TYPE=InnoDB; 
DROP TABLE IF EXISTS `src_cd`;

-- The above CREATE TABLE statement causes a 1064 error --

Suggested fix:
Allow the use of variable for table, field, file names, etc. in all statements.
[7 May 2003 18:40] Steve Maze
Corrected synopsis.
[22 May 2003 11:05] MySQL Verification Team
This isn't a bug and it is the expected behavior due to
security reasons.