Bug #2280 mysqldump doesn't quote CREATE TABLE lines for tables with a '-' in their name
Submitted: 5 Jan 2004 4:33 Modified: 14 Jan 2004 2:51
Reporter: Adam Langley Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S2 (Serious)
Version:4.0.16 OS:
Assigned to: Sergei Golubchik CPU Architecture:Any

[5 Jan 2004 4:33] Adam Langley
Description:
Tables with '-' in their name need to be quoted such as:

DROP TABLE IF EXISTS `Members02-03`;

(see the backticks). However, mysqldump doesn't do this for CREATE TABLE lines:

CREATE TABLE `Members02-03` (
  Id int(255) NOT NULL auto_increment,
<snip>

How to repeat:
Just do a mysqldump on a database with tables that have '-' in their name

Suggested fix:
quote it properly
[5 Jan 2004 7:34] MySQL Verification Team
Please us proper option for this:

 ./client/mysqldump --quote-names bug
-- MySQL dump 9.10
--
-- Host: localhost    Database: bug
-- ------------------------------------------------------
-- Server version       4.0.18-debug

--
-- Table structure for table `t1-t2`
--

CREATE TABLE `t1-t2` (
  `c1-cw` int(11) default NULL,
  `a b` int(11) default NULL,
  `id` int(11) default NULL
) TYPE=MyISAM;

--
-- Dumping data for table `t1-t2`
--
[5 Jan 2004 15:54] Sergei Golubchik
bug confirmed.
[6 Jan 2004 2:25] Sergei Golubchik
quoting Paul DuBois:

The situation is actually worse than what what reported in the bug
report.  QUOTE_CHAR is hardwired in the mysqldump source as '`'.
This means that if you run the server with --sql-mode=ANSI, you get
goofy output from mysqldump -Q like this:

DROP TABLE IF EXISTS `t`;
CREATE TABLE "t" (
  "i i" int(11) default NULL
);

Here the name is quoted in both statements, but inconsistently.

Not only that, if you have a database that needs to have its name quoted,
mysqldump --database writes out CREATE DATABASE IF EXISTS and USE
statements for the database, but those statements will use `name`
even when the server's running in ANSI mode.  Furthermore, SHOW CREATE
DATABASE will generate output with the ` character because (for some
reason) the SQL_QUOTE_SHOW_CREATE variable affects SHOW CREATE TABLE
only, not SHOW CREATE DATABASE.  So, SHOW CREATE returns differently   
quoted results, depending what it is you're showing.
[14 Jan 2004 2:51] Sergei Golubchik
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

fixed in 4.1.2