List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:December 1 2010 6:11pm
Subject:bzr commit into mysql-trunk-wl4896 branch (chris.powers:3207)
View as plain text  
#At file:///home/cpowers/work/dev/base_mysql-trunk-wl4896/ based on revid:chris.powers@stripped

 3207 Christopher Powers	2010-12-01 [merge]
      merge

    added:
      mysql-test/collections/mysql-next-mr-wl2540.push
      mysql-test/collections/mysql-trunk.daily
      mysql-test/collections/mysql-trunk.weekly
      mysql-test/extra/rpl_tests/rpl_change_master.test
      mysql-test/extra/rpl_tests/rpl_crash_safe.inc
      mysql-test/extra/rpl_tests/rpl_crash_safe.test
      mysql-test/include/have_binlog_checksum_off.inc
      mysql-test/include/not_master_info_table.inc
      mysql-test/include/not_relay_log_info_table.inc
      mysql-test/suite/binlog/r/binlog_checksum.result
      mysql-test/suite/binlog/t/binlog_checksum.test
      mysql-test/suite/rpl/extension/README.checksum
      mysql-test/suite/rpl/extension/checksum.pl
      mysql-test/suite/rpl/r/rpl_change_master_crash_safe.result
      mysql-test/suite/rpl/r/rpl_checksum.result
      mysql-test/suite/rpl/r/rpl_checksum_cache.result
      mysql-test/suite/rpl/r/rpl_corruption.result
      mysql-test/suite/rpl/r/rpl_migration_crash_safe.result
      mysql-test/suite/rpl/r/rpl_mixed_crash_safe.result
      mysql-test/suite/rpl/r/rpl_row_crash_safe.result
      mysql-test/suite/rpl/r/rpl_stm_crash_safe.result
      mysql-test/suite/rpl/t/rpl_change_master_crash_safe-slave.opt
      mysql-test/suite/rpl/t/rpl_change_master_crash_safe.test
      mysql-test/suite/rpl/t/rpl_checksum-master.opt
      mysql-test/suite/rpl/t/rpl_checksum.test
      mysql-test/suite/rpl/t/rpl_checksum_cache.test
      mysql-test/suite/rpl/t/rpl_corruption-master.opt
      mysql-test/suite/rpl/t/rpl_corruption-slave.opt
      mysql-test/suite/rpl/t/rpl_corruption.test
      mysql-test/suite/rpl/t/rpl_migration_crash_safe.test
      mysql-test/suite/rpl/t/rpl_mixed_crash_safe-slave.opt
      mysql-test/suite/rpl/t/rpl_mixed_crash_safe.test
      mysql-test/suite/rpl/t/rpl_row_crash_safe-slave.opt
      mysql-test/suite/rpl/t/rpl_row_crash_safe.test
      mysql-test/suite/rpl/t/rpl_stm_crash_safe-slave.opt
      mysql-test/suite/rpl/t/rpl_stm_crash_safe.test
      mysql-test/suite/sys_vars/r/binlog_checksum_basic.result
      mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result
      mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result
      mysql-test/suite/sys_vars/t/binlog_checksum_basic.test
      mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test
      mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test
      sql/rpl_info_table.cc
      sql/rpl_info_table.h
      sql/rpl_info_table_access.cc
      sql/rpl_info_table_access.h
      sql/rpl_info_values.cc
      sql/rpl_info_values.h
    modified:
      client/mysqlbinlog.cc
      client/mysqldump.c
      libmysqld/CMakeLists.txt
      libmysqld/Makefile.am
      mysql-test/collections/default.experimental
      mysql-test/extra/binlog_tests/binlog.test
      mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
      mysql-test/extra/rpl_tests/rpl_conflicts.test
      mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
      mysql-test/extra/rpl_tests/rpl_reset_slave.test
      mysql-test/extra/rpl_tests/rpl_start_stop_slave.test
      mysql-test/include/mtr_warnings.sql
      mysql-test/r/1st.result
      mysql-test/r/connect.result
      mysql-test/r/information_schema.result
      mysql-test/r/log_tables.result
      mysql-test/r/log_tables_upgrade.result
      mysql-test/r/mysql_upgrade.result
      mysql-test/r/mysql_upgrade_ssl.result
      mysql-test/r/mysqlcheck.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/system_mysql_db.result
      mysql-test/suite/binlog/r/binlog_killed.result
      mysql-test/suite/binlog/r/binlog_old_versions.result
      mysql-test/suite/binlog/r/binlog_row_binlog.result
      mysql-test/suite/binlog/r/binlog_stm_binlog.result
      mysql-test/suite/binlog/t/binlog_killed.test
      mysql-test/suite/binlog/t/binlog_old_versions.test
      mysql-test/suite/binlog/t/disabled.def
      mysql-test/suite/funcs_1/r/is_columns_mysql.result
      mysql-test/suite/funcs_1/r/is_key_column_usage.result
      mysql-test/suite/funcs_1/r/is_statistics.result
      mysql-test/suite/funcs_1/r/is_statistics_mysql.result
      mysql-test/suite/funcs_1/r/is_table_constraints.result
      mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result
      mysql-test/suite/funcs_1/r/is_tables_mysql.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result
      mysql-test/suite/rpl/r/rpl_change_master.result
      mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
      mysql-test/suite/rpl/r/rpl_rotate_logs.result
      mysql-test/suite/rpl/r/rpl_row_conflicts.result
      mysql-test/suite/rpl/r/rpl_server_uuid.result
      mysql-test/suite/rpl/t/disabled.def
      mysql-test/suite/rpl/t/rpl_change_master.test
      mysql-test/suite/rpl/t/rpl_flushlog_loop.test
      mysql-test/suite/rpl/t/rpl_heartbeat_basic.test
      mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
      mysql-test/suite/rpl/t/rpl_rotate_logs.test
      mysql-test/suite/rpl/t/rpl_row_ignorable_event.test
      mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
      mysql-test/suite/rpl/t/rpl_seconds_behind_master.test
      mysql-test/suite/rpl/t/rpl_server_uuid.test
      mysql-test/suite/rpl/t/rpl_show_master_info_file.test
      mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
      mysql-test/suite/rpl/t/rpl_sync.test
      mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test
      mysql-test/suite/sys_vars/t/all_vars.test
      mysql-test/suite/sys_vars/t/master_info_repository_basic.test
      mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test
      mysql-test/t/mysqlbinlog2.test
      mysql-test/t/system_mysql_db_fix40123.test
      mysql-test/t/system_mysql_db_fix50030.test
      mysql-test/t/system_mysql_db_fix50117.test
      scripts/mysql_install_db.pl.in
      scripts/mysql_install_db.sh
      scripts/mysql_system_tables.sql
      sql/CMakeLists.txt
      sql/Makefile.am
      sql/binlog.cc
      sql/binlog.h
      sql/lock.cc
      sql/log.cc
      sql/log_event.cc
      sql/log_event.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/rpl_info.h
      sql/rpl_info_factory.cc
      sql/rpl_info_factory.h
      sql/rpl_info_file.cc
      sql/rpl_info_file.h
      sql/rpl_info_handler.cc
      sql/rpl_info_handler.h
      sql/rpl_master.cc
      sql/rpl_mi.cc
      sql/rpl_mi.h
      sql/rpl_rli.cc
      sql/rpl_rli.h
      sql/rpl_slave.cc
      sql/rpl_slave.h
      sql/rpl_utility.cc
      sql/server_ids.h
      sql/share/errmsg-utf8.txt
      sql/sql_base.cc
      sql/sql_base.h
      sql/sql_binlog.cc
      sql/sql_class.h
      sql/sql_parse.cc
      sql/sql_parse.h
      sql/sys_vars.cc
      sql/sys_vars.h
      sql/table.cc
      sql/table.h
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2010-11-08 02:49:16 +0000
+++ b/client/mysqlbinlog.cc	2010-11-16 12:14:06 +0000
@@ -80,6 +80,7 @@ static my_bool force_opt= 0, short_form=
 static my_bool debug_info_flag, debug_check_flag;
 static my_bool force_if_open_opt= 1, raw_mode= 0;
 static my_bool to_last_remote_log= 0, stop_never= 0;
+static my_bool opt_verify_binlog_checksum= 1;
 static ulonglong offset = 0;
 static uint stop_never_server_id= 1;
 static char* host = 0;
@@ -1148,6 +1149,9 @@ static struct my_option my_long_options[
    "Used to reserve file descriptors for use by this program.",
    &open_files_limit, &open_files_limit, 0, GET_ULONG,
    REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0},
+  {"verify-binlog-checksum", 'c', "Verify checksum binlog events.",
+   (uchar**) &opt_verify_binlog_checksum, (uchar**) &opt_verify_binlog_checksum,
+   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"binlog-row-event-max-size", OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
    "The maximum size of a row-based binary log event in bytes. Rows will be "
    "grouped into events smaller than this size if possible. "
@@ -1494,7 +1498,18 @@ static Exit_status check_master_version(
           "Master reported NULL for the version.");
     goto err;
   }
-
+  /* 
+     Make a notice to the server that this client
+     is checksum-aware. It does not need the first fake Rotate
+     necessary checksummed. 
+     That preference is specified below.
+  */
+  if (mysql_query(mysql, "SET @master_binlog_checksum='NONE'"))
+  {
+    error("Could not notify master about checksum awareness."
+          "Master returned '%s'", mysql_error(mysql));
+    goto err;
+  }
   delete glob_description_event;
   switch (*version) {
   case '3':
@@ -1630,7 +1645,8 @@ static Exit_status dump_remote_log_entri
     {
       if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
                                           len - 1, &error_msg,
-                                          glob_description_event)))
+                                          glob_description_event,
+                                          opt_verify_binlog_checksum)))
       {
         error("Could not construct log event object: %s", error_msg);
         DBUG_RETURN(ERROR_STOP);
@@ -1905,7 +1921,8 @@ static Exit_status check_header(IO_CACHE
         Format_description_log_event *new_description_event;
         my_b_seek(file, tmp_pos); /* seek back to event's start */
         if (!(new_description_event= (Format_description_log_event*) 
-              Log_event::read_log_event(file, glob_description_event)))
+              Log_event::read_log_event(file, glob_description_event,
+                                        opt_verify_binlog_checksum)))
           /* EOF can't be hit here normally, so it's a real error */
         {
           error("Could not read a Format_description_log_event event at "
@@ -1937,7 +1954,8 @@ static Exit_status check_header(IO_CACHE
       {
         Log_event *ev;
         my_b_seek(file, tmp_pos); /* seek back to event's start */
-        if (!(ev= Log_event::read_log_event(file, glob_description_event)))
+        if (!(ev= Log_event::read_log_event(file, glob_description_event,
+                                            opt_verify_binlog_checksum)))
         {
           /* EOF can't be hit here normally, so it's a real error */
           error("Could not read a Rotate_log_event event at offset %llu;"
@@ -2050,7 +2068,8 @@ static Exit_status dump_local_log_entrie
     char llbuff[21];
     my_off_t old_off = my_b_tell(file);
 
-    Log_event* ev = Log_event::read_log_event(file, glob_description_event);
+    Log_event* ev = Log_event::read_log_event(file, glob_description_event,
+                                              opt_verify_binlog_checksum);
     if (!ev)
     {
       /*

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2010-10-25 13:49:55 +0000
+++ b/client/mysqldump.c	2010-11-15 16:43:41 +0000
@@ -902,7 +902,11 @@ static int get_options(int *argc, char *
       my_hash_insert(&ignore_table,
                      (uchar*) my_strdup("mysql.general_log", MYF(MY_WME))) ||
       my_hash_insert(&ignore_table,
-                     (uchar*) my_strdup("mysql.slow_log", MYF(MY_WME))))
+                     (uchar*) my_strdup("mysql.slow_log", MYF(MY_WME))) ||
+      my_hash_insert(&ignore_table,
+                     (uchar*) my_strdup("mysql.slave_master_info", MYF(MY_WME))) ||
+      my_hash_insert(&ignore_table,
+                     (uchar*) my_strdup("mysql.slave_relay_log_info", MYF(MY_WME))))
     return(EX_EOM);
 
   if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))

=== modified file 'libmysqld/CMakeLists.txt'
--- a/libmysqld/CMakeLists.txt	2010-11-04 15:40:18 +0000
+++ b/libmysqld/CMakeLists.txt	2010-11-16 12:14:06 +0000
@@ -86,8 +86,8 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc l
            ../sql/sql_alter.cc ../sql/sql_partition_admin.cc
            ../sql/event_parse_data.cc
            ../sql/sql_signal.cc ../sql/rpl_handler.cc
-           ../sql/rpl_utility.cc ../sql/binlog.cc ../sql/sys_vars.cc
-           ../sql/gcalc_slicescan.cc ../sql/gcalc_tools.cc
+           ../sql/rpl_utility.cc ../sql/rpl_reporting.cc ../sql/binlog.cc 
+           ../sql/sys_vars.cc ../sql/gcalc_slicescan.cc ../sql/gcalc_tools.cc
            ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
            ../sql/mdl.cc ../sql/transaction.cc ../sql/sql_bootstrap.cc
            ${GEN_SOURCES}

=== modified file 'libmysqld/Makefile.am'
--- a/libmysqld/Makefile.am	2010-11-04 15:40:18 +0000
+++ b/libmysqld/Makefile.am	2010-11-16 12:14:06 +0000
@@ -54,7 +54,7 @@ sqlsources = derror.cc field.cc field_co
 	item_xmlfunc.cc \
 	sha2.cc des_key_file.cc \
 	key.cc lock.cc log.cc sql_state.c \
-	log_event.cc rpl_record.cc rpl_utility.cc \
+	log_event.cc rpl_record.cc rpl_utility.cc rpl_reporting.cc \
 	log_event_old.cc rpl_record_old.cc \
 	protocol.cc net_serv.cc opt_range.cc \
 	opt_sum.cc procedure.cc records.cc sql_acl.cc \

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2010-11-08 14:35:45 +0000
+++ b/mysql-test/collections/default.experimental	2010-11-24 11:07:25 +0000
@@ -18,11 +18,13 @@ main.lowercase_table2 @darwin
 main.mysqlslap @windows                  # Bug#54024 2010-08-10 alik mysqlslap fails sporadically starting from Dahlia
 main.outfile_loaddata @solaris           # Bug#46895 2010-01-20 alik Test "outfile_loaddata" fails (reproducible)
 main.server_uuid                         # Bug#57482 2010-11-02 alik server_uuid fails on PB2
+main.server_uuid_embedded                # Bug#58171 2010-11-15 alik server_uuid_embedded fails sporadically
 main.signal_demo3 @solaris               # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 main.sp @solaris                         # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 main.type_float @freebsd                 # Bug#38965 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server
 main.wait_timeout @solaris               # Bug#51244 2010-04-26 alik wait_timeout fails on OpenSolaris
 
+perfschema.func_file_io                  # Bug#58172 2010-11-15 alik perfschema.func_file_io fails sporadically in PB
 perfschema.start_server_on               # Bug#55576 2010-08-02 alik Two perfschema tests failed on mysql-next-mr-innodb PB2 tests#
 perfschema.server_init                   # Bug#55576 2010-08-02 alik Two perfschema tests failed on mysql-next-mr-innodb PB2 tests#
 
@@ -30,6 +32,9 @@ rpl.rpl_heartbeat_basic
 rpl.rpl_innodb_bug28430*                 # Bug#46029
 rpl.rpl_row_sp011* @solaris              # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 rpl.rpl_delayed_slave                    # BUG#57514 rpl_delayed_slave fails sporadically in pb
+rpl.rpl_change_master                    # Bug#57482 2010-11-16 alfranio fails on PB2
+rpl.rpl_change_master_crash_safe         # Bug#57482 2010-11-16 alfranio fails on PB2
+rpl.rpl_seconds_behind_master            # BUG#58053 2010-11-24 luis fails sporadically on pb2
 
 sys_vars.max_sp_recursion_depth_func @solaris # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 sys_vars.slow_query_log_func @solaris         # Bug#54819 2010-06-26 alik sys_vars.slow_query_log_func fails sporadically on Solaris 10

=== added file 'mysql-test/collections/mysql-next-mr-wl2540.push'
--- a/mysql-test/collections/mysql-next-mr-wl2540.push	1970-01-01 00:00:00 +0000
+++ b/mysql-test/collections/mysql-next-mr-wl2540.push	2010-11-11 23:33:21 +0000
@@ -0,0 +1,6 @@
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum  --mysqld=--binlog-checksum=CRC32  --vardir=var-rpl_binlog_checksum --suite=binlog,rpl --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=n_mix          --vardir=var-n_mix                        --mysqld=--binlog-format=mixed  --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row         --vardir=var-ps_row         --ps-protocol --mysqld=--binlog-format=row    --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded       --vardir=var-emebbed        --embedded                                    --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row --vardir=var-rpl_binlog_row               --mysqld=--binlog-format=row    --suite=rpl,binlog --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1        --vardir=var-funcs_1                                                      --suite=funcs_1

=== added file 'mysql-test/collections/mysql-trunk.daily'
--- a/mysql-test/collections/mysql-trunk.daily	1970-01-01 00:00:00 +0000
+++ b/mysql-test/collections/mysql-trunk.daily	2010-11-16 11:34:55 +0000
@@ -0,0 +1,7 @@
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=n_mix          --vardir=var-n_mix                  --mysqld=--binlog-format=mixed
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row         --vardir=var-ps_row   --ps-protocol --mysqld=--binlog-format=row
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded       --vardir=var-emebbed  --embedded
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1        --vardir=var-funcs_1                                              --suite=funcs_1
+perl mysql-test-run.pl --timer --force --parallel=auto                                                 --comment=rpl_ndb_row    --vardir=var-rpl_ndb_row            --mysqld=--binlog-format=row  --suite=rpl_ndb,ndb
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row --vardir=var-rpl_binlog_row --mysqld=--binlog-format=row --suite=rpl,binlog --skip-ndb
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum  --mysqld=--binlog-checksum=CRC32  --vardir=var-rpl_binlog_checksum --suite=binlog,rpl

=== added file 'mysql-test/collections/mysql-trunk.weekly'
--- a/mysql-test/collections/mysql-trunk.weekly	1970-01-01 00:00:00 +0000
+++ b/mysql-test/collections/mysql-trunk.weekly	2010-11-16 11:34:55 +0000
@@ -0,0 +1,2 @@
+perl mysql-test-run.pl --timer --force --comment=1st --experimental=collections/default.experimental 1st
+perl mysql-test-run.pl --timer --force --comment=all_binlog_checksum --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema

=== modified file 'mysql-test/extra/binlog_tests/binlog.test'
--- a/mysql-test/extra/binlog_tests/binlog.test	2010-07-17 11:16:36 +0000
+++ b/mysql-test/extra/binlog_tests/binlog.test	2010-09-28 13:58:50 +0000
@@ -83,17 +83,22 @@ set @bcs = @@binlog_cache_size;
 set global binlog_cache_size=4096;
 reset master;
 
-create table t1 (a int) engine=innodb;
+create table t1 (a int, b char(255)) engine=innodb;
 
-let $1=400;
+flush status;
+show status like "binlog_cache_use";
+
+let $1=100;
 disable_query_log;
 begin;
 while ($1)
 {
- eval insert into t1 values( $1 );
+ eval insert into t1 values( $1, 'just to fill void to make transaction occupying at least two buffers of the trans cache' );
  dec $1;
 }
 commit;
+--echo *** the following must show the counter value > 1 ***
+show status like "binlog_cache_use";
 enable_query_log;
 
 --source include/show_binlog_events.inc

=== modified file 'mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test'
--- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test	2010-09-01 02:51:08 +0000
+++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test	2010-10-25 19:02:24 +0000
@@ -311,6 +311,7 @@ select get_lock("a",10);
 begin;
 insert into t1 values(8);
 insert into t2 select * from t1;
+
 disconnect con3;
 
 connection con4;

=== added file 'mysql-test/extra/rpl_tests/rpl_change_master.test'
--- a/mysql-test/extra/rpl_tests/rpl_change_master.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_change_master.test	2010-11-23 23:10:22 +0000
@@ -0,0 +1,284 @@
+# Verify that after CHANGE MASTER, replication (I/O thread and SQL
+# thread) restart from where SQL thread left, not from where
+# I/O thread left (some old bug fixed in 4.0.17)
+
+call mtr.add_suppression("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum");
+
+connection master;
+# Make SQL slave thread advance a bit
+create table t1(n int);
+sync_slave_with_master;
+select * from t1;
+# Now stop it and make I/O slave thread be ahead
+stop slave sql_thread;
+connection master;
+insert into t1 values(1);
+insert into t1 values(2);
+save_master_pos;
+let $slave_param= Read_Master_Log_Pos;
+let $slave_param_value= query_get_value(SHOW MASTER STATUS, Position, 1);
+connection slave;
+source include/wait_for_slave_param.inc;
+source include/stop_slave.inc;
+
+let $read_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
+let $exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
+if (`SELECT $read_pos = $exec_pos`)
+{
+  source include/show_rpl_debug_info.inc;
+  echo 'Read_Master_Log_Pos: $read_pos' == 'Exec_Master_Log_Pos: $exec_pos';
+  die Failed because Read_Master_Log_Pos is equal to Exec_Master_Log_Pos;
+} 
+change master to master_user='root';
+let $read_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
+let $exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
+if (`SELECT $read_pos <> $exec_pos`)
+{
+  source include/show_rpl_debug_info.inc;
+  echo 'Read_Master_Log_Pos: $read_pos' <> 'Exec_Master_Log_Pos: $exec_pos';
+  die Failed because Read_Master_Log_Pos is not equal to Exec_Master_Log_Pos;
+}
+
+start slave;
+sync_with_master;
+select * from t1;
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+# End of 4.1 tests
+
+#
+# BUG#12190 CHANGE MASTER has differ path requiremts on MASTER_LOG_FILE and RELAY_LOG_FILE
+#
+
+source include/master-slave-reset.inc;
+
+connection master;
+create table t1 (a int);
+insert into t1 values (1);
+flush logs;
+insert into t1 values (2);
+
+# Note: the master positon saved by this will also be used by the
+# 'sync_with_master' below.
+sync_slave_with_master;
+
+# Check if the table t1 and t2 are identical on master and slave;
+let $diff_table_1= master:test.t1
+let $diff_table_2= slave:test.t1
+source include/diff_tables.inc;
+
+connection slave;
+source include/stop_slave.inc;
+delete from t1 where a=2;
+
+# start replication from the second insert, after fix of BUG#12190,
+# relay_log_file does not use absolute path, only the filename is
+# required
+#
+# Note: the follow change master will automatically reset
+# relay_log_purge to false, save the old value to restore
+let $relay_log_purge= `select @@global.relay_log_purge`;
+CHANGE MASTER TO relay_log_file='slave-relay-bin.000005', relay_log_pos=4;
+start slave sql_thread;
+source include/wait_for_slave_sql_to_start.inc;
+
+# Sync to the same position saved by the 'sync_slave_with_master' above.
+sync_with_master;
+
+# Check if the table t1 and t2 are identical on master and slave;
+let $diff_table_1= master:test.t1
+let $diff_table_2= slave:test.t1
+source include/diff_tables.inc;
+
+# clean up
+connection slave;
+start slave io_thread;
+source include/wait_for_slave_io_to_start.inc;
+eval set global relay_log_purge=$relay_log_purge;
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+#
+# BUG#44209: MASTER_CONNECT_RETRY and --master-retry-count disconnected from each other
+#
+
+-- connection master
+-- source include/master-slave-reset.inc
+
+-- connection slave
+-- let $retry_count0= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+
+# assertion: show that the command line is still valid (MTR sets it to 10)
+-- echo Master_Retry_Count: $retry_count
+
+-- source include/stop_slave.inc
+
+# action: change the initial value to some other value
+-- let $retry_count1= `SELECT $retry_count0+10`
+-- eval CHANGE MASTER TO master_retry_count=$retry_count1
+
+-- source include/start_slave.inc
+
+-- let $retry_count1= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+# assertion: it shows the new value -- retry_count0 +10
+if (`SELECT $retry_count1 <> ($retry_count0+10)`)
+{
+  -- let $expected= `SELECT $retry_count0+10`
+  -- echo Unexpected retry count value! Got: $retry_count1, expected: $expected
+  -- die
+}
+
+-- source include/stop_slave.inc
+
+# action: change master_retry_count to zero will set it to zero.
+-- let $retry_count1= 0
+-- eval CHANGE MASTER TO master_retry_count=$retry_count1
+
+-- source include/start_slave.inc
+
+-- let $retry_count2= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+# assertion: it shows no changes
+if (`SELECT $retry_count2 <> $retry_count1`)
+{
+  -- echo Unexpected retry count value! Got: $retry_count2, expected: $retry_count1
+  -- die
+}
+
+-- source include/stop_slave.inc
+
+# action: change the value to the smallest value possible
+CHANGE MASTER TO master_retry_count=1;
+
+-- source include/start_slave.inc
+
+-- let $retry_count3= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+# assertion: it should show 1
+if (`SELECT $retry_count3 <> 1`)
+{
+  -- echo Unexpected retry count value! Got: $retry_count3, expected: 1
+  -- die
+}
+
+-- source include/stop_slave.inc
+
+# action: change the value back to the original one
+-- eval CHANGE MASTER TO master_retry_count=$retry_count0
+
+-- source include/start_slave.inc
+
+-- let $retry_count4= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+# assertion: it should show 1
+if (`SELECT $retry_count4 <> $retry_count0`)
+{
+  -- echo Unexpected retry count value! Got: $retry_count4, expected: $retry_count0
+  -- die
+}
+
+## Now lets change master_retry_count to the maximum value possible
+## and stop and restart the slave to check that (in the middle of it 
+## we also check that when issueing CHANGE MASTER TO without specifying
+## master_retry_count will not affect its current value):
+##   1. master_retry_count persists after restart
+##   2. setting a value higher than the max will make the max to be set.
+##   3. maximum value is accepted and persists after serialization 
+##      and de-serialization
+-- source include/stop_slave.inc
+-- let $retry_count_set= 18446744073709551616
+-- replace_result 18446744073709551616 RETRY_COUNT_SET
+-- eval CHANGE MASTER TO master_retry_count=$retry_count_set
+-- let $retry_count_expected= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+-- replace_result 18446744073709551615 RETRY_COUNT_EXPECTED 4294967295 RETRY_COUNT_EXPECTED 9223372036854775807 RETRY_COUNT_EXPECTED
+-- eval SELECT $retry_count_expected AS current_retry_count
+
+## assert that issuing CHANGE MASTER without changing master_retry_count
+## does not affect the existing value for master_retry_count
+-- let $connect_retry_old= query_get_value(SHOW SLAVE STATUS, Connect_Retry, 1)
+-- let $connect_retry_new= `SELECT $connect_retry_old + 1`
+-- let $retry_count_before= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+-- eval CHANGE MASTER TO master_connect_retry= $connect_retry_new
+-- let $retry_count_after= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+if (`SELECT $retry_count_before <> $retry_count_after`)
+{
+  -- echo Unexpected retry count value! Got: $retry_count_after, expected: $retry_count_before
+  -- die
+}
+-- eval CHANGE MASTER TO master_connect_retry= $connect_retry_old
+
+## Server restart persisting test
+--echo ### stop slave server
+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+wait
+EOF
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+  
+--echo ### start slave server
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+restart
+EOF
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+-- connection slave
+-- source include/start_slave.inc
+
+-- let $retry_count5= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
+if (`SELECT $retry_count5 <> $retry_count_expected`)
+{
+  -- echo Unexpected retry count value! Got: $retry_count5, expected: $retry_count_expected
+  -- die
+}
+
+## assert that there is a parse error if not using a numerical value
+-- error ER_PARSE_ERROR
+CHANGE MASTER TO master_retry_count='a';
+
+## assert that there is a parse error if using a negative number
+-- error ER_PARSE_ERROR
+CHANGE MASTER TO master_retry_count=-1;
+
+## Checks if Replicate_Ignore_Server_Ids is correctly written to a repository.
+
+--connection slave
+-- source include/stop_slave.inc
+
+-- let $connect_old_value= query_get_value(SHOW SLAVE STATUS, Connect_Retry, 1)
+-- let $ignore_old_value= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Server_Ids, 1)
+
+-- eval CHANGE MASTER TO master_connect_retry= 200, IGNORE_SERVER_IDS= (100, 200, 300, 400, 500)
+
+-- let $connect_new_value= query_get_value(SHOW SLAVE STATUS, Connect_Retry, 1)
+-- let $ignore_new_value= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Server_Ids, 1)
+
+--echo ### stop slave server
+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+wait
+EOF
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+
+--echo ### start slave server
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+restart
+EOF
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+-- connection slave
+-- source include/start_slave.inc
+
+-- let $connect_crash_value= query_get_value(SHOW SLAVE STATUS, Connect_Retry, 1)
+-- let $ignore_crash_value= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Server_Ids, 1)
+
+-- echo Eexpected values: "$ignore_new_value" == "$ignore_crash_value" or $connect_new_value == $connect_crash_value
+if (`SELECT "$ignore_new_value" <> "$ignore_crash_value" || $connect_new_value <> $connect_crash_value`)
+{
+  -- echo Unexpected values: "$ignore_new_value" <> "$ignore_crash_value" or $connect_new_value <> $connect_crash_value
+  -- die
+}
+
+-- source include/master-slave-reset.inc
+-- source include/master-slave-end.inc

=== modified file 'mysql-test/extra/rpl_tests/rpl_conflicts.test'
--- a/mysql-test/extra/rpl_tests/rpl_conflicts.test	2010-08-05 17:45:25 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_conflicts.test	2010-10-25 19:02:24 +0000
@@ -146,7 +146,10 @@ if (`SELECT @@global.binlog_format = 'RO
   source include/wait_for_slave_sql_error.inc;
   let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
   let $err= `SELECT SUBSTRING("$err" FROM 17)`;
-  --echo Last_SQL_Error = $err (expected "can't find record" error)
+  --replace_regex /end_log_pos [0-9]+/end_log_pos END_LOG_POS/
+  --disable_query_log
+  --eval SELECT "$err" as 'Last_SQL_Error (expected "duplicate key" error)'
+  --enable_query_log
   SELECT * FROM t1;
 
   --echo ---- Resolve the conflict on the slave and restart SQL thread ----

=== added file 'mysql-test/extra/rpl_tests/rpl_crash_safe.inc'
--- a/mysql-test/extra/rpl_tests/rpl_crash_safe.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_crash_safe.inc	2010-10-27 11:50:22 +0000
@@ -0,0 +1,116 @@
+#
+# This file relies on the rpl_mixing_engines.inc which provides an engine
+# to process commands.
+#
+
+#
+# Creates tables used throughout the test and changes the type of the
+# mysql.slave_relay_log_info to Innodb.
+#
+if (`SELECT HEX(@commands) = HEX('configure')`)
+{
+  --sync_slave_with_master
+  SHOW CREATE TABLE mysql.slave_relay_log_info;
+  ALTER TABLE mysql.slave_relay_log_info ENGINE= Innodb;
+  SHOW CREATE TABLE mysql.slave_relay_log_info;
+
+  connection master;
+  --source extra/rpl_tests/rpl_mixing_engines.inc
+
+  --sync_slave_with_master
+  connection master;
+}
+
+#
+# Cleans the test case by deleting all tables, triggers, procedures and
+# functions that were created.
+#
+if (`SELECT HEX(@commands) = HEX('clean')`)
+{
+  connection master;
+  --source extra/rpl_tests/rpl_mixing_engines.inc
+}
+
+#
+# Executes the set of commands defined in @command by calling
+# rpl_mixing_engines.inc
+#
+if (`SELECT HEX(@commands) != HEX('')`)
+{
+  # 
+  # If an fault injection point was defined, stop the SQL THREAD and
+  # prepare the slave to be restarted. Otherwise, do nothing.
+  #
+  if (`SELECT HEX(@failure) != HEX('')`)
+  {
+    connection slave;
+    STOP SLAVE SQL_THREAD;
+    source include/wait_for_slave_sql_to_stop.inc;
+    --eval SET GLOBAL debug="$failure";
+    --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+  }
+
+  #
+  # Prints the expected outcome after the recovery. Check the
+  # WL#4801 for further details.
+  #
+  connection master;
+  if (`SELECT HEX(@failure) != HEX('')`)
+  {
+    if (`SELECT HEX(@failure) != HEX('d,crash_after_commit_and_update_pos') && HEX(@failure) != HEX('d,crash_after_apply')`)
+    {
+      --echo FAILURE $failure and OUTCOME O1
+    }
+    if (`SELECT HEX(@failure) = HEX('d,crash_after_commit_and_update_pos') || HEX(@failure) = HEX('d,crash_after_apply')`)
+    {
+      --echo FAILURE $failure and OUTCOME O2
+    }
+  }
+
+  #
+  # Executes the set of commands defined in @command by calling
+  # rpl_mixing_engines.inc
+  #
+  connection master;
+  let $master_before= query_get_value(SHOW MASTER STATUS, Position, 1);
+  --source extra/rpl_tests/rpl_mixing_engines.inc
+  let $master_after= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+  #
+  # Restarts the SQL THREAD and waits for the SLAVE to be crashed and
+  # re-started.
+  #
+  connection master;
+  if (`SELECT HEX(@failure) != HEX('')`)
+  {
+    connection slave;
+    --error 0, 2013
+    START SLAVE SQL_THREAD;
+    --source include/wait_until_disconnected.inc
+    --enable_reconnect
+    --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+    --source include/wait_until_connected_again.inc
+    connection slave;
+    --let $slave_before= `SELECT master_log_pos FROM mysql.slave_relay_log_info`
+    START SLAVE;
+    source include/wait_for_slave_to_start.inc;
+  }
+
+  #
+  # Syncs the slave with the master and checks if the slaves applied all
+  # changes from the master and is not out of sync.
+  #
+  connection master;
+  sync_slave_with_master;
+  --let $slave_after= `SELECT master_log_pos FROM mysql.slave_relay_log_info`
+  connection master;
+  if (`SELECT $slave_after != $master_after`)
+  {
+    --echo Slave is out of sync.
+    --echo MASTER_BEFORE $master_before MASTER_AFTER $master_after SLAVE_BEFORE $slave_before SLAVE_AFTER $slave_after
+    --source include/show_rpl_debug_info.inc
+    --die
+  }
+}
+
+connection master;

=== added file 'mysql-test/extra/rpl_tests/rpl_crash_safe.test'
--- a/mysql-test/extra/rpl_tests/rpl_crash_safe.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_crash_safe.test	2010-11-16 12:48:25 +0000
@@ -0,0 +1,239 @@
+###############################################################################
+#  This test case aims at checking if a slave does not go out of sync after
+#  injecting crashes at specific points. The following scenarios are analyzed:
+#
+#     |------------+-----------------------+---------+---------+---------|
+#     | SCENARIO # | SCENARIO              | CRASH-1 | CRASH-2 | CRASH-3 |
+#     |------------+-----------------------+---------+---------+---------|
+#     |          1 | T                     | O1      | O1      | O2      |
+#     |          2 | T-*                   | O1      | O1      | O2      |
+#     |          3 | B T T-* C             | O1      | O1      | O2      |
+#     |          4 | B T-* T C             | O1      | O1      | O2      |
+#     |          5 | N                     | O3      | O3      | O2      |
+#     |          6 | N-*                   | O3      | O3      | O2      |
+#     |------------+-----------------------+---------+---------+---------|
+#
+#  Legend:
+#
+#  . T - Updates transactional table by calling insert/update/delete.
+#
+#  . N - Updates non-transactional by calling insert/update/delete.
+#
+#  . T-* - Updates transactional table through a trigger, procedure or function
+#  by calling insert/update/delete.
+#
+#  . N-* - Updates non-transactional table through a trigger or function
+#  by calling insert/update/delete.
+#
+#  . B - Begin.
+#
+#  . C - Commit.
+#
+#  . R - Rollback.
+#
+#  For those transactions involving only transactional tables, faults are
+#  injected while committing a transaction at the following points:
+#
+#  CRASH-1 - crash_before_update_pos - before updating the positions.
+#  CRASH-2 - crash_after_update_pos_before_apply - after updating the positions
+#  but before committing the transaction.
+#  CRASH-3 - crash_after_apply - after updating the position and committing the
+#  transaction.
+#
+#  When a non-transactional table is updated, faults are injected at one point:
+#
+#  CRASH-3 - crash_after_commit_and_update_pos - after committing and updating
+#  the positions.
+#
+#  After injecting the faults, we expect the following outcomes:
+#
+#  O1. In this case, the slave shall correctly recover to "S" without going out
+#  of sync and process "tx". 
+#
+#  O2. In this case, the slave shall correctly recover to "S'"  without going 
+#  out of sync.
+#
+#  O3. In this case, the slave shall recover to "S''" and re-execute "tx". 
+#  In this case, the SQL Thread may fail due to duplicate keys, if any, and
+#  most likely the slave will become inconsistent. The user should manually 
+#  check the slave and resolve the problems.
+#
+#  where
+#
+#  . S represents a database's state.
+#
+#  . tx represents a transaction ended by either "C" or "R".
+#
+#  . S' represents a database's state after processing "tx" and seen by
+#  concurrent transactions.
+#
+#  . S'' represents a database's state after partially processing "tx"
+#  seen by concurrent transactions.
+#
+#  Note however that we do not inject faults that generate "O3" as we are only
+#  interested in the cases that the slave can automatically recover.
+#  See WL#4801 for further details.
+################################################################################
+
+
+--echo ###################################################################################
+--echo #                               PREPARE EXECUTION
+--echo ###################################################################################
+connection master;
+SET @verbose= 'Y';
+let $engine_type=Innodb;
+SET @commands= 'configure';
+--source extra/rpl_tests/rpl_crash_safe.inc
+
+--echo ###################################################################################
+--echo #                         EXECUTE CASES CRASHING THE XID
+--echo ###################################################################################
+connection master;
+SET @failures= 'd,crash_after_apply d,crash_before_update_pos d,crash_after_update_pos_before_apply';
+#
+# Executes a set of tests while there are crash points in @failures.
+#
+while (`SELECT HEX(@failures) != HEX('')`)
+{
+  #
+  # Gets a crash point from the set of crash points in @failures and
+  # stores it into @failure.
+  #
+  --disable_query_log
+  SET @failure= SUBSTRING_INDEX(@failures, ' ', 1);
+  let $failure= `SELECT @failure`;
+  --enable_query_log
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'T';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'T-trig';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'T-func';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'T-proc';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'B T T-trig C';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+   SET @commands= 'B T T-func C';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'B T T-proc C';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'B T-trig T C';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'B T-func T C';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'B T-proc T C';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  #
+  # Removes @failure from the set of crash points in @failures.
+  #
+  --disable_query_log
+  --eval  SET @failure= '$failure';
+  SET @failures= LTRIM(SUBSTRING(@failures, LENGTH(@failure) + 1));
+  --enable_query_log
+}
+
+--echo ###################################################################################
+--echo #                      EXECUTE CASES CRASHING THE BEGIN/COMMIT
+--echo ###################################################################################
+SET @failures= 'd,crash_after_commit_and_update_pos';
+#
+# Executes a set of tests while there are crash points in @failures.
+#
+while (`SELECT HEX(@failures) != HEX('')`)
+{
+  #
+  # Gets a crash point from the set of crash points in @failures and
+  # stores it into @failure.
+  #
+  --disable_query_log
+  SET @failure= SUBSTRING_INDEX(@failures, ' ', 1);
+  let $failure= `SELECT @failure`;
+  --enable_query_log
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'N';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'N-trig';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  --echo
+  --echo
+  --echo
+  SET @commands= 'N-func';
+  --source extra/rpl_tests/rpl_crash_safe.inc
+
+  #
+  # Removes @failure from the set of crash points in @failures.
+  #
+  --disable_query_log
+  --eval  SET @failure= '$failure';
+  SET @failures= LTRIM(SUBSTRING(@failures, LENGTH(@failure) + 1));
+  --enable_query_log
+}
+
+--echo ###################################################################################
+--echo #                               CHECK CONSISTENCY
+--echo ###################################################################################
+connection master;
+sync_slave_with_master;
+connection master;
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-crash-master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-crash-slave.sql
+--diff_files $MYSQLD_DATADIR/test-crash-master.sql $MYSQLD_DATADIR/test-crash-slave.sql
+
+--echo ###################################################################################
+--echo #                                        CLEAN
+--echo ###################################################################################
+connection master;
+SET @commands= 'clean';
+--source extra/rpl_tests/rpl_crash_safe.inc

=== modified file 'mysql-test/extra/rpl_tests/rpl_flsh_tbls.test'
--- a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test	2010-10-08 16:11:32 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test	2010-11-23 23:10:22 +0000
@@ -5,6 +5,7 @@
 #
 
 source include/master-slave.inc;
+source include/not_relay_log_info_table.inc;
 
 let $SERVER_VERSION=`select version()`;
 
@@ -15,6 +16,7 @@ create table t3 (a int) engine=merge uni
 create table t4 (a int);
 # We force the slave to open t3 (because we want to try confusing him) with this :
 insert into t4 select * from t3;
+--let $rename_event_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
 rename table t1 to t5, t2 to t1;
 # RENAME may have confused the master (this is a known bug): so FLUSH tables,
 # first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword.

=== modified file 'mysql-test/extra/rpl_tests/rpl_reset_slave.test'
--- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test	2010-06-19 09:24:34 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test	2010-09-28 17:19:47 +0000
@@ -10,6 +10,9 @@
 
 -- source include/master-slave.inc
 sync_slave_with_master;
+--disable_query_log
+call mtr.add_suppression('Slave I/O: Get master BINLOG_CHECKSUM failed with error');
+--enable_query_log
 let $status_items= Master_User, Master_Host;
 source include/show_slave_status.inc;
 

=== modified file 'mysql-test/extra/rpl_tests/rpl_start_stop_slave.test'
--- a/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test	2010-10-14 01:54:07 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_start_stop_slave.test	2010-11-16 12:14:06 +0000
@@ -15,7 +15,7 @@ sync_slave_with_master;
 stop slave;
 --source include/wait_for_slave_to_stop.inc
 connection master;
-let $1=5000;
+let $1=2500;
 disable_query_log;
 while ($1)
 {

=== added file 'mysql-test/include/have_binlog_checksum_off.inc'
--- a/mysql-test/include/have_binlog_checksum_off.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/have_binlog_checksum_off.inc	2010-06-14 10:04:20 +0000
@@ -0,0 +1,4 @@
+if (`select variable_value not like 'NONE' from information_schema.GLOBAL_VARIABLES
+       where variable_name='binlog_checksum'`){
+   skip Can not run the test when server activated checksumming;
+}

=== modified file 'mysql-test/include/mtr_warnings.sql'
--- a/mysql-test/include/mtr_warnings.sql	2010-11-09 20:10:44 +0000
+++ b/mysql-test/include/mtr_warnings.sql	2010-11-16 12:14:06 +0000
@@ -233,6 +233,9 @@ INSERT INTO global_suppressions VALUES
  ("Slave I/O: Get master clock failed with error:.*"),
  ("Slave I/O: Get master COLLATION_SERVER failed with error:.*"),
  ("Slave I/O: Get master TIME_ZONE failed with error:.*"),
+ ("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum on master.*"),
+ ("Slave I/O: Get master BINLOG_CHECKSUM failed with error.*"),
+ ("Slave I/O: Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error.*"),
  /*
    BUG#42147 - Concurrent DML and LOCK TABLE ... READ for InnoDB 
    table cause warnings in errlog

=== added file 'mysql-test/include/not_master_info_table.inc'
--- a/mysql-test/include/not_master_info_table.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/not_master_info_table.inc	2010-10-25 10:39:01 +0000
@@ -0,0 +1,4 @@
+if (`SELECT @@GLOBAL.master_info_repository = 'TABLE'`)
+{
+     skip Test cannot run with master.info repository table;
+}

=== added file 'mysql-test/include/not_relay_log_info_table.inc'
--- a/mysql-test/include/not_relay_log_info_table.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/not_relay_log_info_table.inc	2010-10-25 10:39:01 +0000
@@ -0,0 +1,4 @@
+if (`SELECT @@GLOBAL.relay_log_info_repository = 'TABLE'`)
+{
+     skip Test cannot run with relay_log.info repository table;
+}

=== modified file 'mysql-test/r/1st.result'
--- a/mysql-test/r/1st.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/r/1st.result	2010-11-15 16:43:41 +0000
@@ -23,6 +23,8 @@ proc
 procs_priv
 proxies_priv
 servers
+slave_master_info
+slave_relay_log_info
 slow_log
 tables_priv
 time_zone

=== modified file 'mysql-test/r/connect.result'
--- a/mysql-test/r/connect.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/r/connect.result	2010-11-15 16:43:41 +0000
@@ -17,6 +17,8 @@ proc
 procs_priv
 proxies_priv
 servers
+slave_master_info
+slave_relay_log_info
 slow_log
 tables_priv
 time_zone
@@ -51,6 +53,8 @@ proc
 procs_priv
 proxies_priv
 servers
+slave_master_info
+slave_relay_log_info
 slow_log
 tables_priv
 time_zone
@@ -93,6 +97,8 @@ proc
 procs_priv
 proxies_priv
 servers
+slave_master_info
+slave_relay_log_info
 slow_log
 tables_priv
 time_zone

=== modified file 'mysql-test/r/information_schema.result'
--- a/mysql-test/r/information_schema.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/r/information_schema.result	2010-11-15 16:43:41 +0000
@@ -90,6 +90,8 @@ proc
 procs_priv
 proxies_priv
 servers
+slave_master_info
+slave_relay_log_info
 slow_log
 tables_priv
 time_zone
@@ -874,7 +876,7 @@ AND table_name not like 'ndb%' AND table
 GROUP BY TABLE_SCHEMA;
 table_schema	count(*)
 information_schema	30
-mysql	23
+mysql	25
 create table t1 (i int, j int);
 create trigger trg1 before insert on t1 for each row
 begin

=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	2010-11-08 14:35:45 +0000
+++ b/mysql-test/r/log_tables.result	2010-11-15 16:43:41 +0000
@@ -363,6 +363,7 @@ Tables_in_mysql (%log%)
 general_log
 general_log_new
 ndb_binlog_index
+slave_relay_log_info
 slow_log
 slow_log_new
 drop table slow_log_new, general_log_new;

=== modified file 'mysql-test/r/log_tables_upgrade.result'
--- a/mysql-test/r/log_tables_upgrade.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/r/log_tables_upgrade.result	2010-11-15 16:43:41 +0000
@@ -30,6 +30,8 @@ mysql.procs_priv
 mysql.proxies_priv                                 OK
 mysql.renamed_general_log                          OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
 mysql.time_zone                                    OK

=== modified file 'mysql-test/r/mysql_upgrade.result'
--- a/mysql-test/r/mysql_upgrade.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/r/mysql_upgrade.result	2010-11-15 16:43:41 +0000
@@ -17,6 +17,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
 mysql.time_zone                                    OK
@@ -46,6 +48,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
 mysql.time_zone                                    OK
@@ -75,6 +79,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
 mysql.time_zone                                    OK
@@ -106,6 +112,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
 mysql.time_zone                                    OK
@@ -141,6 +149,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
 mysql.time_zone                                    OK
@@ -179,6 +189,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
 mysql.time_zone                                    OK

=== modified file 'mysql-test/r/mysql_upgrade_ssl.result'
--- a/mysql-test/r/mysql_upgrade_ssl.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/r/mysql_upgrade_ssl.result	2010-11-15 16:43:41 +0000
@@ -19,6 +19,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
 mysql.time_zone                                    OK

=== modified file 'mysql-test/r/mysqlcheck.result'
--- a/mysql-test/r/mysqlcheck.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/r/mysqlcheck.result	2010-11-15 16:43:41 +0000
@@ -20,6 +20,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log
 note     : The storage engine for the table doesn't support analyze
 mysql.tables_priv                                  OK
@@ -48,6 +50,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log
 note     : The storage engine for the table doesn't support optimize
 mysql.tables_priv                                  OK
@@ -74,6 +78,8 @@ mysql.proc
 mysql.procs_priv                                   OK
 mysql.proxies_priv                                 OK
 mysql.servers                                      OK
+mysql.slave_master_info                            OK
+mysql.slave_relay_log_info                         OK
 mysql.slow_log
 note     : The storage engine for the table doesn't support analyze
 mysql.tables_priv                                  OK
@@ -100,6 +106,8 @@ mysql.proc
 mysql.procs_priv                                   Table is already up to date
 mysql.proxies_priv                                 Table is already up to date
 mysql.servers                                      Table is already up to date
+mysql.slave_master_info                            Table is already up to date
+mysql.slave_relay_log_info                         Table is already up to date
 mysql.slow_log
 note     : The storage engine for the table doesn't support optimize
 mysql.tables_priv                                  Table is already up to date

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2010-11-11 14:30:15 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2010-11-16 12:14:06 +0000
@@ -36,6 +36,10 @@ The following options may be given as th
  binary log during a transaction. If you often use big,
  multi-statement transactions you can increase this to get
  more performance
+ --binlog-checksum=name 
+ Type of BINLOG_CHECKSUM_ALG. Include checksum for log
+ events in the binary log. Possible values are NONE and
+ CRC32; default is NONE.
  --binlog-direct-non-transactional-updates 
  Causes updates to non-transactional engines using
  statement format to be written directly to binary log.
@@ -278,6 +282,10 @@ The following options may be given as th
  The number of tries the slave will make to connect to the
  master before giving up. Deprecated option, use 'CHANGE
  MASTER TO master_retry_count = <num>' instead.
+ --master-verify-checksum 
+ Force checksum verification of logged events in binary
+ log before sending them to slaves or printing them in
+ output of SHOW BINLOG EVENTS. Disabled by default.
  --max-allowed-packet=# 
  Max packet length to send to or receive from the server
  --max-binlog-cache-size=# 
@@ -628,6 +636,13 @@ The following options may be given as th
  --slave-skip-errors=name 
  Tells the slave thread to continue replication when a
  query event returns an error from the provided list
+ --slave-sql-verify-checksum 
+ Force checksum verification of replication events after
+ reading them from relay log. Note: Events are always
+ checksum-verified by slave on receiving them from the
+ network before writing them to the relay log. Enabled by
+ default.
+ (Defaults to on; use --skip-slave-sql-verify-checksum to disable.)
  --slave-transaction-retries=# 
  Number of times the slave SQL thread will retry a
  transaction in case it failed with a deadlock or elapsed
@@ -732,6 +747,7 @@ back-log 50
 big-tables FALSE
 bind-address (No default value)
 binlog-cache-size 32768
+binlog-checksum NONE
 binlog-direct-non-transactional-updates FALSE
 binlog-format STATEMENT
 binlog-row-event-max-size 1024
@@ -811,6 +827,7 @@ lower-case-table-names 1
 master-info-file master.info
 master-info-repository FILE
 master-retry-count 86400
+master-verify-checksum FALSE
 max-allowed-packet 1048576
 max-binlog-cache-size 18446744073709547520
 max-binlog-dump-events 0
@@ -914,6 +931,7 @@ slave-compressed-protocol FALSE
 slave-exec-mode STRICT
 slave-net-timeout 3600
 slave-skip-errors (No default value)
+slave-sql-verify-checksum TRUE
 slave-transaction-retries 10
 slave-type-conversions 
 slow-launch-time 2

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2010-11-11 14:30:15 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2010-11-16 12:14:06 +0000
@@ -36,6 +36,10 @@ The following options may be given as th
  binary log during a transaction. If you often use big,
  multi-statement transactions you can increase this to get
  more performance
+ --binlog-checksum=name 
+ Type of BINLOG_CHECKSUM_ALG. Include checksum for log
+ events in the binary log. Possible values are NONE and
+ CRC32; default is NONE.
  --binlog-direct-non-transactional-updates 
  Causes updates to non-transactional engines using
  statement format to be written directly to binary log.
@@ -277,6 +281,10 @@ The following options may be given as th
  The number of tries the slave will make to connect to the
  master before giving up. Deprecated option, use 'CHANGE
  MASTER TO master_retry_count = <num>' instead.
+ --master-verify-checksum 
+ Force checksum verification of logged events in binary
+ log before sending them to slaves or printing them in
+ output of SHOW BINLOG EVENTS. Disabled by default.
  --max-allowed-packet=# 
  Max packet length to send to or receive from the server
  --max-binlog-cache-size=# 
@@ -631,6 +639,13 @@ The following options may be given as th
  --slave-skip-errors=name 
  Tells the slave thread to continue replication when a
  query event returns an error from the provided list
+ --slave-sql-verify-checksum 
+ Force checksum verification of replication events after
+ reading them from relay log. Note: Events are always
+ checksum-verified by slave on receiving them from the
+ network before writing them to the relay log. Enabled by
+ default.
+ (Defaults to on; use --skip-slave-sql-verify-checksum to disable.)
  --slave-transaction-retries=# 
  Number of times the slave SQL thread will retry a
  transaction in case it failed with a deadlock or elapsed
@@ -736,6 +751,7 @@ back-log 50
 big-tables FALSE
 bind-address (No default value)
 binlog-cache-size 32768
+binlog-checksum NONE
 binlog-direct-non-transactional-updates FALSE
 binlog-format STATEMENT
 binlog-row-event-max-size 1024
@@ -814,6 +830,7 @@ lower-case-table-names 1
 master-info-file master.info
 master-info-repository FILE
 master-retry-count 86400
+master-verify-checksum FALSE
 max-allowed-packet 1048576
 max-binlog-cache-size 18446744073709547520
 max-binlog-dump-events 0
@@ -920,6 +937,7 @@ slave-compressed-protocol FALSE
 slave-exec-mode STRICT
 slave-net-timeout 3600
 slave-skip-errors (No default value)
+slave-sql-verify-checksum TRUE
 slave-transaction-retries 10
 slave-type-conversions 
 slow-launch-time 2

=== modified file 'mysql-test/r/system_mysql_db.result'
--- a/mysql-test/r/system_mysql_db.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/r/system_mysql_db.result	2010-11-15 16:43:41 +0000
@@ -16,6 +16,8 @@ proc
 procs_priv
 proxies_priv
 servers
+slave_master_info
+slave_relay_log_info
 slow_log
 tables_priv
 time_zone

=== added file 'mysql-test/suite/binlog/r/binlog_checksum.result'
--- a/mysql-test/suite/binlog/r/binlog_checksum.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/binlog_checksum.result	2010-06-18 10:45:52 +0000
@@ -0,0 +1,23 @@
+set @save_binlog_checksum = @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 1;
+reset master;
+must be master-bin.000001 
+show binary logs;
+Log_name	File_size
+master-bin.000001	#
+create table t1 (a int);
+flush logs;
+drop table t1;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int)
+master-bin.000001	#	Rotate	#	#	master-bin.000002;pos=4
+show tables;
+Tables_in_test
+t1
+drop table t1;
+set @@global.binlog_checksum = @save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+End of the tests

=== modified file 'mysql-test/suite/binlog/r/binlog_killed.result'
--- a/mysql-test/suite/binlog/r/binlog_killed.result	2010-04-28 12:47:49 +0000
+++ b/mysql-test/suite/binlog/r/binlog_killed.result	2010-07-07 17:27:55 +0000
@@ -7,6 +7,11 @@ get_lock("a", 20)
 1
 reset master;
 insert into t2 values (null, null), (null, get_lock("a", 10));
+kill query ID;
+select
+(@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog"))
+is not null;
+set @result= 2 - 1 - 1;
 select @result /* must be zero either way */;
 @result
 0
@@ -85,20 +90,21 @@ a	b
 select @b  /* must be 1 at the end of a stmt calling bug27563() */;
 @b
 1
-must have the update query event more to FD
+must have the update query event on the 4th line
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	User var	#	#	@`b`=0
 master-bin.000001	#	Query	#	#	use `test`; update t4 set b=b + bug27563(b)
 master-bin.000001	#	Query	#	#	COMMIT
+*** a proof the query is binlogged with an error ***
 select
 (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
 is not null;
 (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
 is not null
 1
-select 0 /* must return 0 to mean the killed query is in */;
+select 0 /* must return 0 to mean the killed update is in */;
 0
 0
 select RELEASE_LOCK("a");
@@ -123,7 +129,7 @@ count(*)
 select @b  /* must be 1 at the end of a stmt calling bug27563() */;
 @b
 1
-must have the delete query event more to FD
+must have the delete query event on the 4th line
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
@@ -136,7 +142,7 @@ is not null;
 (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
 is not null
 1
-select 0 /* must return 0 to mean the killed query is in */;
+select 0 /* must return 0 to mean the killed delete is in */;
 0
 0
 select RELEASE_LOCK("a");

=== modified file 'mysql-test/suite/binlog/r/binlog_old_versions.result'
--- a/mysql-test/suite/binlog/r/binlog_old_versions.result	2008-01-30 13:12:40 +0000
+++ b/mysql-test/suite/binlog/r/binlog_old_versions.result	2010-06-14 10:04:20 +0000
@@ -39,21 +39,11 @@ SELECT COUNT(*) FROM t3;
 COUNT(*)
 17920
 DROP TABLE t1, t3;
+*** wl#2540 Replication events checksum is not yet defined 
+*** its born-version. One that is temporarily chosen conflicts with 
+*** the version in the following pre-recorded binlogs
+*** TODO: uncomment this snippet when the WL patches will be about to push
 ==== Read binlog from alcatel tree (mysql-5.1-wl2325-5.0-drop6) ====
-SELECT * FROM t1 ORDER BY a;
-a	b
-0	last_insert_id
-1	one
-3	last stm in trx: next event should be xid
-4	four
-781729	random
-SELECT * FROM t2 ORDER BY a;
-a	b
-3	first stm in trx
-SELECT COUNT(*) FROM t3;
-COUNT(*)
-17920
-DROP TABLE t1, t2, t3;
 ==== Read binlog from ndb tree (mysql-5.1-telco-6.1) ====
 SELECT * FROM t1 ORDER BY a;
 a	b

=== modified file 'mysql-test/suite/binlog/r/binlog_row_binlog.result'
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result	2010-10-03 23:42:39 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result	2010-10-25 19:02:24 +0000
@@ -282,614 +282,22 @@ master-bin.000001	#	Query	#	#	use `test`
 set @bcs = @@binlog_cache_size;
 set global binlog_cache_size=4096;
 reset master;
-create table t1 (a int) engine=innodb;
+create table t1 (a int, b char(255)) engine=innodb;
+flush status;
+show status like "binlog_cache_use";
+Variable_name	Value
+Binlog_cache_use	0
+*** the following must show the counter value > 1 ***
+Variable_name	Value
+Binlog_cache_use	2
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int) engine=innodb
+master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int, b char(255)) engine=innodb
+master-bin.000001	#	Query	#	#	use `test`; flush status
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_binlog.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result	2010-09-01 02:51:08 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result	2010-10-25 19:02:24 +0000
@@ -166,411 +166,119 @@ master-bin.000001	#	Query	#	#	use `test`
 set @bcs = @@binlog_cache_size;
 set global binlog_cache_size=4096;
 reset master;
-create table t1 (a int) engine=innodb;
+create table t1 (a int, b char(255)) engine=innodb;
+flush status;
+show status like "binlog_cache_use";
+Variable_name	Value
+Binlog_cache_use	0
+*** the following must show the counter value > 1 ***
+Variable_name	Value
+Binlog_cache_use	2
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int) engine=innodb
+master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int, b char(255)) engine=innodb
+master-bin.000001	#	Query	#	#	use `test`; flush status
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 400 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 399 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 398 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 397 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 396 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 395 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 394 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 393 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 392 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 391 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 390 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 389 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 388 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 387 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 386 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 385 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 384 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 383 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 382 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 381 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 380 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 379 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 378 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 377 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 376 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 375 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 374 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 373 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 372 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 371 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 370 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 369 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 368 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 367 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 366 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 365 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 364 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 363 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 362 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 361 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 360 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 359 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 358 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 357 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 356 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 355 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 354 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 353 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 352 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 351 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 350 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 349 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 348 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 347 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 346 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 345 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 344 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 343 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 342 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 341 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 340 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 339 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 338 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 337 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 336 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 335 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 334 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 333 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 332 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 331 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 330 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 329 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 328 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 327 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 326 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 325 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 324 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 323 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 322 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 321 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 320 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 319 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 318 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 317 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 316 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 315 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 314 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 313 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 312 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 311 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 310 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 309 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 308 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 307 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 306 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 305 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 304 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 303 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 302 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 301 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 300 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 299 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 298 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 297 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 296 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 295 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 294 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 293 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 292 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 291 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 290 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 289 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 288 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 287 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 286 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 285 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 284 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 283 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 282 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 281 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 280 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 279 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 278 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 277 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 276 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 275 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 274 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 273 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 272 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 271 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 270 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 269 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 268 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 267 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 266 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 265 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 264 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 263 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 262 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 261 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 260 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 259 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 258 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 257 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 256 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 255 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 254 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 253 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 252 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 251 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 250 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 249 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 248 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 247 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 246 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 245 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 244 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 243 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 242 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 241 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 240 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 239 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 238 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 237 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 236 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 235 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 234 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 233 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 232 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 231 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 230 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 229 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 228 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 227 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 226 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 225 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 224 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 223 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 222 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 221 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 220 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 219 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 218 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 217 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 216 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 215 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 214 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 213 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 212 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 211 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 210 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 209 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 208 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 207 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 206 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 205 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 204 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 203 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 202 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 201 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 200 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 199 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 198 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 197 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 196 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 195 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 194 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 193 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 192 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 191 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 190 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 189 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 188 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 187 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 186 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 185 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 184 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 183 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 182 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 181 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 180 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 179 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 178 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 177 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 176 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 175 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 174 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 173 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 172 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 171 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 170 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 169 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 168 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 167 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 166 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 165 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 164 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 163 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 162 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 161 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 160 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 159 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 158 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 157 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 156 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 155 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 154 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 153 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 152 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 151 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 150 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 149 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 148 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 147 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 146 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 145 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 144 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 143 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 142 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 141 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 140 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 139 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 138 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 137 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 136 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 135 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 134 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 133 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 132 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 131 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 130 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 129 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 128 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 127 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 126 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 125 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 124 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 123 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 122 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 121 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 120 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 119 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 118 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 117 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 116 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 115 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 114 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 113 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 112 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 111 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 110 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( <binlog_start> )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 108 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 107 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 106 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 105 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 104 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 103 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 102 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 101 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 100 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 99 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 98 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 97 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 96 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 95 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 94 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 93 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 92 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 91 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 90 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 89 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 88 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 87 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 86 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 85 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 84 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 83 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 82 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 81 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 80 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 79 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 78 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 77 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 76 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 75 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 74 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 73 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 72 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 71 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 70 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 69 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 68 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 67 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 66 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 65 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 64 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 63 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 62 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 61 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 60 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 59 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 58 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 57 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 56 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 55 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 54 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 53 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 52 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 51 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 50 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 49 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 48 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 47 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 46 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 45 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 44 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 43 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 42 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 41 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 40 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 39 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 38 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 37 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 36 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 35 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 34 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 33 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 32 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 31 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 30 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 29 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 28 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 27 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 26 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 25 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 24 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 23 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 22 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 21 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 20 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 19 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 18 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 17 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 16 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 15 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 14 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 13 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 12 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 11 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 10 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 9 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 8 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 7 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 6 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 5 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 4 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 3 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 2 )
-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 1 )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 100, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 99, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 98, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 97, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 96, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 95, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 94, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 93, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 92, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 91, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 90, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 89, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 88, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 87, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 86, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 85, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 84, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 83, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 82, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 81, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 80, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 79, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 78, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 77, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 76, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 75, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 74, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 73, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 72, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 71, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 70, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 69, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 68, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 67, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 66, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 65, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 64, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 63, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 62, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 61, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 60, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 59, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 58, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 57, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 56, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 55, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 54, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 53, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 52, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 51, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 50, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 49, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 48, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 47, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 46, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 45, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 44, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 43, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 42, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 41, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 40, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 39, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 38, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 37, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 36, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 35, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 34, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 33, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 32, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 31, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 30, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 29, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 28, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 27, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 26, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 25, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 24, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 23, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 22, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 21, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 20, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 19, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 18, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 17, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 16, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 15, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 14, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 13, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 12, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 11, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 10, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 9, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 8, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 7, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 6, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 5, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 4, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 3, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 2, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 1, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 master-bin.000001	#	Rotate	#	#	master-bin.000002;pos=4
 drop table t1;

=== added file 'mysql-test/suite/binlog/t/binlog_checksum.test'
--- a/mysql-test/suite/binlog/t/binlog_checksum.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_checksum.test	2010-06-18 10:45:52 +0000
@@ -0,0 +1,37 @@
+source include/have_innodb.inc;
+source include/have_log_bin.inc;
+
+#
+# WL#2540 replication event checksum
+#
+# Objectives of the test are:
+# to demo binlog events with CRC32 checksum in them and 
+# to prove show binlog events and mysqlbinlog are capable to handle 
+# the checksum.
+#
+
+set @save_binlog_checksum = @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 1;
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+reset master; 
+--echo must be master-bin.000001 
+--source include/show_binary_logs.inc
+
+create table t1 (a int);
+flush logs;
+drop table t1;
+
+--source include/show_binlog_events.inc
+--exec $MYSQL_BINLOG -c $MYSQLD_DATADIR/master-bin.000001 | $MYSQL
+show tables;
+
+# clean-up 
+
+drop table t1;
+set @@global.binlog_checksum = @save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+
+--echo End of the tests

=== modified file 'mysql-test/suite/binlog/t/binlog_killed.test'
--- a/mysql-test/suite/binlog/t/binlog_killed.test	2010-09-26 23:06:44 +0000
+++ b/mysql-test/suite/binlog/t/binlog_killed.test	2010-10-25 19:02:24 +0000
@@ -36,16 +36,20 @@ let $ID= `select connection_id()`;
 # `reset master' problem is to be addressed by bug#15580 fixes.
 #
 reset master;
-let $start_pos= query_get_value("SHOW MASTER STATUS", Position, 1);
 send insert into t2 values (null, null), (null, get_lock("a", 10));
 
 
 connection con1;
 
-disable_abort_on_error;
-disable_query_log;
-disable_result_log;
+--disable_abort_on_error
+--disable_warnings
+
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where info like "%insert into t2 values%" and state like 'User lock';
+--source include/wait_condition.inc
 
+--replace_regex /[0-9]+/ID/
 eval kill query $ID;
 
 connection con2;
@@ -53,19 +57,23 @@ connection con2;
 reap;
 let $rows= `select count(*) from t2  /* must be 2 or 0 */`;
 let $MYSQLD_DATADIR= `select @@datadir`;
---exec $MYSQL_BINLOG --force-if-open --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
+
+--let $binlog_killed_pos=query_get_value(SHOW BINLOG EVENTS, Pos, 4)
+--let $binlog_killed_end_log_pos=query_get_value(SHOW BINLOG EVENTS, End_log_pos, 4)
+--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_killed_pos --stop-position=$binlog_killed_end_log_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--disable_result_log
 eval select
 (@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog"))
 is not null;
+--enable_result_log
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
 let $error_code= `select @a like "%#%error_code=0%" /* must return 1 or 0*/`;
 let $insert_binlogged= `select @a like "%insert into%" /* must return 1 or 0 */`;
-eval set @result= $rows- $error_code - $insert_binlogged;
+eval set @result= $rows - $error_code - $insert_binlogged;
 
-enable_abort_on_error;
-enable_query_log;
-enable_result_log;
+--enable_warnings
+--enable_abort_on_error
 
 if (`SELECT @result != 0`)
 {
@@ -267,19 +275,21 @@ connection con2;
 reap;
 select * from t4 order by b /* must be (1,1), (1,2) */;
 select @b  /* must be 1 at the end of a stmt calling bug27563() */;
---echo must have the update query event more to FD
+--echo must have the update query event on the 4th line
 source include/show_binlog_events.inc;
+--let $binlog_killed_pos= query_get_value(SHOW BINLOG EVENTS, Pos, 4)
+--let $binlog_killed_end_log_pos= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 4)
 
-# a proof the query is binlogged with an error
+--echo *** a proof the query is binlogged with an error ***
 
---exec $MYSQL_BINLOG --force-if-open --start-position=106 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
+--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_killed_pos --stop-position=$binlog_killed_end_log_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 eval select
 (@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
 is not null;
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
 let $error_code= `select @a like "%#%error_code=0%" /* must return 0*/`;
-eval select $error_code /* must return 0 to mean the killed query is in */;
+eval select $error_code /* must return 0 to mean the killed update is in */;
 
 # cleanup for the sub-case
 connection con1;
@@ -313,19 +323,21 @@ connection con2;
 reap;
 select count(*) from t4 /* must be 1 */;
 select @b  /* must be 1 at the end of a stmt calling bug27563() */;
---echo must have the delete query event more to FD
+--echo must have the delete query event on the 4th line
 source include/show_binlog_events.inc;
+--let $binlog_killed_pos= query_get_value(SHOW BINLOG EVENTS, Pos, 4)
+--let $binlog_killed_end_log_pos= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 4)
 
 # a proof the query is binlogged with an error
 
---exec $MYSQL_BINLOG --force-if-open --start-position=106 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
+--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_killed_pos --stop-position=$binlog_killed_end_log_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 eval select
 (@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
 is not null;
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
 let $error_code= `select @a like "%#%error_code=0%" /* must return 0*/`;
-eval select $error_code /* must return 0 to mean the killed query is in */;
+eval select $error_code /* must return 0 to mean the killed delete is in */;
 
 # cleanup for the sub-case
 connection con1;

=== modified file 'mysql-test/suite/binlog/t/binlog_old_versions.test'
--- a/mysql-test/suite/binlog/t/binlog_old_versions.test	2008-02-07 11:38:13 +0000
+++ b/mysql-test/suite/binlog/t/binlog_old_versions.test	2010-06-14 10:04:20 +0000
@@ -67,6 +67,11 @@ SELECT COUNT(*) FROM t3;
 DROP TABLE t1, t3;
 
 
+--echo *** wl#2540 Replication events checksum is not yet defined 
+--echo *** its born-version. One that is temporarily chosen conflicts with 
+--echo *** the version in the following pre-recorded binlogs
+--echo *** TODO: uncomment this snippet when the WL patches will be about to push
+
 --echo ==== Read binlog from alcatel tree (mysql-5.1-wl2325-5.0-drop6) ====
 
 # In this version, it was not possible to switch between row-based and
@@ -75,15 +80,15 @@ DROP TABLE t1, t3;
 # replication.
 
 # Read rbr binlog.
---exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-wl2325_r.001 | $MYSQL --local-infile=1
-# Read stm binlog.
---exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-wl2325_s.001 | $MYSQL --local-infile=1
-# Show result.
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-SELECT COUNT(*) FROM t3;
-# Reset.
-DROP TABLE t1, t2, t3;
+# --exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-wl2325_r.001 | $MYSQL --local-infile=1
+# # Read stm binlog.
+# --exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-wl2325_s.001 | $MYSQL --local-infile=1
+# # Show result.
+# SELECT * FROM t1 ORDER BY a;
+# SELECT * FROM t2 ORDER BY a;
+# SELECT COUNT(*) FROM t3;
+# # Reset.
+# DROP TABLE t1, t2, t3;
 
 
 --echo ==== Read binlog from ndb tree (mysql-5.1-telco-6.1) ====

=== modified file 'mysql-test/suite/binlog/t/disabled.def'
--- a/mysql-test/suite/binlog/t/disabled.def	2010-10-27 10:28:09 +0000
+++ b/mysql-test/suite/binlog/t/disabled.def	2010-11-16 12:14:06 +0000
@@ -11,3 +11,4 @@
 ##############################################################################
 binlog_truncate_innodb	: BUG#57291 2010-10-20 anitha Originally disabled due to BUG#42643. Product bug fixed, but test changes needed
 binlog_spurious_ddl_errors  : BUG#54195 2010-06-03 alik binlog_spurious_ddl_errors.test fails, thus disabled
+binlog_unsafe               : Bug#56678 2010-11-08 andrei (*local* to wl2540 tree! fixes of which are not arrived yet to mysql-next-mr-wl2540)

=== modified file 'mysql-test/suite/funcs_1/r/is_columns_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result	2010-11-15 16:43:41 +0000
@@ -150,6 +150,34 @@ def	mysql	servers	Server_name	1		NO	char
 def	mysql	servers	Socket	7		NO	char	64	192	NULL	NULL	utf8	utf8_general_ci	char(64)			select,insert,update,references	
 def	mysql	servers	Username	4		NO	char	64	192	NULL	NULL	utf8	utf8_general_ci	char(64)			select,insert,update,references	
 def	mysql	servers	Wrapper	8		NO	char	64	192	NULL	NULL	utf8	utf8_general_ci	char(64)			select,insert,update,references	
+def	mysql	slave_master_info	Bind	18	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Connect_retry	9	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned			select,insert,update,references	
+def	mysql	slave_master_info	Enabled_ssl	10	NULL	NO	tinyint	NULL	NULL	3	0	NULL	NULL	tinyint(1)			select,insert,update,references	
+def	mysql	slave_master_info	Heartbeat	17	NULL	NO	float	NULL	NULL	12	NULL	NULL	NULL	float			select,insert,update,references	
+def	mysql	slave_master_info	Host	5	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Ignored_server_ids	19	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Master_id	1	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned	PRI		select,insert,update,references	
+def	mysql	slave_master_info	Master_log_name	3	NULL	NO	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Master_log_pos	4	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	mysql	slave_master_info	Number_of_lines	2	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned			select,insert,update,references	
+def	mysql	slave_master_info	Port	8	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned			select,insert,update,references	
+def	mysql	slave_master_info	Retry_count	21	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	mysql	slave_master_info	Ssl_ca	11	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Ssl_capath	12	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Ssl_cert	13	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Ssl_cipher	14	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Ssl_key	15	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Ssl_verify_servert_cert	16	NULL	NO	tinyint	NULL	NULL	3	0	NULL	NULL	tinyint(1)			select,insert,update,references	
+def	mysql	slave_master_info	User_name	6	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	User_password	7	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_master_info	Uuid	20	NULL	YES	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_relay_log_info	Master_id	1	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned	PRI		select,insert,update,references	
+def	mysql	slave_relay_log_info	Master_log_name	5	NULL	NO	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_relay_log_info	Master_log_pos	6	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	mysql	slave_relay_log_info	Number_of_lines	2	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned			select,insert,update,references	
+def	mysql	slave_relay_log_info	Relay_log_name	3	NULL	NO	text	65535	65535	NULL	NULL	utf8	utf8_bin	text			select,insert,update,references	
+def	mysql	slave_relay_log_info	Relay_log_pos	4	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	mysql	slave_relay_log_info	Sql_delay	7	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(11)			select,insert,update,references	
 def	mysql	slow_log	db	7	NULL	NO	varchar	512	1536	NULL	NULL	utf8	utf8_general_ci	varchar(512)			select,insert,update,references	
 def	mysql	slow_log	insert_id	9	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(11)			select,insert,update,references	
 def	mysql	slow_log	last_insert_id	8	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(11)			select,insert,update,references	
@@ -274,6 +302,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_N
 COL_CML	DATA_TYPE	CHARACTER_SET_NAME	COLLATION_NAME
 NULL	bigint	NULL	NULL
 NULL	datetime	NULL	NULL
+NULL	float	NULL	NULL
 NULL	int	NULL	NULL
 NULL	smallint	NULL	NULL
 NULL	time	NULL	NULL
@@ -443,6 +472,34 @@ NULL	mysql	servers	Port	int	NULL	NULL	NU
 3.0000	mysql	servers	Socket	char	64	192	utf8	utf8_general_ci	char(64)
 3.0000	mysql	servers	Wrapper	char	64	192	utf8	utf8_general_ci	char(64)
 3.0000	mysql	servers	Owner	char	64	192	utf8	utf8_general_ci	char(64)
+NULL	mysql	slave_master_info	Master_id	int	NULL	NULL	NULL	NULL	int(10) unsigned
+NULL	mysql	slave_master_info	Number_of_lines	int	NULL	NULL	NULL	NULL	int(10) unsigned
+1.0000	mysql	slave_master_info	Master_log_name	text	65535	65535	utf8	utf8_bin	text
+NULL	mysql	slave_master_info	Master_log_pos	bigint	NULL	NULL	NULL	NULL	bigint(20) unsigned
+1.0000	mysql	slave_master_info	Host	text	65535	65535	utf8	utf8_bin	text
+1.0000	mysql	slave_master_info	User_name	text	65535	65535	utf8	utf8_bin	text
+1.0000	mysql	slave_master_info	User_password	text	65535	65535	utf8	utf8_bin	text
+NULL	mysql	slave_master_info	Port	int	NULL	NULL	NULL	NULL	int(10) unsigned
+NULL	mysql	slave_master_info	Connect_retry	int	NULL	NULL	NULL	NULL	int(10) unsigned
+NULL	mysql	slave_master_info	Enabled_ssl	tinyint	NULL	NULL	NULL	NULL	tinyint(1)
+1.0000	mysql	slave_master_info	Ssl_ca	text	65535	65535	utf8	utf8_bin	text
+1.0000	mysql	slave_master_info	Ssl_capath	text	65535	65535	utf8	utf8_bin	text
+1.0000	mysql	slave_master_info	Ssl_cert	text	65535	65535	utf8	utf8_bin	text
+1.0000	mysql	slave_master_info	Ssl_cipher	text	65535	65535	utf8	utf8_bin	text
+1.0000	mysql	slave_master_info	Ssl_key	text	65535	65535	utf8	utf8_bin	text
+NULL	mysql	slave_master_info	Ssl_verify_servert_cert	tinyint	NULL	NULL	NULL	NULL	tinyint(1)
+NULL	mysql	slave_master_info	Heartbeat	float	NULL	NULL	NULL	NULL	float
+1.0000	mysql	slave_master_info	Bind	text	65535	65535	utf8	utf8_bin	text
+1.0000	mysql	slave_master_info	Ignored_server_ids	text	65535	65535	utf8	utf8_bin	text
+1.0000	mysql	slave_master_info	Uuid	text	65535	65535	utf8	utf8_bin	text
+NULL	mysql	slave_master_info	Retry_count	bigint	NULL	NULL	NULL	NULL	bigint(20) unsigned
+NULL	mysql	slave_relay_log_info	Master_id	int	NULL	NULL	NULL	NULL	int(10) unsigned
+NULL	mysql	slave_relay_log_info	Number_of_lines	int	NULL	NULL	NULL	NULL	int(10) unsigned
+1.0000	mysql	slave_relay_log_info	Relay_log_name	text	65535	65535	utf8	utf8_bin	text
+NULL	mysql	slave_relay_log_info	Relay_log_pos	bigint	NULL	NULL	NULL	NULL	bigint(20) unsigned
+1.0000	mysql	slave_relay_log_info	Master_log_name	text	65535	65535	utf8	utf8_bin	text
+NULL	mysql	slave_relay_log_info	Master_log_pos	bigint	NULL	NULL	NULL	NULL	bigint(20) unsigned
+NULL	mysql	slave_relay_log_info	Sql_delay	int	NULL	NULL	NULL	NULL	int(11)
 NULL	mysql	slow_log	start_time	timestamp	NULL	NULL	NULL	NULL	timestamp
 1.0000	mysql	slow_log	user_host	mediumtext	16777215	16777215	utf8	utf8_general_ci	mediumtext
 NULL	mysql	slow_log	query_time	time	NULL	NULL	NULL	NULL	time

=== modified file 'mysql-test/suite/funcs_1/r/is_key_column_usage.result'
--- a/mysql-test/suite/funcs_1/r/is_key_column_usage.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/suite/funcs_1/r/is_key_column_usage.result	2010-11-15 16:43:41 +0000
@@ -111,6 +111,8 @@ def	mysql	PRIMARY	def	mysql	proxies_priv
 def	mysql	PRIMARY	def	mysql	proxies_priv	Proxied_host
 def	mysql	PRIMARY	def	mysql	proxies_priv	Proxied_user
 def	mysql	PRIMARY	def	mysql	servers	Server_name
+def	mysql	PRIMARY	def	mysql	slave_master_info	Master_id
+def	mysql	PRIMARY	def	mysql	slave_relay_log_info	Master_id
 def	mysql	PRIMARY	def	mysql	tables_priv	Host
 def	mysql	PRIMARY	def	mysql	tables_priv	Db
 def	mysql	PRIMARY	def	mysql	tables_priv	User

=== modified file 'mysql-test/suite/funcs_1/r/is_statistics.result'
--- a/mysql-test/suite/funcs_1/r/is_statistics.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/suite/funcs_1/r/is_statistics.result	2010-11-15 16:43:41 +0000
@@ -124,6 +124,8 @@ def	mysql	proxies_priv	mysql	PRIMARY
 def	mysql	proxies_priv	mysql	PRIMARY
 def	mysql	proxies_priv	mysql	Grantor
 def	mysql	servers	mysql	PRIMARY
+def	mysql	slave_master_info	mysql	PRIMARY
+def	mysql	slave_relay_log_info	mysql	PRIMARY
 def	mysql	tables_priv	mysql	PRIMARY
 def	mysql	tables_priv	mysql	PRIMARY
 def	mysql	tables_priv	mysql	PRIMARY

=== modified file 'mysql-test/suite/funcs_1/r/is_statistics_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_statistics_mysql.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/suite/funcs_1/r/is_statistics_mysql.result	2010-11-15 16:43:41 +0000
@@ -46,6 +46,8 @@ def	mysql	proxies_priv	0	mysql	PRIMARY	2
 def	mysql	proxies_priv	0	mysql	PRIMARY	3	Proxied_host	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	proxies_priv	0	mysql	PRIMARY	4	Proxied_user	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	servers	0	mysql	PRIMARY	1	Server_name	A	#CARD#	NULL	NULL		BTREE		
+def	mysql	slave_master_info	0	mysql	PRIMARY	1	Master_id	A	#CARD#	NULL	NULL		BTREE		
+def	mysql	slave_relay_log_info	0	mysql	PRIMARY	1	Master_id	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	tables_priv	1	mysql	Grantor	1	Grantor	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	tables_priv	0	mysql	PRIMARY	1	Host	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	tables_priv	0	mysql	PRIMARY	2	Db	A	#CARD#	NULL	NULL		BTREE		

=== modified file 'mysql-test/suite/funcs_1/r/is_table_constraints.result'
--- a/mysql-test/suite/funcs_1/r/is_table_constraints.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/suite/funcs_1/r/is_table_constraints.result	2010-11-15 16:43:41 +0000
@@ -75,6 +75,8 @@ def	mysql	PRIMARY	mysql	proc
 def	mysql	PRIMARY	mysql	procs_priv
 def	mysql	PRIMARY	mysql	proxies_priv
 def	mysql	PRIMARY	mysql	servers
+def	mysql	PRIMARY	mysql	slave_master_info
+def	mysql	PRIMARY	mysql	slave_relay_log_info
 def	mysql	PRIMARY	mysql	tables_priv
 def	mysql	PRIMARY	mysql	time_zone
 def	mysql	PRIMARY	mysql	time_zone_leap_second

=== modified file 'mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result	2010-11-15 16:43:41 +0000
@@ -25,6 +25,8 @@ def	mysql	PRIMARY	mysql	proc	PRIMARY KEY
 def	mysql	PRIMARY	mysql	procs_priv	PRIMARY KEY
 def	mysql	PRIMARY	mysql	proxies_priv	PRIMARY KEY
 def	mysql	PRIMARY	mysql	servers	PRIMARY KEY
+def	mysql	PRIMARY	mysql	slave_master_info	PRIMARY KEY
+def	mysql	PRIMARY	mysql	slave_relay_log_info	PRIMARY KEY
 def	mysql	PRIMARY	mysql	tables_priv	PRIMARY KEY
 def	mysql	PRIMARY	mysql	time_zone	PRIMARY KEY
 def	mysql	PRIMARY	mysql	time_zone_leap_second	PRIMARY KEY

=== modified file 'mysql-test/suite/funcs_1/r/is_tables_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_tables_mysql.result	2010-11-03 14:31:27 +0000
+++ b/mysql-test/suite/funcs_1/r/is_tables_mysql.result	2010-11-15 16:43:41 +0000
@@ -382,6 +382,52 @@ user_comment	MySQL Foreign Servers table
 Separator	-----------------------------------------------------
 TABLE_CATALOG	def
 TABLE_SCHEMA	mysql
+TABLE_NAME	slave_master_info
+TABLE_TYPE	BASE TABLE
+ENGINE	MyISAM
+VERSION	10
+ROW_FORMAT	Dynamic
+TABLE_ROWS	#TBLR#
+AVG_ROW_LENGTH	#ARL#
+DATA_LENGTH	#DL#
+MAX_DATA_LENGTH	#MDL#
+INDEX_LENGTH	#IL#
+DATA_FREE	#DF#
+AUTO_INCREMENT	NULL
+CREATE_TIME	#CRT#
+UPDATE_TIME	#UT#
+CHECK_TIME	#CT#
+TABLE_COLLATION	utf8_general_ci
+CHECKSUM	NULL
+CREATE_OPTIONS	#CO#
+TABLE_COMMENT	#TC#
+user_comment	Master Information
+Separator	-----------------------------------------------------
+TABLE_CATALOG	def
+TABLE_SCHEMA	mysql
+TABLE_NAME	slave_relay_log_info
+TABLE_TYPE	BASE TABLE
+ENGINE	MyISAM
+VERSION	10
+ROW_FORMAT	Dynamic
+TABLE_ROWS	#TBLR#
+AVG_ROW_LENGTH	#ARL#
+DATA_LENGTH	#DL#
+MAX_DATA_LENGTH	#MDL#
+INDEX_LENGTH	#IL#
+DATA_FREE	#DF#
+AUTO_INCREMENT	NULL
+CREATE_TIME	#CRT#
+UPDATE_TIME	#UT#
+CHECK_TIME	#CT#
+TABLE_COLLATION	utf8_general_ci
+CHECKSUM	NULL
+CREATE_OPTIONS	#CO#
+TABLE_COMMENT	#TC#
+user_comment	Relay Log Information
+Separator	-----------------------------------------------------
+TABLE_CATALOG	def
+TABLE_SCHEMA	mysql
 TABLE_NAME	slow_log
 TABLE_TYPE	BASE TABLE
 ENGINE	CSV

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result	2010-11-15 16:43:41 +0000
@@ -8,25 +8,25 @@ use performance_schema;
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
 user_table
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -39,25 +39,25 @@ use performance_schema;
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
 user_view
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -68,25 +68,25 @@ drop view test.user_view;
 create procedure test.user_proc()
 select "Not supposed to be here";
 update mysql.proc set db='performance_schema' where name='user_proc';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -97,25 +97,25 @@ drop procedure test.user_proc;
 create function test.user_func() returns integer
 return 0;
 update mysql.proc set db='performance_schema' where name='user_func';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -126,25 +126,25 @@ drop function test.user_func;
 create event test.user_event on schedule every 1 day do
 select "not supposed to be here";
 update mysql.event set db='performance_schema' where name='user_event';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result	2010-11-16 20:19:48 +0000
@@ -8,25 +8,25 @@ use performance_schema;
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
 user_table
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -39,25 +39,25 @@ use performance_schema;
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
 user_view
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -68,25 +68,25 @@ drop view test.user_view;
 create procedure test.user_proc()
 select "Not supposed to be here";
 update mysql.proc set db='performance_schema' where name='user_proc';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -97,25 +97,25 @@ drop procedure test.user_proc;
 create function test.user_func() returns integer
 return 0;
 update mysql.proc set db='performance_schema' where name='user_func';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -126,25 +126,25 @@ drop function test.user_func;
 create event test.user_event on schedule every 1 day do
 select "not supposed to be here";
 update mysql.event set db='performance_schema' where name='user_event';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result	2010-11-19 11:24:33 +0000
@@ -8,25 +8,25 @@ use performance_schema;
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
 user_table
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -39,25 +39,25 @@ use performance_schema;
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
 user_view
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -68,25 +68,25 @@ drop view test.user_view;
 create procedure test.user_proc()
 select "Not supposed to be here";
 update mysql.proc set db='performance_schema' where name='user_proc';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -97,25 +97,25 @@ drop procedure test.user_proc;
 create function test.user_func() returns integer
 return 0;
 update mysql.proc set db='performance_schema' where name='user_func';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -126,25 +126,25 @@ drop function test.user_func;
 create event test.user_event on schedule every 1 day do
 select "not supposed to be here";
 update mysql.event set db='performance_schema' where name='user_event';
-ERROR 1050 (42S01) at line 68: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 90: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 112: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 134: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 147: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 160: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 172: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 192: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 204: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 213: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 223: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 233: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 242: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 250: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 259: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 267: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 287: Table 'threads' already exists
-ERROR 1644 (HY000) at line 705: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
+ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 289: Table 'threads' already exists
+ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== added file 'mysql-test/suite/rpl/extension/README.checksum'
--- a/mysql-test/suite/rpl/extension/README.checksum	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/extension/README.checksum	2010-10-27 10:47:25 +0000
@@ -0,0 +1,23 @@
+Binlog checksum testing
+=======================
+
+1. How it works.
+The script copies a <suite> to directory <suite>_checksum, 
+collects test case names for t/ directory (except tests from
+disabled def), randomly choose 90% of tests and add them 
+to disabled.def.
+It means that mtr will run only 10% of random tests from each 
+suite.
+At end the script run mtr:
+./mysql-test-run.pl --suite=aaa_checksum,bbb_checksum \
+    --mysqld=--binlog-checksum=CRC32 arg1 ... argN
+
+aaa,bbb 	- suite names from --suite option
+arg1,argN	- other command-line arguments of checksum.pl
+
+2. The options:
+
+--suite=suite1,suite2.  Mandatory option. The list of suites for 
+    binlog checksum testing.
+
+--percent=N, where N is 1..99. Percent of running tests. 

=== added file 'mysql-test/suite/rpl/extension/checksum.pl'
--- a/mysql-test/suite/rpl/extension/checksum.pl	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/extension/checksum.pl	2010-10-27 10:47:25 +0000
@@ -0,0 +1,164 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+use File::Basename;
+use File::Copy qw(copy);
+use File::Spec qw(catdir);
+use File::Path;
+use IO::File;
+use strict;
+
+# Constants and variables with default values
+my $suites;
+my $suffix = "_checksum";
+my $percent_random_test = 10;
+my $mtr_script;
+my @mtr_argv;
+my @mtr_suites;
+
+# Check some arguments
+foreach my $arg ( @ARGV )
+{
+    if ($arg =~ m/\-\-suite\=(.+)/i)
+    {
+        $suites = $1;
+    }
+    elsif ($arg =~ m/\-\-percent\=(\d{1,2})/i)
+    {
+	$percent_random_test= $1;
+    }
+    else
+    {
+	push(@mtr_argv, $arg);
+    }
+    
+}
+if (! defined( $suites ) )
+{
+    die("The script requires --suite argument");
+}
+
+print "#################################################################\n";
+print "# Binlog checksum testing\n";
+print "# Run randomly $percent_random_test\% of tests from following suites: $suites\n";
+print "#################################################################\n";
+
+# Set extension directory
+my $ext_dir= dirname(File::Spec->rel2abs($0));
+# Set mysql-test directory
+my $mysql_test_dir= $ext_dir;
+$mysql_test_dir =~ s/(\/|\\)suite(\/|\\)rpl(\/|\\)extension$//;
+
+# Main loop
+foreach my $src_suite (split(",", $suites))
+{
+    $src_suite=~ s/ //g;
+    my $dest_suite= $src_suite . $suffix;
+    push( @mtr_suites, $dest_suite);
+    print "Creating suite $dest_suite\n";
+    # *** Set platform-independent pathes ***
+    # Set source directory of suite
+    my $src_suite_dir = File::Spec->catdir($mysql_test_dir, "suite", $src_suite);
+    # Set destination directory of suite
+    my $dest_suite_dir = File::Spec->catdir($mysql_test_dir, "suite", $dest_suite);
+    print "Copying files\n\tfrom '$src_suite_dir'\n\tto '$dest_suite_dir'\n";
+    dircopy($src_suite_dir, $dest_suite_dir);
+    my $test_case_dir= File::Spec->catdir($dest_suite_dir, "t");
+    # Read disabled.def
+    my %disabled = ();
+    print "Read disabled.def\n";
+    my $fh = new IO::File File::Spec->catdir($test_case_dir, "disabled.def"), "r";
+    if ( defined $fh ) 
+    {
+	my @lines = <$fh>;
+	undef $fh;
+	foreach my $line ( @lines )
+	{
+	    if ($line =~ m/^([a-zA-Z0-9_]+).+\:.+/i)
+	    {
+		$disabled{$1}= 1;
+	    }
+	}
+    }
+    # Read test case list
+    my %tests = ();
+    print "Generate test case list\n";
+    opendir my ($dh), $test_case_dir or die "Could not open dir '$test_case_dir': $!";
+    for my $entry (readdir $dh) 
+    {
+	if ( $entry =~ m/^([a-zA-Z0-9_]+)\.test$/i )
+	{
+	    my $test= $1;
+	    if ( ! defined( $disabled{$test}) )
+	    {
+		$tests{$test}= 1;
+	    }
+	}
+    }
+    closedir($dh);
+    # 
+    my @excluded = ();
+    my $excluded_test= int((((100 - $percent_random_test)/100) * scalar( keys %tests )));
+    while  ( $excluded_test > 0 )
+    {
+	my @cases = keys %tests;
+	my $test = $cases[int(rand(scalar(@cases)))];
+	push ( @excluded, $test . "\t\t: Excluded for $dest_suite\n" );
+	delete $tests{$test};		
+	$excluded_test--;
+    }
+    my $fh = new IO::File File::Spec->catdir($test_case_dir, "disabled.def"), O_WRONLY|O_APPEND;
+    if (defined $fh) {
+	print $fh join ("", sort @excluded);
+	undef $fh;
+    }
+    print "\t" . join("\n\t", sort keys %tests) . "\n";
+    
+}
+
+# Set path to mtr with arguments
+my $mtr_script = "perl " . File::Spec->catdir($mysql_test_dir, "mysql-test-run.pl") . 
+    " --suite=" . join(",", @mtr_suites) . " " . 
+    " --mysqld=--binlog-checksum=CRC32 " . 
+    join (" ", @mtr_argv);
+
+print "Run $mtr_script\n";
+system( $mtr_script );
+
+sub dircopy
+{
+    my ($from_dir, $to_dir)= @_;
+    mkdir $to_dir if (! -e $to_dir);
+    opendir my($dh), $from_dir or die "Could not open dir '$from_dir': $!";
+    for my $entry (readdir $dh) 
+    {
+	next if $entry =~ /^(\.|\.\.)$/;
+        my $source = File::Spec->catdir($from_dir, $entry);
+        my $destination = File::Spec->catdir($to_dir, $entry);
+        if (-d $source) 
+        {
+    	    mkdir $destination or die "mkdir '$destination' failed: $!" if not -e $destination;
+            dircopy($source, $destination);
+        } 
+        else 
+        {
+    	    copy($source, $destination) or die "copy '$source' to '$destination' failed: $!";
+        }
+    }
+    closedir $dh;
+    return;                                                                                                  
+}

=== modified file 'mysql-test/suite/rpl/r/rpl_change_master.result'
--- a/mysql-test/suite/rpl/r/rpl_change_master.result	2010-08-05 17:45:25 +0000
+++ b/mysql-test/suite/rpl/r/rpl_change_master.result	2010-11-23 23:10:22 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+call mtr.add_suppression("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum");
 create table t1(n int);
 select * from t1;
 n
@@ -68,6 +69,12 @@ CHANGE MASTER TO master_retry_count='a';
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''a'' at line 1
 CHANGE MASTER TO master_retry_count=-1;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1
+include/stop_slave.inc
+CHANGE MASTER TO master_connect_retry= 200, IGNORE_SERVER_IDS= (100, 200, 300, 400, 500);
+### stop slave server
+### start slave server
+include/start_slave.inc
+Eexpected values: "100, 200, 300, 400, 500" == "100, 200, 300, 400, 500" or 200 == 200
 stop slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 reset master;

=== added file 'mysql-test/suite/rpl/r/rpl_change_master_crash_safe.result'
--- a/mysql-test/suite/rpl/r/rpl_change_master_crash_safe.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_change_master_crash_safe.result	2010-11-24 11:02:26 +0000
@@ -0,0 +1,83 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+call mtr.add_suppression("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum");
+create table t1(n int);
+select * from t1;
+n
+stop slave sql_thread;
+insert into t1 values(1);
+insert into t1 values(2);
+include/stop_slave.inc
+change master to master_user='root';
+start slave;
+select * from t1;
+n
+1
+2
+drop table t1;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1 (a int);
+insert into t1 values (1);
+flush logs;
+insert into t1 values (2);
+include/stop_slave.inc
+delete from t1 where a=2;
+CHANGE MASTER TO relay_log_file='slave-relay-bin.000005', relay_log_pos=4;
+start slave sql_thread;
+start slave io_thread;
+set global relay_log_purge=1;
+drop table t1;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+Master_Retry_Count: 
+include/stop_slave.inc
+CHANGE MASTER TO master_retry_count=20;
+include/start_slave.inc
+include/stop_slave.inc
+CHANGE MASTER TO master_retry_count=0;
+include/start_slave.inc
+include/stop_slave.inc
+CHANGE MASTER TO master_retry_count=1;
+include/start_slave.inc
+include/stop_slave.inc
+CHANGE MASTER TO master_retry_count=10;
+include/start_slave.inc
+include/stop_slave.inc
+CHANGE MASTER TO master_retry_count=RETRY_COUNT_SET;
+SELECT RETRY_COUNT_EXPECTED AS current_retry_count;
+current_retry_count
+RETRY_COUNT_EXPECTED
+CHANGE MASTER TO master_connect_retry= 2;
+CHANGE MASTER TO master_connect_retry= 1;
+### stop slave server
+### start slave server
+include/start_slave.inc
+CHANGE MASTER TO master_retry_count='a';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''a'' at line 1
+CHANGE MASTER TO master_retry_count=-1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1
+include/stop_slave.inc
+CHANGE MASTER TO master_connect_retry= 200, IGNORE_SERVER_IDS= (100, 200, 300, 400, 500);
+### stop slave server
+### start slave server
+include/start_slave.inc
+Eexpected values: "100, 200, 300, 400, 500" == "100, 200, 300, 400, 500" or 200 == 200
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;

=== added file 'mysql-test/suite/rpl/r/rpl_checksum.result'
--- a/mysql-test/suite/rpl/r/rpl_checksum.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_checksum.result	2010-10-28 10:45:52 +0000
@@ -0,0 +1,124 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+call mtr.add_suppression('Slave can not handle replication events with the checksum that master is configured to log');
+call mtr.add_suppression('Replication event checksum verification failed');
+call mtr.add_suppression('Relay log write failure: could not queue event from master');
+set @master_save_binlog_checksum= @@global.binlog_checksum;
+set @save_master_verify_checksum =  @@global.master_verify_checksum;
+select @@global.binlog_checksum as 'must be CRC32 because of the command line option';
+must be CRC32 because of the command line option
+CRC32
+select @@session.binlog_checksum as 'no session var';
+ERROR HY000: Variable 'binlog_checksum' is a GLOBAL variable
+select @@global.master_verify_checksum  as 'must be zero because of default';
+must be zero because of default
+0
+select @@session.master_verify_checksum  as 'no session var';
+ERROR HY000: Variable 'master_verify_checksum' is a GLOBAL variable
+set @slave_save_binlog_checksum= @@global.binlog_checksum;
+set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
+select @@global.slave_sql_verify_checksum  as 'must be one because of default';
+must be one because of default
+1
+select @@session.slave_sql_verify_checksum  as 'no session var';
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable
+show binary logs;
+Log_name	File_size
+master-bin.000001	#
+set @@global.binlog_checksum = NONE;
+*** must be rotations seen ***
+show binary logs;
+Log_name	File_size
+master-bin.000001	#
+master-bin.000002	#
+set @@global.binlog_checksum = default;
+set @@global.binlog_checksum = CRC32;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+set @@global.binlog_checksum = ADLER32;
+ERROR 42000: Variable 'binlog_checksum' can't be set to the value of 'ADLER32'
+set @@global.master_verify_checksum = 2;
+ERROR 42000: Variable 'master_verify_checksum' can't be set to the value of '2'
+set @@global.slave_sql_verify_checksum = 0;
+set @@global.slave_sql_verify_checksum = default;
+set @@global.slave_sql_verify_checksum = 2;
+ERROR 42000: Variable 'slave_sql_verify_checksum' can't be set to the value of '2'
+set @@global.binlog_checksum = NONE;
+create table t1 (a int);
+flush logs;
+flush logs;
+flush logs;
+flush logs;
+flush logs;
+flush logs;
+select count(*) as zero from t1;
+zero
+0
+include/stop_slave.inc
+set @@global.binlog_checksum = CRC32;
+insert into t1 values (1) /* will not be applied on slave due to simulation */;
+set @@global.debug='d,simulate_slave_unaware_checksum';
+start slave;
+*** Got IO thread error code: 1236, text: Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log' ***
+select count(*) as zero from t1;
+zero
+0
+set @@global.debug='';
+include/start_slave.inc
+set @@global.master_verify_checksum = 1;
+set @@session.debug='d,simulate_checksum_test_failure';
+show binlog events;
+ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
+set @@session.debug='';
+set @@global.master_verify_checksum = default;
+include/stop_slave.inc
+create table t2 (a int);
+set @@global.debug='d,simulate_checksum_test_failure';
+start slave io_thread;
+*** Got IO thread error code: 1595, text: Relay log write failure: could not queue event from master ***
+set @@global.debug='';
+start slave io_thread;
+set @@global.slave_sql_verify_checksum = 1;
+set @@global.debug='d,simulate_checksum_test_failure';
+start slave sql_thread;
+*** Got SQL thread error code: 1593, text: Error initializing relay log position: I/O error reading event at position 4 ***
+set @@global.debug='';
+include/start_slave.inc
+select count(*) as 'must be zero' from t2;
+must be zero
+0
+stop slave;
+reset slave;
+set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
+flush logs;
+set @@global.binlog_checksum= CRC32;
+reset master;
+flush logs;
+create table t3 (a int, b char(5));
+include/start_slave.inc
+select count(*) as 'must be zero' from t3;
+must be zero
+0
+include/stop_slave.inc
+change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
+flush logs;
+reset master;
+insert into t3 value (1, @@global.binlog_checksum);
+include/start_slave.inc
+flush logs;
+select count(*) as 'must be one' from t3;
+must be one
+1
+set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
+insert into t3 value (1, @@global.binlog_checksum);
+drop table t1, t2, t3;
+set @@global.binlog_checksum = @master_save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+set @@global.binlog_checksum = @slave_save_binlog_checksum;
+set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
+End of tests

=== added file 'mysql-test/suite/rpl/r/rpl_checksum_cache.result'
--- a/mysql-test/suite/rpl/r/rpl_checksum_cache.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_checksum_cache.result	2010-11-11 02:11:10 +0000
@@ -0,0 +1,123 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into t2 set data=repeat.*'a', @act_size.*");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into t1 values.* NAME_CONST.*'n',.*, @data .*");
+set @save_binlog_cache_size = @@global.binlog_cache_size;
+set @save_binlog_checksum = @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+set @@global.binlog_cache_size = 4096;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 1;
+include/stop_slave.inc
+include/start_slave.inc
+flush status;
+show status like "binlog_cache_use";
+Variable_name	Value
+Binlog_cache_use	0
+show status like "binlog_cache_disk_use";
+Variable_name	Value
+Binlog_cache_disk_use	0
+drop table if exists t1;
+create table t1 (a int PRIMARY KEY, b CHAR(32)) engine=innodb;
+create procedure test.p_init (n int, size int) 
+begin
+while n > 0 do
+select round(RAND() * size) into @act_size;
+set @data = repeat('a', @act_size);
+insert into t1 values(n, @data );
+set n= n-1;
+end while;
+end|
+begin;
+call test.p_init(4000, 32);
+commit;
+show status like "binlog_cache_use";
+Variable_name	Value
+Binlog_cache_use	2
+*** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+Variable_name	Value
+Binlog_cache_disk_use	1
+Comparing tables master:test.t1 and slave:test.t1
+begin;
+delete from t1;
+commit;
+flush status;
+create table t2(a int auto_increment primary key, data VARCHAR(12288)) ENGINE=Innodb;
+show status like "binlog_cache_use";
+Variable_name	Value
+Binlog_cache_use	2
+*** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+Variable_name	Value
+Binlog_cache_disk_use	1
+Comparing tables master:test.t2 and slave:test.t2
+begin;
+delete from t2;
+commit;
+flush status;
+create table t3(a int auto_increment primary key, data VARCHAR(8192)) engine=innodb;
+show status like "binlog_cache_use";
+Variable_name	Value
+Binlog_cache_use	2
+*** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+Variable_name	Value
+Binlog_cache_disk_use	1
+Comparing tables master:test.t3 and slave:test.t3
+begin;
+delete from t3;
+commit;
+flush status;
+create procedure test.p1 (n int) 
+begin
+while n > 0 do
+case (select (round(rand()*100) % 3) + 1)
+when 1 then
+select round(RAND() * 32) into @act_size;
+set @data = repeat('a', @act_size);
+insert into t1 values(n, @data);
+when 2 then
+begin
+select round(8192 + RAND() * 4096) into @act_size;
+insert into t2 set data=repeat('a', @act_size);
+end;
+when 3 then
+begin
+select round(3686.4000 + RAND() * 819.2000) into @act_size;
+insert into t3 set data= repeat('a', @act_size);
+end;
+end case;
+set n= n-1;
+end while;
+end|
+set autocommit= 0;
+begin;
+call test.p1(1000);
+commit;
+show status like "binlog_cache_use";
+Variable_name	Value
+Binlog_cache_use	2
+*** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+Variable_name	Value
+Binlog_cache_disk_use	1
+Comparing tables master:test.t1 and slave:test.t1
+Comparing tables master:test.t2 and slave:test.t2
+Comparing tables master:test.t3 and slave:test.t3
+begin;
+delete from t1;
+delete from t2;
+delete from t3;
+commit;
+drop table t1, t2, t3;
+set @@global.binlog_cache_size = @save_binlog_cache_size;
+set @@global.binlog_checksum = @save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+drop procedure test.p_init;
+drop procedure test.p1;
+End of tests

=== added file 'mysql-test/suite/rpl/r/rpl_corruption.result'
--- a/mysql-test/suite/rpl/r/rpl_corruption.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_corruption.result	2010-11-11 02:11:10 +0000
@@ -0,0 +1,46 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+call mtr.add_suppression('Found invalid event in binary log');
+call mtr.add_suppression('Slave I/O: Relay log write failure: could not queue event from master');
+call mtr.add_suppression('event read from binlog did not pass crc check');
+call mtr.add_suppression('Replication event checksum verification failed');
+SET @old_master_verify_checksum = @@master_verify_checksum;
+# 1. Creating test table/data and set corruption position for testing
+* insert/update/delete rows in table t1 *
+CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100));
+include/stop_slave.inc
+# 2. Corruption in master binlog and SHOW BINLOG EVENTS
+SET GLOBAL debug="+d,corrupt_read_log_event_char";
+SHOW BINLOG EVENTS;
+ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
+SET GLOBAL debug="-d,corrupt_read_log_event_char";
+# 3. Master read a corrupted event from binlog and send the error to slave
+SET GLOBAL debug="+d,corrupt_read_log_event";
+START SLAVE IO_THREAD;
+SET GLOBAL debug="-d,corrupt_read_log_event";
+# 4. Master read a corrupted event from binlog and send it to slave
+SET GLOBAL master_verify_checksum=0;
+SET GLOBAL debug="+d,corrupt_read_log_event";
+START SLAVE IO_THREAD;
+SET GLOBAL debug="-d,corrupt_read_log_event";
+SET GLOBAL master_verify_checksum=1;
+# 5. Slave. Corruption in network
+SET GLOBAL debug="+d,corrupt_queue_event";
+START SLAVE IO_THREAD;
+SET GLOBAL debug="-d,corrupt_queue_event";
+# 6. Slave. Corruption in relay log
+SET GLOBAL debug="+d,corrupt_read_log_event_char";
+START SLAVE;
+SET GLOBAL debug="-d,corrupt_read_log_event_char";
+# 7. Seek diff for tables on master and slave
+include/start_slave.inc
+Comparing tables master:test.t1 and slave:test.t1
+# 8. Clean up
+SET GLOBAL debug= "";
+SET GLOBAL master_verify_checksum = @old_master_verify_checksum;
+DROP TABLE t1;
+SET GLOBAL debug= "";

=== modified file 'mysql-test/suite/rpl/r/rpl_heartbeat_basic.result'
--- a/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result	2010-10-21 11:34:17 +0000
+++ b/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result	2010-11-16 12:14:06 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+call mtr.add_suppression("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum");
 
 *** Preparing ***
 include/stop_slave.inc

=== added file 'mysql-test/suite/rpl/r/rpl_migration_crash_safe.result'
--- a/mysql-test/suite/rpl/r/rpl_migration_crash_safe.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_migration_crash_safe.result	2010-10-29 18:16:48 +0000
@@ -0,0 +1,15 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+include/stop_slave.inc
+CREATE TABLE test(id INTEGER NOT NULL PRIMARY KEY);
+INSERT INTO test VALUES (1), (2), (3);
+### stop slave server
+### start slave server with --relay-log-info-repository=TABLE
+### stop slave server
+### start slave server with --relay-log-info-repository=FILE
+include/start_slave.inc
+DROP TABLE test;

=== added file 'mysql-test/suite/rpl/r/rpl_mixed_crash_safe.result'
--- a/mysql-test/suite/rpl/r/rpl_mixed_crash_safe.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mixed_crash_safe.result	2010-11-16 12:48:25 +0000
@@ -0,0 +1,1208 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+call mtr.add_suppression('Attempting backtrace');
+call mtr.add_suppression("Recovery from master pos .* and file master-bin.000001");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression(".*  InnoDB: Warning: allocated tablespace .*, old maximum was .*");
+call mtr.add_suppression(".*int __cxa_pure_virtual().*");
+###################################################################################
+#                               PREPARE EXECUTION
+###################################################################################
+SET @verbose= 'Y';
+SET @commands= 'configure';
+SHOW CREATE TABLE mysql.slave_relay_log_info;
+Table	Create Table
+slave_relay_log_info	CREATE TABLE `slave_relay_log_info` (
+  `Master_id` int(10) unsigned NOT NULL,
+  `Number_of_lines` int(10) unsigned NOT NULL,
+  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Relay_log_pos` bigint(20) unsigned NOT NULL,
+  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Master_log_pos` bigint(20) unsigned NOT NULL,
+  `Sql_delay` int(11) NOT NULL,
+  PRIMARY KEY (`Master_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Relay Log Information'
+ALTER TABLE mysql.slave_relay_log_info ENGINE= Innodb;
+SHOW CREATE TABLE mysql.slave_relay_log_info;
+Table	Create Table
+slave_relay_log_info	CREATE TABLE `slave_relay_log_info` (
+  `Master_id` int(10) unsigned NOT NULL,
+  `Number_of_lines` int(10) unsigned NOT NULL,
+  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Relay_log_pos` bigint(20) unsigned NOT NULL,
+  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Master_log_pos` bigint(20) unsigned NOT NULL,
+  `Sql_delay` int(11) NOT NULL,
+  PRIMARY KEY (`Master_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Relay Log Information'
+SET SQL_LOG_BIN=0;
+CREATE TABLE nt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE tt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+SET SQL_LOG_BIN=1;
+SET SQL_LOG_BIN=0;
+CREATE TABLE nt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE tt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+SET SQL_LOG_BIN=1;
+INSERT INTO nt_1(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_2(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_3(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_4(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_6(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_1(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_2(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_3(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_4(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_6(trans_id, stmt_id) VALUES(1,1);
+CREATE PROCEDURE pc_i_tt_5_suc (IN p_trans_id INTEGER, IN p_stmt_id INTEGER)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+END|
+CREATE PROCEDURE pc_i_nt_5_suc (IN p_trans_id INTEGER, IN p_stmt_id INTEGER)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+END|
+CREATE FUNCTION fc_i_tt_5_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+RETURN "fc_i_tt_5_suc";
+END|
+CREATE FUNCTION fc_i_nt_5_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+RETURN "fc_i_nt_5_suc";
+END|
+CREATE TRIGGER tr_i_tt_3_to_nt_3 AFTER INSERT ON tt_3 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_3 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_3(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO nt_3(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_nt_4_to_tt_4 AFTER INSERT ON nt_4 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_4 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_4(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO tt_4(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_tt_5_to_tt_6 AFTER INSERT ON tt_5 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_6 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id, 1), 1) INTO in_stmt_id;
+INSERT INTO tt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO tt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_nt_5_to_nt_6 AFTER INSERT ON nt_5 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_6 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO nt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+SET @commands= '';
+###################################################################################
+#                         EXECUTE CASES CRASHING THE XID
+###################################################################################
+SET @failures= 'd,crash_after_apply d,crash_before_update_pos d,crash_after_update_pos_before_apply';
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (7, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (7, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (7, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (8, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (8, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (8, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (9, 1);
+fc_i_tt_5_suc (9, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(9,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(9,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (10, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',10),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',10),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',10),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',10),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (11, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (11, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (11, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (11, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (11, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (11, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (12, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (12, 4);
+fc_i_tt_5_suc (12, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (12, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(12,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (12, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(12,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (13, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (13, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (13, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',13),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',13),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (13, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',13),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',13),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (14, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (14, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (14, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (14, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (14, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (14, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (15, 2);
+fc_i_tt_5_suc (15, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (15, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(15,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (15, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(15,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (15, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (16, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (16, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',16),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',16),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (16, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',16),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',16),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (16, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (17, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (17, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (17, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (18, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (18, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (18, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (19, 1);
+fc_i_tt_5_suc (19, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(19,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(19,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (20, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',20),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',20),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',20),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',20),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (21, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (21, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (21, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (21, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (21, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (21, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (22, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (22, 4);
+fc_i_tt_5_suc (22, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (22, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(22,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (22, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(22,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (23, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (23, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (23, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',23),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',23),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (23, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',23),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',23),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (24, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (24, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (24, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (24, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (24, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (24, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (25, 2);
+fc_i_tt_5_suc (25, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (25, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(25,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (25, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(25,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (25, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (26, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (26, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',26),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',26),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (26, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',26),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',26),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (26, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (27, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (27, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (27, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (28, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (28, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (28, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (29, 1);
+fc_i_tt_5_suc (29, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(29,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(29,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (30, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',30),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',30),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',30),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',30),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (31, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (31, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (31, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (31, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (31, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (31, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (32, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (32, 4);
+fc_i_tt_5_suc (32, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (32, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(32,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (32, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(32,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (33, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (33, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (33, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',33),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',33),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (33, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',33),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',33),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (34, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (34, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (34, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (34, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (34, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (34, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (35, 2);
+fc_i_tt_5_suc (35, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (35, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(35,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (35, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(35,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (35, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (36, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (36, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',36),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',36),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (36, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',36),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',36),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (36, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+###################################################################################
+#                      EXECUTE CASES CRASHING THE BEGIN/COMMIT
+###################################################################################
+SET @failures= 'd,crash_after_commit_and_update_pos';
+
+
+
+SET @commands= 'N';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO nt_1(trans_id, stmt_id) VALUES (37, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_1(trans_id, stmt_id) VALUES (37, 1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_1(trans_id, stmt_id) VALUES (37, 1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'N-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (38, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_5(trans_id, stmt_id) VALUES (38, 1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_5(trans_id, stmt_id) VALUES (38, 1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'N-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_nt_5_suc (39, 1);
+fc_i_nt_5_suc (39, 1)
+fc_i_nt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_nt_5_suc`(39,1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_nt_5_suc`(39,1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+###################################################################################
+#                               CHECK CONSISTENCY
+###################################################################################
+###################################################################################
+#                                        CLEAN
+###################################################################################
+SET @commands= 'clean';
+DROP TABLE tt_1;
+DROP TABLE tt_2;
+DROP TABLE tt_3;
+DROP TABLE tt_4;
+DROP TABLE tt_5;
+DROP TABLE tt_6;
+DROP TABLE nt_1;
+DROP TABLE nt_2;
+DROP TABLE nt_3;
+DROP TABLE nt_4;
+DROP TABLE nt_5;
+DROP TABLE nt_6;
+DROP PROCEDURE pc_i_tt_5_suc;
+DROP PROCEDURE pc_i_nt_5_suc;
+DROP FUNCTION fc_i_tt_5_suc;
+DROP FUNCTION fc_i_nt_5_suc;
+SET @commands= '';

=== modified file 'mysql-test/suite/rpl/r/rpl_rotate_logs.result'
--- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result	2010-08-05 17:45:25 +0000
+++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result	2010-10-25 19:02:24 +0000
@@ -74,7 +74,7 @@ insert into temp_table values ("testing
 create table t3 (n int);
 select count(*) from t3 where n >= 4;
 count(*)
-100
+90
 create table t4 select * from temp_table;
 show binary logs;
 Log_name	File_size
@@ -96,7 +96,7 @@ Checking that both slave threads are run
 lock tables t3 read;
 select count(*) from t3 where n >= 4;
 count(*)
-100
+90
 unlock tables;
 drop table if exists t1,t2,t3,t4;
 End of 4.1 tests

=== modified file 'mysql-test/suite/rpl/r/rpl_row_conflicts.result'
--- a/mysql-test/suite/rpl/r/rpl_row_conflicts.result	2010-09-01 02:51:08 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_conflicts.result	2010-10-25 19:02:24 +0000
@@ -51,7 +51,8 @@ SELECT * FROM t1;
 a
 [on slave]
 ---- Wait until slave stops with an error ----
-Last_SQL_Error = Could not execute Delete_rows event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log master-bin.000001, end_log_pos 985 (expected "can't find record" error)
+Last_SQL_Error (expected "duplicate key" error)
+Could not execute Delete_rows event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log master-bin.000001, end_log_pos END_LOG_POS
 SELECT * FROM t1;
 a
 ---- Resolve the conflict on the slave and restart SQL thread ----

=== added file 'mysql-test/suite/rpl/r/rpl_row_crash_safe.result'
--- a/mysql-test/suite/rpl/r/rpl_row_crash_safe.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_crash_safe.result	2010-11-16 12:48:25 +0000
@@ -0,0 +1,1520 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+call mtr.add_suppression('Attempting backtrace');
+call mtr.add_suppression("Recovery from master pos .* and file master-bin.000001");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression(".*  InnoDB: Warning: allocated tablespace .*, old maximum was .*");
+call mtr.add_suppression(".*int __cxa_pure_virtual().*");
+###################################################################################
+#                               PREPARE EXECUTION
+###################################################################################
+SET @verbose= 'Y';
+SET @commands= 'configure';
+SHOW CREATE TABLE mysql.slave_relay_log_info;
+Table	Create Table
+slave_relay_log_info	CREATE TABLE `slave_relay_log_info` (
+  `Master_id` int(10) unsigned NOT NULL,
+  `Number_of_lines` int(10) unsigned NOT NULL,
+  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Relay_log_pos` bigint(20) unsigned NOT NULL,
+  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Master_log_pos` bigint(20) unsigned NOT NULL,
+  `Sql_delay` int(11) NOT NULL,
+  PRIMARY KEY (`Master_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Relay Log Information'
+ALTER TABLE mysql.slave_relay_log_info ENGINE= Innodb;
+SHOW CREATE TABLE mysql.slave_relay_log_info;
+Table	Create Table
+slave_relay_log_info	CREATE TABLE `slave_relay_log_info` (
+  `Master_id` int(10) unsigned NOT NULL,
+  `Number_of_lines` int(10) unsigned NOT NULL,
+  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Relay_log_pos` bigint(20) unsigned NOT NULL,
+  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Master_log_pos` bigint(20) unsigned NOT NULL,
+  `Sql_delay` int(11) NOT NULL,
+  PRIMARY KEY (`Master_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Relay Log Information'
+SET SQL_LOG_BIN=0;
+CREATE TABLE nt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE tt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+SET SQL_LOG_BIN=1;
+SET SQL_LOG_BIN=0;
+CREATE TABLE nt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE tt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+SET SQL_LOG_BIN=1;
+INSERT INTO nt_1(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_2(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_3(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_4(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_6(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_1(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_2(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_3(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_4(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_6(trans_id, stmt_id) VALUES(1,1);
+CREATE PROCEDURE pc_i_tt_5_suc (IN p_trans_id INTEGER, IN p_stmt_id INTEGER)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+END|
+CREATE PROCEDURE pc_i_nt_5_suc (IN p_trans_id INTEGER, IN p_stmt_id INTEGER)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+END|
+CREATE FUNCTION fc_i_tt_5_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+RETURN "fc_i_tt_5_suc";
+END|
+CREATE FUNCTION fc_i_nt_5_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+RETURN "fc_i_nt_5_suc";
+END|
+CREATE TRIGGER tr_i_tt_3_to_nt_3 AFTER INSERT ON tt_3 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_3 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_3(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO nt_3(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_nt_4_to_tt_4 AFTER INSERT ON nt_4 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_4 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_4(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO tt_4(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_tt_5_to_tt_6 AFTER INSERT ON tt_5 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_6 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id, 1), 1) INTO in_stmt_id;
+INSERT INTO tt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO tt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_nt_5_to_nt_6 AFTER INSERT ON nt_5 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_6 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO nt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+SET @commands= '';
+###################################################################################
+#                         EXECUTE CASES CRASHING THE XID
+###################################################################################
+SET @failures= 'd,crash_after_apply d,crash_before_update_pos d,crash_after_update_pos_before_apply';
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (7, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (8, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (9, 1);
+fc_i_tt_5_suc (9, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (10, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (11, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (11, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (12, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (12, 4);
+fc_i_tt_5_suc (12, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (13, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (13, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (14, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (14, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (15, 2);
+fc_i_tt_5_suc (15, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (15, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (16, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (16, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (17, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (18, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (19, 1);
+fc_i_tt_5_suc (19, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (20, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (21, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (21, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (22, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (22, 4);
+fc_i_tt_5_suc (22, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (23, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (23, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (24, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (24, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (25, 2);
+fc_i_tt_5_suc (25, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (25, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (26, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (26, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (27, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (28, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (29, 1);
+fc_i_tt_5_suc (29, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (30, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (31, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (31, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (32, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (32, 4);
+fc_i_tt_5_suc (32, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (33, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (33, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (34, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (34, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (35, 2);
+fc_i_tt_5_suc (35, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (35, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (36, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (36, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	#	#	table_id: # (test.tt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+###################################################################################
+#                      EXECUTE CASES CRASHING THE BEGIN/COMMIT
+###################################################################################
+SET @failures= 'd,crash_after_commit_and_update_pos';
+
+
+
+SET @commands= 'N';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO nt_1(trans_id, stmt_id) VALUES (37, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'N-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (38, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'N-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_nt_5_suc (39, 1);
+fc_i_nt_5_suc (39, 1)
+fc_i_nt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+###################################################################################
+#                               CHECK CONSISTENCY
+###################################################################################
+###################################################################################
+#                                        CLEAN
+###################################################################################
+SET @commands= 'clean';
+DROP TABLE tt_1;
+DROP TABLE tt_2;
+DROP TABLE tt_3;
+DROP TABLE tt_4;
+DROP TABLE tt_5;
+DROP TABLE tt_6;
+DROP TABLE nt_1;
+DROP TABLE nt_2;
+DROP TABLE nt_3;
+DROP TABLE nt_4;
+DROP TABLE nt_5;
+DROP TABLE nt_6;
+DROP PROCEDURE pc_i_tt_5_suc;
+DROP PROCEDURE pc_i_nt_5_suc;
+DROP FUNCTION fc_i_tt_5_suc;
+DROP FUNCTION fc_i_nt_5_suc;
+SET @commands= '';

=== modified file 'mysql-test/suite/rpl/r/rpl_server_uuid.result'
--- a/mysql-test/suite/rpl/r/rpl_server_uuid.result	2010-10-08 14:23:55 +0000
+++ b/mysql-test/suite/rpl/r/rpl_server_uuid.result	2010-10-25 19:02:24 +0000
@@ -8,6 +8,8 @@ call mtr.add_suppression("Slave I/O thre
 call mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: .*");
 CALL mtr.add_suppression(".*master and slave have equal MySQL server UUIDs.*");
 CALL mtr.add_suppression("Master's UUID has changed, its old UUID is.*");
+CALL mtr.add_suppression("Slave I/O: SET @master_heartbeat_period to master failed with error: Lost connection to MySQL server during query");
+CALL mtr.add_suppression("Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error");
 
 # Case 1:
 # Master's UUID appears in the result of 'SHOW SLAVE STATUS'.

=== added file 'mysql-test/suite/rpl/r/rpl_stm_crash_safe.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_crash_safe.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_crash_safe.result	2010-11-16 12:48:25 +0000
@@ -0,0 +1,1208 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+call mtr.add_suppression('Attempting backtrace');
+call mtr.add_suppression("Recovery from master pos .* and file master-bin.000001");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression(".*  InnoDB: Warning: allocated tablespace .*, old maximum was .*");
+call mtr.add_suppression(".*int __cxa_pure_virtual().*");
+###################################################################################
+#                               PREPARE EXECUTION
+###################################################################################
+SET @verbose= 'Y';
+SET @commands= 'configure';
+SHOW CREATE TABLE mysql.slave_relay_log_info;
+Table	Create Table
+slave_relay_log_info	CREATE TABLE `slave_relay_log_info` (
+  `Master_id` int(10) unsigned NOT NULL,
+  `Number_of_lines` int(10) unsigned NOT NULL,
+  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Relay_log_pos` bigint(20) unsigned NOT NULL,
+  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Master_log_pos` bigint(20) unsigned NOT NULL,
+  `Sql_delay` int(11) NOT NULL,
+  PRIMARY KEY (`Master_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Relay Log Information'
+ALTER TABLE mysql.slave_relay_log_info ENGINE= Innodb;
+SHOW CREATE TABLE mysql.slave_relay_log_info;
+Table	Create Table
+slave_relay_log_info	CREATE TABLE `slave_relay_log_info` (
+  `Master_id` int(10) unsigned NOT NULL,
+  `Number_of_lines` int(10) unsigned NOT NULL,
+  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Relay_log_pos` bigint(20) unsigned NOT NULL,
+  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+  `Master_log_pos` bigint(20) unsigned NOT NULL,
+  `Sql_delay` int(11) NOT NULL,
+  PRIMARY KEY (`Master_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Relay Log Information'
+SET SQL_LOG_BIN=0;
+CREATE TABLE nt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE tt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+SET SQL_LOG_BIN=1;
+SET SQL_LOG_BIN=0;
+CREATE TABLE nt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE nt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
+CREATE TABLE tt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+CREATE TABLE tt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = Innodb;
+SET SQL_LOG_BIN=1;
+INSERT INTO nt_1(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_2(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_3(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_4(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO nt_6(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_1(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_2(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_3(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_4(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES(1,1);
+INSERT INTO tt_6(trans_id, stmt_id) VALUES(1,1);
+CREATE PROCEDURE pc_i_tt_5_suc (IN p_trans_id INTEGER, IN p_stmt_id INTEGER)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+END|
+CREATE PROCEDURE pc_i_nt_5_suc (IN p_trans_id INTEGER, IN p_stmt_id INTEGER)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+END|
+CREATE FUNCTION fc_i_tt_5_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+RETURN "fc_i_tt_5_suc";
+END|
+CREATE FUNCTION fc_i_nt_5_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_5 WHERE trans_id= p_trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
+RETURN "fc_i_nt_5_suc";
+END|
+CREATE TRIGGER tr_i_tt_3_to_nt_3 AFTER INSERT ON tt_3 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_3 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_3(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO nt_3(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_nt_4_to_tt_4 AFTER INSERT ON nt_4 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_4 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO tt_4(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO tt_4(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_tt_5_to_tt_6 AFTER INSERT ON tt_5 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM tt_6 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id, 1), 1) INTO in_stmt_id;
+INSERT INTO tt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO tt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+CREATE TRIGGER tr_i_nt_5_to_nt_6 AFTER INSERT ON nt_5 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+SELECT max(stmt_id) INTO in_stmt_id FROM nt_6 WHERE trans_id= NEW.trans_id;
+SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
+INSERT INTO nt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
+INSERT INTO nt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
+END|
+SET @commands= '';
+###################################################################################
+#                         EXECUTE CASES CRASHING THE XID
+###################################################################################
+SET @failures= 'd,crash_after_apply d,crash_before_update_pos d,crash_after_update_pos_before_apply';
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (7, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (7, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (7, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (8, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (8, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (8, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (9, 1);
+fc_i_tt_5_suc (9, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(9,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(9,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (10, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',10),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',10),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',10),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',10),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (11, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (11, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (11, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (11, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (11, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (11, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (12, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (12, 4);
+fc_i_tt_5_suc (12, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (12, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(12,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (12, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(12,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (13, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (13, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (13, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',13),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',13),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (13, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',13),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',13),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (14, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (14, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (14, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (14, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (14, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (14, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (15, 2);
+fc_i_tt_5_suc (15, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (15, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(15,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (15, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(15,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (15, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_apply";;
+FAILURE d,crash_after_apply and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (16, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (16, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',16),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',16),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (16, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',16),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',16),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (16, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (17, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (17, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (17, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (18, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (18, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (18, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (19, 1);
+fc_i_tt_5_suc (19, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(19,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(19,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (20, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',20),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',20),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',20),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',20),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (21, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (21, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (21, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (21, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (21, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (21, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (22, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (22, 4);
+fc_i_tt_5_suc (22, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (22, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(22,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (22, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(22,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (23, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (23, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (23, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',23),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',23),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (23, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',23),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',23),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (24, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (24, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (24, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (24, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (24, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (24, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (25, 2);
+fc_i_tt_5_suc (25, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (25, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(25,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (25, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(25,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (25, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_before_update_pos";;
+FAILURE d,crash_before_update_pos and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (26, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (26, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',26),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',26),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (26, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',26),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',26),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (26, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (27, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (27, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (27, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (28, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (28, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (28, 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (29, 1);
+fc_i_tt_5_suc (29, 1)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(29,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(29,1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'T-proc';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (30, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',30),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',30),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',30),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',30),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-trig C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (31, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (31, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (31, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (31, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (31, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (31, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-func C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (32, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (32, 4);
+fc_i_tt_5_suc (32, 4)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (32, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(32,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-func C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (32, 2)
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(32,4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-func C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T T-proc C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (33, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (33, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (33, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',33),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',33),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T T-proc C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (33, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',33),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',33),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T T-proc C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-trig T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_5(trans_id, stmt_id) VALUES (34, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (34, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (34, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (34, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-trig T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES (34, 2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (34, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-trig T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-func T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_tt_5_suc (35, 2);
+fc_i_tt_5_suc (35, 2)
+fc_i_tt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (35, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(35,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (35, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-func T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_tt_5_suc`(35,2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (35, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-func T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'B T-proc T C';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_update_pos_before_apply";;
+FAILURE d,crash_after_update_pos_before_apply and OUTCOME O1
+-b-b-b-b-b-b-b-b-b-b-b- >> B << -b-b-b-b-b-b-b-b-b-b-b-
+BEGIN;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> B << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T-proc << -b-b-b-b-b-b-b-b-b-b-b-
+CALL pc_i_tt_5_suc (36, 2);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T-proc << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> T << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO tt_1(trans_id, stmt_id) VALUES (36, 4);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+-e-e-e-e-e-e-e-e-e-e-e- >> T << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> C << -b-b-b-b-b-b-b-b-b-b-b-
+COMMIT;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',36),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',36),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (36, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> C << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> B T-proc T C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',36),  NAME_CONST('in_stmt_id',1))
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_5(trans_id, stmt_id) VALUES ( NAME_CONST('p_trans_id',36),  NAME_CONST('in_stmt_id',1) + 1)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_1(trans_id, stmt_id) VALUES (36, 4)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T-proc T C << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+###################################################################################
+#                      EXECUTE CASES CRASHING THE BEGIN/COMMIT
+###################################################################################
+SET @failures= 'd,crash_after_commit_and_update_pos';
+
+
+
+SET @commands= 'N';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO nt_1(trans_id, stmt_id) VALUES (37, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_1(trans_id, stmt_id) VALUES (37, 1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_1(trans_id, stmt_id) VALUES (37, 1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'N-trig';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N-trig << -b-b-b-b-b-b-b-b-b-b-b-
+INSERT INTO nt_5(trans_id, stmt_id) VALUES (38, 1);
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_5(trans_id, stmt_id) VALUES (38, 1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-trig << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N-trig << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_5(trans_id, stmt_id) VALUES (38, 1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-trig << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+
+
+
+SET @commands= 'N-func';
+STOP SLAVE SQL_THREAD;
+SET GLOBAL debug="d,crash_after_commit_and_update_pos";;
+FAILURE d,crash_after_commit_and_update_pos and OUTCOME O2
+-b-b-b-b-b-b-b-b-b-b-b- >> N-func << -b-b-b-b-b-b-b-b-b-b-b-
+SELECT fc_i_nt_5_suc (39, 1);
+fc_i_nt_5_suc (39, 1)
+fc_i_nt_5_suc
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_nt_5_suc`(39,1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-func << -e-e-e-e-e-e-e-e-e-e-e-
+-b-b-b-b-b-b-b-b-b-b-b- >> N-func << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SELECT `test`.`fc_i_nt_5_suc`(39,1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> N-func << -e-e-e-e-e-e-e-e-e-e-e-
+
+START SLAVE;
+###################################################################################
+#                               CHECK CONSISTENCY
+###################################################################################
+###################################################################################
+#                                        CLEAN
+###################################################################################
+SET @commands= 'clean';
+DROP TABLE tt_1;
+DROP TABLE tt_2;
+DROP TABLE tt_3;
+DROP TABLE tt_4;
+DROP TABLE tt_5;
+DROP TABLE tt_6;
+DROP TABLE nt_1;
+DROP TABLE nt_2;
+DROP TABLE nt_3;
+DROP TABLE nt_4;
+DROP TABLE nt_5;
+DROP TABLE nt_6;
+DROP PROCEDURE pc_i_tt_5_suc;
+DROP PROCEDURE pc_i_nt_5_suc;
+DROP FUNCTION fc_i_tt_5_suc;
+DROP FUNCTION fc_i_nt_5_suc;
+SET @commands= '';

=== modified file 'mysql-test/suite/rpl/t/disabled.def'
--- a/mysql-test/suite/rpl/t/disabled.def	2010-11-12 11:37:06 +0000
+++ b/mysql-test/suite/rpl/t/disabled.def	2010-11-16 12:14:06 +0000
@@ -13,4 +13,6 @@
 rpl_change_master         : Bug#58160 2010-11-12 alik Incorrect behaviour of rpl_chage_master
 rpl_row_create_table      : Bug#51574 2010-02-27 andrei failed different way than earlier with bug#45576
 rpl_spec_variables        : BUG#47661 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux
+rpl_row_event_max_size    : Bug#55675 2010-10-25 andrei mysql_binlog_send attempts to read events partly
+rpl_delayed_slave         : Bug#57514 2010-11-09 andrei rpl_delayed_slave fails sporadically in pb
 rpl_log_pos               : BUG#55675 2010-09-10 alfranio rpl.rpl_log_pos fails sporadically with error binlog truncated in the middle

=== modified file 'mysql-test/suite/rpl/t/rpl_change_master.test'
--- a/mysql-test/suite/rpl/t/rpl_change_master.test	2010-10-07 16:39:57 +0000
+++ b/mysql-test/suite/rpl/t/rpl_change_master.test	2010-11-23 23:10:22 +0000
@@ -1,244 +1,9 @@
-# Verify that after CHANGE MASTER, replication (I/O thread and SQL
-# thread) restart from where SQL thread left, not from where
-# I/O thread left (some old bug fixed in 4.0.17)
 
-source include/master-slave.inc;
-
-connection master;
-# Make SQL slave thread advance a bit
-create table t1(n int);
-sync_slave_with_master;
-select * from t1;
-# Now stop it and make I/O slave thread be ahead
-stop slave sql_thread;
-connection master;
-insert into t1 values(1);
-insert into t1 values(2);
-save_master_pos;
-let $slave_param= Read_Master_Log_Pos;
-let $slave_param_value= query_get_value(SHOW MASTER STATUS, Position, 1);
-connection slave;
-source include/wait_for_slave_param.inc;
-source include/stop_slave.inc;
-
-let $read_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
-let $exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
-if (`SELECT $read_pos = $exec_pos`)
-{
-  source include/show_rpl_debug_info.inc;
-  echo 'Read_Master_Log_Pos: $read_pos' == 'Exec_Master_Log_Pos: $exec_pos';
-  die Failed because Read_Master_Log_Pos is equal to Exec_Master_Log_Pos;
-} 
-change master to master_user='root';
-let $read_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
-let $exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
-if (`SELECT $read_pos <> $exec_pos`)
-{
-  source include/show_rpl_debug_info.inc;
-  echo 'Read_Master_Log_Pos: $read_pos' <> 'Exec_Master_Log_Pos: $exec_pos';
-  die Failed because Read_Master_Log_Pos is not equal to Exec_Master_Log_Pos;
-}
-
-start slave;
-sync_with_master;
-select * from t1;
-connection master;
-drop table t1;
-sync_slave_with_master;
-
-# End of 4.1 tests
-
-#
-# BUG#12190 CHANGE MASTER has differ path requiremts on MASTER_LOG_FILE and RELAY_LOG_FILE
+# This test calls CHANGE MASTER in order to check if replication can
+# restart from where SQL thread left, not from where I/O thread left.
+#  
+# File is used as repository.
 #
 
-source include/master-slave-reset.inc;
-
-connection master;
-create table t1 (a int);
-insert into t1 values (1);
-flush logs;
-insert into t1 values (2);
-
-# Note: the master positon saved by this will also be used by the
-# 'sync_with_master' below.
-sync_slave_with_master;
-
-# Check if the table t1 and t2 are identical on master and slave;
-let $diff_table_1= master:test.t1
-let $diff_table_2= slave:test.t1
-source include/diff_tables.inc;
-
-connection slave;
-source include/stop_slave.inc;
-delete from t1 where a=2;
-
-# start replication from the second insert, after fix of BUG#12190,
-# relay_log_file does not use absolute path, only the filename is
-# required
-#
-# Note: the follow change master will automatically reset
-# relay_log_purge to false, save the old value to restore
-let $relay_log_purge= `select @@global.relay_log_purge`;
-CHANGE MASTER TO relay_log_file='slave-relay-bin.000005', relay_log_pos=4;
-start slave sql_thread;
-source include/wait_for_slave_sql_to_start.inc;
-
-# Sync to the same position saved by the 'sync_slave_with_master' above.
-sync_with_master;
-
-# Check if the table t1 and t2 are identical on master and slave;
-let $diff_table_1= master:test.t1
-let $diff_table_2= slave:test.t1
-source include/diff_tables.inc;
-
-# clean up
-connection slave;
-start slave io_thread;
-source include/wait_for_slave_io_to_start.inc;
-eval set global relay_log_purge=$relay_log_purge;
-connection master;
-drop table t1;
-sync_slave_with_master;
-
-#
-# BUG#44209: MASTER_CONNECT_RETRY and --master-retry-count disconnected from each other
-#
-
--- connection master
--- source include/master-slave-reset.inc
-
--- connection slave
--- let $retry_count0= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
-
-# assertion: show that the command line is still valid (MTR sets it to 10)
--- echo Master_Retry_Count: $retry_count
-
--- source include/stop_slave.inc
-
-# action: change the initial value to some other value
--- let $retry_count1= `SELECT $retry_count0+10`
--- eval CHANGE MASTER TO master_retry_count=$retry_count1
-
--- source include/start_slave.inc
-
--- let $retry_count1= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
-# assertion: it shows the new value -- retry_count0 +10
-if (`SELECT $retry_count1 <> ($retry_count0+10)`)
-{
-  -- let $expected= `SELECT $retry_count0+10`
-  -- echo Unexpected retry count value! Got: $retry_count1, expected: $expected
-  -- die
-}
-
--- source include/stop_slave.inc
-
-# action: change master_retry_count to zero will set it to zero.
--- let $retry_count1= 0
--- eval CHANGE MASTER TO master_retry_count=$retry_count1
-
--- source include/start_slave.inc
-
--- let $retry_count2= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
-# assertion: it shows no changes
-if (`SELECT $retry_count2 <> $retry_count1`)
-{
-  -- echo Unexpected retry count value! Got: $retry_count2, expected: $retry_count1
-  -- die
-}
-
--- source include/stop_slave.inc
-
-# action: change the value to the smallest value possible
-CHANGE MASTER TO master_retry_count=1;
-
--- source include/start_slave.inc
-
--- let $retry_count3= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
-# assertion: it should show 1
-if (`SELECT $retry_count3 <> 1`)
-{
-  -- echo Unexpected retry count value! Got: $retry_count3, expected: 1
-  -- die
-}
-
--- source include/stop_slave.inc
-
-# action: change the value back to the original one
--- eval CHANGE MASTER TO master_retry_count=$retry_count0
-
--- source include/start_slave.inc
-
--- let $retry_count4= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
-# assertion: it should show 1
-if (`SELECT $retry_count4 <> $retry_count0`)
-{
-  -- echo Unexpected retry count value! Got: $retry_count4, expected: $retry_count0
-  -- die
-}
-
-## Now lets change master_retry_count to the maximum value possible
-## and stop and restart the slave to check that (in the middle of it 
-## we also check that when issueing CHANGE MASTER TO without specifying
-## master_retry_count will not affect its current value):
-##   1. master_retry_count persists after restart
-##   2. setting a value higher than the max will make the max to be set.
-##   3. maximum value is accepted and persists after serialization 
-##      and de-serialization
--- source include/stop_slave.inc
--- let $retry_count_set= 18446744073709551616
--- replace_result 18446744073709551616 RETRY_COUNT_SET
--- eval CHANGE MASTER TO master_retry_count=$retry_count_set
--- let $retry_count_expected= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
--- replace_result 18446744073709551615 RETRY_COUNT_EXPECTED 4294967295 RETRY_COUNT_EXPECTED 9223372036854775807 RETRY_COUNT_EXPECTED
--- eval SELECT $retry_count_expected AS current_retry_count
-
-## assert that issuing CHANGE MASTER without changing master_retry_count
-## does not affect the existing value for master_retry_count
--- let $connect_retry_old= query_get_value(SHOW SLAVE STATUS, Connect_Retry, 1)
--- let $connect_retry_new= `SELECT $connect_retry_old + 1`
--- let $retry_count_before= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
--- eval CHANGE MASTER TO master_connect_retry= $connect_retry_new
--- let $retry_count_after= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
-if (`SELECT $retry_count_before <> $retry_count_after`)
-{
-  -- echo Unexpected retry count value! Got: $retry_count_after, expected: $retry_count_before
-  -- die
-}
--- eval CHANGE MASTER TO master_connect_retry= $connect_retry_old
-
-## Server restart persisting test
---echo ### stop slave server
---write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
-wait
-EOF
---shutdown_server 10
---source include/wait_until_disconnected.inc
-  
---echo ### start slave server
---append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
-restart
-EOF
---enable_reconnect
---source include/wait_until_connected_again.inc
-
--- connection slave
--- source include/start_slave.inc
-
--- let $retry_count5= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
-if (`SELECT $retry_count5 <> $retry_count_expected`)
-{
-  -- echo Unexpected retry count value! Got: $retry_count5, expected: $retry_count_expected
-  -- die
-}
-
-## assert that there is a parse error if not using a numerical value
--- error ER_PARSE_ERROR
-CHANGE MASTER TO master_retry_count='a';
-
-## assert that there is a parse error if using a negative number
--- error ER_PARSE_ERROR
-CHANGE MASTER TO master_retry_count=-1;
-
--- source include/master-slave-reset.inc
--- source include/master-slave-end.inc
+--source include/master-slave.inc
+--source extra/rpl_tests/rpl_change_master.test

=== added file 'mysql-test/suite/rpl/t/rpl_change_master_crash_safe-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_change_master_crash_safe-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_change_master_crash_safe-slave.opt	2010-11-12 19:41:49 +0000
@@ -0,0 +1 @@
+--master-info-repository=TABLE

=== added file 'mysql-test/suite/rpl/t/rpl_change_master_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_change_master_crash_safe.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_change_master_crash_safe.test	2010-11-12 19:41:49 +0000
@@ -0,0 +1,9 @@
+#
+# This test calls CHANGE MASTER in order to check if replication can
+# restart from where SQL thread left, not from where I/O thread left.
+#  
+# Table is used as repository.
+#
+
+--source include/master-slave.inc
+--source extra/rpl_tests/rpl_change_master.test

=== added file 'mysql-test/suite/rpl/t/rpl_checksum-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_checksum-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_checksum-master.opt	2010-06-14 10:04:20 +0000
@@ -0,0 +1 @@
+--binlog-checksum=CRC32

=== added file 'mysql-test/suite/rpl/t/rpl_checksum.test'
--- a/mysql-test/suite/rpl/t/rpl_checksum.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_checksum.test	2010-09-28 15:42:48 +0000
@@ -0,0 +1,247 @@
+# WL2540 replication events checksum
+# Testing configuration parameters
+
+--source include/master-slave.inc
+--source include/have_debug.inc
+--source include/have_binlog_format_mixed.inc
+
+call mtr.add_suppression('Slave can not handle replication events with the checksum that master is configured to log');
+call mtr.add_suppression('Replication event checksum verification failed');
+# due to C failure simulation
+call mtr.add_suppression('Relay log write failure: could not queue event from master');
+
+# A. read/write access to the global vars:
+# binlog_checksum master_verify_checksum slave_sql_verify_checksum
+
+connection master;
+
+set @master_save_binlog_checksum= @@global.binlog_checksum;
+set @save_master_verify_checksum =  @@global.master_verify_checksum;
+
+select @@global.binlog_checksum as 'must be CRC32 because of the command line option';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.binlog_checksum as 'no session var';
+
+select @@global.master_verify_checksum  as 'must be zero because of default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.master_verify_checksum  as 'no session var';
+
+connection slave;
+
+set @slave_save_binlog_checksum= @@global.binlog_checksum;
+set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
+
+select @@global.slave_sql_verify_checksum  as 'must be one because of default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.slave_sql_verify_checksum  as 'no session var';
+
+connection master;
+
+source include/show_binary_logs.inc;
+set @@global.binlog_checksum = NONE;
+--echo  *** must be rotations seen ***
+source include/show_binary_logs.inc;
+
+set @@global.binlog_checksum = default;
+
+# testing lack of side-effects in non-effective update of binlog_checksum:
+set @@global.binlog_checksum = CRC32;
+set @@global.binlog_checksum = CRC32; 
+
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.binlog_checksum = ADLER32;
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.master_verify_checksum = 2; # the var is of bool type
+
+connection slave;
+
+set @@global.slave_sql_verify_checksum = 0;
+set @@global.slave_sql_verify_checksum = default;
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.slave_sql_verify_checksum = 2; # the var is of bool type
+
+#
+# B. Old Slave to New master conditions
+#
+# while master does not send a checksum-ed binlog the Old Slave can
+# work with the New Master
+
+connection master;
+
+set @@global.binlog_checksum = NONE;
+create table t1 (a int);
+
+# testing that binlog rotation preserves opt_binlog_checksum value
+flush logs;
+flush logs;
+flush logs;
+
+sync_slave_with_master;
+#connection slave;
+# checking that rotation on the slave side leaves slave stable
+flush logs;
+flush logs;
+flush logs;
+select count(*) as zero from t1;
+
+source include/stop_slave.inc;
+
+connection master;
+set @@global.binlog_checksum = CRC32;
+insert into t1 values (1) /* will not be applied on slave due to simulation */;
+
+# instruction to the dump thread
+### set @@global.debug='d,simulate_slave_unaware_checksum'; # merge todo: +/- d syntax fails in my clone
+
+connection slave;
+set @@global.debug='d,simulate_slave_unaware_checksum'; # merge todo: +/- d syntax fails in my clone
+start slave;
+source include/wait_for_slave_io_to_stop.inc;
+
+let $errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+let $error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1);
+let $error= `select substring("$error", 17)`;  # todo:  declare a global const let $slave_error_date_col= 17
+--echo *** Got IO thread error code: $errno, text: $error ***
+
+select count(*) as zero from t1;
+
+###connection master;
+set @@global.debug=''; # merge todo: +/- d syntax fails in my clone
+
+connection slave;
+source include/start_slave.inc;
+
+# 
+# C. checksum failure simulations
+#
+
+# C1. Failure by a client thread
+connection master;
+set @@global.master_verify_checksum = 1;
+set @@session.debug='d,simulate_checksum_test_failure'; # merge todo deploy +/- syntax
+--error ER_ERROR_WHEN_EXECUTING_COMMAND
+show binlog events;
+set @@session.debug=''; # merge todo: +/- d syntax fails in my clone
+set @@global.master_verify_checksum = default;
+
+#connection master;
+sync_slave_with_master;
+
+connection slave;
+source include/stop_slave.inc;
+
+connection master;
+create table t2 (a int);
+let $pos_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+connection slave;
+
+# C2. Failure by IO thread
+# instruction to io thread
+set @@global.debug='d,simulate_checksum_test_failure'; # merge todo deploy +/- syntax
+start slave io_thread;
+source include/wait_for_slave_io_to_stop.inc;
+let $errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+let $error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1);
+let $error= `select substring("$error", 17)`;
+--echo *** Got IO thread error code: $errno, text: $error ***
+set @@global.debug=''; # todo: merge
+
+# to make IO thread re-read it again w/o the failure
+start slave io_thread;
+let $slave_param= Read_Master_Log_Pos;
+let $slave_param_value= $pos_master;
+source include/wait_for_slave_param.inc;
+
+# C3. Failure by SQL thread
+# instruction to sql thread;
+set @@global.slave_sql_verify_checksum = 1;
+
+set @@global.debug='d,simulate_checksum_test_failure'; # merge todo deploy +/- syntax
+
+start slave sql_thread;
+source include/wait_for_slave_sql_to_stop.inc;
+let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
+let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
+let $error= `select substring("$error", 17)`;
+--echo *** Got SQL thread error code: $errno, text: $error ***
+
+# resuming SQL thread to parse out the event w/o the failure
+
+set @@global.debug=''; 
+source include/start_slave.inc;
+
+connection master;
+sync_slave_with_master;
+
+#connection slave;
+select count(*) as 'must be zero' from t2;
+
+#
+# D. Reset slave, Change-Master, Binlog & Relay-log rotations with 
+#    random value on binlog_checksum on both master and slave
+#
+connection slave;
+stop slave;
+reset slave;
+
+# randomize slave server's own checksum policy
+set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
+flush logs;
+
+connection master;
+set @@global.binlog_checksum= CRC32;
+reset master;
+flush logs;
+create table t3 (a int, b char(5));
+
+connection slave;
+source include/start_slave.inc;
+
+connection master;
+sync_slave_with_master;
+
+#connection slave;
+select count(*) as 'must be zero' from t3;
+source include/stop_slave.inc;
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
+
+connection master;
+flush logs;
+reset master;
+insert into t3 value (1, @@global.binlog_checksum);
+
+connection slave;
+source include/start_slave.inc;
+flush logs;
+
+connection master;
+sync_slave_with_master;
+
+#connection slave;
+select count(*) as 'must be one' from t3;
+
+connection master;
+set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
+insert into t3 value (1, @@global.binlog_checksum);
+sync_slave_with_master;
+
+#connection slave;
+
+#clean-up
+
+connection master;
+drop table t1, t2, t3;
+set @@global.binlog_checksum = @master_save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+
+#connection slave;
+sync_slave_with_master;
+set @@global.binlog_checksum = @slave_save_binlog_checksum;
+set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
+
+--echo End of tests

=== added file 'mysql-test/suite/rpl/t/rpl_checksum_cache.test'
--- a/mysql-test/suite/rpl/t/rpl_checksum_cache.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_checksum_cache.test	2010-11-11 02:11:10 +0000
@@ -0,0 +1,264 @@
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+
+--disable_warnings
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into t2 set data=repeat.*'a', @act_size.*");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into t1 values.* NAME_CONST.*'n',.*, @data .*");
+--enable_warnings
+
+connection master;
+set @save_binlog_cache_size = @@global.binlog_cache_size;
+set @save_binlog_checksum = @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+set @@global.binlog_cache_size = 4096;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 1;
+
+# restart slave to force the dump thread to verify events (on master side)
+connection slave;
+source include/stop_slave.inc;
+source include/start_slave.inc;
+
+connection master;
+
+#
+# Testing a critical part of checksum handling dealing with transaction cache.
+# The cache's buffer size is set to be less than the transaction's footprint
+# in binlog.
+#
+# To verify combined buffer-by-buffer read out of the file and fixing crc per event
+# there are the following parts:
+#
+# 1. the event size is much less than the cache's buffer
+# 2. the event size is bigger than the cache's buffer
+# 3. the event size if approximately the same as the cache's buffer
+# 4. all in above
+
+#
+# 1. the event size is much less than the cache's buffer
+#
+
+flush status;
+show status like "binlog_cache_use";
+show status like "binlog_cache_disk_use";
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# parameter to ensure the test slightly varies binlog content
+# between different invocations
+#
+let $deviation_size=32;
+eval create table t1 (a int PRIMARY KEY, b CHAR($deviation_size)) engine=innodb;
+
+# Now we are going to create transaction which is long enough so its 
+# transaction binlog will be flushed to disk...
+
+delimiter |;
+create procedure test.p_init (n int, size int) 
+begin
+  while n > 0 do
+    select round(RAND() * size) into @act_size;
+    set @data = repeat('a', @act_size);
+    insert into t1 values(n, @data );
+    set n= n-1;
+  end while;
+end|
+
+delimiter ;|
+
+let $1 = 4000; # PB2 can run it slow to time out on following sync_slave_with_master:s
+
+begin;
+--disable_warnings
+# todo: check if it is really so.
+#+Note   1592    Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave.
+eval call test.p_init($1, $deviation_size);
+--enable_warnings
+commit;
+
+show status like "binlog_cache_use";
+--echo *** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+
+sync_slave_with_master;
+
+let $diff_table_1=master:test.t1;
+let $diff_table_2=slave:test.t1;
+source include/diff_tables.inc;
+
+# undoing changes with verifying the above once again
+connection master;
+
+begin;
+delete from t1;
+commit;
+
+sync_slave_with_master;
+
+
+#
+# 2. the event size is bigger than the cache's buffer
+#
+connection master;
+
+flush status;
+let $t2_data_size= `select 3 * @@global.binlog_cache_size`;
+let $t2_aver_size= `select 2 * @@global.binlog_cache_size`;
+let $t2_max_rand=  `select 1 * @@global.binlog_cache_size`;
+
+eval create table t2(a int auto_increment primary key, data VARCHAR($t2_data_size)) ENGINE=Innodb;
+let $1=100;
+--disable_query_log
+begin;
+while ($1)
+{
+ eval select round($t2_aver_size + RAND() * $t2_max_rand) into @act_size;
+ set @data = repeat('a', @act_size);
+ insert into t2 set data = @data;
+ dec $1;
+}
+commit;
+--enable_query_log
+show status like "binlog_cache_use";
+--echo *** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+
+sync_slave_with_master;
+
+let $diff_table_1=master:test.t2;
+let $diff_table_2=slave:test.t2;
+source include/diff_tables.inc;
+
+# undoing changes with verifying the above once again
+connection master;
+
+begin;
+delete from t2;
+commit;
+
+sync_slave_with_master;
+
+#
+# 3. the event size if approximately the same as the cache's buffer
+#
+
+connection master;
+
+flush status;
+let $t3_data_size= `select 2 * @@global.binlog_cache_size`;
+let $t3_aver_size= `select (9 * @@global.binlog_cache_size) / 10`;
+let $t3_max_rand=  `select (2 * @@global.binlog_cache_size) / 10`;
+
+eval create table t3(a int auto_increment primary key, data VARCHAR($t3_data_size)) engine=innodb;
+
+let $1= 300;
+--disable_query_log
+begin;
+while ($1)
+{
+ eval select round($t3_aver_size + RAND() * $t3_max_rand) into @act_size;
+ insert into t3 set data= repeat('a', @act_size);
+ dec $1;
+}
+commit;
+--enable_query_log
+show status like "binlog_cache_use";
+--echo *** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+
+sync_slave_with_master;
+
+let $diff_table_1=master:test.t3;
+let $diff_table_2=slave:test.t3;
+source include/diff_tables.inc;
+
+# undoing changes with verifying the above once again
+connection master;
+
+begin;
+delete from t3;
+commit;
+
+sync_slave_with_master;
+
+
+#
+# 4. all in above
+#
+
+connection master;
+flush status;
+
+delimiter |;
+eval create procedure test.p1 (n int) 
+begin
+  while n > 0 do
+    case (select (round(rand()*100) % 3) + 1)
+    when 1 then
+      select round(RAND() * $deviation_size) into @act_size;
+      set @data = repeat('a', @act_size);
+      insert into t1 values(n, @data);
+    when 2 then
+      begin
+        select round($t2_aver_size + RAND() * $t2_max_rand) into @act_size;
+	insert into t2 set data=repeat('a', @act_size);
+      end;
+    when 3 then
+      begin
+        select round($t3_aver_size + RAND() * $t3_max_rand) into @act_size;
+	insert into t3 set data= repeat('a', @act_size);
+      end;
+    end case;
+    set n= n-1;
+  end while;
+end|
+delimiter ;|
+
+let $1= 1000;
+set autocommit= 0;
+begin;
+--disable_warnings
+eval call test.p1($1);
+--enable_warnings
+commit;
+
+show status like "binlog_cache_use";
+--echo *** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+
+sync_slave_with_master;
+
+let $diff_table_1=master:test.t1;
+let $diff_table_2=slave:test.t1;
+source include/diff_tables.inc;
+
+let $diff_table_1=master:test.t2;
+let $diff_table_2=slave:test.t2;
+source include/diff_tables.inc;
+
+let $diff_table_1=master:test.t3;
+let $diff_table_2=slave:test.t3;
+source include/diff_tables.inc;
+
+
+connection master;
+
+begin;
+delete from t1;
+delete from t2;
+delete from t3;
+commit;
+
+drop table t1, t2, t3;
+set @@global.binlog_cache_size = @save_binlog_cache_size;
+set @@global.binlog_checksum = @save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+drop procedure test.p_init;
+drop procedure test.p1;
+
+sync_slave_with_master;
+
+--echo End of tests
+

=== added file 'mysql-test/suite/rpl/t/rpl_corruption-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_corruption-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_corruption-master.opt	2010-11-02 12:43:13 +0000
@@ -0,0 +1 @@
+--binlog-checksum=CRC32 --master-verify-checksum=1

=== added file 'mysql-test/suite/rpl/t/rpl_corruption-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_corruption-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_corruption-slave.opt	2010-11-02 12:43:13 +0000
@@ -0,0 +1 @@
+--binlog-checksum=CRC32 --slave-sql-verify-checksum=1

=== added file 'mysql-test/suite/rpl/t/rpl_corruption.test'
--- a/mysql-test/suite/rpl/t/rpl_corruption.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_corruption.test	2010-11-11 02:11:10 +0000
@@ -0,0 +1,128 @@
+############################################################
+# Author: Serge Kozlov <serge.kozlov@stripped>
+# Date:	17 Oct 2010
+# Purpose: WL#5064 Testing with corrupted events.
+# The test emulates the corruption at the vary stages
+# of replication:
+#  - in binlog file
+#  - in network
+#  - in relay log
+############################################################
+
+--source include/have_debug.inc
+--source include/master-slave.inc
+
+# Block legal errors for MTR 
+call mtr.add_suppression('Found invalid event in binary log');
+call mtr.add_suppression('Slave I/O: Relay log write failure: could not queue event from master');
+call mtr.add_suppression('event read from binlog did not pass crc check');
+call mtr.add_suppression('Replication event checksum verification failed');
+
+SET @old_master_verify_checksum = @@master_verify_checksum;
+
+# Creating test table/data and set corruption position for testing
+--echo # 1. Creating test table/data and set corruption position for testing
+--connection master
+--echo * insert/update/delete rows in table t1 *
+# Corruption algorithm modifies only the first event and 
+# then will be reset. To avoid checking always the first event 
+# from binlog (usually it is FD) we randomly execute different 
+# statements and set position for corruption inside events.
+
+CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100));
+--disable_query_log
+let $i=`SELECT 3+CEILING(10*RAND())`;
+let $j=1;
+let $pos=0;
+while ($i) {  
+  eval INSERT INTO t1 VALUES ($j, 'a', NULL);
+  if (`SELECT RAND() > 0.7`)
+  {
+    eval UPDATE t1 SET c = REPEAT('a', 20) WHERE a = $j;
+  }
+  if (`SELECT RAND() > 0.8`)
+  {
+    eval DELETE FROM t1 WHERE a = $j;
+  }
+  if (!$pos) {
+    let $pos= query_get_value(SHOW MASTER STATUS, Position, 1);
+    --sync_slave_with_master
+    --source include/stop_slave.inc
+    --disable_query_log
+    --connection master
+  }
+  dec $i;
+  inc $j;
+}
+--enable_query_log
+
+# Emulate corruption in binlog file when SHOW BINLOG EVENTS is executing
+--echo # 2. Corruption in master binlog and SHOW BINLOG EVENTS
+SET GLOBAL debug="+d,corrupt_read_log_event_char";
+--echo SHOW BINLOG EVENTS;
+--disable_query_log
+send_eval SHOW BINLOG EVENTS FROM $pos;
+--enable_query_log
+--error ER_ERROR_WHEN_EXECUTING_COMMAND
+reap;
+SET GLOBAL debug="-d,corrupt_read_log_event_char";
+
+# Emulate corruption on master with crc checking on master
+--echo # 3. Master read a corrupted event from binlog and send the error to slave
+SET GLOBAL debug="+d,corrupt_read_log_event";
+--connection slave
+START SLAVE IO_THREAD;
+let $slave_io_errno= 1236;
+--source include/wait_for_slave_io_error.inc
+--connection master
+SET GLOBAL debug="-d,corrupt_read_log_event";
+
+# Emulate corruption on master without crc checking on master
+--echo # 4. Master read a corrupted event from binlog and send it to slave
+--connection master
+SET GLOBAL master_verify_checksum=0;
+SET GLOBAL debug="+d,corrupt_read_log_event";
+--connection slave
+START SLAVE IO_THREAD;
+let $slave_io_errno= 1595;
+--source include/wait_for_slave_io_error.inc
+--connection master
+SET GLOBAL debug="-d,corrupt_read_log_event";
+SET GLOBAL master_verify_checksum=1;
+
+# Emulate corruption in network
+--echo # 5. Slave. Corruption in network
+--connection slave
+SET GLOBAL debug="+d,corrupt_queue_event";
+START SLAVE IO_THREAD;
+let $slave_io_errno= 1595;
+--source include/wait_for_slave_io_error.inc
+SET GLOBAL debug="-d,corrupt_queue_event";
+
+# Emulate corruption in relay log
+--echo # 6. Slave. Corruption in relay log
+SET GLOBAL debug="+d,corrupt_read_log_event_char";
+START SLAVE;
+let $slave_sql_errno= 1593;
+--source include/wait_for_slave_sql_error.inc
+SET GLOBAL debug="-d,corrupt_read_log_event_char";
+
+# Start normal replication and compare same table on master
+# and slave
+--echo # 7. Seek diff for tables on master and slave
+--connection slave
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+let $diff_table_1= master:test.t1;
+let $diff_table_2= slave:test.t1;
+--source include/diff_tables.inc
+                                                               
+# Clean up
+--echo # 8. Clean up
+--connection master
+SET GLOBAL debug= "";
+SET GLOBAL master_verify_checksum = @old_master_verify_checksum;
+DROP TABLE t1;
+--sync_slave_with_master
+SET GLOBAL debug= "";

=== modified file 'mysql-test/suite/rpl/t/rpl_flushlog_loop.test'
--- a/mysql-test/suite/rpl/t/rpl_flushlog_loop.test	2010-10-08 16:11:32 +0000
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop.test	2010-10-25 10:39:01 +0000
@@ -1,6 +1,7 @@
 # Testing if "flush logs" command bouncing resulting in logs created in a loop 
 # in case of bi-directional replication
 -- source include/master-slave.inc
+-- source include/not_relay_log_info_table.inc
 # Use wait_for_slave_to_(start|stop) for current connections
 let $keep_connection= 1;
 

=== modified file 'mysql-test/suite/rpl/t/rpl_heartbeat_basic.test'
--- a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test	2010-08-26 16:37:57 +0000
+++ b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test	2010-10-25 19:02:24 +0000
@@ -16,10 +16,14 @@
 # in order to not slow down much `make test'.
 #
 --source include/have_binlog_format_mixed.inc
+
+call mtr.add_suppression("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum");
+
 --echo
 
 --echo *** Preparing ***
 --connection slave
+
 --source include/stop_slave.inc
 RESET SLAVE;
 SET @restore_slave_net_timeout=@@global.slave_net_timeout;

=== modified file 'mysql-test/suite/rpl/t/rpl_known_bugs_detection.test'
--- a/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test	2010-08-05 17:45:25 +0000
+++ b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test	2010-10-25 19:02:24 +0000
@@ -4,11 +4,14 @@
 # imitate the bug, so it has to stop).
 
 source include/have_debug.inc;
+# because of pretend_version_50034_in_binlog the test can't run with checksum
+source include/have_binlog_checksum_off.inc;
 source include/master-slave.inc;
 
 # Currently only statement-based-specific bugs are here
 -- source include/have_binlog_format_mixed_or_statement.inc
 
+
 #
 # This is to test that slave properly detects if
 # master may suffer from:

=== added file 'mysql-test/suite/rpl/t/rpl_migration_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_migration_crash_safe.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_migration_crash_safe.test	2010-11-02 17:58:52 +0000
@@ -0,0 +1,142 @@
+########################################################################################
+# This test verifies if the server migrates correctly from a file repository to a
+# table repository and vice-versa. In particular, it checks if the information in the
+# relay log info is correctly migrated between the different types (i.e. FILE or TABLE)
+# of repositories. The algorithm and the function used to migrate the master info is
+# the same and for that reason, we do not test its migration.
+# 
+# If a FILE repository is used, the following assertions are valid:
+#   AF1. SELECT COUNT(*) FROM mysql.slave_relay_log_info == 0
+#   AF2. file_exists $MYSQLD_DATADIR/relay-log.info == 1
+#
+# If a TABLE repository is used, the following assertions are valid:
+#   AT1. SELECT COUNT(*) FROM mysql.slave_relay_log_info == 1
+#   AT2. file_exists $MYSQLD_DATADIR/relay-log.info == 0
+#
+# The test case is organized as follows:
+#
+# 1. Preparation:
+#   1.1. The slave is started with a FILE repository enabled and the replication
+#   stopped.
+#   1.2. A table is created and populated in order to check at the end of the test
+#   if data is replicated correctly.
+#   1.3. Assertions AF1 and AF2 are verified.
+#
+# 2. Migration from FILE to TABLE
+#   2.1. The slave is stopped and restarted with --relay-log-info-repository=TABLE
+#   2.2. Assertions AT1 and AT2 are verified.
+#
+# 3. Migration from TABLE to FILE with success
+#   4.1. The slave is stopped and restarted with --relay-log-info-repository=FILE
+#   4.2. Assertions AF1 and AF2 are verified.
+#
+# 4. Check consistency
+#   4.1. The replication is started and the master is compared to the slave.
+########################################################################################
+########################################################################################
+# 1. Preparation
+########################################################################################
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_valgrind.inc
+--source include/not_relay_log_info_table.inc
+
+--connection slave
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+let $exp_slave= 0;
+let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
+if (`SELECT $got_slave <> $exp_slave`)
+{
+  --echo "The mysql.slave_relay_log_info has information and this is not expected."
+  --die
+}
+file_exists $MYSQLD_DATADIR/relay-log.info;
+
+--source include/stop_slave.inc
+
+--connection master
+
+CREATE TABLE test(id INTEGER NOT NULL PRIMARY KEY);
+INSERT INTO test VALUES (1), (2), (3);
+
+########################################################################################
+# 2. Migration from FILE to TABLE
+########################################################################################
+--connection slave
+
+--echo ### stop slave server
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+wait
+EOF
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+
+--echo ### start slave server with --relay-log-info-repository=TABLE
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+restart:--relay-log-info-repository=TABLE --skip-slave-start
+EOF
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--connection slave
+
+let $exp_slave= 1;
+let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
+if (`SELECT $got_slave <> $exp_slave`)
+{
+  --echo "The mysql.slave_relay_log_info has information and this is not expected."
+  --die
+}
+--error 1
+file_exists $MYSQLD_DATADIR/relay-log.info;
+
+########################################################################################
+# 3. Migration from TABLE to FILE
+########################################################################################
+--connection slave
+
+--echo ### stop slave server
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+wait
+EOF
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+
+--echo ### start slave server with --relay-log-info-repository=FILE
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+restart:--relay-log-info-repository=FILE --skip-slave-start
+EOF
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--connection slave
+
+let $exp_slave= 0;
+let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
+if (`SELECT $got_slave <> $exp_slave`)
+{
+  --echo "The mysql.slave_relay_log_info has information and this is not expected."
+  --die
+}
+file_exists $MYSQLD_DATADIR/relay-log.info;
+
+########################################################################################
+# 4. Check consistency
+########################################################################################
+--connection slave
+
+--source include/start_slave.inc
+
+--connection master
+
+sync_slave_with_master;
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-migration-master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-migration-slave.sql
+--diff_files $MYSQLD_DATADIR/test-migration-master.sql $MYSQLD_DATADIR/test-migration-slave.sql
+
+--connection master
+
+DROP TABLE test;
+sync_slave_with_master;

=== added file 'mysql-test/suite/rpl/t/rpl_mixed_crash_safe-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_mixed_crash_safe-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_mixed_crash_safe-slave.opt	2010-10-27 11:50:22 +0000
@@ -0,0 +1 @@
+--skip-core-file --skip-slave-start --relay-log-info-repository=TABLE --relay-log-recovery=1

=== added file 'mysql-test/suite/rpl/t/rpl_mixed_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_mixed_crash_safe.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_mixed_crash_safe.test	2010-11-02 17:58:52 +0000
@@ -0,0 +1,14 @@
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_valgrind.inc
+--source include/have_debug.inc
+--source include/have_innodb.inc
+--source include/have_binlog_format_mixed.inc
+
+call mtr.add_suppression('Attempting backtrace');
+call mtr.add_suppression("Recovery from master pos .* and file master-bin.000001");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression(".*  InnoDB: Warning: allocated tablespace .*, old maximum was .*");
+call mtr.add_suppression(".*int __cxa_pure_virtual().*");
+
+--source extra/rpl_tests/rpl_crash_safe.test

=== modified file 'mysql-test/suite/rpl/t/rpl_rotate_logs.test'
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test	2010-10-08 16:11:32 +0000
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test	2010-11-23 23:10:22 +0000
@@ -1,6 +1,7 @@
 # This test uses chmod, can't be run with root permissions
 -- source include/not_as_root.inc
 -- source include/have_log_bin.inc
+-- source include/not_master_info_table.inc
 
 #
 # Test is run with max_binlog_size=2048 to force automatic rotation of the
@@ -155,7 +156,10 @@ select * from t2;
 connection master;
 create temporary table temp_table (a char(80) not null);
 insert into temp_table values ("testing temporary tables part 2");
-let $1=100;
+
+# the nummber of produced logs is sensitive to whether checksum is NONE or CRC32
+# the value of 90 makes it even
+let $1=90;
 
 create table t3 (n int);
 disable_query_log;

=== added file 'mysql-test/suite/rpl/t/rpl_row_crash_safe-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_crash_safe-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_crash_safe-slave.opt	2010-10-27 11:50:22 +0000
@@ -0,0 +1 @@
+--skip-core-file --skip-slave-start --relay-log-info-repository=TABLE --relay-log-recovery=1

=== added file 'mysql-test/suite/rpl/t/rpl_row_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_row_crash_safe.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_crash_safe.test	2010-11-02 17:58:52 +0000
@@ -0,0 +1,14 @@
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_valgrind.inc
+--source include/have_debug.inc
+--source include/have_innodb.inc
+--source include/have_binlog_format_row.inc
+
+call mtr.add_suppression('Attempting backtrace');
+call mtr.add_suppression("Recovery from master pos .* and file master-bin.000001");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression(".*  InnoDB: Warning: allocated tablespace .*, old maximum was .*");
+call mtr.add_suppression(".*int __cxa_pure_virtual().*");
+
+--source extra/rpl_tests/rpl_crash_safe.test

=== modified file 'mysql-test/suite/rpl/t/rpl_row_ignorable_event.test'
--- a/mysql-test/suite/rpl/t/rpl_row_ignorable_event.test	2010-10-19 08:51:50 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_ignorable_event.test	2010-11-16 12:14:06 +0000
@@ -80,7 +80,7 @@ source include/show_binlog_events.inc;
 --echo # MYSQL_BINLOG output base on master-bin.000001
 let $MYSQLD_DATADIR= `select @@datadir`;
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---replace_regex /TIMESTAMP=[0-9]*/TIMESTAMP=t/ /#[0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* server id [0-9]*/#server id #/ /exec_time=[0-9]*/exec_time=#/ /error_code=[0-9]*/error_code=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /Start: binlog v [0-9]*/Start: binlog v#/ /created [0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* at startup/created # #:#:# at startup/
+--replace_regex /TIMESTAMP=[0-9]*/TIMESTAMP=t/ /#[0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* server id [0-9]*/#server id #/ /exec_time=[0-9]*/exec_time=#/ /error_code=[0-9]*/error_code=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /Start: binlog v [0-9]*/Start: binlog v#/ /created [0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* at startup/created # #:#:# at startup/ /[	 ]CRC32 0x[abcdef0-9]+//
 --exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/$master_binlog
 
 let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);

=== modified file 'mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test'
--- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test	2010-09-01 02:51:08 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test	2010-10-25 19:02:24 +0000
@@ -248,6 +248,7 @@ connection master;
 # transactions. /Matz
 
 # LOAD DATA
+
 --disable_query_log
 select "--- Test 5 LOAD DATA --" as "";
 --enable_query_log

=== modified file 'mysql-test/suite/rpl/t/rpl_seconds_behind_master.test'
--- a/mysql-test/suite/rpl/t/rpl_seconds_behind_master.test	2010-05-04 10:35:47 +0000
+++ b/mysql-test/suite/rpl/t/rpl_seconds_behind_master.test	2010-10-25 10:39:01 +0000
@@ -62,6 +62,7 @@ let $lower_bound= 3;
 if (`SELECT $sbm < $lower_bound or $sbm > $upper_bound`)
 {
   -- echo #### Seconds behind master is not in acceptable time window
+   --echo Seconds_Behind_Master $sbm Upper Bound $upper_bound Lower bound $lower_bound
   -- source include/show_rpl_debug_info.inc
   -- die
 }

=== modified file 'mysql-test/suite/rpl/t/rpl_server_uuid.test'
--- a/mysql-test/suite/rpl/t/rpl_server_uuid.test	2010-10-08 14:23:55 +0000
+++ b/mysql-test/suite/rpl/t/rpl_server_uuid.test	2010-10-25 19:02:24 +0000
@@ -17,6 +17,8 @@ call mtr.add_suppression("Slave I/O thre
 call mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: .*");
 CALL mtr.add_suppression(".*master and slave have equal MySQL server UUIDs.*");
 CALL mtr.add_suppression("Master's UUID has changed, its old UUID is.*");
+CALL mtr.add_suppression("Slave I/O: SET @master_heartbeat_period to master failed with error: Lost connection to MySQL server during query");
+CALL mtr.add_suppression("Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error");
 
 --let $uuid_file= auto.cnf
 

=== modified file 'mysql-test/suite/rpl/t/rpl_show_master_info_file.test'
--- a/mysql-test/suite/rpl/t/rpl_show_master_info_file.test	2010-10-08 16:11:32 +0000
+++ b/mysql-test/suite/rpl/t/rpl_show_master_info_file.test	2010-10-25 10:39:01 +0000
@@ -6,6 +6,7 @@
 
 source include/master-slave.inc;
 source include/have_binlog_format_mixed.inc;
+source include/not_master_info_table.inc;
 
 # test reveals different path separator on windows.
 # Leaving out windows because there is nothing more platform specific.

=== added file 'mysql-test/suite/rpl/t/rpl_stm_crash_safe-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_stm_crash_safe-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_crash_safe-slave.opt	2010-10-27 11:50:22 +0000
@@ -0,0 +1 @@
+--skip-core-file --skip-slave-start --relay-log-info-repository=TABLE --relay-log-recovery=1

=== added file 'mysql-test/suite/rpl/t/rpl_stm_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_crash_safe.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_crash_safe.test	2010-11-02 17:58:52 +0000
@@ -0,0 +1,14 @@
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_valgrind.inc
+--source include/have_debug.inc
+--source include/have_innodb.inc
+--source include/have_binlog_format_statement.inc
+
+call mtr.add_suppression('Attempting backtrace');
+call mtr.add_suppression("Recovery from master pos .* and file master-bin.000001");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression(".*  InnoDB: Warning: allocated tablespace .*, old maximum was .*");
+call mtr.add_suppression(".*int __cxa_pure_virtual().*");
+
+--source extra/rpl_tests/rpl_crash_safe.test

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test	2010-10-08 16:11:32 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test	2010-10-25 10:39:01 +0000
@@ -1,5 +1,6 @@
 # depends on the binlog output
 --source include/have_binlog_format_mixed_or_statement.inc
+--source include/not_relay_log_info_table.inc
 
 let $rename_event_pos= 933;
 -- source extra/rpl_tests/rpl_flsh_tbls.test

=== modified file 'mysql-test/suite/rpl/t/rpl_sync.test'
--- a/mysql-test/suite/rpl/t/rpl_sync.test	2010-11-09 20:10:44 +0000
+++ b/mysql-test/suite/rpl/t/rpl_sync.test	2010-11-15 16:43:41 +0000
@@ -31,6 +31,7 @@
 --source include/not_valgrind.inc
 --source include/have_debug.inc
 --source include/have_innodb.inc
+--source include/not_master_info_table.inc
 
 call mtr.add_suppression('Attempting backtrace');
 call mtr.add_suppression("Recovery from master pos .* and file master-bin.000001");

=== modified file 'mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test'
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test	2010-07-17 11:07:36 +0000
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test	2010-09-28 13:58:50 +0000
@@ -32,8 +32,10 @@ stop slave;
 # get the master binlog pos from the epoch, from the _other_ "master", server2
 connection server2;
 --replace_result $the_epoch <the_epoch>
+--disable_result_log
 eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
    FROM mysql.ndb_binlog_index WHERE epoch = $the_epoch ;
+--enable_result_log
 let $the_pos= `SELECT @the_pos` ;
 let $the_file= `SELECT @the_file` ;
 

=== added file 'mysql-test/suite/sys_vars/r/binlog_checksum_basic.result'
--- a/mysql-test/suite/sys_vars/r/binlog_checksum_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/binlog_checksum_basic.result	2010-11-01 18:00:28 +0000
@@ -0,0 +1,14 @@
+set @save_binlog_checksum= @@global.binlog_checksum;
+set @@global.binlog_checksum = default;
+select @@global.binlog_checksum as 'must be NONE by default';
+must be NONE by default
+NONE
+select @@session.binlog_checksum as 'no session var';
+ERROR HY000: Variable 'binlog_checksum' is a GLOBAL variable
+set @@global.binlog_checksum = CRC32;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+set @@global.binlog_checksum = ADLER32;
+ERROR 42000: Variable 'binlog_checksum' can't be set to the value of 'ADLER32'
+set @@global.binlog_checksum = @save_binlog_checksum;

=== added file 'mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result'
--- a/mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result	2010-10-28 17:09:41 +0000
@@ -0,0 +1,11 @@
+set @save_master_verify_checksum =  @@global.master_verify_checksum;
+select @@global.master_verify_checksum  as 'must be zero because of default';
+must be zero because of default
+0
+select @@session.master_verify_checksum  as 'no session var';
+ERROR HY000: Variable 'master_verify_checksum' is a GLOBAL variable
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+set @@global.master_verify_checksum = 2;
+ERROR 42000: Variable 'master_verify_checksum' can't be set to the value of '2'
+set @@global.master_verify_checksum = @save_master_verify_checksum;

=== added file 'mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result'
--- a/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result	2010-10-28 17:09:41 +0000
@@ -0,0 +1,11 @@
+set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
+select @@global.slave_sql_verify_checksum  as 'must be one because of default';
+must be one because of default
+1
+select @@session.slave_sql_verify_checksum  as 'no session var';
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable
+set @@global.slave_sql_verify_checksum = 0;
+set @@global.slave_sql_verify_checksum = default;
+set @@global.slave_sql_verify_checksum = 2;
+ERROR 42000: Variable 'slave_sql_verify_checksum' can't be set to the value of '2'
+set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;

=== modified file 'mysql-test/suite/sys_vars/t/all_vars.test'
--- a/mysql-test/suite/sys_vars/t/all_vars.test	2010-10-21 08:30:43 +0000
+++ b/mysql-test/suite/sys_vars/t/all_vars.test	2010-11-16 12:14:06 +0000
@@ -53,6 +53,11 @@ perl;
   print F join "\n", sort map { s/_basic(_32|_64)?\.test$//; basename $_ } @all_tests;
 EOF
 
+#
+# todo: fix Bug #55080 mysql-next-mr requires a specic to new added global variables test file
+# to get rid of unxpected and probited following SELECT results
+#
+
 create table t1 (test_name text);
 create table t2 (variable_name text);
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR

=== added file 'mysql-test/suite/sys_vars/t/binlog_checksum_basic.test'
--- a/mysql-test/suite/sys_vars/t/binlog_checksum_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/binlog_checksum_basic.test	2010-11-01 18:00:28 +0000
@@ -0,0 +1,25 @@
+--source include/not_embedded.inc
+
+# suite/rpl/t/rpl_checksum.test contains similar testing of 
+# all checksum related system variables.
+
+set @save_binlog_checksum= @@global.binlog_checksum;
+set @@global.binlog_checksum = default;
+
+select @@global.binlog_checksum as 'must be NONE by default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.binlog_checksum as 'no session var';
+
+
+# testing lack of side-effects in non-effective update of binlog_checksum:
+set @@global.binlog_checksum = CRC32;
+set @@global.binlog_checksum = CRC32; 
+
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.binlog_checksum = ADLER32;
+
+# cleanup
+set @@global.binlog_checksum = @save_binlog_checksum;

=== modified file 'mysql-test/suite/sys_vars/t/master_info_repository_basic.test'
--- a/mysql-test/suite/sys_vars/t/master_info_repository_basic.test	2010-10-08 16:11:32 +0000
+++ b/mysql-test/suite/sys_vars/t/master_info_repository_basic.test	2010-10-25 10:39:01 +0000
@@ -19,6 +19,7 @@
 #    http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html      #
 #                                                                             #
 ###############################################################################
+--source include/not_master_info_table.inc
 
 --echo '#---------------------BS_STVARS_002_01----------------------#'
 ####################################################################

=== added file 'mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test'
--- a/mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test	2010-10-28 17:09:41 +0000
@@ -0,0 +1,19 @@
+--source include/not_embedded.inc
+
+# suite/rpl/t/rpl_checksum.test contains similar testing of 
+# all checksum related system variables.
+
+set @save_master_verify_checksum =  @@global.master_verify_checksum;
+
+select @@global.master_verify_checksum  as 'must be zero because of default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.master_verify_checksum  as 'no session var';
+
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.master_verify_checksum = 2; # the var is of bool type
+
+# cleanup
+set @@global.master_verify_checksum = @save_master_verify_checksum;

=== modified file 'mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test'
--- a/mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test	2010-10-08 16:11:32 +0000
+++ b/mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test	2010-10-25 10:39:01 +0000
@@ -19,6 +19,8 @@
 #    http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html      #
 #                                                                             #
 ###############################################################################
+--source include/not_relay_log_info_table.inc
+
 --echo '#---------------------BS_STVARS_002_01----------------------#'
 ####################################################################
 #   Displaying default value                                       #

=== added file 'mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test'
--- a/mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test	2010-10-28 17:09:41 +0000
@@ -0,0 +1,18 @@
+--source include/not_embedded.inc
+
+# suite/rpl/t/rpl_checksum.test contains similar testing of 
+# all checksum related system variables.
+
+set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
+
+select @@global.slave_sql_verify_checksum  as 'must be one because of default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.slave_sql_verify_checksum  as 'no session var';
+
+set @@global.slave_sql_verify_checksum = 0;
+set @@global.slave_sql_verify_checksum = default;
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.slave_sql_verify_checksum = 2; # the var is of bool type
+
+# cleanup
+set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;

=== modified file 'mysql-test/t/mysqlbinlog2.test'
--- a/mysql-test/t/mysqlbinlog2.test	2010-09-01 02:51:08 +0000
+++ b/mysql-test/t/mysqlbinlog2.test	2010-10-25 19:02:24 +0000
@@ -105,7 +105,6 @@ select "--- stop-datetime --" as "";
 --disable_query_log
 select "--- Remote --" as "";
 --enable_query_log
-
 --exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
 
 --disable_query_log

=== modified file 'mysql-test/t/system_mysql_db_fix40123.test'
--- a/mysql-test/t/system_mysql_db_fix40123.test	2010-11-03 14:31:27 +0000
+++ b/mysql-test/t/system_mysql_db_fix40123.test	2010-11-15 16:43:41 +0000
@@ -72,7 +72,7 @@ CREATE TABLE time_zone_leap_second (   T
 -- disable_query_log
 
 # Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv, slave_master_info, slave_relay_log_info;
 
 -- enable_query_log
 

=== modified file 'mysql-test/t/system_mysql_db_fix50030.test'
--- a/mysql-test/t/system_mysql_db_fix50030.test	2010-11-03 14:31:27 +0000
+++ b/mysql-test/t/system_mysql_db_fix50030.test	2010-11-15 16:43:41 +0000
@@ -78,7 +78,7 @@ INSERT INTO servers VALUES ('test','loca
 -- disable_query_log
 
 # Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv, slave_master_info, slave_relay_log_info;
 
 -- enable_query_log
 

=== modified file 'mysql-test/t/system_mysql_db_fix50117.test'
--- a/mysql-test/t/system_mysql_db_fix50117.test	2010-11-03 14:31:27 +0000
+++ b/mysql-test/t/system_mysql_db_fix50117.test	2010-11-15 16:43:41 +0000
@@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS ndb_binlog_in
 -- disable_query_log
 
 # Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv, slave_master_info, slave_relay_log_info;
 
 -- enable_query_log
 

=== modified file 'scripts/mysql_install_db.pl.in'
--- a/scripts/mysql_install_db.pl.in	2010-10-08 16:11:32 +0000
+++ b/scripts/mysql_install_db.pl.in	2010-10-25 10:39:01 +0000
@@ -79,6 +79,11 @@ Usage: $0 [OPTIONS]
                        user.  You must be root to use this option.  By default
                        mysqld runs using your current login name and files and
                        directories that it creates will be owned by you.
+  --rpl-engine=engine  The storage engine used for the mysql.slave_master_info and
+                       mysql.slave_relay_log_info tables. By default, both tables are
+                       created using the MyISAM storage engine. However, any storage
+                       engine available to the server may be used. If a crash-safe
+                       slave is required, the storage engine must be transactional.
 
 All other options are passed to the mysqld program
 
@@ -117,6 +122,7 @@ sub parse_arguments
              "builddir=s",      # FIXME not documented
              "srcdir=s",
              "ldata|datadir=s",
+             "rpl-engine=s",
 
              # Note that the user will be passed to mysqld so that it runs
              # as 'user' (crucial e.g. if log-bin=/some_other_path/
@@ -453,6 +459,29 @@ if ( open(PIPE, "| $mysqld_install_cmd_l
   report_verbose($opt,"OK");
 
   # ----------------------------------------------------------------------
+  # Pipe ALTER TABLE mysql.slave_master_info|slave_relay_log_info to "mysqld --bootstrap"
+  # ----------------------------------------------------------------------
+
+  if ($opt->{'rpl-engine'})
+  {
+    report_verbose_wait($opt,"Setting engine for mysql.slave_master_info mysql.slave_relay_log_info tables...");
+    if ( open(PIPE, "| $mysqld_install_cmd_line") )
+    {
+      print PIPE "use mysql;\n";
+      print PIPE "ALTER TABLE mysql.slave_master_info ENGINE= " . $opt->{'rpl-engine'} . ";\n";
+      print PIPE "ALTER TABLE mysql.slave_relay_log_info ENGINE= " . $opt->{'$rpl-engine'} . ";\n";
+      close PIPE;
+
+      report_verbose($opt,"OK");
+    }
+    else
+    {
+      warning($opt,"CRASH-SAFE SLAVE IS NOT COMPLETELY CONFIGURED!",
+                   "The \"CRASH-SAFE SLAVE\" might not work properly.");
+    }
+  }
+
+  # ----------------------------------------------------------------------
   # Pipe fill_help_tables.sql to "mysqld --bootstrap"
   # ----------------------------------------------------------------------
 

=== modified file 'scripts/mysql_install_db.sh'
--- a/scripts/mysql_install_db.sh	2010-10-08 16:11:32 +0000
+++ b/scripts/mysql_install_db.sh	2010-10-25 10:39:01 +0000
@@ -63,6 +63,11 @@ Usage: $0 [OPTIONS]
                        user.  You must be root to use this option.  By default
                        mysqld runs using your current login name and files and
                        directories that it creates will be owned by you.
+  --rpl-engine=engine  The storage engine used for the mysql.slave_master_info and
+                       mysql.slave_relay_log_info tables. By default, both tables are
+                       created using the MyISAM storage engine. However, any storage
+                       engine available to the server may be used. If a crash-safe
+                       slave is required, the storage engine must be transactional.
 
 All other options are passed to the mysqld program
 
@@ -115,6 +120,8 @@ parse_arguments()
       --no-defaults|--defaults-file=*|--defaults-extra-file=*)
         defaults="$arg" ;;
 
+      --rpl-engine=*) rpl_engine=`parse_arg "$arg"` ;;
+
       --cross-bootstrap|--windows)
         # Used when building the MySQL system tables on a different host than
         # the target. The platform-independent files that are created in
@@ -427,6 +434,19 @@ else
   exit 1
 fi
 
+if test -n "$rpl_engine"
+then
+  s_echo "Setting engine for mysql.slave_master_info mysql.slave_relay_log_info tables..."
+  if { echo "use mysql;"; echo "ALTER TABLE mysql.slave_master_info ENGINE= $rpl_engine;"; echo "ALTER TABLE mysql.slave_relay_log_info ENGINE= $rpl_engine;"; } | $mysqld_install_cmd_line > /dev/null
+  then
+    s_echo "OK"
+  else
+    echo
+    echo "WARNING: CRASH-SAFE SLAVE IS NOT COMPLETELY CONFIGURED!"
+    echo "The \"CRASH-SAFE SLAVE\" might not work properly."
+  fi
+fi
+
 s_echo "Filling help tables..."
 if { echo "use mysql;"; cat $fill_help_tables; } | $mysqld_install_cmd_line > /dev/null
 then

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2010-11-09 08:16:50 +0000
+++ b/scripts/mysql_system_tables.sql	2010-11-15 16:43:41 +0000
@@ -100,6 +100,10 @@ CREATE TABLE IF NOT EXISTS event ( db ch
 
 CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM;
 
+CREATE TABLE IF NOT EXISTS slave_relay_log_info (Master_id INTEGER UNSIGNED NOT NULL, Number_of_lines INTEGER UNSIGNED NOT NULL, Relay_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, Relay_log_pos BIGINT UNSIGNED NOT NULL, Master_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, Master_log_pos BIGINT UNSIGNED NOT NULL, Sql_delay INTEGER NOT NULL, PRIMARY KEY(Master_id)) ENGINE=MYISAM DEFAULT CHARSET=utf8 COMMENT 'Relay Log Information';
+
+CREATE TABLE IF NOT EXISTS slave_master_info (Master_id INTEGER UNSIGNED NOT NULL, Number_of_lines INTEGER UNSIGNED NOT NULL, Master_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, Master_log_pos BIGINT UNSIGNED NOT NULL, Host TEXT CHARACTER SET utf8 COLLATE utf8_bin, User_name TEXT CHARACTER SET utf8 COLLATE utf8_bin, User_password TEXT CHARACTER SET utf8 COLLATE utf8_bin, Port INTEGER UNSIGNED NOT NULL, Connect_retry INTEGER UNSIGNED NOT NULL, Enabled_ssl BOOLEAN NOT NULL, Ssl_ca TEXT CHARACTER SET utf8 COLLATE utf8_bin, Ssl_capath TEXT CHARACTER SET utf8 COLLATE utf8_bin, Ssl_cert TEXT CHARACTER SET utf8 COLLATE utf8_bin, Ssl_cipher TEXT CHARACTER SET utf8 COLLATE utf8_bin, Ssl_key TEXT CHARACTER SET utf8 COLLATE utf8_bin, Ssl_verify_servert_cert BOOLEAN NOT NULL, Heartbeat FLOAT NOT NULL, Bind TEXT CHARACTER SET utf8 COLLATE utf8_bin, Ignored_server_ids TEXT CHARACTER SET utf8 COLLATE utf8_bin, Uuid TEXT CHARACTER SET utf8 COLLATE utf8_bin, Retry_count BIGINT
  UNSIGNED NOT NULL, PRIMARY KEY(Master_id)) ENGINE=MYISAM DEFAULT CHARSET=utf8 COMMENT 'Master Information';
+
 --
 -- PERFORMANCE SCHEMA INSTALLATION
 -- Note that this script is also reused by mysql_upgrade,

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2010-11-04 15:40:18 +0000
+++ b/sql/CMakeLists.txt	2010-11-19 11:24:33 +0000
@@ -95,7 +95,7 @@ TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATI
 
 SET (BINLOG_SOURCE log_event.cc log_event_old.cc binlog.cc sql_binlog.cc
 		   rpl_filter.cc rpl_record.cc rpl_record_old.cc rpl_utility.cc
-		   sql_binlog.cc rpl_injector.cc)
+		   rpl_injector.cc)
 ADD_LIBRARY(binlog ${BINLOG_SOURCE})
 SET (RPL_SOURCE rpl_handler.cc rpl_tblmap.cc)
 ADD_DEPENDENCIES(binlog GenError)
@@ -105,8 +105,9 @@ ADD_DEPENDENCIES(rpl GenError)
 ADD_LIBRARY(master ${MASTER_SOURCE})
 ADD_DEPENDENCIES(master GenError)
 SET (SLAVE_SOURCE rpl_slave.cc rpl_reporting.cc rpl_mi.cc rpl_rli.cc
-		  rpl_info_handler.cc rpl_info_file.cc rpl_info.cc
-                  rpl_info_factory.cc server_ids.h)
+		  rpl_info_handler.cc rpl_info_file.cc rpl_info_table.cc
+		  rpl_info_values.cc rpl_info.cc rpl_info_factory.cc
+		  rpl_info_table_access.cc server_ids.h)
 ADD_LIBRARY(slave ${SLAVE_SOURCE})
 ADD_DEPENDENCIES(slave GenError)
 ADD_LIBRARY(sqlgunitlib mdl.cc sql_list.cc sql_string.cc thr_malloc.cc)

=== modified file 'sql/Makefile.am'
--- a/sql/Makefile.am	2010-11-09 20:10:44 +0000
+++ b/sql/Makefile.am	2010-11-15 16:43:41 +0000
@@ -108,7 +108,8 @@ noinst_HEADERS =	item.h item_func.h item
 			rpl_reporting.h sql_locale.h sql_parse.h \
 			rpl_info_handler.h \
 			log.h sql_show.h rpl_info.h rpl_info_file.h \
-			rpl_rli.h rpl_mi.h \
+			rpl_info_table.h rpl_rli.h rpl_mi.h rpl_info_values.h \
+			rpl_info_table_access.h \
 			rpl_info_factory.h server_ids.h \
 			sql_select.h structs.h table.h sql_udf.h hash_filo.h \
 			lex.h lex_symbol.h sql_acl.h sql_crypt.h sql_base.h \
@@ -194,7 +195,8 @@ librpl_la_SOURCES    =  rpl_handler.cc r
 libmaster_la_SOURCES =	rpl_master.cc
 libslave_la_SOURCES = 	rpl_slave.cc rpl_reporting.cc rpl_rli.cc rpl_mi.cc \
 			rpl_info.cc rpl_info_factory.cc rpl_info_file.cc \
-			rpl_info_handler.cc
+			rpl_info_handler.cc rpl_info_table.cc \
+			rpl_info_table_access.cc rpl_info_values.cc
 libndb_la_CPPFLAGS=	@ndbcluster_includes@
 libndb_la_SOURCES=	ha_ndbcluster.cc \
 			ha_ndbcluster_binlog.cc \

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2010-10-27 14:46:44 +0000
+++ b/sql/binlog.cc	2010-11-16 12:14:06 +0000
@@ -509,7 +509,7 @@ binlog_flush_stmt_cache(THD *thd, binlog
   if (thd->binlog_flush_pending_rows_event(TRUE, is_transactional))
     DBUG_RETURN(1);
 
-  Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE, TRUE, 0);
+  Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, TRUE, TRUE, 0);
   if ((error= mysql_bin_log.write(thd, cache_log, &qev,
                                   cache_mngr->stmt_cache.has_incident())))
     DBUG_RETURN(error);
@@ -572,7 +572,7 @@ static int binlog_commit(handlerton *hto
   */
   if (ending_trans(thd, all))
   {
-    Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE, TRUE, 0);
+    Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, TRUE, TRUE, 0);
     error= binlog_flush_trx_cache(thd, cache_mngr, &qev);
   }
 
@@ -668,7 +668,7 @@ static int binlog_rollback(handlerton *h
           ending_single_stmt_trans(thd,all) &&
           thd->variables.binlog_format == BINLOG_FORMAT_MIXED)))
     {
-      Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE, TRUE, 0);
+      Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, TRUE, TRUE, 0);
       error= binlog_flush_trx_cache(thd, cache_mngr, &qev);
     }
     /*
@@ -1312,7 +1312,8 @@ bool show_binlog_events(THD *thd, MYSQL_
       This code will fail on a mixed relay log (one which has Format_desc then
       Rotate then Format_desc).
     */
-    ev= Log_event::read_log_event(&log, (mysql_mutex_t*)0, description_event);
+    ev= Log_event::read_log_event(&log, (mysql_mutex_t*)0, description_event,
+                                   opt_master_verify_checksum);
     if (ev)
     {
       if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
@@ -1334,8 +1335,12 @@ bool show_binlog_events(THD *thd, MYSQL_
 
     for (event_count = 0;
          (ev = Log_event::read_log_event(&log, (mysql_mutex_t*) 0,
-                                         description_event)); )
+                                         description_event,
+                                         opt_master_verify_checksum)); )
     {
+      if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
+        description_event->checksum_alg= ev->checksum_alg;
+
       if (event_count >= limit_start &&
 	  ev->net_send(protocol, linfo.log_file_name, pos))
       {
@@ -1425,6 +1430,8 @@ MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_
    need_start_event(TRUE),
    sync_period_ptr(sync_period),
    is_relay_log(0), signal_cnt(0),
+   checksum_alg_reset(BINLOG_CHECKSUM_ALG_UNDEF),
+   relay_log_checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF),
    description_event_for_exec(0), description_event_for_queue(0)
 {
   /*
@@ -1639,7 +1646,19 @@ bool MYSQL_BIN_LOG::open(const char *log
         as we won't be able to reset it later
       */
       if (io_cache_type == WRITE_CACHE)
-        s.flags|= LOG_EVENT_BINLOG_IN_USE_F;
+        s.flags |= LOG_EVENT_BINLOG_IN_USE_F;
+      s.checksum_alg= is_relay_log ?
+        /* relay-log */
+        /* inherit master's A descriptor if one has been received */
+        (relay_log_checksum_alg= 
+         (relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF) ?
+         relay_log_checksum_alg :
+         /* otherwise use slave's local preference of RL events verification */
+         (opt_slave_sql_verify_checksum == 0) ?
+         (uint8) BINLOG_CHECKSUM_ALG_OFF : binlog_checksum_options):
+        /* binlog */
+        binlog_checksum_options;
+      DBUG_ASSERT(s.checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
       if (!s.is_valid())
         goto err;
       s.dont_set_created= null_created_arg;
@@ -2799,8 +2818,15 @@ void MYSQL_BIN_LOG::new_file_impl(bool n
         We log the whole file name for log file as the user may decide
         to change base names at some point.
       */
-      Rotate_log_event r(new_name+dirname_length(new_name),
-                         0, LOG_EVENT_OFFSET, is_relay_log ? Rotate_log_event::RELAY_LOG : 0);
+      Rotate_log_event r(new_name+dirname_length(new_name), 0, LOG_EVENT_OFFSET,
+                         is_relay_log ? Rotate_log_event::RELAY_LOG : 0);
+      /* 
+         The current relay-log's closing Rotate event must have checksum
+         value computed with an algorithm of the last relay-logged FD event.
+      */
+      if (is_relay_log)
+        r.checksum_alg= relay_log_checksum_alg;
+      DBUG_ASSERT(!is_relay_log || relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
       r.write(&log_file);
       bytes_written += r.data_written;
     }
@@ -2814,7 +2840,12 @@ void MYSQL_BIN_LOG::new_file_impl(bool n
   old_name=name;
   name=0;				// Don't free name
   close(LOG_CLOSE_TO_BE_OPENED | LOG_CLOSE_INDEX);
-
+  if (log_type == LOG_BIN && checksum_alg_reset != BINLOG_CHECKSUM_ALG_UNDEF)
+  {
+    DBUG_ASSERT(!is_relay_log);
+    DBUG_ASSERT(binlog_checksum_options != checksum_alg_reset);
+    binlog_checksum_options= checksum_alg_reset;
+  }
   /*
      Note that at this point, log_state != LOG_CLOSED (important for is_open()).
   */
@@ -3124,10 +3155,16 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
     {
       if (!thd->is_current_stmt_binlog_format_row())
       {
+        /* three possibility for cache_type at this point */
+        DBUG_ASSERT(event_info->cache_type == Log_event::EVENT_TRANSACTIONAL_CACHE ||
+                    event_info->cache_type == Log_event::EVENT_STMT_CACHE ||
+                    event_info->cache_type == Log_event::EVENT_NO_CACHE);
+ 
         if (thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt)
         {
           Intvar_log_event e(thd,(uchar) LAST_INSERT_ID_EVENT,
-                             thd->first_successful_insert_id_in_prev_stmt_for_binlog);
+                             thd->first_successful_insert_id_in_prev_stmt_for_binlog,
+                             event_info->cache_type);
           if (e.write(file))
             goto err;
         }
@@ -3138,13 +3175,14 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
                              nb_elements()));
           Intvar_log_event e(thd, (uchar) INSERT_ID_EVENT,
                              thd->auto_inc_intervals_in_cur_stmt_for_binlog.
-                             minimum());
+                             minimum(), event_info->cache_type);
           if (e.write(file))
             goto err;
         }
         if (thd->rand_used)
         {
-          Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
+          Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2,
+                           event_info->cache_type);
           if (e.write(file))
             goto err;
         }
@@ -3165,8 +3203,8 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
                                  user_var_event->value,
                                  user_var_event->length,
                                  user_var_event->type,
-                                 user_var_event->charset_number,
-                                 flags);
+                                 user_var_event->charset_number, flags,
+                                 event_info->cache_type);
             if (e.write(file))
               goto err;
           }
@@ -3232,6 +3270,8 @@ void MYSQL_BIN_LOG::rotate_and_purge(uin
 #ifdef HAVE_REPLICATION
     check_purge= true;
 #endif
+    if (flags & RP_BINLOG_CHECKSUM_ALG_CHANGE)
+      checksum_alg_reset= BINLOG_CHECKSUM_ALG_UNDEF; // done
   }
   if (!(flags & RP_LOCK_LOG_IS_ALREADY_LOCKED))
     mysql_mutex_unlock(&LOCK_log);
@@ -3260,6 +3300,36 @@ uint MYSQL_BIN_LOG::next_file_id()
 }
 
 
+/**
+  Calculate checksum of possibly a part of an event containing at least
+  the whole common header.
+
+  @param    buf       the pointer to trans cache's buffer
+  @param    off       the offset of the beginning of the event in the buffer
+  @param    event_len no-checksum length of the event
+  @param    length    the current size of the buffer
+
+  @param    crc       [in-out] the checksum
+
+  Event size in incremented by @c BINLOG_CHECKSUM_LEN.
+
+  @return 0 or number of unprocessed yet bytes of the event excluding 
+            the checksum part.
+*/
+  static ulong fix_log_event_crc(uchar *buf, uint off, uint event_len,
+                                 uint length, ha_checksum *crc)
+{
+  ulong ret;
+  uchar *event_begin= buf + off;
+  uint16 flags= uint2korr(event_begin + FLAGS_OFFSET);
+
+  DBUG_ASSERT(length >= off + LOG_EVENT_HEADER_LEN); //at least common header in
+  int2store(event_begin + FLAGS_OFFSET, flags);
+  ret= length >= off + event_len ? 0 : off + event_len - length;
+  *crc= my_checksum(*crc, event_begin, event_len - ret); 
+  return ret;
+}
+
 /*
   Write the contents of a cache to the binary log.
 
@@ -3272,7 +3342,11 @@ uint MYSQL_BIN_LOG::next_file_id()
   DESCRIPTION
     Write the contents of the cache to the binary log. The cache will
     be reset as a READ_CACHE to be able to read the contents from it.
- */
+
+    Reading from the trans cache with possible (per @c binlog_checksum_options) 
+    adding checksum value  and then fixing the length and the end_log_pos of 
+    events prior to fill in the binlog cache.
+*/
 
 int MYSQL_BIN_LOG::write_cache(IO_CACHE *cache, bool lock_log, bool sync_log)
 {
@@ -3281,8 +3355,17 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
   if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
     return ER_ERROR_ON_WRITE;
   uint length= my_b_bytes_in_cache(cache), group, carry, hdr_offs;
+  ulong remains= 0; // part of unprocessed yet netto length of the event
   long val;
+  ulong end_log_pos_inc= 0; // each event processed adds BINLOG_CHECKSUM_LEN 2 t
   uchar header[LOG_EVENT_HEADER_LEN];
+  ha_checksum crc= 0, crc_0= 0; // assignments to keep compiler happy
+  my_bool do_checksum= (binlog_checksum_options != BINLOG_CHECKSUM_ALG_OFF);
+  uchar buf[BINLOG_CHECKSUM_LEN];
+
+  // while there is just one alg the following must hold:
+  DBUG_ASSERT(!do_checksum ||
+              binlog_checksum_options == BINLOG_CHECKSUM_ALG_CRC32);
 
   /*
     The events in the buffer have incorrect end_log_pos data
@@ -3300,6 +3383,8 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
 
   group= (uint)my_b_tell(&log_file);
   hdr_offs= carry= 0;
+  if (do_checksum)
+    crc= crc_0= my_checksum(0L, NULL, 0);
 
   do
   {
@@ -3312,12 +3397,21 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
       DBUG_ASSERT(carry < LOG_EVENT_HEADER_LEN);
 
       /* assemble both halves */
-      memcpy(&header[carry], (char *)cache->read_pos, LOG_EVENT_HEADER_LEN - carry);
+      memcpy(&header[carry], (char *)cache->read_pos,
+             LOG_EVENT_HEADER_LEN - carry);
 
       /* fix end_log_pos */
-      val= uint4korr(&header[LOG_POS_OFFSET]) + group;
+      val= uint4korr(&header[LOG_POS_OFFSET]) + group +
+        (end_log_pos_inc+= (do_checksum ? BINLOG_CHECKSUM_LEN : 0));
       int4store(&header[LOG_POS_OFFSET], val);
 
+      if (do_checksum)
+      {
+        ulong len= uint4korr(&header[EVENT_LEN_OFFSET]);
+        /* fix len */
+        int4store(&header[EVENT_LEN_OFFSET], len + BINLOG_CHECKSUM_LEN);
+      }
+
       /* write the first half of the split header */
       if (my_b_write(&log_file, header, carry))
         return ER_ERROR_ON_WRITE;
@@ -3326,11 +3420,20 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
         copy fixed second half of header to cache so the correct
         version will be written later.
       */
-      memcpy((char *)cache->read_pos, &header[carry], LOG_EVENT_HEADER_LEN - carry);
+      memcpy((char *)cache->read_pos, &header[carry],
+             LOG_EVENT_HEADER_LEN - carry);
 
       /* next event header at ... */
-      hdr_offs = uint4korr(&header[EVENT_LEN_OFFSET]) - carry;
+      hdr_offs= uint4korr(&header[EVENT_LEN_OFFSET]) - carry -
+        (do_checksum ? BINLOG_CHECKSUM_LEN : 0);
 
+      if (do_checksum)
+      {
+        DBUG_ASSERT(crc == crc_0 && remains == 0);
+        crc= my_checksum(crc, header, carry);
+        remains= uint4korr(header + EVENT_LEN_OFFSET) - carry -
+          BINLOG_CHECKSUM_LEN;
+      }
       carry= 0;
     }
 
@@ -3345,6 +3448,25 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
         very next iteration, just "eventually").
       */
 
+      /* crc-calc the whole buffer */
+      if (do_checksum && hdr_offs >= length)
+      {
+
+        DBUG_ASSERT(remains != 0 && crc != crc_0);
+
+        crc= my_checksum(crc, cache->read_pos, length); 
+        remains -= length;
+        if (my_b_write(&log_file, cache->read_pos, length))
+          return ER_ERROR_ON_WRITE;
+        if (remains == 0)
+        {
+          int4store(buf, crc);
+          if (my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
+            return ER_ERROR_ON_WRITE;
+          crc= crc_0;
+        }
+      }
+
       while (hdr_offs < length)
       {
         /*
@@ -3352,6 +3474,26 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
           we get the rest.
         */
 
+        if (do_checksum)
+        {
+          if (remains != 0)
+          {
+            /*
+              finish off with remains of the last event that crawls
+              from previous into the current buffer
+            */
+            DBUG_ASSERT(crc != crc_0);
+            crc= my_checksum(crc, cache->read_pos, hdr_offs);
+            int4store(buf, crc);
+            remains -= hdr_offs;
+            DBUG_ASSERT(remains == 0);
+            if (my_b_write(&log_file, cache->read_pos, hdr_offs) ||
+                my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
+              return ER_ERROR_ON_WRITE;
+            crc= crc_0;
+          }
+        }
+
         if (hdr_offs + LOG_EVENT_HEADER_LEN > length)
         {
           carry= length - hdr_offs;
@@ -3361,17 +3503,38 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
         else
         {
           /* we've got a full event-header, and it came in one piece */
-
-          uchar *log_pos= (uchar *)cache->read_pos + hdr_offs + LOG_POS_OFFSET;
+          uchar *ev= (uchar *)cache->read_pos + hdr_offs;
+          uint event_len= uint4korr(ev + EVENT_LEN_OFFSET); // netto len
+          uchar *log_pos= ev + LOG_POS_OFFSET;
 
           /* fix end_log_pos */
-          val= uint4korr(log_pos) + group;
+          val= uint4korr(log_pos) + group +
+            (end_log_pos_inc += (do_checksum ? BINLOG_CHECKSUM_LEN : 0));
           int4store(log_pos, val);
 
+	  /* fix CRC */
+	  if (do_checksum)
+          {
+            /* fix length */
+            int4store(ev + EVENT_LEN_OFFSET, event_len + BINLOG_CHECKSUM_LEN);
+            remains= fix_log_event_crc(cache->read_pos, hdr_offs, event_len,
+                                       length, &crc);
+            if (my_b_write(&log_file, ev, 
+                           remains == 0 ? event_len : length - hdr_offs))
+              return ER_ERROR_ON_WRITE;
+            if (remains == 0)
+            {
+              int4store(buf, crc);
+              if (my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
+                return ER_ERROR_ON_WRITE;
+              crc= crc_0; // crc is complete
+            }
+          }
+
           /* next event header at ... */
-          log_pos= (uchar *)cache->read_pos + hdr_offs + EVENT_LEN_OFFSET;
-          hdr_offs += uint4korr(log_pos);
+          hdr_offs += event_len; // incr by the netto len
 
+          DBUG_ASSERT(!do_checksum || remains == 0 || hdr_offs >= length);
         }
       }
 
@@ -3386,17 +3549,20 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
       hdr_offs -= length;
     }
 
-    /* Write data to the binary log file */
-    if (my_b_write(&log_file, cache->read_pos, length))
-      return ER_ERROR_ON_WRITE;
+    /* Write the entire buf to the binary log file */
+    if (!do_checksum)
+      if (my_b_write(&log_file, cache->read_pos, length))
+        return ER_ERROR_ON_WRITE;
     cache->read_pos=cache->read_end;		// Mark buffer used up
   } while ((length= my_b_fill(cache)));
 
-  DBUG_ASSERT(carry == 0);
-
   if (sync_log)
     return flush_and_sync(0);
 
+  DBUG_ASSERT(carry == 0);
+  DBUG_ASSERT(!do_checksum || remains == 0);
+  DBUG_ASSERT(!do_checksum || crc == crc_0);
+
   return 0;                                     // All OK
 }
 
@@ -3467,7 +3633,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C
         transaction is either a BEGIN..COMMIT block or a single
         statement in autocommit mode.
       */
-      Query_log_event qinfo(thd, STRING_WITH_LEN("BEGIN"), TRUE, FALSE, TRUE, 0);
+      Query_log_event qinfo(thd, STRING_WITH_LEN("BEGIN"), TRUE, TRUE, TRUE, 0);
       if (qinfo.write(&log_file))
         goto err;
       DBUG_EXECUTE_IF("crash_before_writing_xid",
@@ -3623,6 +3789,11 @@ void MYSQL_BIN_LOG::close(uint exiting)
 	(exiting & LOG_CLOSE_STOP_EVENT))
     {
       Stop_log_event s;
+      // the checksumming rule for relay-log case is similar to Rotate
+        s.checksum_alg= is_relay_log ?
+          relay_log_checksum_alg : binlog_checksum_options;
+      DBUG_ASSERT(!is_relay_log ||
+                  relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
       s.write(&log_file);
       bytes_written+= s.data_written;
       signal_update();
@@ -3770,7 +3941,8 @@ int MYSQL_BIN_LOG::open(const char *opt_
       goto err;
     }
 
-    if ((ev= Log_event::read_log_event(&log, 0, &fdle)) &&
+    if ((ev= Log_event::read_log_event(&log, 0, &fdle,
+                                       opt_master_verify_checksum)) &&
         ev->get_type_code() == FORMAT_DESCRIPTION_EVENT &&
         ev->flags & LOG_EVENT_BINLOG_IN_USE_F)
     {
@@ -3850,7 +4022,9 @@ int MYSQL_BIN_LOG::recover(IO_CACHE *log
 
   fdle->flags&= ~LOG_EVENT_BINLOG_IN_USE_F; // abort on the first error
 
-  while ((ev= Log_event::read_log_event(log,0,fdle)) && ev->is_valid())
+  while ((ev= Log_event::read_log_event(log, 0, fdle,
+                                        opt_master_verify_checksum))
+         && ev->is_valid())
   {
     if (ev->get_type_code() == XID_EVENT)
     {

=== modified file 'sql/binlog.h'
--- a/sql/binlog.h	2010-10-04 10:16:31 +0000
+++ b/sql/binlog.h	2010-10-25 19:02:24 +0000
@@ -96,6 +96,41 @@ public:
   /* This is relay log */
   bool is_relay_log;
   ulong signal_cnt;  // update of the counter is checked by heartbeat
+  uint8 checksum_alg_reset; // to contain a new value when binlog is rotated
+  /*
+    Holds the last seen in Relay-Log FD's checksum alg value.
+    The initial value comes from the slave's local FD that heads
+    the very first Relay-Log file. In the following the value may change
+    with each received master's FD_m.
+    Besides to be used in verification events that IO thread receives
+    (except the 1st fake Rotate, see @c Master_info:: checksum_alg_before_fd), 
+    the value specifies if/how to compute checksum for slave's local events
+    and the first fake Rotate (R_f^1) coming from the master.
+    R_f^1 needs logging checksum-compatibly with the RL's heading FD_s.
+
+    Legends for the checksum related comments:
+
+    FD     - Format-Description event,
+    R      - Rotate event
+    R_f    - the fake Rotate event
+    E      - an arbirary event
+
+    The underscore indexes for any event
+    `_s'   indicates the event is generated by Slave
+    `_m'   - by Master
+
+    Two special underscore indexes of FD:
+    FD_q   - Format Description event for queuing   (relay-logging)
+    FD_e   - Format Description event for executing (relay-logging)
+
+    Upper indexes:
+    E^n    - n:th event is a sequence
+
+    RL     - Relay Log
+    (A)    - checksum algorithm descriptor value
+    FD.(A) - the value of (A) in FD
+  */
+  uint8 relay_log_checksum_alg;
   /*
     These describe the log's format. This is used only for relay logs.
     _for_exec is used by the SQL thread, _for_queue by the I/O thread. It's

=== modified file 'sql/lock.cc'
--- a/sql/lock.cc	2010-10-25 09:18:21 +0000
+++ b/sql/lock.cc	2010-11-15 16:43:41 +0000
@@ -116,14 +116,21 @@ static int
 lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags)
 {
   uint system_count, i;
-  bool is_superuser, log_table_write_query;
+  bool is_superuser;
+  /*
+    Identifies if the executed sql command can updated either a log
+    or rpl info table.
+  */
+  bool log_table_write_query, rpl_info_table_write_query;
 
   DBUG_ENTER("lock_tables_check");
 
   system_count= 0;
   is_superuser= thd->security_ctx->master_access & SUPER_ACL;
-  log_table_write_query= (is_log_table_write_query(thd->lex->sql_command)
-                         || ((flags & MYSQL_LOCK_LOG_TABLE) != 0));
+  log_table_write_query=
+     is_log_table_write_query(thd->lex->sql_command);
+  rpl_info_table_write_query=
+     is_rpl_info_table_write_query(thd->lex->sql_command);
 
   for (i=0 ; i<count; i++)
   {
@@ -138,16 +145,34 @@ lock_tables_check(THD *thd, TABLE **tabl
       When a user is requesting a lock, the following
       constraints are enforced:
     */
-    if (t->s->require_write_privileges() &&
-        ! log_table_write_query)
+    if (t->s->table_category == TABLE_CATEGORY_RPL_INFO &&
+        (flags & MYSQL_LOCK_RPL_INFO_TABLE) == 0 &&
+        !rpl_info_table_write_query)
     {
       /*
         A user should not be able to prevent writes,
         or hold any type of lock in a session,
         since this would be a DOS attack.
       */
-      if ((t->reginfo.lock_type >= TL_READ_NO_INSERT
-          || thd->lex->sql_command == SQLCOM_LOCK_TABLES))
+      if (t->reginfo.lock_type >= TL_READ_NO_INSERT ||
+          thd->lex->sql_command == SQLCOM_LOCK_TABLES)
+      {
+          my_error(ER_CANT_LOCK_RPL_INFO_TABLE, MYF(0));
+          DBUG_RETURN(1);
+      }
+    }
+
+    if (t->s->table_category == TABLE_CATEGORY_LOG &&
+        (flags & MYSQL_LOCK_LOG_TABLE) == 0 &&
+        !log_table_write_query)
+    {
+      /*
+        A user should not be able to prevent writes,
+        or hold any type of lock in a session,
+        since this would be a DOS attack.
+      */
+      if (t->reginfo.lock_type >= TL_READ_NO_INSERT ||
+          thd->lex->sql_command == SQLCOM_LOCK_TABLES)
       {
         my_error(ER_CANT_LOCK_LOG_TABLE, MYF(0));
         DBUG_RETURN(1);

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-10-27 10:28:09 +0000
+++ b/sql/log.cc	2010-11-16 12:14:06 +0000
@@ -1932,8 +1932,6 @@ bool general_log_write(THD *thd, enum en
   return FALSE;
 }
 
-
-
 /**
   Check if a string is a valid number.
 

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-11-08 02:49:16 +0000
+++ b/sql/log_event.cc	2010-11-23 23:10:22 +0000
@@ -51,6 +51,31 @@
 #include <my_bitmap.h>
 #include "rpl_utility.h"
 
+
+/**
+  BINLOG_CHECKSUM variable.
+*/
+const char *binlog_checksum_type_names[]= {
+  "NONE",
+  "CRC32",
+  NullS
+};
+
+unsigned int binlog_checksum_type_length[]= {
+  sizeof("NONE") - 1,
+  sizeof("CRC32") - 1,
+  0
+};
+
+TYPELIB binlog_checksum_typelib=
+{
+  array_elements(binlog_checksum_type_names) - 1, "",
+  binlog_checksum_type_names,
+  binlog_checksum_type_length
+};
+
+
+
 #define log_cs	&my_charset_latin1
 
 #define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
@@ -64,6 +89,18 @@
 */
 #define FMT_G_BUFSIZE(PREC) (3 + (PREC) + 5 + 1)
 
+/* 
+   replication event checksum is introduced in the following "checksum-home" version.
+   The checksum-aware servers extract FD's version to decide whether the FD event
+   carries checksum info.
+
+   TODO: correct the constant when it has been determined 
+   (which main tree to push and when) 
+*/
+const uchar checksum_version_split[3]= {5, 1, 46};
+const ulong checksum_version_product=
+  (checksum_version_split[0] * 256 + checksum_version_split[1]) * 256 +
+  checksum_version_split[2];
 
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
 static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD* thd);
@@ -574,7 +611,6 @@ static void print_set_option(IO_CACHE* f
   }
 }
 #endif
-
 /**************************************************************************
 	Log_event methods (= the parent class of all events)
 **************************************************************************/
@@ -631,7 +667,8 @@ const char* Log_event::get_type_str()
 #ifndef MYSQL_CLIENT
 Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans)
   :log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg),
-  cache_type(Log_event::EVENT_INVALID_CACHE), thd(thd_arg)
+   cache_type(Log_event::EVENT_INVALID_CACHE), crc(0), thd(thd_arg),
+   checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF)
 {
   server_id=	thd->server_id;
   when=		thd->start_time;
@@ -650,8 +687,8 @@ Log_event::Log_event(THD* thd_arg, uint1
 */
 
 Log_event::Log_event()
-  :temp_buf(0), exec_time(0), flags(0),
-  cache_type(Log_event::EVENT_INVALID_CACHE), thd(0)
+  :temp_buf(0), exec_time(0), flags(0),  crc(0), thd(0),
+   checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF)
 {
   server_id=	::server_id;
   /*
@@ -670,7 +707,8 @@ Log_event::Log_event()
 
 Log_event::Log_event(const char* buf,
                      const Format_description_log_event* description_event)
-  :temp_buf(0), exec_time(0), cache_type(Log_event::EVENT_INVALID_CACHE)
+  :temp_buf(0), exec_time(0), cache_type(Log_event::EVENT_INVALID_CACHE),
+    crc(0), checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF)
 {
 #ifndef MYSQL_CLIENT
   thd = 0;
@@ -832,6 +870,105 @@ void Log_event::init_show_field_list(Lis
   field_list->push_back(new Item_empty_string("Info", 20));
 }
 
+/**
+   A decider of whether to trigger checksum computation or not.
+   To be invoked in Log_event::write() stack.
+   The decision is positive 
+
+    S,M) if it's been marked for checksumming with @c checksum_alg
+    
+    M) otherwise, if @@global.binlog_checksum is not NONE and the event is 
+       directly written to the binlog file.
+       The to-be-cached event decides at @c write_cache() time.
+
+   Otherwise the decision is negative.
+
+   @note   A side effect of the method is altering Log_event::checksum_alg
+           it the latter was undefined at calling.
+
+   @return true (positive) or false (negative)
+*/
+my_bool Log_event::need_checksum()
+{
+  DBUG_ENTER("Log_event::need_checksum");
+  my_bool ret;
+  /* 
+     few callers of Log_event::write 
+     (incl FD::write, FD constructing code on the slave side, Rotate relay log
+     and Stop event) 
+     provides their checksum alg preference through Log_event::checksum_alg.
+  */
+  ret= (checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF) ?
+    (checksum_alg != BINLOG_CHECKSUM_ALG_OFF) :
+    ((binlog_checksum_options != BINLOG_CHECKSUM_ALG_OFF) &&
+     (cache_type == Log_event::EVENT_NO_CACHE))? binlog_checksum_options :
+    FALSE;
+
+  /*
+    FD calls the methods before data_written has been calculated.
+    The following invariant claims if the current is not the first
+    call (and therefore data_written is not zero) then `ret' must be
+    TRUE. It may not be null because FD is always checksummed.
+  */
+  
+  DBUG_ASSERT(get_type_code() != FORMAT_DESCRIPTION_EVENT || ret ||
+              data_written == 0);
+
+  if (checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF)
+    checksum_alg= ret ? // calculated value stored
+      binlog_checksum_options : (uint8) BINLOG_CHECKSUM_ALG_OFF;
+
+  DBUG_ASSERT(!ret || 
+              ((checksum_alg == binlog_checksum_options ||
+               /* 
+                  Stop event closes the relay-log and its checksum alg
+                  preference is set by the caller can be different
+                  from the server's binlog_checksum_options.
+               */
+               get_type_code() == STOP_EVENT ||
+               /* 
+                  Rotate:s can be checksummed regardless of the server's
+                  binlog_checksum_options. That applies to both
+                  the local RL's Rotate and the master's Rotate
+                  which IO thread instantiates via queue_binlog_ver_3_event.
+               */
+               get_type_code() == ROTATE_EVENT
+               ||  /* FD is always checksummed */
+               get_type_code() == FORMAT_DESCRIPTION_EVENT) && 
+               checksum_alg != BINLOG_CHECKSUM_ALG_OFF));
+
+  DBUG_ASSERT(checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
+
+  DBUG_ASSERT(((get_type_code() != ROTATE_EVENT &&
+                get_type_code() != STOP_EVENT) ||
+               get_type_code() != FORMAT_DESCRIPTION_EVENT) ||
+              cache_type == Log_event::EVENT_NO_CACHE);
+
+  DBUG_RETURN(ret);
+}
+
+bool Log_event::wrapper_my_b_safe_write(IO_CACHE* file, const uchar* buf, ulong size)
+{
+  if (need_checksum() && size != 0)
+    crc= my_checksum(crc, buf, size);
+
+  return my_b_safe_write(file, buf, size);
+}
+
+bool Log_event::write_footer(IO_CACHE* file) 
+{
+  /*
+     footer contains the checksum-algorithm descriptor 
+     followed by the checksum value
+  */
+  if (need_checksum())
+  {
+    uchar buf[BINLOG_CHECKSUM_LEN];
+    int4store(buf, crc);
+    return (my_b_safe_write(file, (uchar*) buf, sizeof(buf)));
+  }
+  return 0;
+}
 
 /*
   Log_event::write()
@@ -841,11 +978,18 @@ bool Log_event::write_header(IO_CACHE* f
 {
   uchar header[LOG_EVENT_HEADER_LEN];
   ulong now;
+  bool ret;
   DBUG_ENTER("Log_event::write_header");
 
   /* Store number of bytes that will be written by this event */
   data_written= event_data_length + sizeof(header);
 
+  if (need_checksum())
+  {
+    crc= my_checksum(0L, NULL, 0);
+    data_written += BINLOG_CHECKSUM_LEN;
+  }
+
   /*
     log_pos != 0 if this is relay-log event. In this case we should not
     change the position
@@ -918,9 +1062,36 @@ bool Log_event::write_header(IO_CACHE* f
   int4store(header+ SERVER_ID_OFFSET, server_id);
   int4store(header+ EVENT_LEN_OFFSET, data_written);
   int4store(header+ LOG_POS_OFFSET, log_pos);
-  int2store(header+ FLAGS_OFFSET, flags);
-
-  DBUG_RETURN(my_b_safe_write(file, header, sizeof(header)) != 0);
+  /*
+    recording checksum of FD event computed with dropped
+    possibly active LOG_EVENT_BINLOG_IN_USE_F flag.
+    Similar step at verication: the active flag is dropped before
+    checksum computing.
+  */
+  if (header[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT ||
+      !need_checksum() || !(flags & LOG_EVENT_BINLOG_IN_USE_F))
+  {
+    int2store(header+ FLAGS_OFFSET, flags);
+    ret= wrapper_my_b_safe_write(file, header, sizeof(header)) != 0;
+  }
+  else
+  {
+    ret= (wrapper_my_b_safe_write(file, header, FLAGS_OFFSET) != 0);
+    if (!ret)
+    {
+      flags &= ~LOG_EVENT_BINLOG_IN_USE_F;
+      int2store(header + FLAGS_OFFSET, flags);
+      crc= my_checksum(crc, header + FLAGS_OFFSET, sizeof(flags));
+      flags |= LOG_EVENT_BINLOG_IN_USE_F;    
+      int2store(header + FLAGS_OFFSET, flags);
+      ret= (my_b_safe_write(file, header + FLAGS_OFFSET, sizeof(flags)) != 0);
+    }
+    if (!ret)
+      ret= (wrapper_my_b_safe_write(file, header + FLAGS_OFFSET + sizeof(flags),
+                                    sizeof(header)
+                                    - (FLAGS_OFFSET + sizeof(flags))) != 0);
+  }
+  DBUG_RETURN( ret);
 }
 
 
@@ -930,11 +1101,13 @@ bool Log_event::write_header(IO_CACHE* f
 */
 
 int Log_event::read_log_event(IO_CACHE* file, String* packet,
-                              mysql_mutex_t* log_lock)
+                              mysql_mutex_t* log_lock,
+                              uint8 checksum_alg_arg)
 {
   ulong data_len;
   int result=0;
   char buf[LOG_EVENT_MINIMAL_HEADER_LEN];
+  uchar ev_offset= packet->length();
   DBUG_ENTER("Log_event::read_log_event");
 
   if (log_lock)
@@ -993,6 +1166,31 @@ int Log_event::read_log_event(IO_CACHE*
                (file->error >= 0 ? LOG_READ_TRUNC: LOG_READ_IO));
       /* Implicit goto end; */
     }
+    else
+    {
+      /* Corrupt the event for Dump thread*/
+      DBUG_EXECUTE_IF("corrupt_read_log_event",
+	uchar *debug_event_buf_c = (uchar*) packet->ptr() + ev_offset;
+        if (debug_event_buf_c[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT)
+        {
+          int debug_cor_pos = rand() % (data_len + sizeof(buf) - BINLOG_CHECKSUM_LEN);
+          debug_event_buf_c[debug_cor_pos] =~ debug_event_buf_c[debug_cor_pos];
+          DBUG_PRINT("info", ("Corrupt the event at Log_event::read_log_event: byte on position %d", debug_cor_pos));
+          DBUG_SET("-d,corrupt_read_log_event");
+	}
+      );                                                                                           
+      /*
+        CRC verification of the Dump thread
+      */
+      if (opt_master_verify_checksum &&
+          event_checksum_test((uchar*) packet->ptr() + ev_offset,
+                              data_len + sizeof(buf),
+                              checksum_alg_arg))
+      {
+        result= LOG_READ_CHECKSUM_FAILURE;
+        goto end;
+      }
+    }
   }
 
 end:
@@ -1018,11 +1216,13 @@ end:
 Log_event* Log_event::read_log_event(IO_CACHE* file,
                                      mysql_mutex_t* log_lock,
                                      const Format_description_log_event
-                                     *description_event)
+                                     *description_event,
+                                     my_bool crc_check)
 #else
 Log_event* Log_event::read_log_event(IO_CACHE* file,
                                      const Format_description_log_event
-                                     *description_event)
+                                     *description_event,
+                                     my_bool crc_check)
 #endif
 {
   DBUG_ENTER("Log_event::read_log_event");
@@ -1087,7 +1287,7 @@ failed my_b_read"));
     error = "read error";
     goto err;
   }
-  if ((res= read_log_event(buf, data_len, &error, description_event)))
+  if ((res= read_log_event(buf, data_len, &error, description_event, crc_check)))
     res->register_temp_buf(buf);
 
 err:
@@ -1120,9 +1320,11 @@ err:
 
 Log_event* Log_event::read_log_event(const char* buf, uint event_len,
 				     const char **error,
-                                     const Format_description_log_event *description_event)
+                                     const Format_description_log_event *description_event,
+                                     my_bool crc_check)
 {
   Log_event* ev;
+  uint8 alg;
   DBUG_ENTER("Log_event::read_log_event(char*,...)");
   DBUG_ASSERT(description_event != 0);
   DBUG_PRINT("info", ("binlog_version: %d", description_event->binlog_version));
@@ -1138,6 +1340,60 @@ Log_event* Log_event::read_log_event(con
   }
 
   uint event_type= buf[EVENT_TYPE_OFFSET];
+  // all following START events in the current file are without checksum
+  if (event_type == START_EVENT_V3)
+    (const_cast< Format_description_log_event *>(description_event))->checksum_alg= BINLOG_CHECKSUM_ALG_OFF;
+  /*
+    CRC verification by SQL and Show-Binlog-Events master side.
+    The caller has to provide @description_event->checksum_alg to
+    be the last seen FD's (A) descriptor.
+    If event is FD the descriptor is in it.
+    Notice, FD of the binlog can be only in one instance and therefore
+    Show-Binlog-Events executing master side thread needs just to know
+    the only FD's (A) value -  whereas RL can contain more.
+    In the RL case, the alg is kept in FD_e (@description_event) which is reset 
+    to the newer read-out event after its execution with possibly new alg descriptor.
+    Therefore in a typical sequence of RL:
+    {FD_s^0, FD_m, E_m^1} E_m^1 
+    will be verified with (A) of FD_m.
+
+    See legends definition on MYSQL_BIN_LOG::relay_log_checksum_alg docs
+    lines (log.h).
+
+    Notice, a pre-checksum FD version forces alg := BINLOG_CHECKSUM_ALG_UNDEF.
+  */
+  alg= (event_type != FORMAT_DESCRIPTION_EVENT) ?
+    description_event->checksum_alg : get_checksum_alg(buf, event_len);
+  // Emulate the corruption during reading an event
+  DBUG_EXECUTE_IF("corrupt_read_log_event_char",
+    if (event_type != FORMAT_DESCRIPTION_EVENT)
+    {
+      char *debug_event_buf_c = (char *)buf;
+      int debug_cor_pos = rand() % (event_len - BINLOG_CHECKSUM_LEN);
+      debug_event_buf_c[debug_cor_pos] =~ debug_event_buf_c[debug_cor_pos];
+      DBUG_PRINT("info", ("Corrupt the event at Log_event::read_log_event(char*,...): byte on position %d", debug_cor_pos));
+      DBUG_SET("-d,corrupt_read_log_event_char");
+    }
+  );                                                 
+  if (crc_check &&
+      event_checksum_test((uchar *) buf, event_len, alg))
+  {
+#ifdef MYSQL_CLIENT
+    *error= "Event crc check failed! Most likely there is event corruption.";
+    if (force_opt)
+    {
+      ev= new Unknown_log_event(buf, description_event);
+      DBUG_RETURN(ev);
+    }
+    else
+      DBUG_RETURN(NULL);
+#else
+    *error= ER(ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE);
+    sql_print_error("%s", ER(ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE));
+    DBUG_RETURN(NULL);
+#endif
+  }
+
   if (event_type > description_event->number_of_event_types &&
       event_type != FORMAT_DESCRIPTION_EVENT)
   {
@@ -1172,6 +1428,11 @@ Log_event* Log_event::read_log_event(con
       event_type= new_event_type;
     }
 
+    if (alg != BINLOG_CHECKSUM_ALG_UNDEF &&
+        (event_type == FORMAT_DESCRIPTION_EVENT ||
+         alg != BINLOG_CHECKSUM_ALG_OFF))
+      event_len= event_len - BINLOG_CHECKSUM_LEN;
+    
     switch(event_type) {
     case QUERY_EVENT:
       ev  = new Query_log_event(buf, event_len, description_event, QUERY_EVENT);
@@ -1272,6 +1533,14 @@ Log_event* Log_event::read_log_event(con
     }
   }
 
+  if (ev)
+  {
+    ev->checksum_alg= alg;
+    if (ev->checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+        ev->checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+      ev->crc= uint4korr(buf + (event_len));
+  }
+
   DBUG_PRINT("read_event", ("%s(type_code: %d; event_len: %d)",
                             ev ? ev->get_type_str() : "<unknown>",
                             buf[EVENT_TYPE_OFFSET],
@@ -1326,6 +1595,18 @@ void Log_event::print_header(IO_CACHE* f
   my_b_printf(file, " server id %lu  end_log_pos %s ", (ulong) server_id,
               llstr(log_pos,llbuff));
 
+  /* print the checksum */
+
+  if (checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+      checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+  {
+    char checksum_buf[BINLOG_CHECKSUM_LEN * 2 + 4]; // to fit to "0x%lx "
+    size_t const bytes_written=
+      my_snprintf(checksum_buf, sizeof(checksum_buf), "0x%08lx ", (ulong) crc);
+    my_b_printf(file, "%s ", get_type(&binlog_checksum_typelib, checksum_alg));
+    my_b_printf(file, checksum_buf, bytes_written);
+  }
+
   /* mysqlbinlog --hexdump */
   if (print_event_info->hexdump_from)
   {
@@ -2003,6 +2284,9 @@ void Log_event::print_base64(IO_CACHE* f
   if (print_event_info->verbose)
   {
     Rows_log_event *ev= NULL;
+    if (checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF &&
+        checksum_alg != BINLOG_CHECKSUM_ALG_OFF)
+      size-= BINLOG_CHECKSUM_LEN; // checksum is displayed through the header
     
     if (ptr[4] == TABLE_MAP_EVENT)
     {
@@ -2365,12 +2649,13 @@ bool Query_log_event::write(IO_CACHE* fi
   event_length= (uint) (start-buf) + get_post_header_size_for_derived() + db_len + 1 + q_len;
 
   return (write_header(file, event_length) ||
-          my_b_safe_write(file, (uchar*) buf, QUERY_HEADER_LEN) ||
+          wrapper_my_b_safe_write(file, (uchar*) buf, QUERY_HEADER_LEN) ||
           write_post_header_for_derived(file) ||
-          my_b_safe_write(file, (uchar*) start_of_status,
+          wrapper_my_b_safe_write(file, (uchar*) start_of_status,
                           (uint) (start-start_of_status)) ||
-          my_b_safe_write(file, (db) ? (uchar*) db : (uchar*)"", db_len + 1) ||
-          my_b_safe_write(file, (uchar*) query, q_len)) ? 1 : 0;
+          wrapper_my_b_safe_write(file, (db) ? (uchar*) db : (uchar*)"", db_len + 1) ||
+          wrapper_my_b_safe_write(file, (uchar*) query, q_len) ||
+	  write_footer(file)) ? 1 : 0;
 }
 
 /**
@@ -3504,6 +3789,14 @@ int Query_log_event::do_update_pos(Relay
   else
     ret= Log_event::do_update_pos(rli);
 
+  DBUG_EXECUTE_IF("crash_after_commit_and_update_pos",
+       if (!strcmp("COMMIT", query))
+       {
+         rli->flush_info(TRUE);
+         DBUG_SUICIDE();
+       }
+  );
+  
   return ret;
 }
 
@@ -3650,7 +3943,8 @@ bool Start_log_event_v3::write(IO_CACHE*
     created= when= get_time();
   int4store(buff + ST_CREATED_OFFSET,created);
   return (write_header(file, sizeof(buff)) ||
-          my_b_safe_write(file, (uchar*) buff, sizeof(buff)));
+          wrapper_my_b_safe_write(file, (uchar*) buff, sizeof(buff)) ||
+	  write_footer(file));
 }
 #endif
 
@@ -3753,6 +4047,7 @@ int Start_log_event_v3::do_apply_event(R
                                 old 4.0 (binlog version 2) is not supported;
                                 it should not be used for replication with
                                 5.0.
+  @param server_ver             a string containing the server version.
 */
 
 Format_description_log_event::
@@ -3768,9 +4063,9 @@ Format_description_log_event(uint8 binlo
     common_header_len= LOG_EVENT_HEADER_LEN;
     number_of_event_types= LOG_EVENT_TYPES;
     /* we'll catch my_malloc() error in is_valid() */
-    post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8),
+    post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8)
+                                       + BINLOG_CHECKSUM_ALG_DESC_LEN,
                                        MYF(0));
-
     /*
       This long list of assignments is not beautiful, but I see no way to
       make it nicer, as the right members are #defines, not array members, so
@@ -3889,6 +4184,7 @@ Format_description_log_event(uint8 binlo
     break;
   }
   calc_server_version_split();
+  checksum_alg= (uint8) BINLOG_CHECKSUM_ALG_UNDEF;
 }
 
 
@@ -3918,19 +4214,39 @@ Format_description_log_event(const char*
                              description_event)
   :Start_log_event_v3(buf, description_event), event_type_permutation(0)
 {
+  ulong ver_calc;
   DBUG_ENTER("Format_description_log_event::Format_description_log_event(char*,...)");
   buf+= LOG_EVENT_MINIMAL_HEADER_LEN;
   if ((common_header_len=buf[ST_COMMON_HEADER_LEN_OFFSET]) < OLD_HEADER_LEN)
     DBUG_VOID_RETURN; /* sanity check */
   number_of_event_types=
-    event_len-(LOG_EVENT_MINIMAL_HEADER_LEN+ST_COMMON_HEADER_LEN_OFFSET+1);
+    event_len - (LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET + 1);
   DBUG_PRINT("info", ("common_header_len=%d number_of_event_types=%d",
                       common_header_len, number_of_event_types));
   /* If alloc fails, we'll detect it in is_valid() */
+
   post_header_len= (uint8*) my_memdup((uchar*)buf+ST_COMMON_HEADER_LEN_OFFSET+1,
                                       number_of_event_types*
-                                      sizeof(*post_header_len), MYF(0));
+                                      sizeof(*post_header_len),
+                                      MYF(0));
   calc_server_version_split();
+  if ((ver_calc= get_version_product()) >= checksum_version_product)
+  {
+    /* the last bytes are the checksum alg desc and value (or value's room) */
+    number_of_event_types -= BINLOG_CHECKSUM_ALG_DESC_LEN;
+    /*
+      FD from the checksum-home version server (ver_calc ==
+      checksum_version_product) must have 
+      number_of_event_types == LOG_EVENT_TYPES.
+    */
+    DBUG_ASSERT(ver_calc != checksum_version_product ||
+                number_of_event_types == LOG_EVENT_TYPES);
+    checksum_alg= post_header_len[number_of_event_types];
+  }
+  else
+  {
+    checksum_alg= (uint8) BINLOG_CHECKSUM_ALG_UNDEF;
+  }
 
   /*
     In some previous versions, the events were given other event type
@@ -4041,21 +4357,59 @@ Format_description_log_event(const char*
 #ifndef MYSQL_CLIENT
 bool Format_description_log_event::write(IO_CACHE* file)
 {
+  bool ret;
+  bool no_checksum;
   /*
     We don't call Start_log_event_v3::write() because this would make 2
     my_b_safe_write().
   */
-  uchar buff[FORMAT_DESCRIPTION_HEADER_LEN];
+  uchar buff[FORMAT_DESCRIPTION_HEADER_LEN + BINLOG_CHECKSUM_ALG_DESC_LEN];
+  size_t rec_size= sizeof(buff);
   int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
   memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
   if (!dont_set_created)
     created= when= get_time();
   int4store(buff + ST_CREATED_OFFSET,created);
   buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN;
-  memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (uchar*) post_header_len,
+  memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET + 1, (uchar*) post_header_len,
          LOG_EVENT_TYPES);
-  return (write_header(file, sizeof(buff)) ||
-          my_b_safe_write(file, buff, sizeof(buff)));
+  /*
+    if checksum is requested
+    record the checksum-algorithm descriptor next to
+    post_header_len vector which will be followed by the checksum value.
+    Master is supposed to trigger checksum computing by binlog_checksum_options,
+    slave does it via marking the event according to
+    FD_queue checksum_alg value.
+  */
+  compile_time_assert(sizeof(BINLOG_CHECKSUM_ALG_DESC_LEN == 1));
+#ifndef DBUG_OFF
+  data_written= 0; // to prepare for need_checksum assert
+#endif
+  buff[FORMAT_DESCRIPTION_HEADER_LEN]= need_checksum() ?
+    checksum_alg : (uint8) BINLOG_CHECKSUM_ALG_OFF;
+  /* 
+     FD of checksum-aware server is always checksum-equipped, (V) is in,
+     regardless of @@global.binlog_checksum policy.
+     Thereby a combination of (A) == 0, (V) != 0 means
+     it's the checksum-aware server's FD event that heads checksum-free binlog
+     file. 
+     Here 0 stands for checksumming OFF to evaluate (V) as 0 is that case.
+     A combination of (A) != 0, (V) != 0 denotes FD of the checksum-aware server
+     heading the checksummed binlog.
+     (A), (V) presence in FD of the checksum-aware server makes the event
+     1 + 4 bytes bigger comparing to the former FD.
+  */
+
+  if ((no_checksum= (checksum_alg == BINLOG_CHECKSUM_ALG_OFF)))
+  {
+    checksum_alg= BINLOG_CHECKSUM_ALG_CRC32;  // Forcing (V) room to fill anyway
+  }
+  ret= (write_header(file, rec_size) ||
+        wrapper_my_b_safe_write(file, buff, rec_size) ||
+        write_footer(file));
+  if (no_checksum)
+    checksum_alg= BINLOG_CHECKSUM_ALG_OFF;
+  return ret;
 }
 #endif
 
@@ -4150,6 +4504,22 @@ Format_description_log_event::do_shall_s
 
 #endif
 
+inline void do_server_version_split(char* version, uchar split_versions[3])
+{
+  char *p= version, *r;
+  ulong number;
+  for (uint i= 0; i<=2; i++)
+  {
+    number= strtoul(p, &r, 10);
+    split_versions[i]= (uchar) number;
+    DBUG_ASSERT(number < 256); // fit in uchar
+    p= r;
+    DBUG_ASSERT(!((i == 0) && (*r != '.'))); // should be true in practice
+    if (*r == '.')
+      p++; // skip the dot
+  }
+}
+
 
 /**
    Splits the event's 'server_version' string into three numeric pieces stored
@@ -4162,24 +4532,71 @@ Format_description_log_event::do_shall_s
 */
 void Format_description_log_event::calc_server_version_split()
 {
-  char *p= server_version, *r;
-  ulong number;
-  for (uint i= 0; i<=2; i++)
-  {
-    number= strtoul(p, &r, 10);
-    server_version_split[i]= (uchar)number;
-    DBUG_ASSERT(number < 256); // fit in uchar
-    p= r;
-    DBUG_ASSERT(!((i == 0) && (*r != '.'))); // should be true in practice
-    if (*r == '.')
-      p++; // skip the dot
-  }
+  do_server_version_split(server_version, server_version_split);
+
   DBUG_PRINT("info",("Format_description_log_event::server_version_split:"
                      " '%s' %d %d %d", server_version,
                      server_version_split[0],
                      server_version_split[1], server_version_split[2]));
 }
 
+inline ulong version_product(const uchar* version_split)
+{
+  return ((version_split[0] * 256 + version_split[1]) * 256
+          + version_split[2]);
+}
+
+/**
+   @return integer representing the version of server that originated
+   the current FD instance.
+*/
+ulong Format_description_log_event::get_version_product() const
+{ 
+  return version_product(server_version_split);
+}
+
+/**
+   @return TRUE is the event's version is earlier than one that introduced
+   the replication event checksum. FALSE otherwise.
+*/
+bool Format_description_log_event::is_version_before_checksum() const
+{
+  return get_version_product() < checksum_version_product;
+}
+
+/**
+   @param buf buffer holding serialized FD event
+   @param len netto (possible checksum is stripped off) length of the event buf
+   
+   @return  the version-safe checksum alg descriptor where zero
+            designates no checksum, 255 - the orginator is
+            checksum-unaware (effectively no checksum) and the actuall
+            [1-254] range alg descriptor.
+*/
+uint8 get_checksum_alg(const char* buf, ulong len)
+{
+  uint8 ret;
+  char version[ST_SERVER_VER_LEN];
+  uchar version_split[3];
+
+  DBUG_ENTER("get_checksum_alg");
+  DBUG_ASSERT(buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT);
+
+  memcpy(version, buf +
+         buf[LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET]
+         + ST_SERVER_VER_OFFSET, ST_SERVER_VER_LEN);
+  version[ST_SERVER_VER_LEN - 1]= 0;
+  
+  do_server_version_split(version, version_split);
+  ret= (version_product(version_split) < checksum_version_product) ?
+    (uint8) BINLOG_CHECKSUM_ALG_UNDEF :
+    * (uint8*) (buf + len - BINLOG_CHECKSUM_LEN - BINLOG_CHECKSUM_ALG_DESC_LEN);
+  DBUG_ASSERT(ret == BINLOG_CHECKSUM_ALG_OFF ||
+              ret == BINLOG_CHECKSUM_ALG_UNDEF ||
+              ret == BINLOG_CHECKSUM_ALG_CRC32);
+  DBUG_RETURN(ret);
+}
+  
 
   /**************************************************************************
         Load_log_event methods
@@ -5034,6 +5451,7 @@ Rotate_log_event::Rotate_log_event(const
   DBUG_PRINT("enter",("new_log_ident: %s  pos: %s  flags: %lu", new_log_ident_arg,
                       llstr(pos_arg, buff), (ulong) flags));
 #endif
+  cache_type= EVENT_NO_CACHE;
   if (flags & DUP_NAME)
     new_log_ident= my_strndup(new_log_ident_arg, ident_len, MYF(MY_WME));
   if (flags & RELAY_LOG)
@@ -5075,9 +5493,11 @@ bool Rotate_log_event::write(IO_CACHE* f
 {
   char buf[ROTATE_HEADER_LEN];
   int8store(buf + R_POS_OFFSET, pos);
-  return (write_header(file, ROTATE_HEADER_LEN + ident_len) ||
-          my_b_safe_write(file, (uchar*)buf, ROTATE_HEADER_LEN) ||
-          my_b_safe_write(file, (uchar*)new_log_ident, (uint) ident_len));
+  return (write_header(file, ROTATE_HEADER_LEN + ident_len) || 
+          wrapper_my_b_safe_write(file, (uchar*) buf, ROTATE_HEADER_LEN) ||
+          wrapper_my_b_safe_write(file, (uchar*) new_log_ident,
+                                     (uint) ident_len) ||
+          write_footer(file));
 }
 #endif
 
@@ -5251,7 +5671,8 @@ bool Intvar_log_event::write(IO_CACHE* f
   buf[I_TYPE_OFFSET]= (uchar) type;
   int8store(buf + I_VAL_OFFSET, val);
   return (write_header(file, sizeof(buf)) ||
-          my_b_safe_write(file, buf, sizeof(buf)));
+          wrapper_my_b_safe_write(file, buf, sizeof(buf)) ||
+	  write_footer(file));
 }
 #endif
 
@@ -5378,7 +5799,8 @@ bool Rand_log_event::write(IO_CACHE* fil
   int8store(buf + RAND_SEED1_OFFSET, seed1);
   int8store(buf + RAND_SEED2_OFFSET, seed2);
   return (write_header(file, sizeof(buf)) ||
-          my_b_safe_write(file, buf, sizeof(buf)));
+          wrapper_my_b_safe_write(file, buf, sizeof(buf)) ||
+	  write_footer(file));
 }
 #endif
 
@@ -5479,8 +5901,9 @@ Xid_log_event(const char* buf,
 bool Xid_log_event::write(IO_CACHE* file)
 {
   DBUG_EXECUTE_IF("do_not_write_xid", return 0;);
-  return write_header(file, sizeof(xid)) ||
-         my_b_safe_write(file, (uchar*) &xid, sizeof(xid));
+  return (write_header(file, sizeof(xid)) ||
+	  wrapper_my_b_safe_write(file, (uchar*) &xid, sizeof(xid)) ||
+	  write_footer(file));
 }
 #endif
 
@@ -5508,12 +5931,75 @@ int Xid_log_event::do_apply_event(Relay_
 {
   int error= 0;
 
+  Relay_log_info *rli_ptr= const_cast<Relay_log_info *>(rli);
+
+  /*
+    If the repository is transactional, i.e., created over a
+    transactional table, we need to update the positions within
+    the context of the current transaction in order to provide
+    data integrity. See sql/rpl_rli.h for further details.
+  */
+  bool is_trans_repo= rli_ptr->is_transactional();
+
   /* For a slave Xid_log_event is COMMIT */
   general_log_print(thd, COM_QUERY,
                     "COMMIT /* implicit, from Xid_log_event */");
+
+  if (is_trans_repo)
+  {
+    mysql_mutex_lock(&rli_ptr->data_lock);
+  }
+
+  DBUG_PRINT("info", ("do_apply group master %s %lu  group relay %s %lu event %s %lu\n",
+    rli_ptr->get_group_master_log_name(),
+    (ulong) rli_ptr->get_group_master_log_pos(),
+    rli_ptr->get_group_relay_log_name(),
+    (ulong) rli_ptr->get_group_relay_log_pos(),
+    rli_ptr->get_event_relay_log_name(),
+    (ulong) rli_ptr->get_event_relay_log_pos()));
+
+  DBUG_EXECUTE_IF("crash_before_update_pos", DBUG_SUICIDE(););
+
+  /*
+    We need to update the positions in here to make it transactional.  
+  */
+  if (is_trans_repo)
+  {
+    rli_ptr->inc_event_relay_log_pos();
+    rli_ptr->set_group_relay_log_pos(rli_ptr->get_event_relay_log_pos());
+    rli_ptr->set_group_relay_log_name(rli_ptr->get_event_relay_log_name());
+
+    rli_ptr->notify_group_relay_log_name_update();
+
+    if (log_pos) // 3.23 binlogs don't have log_posx
+    {
+      rli_ptr->set_group_master_log_pos(log_pos);
+    }
+  
+    if ((error= rli_ptr->flush_info(TRUE)))
+      goto err;
+  }
+
+  DBUG_PRINT("info", ("do_apply group master %s %lu  group relay %s %lu event %s %lu\n",
+    rli_ptr->get_group_master_log_name(),
+    (ulong) rli_ptr->get_group_master_log_pos(),
+    rli_ptr->get_group_relay_log_name(),
+    (ulong) rli_ptr->get_group_relay_log_pos(),
+    rli_ptr->get_event_relay_log_name(),
+    (ulong) rli_ptr->get_event_relay_log_pos()));
+
+  DBUG_EXECUTE_IF("crash_after_update_pos_before_apply", DBUG_SUICIDE(););
+
   error= trans_commit(thd); /* Automatically rolls back on error. */
+  DBUG_EXECUTE_IF("crash_after_apply", DBUG_SUICIDE(););
   thd->mdl_context.release_transactional_locks();
 
+err:
+  if (is_trans_repo)
+  {
+    mysql_cond_broadcast(&rli_ptr->data_cond);
+    mysql_mutex_unlock(&rli_ptr->data_lock);
+  }
   return error;
 }
 
@@ -5659,8 +6145,20 @@ User_var_log_event(const char* buf,
       we keep the flags set to UNDEF_F.
     */
     uint bytes_read= ((val + val_len) - start);
-    DBUG_ASSERT(bytes_read==data_written || 
-                bytes_read==(data_written-1));
+#ifndef DBUG_OFF
+    bool old_pre_checksum_fd= description_event->is_version_before_checksum();
+#endif
+    DBUG_ASSERT((bytes_read == data_written -
+                 (old_pre_checksum_fd ||
+                  (description_event->checksum_alg ==
+                   BINLOG_CHECKSUM_ALG_OFF)) ?
+                 0 : BINLOG_CHECKSUM_LEN)
+                ||
+                (bytes_read == data_written -1 -
+                 (old_pre_checksum_fd ||
+                  (description_event->checksum_alg ==
+                   BINLOG_CHECKSUM_ALG_OFF)) ?
+                 0 : BINLOG_CHECKSUM_LEN));
     if ((data_written - bytes_read) > 0)
     {
       flags= (uint) *(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
@@ -5728,11 +6226,12 @@ bool User_var_log_event::write(IO_CACHE*
   event_length= sizeof(buf)+ name_len + buf1_length + val_len + unsigned_len;
 
   return (write_header(file, event_length) ||
-          my_b_safe_write(file, (uchar*) buf, sizeof(buf))   ||
-          my_b_safe_write(file, (uchar*) name, name_len)     ||
-          my_b_safe_write(file, (uchar*) buf1, buf1_length) ||
-          my_b_safe_write(file, pos, val_len) ||
-          my_b_safe_write(file, &flags, unsigned_len));
+          wrapper_my_b_safe_write(file, (uchar*) buf, sizeof(buf))   ||
+	  wrapper_my_b_safe_write(file, (uchar*) name, name_len)     ||
+	  wrapper_my_b_safe_write(file, (uchar*) buf1, buf1_length) ||
+	  wrapper_my_b_safe_write(file, pos, val_len) ||
+          wrapper_my_b_safe_write(file, &flags, unsigned_len) ||
+	  write_footer(file));
 }
 #endif
 
@@ -6348,8 +6847,9 @@ bool Append_block_log_event::write(IO_CA
   uchar buf[APPEND_BLOCK_HEADER_LEN];
   int4store(buf + AB_FILE_ID_OFFSET, file_id);
   return (write_header(file, APPEND_BLOCK_HEADER_LEN + block_len) ||
-          my_b_safe_write(file, buf, APPEND_BLOCK_HEADER_LEN) ||
-	  my_b_safe_write(file, (uchar*) block, block_len));
+          wrapper_my_b_safe_write(file, buf, APPEND_BLOCK_HEADER_LEN) ||
+	  wrapper_my_b_safe_write(file, (uchar*) block, block_len) ||
+	  write_footer(file));
 }
 #endif
 
@@ -6507,7 +7007,8 @@ bool Delete_file_log_event::write(IO_CAC
  uchar buf[DELETE_FILE_HEADER_LEN];
  int4store(buf + DF_FILE_ID_OFFSET, file_id);
  return (write_header(file, sizeof(buf)) ||
-         my_b_safe_write(file, buf, sizeof(buf)));
+         wrapper_my_b_safe_write(file, buf, sizeof(buf)) ||
+	 write_footer(file));
 }
 #endif
 
@@ -6603,7 +7104,8 @@ bool Execute_load_log_event::write(IO_CA
   uchar buf[EXEC_LOAD_HEADER_LEN];
   int4store(buf + EL_FILE_ID_OFFSET, file_id);
   return (write_header(file, sizeof(buf)) || 
-          my_b_safe_write(file, buf, sizeof(buf)));
+          wrapper_my_b_safe_write(file, buf, sizeof(buf)) ||
+	  write_footer(file));
 }
 #endif
 
@@ -6663,16 +7165,17 @@ int Execute_load_log_event::do_apply_eve
                 fname);
     goto err;
   }
-  if (!(lev = (Load_log_event*)Log_event::read_log_event(&file,
-                                                         (mysql_mutex_t*)0,
-                                                         rli->relay_log.description_event_for_exec)) ||
+  if (!(lev= (Load_log_event*)
+        Log_event::read_log_event(&file,
+                                  (mysql_mutex_t*) 0,
+                                  rli->relay_log.description_event_for_exec,
+                                  opt_slave_sql_verify_checksum)) ||
       lev->get_type_code() != NEW_LOAD_EVENT)
   {
     rli->report(ERROR_LEVEL, 0, "Error in Exec_load event: "
                     "file '%s' appears corrupted", fname);
     goto err;
   }
-
   lev->thd = thd;
   /*
     lev->do_apply_event should use rli only for errors i.e. should
@@ -6834,7 +7337,7 @@ Execute_load_query_log_event::write_post
   int4store(buf + 4, fn_pos_start);
   int4store(buf + 4 + 4, fn_pos_end);
   *(buf + 4 + 4 + 4)= (uchar) dup_handling;
-  return my_b_safe_write(file, buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
+  return wrapper_my_b_safe_write(file, buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
 }
 #endif
 
@@ -7811,11 +8314,11 @@ bool Rows_log_event::write_data_header(I
                   {
                     int4store(buf + 0, m_table_id);
                     int2store(buf + 4, m_flags);
-                    return (my_b_safe_write(file, buf, 6));
+                    return (wrapper_my_b_safe_write(file, buf, 6));
                   });
   int6store(buf + RW_MAPID_OFFSET, (ulonglong)m_table_id);
   int2store(buf + RW_FLAGS_OFFSET, m_flags);
-  return (my_b_safe_write(file, buf, ROWS_HEADER_LEN));
+  return (wrapper_my_b_safe_write(file, buf, ROWS_HEADER_LEN));
 }
 
 bool Rows_log_event::write_data_body(IO_CACHE*file)
@@ -7831,10 +8334,10 @@ bool Rows_log_event::write_data_body(IO_
   DBUG_ASSERT(static_cast<size_t>(sbuf_end - sbuf) <= sizeof(sbuf));
 
   DBUG_DUMP("m_width", sbuf, (size_t) (sbuf_end - sbuf));
-  res= res || my_b_safe_write(file, sbuf, (size_t) (sbuf_end - sbuf));
+  res= res || wrapper_my_b_safe_write(file, sbuf, (size_t) (sbuf_end - sbuf));
 
   DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols));
-  res= res || my_b_safe_write(file, (uchar*) m_cols.bitmap,
+  res= res || wrapper_my_b_safe_write(file, (uchar*) m_cols.bitmap,
                               no_bytes_in_map(&m_cols));
   /*
     TODO[refactor write]: Remove the "down cast" here (and elsewhere).
@@ -7843,11 +8346,11 @@ bool Rows_log_event::write_data_body(IO_
   {
     DBUG_DUMP("m_cols_ai", (uchar*) m_cols_ai.bitmap,
               no_bytes_in_map(&m_cols_ai));
-    res= res || my_b_safe_write(file, (uchar*) m_cols_ai.bitmap,
+    res= res || wrapper_my_b_safe_write(file, (uchar*) m_cols_ai.bitmap,
                                 no_bytes_in_map(&m_cols_ai));
   }
   DBUG_DUMP("rows", m_rows_buf, data_size);
-  res= res || my_b_safe_write(file, m_rows_buf, (size_t) data_size);
+  res= res || wrapper_my_b_safe_write(file, m_rows_buf, (size_t) data_size);
 
   return res;
 
@@ -8279,11 +8782,11 @@ bool Table_map_log_event::write_data_hea
                   {
                     int4store(buf + 0, m_table_id);
                     int2store(buf + 4, m_flags);
-                    return (my_b_safe_write(file, buf, 6));
+                    return (wrapper_my_b_safe_write(file, buf, 6));
                   });
   int6store(buf + TM_MAPID_OFFSET, (ulonglong)m_table_id);
   int2store(buf + TM_FLAGS_OFFSET, m_flags);
-  return (my_b_safe_write(file, buf, TABLE_MAP_HEADER_LEN));
+  return (wrapper_my_b_safe_write(file, buf, TABLE_MAP_HEADER_LEN));
 }
 
 bool Table_map_log_event::write_data_body(IO_CACHE *file)
@@ -8307,15 +8810,15 @@ bool Table_map_log_event::write_data_bod
   uchar mbuf[sizeof(m_field_metadata_size)];
   uchar *const mbuf_end= net_store_length(mbuf, m_field_metadata_size);
 
-  return (my_b_safe_write(file, dbuf,      sizeof(dbuf)) ||
-          my_b_safe_write(file, (const uchar*)m_dbnam,   m_dblen+1) ||
-          my_b_safe_write(file, tbuf,      sizeof(tbuf)) ||
-          my_b_safe_write(file, (const uchar*)m_tblnam,  m_tbllen+1) ||
-          my_b_safe_write(file, cbuf, (size_t) (cbuf_end - cbuf)) ||
-          my_b_safe_write(file, m_coltype, m_colcnt) ||
-          my_b_safe_write(file, mbuf, (size_t) (mbuf_end - mbuf)) ||
-          my_b_safe_write(file, m_field_metadata, m_field_metadata_size),
-          my_b_safe_write(file, m_null_bits, (m_colcnt + 7) / 8));
+  return (wrapper_my_b_safe_write(file, dbuf,      sizeof(dbuf)) ||
+          wrapper_my_b_safe_write(file, (const uchar*)m_dbnam,   m_dblen+1) ||
+          wrapper_my_b_safe_write(file, tbuf,      sizeof(tbuf)) ||
+          wrapper_my_b_safe_write(file, (const uchar*)m_tblnam,  m_tbllen+1) ||
+          wrapper_my_b_safe_write(file, cbuf, (size_t) (cbuf_end - cbuf)) ||
+          wrapper_my_b_safe_write(file, m_coltype, m_colcnt) ||
+          wrapper_my_b_safe_write(file, mbuf, (size_t) (mbuf_end - mbuf)) ||
+          wrapper_my_b_safe_write(file, m_field_metadata, m_field_metadata_size),
+          wrapper_my_b_safe_write(file, m_null_bits, (m_colcnt + 7) / 8));
  }
 #endif
 
@@ -9860,13 +10363,25 @@ Incident_log_event::write_data_header(IO
   DBUG_PRINT("enter", ("m_incident: %d", m_incident));
   uchar buf[sizeof(int16)];
   int2store(buf, (int16) m_incident);
-  DBUG_RETURN(my_b_safe_write(file, buf, sizeof(buf)));
+#ifndef MYSQL_CLIENT
+  DBUG_RETURN(wrapper_my_b_safe_write(file, buf, sizeof(buf)));
+#else
+   DBUG_RETURN(my_b_safe_write(file, buf, sizeof(buf)));
+#endif
 }
 
 bool
 Incident_log_event::write_data_body(IO_CACHE *file)
 {
+  uchar tmp[1];
   DBUG_ENTER("Incident_log_event::write_data_body");
+  tmp[0]= (uchar) m_message.length;
+  crc= my_checksum(crc, (uchar*) tmp, 1);
+  if (m_message.length > 0)
+  {
+    crc= my_checksum(crc, (uchar*) m_message.str, m_message.length);
+    // todo: report a bug on write_str accepts uint but treats it as uchar
+  }
   DBUG_RETURN(write_str(file, m_message.str, (uint) m_message.length));
 }
 

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2010-11-08 02:49:16 +0000
+++ b/sql/log_event.h	2010-11-16 12:14:06 +0000
@@ -77,6 +77,7 @@ class String;
 #define LOG_READ_MEM    -5
 #define LOG_READ_TRUNC  -6
 #define LOG_READ_TOO_LARGE -7
+#define LOG_READ_CHECKSUM_FAILURE -8
 
 #define LOG_EVENT_OFFSET 4
 
@@ -541,6 +542,22 @@ struct sql_ex_info
 #endif
 #undef EXPECTED_OPTIONS         /* You shouldn't use this one */
 
+enum enum_binlog_checksum_alg {
+  BINLOG_CHECKSUM_ALG_OFF= 0,    // Events are without checksum though its generator
+                                 // is checksum-capable New Master (NM).
+  BINLOG_CHECKSUM_ALG_CRC32= 1,  // CRC32 of zlib algorithm.
+  BINLOG_CHECKSUM_ALG_ENUM_END,  // the cut line: valid alg range is [1, 0x7f].
+  BINLOG_CHECKSUM_ALG_UNDEF= 255 // special value to tag undetermined yet checksum
+                                 // or events from checksum-unaware servers
+};
+
+#define CHECKSUM_CRC32_SIGNATURE_LEN 4
+/**
+   defined statically while there is just one alg implemented
+*/
+#define BINLOG_CHECKSUM_LEN CHECKSUM_CRC32_SIGNATURE_LEN
+#define BINLOG_CHECKSUM_ALG_DESC_LEN 1  /* 1 byte checksum alg descriptor */
+
 /**
   @enum Log_event_type
 
@@ -990,6 +1007,10 @@ public:
   */
   ulong slave_exec_mode;
 
+  /**
+    Placeholder for event checksum while writing to binlog.
+   */
+  ha_checksum crc;
 #ifdef MYSQL_SERVER
   THD* thd;
 
@@ -1009,9 +1030,10 @@ public:
   static Log_event* read_log_event(IO_CACHE* file,
                                    mysql_mutex_t* log_lock,
                                    const Format_description_log_event
-                                   *description_event);
+                                   *description_event,
+                                   my_bool crc_check);
   static int read_log_event(IO_CACHE* file, String* packet,
-                            mysql_mutex_t* log_lock);
+                            mysql_mutex_t* log_lock, uint8 checksum_alg_arg);
   /*
     init_show_field_list() prepares the column names and types for the
     output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG
@@ -1038,7 +1060,7 @@ public:
     /* avoid having to link mysqlbinlog against libpthread */
   static Log_event* read_log_event(IO_CACHE* file,
                                    const Format_description_log_event
-                                   *description_event);
+                                   *description_event, my_bool crc_check);
   /* print*() functions are used by mysqlbinlog */
   virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0;
   void print_timestamp(IO_CACHE* file, time_t *ts = 0);
@@ -1047,6 +1069,15 @@ public:
   void print_base64(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
                     bool is_more);
 #endif
+  /* 
+     The value is set by caller of FD constructor and
+     Log_event::write_header() for the rest.
+     In the FD case it's propagated into the last byte 
+     of post_header_len[] at FD::write().
+     On the slave side the value is assigned from post_header_len[last] 
+     of the last seen FD event.
+  */
+  uint8 checksum_alg;
 
   static void *operator new(size_t size)
   {
@@ -1061,14 +1092,19 @@ public:
   /* Placement version of the above operators */
   static void *operator new(size_t, void* ptr) { return ptr; }
   static void operator delete(void*, void*) { }
+  bool wrapper_my_b_safe_write(IO_CACHE* file, const uchar* buf, ulong data_length);
 
 #ifdef MYSQL_SERVER
   bool write_header(IO_CACHE* file, ulong data_length);
+  bool write_footer(IO_CACHE* file);
+  my_bool need_checksum();
+
   virtual bool write(IO_CACHE* file)
   {
-    return (write_header(file, get_data_size()) ||
-            write_data_header(file) ||
-            write_data_body(file));
+    return(write_header(file, get_data_size()) ||
+	   write_data_header(file) ||
+	   write_data_body(file) ||
+	   write_footer(file));
   }
   virtual bool write_data_header(IO_CACHE* file)
   { return 0; }
@@ -1125,7 +1161,7 @@ public:
   static Log_event* read_log_event(const char* buf, uint event_len,
 				   const char **error,
                                    const Format_description_log_event
-                                   *description_event);
+                                   *description_event, my_bool crc_check);
   /**
     Returns the human readable name of the given event type.
   */
@@ -2227,7 +2263,10 @@ public:
   */
   uint8 common_header_len;
   uint8 number_of_event_types;
-  /* The list of post-headers' lengthes */
+  /* 
+     The list of post-headers' lengths followed 
+     by the checksum alg decription byte
+  */
   uint8 *post_header_len;
   uchar server_version_split[3];
   const uint8 *event_type_permutation;
@@ -2261,7 +2300,8 @@ public:
   }
 
   void calc_server_version_split();
-
+  ulong get_version_product() const;
+  bool is_version_before_checksum() const;
 protected:
 #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
@@ -2316,9 +2356,10 @@ public:
   uchar type;
 
 #ifdef MYSQL_SERVER
-  Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
-    :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
-  {}
+  Intvar_log_event(THD* thd_arg, uchar type_arg, ulonglong val_arg,
+                   uint16 cache_type_arg)
+    :Log_event(thd_arg, 0, 0), val(val_arg), type(type_arg)
+  { cache_type= cache_type_arg; }
 #ifdef HAVE_REPLICATION
   void pack_info(Protocol* protocol);
 #endif /* HAVE_REPLICATION */
@@ -2392,9 +2433,10 @@ class Rand_log_event: public Log_event
   ulonglong seed2;
 
 #ifdef MYSQL_SERVER
-  Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg)
-    :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
-  {}
+  Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg,
+                 uint16 cache_type_arg)
+    :Log_event(thd_arg, 0, 0), seed1(seed1_arg), seed2(seed2_arg)
+    { cache_type= cache_type_arg; }
 #ifdef HAVE_REPLICATION
   void pack_info(Protocol* protocol);
 #endif /* HAVE_REPLICATION */
@@ -2438,7 +2480,8 @@ class Xid_log_event: public Log_event
    my_xid xid;
 
 #ifdef MYSQL_SERVER
-  Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
+  Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg, 0, 0), xid(x)
+  { cache_type= EVENT_NO_CACHE; }
 #ifdef HAVE_REPLICATION
   void pack_info(Protocol* protocol);
 #endif /* HAVE_REPLICATION */
@@ -2490,11 +2533,12 @@ public:
 #ifdef MYSQL_SERVER
   User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg,
                      char *val_arg, ulong val_len_arg, Item_result type_arg,
-		     uint charset_number_arg, uchar flags_arg)
-    :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
-    val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg),
-    flags(flags_arg)
-    { is_null= !val; }
+		     uint charset_number_arg, uchar flags_arg,
+                     uint16 cache_type_arg)
+    :Log_event(thd_arg, 0, 0), name(name_arg), name_len(name_len_arg), val(val_arg),
+     val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg),
+     flags(flags_arg)
+    { is_null= !val; cache_type= cache_type_arg; }
   void pack_info(Protocol* protocol);
 #else
   void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@@ -4154,6 +4198,10 @@ int append_query_string(CHARSET_INFO *cs
 bool sqlcom_can_generate_row_events(const THD *thd);
 void handle_rows_query_log_event(Log_event *ev, Relay_log_info *rli);
 
+bool event_checksum_test(uchar *buf, ulong event_len, uint8 alg);
+uint8 get_checksum_alg(const char* buf, ulong len);
+extern TYPELIB binlog_checksum_typelib;
+
 /**
   @} (end of group Replication)
 */

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-11-09 20:10:44 +0000
+++ b/sql/mysqld.cc	2010-11-16 12:14:06 +0000
@@ -434,6 +434,10 @@ my_bool opt_noacl;
 my_bool sp_automatic_privileges= 1;
 
 ulong opt_binlog_rows_event_max_size;
+const char *binlog_checksum_default= "NONE";
+ulong binlog_checksum_options;
+my_bool opt_master_verify_checksum= 0;
+my_bool opt_slave_sql_verify_checksum= 1;
 const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
 #ifdef HAVE_INITGROUPS
 static bool calling_initgroups= FALSE; /**< Used in SIGSEGV handler. */
@@ -4564,6 +4568,7 @@ int mysqld_main(int argc, char **argv)
 
 #ifndef DBUG_OFF
   test_lc_time_sz();
+  srand(time(NULL)); 
 #endif
 
   /*

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2010-11-08 14:35:45 +0000
+++ b/sql/mysqld.h	2010-11-16 12:14:06 +0000
@@ -180,6 +180,10 @@ extern ulong binlog_cache_size, open_fil
 extern ulonglong max_binlog_cache_size;
 extern ulong max_binlog_size, max_relay_log_size;
 extern ulong opt_binlog_rows_event_max_size;
+extern ulong binlog_checksum_options;
+extern const char *binlog_checksum_type_names[];
+extern my_bool opt_master_verify_checksum;
+extern my_bool opt_slave_sql_verify_checksum;
 extern ulong thread_cache_size;
 extern ulong back_log;
 extern char language[FN_REFLEN];
@@ -355,6 +359,7 @@ enum options_mysqld
 {
   OPT_to_set_the_start_number=256,
   OPT_BIND_ADDRESS,
+  OPT_BINLOG_CHECKSUM,
   OPT_BINLOG_DO_DB,
   OPT_BINLOG_FORMAT,
   OPT_BINLOG_IGNORE_DB,
@@ -371,6 +376,7 @@ enum options_mysqld
   OPT_LC_MESSAGES_DIRECTORY,
   OPT_LOWER_CASE_TABLE_NAMES,
   OPT_MASTER_RETRY_COUNT,
+  OPT_MASTER_VERIFY_CHECKSUM,
   OPT_POOL_OF_THREADS,
   OPT_REPLICATE_DO_DB,
   OPT_REPLICATE_DO_TABLE,
@@ -387,6 +393,7 @@ enum options_mysqld
   OPT_SKIP_RESOLVE,
   OPT_SKIP_STACK_TRACE,
   OPT_SKIP_SYMLINKS,
+  OPT_SLAVE_SQL_VERIFY_CHECKSUM,
   OPT_SSL_CA,
   OPT_SSL_CAPATH,
   OPT_SSL_CERT,

=== modified file 'sql/rpl_info.h'
--- a/sql/rpl_info.h	2010-10-08 14:23:55 +0000
+++ b/sql/rpl_info.h	2010-10-25 10:39:01 +0000
@@ -64,9 +64,9 @@ public:
     return (handler->check_info());
   }
 
-  int reset_info()
+  int remove_info()
   {
-    return (handler->reset_info());
+    return (handler->remove_info());
   }
 
   bool is_transactional()

=== modified file 'sql/rpl_info_factory.cc'
--- a/sql/rpl_info_factory.cc	2010-10-08 16:11:32 +0000
+++ b/sql/rpl_info_factory.cc	2010-10-29 18:16:48 +0000
@@ -17,9 +17,13 @@
 #include "sql_priv.h"
 #include "rpl_slave.h"
 #include "rpl_info_factory.h"
-#include "rpl_info_file.h"
-#include "rpl_mi.h"
-#include "rpl_rli.h"
+
+/*
+  We need to replace these definitions by an option that states the
+  engine one wants to use in the master info repository.
+*/
+#define master_info_engine NULL
+#define relay_log_info_engine NULL
 
 /**
   Creates both a Master info and a Relay log info repository whose types are
@@ -38,22 +42,16 @@
 bool Rpl_info_factory::create(uint mi_option, Master_info **mi,
                               uint rli_option, Relay_log_info **rli)
 {
-  bool error= FALSE;
-
   DBUG_ENTER("Rpl_info_factory::Rpl_info_factory");
 
-  if ((error= Rpl_info_factory::create_mi(mi_option, mi)))
-  {
-    *mi= NULL;
-    DBUG_RETURN(error);
-  }
+  if (!((*mi)= Rpl_info_factory::create_mi(mi_option)))
+    DBUG_RETURN(TRUE);
     
-  if ((error= Rpl_info_factory::create_rli(rli_option, relay_log_recovery,
-                                           rli)))
+  if (!((*rli)= Rpl_info_factory::create_rli(rli_option, relay_log_recovery)))
   {
     delete *mi;
     *mi= NULL;
-    DBUG_RETURN(error);
+    DBUG_RETURN(TRUE);
   }
 
   /*
@@ -62,7 +60,7 @@ bool Rpl_info_factory::create(uint mi_op
   (*mi)->set_relay_log_info(*rli);
   (*rli)->set_master_info(*mi);
 
-  DBUG_RETURN(error); 
+  DBUG_RETURN(FALSE); 
 }
 
 /**
@@ -79,19 +77,21 @@ bool Rpl_info_factory::create(uint mi_op
   @retval FALSE No error
   @retval TRUE  Failure
 */ 
-bool Rpl_info_factory::create_mi(uint mi_option, Master_info **mi)
+Master_info *Rpl_info_factory::create_mi(uint mi_option)
 {
-  bool error= TRUE;
+  Master_info* mi= NULL;
   Rpl_info_file*  mi_file= NULL;
+  Rpl_info_table*  mi_table= NULL;
   const char *msg= "Failed to allocate memory for the master info "
                    "structure";
 
   DBUG_ENTER("Rpl_info_factory::Rpl_info_factory");
 
-  *mi= new Master_info(&key_master_info_run_lock, &key_master_info_data_lock,
-                       &key_master_info_data_cond, &key_master_info_start_cond,
-                       &key_master_info_stop_cond);
-  if (!(*mi))
+  if (!(mi= new Master_info(&key_master_info_run_lock,
+                            &key_master_info_data_lock,
+                            &key_master_info_data_cond,
+                            &key_master_info_start_cond,
+                            &key_master_info_stop_cond)))
     goto err;
 
   /*
@@ -99,23 +99,42 @@ bool Rpl_info_factory::create_mi(uint mi
     but not without first checking if there is already existing data for
     a repo different from the one that is being requested.
   */
-  mi_file= new Rpl_info_file((*mi)->get_number_info_mi_fields(),
-                             master_info_file);
-  if (!mi_file)
+  if (!(mi_file= new Rpl_info_file(mi->get_number_info_mi_fields(),
+                                   master_info_file)))
     goto err;
 
-  DBUG_ASSERT(mi_option == MI_REPOSITORY_FILE); 
+  if (!(mi_table= new Rpl_info_table(mi->get_number_info_mi_fields() + 1,
+                                     MI_FIELD_ID, MI_SCHEMA, MI_TABLE)))
+    goto err;
 
-  (*mi)->set_rpl_info_handler(mi_file);
-  error= FALSE;
+  DBUG_ASSERT(mi_option == MI_REPOSITORY_FILE ||
+              mi_option == MI_REPOSITORY_TABLE);
 
-  DBUG_RETURN(error);
+  if (decide_repository(mi, &mi_table, &mi_file,
+                        mi_option == MI_REPOSITORY_TABLE, &msg))
+    goto err;
+
+  if ((mi_option == MI_REPOSITORY_TABLE) &&
+       change_engine(static_cast<Rpl_info_table *>(mi_table),
+                     master_info_engine, &msg))
+    goto err;
+
+  DBUG_RETURN(mi);
 
 err:
-  if (*mi) delete (*mi);
   if (mi_file) delete mi_file;
+  if (mi_table) delete mi_table;
+  if (mi)
+  {
+    /*
+      The handler was previously deleted so we need to remove
+      any reference to it.  
+    */
+    mi->set_rpl_info_handler(NULL);
+    delete (mi);
+  }
   sql_print_error("%s", msg);
-  DBUG_RETURN(error);
+  DBUG_RETURN(NULL);
 }
 
 /**
@@ -134,24 +153,22 @@ err:
   @retval FALSE No error
   @retval TRUE  Failure
 */ 
-bool Rpl_info_factory::create_rli(uint rli_option, bool is_slave_recovery,
-                                  Relay_log_info **rli)
+Relay_log_info *Rpl_info_factory::create_rli(uint rli_option, bool is_slave_recovery)
 {
-  bool error= TRUE;
+  Relay_log_info *rli= NULL;
   Rpl_info_file* rli_file= NULL;
+  Rpl_info_table* rli_table= NULL;
   const char *msg= "Failed to allocate memory for the relay log info "
                    "structure";
 
   DBUG_ENTER("Rpl_info_factory::create_rli");
 
-  (*rli)=
-    new Relay_log_info(
-      is_slave_recovery,
-      &key_relay_log_info_run_lock, &key_relay_log_info_data_lock,
-      &key_relay_log_info_data_cond, &key_relay_log_info_start_cond,
-      &key_relay_log_info_stop_cond);
-
-  if (!(*rli))
+  if (!(rli= new Relay_log_info(is_slave_recovery,
+                                &key_relay_log_info_run_lock,
+                                &key_relay_log_info_data_lock,
+                                &key_relay_log_info_data_cond,
+                                &key_relay_log_info_start_cond,
+                                &key_relay_log_info_stop_cond)))
     goto err;
 
   /*
@@ -159,21 +176,174 @@ bool Rpl_info_factory::create_rli(uint r
     but not without first checking if there is already existing data for
     a repo different from the one that is being requested.
   */
-  rli_file= new Rpl_info_file((*rli)->get_number_info_rli_fields(),
-                              relay_log_info_file);
-  if (!rli_file)
+  if (!(rli_file= new Rpl_info_file(rli->get_number_info_rli_fields(),
+                                    relay_log_info_file)))
+    goto err;
+
+  if (!(rli_table= new Rpl_info_table(rli->get_number_info_rli_fields() + 1,
+                                      RLI_FIELD_ID, RLI_SCHEMA, RLI_TABLE)))
     goto err;
 
-  DBUG_ASSERT(rli_option == RLI_REPOSITORY_FILE);
+  DBUG_ASSERT(rli_option == RLI_REPOSITORY_FILE ||
+              rli_option == RLI_REPOSITORY_TABLE);
+
+  if (decide_repository(rli, &rli_table, &rli_file,
+                        rli_option == RLI_REPOSITORY_TABLE, &msg))
+    goto err;
 
-  (*rli)->set_rpl_info_handler(rli_file);
-  error= FALSE; 
+  if ((rli_option == RLI_REPOSITORY_TABLE) &&
+      change_engine(static_cast<Rpl_info_table *>(rli_table),
+                    relay_log_info_engine, &msg))
+    goto err;
 
-  DBUG_RETURN(error);
+  DBUG_RETURN(rli);
 
 err:
-  if (*rli) delete (*rli);
   if (rli_file) delete rli_file;
+  if (rli_table) delete rli_table;
+  if (rli) 
+  {
+    /*
+      The handler was previously deleted so we need to remove
+      any reference to it.  
+    */
+    rli->set_rpl_info_handler(NULL);
+    delete (rli);
+  }
   sql_print_error("%s", msg);
-  DBUG_RETURN(error);
+  DBUG_RETURN(NULL);
+}
+
+/**
+  Decides what repository will be used based on the following decision table:
+
+  \code
+  |--------------+-----------------------+-----------------------|
+  | Exists \ Opt |         TABLE         |          FILE         |
+  |--------------+-----------------------+-----------------------|
+  | ~is_t,  is_f | Update T and delete F | Read F                |
+  |  is_t,  is_f | ERROR                 | ERROR                 |
+  | ~is_t, ~is_f | Fill in T             | Create and Fill in F  |
+  |  is_t, ~is_f | Read T                | Update F and delete T |
+  |--------------+-----------------------+-----------------------|
+  \endcode
+
+  <ul>
+    \li F     --> file
+
+    \li T     --> table
+
+    \li is_t  --> table with data
+
+    \li is_f  --> file with data
+
+    \li ~is_t --> no data in the table
+
+    \li ~is_f --> no file
+  </ul> 
+
+  @param[in] info     Either master info or relay log info.
+  @param[in] table    Table handler.
+  @param[in] file     File handler.
+  @param[in] is_table True if a table handler was requested.
+  @param[out] msg     Message specifying what went wrong, if there is any error.
+
+  @retval FALSE No error
+  @retval TRUE  Failure
+*/
+bool Rpl_info_factory::decide_repository(Rpl_info *info, Rpl_info_table **table,
+                                         Rpl_info_file **file, bool is_table,
+                                         const char **msg)
+{
+
+  DBUG_ENTER("Rpl_info_factory::decide_repository");
+ 
+  bool error= TRUE;
+  bool is_t= !((*table)->check_info());
+  bool is_f= !((*file)->check_info());
+
+  if (is_t && is_f)
+  {
+    *msg= "Multiple replication metadata repository instances "
+          "found with data in them. Unable to decide which is "
+          "the correct one to choose.";
+    DBUG_RETURN(error);
+  }
+
+  if (is_table)
+  {
+    if (!is_t && is_f)
+    {
+      if ((*table)->init_info() || (*file)->init_info())
+      {
+        *msg= "Error transfering information from a file to a table.";
+        goto err;
+      }
+      /*
+        Transfer the information from the file to the table and delete the
+        file, i.e. Update the table (T) and delete the file (F).
+      */
+      if (info->copy_info(*file, *table) || (*file)->remove_info())
+      {
+        *msg= "Error transfering information from a file to a table.";
+        goto err;
+      }
+    }
+    delete (*file);
+    info->set_rpl_info_handler(*table);
+    error= FALSE;
+    *file= NULL;
+  }
+  else
+  {
+    if (is_t && !is_f)
+    {
+      if ((*table)->init_info() || (*file)->init_info())
+      {
+        *msg= "Error transfering information from a file to a table.";
+        goto err;
+      }
+      /*
+        Transfer the information from the table to the file and delete 
+        entries in the table, i.e. Update the file (F) and delete the
+        table (T).
+      */
+      if (info->copy_info(*table, *file) || (*table)->remove_info())
+      {
+        *msg= "Error transfering information from a table to a file.";
+        goto err;
+      } 
+    }
+    delete (*table);
+    info->set_rpl_info_handler(*file);
+    error= FALSE;
+    *table= NULL;
+  }
+
+err:
+  DBUG_RETURN(error); 
+}
+
+/**
+  Changes the engine in use by a handler.
+  
+  @param[in]  handler Reference to a handler.
+  @param[in]  engine  Type of the engine, e.g. Innodb, MyIsam.
+  @param[out] msg     Message specifying what went wrong, if there is any error.
+
+  @retval FALSE No error
+  @retval TRUE  Failure
+*/
+bool Rpl_info_factory::change_engine(Rpl_info_table *table, const char *engine,
+                                     const char **msg)
+{
+  DBUG_ENTER("Rpl_info_factory::decide_engine");
+
+  if (engine && table->change_engine(engine))
+  {
+    *msg= "Error changing the engine for a respository.";
+    DBUG_RETURN(TRUE);
+  }
+
+  DBUG_RETURN(FALSE);
 }

=== modified file 'sql/rpl_info_factory.h'
--- a/sql/rpl_info_factory.h	2010-10-08 16:11:32 +0000
+++ b/sql/rpl_info_factory.h	2010-10-25 10:39:01 +0000
@@ -19,31 +19,46 @@
 #include "rpl_info.h"
 #include "rpl_mi.h"
 #include "rpl_rli.h"
+#include "rpl_info_file.h"
+#include "rpl_info_table.h"
 #include "rpl_info_handler.h"
 
 enum enum_mi_repository
 {
-  MI_REPOSITORY_FILE= 0
+  MI_REPOSITORY_FILE= 0,
+  MI_REPOSITORY_TABLE= 1
 };
 extern ulong opt_mi_repository_id;
 
 enum enum_rli_repository
 {
-  RLI_REPOSITORY_FILE= 0
+  RLI_REPOSITORY_FILE= 0,
+  RLI_REPOSITORY_TABLE= 1
 };
 extern ulong opt_rli_repository_id;
 
+#define MI_FIELD_ID 0
+
+#define MI_SCHEMA "mysql"
+#define MI_TABLE  "slave_master_info"
+
+#define RLI_FIELD_ID 0
+
+#define RLI_SCHEMA "mysql"
+#define RLI_TABLE  "slave_relay_log_info"
+
 class Rpl_info_factory
 {
   public:
 
-  bool static create(uint mi_option, Master_info **mi,
+  static bool create(uint mi_option, Master_info **mi,
                      uint rli_option, Relay_log_info **rli);
-  bool static create_mi(uint rli_option, Master_info **rli);
-  bool static create_rli(uint rli_option, bool is_slave_recovery,
-                         Relay_log_info **rli);
-  bool static decide_repository(Rpl_info *info, Rpl_info_handler *table,
-                                Rpl_info_handler *file, bool is_table,
+  static Master_info *create_mi(uint rli_option);
+  static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery);
+  static bool decide_repository(Rpl_info *info, Rpl_info_table **table,
+                                Rpl_info_file **file, bool is_table,
                                 const char **msg);
+  static bool change_engine(Rpl_info_table *table, const char *engine,
+                            const char **msg);
 };
 #endif

=== modified file 'sql/rpl_info_file.cc'
--- a/sql/rpl_info_file.cc	2010-09-13 23:30:43 +0000
+++ b/sql/rpl_info_file.cc	2010-10-29 09:07:21 +0000
@@ -25,7 +25,8 @@ int init_strvar_from_file(char *var, int
                           const char *default_val);
 int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
 int init_floatvar_from_file(float* var, IO_CACHE* f, float default_val);
-bool init_dynarray_intvar_from_file(char *buffer, char **buffer_act, IO_CACHE* f);
+bool init_dynarray_intvar_from_file(char *buffer, size_t size, 
+                                    char **buffer_act, IO_CACHE* f);
 
 Rpl_info_file::Rpl_info_file(const int nparam, const char* param_info_fname)
   :Rpl_info_handler(nparam), info_fd(-1)
@@ -158,12 +159,12 @@ void Rpl_info_file::do_end_info()
   DBUG_VOID_RETURN;
 }
 
-int Rpl_info_file::do_reset_info()
+int Rpl_info_file::do_remove_info()
 {
   MY_STAT stat_area;
   int error= 0;
 
-  DBUG_ENTER("Rpl_info_file::do_reset_info");
+  DBUG_ENTER("Rpl_info_file::do_remove_info");
 
   if (my_stat(info_fname, &stat_area, MYF(0)) && my_delete(info_fname, MYF(MY_WME)))
     error= 1;
@@ -213,23 +214,17 @@ bool Rpl_info_file::do_set_info(const in
 bool Rpl_info_file::do_set_info(const int pos, const Server_ids *value)
 {
   bool error= TRUE;
-  char *server_ids_buffer= (char*) my_malloc((sizeof(::server_id) * 3 + 1) *
-                                   (1 + value->server_ids.elements), MYF(0));
-
-  if (server_ids_buffer == NULL)
-    return error;
+  String buffer;
 
   /*
     This produces a line listing the total number and all the server_ids.
   */
-  if (const_cast<Server_ids *>(value)->pack_server_ids(server_ids_buffer))
+  if (const_cast<Server_ids *>(value)->pack_server_ids(&buffer))
     goto err;
 
-  error= (my_b_printf(&info_file, "%s\n", server_ids_buffer) >
+  error= (my_b_printf(&info_file, "%s\n", buffer.c_ptr_safe()) >
           (size_t) 0 ? FALSE : TRUE);
-
 err:
-  my_free(server_ids_buffer);
   return error;
 }
 
@@ -268,11 +263,12 @@ bool Rpl_info_file::do_get_info(const in
     Static buffer to use most of the times. However, if it is not big
     enough to accommodate the server ids, a new buffer is allocated.
   */
-  const int array_size= 16 * (sizeof(long) * 4 + 1);
+  const int array_size= 16 * (sizeof(long) * 3 + 1);
   char buffer[array_size];
   char *buffer_act= buffer;
 
-  bool error= init_dynarray_intvar_from_file(buffer, &buffer_act,
+  bool error= init_dynarray_intvar_from_file(buffer, sizeof(buffer),
+                                             &buffer_act,
                                              &info_file);
   if (!error)
     value->unpack_server_ids(buffer_act);
@@ -409,6 +405,9 @@ int init_floatvar_from_file(float* var,
 }
 
 /**
+   TODO - Improve this function to use String and avoid this weird computation
+   to calculate the size of the buffers.
+
    Particularly, this function is responsible for restoring IGNORE_SERVER_IDS
    list of servers whose events the slave is going to ignore (to not log them
    in the relay log).
@@ -417,41 +416,43 @@ int init_floatvar_from_file(float* var,
    shorter or equal of @c long and separated by the single space.
 
    @param  buffer      Put the read values in this static buffer
+   @param  buffer      Size of the static buffer
    @param  buffer_act  Points to the final buffer as dynamic buffer may
                        be used if the static buffer is not big enough.
 
    @retval 0           All OK
    @retval non-zero  An error
 */
-bool init_dynarray_intvar_from_file(char *buffer, char **buffer_act, IO_CACHE* f)
+bool init_dynarray_intvar_from_file(char *buffer, size_t size,
+                                    char **buffer_act, IO_CACHE* f)
 {
   char *buf= buffer; // actual buffer can be dynamic if static is short
   char *buf_act= buffer;
   char *last;
-  uint num_items;     // number of items of `arr'
+  uint num_items;   // number of items of `arr'
   size_t read_size;
 
   DBUG_ENTER("init_dynarray_intvar_from_file");
 
-  if ((read_size= my_b_gets(f, buf_act, sizeof(buf))) == 0)
+  if ((read_size= my_b_gets(f, buf_act, size)) == 0)
   {
     DBUG_RETURN(FALSE); // no line in master.info
   }
-  if (read_size + 1 == sizeof(buf) && buf[sizeof(buf) - 2] != '\n')
+  if (read_size + 1 == size && buf[size - 2] != '\n')
   {
     /*
       short read happend; allocate sufficient memory and make the 2nd read
     */
-    char buf_work[(sizeof(long)*3 + 1)*16];
+    char buf_work[(sizeof(long) * 3 + 1) * 16];
     memcpy(buf_work, buf, sizeof(buf_work));
     num_items= atoi(strtok_r(buf_work, " ", &last));
     size_t snd_size;
     /*
-      max size lower bound approximate estimation bases on the formula:
+      max size upper bound approximate estimation bases on the formula:
       (the items number + items themselves) * 
           (decimal size + space) - 1 + `\n' + '\0'
     */
-    size_t max_size= (1 + num_items) * (sizeof(long)*3 + 1) + 1;
+    size_t max_size= (1 + num_items) * (sizeof(long) * 3 + 1) + 1;
     buf_act= (char*) my_malloc(max_size, MYF(MY_WME));
     buffer_act= &buf_act;
     memcpy(buf_act, buf, read_size);

=== modified file 'sql/rpl_info_file.h'
--- a/sql/rpl_info_file.h	2010-07-06 22:01:07 +0000
+++ b/sql/rpl_info_file.h	2010-10-25 10:39:01 +0000
@@ -45,7 +45,7 @@ private:
   int do_check_info();
   void do_end_info();
   int do_flush_info(const bool force);
-  int do_reset_info();
+  int do_remove_info();
 
   int do_prepare_info_for_read();
   int do_prepare_info_for_write();

=== modified file 'sql/rpl_info_handler.cc'
--- a/sql/rpl_info_handler.cc	2010-10-08 16:11:32 +0000
+++ b/sql/rpl_info_handler.cc	2010-10-25 10:39:01 +0000
@@ -18,15 +18,27 @@
 #include "rpl_info_handler.h"
 
 Rpl_info_handler::Rpl_info_handler(const int nparam)
-  :ninfo(nparam), cursor((my_off_t)0),
+  :field_values(0), ninfo(nparam), cursor((my_off_t)0),
   prv_error(0), sync_counter(0), sync_period(0)
 {  
-  /* Nothing to do here. */
+  field_values= new Rpl_info_values(ninfo);
+  /*
+    Configures fields to temporary hold information. If the configuration
+    fails due to memory allocation problems, the object is deleted.
+  */
+  if (field_values && field_values->init())
+  {
+    delete field_values;
+    field_values= 0;
+  }
 }
 
 Rpl_info_handler::~Rpl_info_handler()
 {
-  /* Nothing to do here. */
+  if (field_values)
+  {
+    delete field_values;
+  }
 }
 
 void Rpl_info_handler::set_sync_period(uint period)

=== modified file 'sql/rpl_info_handler.h'
--- a/sql/rpl_info_handler.h	2010-10-17 23:27:40 +0000
+++ b/sql/rpl_info_handler.h	2010-10-25 10:39:01 +0000
@@ -18,6 +18,7 @@
 
 #include <my_global.h>
 #include <server_ids.h>
+#include "rpl_info_values.h"
 
 class Rpl_info_handler
 {
@@ -80,9 +81,9 @@ public:
     @retval FALSE No error
     @retval TRUE  Failure
   */
-  int reset_info()
+  int remove_info()
   {
-    return do_reset_info();
+    return do_remove_info();
   }
 
   /**
@@ -259,6 +260,13 @@ public:
   */
   bool is_transactional() { return do_is_transactional(); }
 
+  /*                                                                                                                                    
+    Pre-store information before writing it to the repository and if
+    necessary after reading it from the repository. The decision is
+    delegated to the sub-classes.
+  */
+  Rpl_info_values *field_values;
+
 protected:
   /* Number of fields to be stored in the repository. */
   int ninfo;
@@ -285,7 +293,7 @@ private:
   virtual int do_init_info()= 0;
   virtual int do_check_info()= 0;
   virtual int do_flush_info(const bool force)= 0;
-  virtual int do_reset_info()= 0;
+  virtual int do_remove_info()= 0;
   virtual void do_end_info()= 0;
   virtual int do_prepare_info_for_read()= 0;
   virtual int do_prepare_info_for_write()= 0;

=== added file 'sql/rpl_info_table.cc'
--- a/sql/rpl_info_table.cc	1970-01-01 00:00:00 +0000
+++ b/sql/rpl_info_table.cc	2010-10-27 09:04:21 +0000
@@ -0,0 +1,495 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "rpl_info_table.h"
+#include "rpl_utility.h"
+#include "sql_parse.h"
+
+Rpl_info_table::Rpl_info_table(uint nparam, uint param_field_idx,
+                               const char* param_schema,
+                               const char *param_table)
+:Rpl_info_handler(nparam), field_idx(param_field_idx)
+{
+  str_schema.str= str_table.str= NULL;
+  str_schema.length= str_table.length= 0;
+
+  uint schema_length= strlen(param_schema);
+  if ((str_schema.str= (char *) my_malloc(schema_length + 1, MYF(0))))
+  {
+    str_schema.length= schema_length;
+    strmake(str_schema.str, param_schema, schema_length);
+  }
+  
+  uint table_length= strlen(param_table);
+  if ((str_table.str= (char *) my_malloc(table_length + 1, MYF(0))))
+  {
+    str_table.length= table_length;
+    strmake(str_table.str, param_table, table_length);
+  }
+
+  if ((description= (char *)
+      my_malloc(str_schema.length + str_table.length + 2, MYF(0))))
+  {
+    char *pos= strmov(description, param_schema);
+    pos= strmov(pos, ".");
+    pos= strmov(pos, param_table);
+  }
+
+  access= new Rpl_info_table_access();
+}
+
+Rpl_info_table::~Rpl_info_table()
+{ 
+  if (access)
+    delete access;
+  
+  if (description)
+    delete description;
+
+  if (str_table.str)
+    delete str_table.str;
+
+  if (str_schema.str)
+    delete str_schema.str;
+}
+
+int Rpl_info_table::do_init_info()
+{
+  int error= 1;
+  enum enum_return_id res= FOUND_ID;
+  TABLE *table= NULL;
+  ulong saved_mode;
+  Open_tables_backup backup;
+
+  DBUG_ENTER("Rlp_info_table::do_init_info");
+
+  THD *thd= access->create_thd();
+
+  saved_mode= thd->variables.sql_mode;
+  tmp_disable_binlog(thd);
+
+  /*
+    Opens and locks the rpl_info table before accessing it.
+  */
+  if (access->open_table(thd, str_schema, str_table,
+                         get_number_info(), TL_WRITE,
+                         &table, &backup))
+    goto end;
+
+  /*
+    Points the cursor at the row to be read where the master_id equals to
+    the server_id.
+  */
+  if ((res= access->find_info_for_server_id(server_id, field_idx,
+                                            field_values, table)) == FOUND_ID)
+  {
+    /*
+      Reads the information stored in the rpl_info table into a
+      set of variables. If there is a failure, an error is returned.
+      Then executes some initialization routines.
+    */
+    if (access->load_info_values(get_number_info(), table->field,
+                                 field_values))
+      goto end;
+  }
+  error= (res == ERROR_ID);
+end:
+  /*
+    Unlocks and closes the rpl_info table.
+  */
+  access->close_table(thd, table, &backup, error);
+  reenable_binlog(thd);
+  thd->variables.sql_mode= saved_mode;
+  access->drop_thd(thd);
+  DBUG_RETURN(error);
+}
+
+int Rpl_info_table::do_flush_info(const bool force)
+{
+  int error= 1;
+  enum enum_return_id res= FOUND_ID;
+  TABLE *table= NULL;
+  ulong saved_mode;
+  Open_tables_backup backup;
+
+  DBUG_ENTER("Rpl_info_table::do_flush_info");
+
+  if (!(force || (sync_period &&
+      ++(sync_counter) >= sync_period)))
+    DBUG_RETURN(0);
+
+  THD *thd= access->create_thd();
+
+  sync_counter= 0;
+  saved_mode= thd->variables.sql_mode;
+  tmp_disable_binlog(thd);
+
+  /*
+    Opens and locks the rpl_info table before accessing it.
+  */
+  if (access->open_table(thd, str_schema, str_table,
+                         get_number_info(), TL_WRITE,
+                         &table, &backup))
+    goto end;
+
+  /*
+    Points the cursor at the row to be read where the master_id
+    equals to the server_id. If the row is not found an error is
+    reported.
+  */
+  if ((res= access->find_info_for_server_id(server_id, field_idx,
+                                            field_values, table)) == NOT_FOUND_ID)
+  {
+    /*
+      Prepares the information to be stored before calling ha_write_row.
+    */
+    empty_record(table);
+    if (access->store_info_values(get_number_info(), table->field,
+                                  field_values))
+      goto end;
+
+    /*
+      Inserts a new row into rpl_info table.
+    */
+    if ((error= table->file->ha_write_row(table->record[0])))
+    {
+      table->file->print_error(error, MYF(0));
+      /*
+        This makes sure that the error is 1 and not the status returned
+        by the handler.
+      */
+      error= 1;
+      goto end;
+    }
+    error= 0;
+  }
+  else if (res == FOUND_ID)
+  {
+    /*
+      Prepares the information to be stored before calling ha_update_row.
+    */
+    store_record(table, record[1]);
+    table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
+    if (access->store_info_values(get_number_info(), table->field,
+                                  field_values))
+      goto end;
+ 
+    /*
+      Updates a row in the rpl_info table.
+    */
+    if ((error= table->file->ha_update_row(table->record[1], table->record[0])) &&
+        error != HA_ERR_RECORD_IS_THE_SAME)
+    {
+      table->file->print_error(error, MYF(0));
+      /*
+        This makes sure that the error is 1 and not the status returned
+        by the handler.
+      */
+      error= 1;
+      goto end;
+    }
+    error= 0;
+  }
+
+end:
+  /*
+    Unlocks and closes the rpl_info table.
+  */
+  access->close_table(thd, table, &backup, error);
+  reenable_binlog(thd);
+  thd->variables.sql_mode= saved_mode;
+  access->drop_thd(thd);
+  DBUG_RETURN(error);
+}
+
+int Rpl_info_table::do_remove_info()
+{
+  int error= 1;
+  enum enum_return_id res= FOUND_ID;
+  TABLE *table= NULL;
+  ulong saved_mode;
+  Open_tables_backup backup;
+
+  DBUG_ENTER("Rpl_info_table::do_remove_info");
+
+  THD *thd= access->create_thd();
+
+  saved_mode= thd->variables.sql_mode;
+  tmp_disable_binlog(thd);
+
+  /*
+    Opens and locks the rpl_info table before accessing it.
+  */
+  if (access->open_table(thd, str_schema, str_table,
+                         get_number_info(), TL_WRITE,
+                         &table, &backup))
+    goto end;
+
+  /*
+    Points the cursor at the row to be deleted where the the master_id
+    equals to the server_id. If the row is not found, the execution
+    proceeds normally.
+  */
+  if ((res= access->find_info_for_server_id(server_id, field_idx,
+                                            field_values, table)) == FOUND_ID)
+  {
+    /*
+      Deletes a row in the rpl_info table.
+    */
+    if ((error= table->file->ha_delete_row(table->record[0])))
+    {
+      table->file->print_error(error, MYF(0));
+      goto end;
+    }
+  }
+  error= (res == ERROR_ID);
+end:
+  /*
+    Unlocks and closes the rpl_info table.
+  */
+  access->close_table(thd, table, &backup, error);
+  reenable_binlog(thd);
+  thd->variables.sql_mode= saved_mode;
+  access->drop_thd(thd);
+  DBUG_RETURN(error);
+}
+
+int Rpl_info_table::do_check_info()
+{
+  int error= 1;
+  TABLE *table= NULL;
+  ulong saved_mode;
+  Open_tables_backup backup;
+
+  DBUG_ENTER("Rpl_info_table::do_check_info");
+
+  THD *thd= access->create_thd();
+
+  saved_mode= thd->variables.sql_mode;
+
+  /*
+    Opens and locks the rpl_info table before accessing it.
+  */
+  if (access->open_table(thd, str_schema, str_table,
+                         get_number_info(), TL_READ,
+                         &table, &backup))
+    goto end;
+
+  /*
+    Points the cursor at the row to be deleted where the the master_id
+    equals to the server_id. If the row is not found, an error is
+    reported.
+  */
+  if (access->find_info_for_server_id(server_id, field_idx,
+                                      field_values, table) != FOUND_ID)
+  {
+    /* 
+       We cannot simply call my_error here because it does not
+       really means that there was a failure but only that the
+       record was not found.
+    */
+    goto end;
+  }
+  error= 0;
+
+end:
+  /*
+    Unlocks and closes the rpl_info table.
+  */
+  access->close_table(thd, table, &backup, error);
+  thd->variables.sql_mode= saved_mode;
+  access->drop_thd(thd);
+  DBUG_RETURN(error);
+}
+
+void Rpl_info_table::do_end_info()
+{
+}
+
+int Rpl_info_table::do_prepare_info_for_read()
+{
+  if (!field_values)
+    return TRUE;
+
+  cursor= 1;
+
+  return FALSE;
+}
+
+int Rpl_info_table::do_prepare_info_for_write()
+{
+  return(do_prepare_info_for_read());
+}
+
+bool Rpl_info_table::do_set_info(const int pos, const char *value)
+{
+  return (field_values->value[pos].copy(value, strlen(value),
+                                        &my_charset_bin));
+}
+
+bool Rpl_info_table::do_set_info(const int pos, const ulong value)
+{
+  return (field_values->value[pos].set_int(value, TRUE,
+                                           &my_charset_bin));
+}
+
+bool Rpl_info_table::do_set_info(const int pos, const int value)
+{
+  return (field_values->value[pos].set_int(value, FALSE,
+                                           &my_charset_bin));
+}
+
+bool Rpl_info_table::do_set_info(const int pos, const float value)
+{
+  return (field_values->value[pos].set_real(value, NOT_FIXED_DEC,
+                                            &my_charset_bin));
+}
+
+bool Rpl_info_table::do_set_info(const int pos, const Server_ids *value)
+{
+  if (const_cast<Server_ids *>(value)->pack_server_ids(&field_values->value[pos]))
+    return TRUE;
+
+  return FALSE;
+}
+
+bool Rpl_info_table::do_get_info(const int pos, char *value, const size_t size,
+                                 const char *default_value)
+{
+  if (field_values->value[pos].length())
+    strmake(value, field_values->value[pos].c_ptr_safe(),
+            field_values->value[pos].length());
+  else if (default_value)
+    strmake(value, default_value, strlen(default_value));
+  else
+    *value= '\0';
+
+  return FALSE;
+}
+
+bool Rpl_info_table::do_get_info(const int pos, ulong *value,
+                                 const ulong default_value)
+{
+  if (field_values->value[pos].length())
+  {
+    *value= strtoul(field_values->value[pos].c_ptr_safe(), 0, 10);
+    return FALSE;
+  }
+  else if (default_value)
+  {
+    *value= default_value;
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+bool Rpl_info_table::do_get_info(const int pos, int *value,
+                                 const int default_value)
+{
+  if (field_values->value[pos].length())
+  {
+    *value=  atoi(field_values->value[pos].c_ptr_safe());
+    return FALSE;
+  }
+  else if (default_value)
+  {
+    *value= default_value;
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+bool Rpl_info_table::do_get_info(const int pos, float *value,
+                                 const float default_value)
+{
+  if (field_values->value[pos].length())
+  {
+    if (sscanf(field_values->value[pos].c_ptr_safe(), "%f", value) != 1)
+      return TRUE;
+    return FALSE;
+  }
+  else if (default_value != 0.0)
+  {
+    *value= default_value;
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+bool Rpl_info_table::do_get_info(const int pos, Server_ids *value,
+                                 const Server_ids *default_value __attribute__((unused)))
+{
+  if (value->unpack_server_ids(field_values->value[pos].c_ptr_safe()))
+    return TRUE;
+
+  return FALSE;
+}
+
+char* Rpl_info_table::do_get_description_info()
+{
+  return description;
+}
+
+bool Rpl_info_table::do_is_transactional()
+{
+  ulong saved_mode;
+  TABLE *table= NULL;
+  Open_tables_backup backup;
+  bool is_trans= FALSE;
+
+  DBUG_ENTER("Rpl_info_table::do_is_transactional");
+
+  THD *thd= access->create_thd();
+
+  saved_mode= thd->variables.sql_mode;
+
+  /*
+    Opens and locks the rpl_info table before accessing it.
+  */
+  if (!access->open_table(thd, str_schema, str_table,
+                          get_number_info(), TL_READ,
+                          &table, &backup))
+    is_trans= table->file->has_transactions();
+
+  access->close_table(thd, table, &backup, 0);
+  thd->variables.sql_mode= saved_mode;
+  access->drop_thd(thd);
+  DBUG_RETURN(is_trans);
+}
+
+bool Rpl_info_table::change_engine(const char *engine)
+{
+  bool error= TRUE;
+  ulong saved_mode;
+
+  DBUG_ENTER("Rpl_info_table::do_check_info");
+
+  THD *thd= access->create_thd();
+
+  saved_mode= thd->variables.sql_mode;
+  tmp_disable_binlog(thd);
+
+  /* TODO: Change the engine using internal functions */
+
+  error= FALSE;
+
+  reenable_binlog(thd);
+  thd->variables.sql_mode= saved_mode;
+  access->drop_thd(thd);
+  DBUG_RETURN(error);
+}

=== added file 'sql/rpl_info_table.h'
--- a/sql/rpl_info_table.h	1970-01-01 00:00:00 +0000
+++ b/sql/rpl_info_table.h	2010-10-25 10:39:01 +0000
@@ -0,0 +1,98 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef RPL_INFO_TABLE_H
+#define RPL_INFO_TABLE_H
+
+#include "rpl_info_handler.h"
+#include "rpl_info_table_access.h"
+
+class Rpl_info_table : public Rpl_info_handler
+{
+public:
+  Rpl_info_table(uint nparam, uint param_field_id, const char* param_schema,
+                 const char *param_table);
+  virtual ~Rpl_info_table();
+  /*
+    This enables to change the engine in use by internally executing
+    an ALTER TABLE ENGINE= engine.
+
+    @param[in]  engine  Type of the engine, e.g. Innodb, MyIsam.
+
+    @retval FALSE No error
+    @retval TRUE  Failure
+  */
+  bool change_engine(const char* engine);
+private:
+  /*
+    This property identifies the name of the schema where a
+    replication table is created.
+  */
+  LEX_STRING str_schema;
+
+  /*
+    This property identifies the name of a replication
+    table.
+  */
+  LEX_STRING str_table;
+
+  /*
+    This property indentifies the id/position of the field that is
+    used as primary key.
+  */
+  uint field_idx;
+  /*
+    This property represents a description of the repository.
+    Speciffically, "schema"."table".
+  */
+  char *description;
+
+  /*
+    This is a pointer to a class that facilitates manipulation
+    of replication tables.
+  */
+  Rpl_info_table_access *access;
+
+  int do_init_info();
+  int do_check_info();
+  void do_end_info();
+  int do_flush_info(const bool force);
+  int do_remove_info();
+
+  int do_prepare_info_for_read();
+  int do_prepare_info_for_write();
+  bool do_set_info(const int pos, const char *value);
+  bool do_set_info(const int pos, const int value);
+  bool do_set_info(const int pos, const ulong value);
+  bool do_set_info(const int pos, const float value);
+  bool do_set_info(const int pos, const Server_ids *value);
+  bool do_get_info(const int pos, char *value, const size_t size,
+                   const char *default_value);
+  bool do_get_info(const int pos, int *value,
+                   const int default_value);
+  bool do_get_info(const int pos, ulong *value,
+                   const ulong default_value);
+  bool do_get_info(const int pos, float *value,
+                   const float default_value);
+  bool do_get_info(const int pos, Server_ids *value,
+                   const Server_ids *default_value);
+  char* do_get_description_info();
+  bool do_is_transactional();
+
+  Rpl_info_table& operator=(const Rpl_info_table& info);
+  Rpl_info_table(const Rpl_info_table& info);
+};
+
+#endif /* RPL_INFO_TABLE_H */

=== added file 'sql/rpl_info_table_access.cc'
--- a/sql/rpl_info_table_access.cc	1970-01-01 00:00:00 +0000
+++ b/sql/rpl_info_table_access.cc	2010-10-27 11:20:32 +0000
@@ -0,0 +1,319 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "rpl_info_table_access.h"
+#include "rpl_utility.h"
+#include "handler.h"
+#include "sql_parse.h"
+
+/**
+  Opens and locks a table.
+
+  It's assumed that the caller knows what they are doing:
+  - whether it was necessary to reset-and-backup the open tables state
+  - whether the requested lock does not lead to a deadlock
+  - whether this open mode would work under LOCK TABLES, or inside a
+  stored function or trigger.
+
+  Note that if the table can't be locked successfully this operation will
+  close it. Therefore it provides guarantee that it either opens and locks
+  table or fails without leaving any tables open.
+
+  @param[in]  thd           Thread requesting to open the table
+  @param[in]  dbstr         Database where the table resides
+  @param[in]  tbstr         Table to be openned
+  @param[in]  max_num_field Maximum number of fields
+  @param[in]  lock_type     How to lock the table
+  @param[out] table         We will store the open table here
+  @param[out] backup        Save the lock info. here
+
+  @return
+    @retval TRUE open and lock failed - an error message is pushed into the
+                                        stack
+    @retval FALSE success
+*/
+bool Rpl_info_table_access::open_table(THD* thd, const LEX_STRING dbstr,
+                                       const LEX_STRING tbstr,
+                                       uint max_num_field,
+                                       enum thr_lock_type lock_type,
+                                       TABLE** table,
+                                       Open_tables_backup* backup)
+{
+  TABLE_LIST tables;
+
+  uint flags= (MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK |
+               MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY |
+               MYSQL_OPEN_IGNORE_FLUSH |
+               MYSQL_LOCK_IGNORE_TIMEOUT |
+               MYSQL_LOCK_RPL_INFO_TABLE);
+
+  DBUG_ENTER("Rpl_info_table_access::open_table");
+
+  /*
+    This is equivalent to a new "statement". For that reason, we call both
+    lex_start() and mysql_reset_thd_for_next_command.
+  */
+  if (thd->slave_thread || !current_thd)
+  { 
+    lex_start(thd);
+    mysql_reset_thd_for_next_command(thd);
+  }
+
+  thd->reset_n_backup_open_tables_state(backup);
+
+  tables.init_one_table(dbstr.str, dbstr.length, tbstr.str, tbstr.length,
+                        tbstr.str, lock_type);
+
+  if (!open_n_lock_single_table(thd, &tables, tables.lock_type, flags))
+  {
+    close_thread_tables(thd);
+    thd->restore_backup_open_tables_state(backup);
+    my_error(ER_NO_SUCH_TABLE, MYF(0), dbstr.str, tbstr.str);
+    DBUG_RETURN(TRUE);
+  }
+
+  DBUG_ASSERT(tables.table->s->table_category == TABLE_CATEGORY_RPL_INFO);
+
+  if (tables.table->s->fields < max_num_field)
+  {
+    /*
+      Safety: this can only happen if someone started the server and then
+      altered the table.
+    */
+    my_error(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2, MYF(0),
+             tables.table->s->db.str, tables.table->s->table_name.str,
+             max_num_field, tables.table->s->fields);
+    close_thread_tables(thd);
+    thd->restore_backup_open_tables_state(backup);
+    DBUG_RETURN(TRUE);
+  }
+
+  *table= tables.table;
+  tables.table->use_all_columns();
+  DBUG_RETURN(FALSE);
+}
+
+/**
+  Commits the changes, unlocks the table and closes it. This method
+  needs to be called even if the open_table fails, in order to ensure
+  the lock info is properly restored.
+
+  @param[in] thd    Thread requesting to close the table
+  @param[in] table  Table to be closed
+  @param[in] backup Restore the lock info from here
+  @param[in] error  If there was an error while updating
+                    the table
+
+  If there is an error, rolls back the current statement. Otherwise,
+  commits it. However, if a new thread was created and there is an
+  error, the transaction must be rolled back. Otherwise, it must be
+  committed. In this case, the changes were not done on behalf of
+  any user transaction and if not finished, there would be pending
+  changes.
+  
+  @return
+    @retval FALSE No error
+    @retval TRUE  Failure
+*/
+bool Rpl_info_table_access::close_table(THD *thd, TABLE* table,
+                                        Open_tables_backup *backup,
+                                        bool error)
+{
+  DBUG_ENTER("Rpl_info_table_access::close_table");
+
+  if (table)
+  {
+    if (error)
+      ha_rollback_trans(thd, FALSE);
+    else
+      ha_commit_trans(thd, FALSE);
+
+    if (saved_current_thd != current_thd)
+    {
+      if (error)
+        ha_rollback_trans(thd, TRUE);
+      else
+        ha_commit_trans(thd, TRUE);
+    }
+    close_thread_tables(thd);
+    thd->restore_backup_open_tables_state(backup);
+  }
+
+  DBUG_RETURN(FALSE);
+}
+
+/**
+  Positions the internal pointer of `table` to the place where (id)
+  is stored.
+
+  In case search succeeded, the table cursor points to the found row.
+
+  @param[in]      server_id    Server id
+  @param[in]      idx          Index field
+  @param[in,out]  field_values The sequence of values
+  @param[in,out]  table        Table
+
+  @return
+    @retval FOUND     The row was found.
+    @retval NOT_FOUND The row was not found.
+    @retval ERROR     There was a failure.
+*/
+enum enum_return_id Rpl_info_table_access::find_info_for_server_id(ulong server_id,
+                                                                   uint idx,
+                                                                   Rpl_info_values *field_values,
+                                                                   TABLE *table)
+{
+  uchar key[MAX_KEY_LENGTH];
+  DBUG_ENTER("Rpl_info_table_access::find_info_for_server_id");
+
+  field_values->value[idx].set_int(server_id, TRUE, &my_charset_bin);
+
+  if (field_values->value[idx].length() > table->field[idx]->field_length)
+    DBUG_RETURN(ERROR_ID);
+
+  table->field[idx]->store(field_values->value[idx].c_ptr_safe(),
+                           field_values->value[idx].length(),
+                           &my_charset_bin);
+
+  if (!(table->field[idx]->flags & PRI_KEY_FLAG) &&
+      table->s->keys_in_use.is_set(0))
+    DBUG_RETURN(ERROR_ID);
+
+  key_copy(key, table->record[0], table->key_info, table->key_info->key_length);
+
+  if (table->file->ha_index_read_idx_map(table->record[0], 0, key, HA_WHOLE_KEY,
+                                         HA_READ_KEY_EXACT))
+  {
+    DBUG_RETURN(NOT_FOUND_ID);
+  }
+
+  DBUG_RETURN(FOUND_ID);
+}
+
+/**
+  Reads information from a sequence of fields into a set of LEX_STRING
+  structures, where the sequence of values is specified through the object
+  Rpl_info_values.
+
+  @param[in] max_num_field Maximum number of fields
+  @param[in] fields        The sequence of fields
+  @param[in] field_values  The sequence of values
+
+  @return
+    @retval FALSE No error
+    @retval TRUE  Failure
+ */
+bool Rpl_info_table_access::load_info_values(uint max_num_field, Field **fields,
+                                             Rpl_info_values *field_values)
+{
+  DBUG_ENTER("Rpl_info_table_access::load_info_values");
+  char buff[MAX_FIELD_WIDTH];
+  String str(buff, sizeof(buff), &my_charset_bin);
+
+  uint field_idx= 0;
+  while (field_idx < max_num_field)
+  {
+    fields[field_idx]->val_str(&str);
+    field_values->value[field_idx].copy(str.c_ptr_safe(), str.length(),
+                                             &my_charset_bin);
+    field_idx++;
+  }
+
+  DBUG_RETURN(FALSE);
+}
+
+/**
+  Stores information from a sequence of fields into a set of LEX_STRING
+  structures, where the sequence of values is specified through the object
+  Rpl_info_values.
+
+  @param[in] max_num_field Maximum number of fields
+  @param[in] fields        The sequence of fields
+  @param[in] field_values  The sequence of values
+
+  @return
+    @retval FALSE No error
+    @retval TRUE  Failure
+ */
+bool Rpl_info_table_access::store_info_values(uint max_num_field, Field **fields,
+                                              Rpl_info_values *field_values)
+{
+  DBUG_ENTER("Rpl_info_table_access::store_info_values");
+  uint field_idx= 0;
+
+  while (field_idx < max_num_field)
+  {
+    fields[field_idx]->set_notnull();
+    if (fields[field_idx]->store(field_values->value[field_idx].c_ptr_safe(),
+                                 field_values->value[field_idx].length(),
+                                 &my_charset_bin))
+    {
+      my_error(ER_RPL_INFO_DATA_TOO_LONG, MYF(0),
+               fields[field_idx]->field_name);
+      DBUG_RETURN(TRUE);
+    }
+    field_idx++;
+  }
+
+  DBUG_RETURN(FALSE);
+}
+
+/**
+  Creates a new thread if necessary. In the bootstrap process or in
+  the mysqld startup, a thread is created in order to be able to
+  access a table. Otherwise, the current thread is used.
+
+  @return
+    @retval THD* Pointer to thread structure
+*/
+THD *Rpl_info_table_access::create_thd()
+{
+  THD *thd= NULL;
+  saved_current_thd= current_thd;
+
+  if (!current_thd)
+  {
+    thd= new THD;
+    thd->thread_stack= (char*) &thd;
+    thd->store_globals();
+  }
+  else
+    thd= current_thd;
+
+  return(thd);
+}
+
+/**
+  Destroys the created thread if necessary and restores the
+  system_thread information.
+
+  @param[in] thd Thread requesting to be destroyed
+
+  @return
+    @retval FALSE No error
+    @retval TRUE  Failure
+*/
+bool Rpl_info_table_access::drop_thd(THD *thd)
+{
+  DBUG_ENTER("Rpl_info::drop_thd");
+
+  if (saved_current_thd != current_thd)
+  {
+    delete thd;
+    my_pthread_setspecific_ptr(THR_THD,  NULL);
+  }
+
+  DBUG_RETURN(FALSE);
+}

=== added file 'sql/rpl_info_table_access.h'
--- a/sql/rpl_info_table_access.h	1970-01-01 00:00:00 +0000
+++ b/sql/rpl_info_table_access.h	2010-10-25 10:39:01 +0000
@@ -0,0 +1,55 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+#ifndef RPL_INFO_TABLE_ACCESS_H
+#define RPL_INFO_TABLE_ACCESS_H
+
+#include "my_global.h"
+#include "sql_priv.h"
+#include <table.h>
+#include <key.h>
+#include <sql_base.h>
+#include "rpl_info_handler.h"
+#include "rpl_info_values.h"
+
+enum enum_return_id { FOUND_ID= 1, NOT_FOUND_ID, ERROR_ID };
+
+class Rpl_info_table_access
+{
+public:
+  Rpl_info_table_access() { };
+  virtual ~Rpl_info_table_access() { };
+
+  bool open_table(THD* thd, const LEX_STRING dbstr, const LEX_STRING tbstr,
+                  uint max_num_field, enum thr_lock_type lock_type,
+                  TABLE** table, Open_tables_backup* backup);
+  bool close_table(THD* thd, TABLE* table, Open_tables_backup* backup,
+                   bool error);
+  enum enum_return_id find_info_for_server_id(ulong server_id, uint idx, Rpl_info_values *,
+                                              TABLE *table);
+  bool load_info_values(uint max_num_field, Field **fields,
+                        Rpl_info_values *field_values);
+  bool store_info_values(uint max_num_field, Field **fields,
+                         Rpl_info_values *field_values);
+  THD *create_thd();
+  bool drop_thd(THD* thd);
+
+private:
+  THD *saved_current_thd;
+
+  Rpl_info_table_access& operator=(const Rpl_info_table_access& info);
+  Rpl_info_table_access(const Rpl_info_table_access& info);
+};
+
+#endif /* RPL_INFO_TABLE_ACCESS_H */

=== added file 'sql/rpl_info_values.cc'
--- a/sql/rpl_info_values.cc	1970-01-01 00:00:00 +0000
+++ b/sql/rpl_info_values.cc	2010-10-27 09:04:21 +0000
@@ -0,0 +1,46 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "rpl_info_values.h"
+
+Rpl_info_values::Rpl_info_values(int param_ninfo): value(0),
+    ninfo(param_ninfo) { }
+
+/**
+  Initializes a sequence of values to be read from or stored into a repository.
+  The number of values created and initialized are determined by the property
+  @c ninfo which is set while calling the constructor. Each value is created
+  with the default size of @c FN_REFLEN.
+
+  @retval FALSE No error
+  @retval TRUE Failure
+*/
+bool Rpl_info_values::init()
+{
+  DBUG_ENTER("Rpl_info_values::init");
+
+  if (!value && !(value= new String[ninfo]))
+      DBUG_RETURN(TRUE);
+
+  DBUG_RETURN(FALSE);
+}
+
+Rpl_info_values::~Rpl_info_values()
+{
+  for (int pos= 0; pos < ninfo; pos++)
+    value[pos].~String();
+
+  delete [] value;
+}

=== added file 'sql/rpl_info_values.h'
--- a/sql/rpl_info_values.h	1970-01-01 00:00:00 +0000
+++ b/sql/rpl_info_values.h	2010-10-27 09:04:21 +0000
@@ -0,0 +1,42 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef RPL_INFO_VALUES_H
+#define RPL_INFO_VALUES_H
+
+#include <my_global.h>
+#include <sql_priv.h>
+#include <my_sys.h>
+#include <sql_string.h>
+
+class Rpl_info_values
+{
+public:
+  Rpl_info_values(int param_ninfo);
+  virtual ~Rpl_info_values();
+
+  bool init();
+
+  /* Sequence of values to be read from or stored into a repository. */
+  String *value;
+
+private:
+  /* This property represents the number of fields. */
+  int ninfo;
+
+  Rpl_info_values& operator=(const Rpl_info_values& values);
+  Rpl_info_values(const Rpl_info_values& values);
+};
+#endif /* RPL_INFO_VALUES_H */

=== modified file 'sql/rpl_master.cc'
--- a/sql/rpl_master.cc	2010-09-28 15:17:29 +0000
+++ b/sql/rpl_master.cc	2010-10-27 14:51:07 +0000
@@ -36,6 +36,8 @@ static int binlog_dump_count = 0;
 #define SLAVE_LIST_CHUNK 128
 #define SLAVE_ERRMSG_SIZE (FN_REFLEN+64)
 HASH slave_list;
+extern TYPELIB binlog_checksum_typelib;
+
 
 #define get_object(p, obj, msg) \
 {\
@@ -242,6 +244,86 @@ bool show_slave_hosts(THD* thd)
 }
 
 
+/**
+   Internal to mysql_binlog_send() routine that recalculates checksum for
+   a FD event (asserted) that needs additional arranment prior sending to slave.
+*/
+inline void fix_checksum(String *packet, ulong ev_offset)
+{
+  /* recalculate the crc for this event */
+  uint data_len = uint4korr(packet->ptr() + ev_offset + EVENT_LEN_OFFSET);
+  ha_checksum crc= my_checksum(0L, NULL, 0);
+  DBUG_ASSERT(data_len == 
+              LOG_EVENT_MINIMAL_HEADER_LEN + FORMAT_DESCRIPTION_HEADER_LEN +
+              BINLOG_CHECKSUM_ALG_DESC_LEN + BINLOG_CHECKSUM_LEN);
+  crc= my_checksum(crc, (uchar *)packet->ptr() + ev_offset, data_len -
+                   BINLOG_CHECKSUM_LEN);
+  int4store(packet->ptr() + ev_offset + data_len - BINLOG_CHECKSUM_LEN, crc);
+}
+
+
+static user_var_entry * get_binlog_checksum_uservar(THD * thd)
+{
+  LEX_STRING name=  { C_STRING_WITH_LEN("master_binlog_checksum")};
+  user_var_entry *entry= 
+    (user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
+                                  name.length);
+  return entry;
+}
+
+/**
+  Function for calling in mysql_binlog_send
+  to check if slave initiated checksum-handshake.
+
+  @param[in]    thd  THD to access a user variable
+
+  @return        TRUE if handshake took place, FALSE otherwise
+*/
+
+static bool is_slave_checksum_aware(THD * thd)
+{
+  DBUG_ENTER("is_slave_checksum_aware");
+  user_var_entry *entry= get_binlog_checksum_uservar(thd);
+  DBUG_RETURN(entry? true  : false);
+}
+
+/**
+  Function for calling in mysql_binlog_send
+  to get the value of @@binlog_checksum of the master at
+  time of checksum-handshake.
+
+  The value tells the master whether to compute or not, and the slave
+  to verify or not the first artificial Rotate event's checksum.
+
+  @param[in]    thd  THD to access a user variable
+
+  @return       value of @@binlog_checksum alg according to
+                @c enum enum_binlog_checksum_alg
+*/
+
+static uint8 get_binlog_checksum_value_at_connect(THD * thd)
+{
+  uint8 ret;
+
+  DBUG_ENTER("get_binlog_checksum_value_at_connect");
+  user_var_entry *entry= get_binlog_checksum_uservar(thd);
+  if (!entry)
+  {
+    ret= BINLOG_CHECKSUM_ALG_UNDEF;
+  }
+  else
+  {
+    DBUG_ASSERT(entry->type == STRING_RESULT);
+    String str;
+    uint dummy_errors;
+    str.copy(entry->value, entry->length, &my_charset_bin, &my_charset_bin,
+             &dummy_errors);
+    ret= (uint8) find_type ((char*) str.ptr(), &binlog_checksum_typelib, 1) - 1;
+    DBUG_ASSERT(ret <= BINLOG_CHECKSUM_ALG_CRC32); // while it's just on CRC32 alg
+  }
+  DBUG_RETURN(ret);
+}
+
 /*
     fake_rotate_event() builds a fake (=which does not exist physically in any
     binlog) Rotate event, which contains the name of the binlog we are going to
@@ -261,10 +343,21 @@ bool show_slave_hosts(THD* thd)
 */
 
 static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
-                             ulonglong position, const char** errmsg)
+                             ulonglong position, const char** errmsg,
+                             uint8 checksum_alg_arg)
 {
   DBUG_ENTER("fake_rotate_event");
   char header[LOG_EVENT_HEADER_LEN], buf[ROTATE_HEADER_LEN+100];
+
+  /*
+    this Rotate is to be sent with checksum if and only if
+    slave's get_master_version_and_clock time handshake value 
+    of master's @@global.binlog_checksum was TRUE
+  */
+
+  my_bool do_checksum= checksum_alg_arg != BINLOG_CHECKSUM_ALG_OFF &&
+    checksum_alg_arg != BINLOG_CHECKSUM_ALG_UNDEF;
+
   /*
     'when' (the timestamp) is set to 0 so that slave could distinguish between
     real and fake Rotate events (if necessary)
@@ -274,7 +367,8 @@ static int fake_rotate_event(NET* net, S
 
   char* p = log_file_name+dirname_length(log_file_name);
   uint ident_len = (uint) strlen(p);
-  ulong event_len = ident_len + LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN;
+  ulong event_len = ident_len + LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN +
+    (do_checksum ? BINLOG_CHECKSUM_LEN : 0);
   int4store(header + SERVER_ID_OFFSET, server_id);
   int4store(header + EVENT_LEN_OFFSET, event_len);
   int2store(header + FLAGS_OFFSET, LOG_EVENT_ARTIFICIAL_F);
@@ -285,7 +379,19 @@ static int fake_rotate_event(NET* net, S
   packet->append(header, sizeof(header));
   int8store(buf+R_POS_OFFSET,position);
   packet->append(buf, ROTATE_HEADER_LEN);
-  packet->append(p,ident_len);
+  packet->append(p, ident_len);
+
+  if (do_checksum)
+  {
+    char b[BINLOG_CHECKSUM_LEN];
+    ha_checksum crc= my_checksum(0L, NULL, 0);
+    crc= my_checksum(crc, (uchar*)header, sizeof(header));
+    crc= my_checksum(crc, (uchar*)buf, ROTATE_HEADER_LEN);
+    crc= my_checksum(crc, (uchar*)p, ident_len);
+    int4store(b, crc);
+    packet->append(b, sizeof(b));
+  }
+
   if (my_net_write(net, (uchar*) packet->ptr(), packet->length()))
   {
     *errmsg = "failed on my_net_write()";
@@ -416,6 +522,9 @@ Increase max_allowed_packet on master";
   case LOG_READ_TRUNC:
     *errmsg = "binlog truncated in the middle of event";
     break;
+  case LOG_READ_CHECKSUM_FAILURE:
+    *errmsg = "event read from binlog did not pass crc check";
+    break;
   default:
     *errmsg = "unknown error reading log event on the master";
     break;
@@ -458,10 +567,13 @@ static ulonglong get_heartbeat_period(TH
     the dump thread.
 */
 static int send_heartbeat_event(NET* net, String* packet,
-                                const struct event_coordinates *coord)
+                                const struct event_coordinates *coord,
+                                uint8 checksum_alg_arg)
 {
   DBUG_ENTER("send_heartbeat_event");
   char header[LOG_EVENT_HEADER_LEN];
+  my_bool do_checksum= checksum_alg_arg != BINLOG_CHECKSUM_ALG_OFF &&
+    checksum_alg_arg != BINLOG_CHECKSUM_ALG_UNDEF;
   /*
     'when' (the timestamp) is set to 0 so that slave could distinguish between
     real and fake Rotate events (if necessary)
@@ -473,7 +585,8 @@ static int send_heartbeat_event(NET* net
   char* p= coord->file_name + dirname_length(coord->file_name);
 
   uint ident_len = strlen(p);
-  ulong event_len = ident_len + LOG_EVENT_HEADER_LEN;
+  ulong event_len = ident_len + LOG_EVENT_HEADER_LEN +
+    (do_checksum ? BINLOG_CHECKSUM_LEN : 0);
   int4store(header + SERVER_ID_OFFSET, server_id);
   int4store(header + EVENT_LEN_OFFSET, event_len);
   int2store(header + FLAGS_OFFSET, 0);
@@ -483,6 +596,16 @@ static int send_heartbeat_event(NET* net
   packet->append(header, sizeof(header));
   packet->append(p, ident_len);             // log_file_name
 
+  if (do_checksum)
+  {
+    char b[BINLOG_CHECKSUM_LEN];
+    ha_checksum crc= my_checksum(0L, NULL, 0);
+    crc= my_checksum(crc, (uchar*) header, sizeof(header));
+    crc= my_checksum(crc, (uchar*) p, ident_len);
+    int4store(b, crc);
+    packet->append(b, sizeof(b));
+  }
+
   if (my_net_write(net, (uchar*) packet->ptr(), packet->length()) ||
       net_flush(net))
   {
@@ -513,6 +636,8 @@ void mysql_binlog_send(THD* thd, char* l
   mysql_mutex_t *log_lock;
   mysql_cond_t *log_cond;
   bool binlog_can_be_corrupted= FALSE;
+  uint8 current_checksum_alg= BINLOG_CHECKSUM_ALG_UNDEF;
+
 #ifndef DBUG_OFF
   int left_events = max_binlog_dump_events;
 #endif
@@ -632,7 +757,8 @@ impossible position";
     given that we want minimum modification of 4.0, we send the normal
     and fake Rotates.
   */
-  if (fake_rotate_event(net, packet, log_file_name, pos, &errmsg))
+  if (fake_rotate_event(net, packet, log_file_name, pos, &errmsg,
+                        get_binlog_checksum_value_at_connect(current_thd)))
   {
     /*
        This error code is not perfect, as fake_rotate_event() does not
@@ -668,8 +794,8 @@ impossible position";
        Try to find a Format_description_log_event at the beginning of
        the binlog
      */
-     if (!(error = Log_event::read_log_event(&log, packet, log_lock)))
-     {
+    if (!(error = Log_event::read_log_event(&log, packet, log_lock, 0)))
+    { 
        /*
          The packet has offsets equal to the normal offsets in a
          binlog event + ev_offset (the first ev_offset characters are
@@ -677,9 +803,26 @@ impossible position";
        */
        DBUG_PRINT("info",
                   ("Looked for a Format_description_log_event, found event type %d",
-                   (*packet)[EVENT_TYPE_OFFSET+ev_offset]));
-       if ((*packet)[EVENT_TYPE_OFFSET+ev_offset] == FORMAT_DESCRIPTION_EVENT)
+                   (*packet)[EVENT_TYPE_OFFSET + ev_offset]));
+       if ((*packet)[EVENT_TYPE_OFFSET + ev_offset] == FORMAT_DESCRIPTION_EVENT)
        {
+         current_checksum_alg= get_checksum_alg(packet->ptr() + ev_offset,
+                                                packet->length() - ev_offset);
+         DBUG_ASSERT(current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
+                     current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
+                     current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
+         if (!is_slave_checksum_aware(thd) &&
+             current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+             current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+         {
+           my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
+           errmsg= "Slave can not handle replication events with the checksum "
+             "that master is configured to log";
+           sql_print_warning("Master is configured to log replication events "
+                             "with checksum, but will not send such events to "
+                             "slaves that cannot process them");
+           goto err;
+         }
          binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+ev_offset] &
                                        LOG_EVENT_BINLOG_IN_USE_F);
          (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
@@ -695,6 +838,12 @@ impossible position";
           */
          int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
                    ST_CREATED_OFFSET+ev_offset, (ulong) 0);
+
+	 /* fix the checksum due to latest changes in header */
+	 if (current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+             current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+           fix_checksum(packet, ev_offset);
+
          /* send it */
          if (my_net_write(net, (uchar*) packet->ptr(), packet->length()))
          {
@@ -737,7 +886,8 @@ impossible position";
        file */
     if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg))
       goto err;
-    while (!(error = Log_event::read_log_event(&log, packet, log_lock)))
+    while (!(error = Log_event::read_log_event(&log, packet, log_lock,
+                                               current_checksum_alg)))
     {
 #ifndef DBUG_OFF
       if (max_binlog_dump_events && !left_events--)
@@ -757,6 +907,23 @@ impossible position";
       event_type= (Log_event_type)((*packet)[LOG_EVENT_OFFSET+ev_offset]);
       if (event_type == FORMAT_DESCRIPTION_EVENT)
       {
+        current_checksum_alg= get_checksum_alg(packet->ptr() + ev_offset,
+                                               packet->length() - ev_offset);
+        DBUG_ASSERT(current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
+                    current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
+                    current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
+        if (!is_slave_checksum_aware(thd) &&
+            current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+            current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+        {
+          my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
+          errmsg= "Slave can not handle replication events with the checksum "
+            "that master is configured to log";
+          sql_print_warning("Master is configured to log replication events "
+                            "with checksum, but will not send such events to "
+                            "slaves that cannot process them");
+          goto err;
+        }
         binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+ev_offset] &
                                       LOG_EVENT_BINLOG_IN_USE_F);
         (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
@@ -807,7 +974,8 @@ impossible position";
       here we were reading binlog that was not closed properly (as a result
       of a crash ?). treat any corruption as EOF
     */
-    if (binlog_can_be_corrupted && error != LOG_READ_MEM)
+    if (binlog_can_be_corrupted &&
+        (error != LOG_READ_MEM && error != LOG_READ_CHECKSUM_FAILURE))
       error=LOG_READ_EOF;
     /*
       TODO: now that we are logging the offset, check to make sure
@@ -867,7 +1035,8 @@ impossible position";
 	*/
 
         mysql_mutex_lock(log_lock);
-        switch (error= Log_event::read_log_event(&log, packet, (mysql_mutex_t*) 0)) {
+        switch (error= Log_event::read_log_event(&log, packet, (mysql_mutex_t*) 0,
+                                                 current_checksum_alg)) {
 	case 0:
 	  /* we read successfully, so we'll need to send it to the slave */
           mysql_mutex_unlock(log_lock);
@@ -875,6 +1044,7 @@ impossible position";
           if (coord)
             coord->pos= uint4korr(packet->ptr() + ev_offset + LOG_POS_OFFSET);
           event_type= (Log_event_type)((*packet)[LOG_EVENT_OFFSET+ev_offset]);
+          DBUG_ASSERT(event_type != FORMAT_DESCRIPTION_EVENT);
 	  break;
 
 	case LOG_READ_EOF:
@@ -922,7 +1092,7 @@ impossible position";
                 thd->exit_cond(old_msg);
                 goto err;
               }
-              if (send_heartbeat_event(net, packet, coord))
+              if (send_heartbeat_event(net, packet, coord, current_checksum_alg))
               {
                 errmsg = "Failed on my_net_write()";
                 my_errno= ER_UNKNOWN_ERROR;
@@ -1027,7 +1197,7 @@ impossible position";
       */
       if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0 ||
 	  fake_rotate_event(net, packet, log_file_name, BIN_LOG_HEADER_SIZE,
-                            &errmsg))
+                            &errmsg, current_checksum_alg))
       {
 	my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
 	goto err;

=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc	2010-08-24 08:39:26 +0000
+++ b/sql/rpl_mi.cc	2010-10-25 19:02:24 +0000
@@ -87,7 +87,9 @@ Master_info::Master_info(PSI_mutex_key *
    ssl(0), ssl_verify_server_cert(0),
    port(MYSQL_PORT), connect_retry(DEFAULT_CONNECT_RETRY),
    clock_diff_with_master(0), heartbeat_period(0),
-   received_heartbeats(0), master_id(0), retry_count(master_retry_count)
+   received_heartbeats(0), master_id(0),
+   checksum_alg_before_fd(BINLOG_CHECKSUM_ALG_UNDEF),
+   retry_count(master_retry_count)
 {
   host[0] = 0; user[0] = 0; password[0] = 0;
   ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0;

=== modified file 'sql/rpl_mi.h'
--- a/sql/rpl_mi.h	2010-08-05 17:45:25 +0000
+++ b/sql/rpl_mi.h	2010-10-25 19:02:24 +0000
@@ -98,6 +98,12 @@ class Master_info : public Rpl_info
   ulonglong received_heartbeats;  // counter of received heartbeat events
   Server_ids *ignore_server_ids;
   ulong master_id;
+  /*
+    to hold checksum alg in use until IO thread has received FD.
+    Initialized to novalue, then set to the queried from master
+    @@global.binlog_checksum and deactivated once FD has been received.
+  */
+  uint8 checksum_alg_before_fd;
   ulong retry_count;
   char master_uuid[UUID_LENGTH+1];
 

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2010-10-17 23:27:40 +0000
+++ b/sql/rpl_rli.cc	2010-10-25 19:02:24 +0000
@@ -286,8 +286,9 @@ int Relay_log_info::init_relay_log_pos(c
         Because of we have data_lock and log_lock, we can safely read an
         event
       */
-      if (!(ev=Log_event::read_log_event(cur_log,0,
-                                         relay_log.description_event_for_exec)))
+      if (!(ev= Log_event::read_log_event(cur_log, 0,
+                                          relay_log.description_event_for_exec,
+                                          opt_slave_sql_verify_checksum)))
       {
         DBUG_PRINT("info",("could not read event, cur_log->error=%d",
                            cur_log->error));
@@ -1149,6 +1150,9 @@ a file name for --relay-log-index option
                         "use '--relay-log=%s' to avoid this problem.", ln);
       name_warning_sent= 1;
     }
+
+    relay_log.is_relay_log= TRUE;
+
     /*
       note, that if open() fails, we'll still have index file open
       but a destructor will take care of that
@@ -1161,7 +1165,6 @@ a file name for --relay-log-index option
       sql_print_error("Failed in open_log() called from Relay_log_info::init_info()");
       DBUG_RETURN(1);
     }
-    relay_log.is_relay_log= TRUE;
   }
 
   /*

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2010-10-21 12:18:25 +0000
+++ b/sql/rpl_rli.h	2010-11-15 16:43:41 +0000
@@ -40,9 +40,67 @@ Relay_log_info contains:
   - master log sequence corresponding to the last update
   - misc information specific to the SQL thread
 
-Relay_log_info is initialized from a repository, e.g. table or file, if there is
+Relay_log_info is initialized from a repository, i.e. table or file, if there is
 one. Otherwise, data members are intialized with defaults by calling
-init_relay_log_info(). Currently, only files are available as repositories.
+init_relay_log_info().
+
+The relay.info table/file shall be updated whenever: (i) the relay log file
+is rotated, (ii) SQL Thread is stopped, (iii) while processing a Xid_log_event,
+(iv) after a Query_log_event (i.e. commit or rollback) and (v) after processing
+any statement written to the binary log without a transaction context.
+
+The Xid_log_event is a commit for transactional engines and must be handled
+differently to provide reliability/data integrity. While committing updates to
+transactional engines the following behavior shall be implemented:
+
+  . If the relay.info is stored in a transactional repository, for instance, a
+  system table created using Innodb, the positions are updated in the context
+  of the transaction that updated data. Therefore, should the server crash 
+  before successfully committing the transaction the changes to the position 
+  table will be rolled back too.
+
+  . If the relay.info is stored in a non-transactional repository, for instance,
+  a file or a system table created using MyIsam, the positions are update after
+  processing the commit as in (iv) and (v).
+
+In particular, when there are mixed transactions, i.e a transaction that updates
+both transaction and non-transactional engines, the Xid_log_event is still used
+but reliability/data integrity cannot be achieved as we shall explain in what
+follows.
+
+Changes to non-transactional engines, such as MyIsam, cannot be rolled back if a
+failure happens. For that reason, there is no point in updating the positions
+within the boundaries of any on-going transaction. This is true for both commit
+and rollback. If a failure happens after processing the pseudo-transaction but
+before updating the positions, the transaction will be re-executed when the
+slave is up most likely causing an error that needs to be manually circumvented.
+This is a well-known issue when non-transactional statements are executed.
+
+Specifically, if rolling back any transaction, positions are updated outside the
+transaction boundaries. However, there may be a problem in this scenario even
+when only transactional engines are updated. This happens because if there is a
+rollback and such transaction is written to the binary log, a non-transactional
+engine was updated or a temporary table was created or dropped within its
+boundaries.
+
+In particular, in both STATEMENT and MIXED logging formats, this happens because
+any temporary table is automatically dropped after a shutdown/startup.
+See BUG#26945 for further details.
+
+Statements written to the binary log outside the boundaries of a transaction are
+DDLs or maintenance commands which are not transactional. These means that they
+cannot be rolled back if a failure happens. In such cases, the positions are
+updated after processing the events. If a failure happens after processing the
+statement but before updating the positions, the statement will be
+re-executed when the slave is up most likely causing an error that needs to be
+manually circumvented. This is a well-known issue when non-transactional
+statements are executed.
+
+The --sync-relay-log-info does not have effect when a system table, either
+transactional or non-transactional is used.
+
+To correctly recovery from failures, one should combine transactional system
+tables along with the --relay-log-recovery.
 *******************************************************************************/
 class Relay_log_info : public Rpl_info
 {

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2010-10-27 10:31:46 +0000
+++ b/sql/rpl_slave.cc	2010-11-23 23:10:22 +0000
@@ -438,10 +438,10 @@ void end_info(Master_info* mi)
   DBUG_VOID_RETURN;
 }
 
-int reset_info(Master_info* mi)
+int remove_info(Master_info* mi)
 {
   int error= 0;
-  DBUG_ENTER("reset_info");
+  DBUG_ENTER("remove_info");
   DBUG_ASSERT(mi != NULL && mi->rli != NULL);
 
   /*
@@ -460,7 +460,7 @@ int reset_info(Master_info* mi)
   mi->end_info();
   mi->rli->end_info();
 
-  if (mi->reset_info() || mi->rli->reset_info())
+  if (mi->remove_info() || mi->rli->remove_info())
     error= 1;
 
   DBUG_RETURN(error);
@@ -842,7 +842,7 @@ int start_slave_thread(
   if (start_cond && cond_lock) // caller has cond_lock
   {
     THD* thd = current_thd;
-    while (start_id == *slave_run_id)
+    while (start_id == *slave_run_id && thd != NULL)
     {
       DBUG_PRINT("sleep",("Waiting for slave thread to start"));
       const char* old_msg = thd->enter_cond(start_cond,cond_lock,
@@ -1362,6 +1362,48 @@ static int get_master_version_and_clock(
   }
 
   /*
+    FD_q's (A) is set initially from RL's (A): FD_q.(A) := RL.(A).
+    It's necessary to adjust FD_q.(A) at this point because in the following
+    course FD_q is going to be dumped to RL.
+    Generally FD_q is derived from a received FD_m (roughly FD_q := FD_m) 
+    in queue_event and the master's (A) is installed.
+    At one step with the assignment the Relay-Log's checksum alg is set to 
+    a new value: RL.(A) := FD_q.(A). If the slave service is stopped
+    the last time assigned RL.(A) will be passed over to the restarting
+    service (to the current execution point).
+    RL.A is a "codec" to verify checksum in queue_event() almost all the time
+    the first fake Rotate event.
+    Starting from this point IO thread will executes the following checksum
+    warmup sequence  of actions:
+
+    FD_q.A := RL.A,
+    A_m^0 := master.@@global.binlog_checksum,
+    {queue_event(R_f): verifies(R_f, A_m^0)},
+    {queue_event(FD_m): verifies(FD_m, FD_m.A), dump(FD_q), rotate(RL),
+                        FD_q := FD_m, RL.A := FD_q.A)}
+
+    See legends definition on MYSQL_BIN_LOG::relay_log_checksum_alg
+    docs lines (binlog.h).
+    In above A_m^0 - the value of master's
+    @@binlog_checksum determined in the upcoming handshake (stored in
+    mi->checksum_alg_before_fd).
+
+
+    After the warm-up sequence IO gets to "normal" checksum verification mode
+    to use RL.A in 
+    
+    {queue_event(E_m): verifies(E_m, RL.A)}
+
+    until it has received a new FD_m.
+  */
+  mi->rli->relay_log.description_event_for_queue->checksum_alg=
+    mi->rli->relay_log.relay_log_checksum_alg;
+
+  DBUG_ASSERT(mi->rli->relay_log.description_event_for_queue->checksum_alg !=
+              BINLOG_CHECKSUM_ALG_UNDEF);
+  DBUG_ASSERT(mi->rli->relay_log.relay_log_checksum_alg !=
+              BINLOG_CHECKSUM_ALG_UNDEF); 
+  /*
     Compare the master and slave's clock. Do not die if master's clock is
     unavailable (very old master not supporting UNIX_TIMESTAMP()?).
   */
@@ -1621,20 +1663,130 @@ when it try to get the value of TIME_ZON
     llstr((ulonglong) (mi->heartbeat_period*1000000000UL), llbuf);
     sprintf(query, query_format, llbuf);
 
-    if (mysql_real_query(mysql, query, strlen(query))
-        && !check_io_slave_killed(mi->info_thd, mi, NULL))
+    if (mysql_real_query(mysql, query, strlen(query)))
     {
-      errmsg= "The slave I/O thread stops because SET @master_heartbeat_period "
-        "on master failed.";
-      err_code= ER_SLAVE_FATAL_ERROR;
-      sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
-      mysql_free_result(mysql_store_result(mysql));
-      goto err;
+      if (check_io_slave_killed(mi->info_thd, mi, NULL))
+        goto slave_killed_err;
+
+      if (is_network_error(mysql_errno(mysql)))
+      {
+        mi->report(WARNING_LEVEL, mysql_errno(mysql),
+                   "SET @master_heartbeat_period to master failed with error: %s",
+                   mysql_error(mysql));
+        mysql_free_result(mysql_store_result(mysql));
+        goto network_err;
+      }
+      else
+      {
+        /* Fatal error */
+        errmsg= "The slave I/O thread stops because a fatal error is encountered "
+          " when it tries to SET @master_heartbeat_period on master.";
+        err_code= ER_SLAVE_FATAL_ERROR;
+        sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
+        mysql_free_result(mysql_store_result(mysql));
+        goto err;
+      }
     }
     mysql_free_result(mysql_store_result(mysql));
   }
- 
 
+  /*
+    Querying if master is capable to checksum and notifying it about own
+    CRC-awareness. The master's side instant value of @@global.binlog_checksum 
+    is stored in the dump thread's uservar area as well as cached locally
+    to become known in consensus by master and slave.
+  */
+  DBUG_EXECUTE_IF("simulate_slave_unaware_checksum",
+                  mi->checksum_alg_before_fd= BINLOG_CHECKSUM_ALG_OFF;
+                  goto past_checksum;);
+  {
+    int rc;
+    const char query[]= "SET @master_binlog_checksum= @@global.binlog_checksum";
+    master_res= NULL;
+    mi->checksum_alg_before_fd= BINLOG_CHECKSUM_ALG_UNDEF; //initially undefined
+    /*
+      @c checksum_alg_before_fd is queried from master in this block.
+      If master is old checksum-unaware the value stays undefined.
+      Once the first FD will be received its alg descriptor will replace
+      the being queried one.
+    */
+    rc= mysql_real_query(mysql, query, strlen(query));
+    if (rc != 0)
+    {
+      if (check_io_slave_killed(mi->info_thd, mi, NULL))
+        goto slave_killed_err;
+
+      if (mysql_errno(mysql) == ER_UNKNOWN_SYSTEM_VARIABLE)
+      {
+        // this is tolerable as OM -> NS is supported
+        mi->report(WARNING_LEVEL, mysql_errno(mysql),
+                   "Notifying master by %s failed with "
+                   "error: %s", query, mysql_error(mysql));
+      }
+      else
+      {
+        if (is_network_error(mysql_errno(mysql)))
+        {
+          mi->report(WARNING_LEVEL, mysql_errno(mysql),
+                     "Notifying master by %s failed with "
+                     "error: %s", query, mysql_error(mysql));
+          mysql_free_result(mysql_store_result(mysql));
+          goto network_err;
+        }
+        else
+        {
+          errmsg= "The slave I/O thread stops because a fatal error is encountered "
+            "when it tried to SET @master_binlog_checksum on master.";
+          err_code= ER_SLAVE_FATAL_ERROR;
+          sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
+          mysql_free_result(mysql_store_result(mysql));
+          goto err;
+        }
+      }
+    }
+    else
+    {
+      mysql_free_result(mysql_store_result(mysql));
+      if (!mysql_real_query(mysql,
+                            STRING_WITH_LEN("SELECT @master_binlog_checksum")) &&
+          (master_res= mysql_store_result(mysql)) &&
+          (master_row= mysql_fetch_row(master_res)) &&
+          (master_row[0] != NULL))
+      {
+        mi->checksum_alg_before_fd= (uint8)
+          find_type(master_row[0], &binlog_checksum_typelib, 1) - 1;
+        // valid outcome is either of
+        DBUG_ASSERT(mi->checksum_alg_before_fd == BINLOG_CHECKSUM_ALG_OFF ||
+                    mi->checksum_alg_before_fd == BINLOG_CHECKSUM_ALG_CRC32);
+      }
+      else if (check_io_slave_killed(mi->info_thd, mi, NULL))
+        goto slave_killed_err;
+      else if (is_network_error(mysql_errno(mysql)))
+      {
+        mi->report(WARNING_LEVEL, mysql_errno(mysql),
+                   "Get master BINLOG_CHECKSUM failed with error: %s", mysql_error(mysql));
+        goto network_err;
+      }
+      else
+      {
+        errmsg= "The slave I/O thread stops because a fatal error is encountered "
+          "when it tried to SELECT @master_binlog_checksum.";
+        err_code= ER_SLAVE_FATAL_ERROR;
+        sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
+        mysql_free_result(mysql_store_result(mysql));
+        goto err;
+      }
+    }
+    if (master_res)
+    {
+      mysql_free_result(master_res);
+      master_res= NULL;
+    }
+  }
+
+#ifndef DBUG_OFF
+past_checksum:
+#endif
 err:
   if (errmsg)
   {
@@ -2529,6 +2681,7 @@ static int sql_delay_event(Log_event *ev
 int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli)
 {
   int exec_res= 0;
+  bool skip_event= FALSE;
 
   DBUG_ENTER("apply_event_and_update_pos");
 
@@ -2573,7 +2726,10 @@ int apply_event_and_update_pos(Log_event
 
   int reason= ev->shall_skip(rli);
   if (reason == Log_event::EVENT_SKIP_COUNT)
+  {
     sql_slave_skip_counter= --rli->slave_skip_counter;
+    skip_event= TRUE;
+  }
   if (reason == Log_event::EVENT_SKIP_NOT)
   {
     // Sleeps if needed, and unlocks rli->data_lock.
@@ -2609,12 +2765,20 @@ int apply_event_and_update_pos(Log_event
   if (exec_res == 0)
   {
     /*
-      Positions are not updated when an XID is processed, i.e. not skipped.
-      To make the slave crash-safe positions are updated while processing
-      the XID event and as such do not need to be updated again.
+      Positions are not updated here when an XID is processed and the relay
+      log info is stored in a transactional engine such as Innodb. To make
+      a slave crash-safe, positions must be updated while processing a XID
+      event and as such do not need to be updated here again.
+
+      However, if the event needs to be skipped, this means that it will not
+      be processed and then positions need to be updated here.
+
       See sql/rpl_rli.h for further details.
     */
-    int error= ev->update_pos(rli);
+    int error= 0;
+    if (!(ev->get_type_code() == XID_EVENT && rli->is_transactional()) ||
+        skip_event)
+      error= ev->update_pos(rli);
 #ifndef DBUG_OFF
     DBUG_PRINT("info", ("update_pos error = %d", error));
     if (!rli->belongs_to_client())
@@ -3907,10 +4071,15 @@ static int process_io_rotate(Master_info
   */
   if (mi->rli->relay_log.description_event_for_queue->binlog_version >= 4)
   {
+    DBUG_ASSERT(mi->rli->relay_log.description_event_for_queue->checksum_alg ==
+                mi->rli->relay_log.relay_log_checksum_alg);
+    
     delete mi->rli->relay_log.description_event_for_queue;
     /* start from format 3 (MySQL 4.0) again */
     mi->rli->relay_log.description_event_for_queue= new
       Format_description_log_event(3);
+    mi->rli->relay_log.description_event_for_queue->checksum_alg=
+      mi->rli->relay_log.relay_log_checksum_alg;    
   }
   /*
     Rotate the relay log makes binlog format detection easier (at next slave
@@ -3964,8 +4133,9 @@ static int queue_binlog_ver_1_event(Mast
     Append_block/Exec_load (the SQL thread needs the data, as that thread is not
     connected to the master).
   */
-  Log_event *ev = Log_event::read_log_event(buf,event_len, &errmsg,
-                                            mi->rli->relay_log.description_event_for_queue);
+  Log_event *ev=
+    Log_event::read_log_event(buf, event_len, &errmsg,
+                              mi->rli->relay_log.description_event_for_queue, 0);
   if (unlikely(!ev))
   {
     sql_print_error("Read invalid event from master: '%s',\
@@ -4052,8 +4222,9 @@ static int queue_binlog_ver_3_event(Mast
   DBUG_ENTER("queue_binlog_ver_3_event");
 
   /* read_log_event() will adjust log_pos to be end_log_pos */
-  Log_event *ev = Log_event::read_log_event(buf,event_len, &errmsg,
-                                            mi->rli->relay_log.description_event_for_queue);
+  Log_event *ev=
+    Log_event::read_log_event(buf, event_len, &errmsg,
+                              mi->rli->relay_log.description_event_for_queue, 0);
   if (unlikely(!ev))
   {
     sql_print_error("Read invalid event from master: '%s',\
@@ -4079,6 +4250,7 @@ static int queue_binlog_ver_3_event(Mast
     inc_pos= event_len;
     break;
   }
+
   if (unlikely(rli->relay_log.append(ev)))
   {
     delete ev;
@@ -4142,7 +4314,68 @@ static int queue_event(Master_info* mi,c
   Relay_log_info *rli= mi->rli;
   mysql_mutex_t *log_lock= rli->relay_log.get_log_lock();
   ulong s_id;
+  bool unlock_data_lock= TRUE;
+  /*
+    FD_q must have been prepared for the first R_a event
+    inside get_master_version_and_clock()
+    Show-up of FD:s affects checksum_alg at once because
+    that changes FD_queue.
+  */
+  uint8 checksum_alg= mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF ? 
+    mi->checksum_alg_before_fd :
+    mi->rli->relay_log.relay_log_checksum_alg;
+
+  char *save_buf= NULL; // needed for checksumming the fake Rotate event
+  char rot_buf[LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN + FN_REFLEN];
+
+  DBUG_ASSERT(checksum_alg == BINLOG_CHECKSUM_ALG_OFF || 
+              checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF || 
+              checksum_alg == BINLOG_CHECKSUM_ALG_CRC32); 
+
   DBUG_ENTER("queue_event");
+  /*
+    FD_queue checksum alg description does not apply in a case of
+    FD itself. The one carries both parts of the checksum data.
+  */
+  if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT)
+  {
+    checksum_alg= get_checksum_alg(buf, event_len);
+  }
+  else if (buf[EVENT_TYPE_OFFSET] == START_EVENT_V3)
+  {
+    // checksum behaviour is similar to the pre-checksum FD handling
+    mi->checksum_alg_before_fd= BINLOG_CHECKSUM_ALG_UNDEF;
+    mi->rli->relay_log.description_event_for_queue->checksum_alg=
+      mi->rli->relay_log.relay_log_checksum_alg= checksum_alg=
+      BINLOG_CHECKSUM_ALG_OFF;
+  }
+
+  // does not hold always because of old binlog can work with NM 
+  // DBUG_ASSERT(checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
+
+  // should hold unless manipulations with RL. Tests that do that
+  // will have to refine the clause.
+  DBUG_ASSERT(mi->rli->relay_log.relay_log_checksum_alg !=
+              BINLOG_CHECKSUM_ALG_UNDEF);
+              
+  // Emulate the network corruption
+  DBUG_EXECUTE_IF("corrupt_queue_event",
+    if (buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT)
+    {
+      char *debug_event_buf_c = (char*) buf;
+      int debug_cor_pos = rand() % (event_len - BINLOG_CHECKSUM_LEN);
+      debug_event_buf_c[debug_cor_pos] =~ debug_event_buf_c[debug_cor_pos];
+      DBUG_PRINT("info", ("Corrupt the event at queue_event: byte on position %d", debug_cor_pos));
+      DBUG_SET("-d,corrupt_queue_event");
+    }
+  );
+                                              
+  if (event_checksum_test((uchar *) buf, event_len, checksum_alg))
+  {
+    error= ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE;
+    unlock_data_lock= FALSE;
+    goto err;
+  }
 
   LINT_INIT(inc_pos);
 
@@ -4170,12 +4403,67 @@ static int queue_event(Master_info* mi,c
     goto err;
   case ROTATE_EVENT:
   {
-    Rotate_log_event rev(buf,event_len,mi->rli->relay_log.description_event_for_queue);
-    if (unlikely(process_io_rotate(mi,&rev)))
+    Rotate_log_event rev(buf, checksum_alg != BINLOG_CHECKSUM_ALG_OFF ?
+                         event_len - BINLOG_CHECKSUM_LEN : event_len,
+                         mi->rli->relay_log.description_event_for_queue);
+
+    if (unlikely(process_io_rotate(mi, &rev)))
     {
       error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE;
       goto err;
     }
+    /* 
+       Checksum special cases for the fake Rotate (R_f) event caused by the protocol
+       of events generation and serialization in RL where Rotate of master is 
+       queued right next to FD of slave.
+       Since it's only FD that carries the alg desc of FD_s has to apply to R_m.
+       Two special rules apply only to the first R_f which comes in before any FD_m.
+       The 2nd R_f should be compatible with the FD_s that must have taken over
+       the last seen FD_m's (A).
+       
+       RSC_1: If OM \and fake Rotate \and slave is configured to
+              to compute checksum for its first FD event for RL
+              the fake Rotate gets checksummed here.
+    */
+    if (uint4korr(&buf[0]) == 0 && checksum_alg == BINLOG_CHECKSUM_ALG_OFF &&
+        mi->rli->relay_log.relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_OFF)
+    {
+      ha_checksum rot_crc= my_checksum(0L, NULL, 0);
+      event_len += BINLOG_CHECKSUM_LEN;
+      memcpy(rot_buf, buf, event_len - BINLOG_CHECKSUM_LEN);
+      int4store(&rot_buf[EVENT_LEN_OFFSET],
+                uint4korr(&rot_buf[EVENT_LEN_OFFSET]) + BINLOG_CHECKSUM_LEN);
+      rot_crc= my_checksum(rot_crc, (const uchar *) rot_buf,
+                           event_len - BINLOG_CHECKSUM_LEN);
+      int4store(&rot_buf[event_len - BINLOG_CHECKSUM_LEN], rot_crc);
+      DBUG_ASSERT(event_len == uint4korr(&rot_buf[EVENT_LEN_OFFSET]));
+      DBUG_ASSERT(mi->rli->relay_log.description_event_for_queue->checksum_alg ==
+                  mi->rli->relay_log.relay_log_checksum_alg);
+      /* the first one */
+      DBUG_ASSERT(mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF);
+      save_buf= (char *) buf;
+      buf= rot_buf;
+    }
+    else
+      /*
+        RSC_2: If NM \and fake Rotate \and slave does not compute checksum
+        the fake Rotate's checksum is stripped off before relay-logging.
+      */
+      if (uint4korr(&buf[0]) == 0 && checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+          mi->rli->relay_log.relay_log_checksum_alg == BINLOG_CHECKSUM_ALG_OFF)
+      {
+        event_len -= BINLOG_CHECKSUM_LEN;
+        memcpy(rot_buf, buf, event_len);
+        int4store(&rot_buf[EVENT_LEN_OFFSET],
+                  uint4korr(&rot_buf[EVENT_LEN_OFFSET]) - BINLOG_CHECKSUM_LEN);
+        DBUG_ASSERT(event_len == uint4korr(&rot_buf[EVENT_LEN_OFFSET]));
+        DBUG_ASSERT(mi->rli->relay_log.description_event_for_queue->checksum_alg ==
+                    mi->rli->relay_log.relay_log_checksum_alg);
+        /* the first one */
+        DBUG_ASSERT(mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF);
+        save_buf= (char *) buf;
+        buf= rot_buf;
+      }
     /*
       Now the I/O thread has just changed its mi->get_master_log_name(), so
       incrementing mi->get_master_log_pos() is nonsense.
@@ -4196,15 +4484,24 @@ static int queue_event(Master_info* mi,c
     */
     Format_description_log_event* tmp;
     const char* errmsg;
+    // mark it as undefined that is irrelevant anymore
+    mi->checksum_alg_before_fd= BINLOG_CHECKSUM_ALG_UNDEF;
     if (!(tmp= (Format_description_log_event*)
           Log_event::read_log_event(buf, event_len, &errmsg,
-                                    mi->rli->relay_log.description_event_for_queue)))
+                                    mi->rli->relay_log.description_event_for_queue,
+                                    1)))
     {
       error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE;
       goto err;
     }
     delete mi->rli->relay_log.description_event_for_queue;
     mi->rli->relay_log.description_event_for_queue= tmp;
+    if (tmp->checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF)
+      tmp->checksum_alg= BINLOG_CHECKSUM_ALG_OFF;
+
+    /* installing new value of checksum Alg for relay log */
+    mi->rli->relay_log.relay_log_checksum_alg= tmp->checksum_alg;
+
     /*
        Though this does some conversion to the slave's format, this will
        preserve the master's binlog format version, and number of event types.
@@ -4226,7 +4523,11 @@ static int queue_event(Master_info* mi,c
       HB (heartbeat) cannot come before RL (Relay)
     */
     char  llbuf[22];
-    Heartbeat_log_event hb(buf, event_len, mi->rli->relay_log.description_event_for_queue);
+    Heartbeat_log_event hb(buf,
+                           mi->rli->relay_log.relay_log_checksum_alg
+                           != BINLOG_CHECKSUM_ALG_OFF ?
+                           event_len - BINLOG_CHECKSUM_LEN : event_len,
+                           mi->rli->relay_log.description_event_for_queue);
     if (!hb.is_valid())
     {
       error= ER_SLAVE_HEARTBEAT_FAILURE;
@@ -4349,13 +4650,16 @@ static int queue_event(Master_info* mi,c
       error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE;
     }
     rli->ign_master_log_name_end[0]= 0; // last event is not ignored
+    if (save_buf != NULL)
+      buf= save_buf;
   }
   mysql_mutex_unlock(log_lock);
 
 skip_relay_logging:
   
 err:
-  mysql_mutex_unlock(&mi->data_lock);
+  if (unlock_data_lock)
+    mysql_mutex_unlock(&mi->data_lock);
   DBUG_PRINT("info", ("error: %d", error));
   if (error)
     mi->report(ERROR_LEVEL, error, ER(error), 
@@ -4735,8 +5039,9 @@ static Log_event* next_event(Relay_log_i
       But if the relay log is created by new_file(): then the solution is:
       MYSQL_BIN_LOG::open() will write the buffered description event.
     */
-    if ((ev=Log_event::read_log_event(cur_log,0,
-                                      rli->relay_log.description_event_for_exec)))
+    if ((ev= Log_event::read_log_event(cur_log, 0,
+                                       rli->relay_log.description_event_for_exec,
+                                       opt_slave_sql_verify_checksum)))
     {
       DBUG_ASSERT(thd==rli->info_thd);
       /*
@@ -5465,7 +5770,7 @@ int reset_slave(THD *thd, Master_info* m
   /* Clear master's log coordinates */
   mi->init_master_log_pos();
 
-  if (reset_info(mi))
+  if (remove_info(mi))
   {
     error= 1;
     goto err;
@@ -5688,9 +5993,9 @@ bool change_master(THD* thd, Master_info
       need_relay_log_purge)
    {
      /*
-       Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
+       Sometimes mi->rli->master_log_pos == 0 (it happens when the SQL thread is
        not initialized), so we use a max().
-       What happens to mi->rli.master_log_pos during the initialization stages
+       What happens to mi->rli->master_log_pos during the initialization stages
        of replication is not 100% clear, so we guard against problems using
        max().
       */
@@ -5803,11 +6108,11 @@ Server_ids::~Server_ids()
   delete_dynamic(&server_ids);
 }
 
-bool Server_ids::unpack_server_ids(const char *param_server_ids)
+bool Server_ids::unpack_server_ids(char *param_server_ids)
 {
-  char *token, *last;
-  uint num_items;
-
+  char *token= NULL, *last= NULL;
+  uint num_items= 0;
+ 
   DBUG_ENTER("Server_ids::unpack_server_ids");
 
   token= strtok_r((char *)const_cast<const char*>(param_server_ids),
@@ -5831,22 +6136,21 @@ bool Server_ids::unpack_server_ids(const
   DBUG_RETURN(FALSE);
 }
 
-bool Server_ids::pack_server_ids(char *buffer)
+bool Server_ids::pack_server_ids(String *buffer)
 {
   DBUG_ENTER("Server_ids::pack_server_ids");
 
-  if (!buffer)
+  if (buffer->set_int(server_ids.elements, FALSE, &my_charset_bin))
     DBUG_RETURN(TRUE);
 
-  for (ulong i= 0, cur_len= sprintf(buffer,
-                                    "%u",
-                                    server_ids.elements);
+  for (ulong i= 0;
        i < server_ids.elements; i++)
   {
     ulong s_id;
     get_dynamic(&server_ids, (uchar*) &s_id, i);
-    cur_len +=sprintf(buffer + cur_len,
-                      " %lu", s_id);
+    if (buffer->append(" ") ||
+        buffer->append_ulonglong(s_id))
+      DBUG_RETURN(TRUE);
   }
 
   DBUG_RETURN(FALSE);

=== modified file 'sql/rpl_slave.h'
--- a/sql/rpl_slave.h	2010-08-06 18:09:14 +0000
+++ b/sql/rpl_slave.h	2010-10-25 10:39:01 +0000
@@ -161,7 +161,7 @@ int init_slave();
 int init_recovery(Master_info* mi, const char** errmsg);
 int init_info(Master_info* mi, bool ignore_if_no_info, int thread_mask);
 void end_info(Master_info* mi);
-int reset_info(Master_info* mi);
+int remove_info(Master_info* mi);
 int flush_master_info(Master_info* mi, bool force);
 void init_slave_skip_errors(const char* arg);
 int register_slave_on_master(MYSQL* mysql);

=== modified file 'sql/rpl_utility.cc'
--- a/sql/rpl_utility.cc	2010-11-05 07:58:42 +0000
+++ b/sql/rpl_utility.cc	2010-11-16 12:14:06 +0000
@@ -1057,3 +1057,58 @@ table_def::~table_def()
 #endif
 }
 
+/**
+   @param   even_buf    point to the buffer containing serialized event
+   @param   event_len   length of the event accounting possible checksum alg
+
+   @return  TRUE        if test fails
+            FALSE       as success
+*/
+bool event_checksum_test(uchar *event_buf, ulong event_len, uint8 alg)
+{
+  bool res= FALSE;
+  uint16 flags= 0; // to store in FD's buffer flags orig value
+
+  if (alg != BINLOG_CHECKSUM_ALG_OFF && alg != BINLOG_CHECKSUM_ALG_UNDEF)
+  {
+    ha_checksum incoming;
+    ha_checksum computed;
+
+    if (event_buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT)
+    {
+#ifndef DBUG_OFF
+      int8 fd_alg= event_buf[event_len - BINLOG_CHECKSUM_LEN - 
+                             BINLOG_CHECKSUM_ALG_DESC_LEN];
+#endif
+      /*
+        FD event is checksummed and therefore verified w/o the binlog-in-use flag
+      */
+      flags= uint2korr(event_buf + FLAGS_OFFSET);
+      if (flags & LOG_EVENT_BINLOG_IN_USE_F)
+        event_buf[FLAGS_OFFSET] &= ~LOG_EVENT_BINLOG_IN_USE_F;
+      /* 
+         The only algorithm currently is CRC32. Zero indicates 
+         the binlog file is checksum-free *except* the FD-event.
+      */
+      DBUG_ASSERT(fd_alg == BINLOG_CHECKSUM_ALG_CRC32 || fd_alg == 0);
+      DBUG_ASSERT(alg == BINLOG_CHECKSUM_ALG_CRC32);
+      /*
+        Complile time guard to watch over  the max number of alg
+      */
+      compile_time_assert(BINLOG_CHECKSUM_ALG_ENUM_END <= 0x80);
+    }
+    incoming= uint4korr(event_buf + event_len - BINLOG_CHECKSUM_LEN);
+    computed= my_checksum(0L, NULL, 0);
+    /* checksum the event content but the checksum part itself */
+    computed= my_checksum(computed, (const uchar*) event_buf, 
+                          event_len - BINLOG_CHECKSUM_LEN);
+    if (flags != 0)
+    {
+      /* restoring the orig value of flags of FD */
+      DBUG_ASSERT(event_buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT);
+      event_buf[FLAGS_OFFSET]= flags;
+    }
+    res= !(computed == incoming);
+  }
+  return DBUG_EVALUATE_IF("simulate_checksum_test_failure", TRUE, res);
+}

=== modified file 'sql/server_ids.h'
--- a/sql/server_ids.h	2010-05-24 10:48:30 +0000
+++ b/sql/server_ids.h	2010-10-25 10:39:01 +0000
@@ -2,7 +2,8 @@
 
 #define SERVER_ID_H
 
-#include "my_sys.h"
+#include <my_sys.h>
+#include <sql_string.h>
 
 class Server_ids
 {
@@ -12,8 +13,8 @@ class Server_ids
     Server_ids();
     ~Server_ids();
 
-    bool pack_server_ids(char *buffer);
-    bool unpack_server_ids(const char *param_server_ids);
+    bool pack_server_ids(String *buffer);
+    bool unpack_server_ids(char *param_server_ids);
 };
 
 #endif

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2010-10-29 09:43:58 +0000
+++ b/sql/share/errmsg-utf8.txt	2010-11-23 23:10:22 +0000
@@ -6439,3 +6439,14 @@ ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MA
 ER_PARTITION_EXCHANGE_FOREIGN_KEY
   eng "Table to exchange with partition has foreign key references: '%-.64s'"
   swe "Tabellen att byta ut mot partition har foreign key referenser: '%-.64s'"
+ER_NO_SUCH_KEY_VALUE
+  eng "Key value '%-.192s' was not found in table '%-.192s.%-.192s'"
+ER_RPL_INFO_DATA_TOO_LONG
+  eng "Data for column '%s' too long"
+ER_CANT_LOCK_RPL_INFO_TABLE
+        eng "You can't use locks with rpl info tables."
+ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
+  eng "Replication event checksum verification failed while reading from network."
+ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE
+  eng "Replication event checksum verification failed while reading from a log file."
+

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2010-10-25 12:13:13 +0000
+++ b/sql/sql_base.cc	2010-11-15 16:43:41 +0000
@@ -4073,6 +4073,7 @@ thr_lock_type read_lock_type_for_table(T
   ulong binlog_format= thd->variables.binlog_format;
   if ((log_on == FALSE) || (binlog_format == BINLOG_FORMAT_ROW) ||
       (table_list->table->s->table_category == TABLE_CATEGORY_LOG) ||
+      (table_list->table->s->table_category == TABLE_CATEGORY_RPL_INFO) ||
       (table_list->table->s->table_category == TABLE_CATEGORY_PERFORMANCE) ||
       !(is_update_query(prelocking_ctx->sql_command) ||
         table_list->prelocking_placeholder ||

=== modified file 'sql/sql_base.h'
--- a/sql/sql_base.h	2010-10-05 09:15:51 +0000
+++ b/sql/sql_base.h	2010-11-15 16:43:41 +0000
@@ -127,6 +127,11 @@ TABLE *open_ltable(THD *thd, TABLE_LIST
   be open do not acquire global and schema-scope IX locks.
 */
 #define MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK         0x1000
+/**
+  When opening or locking a replication table through an internal
+  operation rather than explicitly through an user thread.
+*/
+#define MYSQL_LOCK_RPL_INFO_TABLE               0x2000
 
 /** Please refer to the internals manual. */
 #define MYSQL_OPEN_REOPEN  (MYSQL_OPEN_IGNORE_FLUSH |\

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2010-10-04 10:16:31 +0000
+++ b/sql/sql_binlog.cc	2010-11-23 23:10:22 +0000
@@ -151,8 +151,7 @@ void mysql_client_binlog_statement(THD*
   Relay_log_info *rli= thd->rli_fake;
   if (!rli)
   {
-    Rpl_info_factory::create_rli(RLI_REPOSITORY_FILE, FALSE, &rli);
-    if (rli)
+    if ((rli= Rpl_info_factory::create_rli(RLI_REPOSITORY_FILE, FALSE)))
     {
       thd->rli_fake= rli;
       rli->info_thd= thd;
@@ -242,7 +241,8 @@ void mysql_client_binlog_statement(THD*
         goto end;
 
       ev= Log_event::read_log_event(bufptr, event_len, &error,
-                                    rli->relay_log.description_event_for_exec);
+                                    rli->relay_log.description_event_for_exec,
+                                    0);
 
       DBUG_PRINT("info",("binlog base64 err=%s", error));
       if (!ev)

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-11-05 08:13:09 +0000
+++ b/sql/sql_class.h	2010-11-23 23:10:22 +0000
@@ -127,7 +127,7 @@ typedef struct st_user_var_events
 
 #define RP_LOCK_LOG_IS_ALREADY_LOCKED 1
 #define RP_FORCE_ROTATE               2
-
+#define RP_BINLOG_CHECKSUM_ALG_CHANGE 4
 /*
   The COPY_INFO structure is used by INSERT/REPLACE code.
   The schema of the row counting by the INSERT/INSERT ... ON DUPLICATE KEY
@@ -3609,6 +3609,11 @@ public:
 */
 #define CF_CAN_GENERATE_ROW_EVENTS (1U << 11)
 
+/**
+  Identifies statements that can directly update a rpl info table.
+*/
+#define CF_WRITE_RPL_INFO_COMMAND (1U << 12)
+
 /* Bits in server_command_flags */
 
 /**

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2010-10-27 14:46:44 +0000
+++ b/sql/sql_parse.cc	2010-11-23 23:10:22 +0000
@@ -301,7 +301,8 @@ void init_update_queries(void)
                                             CF_CAN_GENERATE_ROW_EVENTS;
   sql_command_flags[SQLCOM_CREATE_INDEX]=   CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
   sql_command_flags[SQLCOM_ALTER_TABLE]=    CF_CHANGES_DATA | CF_WRITE_LOGS_COMMAND |
-                                            CF_AUTO_COMMIT_TRANS | CF_PROTECT_AGAINST_GRL;
+                                            CF_AUTO_COMMIT_TRANS | CF_PROTECT_AGAINST_GRL |
+                                            CF_WRITE_RPL_INFO_COMMAND;
   sql_command_flags[SQLCOM_TRUNCATE]=       CF_CHANGES_DATA | CF_WRITE_LOGS_COMMAND |
                                             CF_AUTO_COMMIT_TRANS | CF_PROTECT_AGAINST_GRL;
   sql_command_flags[SQLCOM_DROP_TABLE]=     CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
@@ -434,10 +435,14 @@ void init_update_queries(void)
     The following admin table operations are allowed
     on log tables.
   */
-  sql_command_flags[SQLCOM_REPAIR]=    CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS;
-  sql_command_flags[SQLCOM_OPTIMIZE]|= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS;
-  sql_command_flags[SQLCOM_ANALYZE]=   CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS;
-  sql_command_flags[SQLCOM_CHECK]=     CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS;
+  sql_command_flags[SQLCOM_REPAIR]=    CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS |
+                                       CF_WRITE_RPL_INFO_COMMAND;
+  sql_command_flags[SQLCOM_OPTIMIZE]|= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS |
+                                       CF_WRITE_RPL_INFO_COMMAND;
+  sql_command_flags[SQLCOM_ANALYZE]=   CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS |
+                                       CF_WRITE_RPL_INFO_COMMAND;
+  sql_command_flags[SQLCOM_CHECK]=     CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS |
+                                       CF_WRITE_RPL_INFO_COMMAND;
 
   sql_command_flags[SQLCOM_CREATE_USER]|=       CF_AUTO_COMMIT_TRANS;
   sql_command_flags[SQLCOM_DROP_USER]|=         CF_AUTO_COMMIT_TRANS;
@@ -479,6 +484,17 @@ bool is_log_table_write_query(enum enum_
   return (sql_command_flags[command] & CF_WRITE_LOGS_COMMAND) != 0;
 }
 
+/**
+  Check if a sql command is allowed to write to rpl info tables.
+  @param command The SQL command
+  @return true if writing is allowed
+*/
+bool is_rpl_info_table_write_query(enum enum_sql_command command)
+{
+  DBUG_ASSERT(command >= 0 && command <= SQLCOM_END);
+  return (sql_command_flags[command] & CF_WRITE_RPL_INFO_COMMAND) != 0;
+}
+
 void execute_init_command(THD *thd, LEX_STRING *init_command,
                           mysql_rwlock_t *var_lock)
 {

=== modified file 'sql/sql_parse.h'
--- a/sql/sql_parse.h	2010-10-01 10:23:16 +0000
+++ b/sql/sql_parse.h	2010-11-15 16:43:41 +0000
@@ -80,6 +80,7 @@ bool check_identifier_name(LEX_STRING *s
 bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
 bool is_update_query(enum enum_sql_command command);
 bool is_log_table_write_query(enum enum_sql_command command);
+bool is_rpl_info_table_write_query(enum enum_sql_command command);
 bool alloc_query(THD *thd, const char *packet, uint packet_length);
 void mysql_init_select(LEX *lex);
 void mysql_parse(THD *thd, char *rawbuf, uint length,

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2010-11-02 11:53:54 +0000
+++ b/sql/sys_vars.cc	2010-11-23 23:10:22 +0000
@@ -408,7 +408,7 @@ static Sys_var_mybool Sys_binlog_direct(
 
 static const char *repository_names[]=
 {
-  "FILE", 0
+  "FILE", "TABLE", 0
 };
 
 ulong opt_mi_repository_id;
@@ -1877,8 +1877,52 @@ static Sys_var_set Slave_type_conversion
        GLOBAL_VAR(slave_type_conversions_options), CMD_LINE(REQUIRED_ARG),
        slave_type_conversions_name,
        DEFAULT(0));
+
+static Sys_var_mybool Sys_slave_sql_verify_checksum(
+       "slave_sql_verify_checksum",
+       "Force checksum verification of replication events after reading them "
+       "from relay log. Note: Events are always checksum-verified by slave on "
+       "receiving them from the network before writing them to the relay "
+       "log. Enabled by default.",
+       GLOBAL_VAR(opt_slave_sql_verify_checksum), CMD_LINE(OPT_ARG), DEFAULT(TRUE));
 #endif
 
+bool Sys_var_enum_binlog_checksum::global_update(THD *thd, set_var *var)
+{
+  mysql_mutex_lock(mysql_bin_log.get_log_lock());
+  if(mysql_bin_log.is_open())
+  {
+    uint flags= RP_FORCE_ROTATE | RP_LOCK_LOG_IS_ALREADY_LOCKED |
+      (binlog_checksum_options != (uint) var->save_result.ulonglong_value?
+       RP_BINLOG_CHECKSUM_ALG_CHANGE : 0);
+    if (flags & RP_BINLOG_CHECKSUM_ALG_CHANGE)
+      mysql_bin_log.checksum_alg_reset= (uint8) var->save_result.ulonglong_value;
+    mysql_bin_log.rotate_and_purge(flags);
+  }
+  else
+  {
+    binlog_checksum_options= var->save_result.ulonglong_value;
+  }
+  DBUG_ASSERT((ulong) binlog_checksum_options == var->save_result.ulonglong_value);
+  DBUG_ASSERT(mysql_bin_log.checksum_alg_reset == BINLOG_CHECKSUM_ALG_UNDEF);
+  mysql_mutex_unlock(mysql_bin_log.get_log_lock());
+  return 0;
+}
+
+static Sys_var_enum_binlog_checksum Binlog_checksum_enum(
+       "binlog_checksum", "Type of BINLOG_CHECKSUM_ALG. Include checksum for "
+       "log events in the binary log. Possible values are NONE and CRC32; "
+       "default is NONE.",
+       GLOBAL_VAR(binlog_checksum_options), CMD_LINE(REQUIRED_ARG),
+       binlog_checksum_type_names, DEFAULT(BINLOG_CHECKSUM_ALG_OFF),
+       NO_MUTEX_GUARD, NOT_IN_BINLOG);
+
+static Sys_var_mybool Sys_master_verify_checksum(
+       "master_verify_checksum",
+       "Force checksum verification of logged events in binary log before "
+       "sending them to slaves or printing them in output of SHOW BINLOG EVENTS. "
+       "Disabled by default.",
+       GLOBAL_VAR(opt_master_verify_checksum), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
 
 static Sys_var_ulong Sys_slow_launch_time(
        "slow_launch_time",

=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h	2010-10-26 09:10:59 +0000
+++ b/sql/sys_vars.h	2010-11-16 12:14:06 +0000
@@ -1674,6 +1674,24 @@ public:
   virtual bool session_update(THD *thd, set_var *var);
 };
 
+/**
+   A class for @@global.binlog_checksum that has
+   a specialized update method.
+*/
+class Sys_var_enum_binlog_checksum: public Sys_var_enum
+{
+public:
+  Sys_var_enum_binlog_checksum(const char *name_arg,
+          const char *comment, int flag_args, ptrdiff_t off, size_t size,
+          CMD_LINE getopt,
+          const char *values[], uint def_val, PolyLock *lock,
+          enum binlog_status_enum binlog_status_arg)
+    :Sys_var_enum(name_arg, comment, flag_args, off, size, getopt,
+                  values, def_val, lock, binlog_status_arg, NULL)
+  {}
+  virtual bool global_update(THD *thd, set_var *var);
+};
+
 /****************************************************************************
   Used templates
 ****************************************************************************/

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-10-21 12:18:25 +0000
+++ b/sql/table.cc	2010-11-15 16:43:41 +0000
@@ -51,6 +51,12 @@ LEX_STRING GENERAL_LOG_NAME= {C_STRING_W
 /* SLOW_LOG name */
 LEX_STRING SLOW_LOG_NAME= {C_STRING_WITH_LEN("slow_log")};
 
+/* RLI_INFO name */
+LEX_STRING RLI_INFO_NAME= {C_STRING_WITH_LEN("slave_relay_log_info")};
+
+/* MI_INFO name */
+LEX_STRING MI_INFO_NAME= {C_STRING_WITH_LEN("slave_master_info")};
+
 	/* Functions defined in this file */
 
 void open_table_error(TABLE_SHARE *share, int error, int db_errno,
@@ -260,6 +266,18 @@ TABLE_CATEGORY get_table_category(const
                        SLOW_LOG_NAME.str,
                        name->str) == 0))
       return TABLE_CATEGORY_LOG;
+
+    if ((name->length == RLI_INFO_NAME.length) &&
+        (my_strcasecmp(system_charset_info,
+                      RLI_INFO_NAME.str,
+                      name->str) == 0))
+      return TABLE_CATEGORY_RPL_INFO;
+
+    if ((name->length == MI_INFO_NAME.length) &&
+        (my_strcasecmp(system_charset_info,
+                      MI_INFO_NAME.str,
+                      name->str) == 0))
+      return TABLE_CATEGORY_RPL_INFO;
   }
 
   return TABLE_CATEGORY_USER;

=== modified file 'sql/table.h'
--- a/sql/table.h	2010-10-27 10:28:09 +0000
+++ b/sql/table.h	2010-11-15 16:43:41 +0000
@@ -440,7 +440,26 @@ enum enum_table_category
     The server implementation perform writes.
     Performance tables are cached in the table cache.
   */
-  TABLE_CATEGORY_PERFORMANCE=6
+  TABLE_CATEGORY_PERFORMANCE=6,
+
+  /**
+    Replication Information Tables.
+    These tables are used to store replication information.
+    These tables do *not* honor:
+    - LOCK TABLE t FOR READ/WRITE
+    - FLUSH TABLES WITH READ LOCK
+    - SET GLOBAL READ_ONLY = ON
+    as there is no point in locking explicitly
+    a Replication Information table.
+    An example of replication tables are:
+    - mysql.slave_master_info
+    - mysql.slave_relay_log_info,
+    which *are* updated even when there is either
+    a GLOBAL READ LOCK or a GLOBAL READ_ONLY in effect.
+    User queries do not write directly to these tables.
+    Replication tables are cached in the table cache.
+  */
+  TABLE_CATEGORY_RPL_INFO=7
 };
 typedef enum enum_table_category TABLE_CATEGORY;
 
@@ -750,11 +769,6 @@ struct TABLE_SHARE
             || (table_category == TABLE_CATEGORY_SYSTEM));
   }
 
-  inline bool require_write_privileges()
-  {
-    return (table_category == TABLE_CATEGORY_LOG);
-  }
-
   inline ulong get_table_def_version()
   {
     return table_map_id;


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20101201181106-37aecxha4jag7h10.bundle
Thread
bzr commit into mysql-trunk-wl4896 branch (chris.powers:3207) Christopher