[Commits] Rev 3371: Fixed bug mdev-485. in file:///home/igor/maria/maria-5.5-mwl248-bugs/

Igor Babaev igor at askmonty.org
Tue Sep 11 08:22:58 EEST 2012


At file:///home/igor/maria/maria-5.5-mwl248-bugs/

------------------------------------------------------------
revno: 3371
revision-id: igor at askmonty.org-20120911052257-dwvlkqef3qvyc70o
parent: igor at askmonty.org-20120909053655-o3c6jp4ihihti8w3
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.5-mwl248-bugs
timestamp: Mon 2012-09-10 22:22:57 -0700
message:
  Fixed bug mdev-485.
  RBR should be turned off when statistical tables are modified 
  in the result of the execution of a DDL statement.
  Revised the fix for bug mdev-463. Ensured suppression of RBR
  for the modifications of the statistical tables triggered
  by the execution of any analyze operation.
-------------- next part --------------
=== modified file 'mysql-test/r/stat_tables_rbr.result'
--- a/mysql-test/r/stat_tables_rbr.result	2012-08-20 19:05:37 +0000
+++ b/mysql-test/r/stat_tables_rbr.result	2012-09-11 05:22:57 +0000
@@ -8,3 +8,18 @@
 test.t1	analyze	status	OK
 DROP TABLE t1;
 SET GLOBAL use_stat_tables = DEFAULT;
+SET use_stat_tables = PREFERABLY;
+CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
+ALTER TABLE t1 ANALYZE PARTITION p1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+SHOW BINLOG EVENTS;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	4	Format_desc	1	245	Server ver: 5.5.27-MariaDB-debug-log, Binlog ver: 4
+master-bin.000001	245	Query	1	345	use `test`; CREATE TABLE t1 (i INT) ENGINE=InnoDB
+master-bin.000001	345	Query	1	424	use `test`; ANALYZE TABLE t1
+master-bin.000001	424	Query	1	528	use `test`; DROP TABLE `t1` /* generated by server */
+master-bin.000001	528	Query	1	664	use `test`; CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2
+master-bin.000001	664	Query	1	762	use `test`; ALTER TABLE t1 ANALYZE PARTITION p1
+SET use_stat_tables = DEFAULT;
+DROP TABLE t1;

=== added file 'mysql-test/r/stat_tables_repl.result'
--- a/mysql-test/r/stat_tables_repl.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/stat_tables_repl.result	2012-09-11 05:22:57 +0000
@@ -0,0 +1,41 @@
+include/master-slave.inc
+[connection master]
+#
+# Bug mdev-485: unexpected failure with replication of DROP/ALTER table
+#               when RBR is on
+#
+CREATE TABLE t1 ( a int, b int ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+DROP TABLE t1;
+CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+DROP INDEX idx1 ON t1;
+DROP TABLE t1;
+CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+ALTER TABLE t1 DROP COLUMN b;
+DROP TABLE t1;
+CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+ALTER TABLE t1 RENAME to s;
+DROP TABLE s;
+CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+ALTER TABLE t1 CHANGE COLUMN b c int ;
+DROP TABLE t1;
+include/rpl_end.inc

=== modified file 'mysql-test/t/stat_tables_rbr.test'
--- a/mysql-test/t/stat_tables_rbr.test	2012-08-20 19:05:37 +0000
+++ b/mysql-test/t/stat_tables_rbr.test	2012-09-11 05:22:57 +0000
@@ -1,5 +1,6 @@
 --source include/have_binlog_format_row.inc
 --source include/have_innodb.inc
+--source include/have_partition.inc
 
 --echo #
 --echo # Bug mdev-463: assertion failure when running ANALYZE with RBR on
@@ -16,3 +17,14 @@
 SET GLOBAL use_stat_tables = DEFAULT;
 --disconnect con1
 
+--connection default
+
+SET use_stat_tables = PREFERABLY;
+
+CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
+ALTER TABLE t1 ANALYZE PARTITION p1;
+SHOW BINLOG EVENTS;
+
+SET use_stat_tables = DEFAULT;
+
+DROP TABLE t1;

=== added file 'mysql-test/t/stat_tables_repl.test'
--- a/mysql-test/t/stat_tables_repl.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/stat_tables_repl.test	2012-09-11 05:22:57 +0000
@@ -0,0 +1,58 @@
+--source include/have_stat_tables.inc
+--source include/master-slave.inc
+--source include/have_binlog_format_row.inc
+
+--echo #
+--echo # Bug mdev-485: unexpected failure with replication of DROP/ALTER table
+--echo #               when RBR is on
+--echo #
+
+CREATE TABLE t1 ( a int, b int ) ENGINE=MyISAM; 
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+DROP TABLE t1;
+
+--sync_slave_with_master
+--connection master
+
+CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+DROP INDEX idx1 ON t1;
+
+--sync_slave_with_master
+--connection master
+
+DROP TABLE t1;
+
+CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+ALTER TABLE t1 DROP COLUMN b;
+
+--sync_slave_with_master
+--connection master
+
+DROP TABLE t1;
+
+CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+ALTER TABLE t1 RENAME to s;
+
+--sync_slave_with_master
+--connection master
+
+DROP TABLE s;
+
+CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
+ANALYZE TABLE t1;
+ALTER TABLE t1 CHANGE COLUMN b c int ;
+
+--sync_slave_with_master
+--connection master
+
+DROP TABLE t1;
+
+--source include/rpl_end.inc

=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc	2012-08-30 01:50:38 +0000
+++ b/sql/sql_admin.cc	2012-09-11 05:22:57 +0000
@@ -323,7 +323,6 @@
   int result_code;
   int compl_result_code;
   bool need_repair_or_alter= 0;
-  bool save_binlog_row_based= 0;
 
   DBUG_ENTER("mysql_admin_table");
   DBUG_PRINT("enter", ("extra_open_options: %u", extra_open_options));
@@ -418,11 +417,6 @@
         */
 
         open_error= open_and_lock_tables(thd, table, TRUE, 0);
-        if (lex->sql_command == SQLCOM_ANALYZE)
-	{
-          if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
-            thd->clear_current_stmt_binlog_format_row();
-        }
       }
       thd->prepare_derived_at_open= FALSE;
 
@@ -962,8 +956,6 @@
     trans_commit_stmt(thd);
     trans_commit_implicit(thd);
     close_thread_tables(thd);
-    if (save_binlog_row_based)
-      thd->set_current_stmt_binlog_format_row();
     thd->mdl_context.release_transactional_locks();
 
     /*
@@ -996,8 +988,6 @@
   trans_rollback_stmt(thd);
   trans_rollback(thd);
   close_thread_tables(thd);			// Shouldn't be needed
-  if (save_binlog_row_based)
-    thd->set_current_stmt_binlog_format_row();
   thd->mdl_context.release_transactional_locks();
   if (table)
     table->table=0;

=== modified file 'sql/sql_statistics.cc'
--- a/sql/sql_statistics.cc	2012-09-09 03:33:03 +0000
+++ b/sql/sql_statistics.cc	2012-09-11 05:22:57 +0000
@@ -2171,6 +2171,7 @@
   Open_tables_backup open_tables_backup;
   uint i;
   int err;
+  bool save_binlog_row_based;
   int rc= 0;
   TABLE *stat_table;
 
@@ -2187,6 +2188,9 @@
     DBUG_RETURN(rc);
   }
    
+  if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+    thd->clear_current_stmt_binlog_format_row();
+
   /* Update the statistical table table_stat */
   stat_table= tables[TABLE_STAT].table;
   Table_stat table_stat(stat_table, table);
@@ -2231,6 +2235,9 @@
     }
   }
 
+  if (save_binlog_row_based)
+    thd->set_current_stmt_binlog_format_row();
+
   close_system_tables(thd, &open_tables_backup);
 
   DBUG_RETURN(rc);
@@ -2510,6 +2517,7 @@
 int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab)
 {
   int err;
+  bool save_binlog_row_based;
   TABLE *stat_table;
   TABLE_LIST tables[STATISTICS_TABLES];
   Open_tables_backup open_tables_backup;
@@ -2528,6 +2536,9 @@
     DBUG_RETURN(rc);
   }
 
+  if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+    thd->clear_current_stmt_binlog_format_row();
+
   /* Delete statistics on table from the statistical table index_stat */
   stat_table= tables[INDEX_STAT].table;
   Index_stat index_stat(stat_table, db, tab);
@@ -2561,6 +2572,9 @@
       rc= 1;
   }
 
+  if (save_binlog_row_based)
+    thd->set_current_stmt_binlog_format_row();
+
   close_system_tables(thd, &open_tables_backup);
 
   DBUG_RETURN(rc);
@@ -2595,6 +2609,7 @@
 int delete_statistics_for_column(THD *thd, TABLE *tab, Field *col)
 {
   int err;
+  bool save_binlog_row_based;
   TABLE *stat_table;
   TABLE_LIST tables;
   Open_tables_backup open_tables_backup;
@@ -2613,6 +2628,9 @@
     DBUG_RETURN(rc);
   }
 
+  if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+    thd->clear_current_stmt_binlog_format_row();
+
   stat_table= tables.table;
   Column_stat column_stat(stat_table, tab);
   column_stat.set_key_fields(col);
@@ -2623,6 +2641,9 @@
       rc= 1;
   }
 
+  if (save_binlog_row_based)
+    thd->set_current_stmt_binlog_format_row();
+
   close_system_tables(thd, &open_tables_backup);
 
   DBUG_RETURN(rc);
@@ -2657,6 +2678,7 @@
 int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info)
 {
   int err;
+  bool save_binlog_row_based;
   TABLE *stat_table;
   TABLE_LIST tables;
   Open_tables_backup open_tables_backup;
@@ -2675,6 +2697,9 @@
     DBUG_RETURN(rc);
   }
 
+  if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+    thd->clear_current_stmt_binlog_format_row();
+
   stat_table= tables.table;
   Index_stat index_stat(stat_table, tab);
   index_stat.set_index_prefix_key_fields(key_info);
@@ -2685,6 +2710,9 @@
       rc= 1;
   }
 
+  if (save_binlog_row_based)
+    thd->set_current_stmt_binlog_format_row();
+
   close_system_tables(thd, &open_tables_backup);
 
   DBUG_RETURN(rc);
@@ -2722,6 +2750,7 @@
                                 LEX_STRING *new_db, LEX_STRING *new_tab)
 {
   int err;
+  bool save_binlog_row_based;
   TABLE *stat_table;
   TABLE_LIST tables[STATISTICS_TABLES];
   Open_tables_backup open_tables_backup;
@@ -2740,6 +2769,9 @@
     DBUG_RETURN(rc);
   }
 
+  if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+    thd->clear_current_stmt_binlog_format_row();
+
   /* Rename table in the statistical table index_stat */
   stat_table= tables[INDEX_STAT].table;
   Index_stat index_stat(stat_table, db, tab);
@@ -2775,6 +2807,9 @@
       rc= 1;
   }
 
+  if (save_binlog_row_based)
+    thd->set_current_stmt_binlog_format_row();
+
   close_system_tables(thd, &open_tables_backup);
 
   DBUG_RETURN(rc);
@@ -2812,6 +2847,7 @@
                                  const char *new_name)
 {
   int err;
+  bool save_binlog_row_based;
   TABLE *stat_table;
   TABLE_LIST tables;
   Open_tables_backup open_tables_backup;
@@ -2830,6 +2866,9 @@
     DBUG_RETURN(rc);
   }
 
+  if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
+    thd->clear_current_stmt_binlog_format_row();
+
   /* Rename column in the statistical table table_stat */
   stat_table= tables.table;
   Column_stat column_stat(stat_table, tab);
@@ -2840,6 +2879,10 @@
     if (err & !rc)
       rc= 1;
   }
+
+  if (save_binlog_row_based)
+    thd->set_current_stmt_binlog_format_row();
+
   close_system_tables(thd, &open_tables_backup);
 
   DBUG_RETURN(rc);



More information about the commits mailing list