List:Commits« Previous MessageNext Message »
From:Nirbhay Choubey Date:February 21 2011 7:33am
Subject:bzr push into mysql-trunk branch (nirbhay.choubey:3681 to 3683)
View as plain text  
 3683 Nirbhay Choubey	2011-02-21
      Post fix for mysqldump test.

    modified:
      mysql-test/r/mysqldump.result
      mysql-test/t/mysqldump.test
 3682 Nirbhay Choubey	2011-02-21 [merge]
      Merge of fix for bug#11766310 from mysql-5.5 -> mysql-trunk.

    modified:
      client/mysqldump.c
      mysql-test/r/mysqldump.result
      mysql-test/t/mysqldump.test
 3681 Libing Song	2011-02-21
      WL#5576 Prohibit CREATE TABLE ... SELECT to modify other tables
      BUG#11749792 and BUG#11763193 are fixed by this worklog.
            
      In 'CREATE TABLE ... SELECT' statement, SELECT clause could call store functions
      to modify other tables. It made CTS's behavior towards complex and not
      understandable. It also caused some binlogging problem. So the behavior modifying
      other tables is prohibited in this worklog.
            
      In this patch, code is added to check if there is any other table owning WRITE
      lock just after all tables have been locked. CREATE TABLE ... SELECT will fail
      and print an error immediately if any other table has WRITE lock.
      As SELECT ... FOR UPDATE uses WRITE lock too. FOR UPDATE clause is also
      prohibited in CREATE TABLE ... SELECT statement.
     @ mysql-test/include/unsafe_binlog.inc
        The CREATE TABLE ... SELECT with a store function which updates
        other tables fails with a new error added by WL#5576.
     @ mysql-test/r/create.result
        Added test to verify WL#5576.
     @ mysql-test/r/func_rollback.result
        The CREATE TABLE ... SELECT with a store function which updates 
        other tables fails with a new error added by WL#5576.
     @ mysql-test/r/mdl_sync.result
        The CREATE TABLE ... SELECT with a store function which updates 
        other tables fails with a new error added by WL#5576.
     @ mysql-test/r/unsafe_binlog_innodb.result
        The CREATE TABLE ... SELECT with a store function which updates 
        other tables fails with a new error added by WL#5576.
     @ mysql-test/suite/innodb/r/innodb.result
        The CREATE TABLE ... SELECT with a store function which updates 
        other tables fails with a new error added by WL#5576.
     @ mysql-test/suite/innodb/t/innodb.test
        The CREATE TABLE ... SELECT with a store function which updates 
        other tables fails with a new error added by WL#5576.
     @ mysql-test/t/create.test
        Added test to verify WL#5576.
     @ mysql-test/t/func_rollback.test
        The CREATE TABLE ... SELECT with a store function which updates
        other tables fails with a new error added by WL#5576.
     @ mysql-test/t/mdl_sync.test
        'FOR UPDATE' is disallowed in CREATE TABLE ... SELECT statement
        after WL#5576. Using a new method to lock the table.
     @ sql/share/errmsg-utf8.txt
        Added a new error for WL#5576.
     @ sql/sql_parse.cc
        Implemented WL#5576.

    modified:
      mysql-test/include/unsafe_binlog.inc
      mysql-test/r/create.result
      mysql-test/r/func_rollback.result
      mysql-test/r/mdl_sync.result
      mysql-test/r/unsafe_binlog_innodb.result
      mysql-test/suite/innodb/r/innodb.result
      mysql-test/suite/innodb/t/innodb.test
      mysql-test/t/create.test
      mysql-test/t/func_rollback.test
      mysql-test/t/mdl_sync.test
      sql/share/errmsg-utf8.txt
      sql/sql_parse.cc
=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2011-01-16 04:02:29 +0000
+++ b/client/mysqldump.c	2011-02-21 07:15:46 +0000
@@ -1164,6 +1164,9 @@ static int switch_db_collation(FILE *sql
 {
   if (strcmp(current_db_cl_name, required_db_cl_name) != 0)
   {
+    char quoted_db_buf[NAME_LEN * 2 + 3];
+    char *quoted_db_name= quote_name(db_name, quoted_db_buf, FALSE);
+
     CHARSET_INFO *db_cl= get_charset_by_name(required_db_cl_name, MYF(0));
 
     if (!db_cl)
@@ -1171,7 +1174,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 *) quoted_db_name,
             (const char *) db_cl->csname,
             (const char *) db_cl->name,
             (const char *) delimiter);
@@ -1192,6 +1195,9 @@ static int restore_db_collation(FILE *sq
                                 const char *delimiter,
                                 const char *db_cl_name)
 {
+  char quoted_db_buf[NAME_LEN * 2 + 3];
+  char *quoted_db_name= quote_name(db_name, quoted_db_buf, FALSE);
+
   CHARSET_INFO *db_cl= get_charset_by_name(db_cl_name, MYF(0));
 
   if (!db_cl)
@@ -1199,7 +1205,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 *) quoted_db_name,
           (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:49:16 +0000
+++ b/mysql-test/r/mysqldump.result	2011-02-21 07:28:19 +0000
@@ -4596,11 +4596,48 @@ CREATE TABLE `comment_table` (i INT COMM
 </mysqldump>
 DROP TABLE `comment_table`;
 #
+# BUG#11766310 : 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
 #
 #
 # Test for --add-drop-trigger
 #
+USE `test`;
 CREATE TABLE t1 (a int, b int);
 CREATE TRIGGER tt1_t1 BEFORE INSERT ON t1 FOR EACH ROW 
 SET NEW.b=NEW.a + 10;

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2011-01-14 14:49:16 +0000
+++ b/mysql-test/t/mysqldump.test	2011-02-21 07:28:19 +0000
@@ -2191,13 +2191,34 @@ CREATE TABLE `comment_table` (i INT COMM
 DROP TABLE `comment_table`;
 
 --echo #
+--echo # BUG#11766310 : 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 #
 
 --echo #
 --echo # Test for --add-drop-trigger
 --echo #
-
+USE `test`;
 CREATE TABLE t1 (a int, b int);
 CREATE TRIGGER tt1_t1 BEFORE INSERT ON t1 FOR EACH ROW 
   SET NEW.b=NEW.a + 10;


Attachment: [text/bzr-bundle]
Thread
bzr push into mysql-trunk branch (nirbhay.choubey:3681 to 3683)Nirbhay Choubey21 Feb