List:Commits« Previous MessageNext Message »
From:Nirbhay Choubey Date:January 24 2011 7:19pm
Subject:bzr commit into mysql-5.1 branch (nirbhay.choubey:3564) Bug#59398
View as plain text  
#At file:///home/nirbhay/Project/mysql/repo/bugs/source/mysql-5.1.59398/ based on revid:martin.hansson@stripped

 3564 Nirbhay Choubey	2011-01-25
      Bug#59398 : mysqldump 5.1 can't handle a dash ("-") in database
                  names in ALTER DATABASE.
      
      mysqldump did not quote database name in 'ALTER DATABASE'
      statements in its output. This can further cause a failure
      while loading if database name contains a hyphen '-'.
      
      This happened as, while printing the 'ALTER DATABASE'
      statements, the database name was not quoted.
      
      Fixed by quoting the database name.
     @ client/mysqldump.c
        Bug#59398 : mysqldump 5.1 can't handle a dash ("-") in database
                    names in ALTER DATABASE.
        
        Modified the print statement in order to print the quoted
        database name for 'ALTER DATABASE' statements.
     @ mysql-test/r/mysqldump.result
        Added a test case for bug#59398.
     @ mysql-test/t/mysqldump.test
        Added a test case for bug#59398.

    modified:
      client/mysqldump.c
      mysql-test/r/mysqldump.result
      mysql-test/t/mysqldump.test
=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2011-01-14 14:20:34 +0000
+++ b/client/mysqldump.c	2011-01-24 19:19:24 +0000
@@ -1134,6 +1134,9 @@ static int switch_db_collation(FILE *sql
 {
   if (strcmp(current_db_cl_name, required_db_cl_name) != 0)
   {
+    char quoted_database_buf[NAME_LEN*2+3];
+    char *qdatabase= quote_name(db_name, quoted_database_buf, 1);
+
     CHARSET_INFO *db_cl= get_charset_by_name(required_db_cl_name, MYF(0));
 
     if (!db_cl)
@@ -1141,7 +1144,7 @@ static int switch_db_collation(FILE *sql
 
     fprintf(sql_file,
             "ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
-            (const char *) db_name,
+            (const char *) qdatabase,
             (const char *) db_cl->csname,
             (const char *) db_cl->name,
             (const char *) delimiter);
@@ -1162,6 +1165,9 @@ static int restore_db_collation(FILE *sq
                                 const char *delimiter,
                                 const char *db_cl_name)
 {
+  char quoted_database_buf[NAME_LEN*2+3];
+  char *qdatabase= quote_name(db_name, quoted_database_buf, 1);
+
   CHARSET_INFO *db_cl= get_charset_by_name(db_cl_name, MYF(0));
 
   if (!db_cl)
@@ -1169,7 +1175,7 @@ static int restore_db_collation(FILE *sq
 
   fprintf(sql_file,
           "ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
-          (const char *) db_name,
+          (const char *) qdatabase,
           (const char *) db_cl->csname,
           (const char *) db_cl->name,
           (const char *) delimiter);

=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2011-01-14 14:20:34 +0000
+++ b/mysql-test/r/mysqldump.result	2011-01-24 19:19:24 +0000
@@ -4591,5 +4591,41 @@ CREATE TABLE `comment_table` (i INT COMM
 </mysqldump>
 DROP TABLE `comment_table`;
 #
+# Bug #59398 : mysqldump 5.1 can't handle a dash ("-") in 
+#              database names in ALTER DATABASE.
+#
+CREATE DATABASE `test-database`;
+USE `test-database`;
+CREATE TABLE `test` (`c1` VARCHAR(10)) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+CREATE TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
+END |
+ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci;
+ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `test` (
+  `c1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
+/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client  = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection  = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
+/*!50003 SET sql_mode              = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode              = @saved_sql_mode */ ;
+/*!50003 SET character_set_client  = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection  = @saved_col_connection */ ;
+ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+DROP DATABASE `test-database`;
+#
 # End of 5.1 tests
 #

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2011-01-14 14:20:34 +0000
+++ b/mysql-test/t/mysqldump.test	2011-01-24 19:19:24 +0000
@@ -2174,6 +2174,27 @@ CREATE TABLE `comment_table` (i INT COMM
 DROP TABLE `comment_table`;
 
 --echo #
+--echo # Bug #59398 : mysqldump 5.1 can't handle a dash ("-") in 
+--echo #              database names in ALTER DATABASE.
+--echo #
+
+CREATE DATABASE `test-database`;
+USE `test-database`;
+CREATE TABLE `test` (`c1` VARCHAR(10)) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DELIMITER |;
+CREATE TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
+END |
+DELIMITER ;|
+
+ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci;
+ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+
+--exec $MYSQL_DUMP --quote-names --compact test-database
+
+DROP DATABASE `test-database`;
+
+--echo #
 --echo # End of 5.1 tests
 --echo #
 


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1 branch (nirbhay.choubey:3564) Bug#59398Nirbhay Choubey24 Jan
  • Re: bzr commit into mysql-5.1 branch (nirbhay.choubey:3564)Bug#59398Sergey Vojtovich27 Jan