List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:March 15 2011 10:54am
Subject:bzr push into mysql-trunk branch (jon.hauglid:3766 to 3767)
View as plain text  
 3767 Jon Olav Hauglid	2011-03-15 [merge]
      Merge from mysql-5.5 to mysql-trunk
      conflicts:
        Text conflict in mysql-test/extra/binlog_tests/database.test
        Text conflict in mysql-test/suite/binlog/r/binlog_database.result

    modified:
      mysql-test/extra/binlog_tests/database.test
      mysql-test/suite/binlog/r/binlog_database.result
      sql/sql_db.cc
 3766 Bjorn Munch	2011-03-15 [merge]
      Add warning suppression to test rpl.rpl_slave_load_remove_tmpfile

    modified:
      mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result
      mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test
=== modified file 'mysql-test/extra/binlog_tests/database.test'
--- a/mysql-test/extra/binlog_tests/database.test	2010-06-30 07:12:50 +0000
+++ b/mysql-test/extra/binlog_tests/database.test	2011-03-15 10:54:06 +0000
@@ -64,3 +64,31 @@ let $MYSQLD_DATADIR= `SELECT @@datadir`;
 --remove_file $MYSQLD_DATADIR/testing_1/fake_file.$prefix
 --echo # Now we can drop the database.
 DROP DATABASE testing_1;
+
+
+--echo #
+--echo # Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
+--echo #              BASED REPLICATION
+--echo #
+
+USE test;
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+CREATE TABLE db1.t2 (b INT, KEY(b)) engine=innodb;
+CREATE TABLE t3 (a INT, KEY (a), FOREIGN KEY(a) REFERENCES db1.t2(b))
+  engine=innodb;
+RESET MASTER;
+
+--error ER_ROW_IS_REFERENCED
+DROP DATABASE db1;                      # Fails because of the fk
+SHOW TABLES FROM db1;                   # t1 was dropped, t2 remains
+--source include/show_binlog_events.inc # Check that the binlog drops t1
+
+# Cleanup
+DROP TABLE t3;
+DROP DATABASE db1;

=== modified file 'mysql-test/suite/binlog/r/binlog_database.result'
--- a/mysql-test/suite/binlog/r/binlog_database.result	2010-08-20 03:37:42 +0000
+++ b/mysql-test/suite/binlog/r/binlog_database.result	2011-03-15 10:54:06 +0000
@@ -59,6 +59,29 @@ ERROR HY000: Error dropping database (ca
 # Remove the fake file.
 # Now we can drop the database.
 DROP DATABASE testing_1;
+#
+# Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
+#              BASED REPLICATION
+#
+USE test;
+DROP DATABASE IF EXISTS db1;
+DROP TABLE IF EXISTS t3;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+CREATE TABLE db1.t2 (b INT, KEY(b)) engine=innodb;
+CREATE TABLE t3 (a INT, KEY (a), FOREIGN KEY(a) REFERENCES db1.t2(b))
+engine=innodb;
+RESET MASTER;
+DROP DATABASE db1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+SHOW TABLES FROM db1;
+Tables_in_db1
+t2
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `db1`; DROP TABLE IF EXISTS `t1`
+DROP TABLE t3;
+DROP DATABASE db1;
 set binlog_format=mixed;
 reset master;
 create database testing_1;
@@ -120,6 +143,29 @@ ERROR HY000: Error dropping database (ca
 # Remove the fake file.
 # Now we can drop the database.
 DROP DATABASE testing_1;
+#
+# Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
+#              BASED REPLICATION
+#
+USE test;
+DROP DATABASE IF EXISTS db1;
+DROP TABLE IF EXISTS t3;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+CREATE TABLE db1.t2 (b INT, KEY(b)) engine=innodb;
+CREATE TABLE t3 (a INT, KEY (a), FOREIGN KEY(a) REFERENCES db1.t2(b))
+engine=innodb;
+RESET MASTER;
+DROP DATABASE db1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+SHOW TABLES FROM db1;
+Tables_in_db1
+t2
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `db1`; DROP TABLE IF EXISTS `t1`
+DROP TABLE t3;
+DROP DATABASE db1;
 set binlog_format=row;
 reset master;
 create database testing_1;
@@ -182,6 +228,29 @@ ERROR HY000: Error dropping database (ca
 # Remove the fake file.
 # Now we can drop the database.
 DROP DATABASE testing_1;
+#
+# Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
+#              BASED REPLICATION
+#
+USE test;
+DROP DATABASE IF EXISTS db1;
+DROP TABLE IF EXISTS t3;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+CREATE TABLE db1.t2 (b INT, KEY(b)) engine=innodb;
+CREATE TABLE t3 (a INT, KEY (a), FOREIGN KEY(a) REFERENCES db1.t2(b))
+engine=innodb;
+RESET MASTER;
+DROP DATABASE db1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+SHOW TABLES FROM db1;
+Tables_in_db1
+t2
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `db1`; DROP TABLE IF EXISTS `t1`
+DROP TABLE t3;
+DROP DATABASE db1;
 show databases;
 Database
 information_schema

=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc	2011-03-09 20:54:55 +0000
+++ b/sql/sql_db.cc	2011-03-15 10:54:06 +0000
@@ -834,12 +834,9 @@ bool mysql_rm_db(THD *thd,char *db,bool
   }
 
   thd->push_internal_handler(&err_handler);
-  if (thd->killed ||
-      (tables && mysql_rm_table_no_locks(thd, tables, true, false, true, true)))
-  {
-    tables= NULL;
-  }
-  else
+  if (!thd->killed &&
+      !(tables &&
+        mysql_rm_table_no_locks(thd, tables, true, false, true, true)))
   {
     /*
       We temporarily disable the binary log while dropping the objects
@@ -924,7 +921,7 @@ update_binlog:
     thd->server_status|= SERVER_STATUS_DB_DROPPED;
     my_ok(thd, deleted_tables);
   }
-  else if (mysql_bin_log.is_open())
+  else if (mysql_bin_log.is_open() && !silent)
   {
     char *query, *query_pos, *query_end, *query_data_start;
     TABLE_LIST *tbl;
@@ -939,6 +936,16 @@ update_binlog:
     for (tbl= tables; tbl; tbl= tbl->next_local)
     {
       uint tbl_name_len;
+      bool exists;
+
+      // Only write drop table to the binlog for tables that no longer exist.
+      if (check_if_table_exists(thd, tbl, &exists))
+      {
+        error= true;
+        goto exit;
+      }
+      if (exists)
+        continue;
 
       /* 3 for the quotes and the comma*/
       tbl_name_len= strlen(tbl->table_name) + 3;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (jon.hauglid:3766 to 3767) Jon Olav Hauglid15 Mar