Bug #67290 mysqldump 5.5.27 throws error 1049 while dumping routines for db with spl chrs
Submitted: 18 Oct 2012 16:10 Modified: 29 Nov 2012 21:47
Reporter: Ravi Thati Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S1 (Critical)
Version:5.5.27, 5.5.30, 5.7.1, 5.1.67 OS:Linux (RHEL 5.5 linux2.6 (x86_64) )
Assigned to: CPU Architecture:Any
Tags: mysqldump, regression, routines, Special Characters

[18 Oct 2012 16:10] Ravi Thati
Description:
I have created a database with name ';havesinglequotes' (single quote at begin and end + a semicolon in it) with one table tb1.

For taking backup I ran the mysqldump with below arguments:

mysqldump --single-transaction --flush-logs --master-data=2 --create-options --default-character-set=utf8 --routines -u root --socket=/tmp/mysql.sock "';havesinglequotes'" -p 

The command fails while dumping routines. Complete output pasted below:

mysqldump --flush-logs --master-data=2 --create-options -B --default-character-set=utf8 --routines -u root --socket=/tmp/mysql.sock "';havesinglequotes'" -p 
Enter password: 
-- MySQL dump 10.13 Distrib 5.5.27, for linux2.6 (x86_64) 
-- 
-- Host: localhost Database: ';havesinglequotes' 
-- ------------------------------------------------------ 
-- Server version 5.5.27-log 

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 
/*!40101 SET NAMES utf8 */; 
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 
/*!40103 SET TIME_ZONE='+00:00' */; 
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 

-- 
-- Position to start replication or point-in-time recovery from 
-- 

-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000093', MASTER_LOG_POS=107; 

-- 
-- Current Database: `';havesinglequotes'` 
-- 

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `';havesinglequotes'` /*!40100 DEFAULT CHARACTER SET latin1 */; 

USE `';havesinglequotes'`; 

-- 
-- Table structure for table `tb1` 
-- 

DROP TABLE IF EXISTS `tb1`; 
/*!40101 SET @saved_cs_client = @@character_set_client */; 
/*!40101 SET character_set_client = utf8 */; 
CREATE TABLE `tb1` ( 
`i` int(11) DEFAULT NULL 
) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
/*!40101 SET character_set_client = @saved_cs_client */; 

-- 
-- Dumping data for table `tb1` 
-- 

LOCK TABLES `tb1` WRITE; 
/*!40000 ALTER TABLE `tb1` DISABLE KEYS */; 
INSERT INTO `tb1` VALUES (2); 
/*!40000 ALTER TABLE `tb1` ENABLE KEYS */; 
UNLOCK TABLES; 

-- 
-- Dumping routines for database '';havesinglequotes'' 
-- 
mysqldump: Couldn't execute 'use `\';havesinglequotes\'`': Unknown database '\';havesinglequotes\'' (1049) 

mysqldump version:
./bin/mysqldump -V
mysqldump  Ver 10.13 Distrib 5.5.27, for linux2.6 (x86_64)
Server version: 5.5.27-log MySQL Community Server (GPL)

How to repeat:

steps:
#1. create database `';havesinglequotes'`;

#2. use `';havesinglequotes'`;

#3.create a table tb1 of any arguments.

I created a table tb1 like below:
create table tb1(i int); and insert few rows

#4.Try to dump the database with routines. (Though the routines are not created here)
mysqldump --flush-logs --master-data=2 --create-options -B --default-character-set=utf8 --routines -u root --socket=/tmp/mysql.sock "';havesinglequotes'" -p 

#5. It will fail with below error:

-- 
-- Dumping routines for database '';havesinglequotes'' 
-- 
mysqldump: Couldn't execute 'use `\';havesinglequotes\'`': Unknown database '\';havesinglequotes\'' (1049)
[29 Nov 2012 21:47] Sveta Smirnova
Thank you for the report.

Verified as described.
[29 Nov 2012 21:47] Sveta Smirnova
test case for MTR

Attachment: bug67290.test (application/octet-stream, text), 243 bytes.