Bug #2989 mysqldump does not quote reserved words used as field names
Submitted: 26 Feb 2004 23:36 Modified: 26 Feb 2004 23:47
Reporter: Carsten Pedersen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S2 (Serious)
Version:4.0.17 OS:Any (Any)
Assigned to: CPU Architecture:Any

[26 Feb 2004 23:36] Carsten Pedersen
Description:
Field names are not quoted during dump. This creates problems on re-import of the data when reserved words have been used as identifiers

How to repeat:
mysql> show create table categories\G
*************************** 1. row ***************************
       Table: categories
Create Table: CREATE TABLE `categories` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `default` enum('y','n') default 'n',
  `cat_owner` int(10) unsigned default NULL,
  PRIMARY KEY  (`id`)
) TYPE=MyISAM
1 row in set (0.00 sec)

gets dumped as:

--
-- Table structure for table `categories`
--

CREATE TABLE categories (
  id int(10) unsigned NOT NULL auto_increment,
  name varchar(255) NOT NULL default '',
  default enum('y','n') default 'n',
  cat_owner int(10) unsigned default NULL,
  PRIMARY KEY  (id)
) TYPE=MyISAM;

- note how the "default" column is unquoted, this breaks re-import

Suggested fix:
quote all field names in mysqldump.

Workaround is to rename the field to a non-reserved word or edit the dump file manually to insert quotes.
[26 Feb 2004 23:47] Carsten Pedersen
Apparently, an old version of mysqldump was used during the dump