List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:August 5 2008 2:51am
Subject:bzr push into mysql-6.0-backup branch (hezx:2691 to 2692) Bug#38374
View as plain text  
 2692 He Zhenxing	2008-08-04 [merge]
      Merge from mysql-5.1-rpl
removed:
  mysql-test/include/wait_show_pattern.inc
  mysql-test/include/wait_slave_status.inc
  mysql-test/suite/rpl/data/
  mysql-test/suite/rpl/t/rpl000018-master.opt
  mysql-test/suite/rpl/t/rpl000018-slave.opt
  mysql-test/suite/rpl/t/rpl_row_inexist_tbl-slave.opt
added:
  mysql-test/include/multi_range_count_basic.inc
  mysql-test/include/start_slave.inc
  mysql-test/include/stop_slave.inc
  mysql-test/include/sync_slave_io_with_master.inc
  mysql-test/include/wait_for_slave_io_error.inc
  mysql-test/include/wait_for_slave_io_to_start.inc
  mysql-test/lib/My/SysInfo.pm
  mysql-test/lib/My/Test.pm
  mysql-test/r/multi_range_count_basic_32.result
  mysql-test/r/multi_range_count_basic_64.result
  mysql-test/suite/rpl/r/rpl_bug26395.result
  mysql-test/suite/rpl/t/rpl_bug26395-master.opt
  mysql-test/suite/rpl/t/rpl_bug26395-slave.opt
  mysql-test/suite/rpl/t/rpl_bug26395.test
  mysql-test/t/multi_range_count_basic_32.test
  mysql-test/t/multi_range_count_basic_64.test
renamed:
  mysql-test/suite/rpl/data/rpl_bug28618.dat => mysql-test/std_data/rpl_bug28618.dat
  mysql-test/suite/rpl/data/rpl_mixed.dat => mysql-test/std_data/rpl_mixed.dat
  mysql-test/suite/rpl_ndb_big/r/rpl_ndb_transaction.result => mysql-test/suite/rpl_ndb_big/r/rpl_ndb_mixed_engines_transactions.result
  mysql-test/suite/rpl_ndb_big/t/rpl_ndb_transaction-master.opt => mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions-master.opt
  mysql-test/suite/rpl_ndb_big/t/rpl_ndb_transaction-slave.opt => mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions-slave.opt
  mysql-test/suite/rpl_ndb_big/t/rpl_ndb_transaction.test => mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions.test
modified:
  .bzrignore
  client/mysqltest.c
  mysql-test/Makefile.am
  mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test
  mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test
  mysql-test/extra/rpl_tests/rpl_log.test
  mysql-test/extra/rpl_tests/rpl_reset_slave.test
  mysql-test/include/have_log_bin.inc
  mysql-test/include/master-slave-reset.inc
  mysql-test/include/reset_master_and_slave.inc
  mysql-test/include/wait_for_slave_io_to_stop.inc
  mysql-test/include/wait_for_slave_param.inc
  mysql-test/include/wait_for_slave_sql_error.inc
  mysql-test/include/wait_for_slave_sql_to_start.inc
  mysql-test/include/wait_for_slave_sql_to_stop.inc
  mysql-test/include/wait_for_slave_to_start.inc
  mysql-test/include/wait_for_slave_to_stop.inc
  mysql-test/lib/My/ConfigFactory.pm
  mysql-test/lib/My/Options.pm
  mysql-test/lib/My/SafeProcess.pm
  mysql-test/lib/mtr_cases.pm
  mysql-test/lib/mtr_report.pm
  mysql-test/mysql-test-run.pl
  mysql-test/r/character_set_database_func.result
  mysql-test/r/func_time.result
  mysql-test/r/grant.result
  mysql-test/r/grant2.result
  mysql-test/r/innodb_max_dirty_pages_pct_func.result
  mysql-test/r/innodb_notembedded.result
  mysql-test/r/loaddata.result
  mysql-test/r/log_bin_trust_function_creators_func.result
  mysql-test/r/mysqlbinlog_base64.result
  mysql-test/r/query_cache.result
  mysql-test/r/query_cache_notembedded.result
  mysql-test/r/rpl_max_binlog_size_func.result
  mysql-test/r/subselect.result
  mysql-test/r/subselect_no_mat.result
  mysql-test/r/subselect_no_opts.result
  mysql-test/r/subselect_no_semijoin.result
  mysql-test/r/timezone2.result
  mysql-test/r/wait_timeout_func.result
  mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test
  mysql-test/suite/federated/federated_bug_25714.test
  mysql-test/suite/parts/inc/partition_layout_check1.inc
  mysql-test/suite/parts/inc/partition_layout_check2.inc
  mysql-test/suite/rpl/include/rpl_mixed_dml.inc
  mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result
  mysql-test/suite/rpl/r/rpl_flushlog_loop.result
  mysql-test/suite/rpl/r/rpl_found_rows.result
  mysql-test/suite/rpl/r/rpl_init_slave.result
  mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
  mysql-test/suite/rpl/r/rpl_log_pos.result
  mysql-test/suite/rpl/r/rpl_packet.result
  mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result
  mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result
  mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result
  mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result
  mysql-test/suite/rpl/r/rpl_row_log.result
  mysql-test/suite/rpl/r/rpl_row_log_innodb.result
  mysql-test/suite/rpl/r/rpl_row_stop_middle_update.result
  mysql-test/suite/rpl/r/rpl_row_until.result
  mysql-test/suite/rpl/r/rpl_slave_grp_exec.result
  mysql-test/suite/rpl/r/rpl_slave_skip.result
  mysql-test/suite/rpl/r/rpl_slave_status.result
  mysql-test/suite/rpl/r/rpl_sp.result
  mysql-test/suite/rpl/r/rpl_sp_effects.result
  mysql-test/suite/rpl/r/rpl_stm_log.result
  mysql-test/suite/rpl/r/rpl_stm_until.result
  mysql-test/suite/rpl/r/rpl_variables.result
  mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
  mysql-test/suite/rpl/t/rpl_dual_pos_advance.test
  mysql-test/suite/rpl/t/rpl_flushlog_loop.test
  mysql-test/suite/rpl/t/rpl_idempotency.test
  mysql-test/suite/rpl/t/rpl_incident.test
  mysql-test/suite/rpl/t/rpl_init_slave.test
  mysql-test/suite/rpl/t/rpl_insert.test
  mysql-test/suite/rpl/t/rpl_log_pos.test
  mysql-test/suite/rpl/t/rpl_packet.test
  mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test
  mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test
  mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test
  mysql-test/suite/rpl/t/rpl_row_until.test
  mysql-test/suite/rpl/t/rpl_server_id1.test
  mysql-test/suite/rpl/t/rpl_slave_grp_exec.test
  mysql-test/suite/rpl/t/rpl_slave_skip.test
  mysql-test/suite/rpl/t/rpl_slave_status.test
  mysql-test/suite/rpl/t/rpl_sp.test
  mysql-test/suite/rpl/t/rpl_sp_effects.test
  mysql-test/suite/rpl/t/rpl_stm_until.test
  mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result
  mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test
  mysql-test/suite/rpl_ndb_big/r/rpl_ndb_log.result
  mysql-test/suite/rpl_ndb_big/r/rpl_row_basic_7ndb.result
  mysql-test/t/backup_myisam1.test
  mysql-test/t/backup_security.test
  mysql-test/t/character_set_database_func.test
  mysql-test/t/disabled.def
  mysql-test/t/error_simulation.test
  mysql-test/t/func_time.test
  mysql-test/t/grant.test
  mysql-test/t/grant2.test
  mysql-test/t/innodb_max_dirty_pages_pct_func.test
  mysql-test/t/innodb_notembedded.test
  mysql-test/t/loaddata.test
  mysql-test/t/log_bin_trust_function_creators_func.test
  mysql-test/t/mysqlbinlog_base64.test
  mysql-test/t/query_cache.test
  mysql-test/t/query_cache_notembedded.test
  mysql-test/t/rpl_init_slave_func.test
  mysql-test/t/rpl_max_binlog_size_func.test
  mysql-test/t/subselect.test
  mysql-test/t/timezone2.test
  mysql-test/t/wait_timeout_func.test
  sql/set_var.cc
  mysql-test/suite/rpl_ndb_big/r/rpl_ndb_mixed_engines_transactions.result
  mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions-master.opt
  mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions.test

 2691 Chuck Bell	2008-07-28
      BUG#38374 Service interface throwing assertions in mysql-6.0-rpl tree after patch 
            
      Code throws assertion because the mysys_var settings were changed in the 
      ViewBaseObjectsIterator::create() method. The mysys_var must be set to
      NULL so that store_globals() can correctly reset it.
modified:
  sql/si_objects.cc

=== modified file '.bzrignore'
--- a/.bzrignore	2008-07-22 14:16:22 +0000
+++ b/.bzrignore	2008-08-04 14:30:50 +0000
@@ -1237,10 +1237,13 @@ sql/*.vcproj
 sql/.gdbinit
 sql/client.c
 sql/cscope.out
+sql/Doxyfile
 sql/f.c
 sql/gen_lex_hash
 sql/gmon.out
 sql/handlerton.cc
+sql/html
+sql/latex
 sql/lex_hash.h
 sql/link_sources
 sql/max/*
@@ -1289,6 +1292,8 @@ sql/share/slovak/
 sql/share/spanish/
 sql/share/swedish/
 sql/share/ukrainian/
+sql/share/norwegian-ny/errmsg.sys
+sql/share/norwegian/errmsg.sys
 sql/sql_builtin.cc
 sql/sql_select.cc.orig
 sql/sql_yacc.cc

=== modified file 'client/mysqltest.c'
--- a/client/mysqltest.c	2008-07-22 14:16:22 +0000
+++ b/client/mysqltest.c	2008-08-04 14:30:50 +0000
@@ -1353,23 +1353,21 @@ void show_diff(DYNAMIC_STRING* ds,
   if (init_dynamic_string(&ds_tmp, "", 256, 256))
     die("Out of memory");
 
-  /* First try with diff --help to see if the command exists at all */
+  /* First try with unified diff */
   if (run_tool("diff",
                &ds_tmp, /* Get output from diff in ds_tmp */
-               "--help",
+               "-u",
+               filename1,
+               filename2,
                "2>&1",
-               NULL) != 0) /* Most "diff --help" tools return 0 */
-  {
-    diff_failed= "You don't appear to have diff installed";
-  }
-  else
+               NULL) > 1) /* Most "diff" tools return >1 if error */
   {
     dynstr_set(&ds_tmp, "");
-    /* First try with unified diff */
 
+    /* Fallback to context diff with "diff -c" */
     if (run_tool("diff",
                  &ds_tmp, /* Get output from diff in ds_tmp */
-                 "-u",
+                 "-c",
                  filename1,
                  filename2,
                  "2>&1",
@@ -1377,17 +1375,17 @@ void show_diff(DYNAMIC_STRING* ds,
     {
       dynstr_set(&ds_tmp, "");
 
-      /* Fallback to context diff with "diff -c" */
+      /* Fallback to plain "diff" */
       if (run_tool("diff",
                    &ds_tmp, /* Get output from diff in ds_tmp */
-                   "-c",
                    filename1,
                    filename2,
                    "2>&1",
                    NULL) > 1) /* Most "diff" tools return >1 if error */
       {
         dynstr_set(&ds_tmp, "");
-        diff_failed= "Could not execute 'diff -u' or 'diff -c'";
+
+        diff_failed= "Could not execute 'diff -u', 'diff -c' or 'diff'";
       }
     }
   }

=== modified file 'mysql-test/Makefile.am'
--- a/mysql-test/Makefile.am	2008-07-23 09:31:19 +0000
+++ b/mysql-test/Makefile.am	2008-08-04 14:30:50 +0000
@@ -38,9 +38,11 @@ nobase_test_DATA = lib/mtr_cases.pm \
 	lib/My/Config.pm \
 	lib/My/Find.pm \
 	lib/My/Options.pm \
+	lib/My/Test.pm \
 	lib/My/Platform.pm \
 	lib/My/SafeProcess.pm \
 	lib/My/File/Path.pm \
+	lib/My/SysInfo.pm \
 	lib/My/SafeProcess/Base.pm \
 	lib/My/SafeProcess/safe_process.pl
 
@@ -63,7 +65,7 @@ TEST_DIRS = t r include std_data std_dat
 	suite/binlog suite/binlog/t suite/binlog/r suite/binlog/std_data \
 	suite/bugs/data suite/bugs/t suite/bugs/r \
 	suite/federated \
-	suite/funcs_1 suite/funcs_1/bitdata suite/funcs_1/data \
+	suite/funcs_1 suite/funcs_1/bitdata \
 	suite/funcs_1/include suite/funcs_1/lib suite/funcs_1/r \
 	suite/funcs_1/t suite/funcs_1/views suite/funcs_1/cursors \
 	suite/funcs_1/datadict suite/funcs_1/storedproc suite/funcs_1/triggers \

=== modified file 'mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test'
--- a/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test	2008-03-12 08:34:37 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test	2008-08-04 14:30:50 +0000
@@ -497,7 +497,7 @@ INSERT INTO t10 () VALUES(1,@b1,DEFAULT,
 --echo ********************************************
 --echo
 connection slave;
-wait_for_slave_to_stop;
+source include/wait_for_slave_sql_to_stop.inc;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
 --query_vertical SHOW SLAVE STATUS
@@ -554,7 +554,7 @@ INSERT INTO t11 () VALUES(1,@b1,'Testing
 --echo ********************************************
 --echo
 connection slave;
-wait_for_slave_to_stop;
+source include/wait_for_slave_sql_to_stop.inc;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
 --query_vertical SHOW SLAVE STATUS
@@ -697,7 +697,7 @@ SELECT c1,c3,hex(c4),c5,c6 FROM t14 ORDE
 # Remove below once fixed
 #***************************
 connection slave;
-wait_for_slave_to_stop;
+source include/wait_for_slave_sql_to_stop.inc;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
 --query_vertical SHOW SLAVE STATUS
@@ -763,7 +763,7 @@ SELECT c1,hex(c4),c5,c6,c7,c2 FROM t15 O
 --echo ********************************************
 --echo
 connection slave;
-wait_for_slave_to_stop;
+source include/wait_for_slave_sql_to_stop.inc;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
 --query_vertical SHOW SLAVE STATUS
@@ -840,7 +840,7 @@ SELECT c1,hex(c4),c5,c6,c7 FROM t16 ORDE
 --echo *****************
 --echo
 connection slave;
-wait_for_slave_to_stop;
+source include/wait_for_slave_sql_to_stop.inc;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
 --query_vertical SHOW SLAVE STATUS

=== modified file 'mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test'
--- a/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test	2008-03-06 18:32:47 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test	2008-07-10 16:09:39 +0000
@@ -94,7 +94,7 @@ SELECT * FROM t2 ORDER BY a;
 --echo *** Start Slave ***
 connection slave;
 START SLAVE;
-wait_for_slave_to_stop;
+source include/wait_for_slave_sql_to_stop.inc;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
 --query_vertical SHOW SLAVE STATUS
@@ -429,6 +429,7 @@ set @b1 = 'b1b1b1b1';
 set @b1 = concat(@b1,@b1);
 INSERT INTO t9 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
 
+connection slave;
 --source include/wait_for_slave_sql_to_stop.inc
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #

=== modified file 'mysql-test/extra/rpl_tests/rpl_log.test'
--- a/mysql-test/extra/rpl_tests/rpl_log.test	2008-04-08 06:34:40 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_log.test	2008-08-04 14:30:50 +0000
@@ -9,10 +9,8 @@
 # test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
 # We wait for the slave to have written all he wants to the binlog
 # (otherwise RESET MASTER may come too early).
-save_master_pos;
-connection slave;
-sync_with_master;
-stop slave;
+sync_slave_with_master;
+source include/stop_slave.inc;
 reset master;
 reset slave;
 # We are going to read the slave's binlog which contains file_id (for some LOAD
@@ -81,17 +79,14 @@ select * from t1 order by 1 asc;
 
 save_master_pos;
 connection slave;
-# Note that the above 'slave start' will cause a 3rd rotate event (a fake one)
-# to go into the relay log (the master always sends a fake one when replication
-# starts). 
-start slave;
-let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%';
---source include/wait_slave_status.inc
+source include/start_slave.inc;
+
 sync_with_master;
 #check t1 on slave to ensure whether it's identical with on master
 select * from t1 order by 1 asc;
 flush logs;
-stop slave;
+source include/stop_slave.inc;
+source include/start_slave.inc;
 connection master;
 
 # Create some entries for second log
@@ -104,10 +99,7 @@ source include/show_binlog_events.inc;
 --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 show binlog events in 'master-bin.000002';
 show binary logs;
-save_master_pos;
-connection slave;
-start slave;
-sync_with_master;
+sync_slave_with_master;
 show binary logs;
 --replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
 --replace_column 2 # 5 #

=== modified file 'mysql-test/extra/rpl_tests/rpl_reset_slave.test'
--- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test	2008-06-07 09:26:50 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test	2008-08-04 14:30:50 +0000
@@ -59,7 +59,7 @@ echo *** errno must be zero: $last_io_er
 
 change master to master_user='impossible_user_name';
 start slave;
-source include/wait_for_slave_io_to_stop.inc;
+source include/wait_for_slave_io_error.inc;
 let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
 --disable_query_log
 eval SELECT $last_io_errno > 0 as ONE;
@@ -81,7 +81,7 @@ let $last_io_error= query_get_value(SHOW
 stop slave;
 change master to master_user='impossible_user_name';
 start slave;
-source include/wait_for_slave_io_to_stop.inc;
+source include/wait_for_slave_io_error.inc;
 let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
 --disable_query_log
 eval SELECT $last_io_errno > 0 as ONE;

=== modified file 'mysql-test/include/have_log_bin.inc'
--- a/mysql-test/include/have_log_bin.inc	2008-07-04 16:41:27 +0000
+++ b/mysql-test/include/have_log_bin.inc	2008-08-04 14:30:50 +0000
@@ -1,3 +1,11 @@
+# ==== Purpose ====
+# 
+# Ensure that the server is running with binlogging on
+#
+# ==== Usage ====
+#
+# source include/have_log_bin.inc;
+
 -- require r/have_log_bin.require
 disable_query_log;
 show variables like 'log_bin';

=== modified file 'mysql-test/include/master-slave-reset.inc'
--- a/mysql-test/include/master-slave-reset.inc	2008-04-30 03:14:44 +0000
+++ b/mysql-test/include/master-slave-reset.inc	2008-08-04 14:30:50 +0000
@@ -1,9 +1,24 @@
+# Reset the master and the slave to start fresh.
+#
+# It is necessary to execute RESET MASTER and RESET SLAVE on both
+# master and slave since the replication setup might be circular.
+#
+# Since we expect STOP SLAVE to produce a warning as the slave is
+# stopped (the server was started with skip-slave-start), we disable
+# warnings when doing STOP SLAVE.
+
 connection slave;
 
 #we expect STOP SLAVE to produce a warning as the slave is stopped
 #(the server was started with skip-slave-start)
 --disable_warnings
 stop slave;
+--disable_query_log
+eval CHANGE MASTER TO MASTER_USER='root',
+                      MASTER_CONNECT_RETRY=1,
+                      MASTER_HOST='127.0.0.1',
+                      MASTER_PORT=$MASTER_MYPORT;
+--enable_query_log
 source include/wait_for_slave_to_stop.inc;
 --enable_warnings
 
@@ -15,6 +30,9 @@ use test;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 --enable_warnings
 reset master;
+--disable_query_log
+reset slave;
+--enable_query_log
 connection slave;
 
 --disable_warnings
@@ -31,10 +49,11 @@ drop table if exists t1,t2,t3,t4,t5,t6,t
 --enable_warnings
 
 --disable_query_log
-eval CHANGE MASTER TO MASTER_USER='root',
-                      MASTER_CONNECT_RETRY=1,
-                      MASTER_HOST='127.0.0.1',
-                      MASTER_PORT=$MASTER_MYPORT;
+#eval CHANGE MASTER TO MASTER_USER='root',
+#                      MASTER_CONNECT_RETRY=1,
+#                      MASTER_HOST='127.0.0.1',
+#                      MASTER_PORT=$MASTER_MYPORT;
+reset master;
 --enable_query_log
 
 start slave;

=== added file 'mysql-test/include/multi_range_count_basic.inc'
--- a/mysql-test/include/multi_range_count_basic.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/multi_range_count_basic.inc	2008-05-08 18:13:39 +0000
@@ -0,0 +1,219 @@
+############## mysql-test\t\multi_range_count_basic.test ###############
+#                                                                             #
+# Variable Name: multi_range_count                                            #
+# Scope: GLOBAL | SESSION                                                     #
+# Access Type: Dynamic                                                        #
+# Data Type: numeric                                                          #
+# Default Value:  256                                                         #
+# Range:1-4294967295                                                          #
+#                                                                             #
+#                                                                             #
+# Creation Date: 2008-02-07                                                   #
+# Author:  Salman                                                             #
+#                                                                             #
+# Description: Test Cases of Dynamic System Variable multi_range_count        #
+#              that checks the behavior of this variable in the following ways#
+#              * Default Value                                                #
+#              * Valid & Invalid values                                       #
+#              * Scope & Access method                                        #
+#              * Data Integrity                                               #
+#                                                                             #
+# Reference: http://dev.mysql.com/doc/refman/5.1/en/                          #
+#  server-system-variables.html                                               #
+#                                                                             #
+###############################################################################
+
+--source include/load_sysvars.inc
+
+#################################################################
+#           START OF multi_range_count TESTS                    #
+#################################################################
+
+
+#############################################################
+#                 Save initial value                        #
+#############################################################
+
+SET @start_global_value = @@global.multi_range_count;
+SELECT @start_global_value;
+SET @start_session_value = @@session.multi_range_count;
+SELECT @start_session_value;
+
+
+--echo '#--------------------FN_DYNVARS_090_01-------------------------#'
+#################################################################
+#     Display the DEFAULT value of multi_range_count            #
+#################################################################
+
+SET @@global.multi_range_count = 100;
+SET @@global.multi_range_count = DEFAULT;
+SELECT @@global.multi_range_count;
+
+SET @@session.multi_range_count = 200;
+SET @@session.multi_range_count = DEFAULT;
+SELECT @@session.multi_range_count;
+
+
+--echo '#--------------------FN_DYNVARS_090_02-------------------------#'
+#################################################################
+#     Check the DEFAULT value of multi_range_count              #
+#################################################################
+
+SET @@global.multi_range_count = DEFAULT;
+SELECT @@global.multi_range_count = 256;
+
+SET @@session.multi_range_count = DEFAULT;
+SELECT @@session.multi_range_count = 256;
+
+
+--echo '#--------------------FN_DYNVARS_090_03-------------------------#'
+###########################################################################
+# Change the value of multi_range_count to a valid value for GLOBAL Scope #
+###########################################################################
+
+SET @@global.multi_range_count = 1;
+SELECT @@global.multi_range_count;
+SET @@global.multi_range_count = 60020;
+SELECT @@global.multi_range_count;
+SET @@global.multi_range_count = 65535;
+SELECT @@global.multi_range_count;
+SET @@global.multi_range_count = 4294967295;
+SELECT @@global.multi_range_count;
+SET @@global.multi_range_count = 4294967294;
+SELECT @@global.multi_range_count;
+
+
+
+--echo '#--------------------FN_DYNVARS_090_04-------------------------#'
+############################################################################
+# Change the value of multi_range_count to a valid value for SESSION Scope #
+############################################################################
+ 
+SET @@session.multi_range_count = 1;
+SELECT @@session.multi_range_count;
+SET @@session.multi_range_count = 50050;
+SELECT @@session.multi_range_count;
+SET @@session.multi_range_count = 65535;
+SELECT @@session.multi_range_count;
+SET @@session.multi_range_count = 4294967295;
+SELECT @@session.multi_range_count;
+SET @@session.multi_range_count = 4294967294;
+SELECT @@session.multi_range_count;
+
+
+--echo '#------------------FN_DYNVARS_090_05-----------------------#'
+#############################################################
+# Change the value of multi_range_count to an invalid value #
+#############################################################
+
+SET @@global.multi_range_count = 0;
+SELECT @@global.multi_range_count;
+SET @@global.multi_range_count = 4294967296;
+SELECT @@global.multi_range_count;
+SET @@global.multi_range_count = -1024;
+SELECT @@global.multi_range_count;
+SET @@global.multi_range_count = 429496729500;
+SELECT @@global.multi_range_count;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.multi_range_count = 65530.34;
+SELECT @@global.multi_range_count;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.multi_range_count = test;
+SELECT @@global.multi_range_count;
+
+SET @@session.multi_range_count = 0;
+SELECT @@session.multi_range_count;
+SET @@session.multi_range_count = 4294967296;
+SELECT @@session.multi_range_count;
+SET @@session.multi_range_count = -1;
+SELECT @@session.multi_range_count;
+--Error ER_PARSE_ERROR
+SET @@session.multi_range_count = 65530.34.;
+SET @@session.multi_range_count = 4294967295021;
+SELECT @@session.multi_range_count;
+--echo 'Bug # 34837: Errors are not coming on assigning invalid values to variable';
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@session.multi_range_count = test;
+SELECT @@session.multi_range_count;
+
+
+--echo '#------------------FN_DYNVARS_090_06-----------------------#'
+####################################################################
+#   Check if the value in GLOBAL Table matches value in variable   #
+####################################################################
+
+
+SELECT @@global.multi_range_count = VARIABLE_VALUE 
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES 
+WHERE VARIABLE_NAME='multi_range_count';
+
+--echo '#------------------FN_DYNVARS_090_07-----------------------#'
+####################################################################
+#  Check if the value in SESSION Table matches value in variable   #
+####################################################################
+
+SELECT @@session.multi_range_count = VARIABLE_VALUE 
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES 
+WHERE VARIABLE_NAME='multi_range_count';
+
+
+--echo '#------------------FN_DYNVARS_090_08-----------------------#'
+####################################################################
+#     Check if TRUE and FALSE values can be used on variable       #
+####################################################################
+
+SET @@global.multi_range_count = TRUE;
+SELECT @@global.multi_range_count;
+SET @@global.multi_range_count = FALSE;
+SELECT @@global.multi_range_count;
+
+
+--echo '#---------------------FN_DYNVARS_090_09----------------------#'
+################################################################################# 
+#  Check if accessing variable with and without GLOBAL point to same variable   #
+################################################################################# 
+
+SET @@global.multi_range_count = 10;
+SELECT @@multi_range_count = @@global.multi_range_count;
+
+
+--echo '#---------------------FN_DYNVARS_090_10----------------------#'
+########################################################################################################
+#    Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable  #
+########################################################################################################
+
+SET @@multi_range_count = 100;
+SELECT @@multi_range_count = @@local.multi_range_count;
+SELECT @@local.multi_range_count = @@session.multi_range_count;
+
+
+--echo '#---------------------FN_DYNVARS_090_11----------------------#'
+############################################################################  
+#   Check if multi_range_count can be accessed with and without @@ sign    #
+############################################################################
+
+SET multi_range_count = 1;
+SELECT @@multi_range_count;
+--Error ER_UNKNOWN_TABLE
+SELECT local.multi_range_count;
+--Error ER_UNKNOWN_TABLE
+SELECT session.multi_range_count;
+--Error ER_BAD_FIELD_ERROR
+SELECT multi_range_count = @@session.multi_range_count;
+
+
+####################################
+#     Restore initial value        #
+####################################
+
+SET @@global.multi_range_count = @start_global_value;
+SELECT @@global.multi_range_count;
+SET @@session.multi_range_count = @start_session_value;
+SELECT @@session.multi_range_count;
+
+
+######################################################
+#                 END OF multi_range_count TESTS     #
+######################################################
+

=== modified file 'mysql-test/include/reset_master_and_slave.inc'
--- a/mysql-test/include/reset_master_and_slave.inc	2007-11-06 16:51:32 +0000
+++ b/mysql-test/include/reset_master_and_slave.inc	2008-07-10 16:09:39 +0000
@@ -1,10 +1,8 @@
 --echo **** Resetting master and slave ****
 connection slave;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 RESET SLAVE;
 connection master;
 RESET MASTER;
 connection slave;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/start_slave.inc;

=== added file 'mysql-test/include/start_slave.inc'
--- a/mysql-test/include/start_slave.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/start_slave.inc	2008-07-14 09:41:23 +0000
@@ -0,0 +1,21 @@
+# ==== Purpose ====
+#
+# Issues START SLAVE on the current connection. Then waits until both
+# the IO and SQL threads have started, or until a timeout is reached.
+#
+# Please use this instead of 'START SLAVE', to reduce the risk of test
+# case bugs.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_to_start.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
+
+--disable_query_log
+START SLAVE;
+--enable_query_log
+--echo include/start_slave.inc
+source include/wait_for_slave_to_start.inc;

=== added file 'mysql-test/include/stop_slave.inc'
--- a/mysql-test/include/stop_slave.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/stop_slave.inc	2008-07-14 09:41:23 +0000
@@ -0,0 +1,21 @@
+# ==== Purpose ====
+#
+# Issues STOP SLAVE on the current connection. Then waits until both
+# the IO and SQL threads have stopped, or until a timeout is reached.
+#
+# Please use this instead of 'STOP SLAVE', to reduce the risk of test
+# case bugs.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_to_start.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
+
+--disable_query_log
+STOP SLAVE;
+--enable_query_log
+--echo include/stop_slave.inc
+source include/wait_for_slave_to_stop.inc;

=== added file 'mysql-test/include/sync_slave_io_with_master.inc'
--- a/mysql-test/include/sync_slave_io_with_master.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/sync_slave_io_with_master.inc	2008-07-10 16:09:39 +0000
@@ -0,0 +1,36 @@
+# ==== Purpose ====
+#
+# Waits until the slave IO thread has been synced, i.e., all events
+# have been copied over to slave.  Does not care if the SQL thread is
+# in sync.
+#
+#
+# ==== Usage ====
+#
+# source include/sync_slave_io_with_master.inc;
+#
+# Syncs to the current position on master, as found by SHOW MASTER
+# STATUS.
+#
+# Must be called on the master. Will change connection to the slave.
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
+
+let $_master_file= query_get_value("SHOW MASTER STATUS", File, 1);
+let $_master_pos= query_get_value("SHOW MASTER STATUS", Position, 1);
+
+connection slave;
+
+let $slave_error_message= Failed while waiting for slave IO thread to sync;
+
+let $slave_param= Master_Log_File;
+let $slave_param_value= $_master_file;
+source include/wait_for_slave_param.inc;
+
+let $slave_param= Read_Master_Log_Pos;
+let $slave_param_value= $_master_pos;
+source include/wait_for_slave_param.inc;
+
+let $slave_error_message= ;

=== added file 'mysql-test/include/wait_for_slave_io_error.inc'
--- a/mysql-test/include/wait_for_slave_io_error.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/wait_for_slave_io_error.inc	2008-08-04 14:30:50 +0000
@@ -0,0 +1,23 @@
+# ==== Purpose ====
+#
+# Waits until the IO thread of the current connection has got an
+# error, or until a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_io_error.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
+
+let $old_slave_param_comparison= $slave_param_comparison;
+
+let $slave_param= Last_IO_Errno;
+let $slave_param_comparison= !=;
+let $slave_param_value= 0;
+let $slave_error_message= Failed while waiting for slave to produce an error in its sql thread;
+source include/wait_for_slave_param.inc;
+let $slave_error_message= ;
+
+let $slave_param_comparison= $old_slave_param_comparison;

=== added file 'mysql-test/include/wait_for_slave_io_to_start.inc'
--- a/mysql-test/include/wait_for_slave_io_to_start.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/wait_for_slave_io_to_start.inc	2008-07-23 11:23:52 +0000
@@ -0,0 +1,19 @@
+# ==== Purpose ====
+#
+# Waits until the IO thread of the current connection has started and
+# connected to the master (i.e., until SHOW SLAVE STATUS returns Yes
+# in the Slave_IO_Running field), or until a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_io_to_start.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
+
+let $slave_param= Slave_IO_Running;
+let $slave_param_value= Yes;
+let $slave_error_message= Failed while waiting for slave IO thread to start;
+source include/wait_for_slave_param.inc;
+let $slave_error_message= ;

=== modified file 'mysql-test/include/wait_for_slave_io_to_stop.inc'
--- a/mysql-test/include/wait_for_slave_io_to_stop.inc	2007-06-19 11:06:11 +0000
+++ b/mysql-test/include/wait_for_slave_io_to_stop.inc	2008-07-10 16:09:39 +0000
@@ -1,33 +1,18 @@
-###################################################
-#Author: Jeb
-#Date: 2007-06-11
-#Purpose: used for io errors on the slave. If Slave gets an io
-#         error, the io trhead should stop
-#Details:
-#      1) Fill in and setup variables
-#      2) loop through looking for
-#         sql threads to stop
-#      3) If loops too long die.
-####################################################
-connection slave;
-let $my_show= SHOW SLAVE STATUS;
-let $sql_running= Slave_IO_Running;
-let $row_number= 1;
-let $run= 1;
-let $counter= 300;
-
-while ($run)
-{
-  let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number);
-  if (`SELECT '$io_result' = 'No'`){
-    let $run= 0;
-  }
-  sleep 0.1;
-  if (!$counter){
-    --echo "Failed while waiting for slave IO thread to stop"
-    query_vertical SHOW SLAVE STATUS;
-    exit;
-  }
-  dec $counter;
-}
+# ==== Purpose ====
+#
+# Waits until the IO thread of the current connection has stopped, or
+# until a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_io_to_stop.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
 
+let $slave_param= Slave_IO_Running;
+let $slave_param_value= No;
+let $slave_error_message= Failed while waiting for slave IO thread to stop;
+source include/wait_for_slave_param.inc;
+let $slave_error_message= ;

=== modified file 'mysql-test/include/wait_for_slave_param.inc'
--- a/mysql-test/include/wait_for_slave_param.inc	2007-06-15 11:09:28 +0000
+++ b/mysql-test/include/wait_for_slave_param.inc	2008-07-10 16:09:39 +0000
@@ -1,26 +1,94 @@
-# include/wait_for_slave_param.inc
+# ==== Purpose ====
 #
-# SUMMARY
+# Waits until SHOW SLAVE STATUS has returned a specified value, or
+# until a timeout is reached.
 #
-#    Waits until SHOW SLAVE STATUS has returned a spicified value.
+# ==== Usage ====
 #
-# USAGE
+# let $slave_param= Slave_SQL_Running;
+# let $slave_param_value= No;
+# --source include/slave_wait_param.inc
 #
-#    let $slave_param= Slave_SQL_Running;
-#    let $slave_param_value= No;
-#    --source include/slave_wait_param.inc
+# Parameters:
+#
+# $slave_param, $slave_param_value
+#   This macro will wait until the column of the output of SHOW SLAVE
+#   STATUS named $slave_param gets the value $slave_param_value.  See
+#   the example above.
+#
+# $slave_param_comparison
+#   By default, this file waits until $slave_param becomes equal to
+#   $slave_param_value.  If you want to wait until $slave_param
+#   becomes *unequal* to $slave_param_value, set this parameter to the
+#   string '!=', like this:
+#     let $slave_param_comparison= !=;
+#
+# $slave_timeout
+#   The default timeout is 5 minutes. You can change the timeout by
+#   setting $slave_timeout. The unit is tenths of seconds.
+#
+# $slave_keep_connection
+#   If the timeout is reached, debug info is given by calling SHOW
+#   SLAVE STATUS, SHOW PROCESSLIST, and SHOW BINLOG EVENTS.  By
+#   default (assuming the current connection is slave), a 'connection
+#   master' is then issued, and the same information is printed again
+#   on the master host.  You can avoid switching to master (and thus
+#   suppress debug info on master too) by setting
+#   $slave_keep_connection to 1.
+#
+# $slave_error_message
+#   If set, this is printed when a timeout occurs. This is primarily
+#   intended to be used by other wait_for_slave_* macros, to indicate
+#   what the purpose of the wait was. (A very similar error message is
+#   given by default, but the wait_for_slave_* macros use this to give
+#   an error message identical to that in previous versions, so that
+#   errors are easier searchable in the pushbuild history.)
+
+let $_slave_timeout_counter= $slave_timeout;
+if (!$_slave_timeout_counter)
+{
+  let $_slave_timeout_counter= 3000;
+}
+
+let $_slave_param_comparison= $slave_param_comparison;
+if (`SELECT '$_slave_param_comparison' = ''`)
+{
+  let $_slave_param_comparison= =;
+}
 
-let $slave_wait_param_counter= 300;
-let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
-while (`select "$slave_value" != "$slave_param_value"`)
+let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
+while (`SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value')`)
 {
-  dec $slave_wait_param_counter;
-  if (!$slave_wait_param_counter)
+  if (!$_slave_timeout_counter)
   {
-    --echo ERROR: failed while waiting for slave parameter $slave_param: $slave_param_value
-    query_vertical show slave status;
+    --echo **** ERROR: failed while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
+    if (`SELECT '$slave_error_message' != ''`)
+    {
+      --echo Message: $slave_error_message
+    }
+    --echo Note: the following output may have changed since the failure was detected
+    --echo **** Showing SLAVE STATUS, PROCESSLIST, and BINLOG EVENTS on slave ****
+    query_vertical SHOW SLAVE STATUS;
+    SHOW PROCESSLIST;
+    let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
+    eval SHOW BINLOG EVENTS IN '$binlog_name';
+    if (!$slave_keep_connection) {
+      let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1);
+      let $master_binlog_name_sql= query_get_value("SHOW SLAVE STATUS", Relay_Master_Log_File, 1);
+      --echo **** Showing MASTER STATUS, PROCESSLIST, and BINLOG EVENTS on master ****
+      --echo [on master]
+      connection master;
+      query_vertical SHOW MASTER STATUS;
+      SHOW PROCESSLIST;
+      eval SHOW BINLOG EVENTS IN '$master_binlog_name_sql';
+      if (`SELECT '$master_binlog_name_io' != '$master_binlog_name_sql'`)
+      {
+        eval SHOW BINLOG EVENTS IN '$master_binlog_name_io';
+      }
+    }
     exit;
   }
+  dec $_slave_timeout_counter;
   sleep 0.1;
-  let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
+  let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
 }

=== modified file 'mysql-test/include/wait_for_slave_sql_error.inc'
--- a/mysql-test/include/wait_for_slave_sql_error.inc	2007-10-10 16:10:54 +0000
+++ b/mysql-test/include/wait_for_slave_sql_error.inc	2008-07-10 16:09:39 +0000
@@ -1,33 +1,23 @@
-###################################################
-#Author: Sven
-#Date: 2007-10-09
-#Purpose: Wait until the slave has an error in the
-#         sql thread, as indicated by
-#         "SHOW SLAVE STATUS", or at most 30
-#         seconds.
-#Details:
-#      1) Fill in and setup variables
-#      2) loop, looking for sql error on slave
-#      3) If it loops too long, die.
-####################################################
-connection slave;
-let $row_number= 1;
-let $run= 1;
-let $counter= 300;
+# ==== Purpose ====
+#
+# Waits until the SQL thread of the current connection has got an
+# error, or until a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_sql_error.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
 
-while ($run)
-{
-  let $sql_result= query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, $row_number);
-  let $run= `SELECT '$sql_result' = '0'`;
-  if ($run) {
-    real_sleep 0.1;
-    if (!$counter){
-      --echo "Failed while waiting for slave to produce an error in its sql thread"
-      --replace_result $MASTER_MYPORT MASTER_PORT
-      --replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
-      query_vertical SHOW SLAVE STATUS;
-      exit;
-    }
-    dec $counter;
-  }
-}
+let $old_slave_param_comparison= $slave_param_comparison;
+
+let $slave_param= Last_SQL_Errno;
+let $slave_param_comparison= !=;
+let $slave_param_value= 0;
+let $slave_error_message= Failed while waiting for slave to produce an error in its sql thread;
+source include/wait_for_slave_param.inc;
+let $slave_error_message= ;
+
+let $slave_param_comparison= $old_slave_param_comparison;

=== modified file 'mysql-test/include/wait_for_slave_sql_to_start.inc'
--- a/mysql-test/include/wait_for_slave_sql_to_start.inc	2008-06-22 20:05:19 +0000
+++ b/mysql-test/include/wait_for_slave_sql_to_start.inc	2008-08-04 14:30:50 +0000
@@ -1,33 +1,17 @@
-###################################################
-#Author:  Mats (based on file written by Jeb)
-#Date:    2008-05-06
-#Purpose: To wait for slave SQL thread to start
-#Details:
-#      1) Fill in and setup variables
-#      2) loop through looking for both
-#         io and sql threads to start
-#      3) If loops too long die.
-####################################################
-if (!$keep_connection) {
-connection slave;
-}
-let $row_number= 1;
-let $run= 1;
-let $counter= 300;
-
-while ($run)
-{
-  let $sql_result= query_get_value("SHOW SLAVE STATUS",  Slave_SQL_Running, $row_number);
-  if (`SELECT '$sql_result' = 'Yes'`){
-    let $run= 0;
-  }
-  sleep 0.1;
-  if (!$counter){
-    --echo "Failed while waiting for slave SQL to start"
-    query_vertical SHOW SLAVE STATUS;
-    exit;
-  }
-  dec $counter;
-}
-
+# ==== Purpose ====
+#
+# Waits the SQL thread of the current connection has started, or until
+# a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_sql_to_start.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
 
+let $slave_param= Slave_SQL_Running;
+let $slave_param_value= Yes;
+let $slave_error_message= Failed while waiting for slave SQL to start;
+source include/wait_for_slave_param.inc;

=== modified file 'mysql-test/include/wait_for_slave_sql_to_stop.inc'
--- a/mysql-test/include/wait_for_slave_sql_to_stop.inc	2008-02-27 17:46:06 +0000
+++ b/mysql-test/include/wait_for_slave_sql_to_stop.inc	2008-07-10 16:09:39 +0000
@@ -1,33 +1,18 @@
-###################################################
-#Author: Jeb
-#Date: 2007-06-11
-#Purpose: used for SQL errors on the slave. If Slave gets a sql
-#         error, the SQL trhead should stop
-#Details:
-#      1) Fill in and setup variables
-#      2) loop through looking for
-#         sql threads to stop
-#      3) If loops too long die.
-####################################################
-if (!$keep_connection)
-{
-  connection slave;
-}
-let $row_number= 1;
-let $run= 1;
-let $counter= 300;
+# ==== Purpose ====
+#
+# Waits the SQL thread of the current connection has stopped, or until
+# a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_sql_to_stop.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
 
-while ($run)
-{
-  let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number);
-  if (`SELECT '$sql_result' = 'No'`){
-    let $run= 0;
-  }
-  sleep 0.1;
-  if (!$counter){
-    --echo "Failed while waiting for slave SQL thread to stop"
-    query_vertical SHOW SLAVE STATUS;
-    exit;
-  }
-  dec $counter;
-}
+let $slave_param= Slave_SQL_Running;
+let $slave_param_value= No;
+let $slave_error_message= Failed while waiting for slave SQL thread to stop;
+source include/wait_for_slave_param.inc;
+let $slave_error_message= ;

=== modified file 'mysql-test/include/wait_for_slave_to_start.inc'
--- a/mysql-test/include/wait_for_slave_to_start.inc	2008-06-22 20:05:19 +0000
+++ b/mysql-test/include/wait_for_slave_to_start.inc	2008-08-04 14:30:50 +0000
@@ -1,40 +1,24 @@
-###################################################
-#Author: Jeb
-#Date: 2007-06-11
-#Purpose: To wait a brief time for slave to start
-#Details:
-#      1) Fill in and setup variables
-#      2) loop through looking for both
-#         io and sql threads to start
-#      3) If loops too long die.
-####################################################
-if (!$keep_connection) {
-connection slave;
-}
-let $row_number= 1;
-let $run= 1;
-let $counter= 300;
+# ==== Purpose ====
+#
+# Waits until both the IO and SQL threads of the current connection
+# have started, or until a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_to_start.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
 
-while ($run)
-{
-  let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number);
-  if (`SELECT '$io_result' = 'Yes'`){
+let $slave_error_message= Failed while waiting for slave to start;
 
-    let $sql_result= query_get_value("SHOW SLAVE STATUS",  Slave_SQL_Running, $row_number);
-    if (`SELECT '$sql_result' = 'Yes'`){
-      let $run= 0;
-    }
-  }
-  sleep 0.1;
-  if (!$counter){
-    --echo "Failed while waiting for slave to start"
-    --replace_result $MASTER_MYPORT MASTER_PORT
-#   --replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
-    --replace_column 1 # 8 # 9 # 23 # 33 #
-    query_vertical SHOW SLAVE STATUS;
-    exit;
-  }
-  dec $counter;
-}
+let $slave_param= Slave_IO_Running;
+let $slave_param_value= Yes;
+source include/wait_for_slave_param.inc;
 
+let $slave_param= Slave_SQL_Running;
+let $slave_param_value= Yes;
+source include/wait_for_slave_param.inc;
 
+let $slave_error_message= ;

=== modified file 'mysql-test/include/wait_for_slave_to_stop.inc'
--- a/mysql-test/include/wait_for_slave_to_stop.inc	2008-06-23 07:49:15 +0000
+++ b/mysql-test/include/wait_for_slave_to_stop.inc	2008-08-04 14:30:50 +0000
@@ -1,41 +1,24 @@
-###################################################
-#Author: Jeb
-#Date: 2007-06-11
-#Purpose: To replace the mysqltest.c executable 
-#         wait_for_slave_to_stop function and
-#         return this to the test language.
-#Details:
-#      1) Fill in and setup variables
-#      2) loop through looking for both
-#         io and sql threads to stop
-#      3) If loops too long die.
-####################################################
-if (!$keep_connection) {
-connection slave;
-}
-let $row_number= 1;
-let $run= 1;
-let $counter= 300;
+# ==== Purpose ====
+#
+# Waits until both the IO and SQL threads of the current connection
+# have stopped, or until a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_to_stop.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
 
-while ($run)
-{
-  let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number);
-  if (`SELECT ('$io_result' = 'No' OR '$io_result' = 'No such row')`) {
+let $slave_error_message= Failed while waiting for slave to stop;
 
-    let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number);
-    if (`SELECT ('$sql_result' = 'No' OR '$io_result' = 'No such row')`) {
-      let $run= 0;
-    }
-  }
-  sleep 0.1;
-  if (!$counter){
-    --echo "Failed while waiting for slave to stop"
-    --replace_result $MASTER_MYPORT MASTER_PORT
-    --replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
-    query_vertical SHOW SLAVE STATUS;
-    exit;
-  }
-  dec $counter;
-}
+let $slave_param= Slave_IO_Running;
+let $slave_param_value= No;
+source include/wait_for_slave_param.inc;
 
+let $slave_param= Slave_SQL_Running;
+let $slave_param_value= No;
+source include/wait_for_slave_param.inc;
 
+let $slave_error_message= ;

=== removed file 'mysql-test/include/wait_show_pattern.inc'
--- a/mysql-test/include/wait_show_pattern.inc	2007-12-20 17:38:23 +0000
+++ b/mysql-test/include/wait_show_pattern.inc	1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
-# include/wait_show_pattern.inc
-#
-# SUMMARY
-#
-#   Waits until output produced by SHOW statement which particular type is
-#   specified as parameter matches certain pattern or maximum time reached.
-#
-# NOTES
-#
-#   Only the first row produced by the parameter statement is checked.
-#
-# USAGE
-#
-#   let $show_type= <Tail of SHOW statement>;
-#   let $show_pattern= 'Pattern to be used for LIKE matching';
-#   --source wait_show_pattern.inc
-#
-# EXAMPLES
-# 
-#   alter_table-big.test, wait_slave_status.inc
-#
-# SEE ALSO
-#
-#   wait_slave_status.inc, wait_condition.inc (>=5.1)
-#
-###############################################################################
-
---disable_query_log
-
-# We accept to wait maximum 30 seconds (0.2 sec/loop).
-let $wait_counter= 150;
-while ($wait_counter)
-{
-  let $result= `SHOW $show_type`;
-  let $success= `SELECT "$result" LIKE $show_pattern`;
-  if ($success)
-  {
-    let $wait_counter= 0;
-  }
-  if (!$success)
-  {
-    real_sleep 0.2;
-    dec $wait_counter;
-  }
-}
-if (!$success)
-{
-  echo Timeout in wait_show_pattern.inc \$show_type= $show_type \$show_pattern= $show_pattern (\$result= '$result');
-}
-
---enable_query_log

=== removed file 'mysql-test/include/wait_slave_status.inc'
--- a/mysql-test/include/wait_slave_status.inc	2007-01-19 20:15:59 +0000
+++ b/mysql-test/include/wait_slave_status.inc	1970-01-01 00:00:00 +0000
@@ -1,129 +0,0 @@
-# include/wait_slave_status.inc
-#
-# Created by Matthias Leich
-#
-# SUMMARY
-#
-#    Waits until slave has reached certain state or maximum time reached.
-#
-#    (This script will not work, when the SHOW command delivers more than one 
-#    result record, because only the first record will be caught.)
-#
-# USAGE
-#
-#    Set $result_pattern in test file and source this file:
-#
-#      let $result_pattern= <pattern used for LIKE on the result of
-#                           SHOW STATUS SLAVE>
-#      --include wait_slave_status.inc
-#
-# EXAMPLE
-#
-#    The script rpl_until.test:
-#       ...
-#       --replace_result $MASTER_MYPORT MASTER_MYPORT
-#       --replace_column 1 # 9 # 23 # 33 #
-#       --vertical_results show slave status;
-#
-#    outputs
-#       show slave status;
-#       Slave_IO_State  #
-#       Master_Host     127.0.0.1
-#       Master_User     root
-#       Master_Port     MASTER_MYPORT
-#       Connect_Retry   1
-#       Master_Log_File master-bin.000001
-#       Read_Master_Log_Pos     776
-#       Relay_Log_File  slave-relay-bin.000004
-#       Relay_Log_Pos   #
-#       Relay_Master_Log_File   master-bin.000001
-#       Slave_IO_Running        Yes
-#       Slave_SQL_Running       No
-#       Replicate_Do_DB
-#       Replicate_Ignore_DB
-#       Replicate_Do_Table
-#       Replicate_Ignore_Table
-#       Replicate_Wild_Do_Table
-#       Replicate_Wild_Ignore_Table
-#       Last_Errno      0
-#       Last_Error
-#       Skip_Counter    0
-#       Exec_Master_Log_Pos     319
-#       Relay_Log_Space #
-#       Until_Condition Master
-#       Until_Log_File  master-bin.000001
-#       Until_Log_Pos   319
-#       Master_SSL_Allowed      No
-#       Master_SSL_CA_File
-#       Master_SSL_CA_Path
-#       Master_SSL_Cert
-#       Master_SSL_Cipher
-#       Master_SSL_Key
-#       Seconds_Behind_Master   #
-#
-# The main problem with the "show slave status;" in rpl_until is, that
-# depending on the total test engine power and the current load caused by
-# other processes, the expected slave status might be not reached though
-# it will happen in maybe some seconds.
-#
-# The typical problem with rpl_until is that Slave_IO_Running is "No"
-# instead of "Yes".
-#
-# The expected result follows the LIKE pattern:
-#
-#   let $result_pattern= '%127.0.0.1%root%1%master-bin.000001%776%slave-relay-bin.000004%master-bin.000001%Yes%No%0%0%319%Master%master-bin.000001%319%No%';
-#
-# The Slave_IO_Running value is the "Yes" just after the "master-bin.000001".
-#
-# How to get this pattern ?
-#
-#     Any lines "--replace_result ..." and "--replace_colum ..." just before
-#     the SHOW TABLE STATUS and of course the expected result itself
-#     show us columns where the content must be unified, because it is non
-#     deterministic or it depends on the current test environment.
-#
-#     Unfortunately "--replace_result ..." and "--replace_colum ..." do not
-#     affect the result of our assignment    let $my_val= `SHOW SLAVE STATUS`;
-#     Therefore such content must be covered by '%'.
-#
-#     Please be careful. A more simple pattern might be dangerous, because we
-#     might get "wrong" matches. Example: There might be several "Yes" and "No"
-#     within one result row.
-#
-###############################################################################
-
-# We do not want to print the auxiliary commands, because they are not of
-# interest and their amount will vary depending how fast we get the
-# desired state.
---disable_query_log
-
-# The protocol should show
-# - the setting of $result_pattern   and
-# - that this file is sourced           ,
-# because this increases the chance to use the protocol as replay script.
-eval SELECT "let \$result_pattern= $result_pattern ;" AS "";
-SELECT '--source include/wait_slave_status.inc' AS "";
-
-let $show_type= SLAVE STATUS;
-let $show_pattern= $result_pattern;
---enable_query_log
-
---source include/wait_show_pattern.inc
-
-if (!$success)
-{
-let $message= ! Attention: Timeout in wait_slave_status.inc.
-              |       Possible reasons with decreasing probability:
-              |       - The LIKE pattern is wrong, because the
-              |         testcase was altered or the layout of the
-              |         SHOW SLAVE STATUS result set changed.
-              |       - There is a new bug within the replication.
-              |       - We met an extreme testing environment and timeout is
-              |         too small.;
---source include/show_msg80.inc
---echo DEBUG INFO START (wait_slave_status.inc):
---echo $result_pattern
---vertical_results
-show slave status;
---echo DEBUG INFO END
-}

=== modified file 'mysql-test/lib/My/ConfigFactory.pm'
--- a/mysql-test/lib/My/ConfigFactory.pm	2008-04-25 14:09:25 +0000
+++ b/mysql-test/lib/My/ConfigFactory.pm	2008-06-19 08:07:55 +0000
@@ -104,10 +104,16 @@ sub fix_server_id {
 sub fix_socket {
   my ($self, $config, $group_name, $group)= @_;
   # Put socket file in tmpdir
-  my $dir= $group->value('tmpdir');
+  my $dir= $self->{ARGS}->{tmpdir};
   return "$dir/$group_name.sock";
 }
 
+sub fix_tmpdir {
+  my ($self, $config, $group_name, $group)= @_;
+  my $dir= $self->{ARGS}->{tmpdir};
+  return "$dir/$group_name";
+}
+
 sub fix_log_error {
   my ($self, $config, $group_name, $group)= @_;
   my $dir= dirname($group->value('datadir'));
@@ -182,7 +188,7 @@ sub fix_ssl_client_key {
 my @mysqld_rules=
   (
  { 'basedir' => sub { return shift->{ARGS}->{basedir}; } },
- { 'tmpdir' => sub { return shift->{ARGS}->{tmpdir}; } },
+ { 'tmpdir' => \&fix_tmpdir },
  { 'character-sets-dir' => \&fix_charset_dir },
  { 'language' => \&fix_language },
  { 'datadir' => \&fix_datadir },
@@ -295,6 +301,16 @@ my @mysqlbinlog_rules=
 
 
 #
+# Rules to run for [mysql_upgrade] section
+#  - will be run in order listed here
+#
+my @mysql_upgrade_rules=
+(
+ { 'tmpdir' => sub { return shift->{ARGS}->{tmpdir}; } },
+);
+
+
+#
 # Generate a [client.<suffix>] group to be
 # used for connecting to [mysqld.<suffix>]
 #
@@ -600,6 +616,11 @@ sub new_config {
 			     $config->insert('mysqlbinlog'),
 			     @mysqlbinlog_rules);
 
+  # [mysql_upgrade] need additional settings
+  $self->run_rules_for_group($config,
+			     $config->insert('mysql_upgrade'),
+			     @mysql_upgrade_rules);
+
   # Additional rules required for [client]
   $self->run_rules_for_group($config,
 			     $config->insert('client'),

=== modified file 'mysql-test/lib/My/Options.pm'
--- a/mysql-test/lib/My/Options.pm	2008-01-08 14:47:04 +0000
+++ b/mysql-test/lib/My/Options.pm	2008-04-24 11:02:53 +0000
@@ -61,6 +61,9 @@ sub _split_option {
   elsif ($option=~ /^--(.*)$/){
     return ($1, undef)
   }
+  elsif ($option=~ /^\$(.*)$/){ # $VAR
+    return ($1, undef)
+  }
   elsif ($option=~ /^(.*)=(.*)$/){
     return ($1, $2)
   }

=== modified file 'mysql-test/lib/My/SafeProcess.pm'
--- a/mysql-test/lib/My/SafeProcess.pm	2008-04-02 08:08:44 +0000
+++ b/mysql-test/lib/My/SafeProcess.pm	2008-04-27 19:31:32 +0000
@@ -65,7 +65,7 @@ END {
   # Kill any children still running
   for my $proc (values %running){
     if ( $proc->is_child($$) ){
-      print "Killing: $proc\n";
+      #print "Killing: $proc\n";
       $proc->kill();
     }
   }
@@ -128,6 +128,7 @@ sub new {
   my $verbose  = delete($opts{'verbose'});
   my $host     = delete($opts{'host'});
   my $shutdown = delete($opts{'shutdown'});
+  my $user_data= delete($opts{'user_data'});
 
 #  if (defined $host) {
 #    $safe_script=  "lib/My/SafeProcess/safe_process_cpcd.pl";
@@ -173,6 +174,7 @@ sub new {
       SAFE_NAME => $name,
       SAFE_SHUTDOWN => $shutdown,
       PARENT => $$,
+      SAFE_USER_DATA => $user_data,
      }, $class);
 
   # Put the new process in list of running
@@ -461,8 +463,8 @@ sub wait_one {
     return 1;
   }
 
-  warn "wait_one: expected pid $pid but got $retpid"
-    unless( $retpid == $pid );
+  #warn "wait_one: expected pid $pid but got $retpid"
+  #  unless( $retpid == $pid );
 
   $self->_collect();
   return 0;
@@ -546,4 +548,16 @@ sub _verbose {
   print STDERR " ## ", @_, "\n";
 }
 
+
+sub pid {
+  my ($self)= @_;
+  return $self->{SAFE_PID};
+}
+
+sub user_data {
+  my ($self)= @_;
+  return $self->{SAFE_USER_DATA};
+}
+
+
 1;

=== added file 'mysql-test/lib/My/SysInfo.pm'
--- a/mysql-test/lib/My/SysInfo.pm	1970-01-01 00:00:00 +0000
+++ b/mysql-test/lib/My/SysInfo.pm	2008-07-24 20:22:47 +0000
@@ -0,0 +1,196 @@
+# -*- cperl -*-
+# Copyright (C) 2004-2006 MySQL AB
+#
+# 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
+
+
+package My::SysInfo;
+
+use strict;
+use Carp;
+use My::Platform;
+
+use constant DEFAULT_BOGO_MIPS => 2000;
+
+sub _cpuinfo {
+  my ($self)= @_;
+
+  my $info_file= "/proc/cpuinfo";
+  if ( !(  -e $info_file and -f $info_file) ) {
+    return undef;
+  }
+
+  my $F= IO::File->new($info_file) or return undef;
+
+  # Set input separator to blank line
+  local $/ = '';
+
+  while ( my $cpu_chunk= <$F>) {
+    chomp($cpu_chunk);
+
+    my $cpuinfo = {};
+
+    foreach my $cpuline ( split(/\n/, $cpu_chunk) ) {
+      my ( $attribute, $value ) = split(/\s*:\s*/, $cpuline);
+
+      $attribute =~ s/\s+/_/;
+      $attribute = lc($attribute);
+
+      if ( $value =~ /^(no|not available|yes)$/ ) {
+	$value = $value eq 'yes' ? 1 : 0;
+      }
+
+      if ( $attribute eq 'flags' ) {
+	@{ $cpuinfo->{flags} } = split / /, $value;
+      } else {
+	$cpuinfo->{$attribute} = $value;
+      }
+    }
+
+    # Make sure bogomips is set to some value
+    $cpuinfo->{bogomips} |= DEFAULT_BOGO_MIPS;
+
+    # Cpus reported once, but with 'cpu_count' set to the actual number
+    my $cpu_count= $cpuinfo->{cpu_count} || 1;
+    for(1..$cpu_count){
+      push(@{$self->{cpus}}, $cpuinfo);
+    }
+  }
+  $F= undef; # Close file
+  return $self;
+}
+
+
+sub _kstat {
+  my ($self)= @_;
+  while (1){
+    my $instance_num= $self->{cpus} ? @{$self->{cpus}} : 0;
+    my $list= `kstat -p -m cpu_info -i $instance_num`;
+    my @lines= split('\n', $list) or last; # Break loop
+
+    my $cpuinfo= {};
+    foreach my $line (@lines)
+    {
+      my ($module, $instance, $name, $statistic, $value)=
+	$line=~ /(\w*):(\w*):(\w*):(\w*)\t(.*)/;
+
+      $cpuinfo->{$statistic}= $value;
+    }
+
+    # Default value, the actual cpu values can be used to decrease this
+    # on slower cpus
+    $cpuinfo->{bogomips}= DEFAULT_BOGO_MIPS;
+
+    push(@{$self->{cpus}}, $cpuinfo);
+  }
+
+  # At least one cpu should have been found
+  # if this method worked
+  if ( $self->{cpus} ) {
+    return $self;
+  }
+  return undef;
+}
+
+
+sub _unamex {
+  my ($self)= @_;
+  # TODO
+  return undef;
+}
+
+
+sub new {
+  my ($class)= @_;
+
+
+  my $self= bless {
+		   cpus => (),
+		  }, $class;
+
+  my @info_methods =
+    (
+     \&_cpuinfo,
+     \&_kstat,
+     \&_unamex,
+   );
+
+  foreach my $method (@info_methods){
+    if ($method->($self)){
+      return $self;
+    }
+  }
+
+  # Push a dummy cpu
+  push(@{$self->{cpus}},
+     {
+      bogomips => DEFAULT_BOGO_MIPS,
+      model_name => "unknown",
+     });
+
+  return $self;
+}
+
+
+# Return the list of cpus found
+sub cpus {
+  my ($self)= @_;
+  return @{$self->{cpus}} or
+    confess "INTERNAL ERROR: No cpus in list";
+}
+
+
+# Return the number of cpus found
+sub num_cpus {
+  my ($self)= @_;
+  return int(@{$self->{cpus}}) or
+    confess "INTERNAL ERROR: No cpus in list";
+}
+
+
+# Return the smallest bogomips value amongst the processors
+sub min_bogomips {
+  my ($self)= @_;
+
+  my $bogomips;
+
+  foreach my $cpu (@{$self->{cpus}}) {
+    if (!defined $bogomips or $bogomips > $cpu->{bogomips}) {
+      $bogomips= $cpu->{bogomips};
+    }
+  }
+
+  return $bogomips;
+}
+
+
+# Prit the cpuinfo
+sub print_info {
+  my ($self)= @_;
+
+  foreach my $cpu (@{$self->{cpus}}) {
+    while ((my ($key, $value)) = each(%$cpu)) {
+      print " ", $key, "= ";
+      if (ref $value eq "ARRAY") {
+	print "[", join(", ", @$value), "]";
+      } else {
+	print $value;
+      }
+      print "\n";
+    }
+    print "\n";
+  }
+}
+
+1;

=== added file 'mysql-test/lib/My/Test.pm'
--- a/mysql-test/lib/My/Test.pm	1970-01-01 00:00:00 +0000
+++ b/mysql-test/lib/My/Test.pm	2008-04-24 11:02:53 +0000
@@ -0,0 +1,122 @@
+# -*- cperl -*-
+
+
+#
+# One test
+#
+package My::Test;
+
+use strict;
+use warnings;
+use Carp;
+
+
+sub new {
+  my $class= shift;
+  my $self= bless {
+		   @_,
+		  }, $class;
+  return $self;
+}
+
+
+#
+# Return a unique key that can be used to
+# identify this test in a hash
+#
+sub key {
+  my ($self)= @_;
+  my $key= $self->{name};
+  $key.= "+".$self->{combination} if $self->{combination};
+  return $key;
+}
+
+
+sub _encode {
+  my ($value)= @_;
+  $value =~ s/([|\\\x{0a}\x{0d}])/sprintf('\%02X', ord($1))/eg;
+  return $value;
+}
+
+sub _decode {
+  my ($value)= @_;
+  $value =~ s/\\([0-9a-fA-F]{2})/chr(hex($1))/ge;
+  return $value;
+}
+
+sub is_failed {
+  my ($self)= @_;
+  my $result= $self->{result};
+  croak "'is_failed' can't be called until test has been run!"
+    unless defined $result;
+
+  return ($result eq 'MTR_RES_FAILED');
+}
+
+
+sub write_test {
+  my ($test, $sock, $header)= @_;
+
+  print $sock $header, "\n";
+  while ((my ($key, $value)) = each(%$test)) {
+    print $sock  $key, "= ";
+    if (ref $value eq "ARRAY") {
+      print $sock "[", _encode(join(", ", @$value)), "]";
+    } else {
+      print $sock _encode($value);
+    }
+    print $sock "\n";
+  }
+  print $sock "\n";
+}
+
+
+sub read_test {
+  my ($sock)= @_;
+  my $test= My::Test->new();
+  # Read the : separated key value pairs until a
+  # single newline on it's own line
+  my $line;
+  while (defined($line= <$sock>)) {
+    # List is terminated by newline on it's own
+    if ($line eq "\n") {
+      # Correctly terminated reply
+      # print "Got newline\n";
+      last;
+    }
+    chomp($line);
+
+    # Split key/value on the first "="
+    my ($key, $value)= split("= ", $line, 2);
+
+    if ($value =~ /^\[(.*)\]/){
+      my @values= split(", ", _decode($1));
+      push(@{$test->{$key}}, @values);
+    }
+    else
+    {
+      $test->{$key}= _decode($value);
+    }
+  }
+  return $test;
+}
+
+
+sub print_test {
+  my ($self)= @_;
+
+  print "[", $self->{name}, "]", "\n";
+  while ((my ($key, $value)) = each(%$self)) {
+    print " ", $key, "= ";
+    if (ref $value eq "ARRAY") {
+      print "[", join(", ", @$value), "]";
+    } else {
+      print $value;
+    }
+    print "\n";
+  }
+  print "\n";
+}
+
+
+1;

=== modified file 'mysql-test/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm	2008-07-22 14:16:22 +0000
+++ b/mysql-test/lib/mtr_cases.pm	2008-08-04 14:30:50 +0000
@@ -40,7 +40,7 @@ our $default_storage_engine;
 our $opt_with_ndbcluster_only;
 our $defaults_file;
 our $defaults_extra_file;
-our $reorder;
+our $reorder= 1;
 
 sub collect_option {
   my ($opt, $value)= @_;
@@ -56,6 +56,7 @@ use File::Spec::Functions qw / splitdir 
 use IO::File();
 use My::Config;
 use My::Platform;
+use My::Test;
 use My::Find;
 
 require "mtr_misc.pl";
@@ -136,52 +137,16 @@ sub collect_test_cases ($$) {
     {
       my @criteria = ();
 
-      # Look for tests that must be run in a defined order - that is
-      # defined by test having the same name except for the ending digit
+      #
+      # Append the criteria for sorting, in order of importance.
+      #
+      push(@criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "A" : "B"));
+      # Group test with equal options together.
+      # Ending with "~" makes empty sort later than filled
+      my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
+      push(@criteria, join("!", sort @{$opts}) . "~");
 
-      # Put variables into hash
-      my $test_name= $tinfo->{'name'};
-      my $depend_on_test_name;
-      if ( $test_name =~ /^([\D]+)([0-9]{1})$/ )
-      {
-	my $base_name= $1;
-	my $idx= $2;
-	mtr_verbose("$test_name =>  $base_name idx=$idx");
-	if ( $idx > 1 )
-	{
-	  $idx-= 1;
-	  $base_name= "$base_name$idx";
-	  mtr_verbose("New basename $base_name");
-	}
-
-	foreach my $tinfo2 (@$cases)
-	{
-	  if ( $tinfo2->{'name'} eq $base_name )
-	  {
-	    mtr_verbose("found dependent test $tinfo2->{'name'}");
-	    $depend_on_test_name=$base_name;
-	  }
-	}
-      }
-
-      if ( defined $depend_on_test_name )
-      {
-	mtr_verbose("Giving $test_name same critera as $depend_on_test_name");
-	$sort_criteria{$test_name} = $sort_criteria{$depend_on_test_name};
-      }
-      else
-      {
-	#
-	# Append the criteria for sorting, in order of importance.
-	#
-	push(@criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "1" : "0"));
-	# Group test with equal options together.
-	# Ending with "~" makes empty sort later than filled
-	my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
-	push(@criteria, join("!", sort @{$opts}) . "~");
-
-	$sort_criteria{$test_name} = join(" ", @criteria);
-      }
+      $sort_criteria{$tinfo->{name}} = join(" ", @criteria);
     }
 
     @$cases = sort {
@@ -459,7 +424,7 @@ sub collect_one_suite($)
 	  }
 
 	  # Copy test options
-	  my $new_test= {};
+	  my $new_test= My::Test->new();
 	  while (my ($key, $value) = each(%$test)) {
 	    if (ref $value eq "ARRAY") {
 	      push(@{$new_test->{$key}}, @$value);
@@ -571,6 +536,26 @@ sub optimize_cases {
 	}
       }
     }
+
+
+    # =======================================================
+    # Check that engine selected by
+    # --default-storage-engine=<engine> is supported
+    # =======================================================
+    foreach my $opt ( @{$tinfo->{master_opt}} ) {
+      my $default_engine=
+	mtr_match_prefix($opt, "--default-storage-engine=");
+
+      if (defined $default_engine){
+	if ( ! exists $::mysqld_variables{$default_engine} )
+	{
+	 $tinfo->{'skip'}= 1;
+	 $tinfo->{'comment'}=
+	 "'$default_engine' not supported";
+
+	}
+      }
+    }
   }
 }
 
@@ -687,13 +672,16 @@ sub collect_one_test_case {
   # ----------------------------------------------------------------------
   # Set defaults
   # ----------------------------------------------------------------------
-  my $tinfo= {};
-  $tinfo->{'name'}= $suitename . ".$tname";
-  $tinfo->{'path'}= "$testdir/$filename";
-
-  # TODO allow nonexistsing result file
-  # in that case .test must issue "exit" otherwise test should fail by default
-  $tinfo->{'result_file'}= "$resdir/$tname.result";
+  my $tinfo= My::Test->new
+    (
+     name          => "$suitename.$tname",
+     path          => "$testdir/$filename",
+
+     # TODO allow nonexistsing result file
+     # in that case .test must issue "exit" otherwise test
+     # should fail by default
+     result_file   => "$resdir/$tname.result",
+    );
 
   # ----------------------------------------------------------------------
   # Skip some tests but include in list, just mark them as skipped
@@ -874,9 +862,16 @@ sub collect_one_test_case {
     }
   }
 
+  if ($tinfo->{'federated_test'})
+  {
+    # This is a test that need federated, enable it
+    push(@{$tinfo->{'master_opt'}}, "--loose-federated");
+    push(@{$tinfo->{'slave_opt'}}, "--loose-federated");
+  }
+
   if ( $tinfo->{'innodb_test'} )
   {
-      # This is a test that need innodb
+    # This is a test that need innodb
     if ( $::mysqld_variables{'innodb'} ne "TRUE" )
     {
       # innodb is not supported, skip it
@@ -996,7 +991,7 @@ my @tags=
  ["include/master-slave.inc", "rpl_test", 1],
  ["include/ndb_master-slave.inc", "rpl_test", 1],
  ["include/ndb_master-slave.inc", "ndb_test", 1],
- ["include/federated.inc", "federated_test", 1],
+ ["federated.inc", "federated_test", 1],
  ["include/not_embedded.inc", "not_embedded", 1],
 );
 
@@ -1058,19 +1053,6 @@ sub unspace {
 }
 
 
-
-sub envsubst {
-  my $string= shift;
-
-  if ( ! defined $ENV{$string} )
-  {
-    mtr_error(".opt file references '$string' which is not set");
-  }
-
-  return $ENV{$string};
-}
-
-
 sub opts_from_file ($) {
   my $file=  shift;
 
@@ -1107,10 +1089,6 @@ sub opts_from_file ($) {
         or $arg =~ s/^([^\'\"]*)\"(.*)\"([^\'\"]*)$/$1$2$3/;
       $arg =~ s/\\\\/\\/g;
 
-      # Expand environment variables
-      $arg =~ s/\$\{(\w+)\}/envsubst($1)/ge;
-      $arg =~ s/\$(\w+)/envsubst($1)/ge;
-
       # Do not pass empty string since my_getopt is not capable to handle it.
       if (length($arg)) {
 	push(@args, $arg);
@@ -1126,17 +1104,7 @@ sub print_testcases {
 
   print "=" x 60, "\n";
   foreach my $test (@cases){
-    print "[", $test->{name}, "]", "\n";
-    while ((my ($key, $value)) = each(%$test)) {
-      print " ", $key, "= ";
-      if (ref $value eq "ARRAY") {
-	print "[", join(", ", @$value), "]";
-      } else {
-	print $value;
-      }
-      print "\n";
-    }
-    print "\n";
+    $test->print_test();
   }
   print "=" x 60, "\n";
 }

=== modified file 'mysql-test/lib/mtr_report.pm'
--- a/mysql-test/lib/mtr_report.pm	2008-07-22 14:16:22 +0000
+++ b/mysql-test/lib/mtr_report.pm	2008-08-04 14:30:50 +0000
@@ -26,7 +26,8 @@ our @EXPORT= qw(report_option mtr_print_
 		mtr_print_header mtr_report mtr_report_stats
 		mtr_warning mtr_error mtr_debug mtr_verbose
 		mtr_verbose_restart mtr_report_test_passed
-		mtr_report_test_failed mtr_report_test_skipped);
+		mtr_report_test_skipped mtr_print
+		mtr_report_test);
 
 use mtr_match;
 require "mtr_io.pl";
@@ -34,7 +35,11 @@ require "mtr_io.pl";
 my $tot_real_time= 0;
 
 our $timestamp= 0;
-our $timediff= 1;
+our $timediff= 0;
+our $name;
+our $verbose;
+our $verbose_restart= 0;
+our $timer= 1;
 
 sub report_option {
   my ($opt, $value)= @_;
@@ -43,115 +48,134 @@ sub report_option {
   $opt =~ s/-/_/g;
   no strict 'refs';
   ${$opt}= $value;
+
+  #print $name, " setting $opt to ", (defined $value? $value : "undef") ,"\n";
 }
 
-sub SHOW_SUITE_NAME() { return  1; };
+sub _name {
+  return $name ? $name." " : undef;
+}
 
 sub _mtr_report_test_name ($) {
   my $tinfo= shift;
   my $tname= $tinfo->{name};
 
-  # Remove suite part of name
-  $tname =~ s/.*\.// unless SHOW_SUITE_NAME;
+  return unless defined $verbose;
 
   # Add combination name if any
   $tname.= " '$tinfo->{combination}'"
     if defined $tinfo->{combination};
 
-  print _timestamp();
-  printf "%-30s ", $tname;
+  print _name(), _timestamp();
+  printf "%-40s ", $tname;
 }
 
 
 sub mtr_report_test_skipped ($) {
-  my $tinfo= shift;
-  _mtr_report_test_name($tinfo);
-
+  my ($tinfo)= @_;
   $tinfo->{'result'}= 'MTR_RES_SKIPPED';
-  if ( $tinfo->{'disable'} )
-  {
-    mtr_report("[ disabled ]  $tinfo->{'comment'}");
-  }
-  elsif ( $tinfo->{'comment'} )
-  {
-    if ( $tinfo->{skip_detected_by_test} )
-    {
-      mtr_report("[ skip ].  $tinfo->{'comment'}");
-    }
-    else
-    {
-      mtr_report("[ skip ]  $tinfo->{'comment'}");
-    }
-  }
-  else
-  {
-    mtr_report("[ skip ]");
-  }
+
+  mtr_report_test($tinfo);
 }
 
 
-sub mtr_report_test_passed ($$) {
-  my ($tinfo, $use_timer)= @_;
-  _mtr_report_test_name($tinfo);
+sub mtr_report_test_passed ($) {
+  my ($tinfo)= @_;
 
-  my $timer=  "";
-  if ( $use_timer and -f "$::opt_vardir/log/timer" )
+  # Save the timer value
+  my $timer_str=  "";
+  if ( $timer and -f "$::opt_vardir/log/timer" )
   {
-    $timer= mtr_fromfile("$::opt_vardir/log/timer");
-    $tot_real_time += ($timer/1000);
-    $timer= sprintf "%12s", $timer;
+    $timer_str= mtr_fromfile("$::opt_vardir/log/timer");
+    $tinfo->{timer}= $timer_str;
   }
+
   # Set as passed unless already set
   if ( not defined $tinfo->{'result'} ){
     $tinfo->{'result'}= 'MTR_RES_PASSED';
   }
-  mtr_report("[ pass ]   $timer");
+
+  mtr_report_test($tinfo);
 }
 
 
-sub mtr_report_test_failed ($$) {
-  my ($tinfo, $logfile)= @_;
+sub mtr_report_test ($) {
+  my ($tinfo)= @_;
   _mtr_report_test_name($tinfo);
 
-  $tinfo->{'result'}= 'MTR_RES_FAILED';
-  my $test_failures= $tinfo->{'failures'} || 0;
-  $tinfo->{'failures'}=  $test_failures + 1;
-  if ( defined $tinfo->{'warnings'} )
-  {
-    mtr_report("[ fail ]  Found warnings in server log file!");
-    mtr_report($tinfo->{'warnings'});
-    return;
-  }
-  elsif ( defined $tinfo->{'timeout'} )
-  {
-    mtr_report("[ fail ]  timeout");
-    return;
-  }
-  else
-  {
-    mtr_report("[ fail ]");
-  }
+  if ($tinfo->{'result'} eq 'MTR_RES_FAILED'){
 
-  if ( $tinfo->{'comment'} )
-  {
-    # The test failure has been detected by mysql-test-run.pl
-    # when starting the servers or due to other error, the reason for
-    # failing the test is saved in "comment"
-    mtr_report("\nERROR: $tinfo->{'comment'}");
+    if ( defined $tinfo->{'warnings'} )
+    {
+      mtr_report("[ fail ]  Found warnings in server log file!");
+      mtr_report($tinfo->{'warnings'});
+      return;
+    }
+    if ( defined $tinfo->{'timeout'} )
+    {
+      mtr_report("[ fail ]  timeout");
+      return;
+    }
+    else
+    {
+      mtr_report("[ fail ]");
+    }
+
+    if ( $tinfo->{'comment'} )
+    {
+      # The test failure has been detected by mysql-test-run.pl
+      # when starting the servers or due to other error, the reason for
+      # failing the test is saved in "comment"
+      mtr_report("\nERROR: $tinfo->{'comment'}");
+    }
+    elsif ( $tinfo->{logfile} )
+    {
+      # Test failure was detected by test tool and its report
+      # about what failed has been saved to file. Display the report.
+      mtr_report("\n");
+      mtr_report($tinfo->{logfile}, "\n");
+
+    }
+    else
+    {
+      # Neither this script or the test tool has recorded info
+      # about why the test has failed. Should be debugged.
+      mtr_report("\nUnexpected termination, probably when starting mysqld");;
+    }
   }
-  elsif ( defined $logfile and -f $logfile )
+  elsif ($tinfo->{'result'} eq 'MTR_RES_SKIPPED')
   {
-    # Test failure was detected by test tool and its report
-    # about what failed has been saved to file. Display the report.
-    print "\n";
-    mtr_printfile($logfile);
-    print "\n";
+    if ( $tinfo->{'disable'} )
+    {
+      mtr_report("[ disabled ]  $tinfo->{'comment'}");
+    }
+    elsif ( $tinfo->{'comment'} )
+    {
+      if ( $tinfo->{skip_detected_by_test} )
+      {
+	mtr_report("[ skip ]. $tinfo->{'comment'}");
+      }
+      else
+      {
+	mtr_report("[ skip ]  $tinfo->{'comment'}");
+      }
+    }
+    else
+    {
+      mtr_report("[ skip ]");
+    }
   }
-  else
+  elsif ($tinfo->{'result'} eq 'MTR_RES_PASSED')
   {
-    # Neither this script or the test tool has recorded info
-    # about why the test has failed. Should be debugged.
-    mtr_report("\nUnexpected termination, probably when starting mysqld");;
+    my $timer_str= $tinfo->{timer} || "";
+    $tot_real_time += ($timer_str/1000);
+    mtr_report("[ pass ] ", sprintf("%5s", $timer_str));
+
+    # Show any problems check-testcase found
+    if ( defined $tinfo->{'check'} )
+    {
+      mtr_report($tinfo->{'check'});
+    }
   }
 }
 
@@ -172,22 +196,27 @@ sub mtr_report_stats ($) {
 
   foreach my $tinfo (@$tests)
   {
-    if ( $tinfo->{'result'} eq 'MTR_RES_SKIPPED' )
+    if ( $tinfo->{failures} )
+    {
+      # Test has failed at least one time
+      $tot_tests++;
+      $tot_failed++;
+    }
+    elsif ( $tinfo->{'result'} eq 'MTR_RES_SKIPPED' )
     {
+      # Test was skipped
       $tot_skiped++;
     }
     elsif ( $tinfo->{'result'} eq 'MTR_RES_PASSED' )
     {
+      # Test passed
       $tot_tests++;
       $tot_passed++;
     }
-    elsif ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
-    {
-      $tot_tests++;
-      $tot_failed++;
-    }
+
     if ( $tinfo->{'restarted'} )
     {
+      # Servers was restarted
       $tot_restarts++;
     }
 
@@ -207,7 +236,7 @@ sub mtr_report_stats ($) {
   # ----------------------------------------------------------------------
   print "The servers were restarted $tot_restarts times\n";
 
-  if ( $::opt_timer )
+  if ( $timer )
   {
     use English;
 
@@ -249,6 +278,14 @@ sub mtr_report_stats ($) {
   # Print a list of testcases that failed
   if ( $tot_failed != 0 )
   {
+
+    # Print each failed test, again
+    #foreach my $test ( @$tests ){
+    #  if ( $test->{failures} ) {
+    #    mtr_report_test($test);
+    #  }
+    #}
+
     my $ratio=  $tot_passed * 100 / $tot_tests;
     print "Failed $tot_failed/$tot_tests tests, ";
     printf("%.2f", $ratio);
@@ -262,7 +299,7 @@ sub mtr_report_stats ($) {
     foreach my $tinfo (@$tests)
     {
       my $tname= $tinfo->{'name'};
-      if ( $tinfo->{'result'} eq 'MTR_RES_FAILED' and ! $seen{$tname})
+      if ( $tinfo->{failures} and ! $seen{$tname})
       {
         print " $tname";
 	$seen{$tname}= 1;
@@ -280,7 +317,7 @@ sub mtr_report_stats ($) {
    }
   else
   {
-    print "All $tot_tests tests were successful.\n";
+    print "All $tot_tests tests were successful.\n\n";
   }
 
   if ( $tot_failed != 0 || $found_problems)
@@ -309,14 +346,11 @@ sub mtr_print_thick_line {
 
 sub mtr_print_header () {
   print "\n";
-  if ( $::opt_timer )
-  {
-    print "TEST                            RESULT        TIME (ms)\n";
-  }
-  else
-  {
-    print "TEST                            RESULT\n";
-  }
+  printf "TEST";
+  print " " x 38;
+  print "RESULT   ";
+  print "TIME (ms)" if $timer;
+  print "\n";
   mtr_print_line();
   print "\n";
 }
@@ -355,38 +389,50 @@ sub _timestamp {
 		 $tm->hour, $tm->min, $tm->sec, $diff);
 }
 
+# Always print message to screen
+sub mtr_print (@) {
+  print _name(), join(" ", @_), "\n";
+}
+
 
-# Print message to screen
+# Print message to screen if verbose is defined
 sub mtr_report (@) {
-  print join(" ", @_), "\n";
+  if (defined $verbose)
+  {
+    print _name(), join(" ", @_), "\n";
+  }
 }
 
 
 # Print warning to screen
 sub mtr_warning (@) {
-  print STDERR _timestamp(), "mysql-test-run: WARNING: ", join(" ", @_), "\n";
+  print STDERR _name(), _timestamp(),
+    "mysql-test-run: WARNING: ", join(" ", @_), "\n";
 }
 
 
 # Print error to screen and then exit
 sub mtr_error (@) {
-  print STDERR _timestamp(), "mysql-test-run: *** ERROR: ", join(" ", @_), "\n";
+  print STDERR _name(), _timestamp(),
+    "mysql-test-run: *** ERROR: ", join(" ", @_), "\n";
   exit(1);
 }
 
 
 sub mtr_debug (@) {
-  if ( $::opt_verbose > 1 )
+  if ( $verbose > 2 )
   {
-    print STDERR _timestamp(), "####: ", join(" ", @_), "\n";
+    print STDERR _name(),
+      _timestamp(), "####: ", join(" ", @_), "\n";
   }
 }
 
 
 sub mtr_verbose (@) {
-  if ( $::opt_verbose )
+  if ( $verbose )
   {
-    print STDERR _timestamp(), "> ",join(" ", @_),"\n";
+    print STDERR _name(), _timestamp(),
+      "> ",join(" ", @_),"\n";
   }
 }
 
@@ -394,9 +440,10 @@ sub mtr_verbose (@) {
 sub mtr_verbose_restart (@) {
   my ($server, @args)= @_;
   my $proc= $server->{proc};
-  if ( $::opt_verbose_restart )
+  if ( $verbose_restart )
   {
-    print STDERR _timestamp(), "> Restart $proc - ",join(" ", @args),"\n";
+    print STDERR _name(),_timestamp(),
+      "> Restart $proc - ",join(" ", @args),"\n";
   }
 }
 

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2008-07-24 20:19:36 +0000
+++ b/mysql-test/mysql-test-run.pl	2008-08-04 14:30:50 +0000
@@ -41,6 +41,7 @@ use Getopt::Long;
 use My::File::Path; # Patched version of File::Path
 use File::Basename;
 use File::Copy;
+use File::Find;
 use File::Temp qw / tempdir /;
 use File::Spec::Functions qw / splitdir /;
 use My::Platform;
@@ -48,9 +49,12 @@ use My::SafeProcess;
 use My::ConfigFactory;
 use My::Options;
 use My::Find;
+use My::SysInfo;
 use mtr_cases;
 use mtr_report;
 use mtr_match;
+use IO::Socket::INET;
+use IO::Select;
 
 require "lib/mtr_process.pl";
 require "lib/mtr_io.pl";
@@ -88,7 +92,6 @@ my $DEFAULT_SUITES= "main,backup,binlog,
 my $opt_suites;
 
 our $opt_verbose= 0;  # Verbose output, enable with --verbose
-our $opt_verbose_restart= 0;  # Verbose output for restarts
 
 our $exe_mysql;
 our $exe_mysqladmin;
@@ -142,7 +145,7 @@ my $config; # The currently running conf
 my $current_config_name; # The currently running config file template
 
 my $opt_baseport;
-my $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto";
+my $opt_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto";
 
 my $opt_record;
 my $opt_report_features;
@@ -154,7 +157,7 @@ my $opt_sleep;
 my $opt_testcase_timeout=    15; # 15 minutes
 my $opt_suite_timeout   =   360; # 6 hours
 my $opt_shutdown_timeout=    10; # 10 seconds
-my $opt_start_timeout   =    30; # 30 seconds
+my $opt_start_timeout   =    180; # 180 seconds
 
 my $opt_start;
 my $opt_start_dirty;
@@ -162,9 +165,9 @@ my $opt_repeat= 1;
 my $opt_retry= 3;
 my $opt_retry_failure= 2;
 
-my $opt_strace_client;
+my $opt_parallel;
 
-our $opt_timer= 1;
+my $opt_strace_client;
 
 our $opt_user;
 
@@ -196,37 +199,69 @@ our %mysqld_variables;
 my $source_dist= 0;
 
 my $opt_max_save_core= $ENV{MTR_MAX_SAVE_CORE} || 5;
-my $num_saved_cores= 0;  # Number of core files saved in vardir/log/ so far.
-
 my $opt_max_save_datadir= $ENV{MTR_MAX_SAVE_DATADIR} || 20;
-my $num_saved_datadir= 0;  # Number of datadirs saved in vardir/log/ so far.
+my $opt_max_test_fail= $ENV{MTR_MAX_TEST_FAIL} || 10;
 
 select(STDOUT);
 $| = 1; # Automatically flush STDOUT
 
 main();
 
+
 sub main {
+  report_option('verbose', 0);
 
-  command_line_setup();
+  # This is needed for test log evaluation in "gen-build-status-page"
+  # in all cases where the calling tool does not log the commands
+  # directly before it executes them, like "make test-force-pl" in RPM builds.
+  mtr_report("Logging: $0 ", join(" ", @ARGV));
 
-  mtr_report("Checking supported features...");
+  Getopt::Long::Configure("pass_through");
+  GetOptions('parallel=i' => \$opt_parallel) or usage(0, "Can't read options");
 
-  check_ndbcluster_support(\%mysqld_variables);
-  check_ssl_support(\%mysqld_variables);
-  check_debug_support(\%mysqld_variables);
+  if ( not defined $opt_parallel ) {
+    # Try to find a suitable value for number of workers
+    my $sys_info= My::SysInfo->new();
 
-  executable_setup();
+    $opt_parallel= $sys_info->num_cpus();
+    for my $limit (2000, 1500, 1000, 500){
+      $opt_parallel-- if ($sys_info->min_bogomips() < $limit);
+    }
+    $opt_parallel= 1 if ($opt_parallel < 1);
+    mtr_report("Using parallel: $opt_parallel");
+  }
 
-  environment_setup();
+  # Create server socket on any free port
+  my $server = new IO::Socket::INET
+    (
+     LocalAddr => 'localhost',
+     Proto => 'tcp',
+     Listen => $opt_parallel,
+    );
+  mtr_error("Could not create testcase server port: $!") unless $server;
+  my $server_port = $server->sockport();
+  mtr_report("Using server port $server_port");
+
+  # Create child processes
+  my %children;
+  for my $child_num (1..$opt_parallel){
+    my $child_pid= My::SafeProcess::Base::_safe_fork();
+    if ($child_pid == 0){
+      $server= undef; # Close the server port in child
+      run_worker($server_port, $child_num);
+      exit(1);
+    }
 
-  if ( $opt_gcov )
-  {
+    $children{$child_pid}= 1;
+  }
+
+  command_line_setup(0);
+
+  if ( $opt_gcov ) {
     gcov_prepare();
   }
 
-  if (!$opt_suites)
-  {
+  if (!$opt_suites) {
     $opt_suites= $DEFAULT_SUITES;
 
     # Check for any extra suites to enable based on the path name
@@ -245,10 +280,9 @@ sub main {
        "mysql-6.0-falcon-kevin"         => "falcon_team",
       );
 
-    foreach my $dir ( reverse splitdir($basedir) )
-    {
+    foreach my $dir ( reverse splitdir($basedir) ) {
       my $extra_suite= $extra_suites{$dir};
-      if (defined $extra_suite){
+      if (defined $extra_suite) {
 	mtr_report("Found extra suite: $extra_suite");
 	$opt_suites= "$extra_suite,$opt_suites";
 	last;
@@ -259,42 +293,393 @@ sub main {
   mtr_report("Collecting tests...");
   my $tests= collect_test_cases($opt_suites, \@opt_cases);
 
-  initialize_servers();
-
   if ( $opt_report_features ) {
     # Put "report features" as the first test to run
-    my $tinfo = {};
-    $tinfo->{'name'} = 'report_features';
-    $tinfo->{'result_file'} = undef; # Prints result
-    $tinfo->{'path'} = 'include/report-features.test';
-    $tinfo->{'master_opt'} = [];
-    $tinfo->{'slave_opt'} = [];
+    my $tinfo = My::Test->new
+      (
+       name           => 'report_features',
+       result_file    => undef, # Prints result
+       path           => 'include/report-features.test'.
+       master_opt     => [],
+       slave_opt      => [],
+      );
     unshift(@$tests, $tinfo);
   }
 
+  initialize_servers();
+
+  mtr_report();
+  mtr_print_thick_line();
+  mtr_print_header();
+
+  my $num_tests= @$tests;
+  my $completed= run_test_server($server, $tests, $opt_parallel);
+
+  # Send Ctrl-C to any children still running
+  kill("INT", keys(%children));
+
+  # Wait for childs to exit
+  foreach my $pid (keys %children)
+  {
+    my $ret_pid= waitpid($pid, 0);
+    if ($ret_pid != $pid){
+      mtr_report("Unknown process $ret_pid exited");
+    }
+    else {
+      delete $children{$ret_pid};
+    }
+  }
+
+  if ( not defined @$completed ) {
+    mtr_error("Test suite aborted");
+  }
+
+  if ( @$completed != $num_tests){
+
+    if ($opt_force){
+      # All test should have been run, print any that are still in $tests
+      foreach my $test ( @$tests ){
+	$test->print_test();
+      }
+    }
+
+    # Not all tests completed, failure
+    mtr_report();
+    mtr_report("Only ", int(@$completed), " of $num_tests completed.");
+    mtr_error("Not all tests completed");
+  }
+
+  mtr_print_line();
+
+  mtr_report_stats($completed);
+
+  exit(0);
+}
+
+
+sub run_test_server {
+  my ($server, $tests, $childs) = @_;
+
+  my $num_saved_cores= 0;  # Number of core files saved in vardir/log/ so far.
+  my $num_saved_datadir= 0;  # Number of datadirs saved in vardir/log/ so far.
+  my $num_failed_test= 0; # Number of tests failed so far
+
+  # Scheduler variables
+  my $max_ndb= $opt_parallel / 2;
+  $max_ndb = 4 if $max_ndb > 4;
+  $max_ndb = 1 if $max_ndb < 1;
+  my $num_ndb_tests= 0;
+
+  my $completed= [];
+  my %running;
+  my $result;
+
+  my $suite_timeout_proc= My::SafeProcess->timer($opt_suite_timeout * 60);
+
+  my $s= IO::Select->new();
+  $s->add($server);
+  while (1) {
+    my @ready = $s->can_read(1); # Wake up once every second
+    foreach my $sock (@ready) {
+      if ($sock == $server) {
+	# New client connected
+	my $child= $sock->accept();
+	mtr_verbose("Client connected");
+	$s->add($child);
+	print $child "HELLO\n";
+      }
+      else {
+	my $line= <$sock>;
+	if (!defined $line) {
+	  # Client disconnected
+	  mtr_verbose("Child closed socket");
+	  $s->remove($sock);
+	  if (--$childs == 0){
+	    $suite_timeout_proc->kill();
+	    return $completed;
+	  }
+	  next;
+	}
+	chomp($line);
+
+	if ($line eq 'TESTRESULT'){
+	  $result= My::Test::read_test($sock);
+	  # $result->print_test();
+
+	  # Report test status
+	  mtr_report_test($result);
+
+	  if ( $result->is_failed() ) {
+
+	    # Save the workers "savedir" in var/log
+	    my $worker_savedir= $result->{savedir};
+	    my $worker_savename= basename($worker_savedir);
+	    my $savedir= "$opt_vardir/log/$worker_savename";
+
+	    if ($opt_max_save_datadir > 0 &&
+		$num_saved_datadir >= $opt_max_save_datadir)
+	    {
+	      mtr_report(" - skipping '$worker_savedir/'");
+	      rmtree($worker_savedir);
+	    }
+	    else {
+	      mtr_report(" - saving '$worker_savedir/' to '$savedir/'");
+	      rename($worker_savedir, $savedir);
+
+	      if ($opt_max_save_core > 0) {
+		# Limit number of core files saved
+		find({ no_chdir => 1,
+		       wanted => sub {
+			 my $core_file= $File::Find::name;
+			 my $core_name= basename($core_file);
+
+			 if ($core_name =~ "core*"){
+			   if ($num_saved_cores >= $opt_max_save_core) {
+			     mtr_report(" - deleting '$core_name'",
+				      "($num_saved_cores/$opt_max_save_core)");
+			     unlink("$core_file");
+			   }
+			   else {
+			     mtr_report(" - found '$core_name'",
+				      "($num_saved_cores/$opt_max_save_core)");
+			   }
+			   ++$num_saved_cores;
+			 }
+		       }
+		     },
+		     $savedir);
+	      }
+	    }
+	    $num_saved_datadir++;
+
+	    if ( !$opt_force ) {
+	      # Test has failed, force is off
+	      $suite_timeout_proc->kill();
+	      push(@$completed, $result);
+	      return $completed;
+	    }
+	    elsif ($opt_max_test_fail > 0 and
+		   $num_failed_test >= $opt_max_test_fail) {
+	      $suite_timeout_proc->kill();
+	      mtr_report("Too many tests($num_failed_test) failed!",
+			 "Terminating...");
+	      return undef;
+	    }
+	    $num_failed_test++;
+	  }
+
+	  # Retry test run after test failure
+	  my $retries= $result->{retries} || 2;
+	  my $test_has_failed= $result->{failures} || 0;
+	  if ($test_has_failed and $retries <= $opt_retry){
+	    # Test should be run one more time unless it has failed
+	    # too many times already
+	    my $failures= $result->{failures};
+	    if ($opt_retry > 1 and $failures >= $opt_retry_failure){
+	      mtr_report("\nTest has failed $failures times,",
+			 "no more retries!\n");
+	    }
+	    else {
+	      mtr_report("\nRetrying test, attempt($retries/$opt_retry)...\n");
+	      delete($result->{result});
+	      $result->{retries}= $retries+1;
+	      $result->write_test($sock, 'TESTCASE');
+	      next;
+	    }
+	  }
+
+	  # Repeat test $opt_repeat number of times
+	  my $repeat= $result->{repeat} || 1;
+	  if ($repeat < $opt_repeat)
+	  {
+	    $result->{retries}= 0;
+	    $result->{failures}= 0;
+	    delete($result->{result});
+	    $result->{repeat}= $repeat+1;
+	    $result->write_test($sock, 'TESTCASE');
+	    next;
+	  }
+
+	  # Remove from list of running
+	  mtr_error("'", $result->{name},"' is not known to be running")
+	    unless delete $running{$result->key()};
+
+	  # Update scheduler variables
+	  $num_ndb_tests-- if ($result->{ndb_test});
+
+	  # Save result in completed list
+	  push(@$completed, $result);
+
+	}
+	elsif ($line eq 'START'){
+	  ; # Send first test
+	}
+	else {
+	  mtr_error("Unknown response: '$line' from client");
+	}
+
+	# Find next test to schedule
+	# - Try to use same configuration as worker used last time
+	# - Limit number of parallel ndb tests
+
+	my $next;
+	my $second_best;
+	for(my $i= 0; $i <= $#$tests; $i++)
+	{
+	  my $t= $tests->[$i];
+
+	  if (run_testcase_check_skip_test($t)){
+	    # Move the test to completed list
+	    #mtr_report("skip - Moving test $i to completed");
+	    push(@$completed, splice(@$tests, $i, 1));
+	    redo; # Start over again
+	  }
+
+	  # Limit number of parallell NDB tests
+	  if ($t->{ndb_test} and $num_ndb_tests >= $max_ndb){
+	    #mtr_report("Skipping, num ndb is already at max, $num_ndb_tests");
+	    next;
+	  }
+
+	  # Prefer same configuration
+	  if (defined $result and
+	      $result->{template_path} eq $t->{template_path})
+	  {
+	    #mtr_report("Test uses same config => good match");
+	    # Test uses same config => good match
+	    $next= splice(@$tests, $i, 1);
+	    last;
+	  }
+
+	  # Second best choice is the first that does not fulfill
+	  # any of the above conditions
+	  if (!defined $second_best){
+	    #mtr_report("Setting second_best to $i");
+	    $second_best= $i;
+	  }
+	}
+
+	# Use second best choice if no other test has been found
+	if (!$next and defined $second_best){
+	  #mtr_report("Take second best choice $second_best");
+	  mtr_error("Internal error, second best too large")
+	    if $second_best >  $#$tests;
+	  $next= splice(@$tests, $second_best, 1);
+	}
+
+	if ($next) {
+	  #$next->print_test();
+	  $next->write_test($sock, 'TESTCASE');
+	  $running{$next->key()}= $next;
+	  $num_ndb_tests++ if ($next->{ndb_test});
+	}
+	else {
+	  # No more test, tell child to exit
+	  #mtr_report("Saying BYE to child");
+	  print $sock "BYE\n";
+	}
+      }
+    }
+
+    # ----------------------------------------------------
+    # Check if test suite timer expired
+    # ----------------------------------------------------
+    if ( ! $suite_timeout_proc->wait_one(0) )
+    {
+      mtr_report("Test suite timeout! Terminating...");
+      return undef;
+    }
+  }
+}
+
+
+sub run_worker ($) {
+  my ($server_port, $thread_num)= @_;
+
+  $SIG{INT}= sub { exit(1); };
+
+  report_option('name',"worker[$thread_num]");
+
+  # Connect to server
+  my $server = new IO::Socket::INET
+    (
+     PeerAddr => 'localhost',
+     PeerPort => $server_port,
+     Proto    => 'tcp'
+    );
+  mtr_error("Could not connect to server at port $server_port: $!")
+    unless $server;
+
+  # Read hello from server which it will send when shared
+  # resources have been setup
+  my $hello= <$server>;
+
+  command_line_setup($thread_num);
+
+  if ( $opt_gcov )
+  {
+    gcov_prepare();
+  }
+
+  setup_vardir();
+  mysql_install_db($thread_num);
+
   if ( using_extern() ) {
     create_config_file_for_extern(%opts_extern);
   }
 
-  run_tests($tests);
+  # Ask server for first test
+  print $server "START\n";
 
-  exit(0);
+  while(my $line= <$server>){
+    chomp($line);
+    if ($line eq 'TESTCASE'){
+      my $test= My::Test::read_test($server);
+      #$test->print_test();
+      run_testcase($test);
+      #$test->{result}= 'MTR_RES_PASSED';
+      # Send it back, now with results set
+      #$test->print_test();
+      $test->write_test($server, 'TESTRESULT');
+    }
+    elsif ($line eq 'BYE'){
+      mtr_report("Server said BYE");
+      exit(0);
+    }
+    else {
+      mtr_error("Could not understand server, '$line'");
+    }
+  }
+
+  stop_all_servers();
+
+  if ( $opt_gcov )
+  {
+    gcov_collect(); # collect coverage information
+  }
+
+  if ( $opt_gcov )
+  {
+    gcov_collect(); # collect coverage information
+  }
+
+  exit(1);
 }
 
 
 sub ignore_option {
   my ($opt, $value)= @_;
-  print "Ignoring option '$opt'\n";
+  mtr_report("Ignoring option '$opt'");
 }
 
 sub command_line_setup {
+  my ($thread_num)= @_;
+
   my $opt_comment;
   my $opt_usage;
 
-  # This is needed for test log evaluation in "gen-build-status-page"
-  # in all cases where the calling tool does not log the commands
-  # directly before it executes them, like "make test-force-pl" in RPM builds.
-  mtr_report("Logging: $0 ", join(" ", @ARGV));
+  # Default verbosity, server ON and workers OFF
+  report_option('verbose', $thread_num ?  undef : 0);
 
   # Read the command line options
   # Note: Keep list, and the order, in sync with usage at end of this file
@@ -335,7 +720,7 @@ sub command_line_setup {
 	     'skip-im'                  => \&ignore_option,
 
              # Specify ports
-	     'build-thread|mtr-build-thread=i' => \$opt_mtr_build_thread,
+	     'build-thread|mtr-build-thread=i' => \$opt_build_thread,
 
              # Test case authoring
              'record'                   => \$opt_record,
@@ -365,6 +750,7 @@ sub command_line_setup {
              'strace-client:s'          => \$opt_strace_client,
              'max-save-core=i'          => \$opt_max_save_core,
              'max-save-datadir=i'       => \$opt_max_save_datadir,
+             'max-test-fail=i'          => \$opt_max_test_fail,
 
              # Coverage, profiling etc
              'gcov'                     => \$opt_gcov,
@@ -398,10 +784,10 @@ sub command_line_setup {
              'report-features'          => \$opt_report_features,
              'comment=s'                => \$opt_comment,
              'fast'                     => \$opt_fast,
-             'reorder'                  => \&collect_option,
+             'reorder!'                 => \&collect_option,
              'enable-disabled'          => \&collect_option,
              'verbose+'                 => \$opt_verbose,
-             'verbose-restart'          => \$opt_verbose_restart,
+             'verbose-restart'          => \&report_option,
              'sleep=i'                  => \$opt_sleep,
              'start-dirty'              => \$opt_start_dirty,
              'start'                    => \$opt_start,
@@ -409,23 +795,32 @@ sub command_line_setup {
 	     'repeat=i'                 => \$opt_repeat,
 	     'retry=i'                  => \$opt_retry,
 	     'retry-failure=i'          => \$opt_retry_failure,
-             'timer!'                   => \$opt_timer,
+             'timer!'                   => \&report_option,
              'user=s'                   => \$opt_user,
              'testcase-timeout=i'       => \$opt_testcase_timeout,
              'suite-timeout=i'          => \$opt_suite_timeout,
              'shutdown-timeout=i'       => \$opt_shutdown_timeout,
              'warnings!'                => \$opt_warnings,
 	     'timestamp'                => \&report_option,
+	     'timediff'                 => \&report_option,
 
              'help|h'                   => \$opt_usage,
-            ) or usage("Can't read options");
+            ) or usage($thread_num, "Can't read options");
 
-  usage("") if $opt_usage;
+  usage($thread_num, "") if $opt_usage;
+
+  # --------------------------------------------------------------------------
+  # Setup verbosity
+  # --------------------------------------------------------------------------
+  if ($opt_verbose != 0){
+    report_option('verbose', $opt_verbose);
+  }
 
   # --------------------------------------------------------------------------
-  # Check mtr_build_thread and calculate baseport
+  # Check build_thread and calculate baseport
+  # Use auto build thread in all but first worker
   # --------------------------------------------------------------------------
-  set_mtr_build_thread_ports($opt_mtr_build_thread);
+  set_build_thread_ports($thread_num > 1 ? 'auto' : $opt_build_thread);
 
   if ( -d "../sql" )
   {
@@ -515,7 +910,7 @@ sub command_line_setup {
     }
     elsif ( $arg =~ /^-/ )
     {
-      usage("Invalid option \"$arg\"");
+      usage($thread_num, "Invalid option \"$arg\"");
     }
     else
     {
@@ -552,8 +947,9 @@ sub command_line_setup {
 
   # --------------------------------------------------------------------------
   # Check if we should speed up tests by trying to run on tmpfs
+  # - Dont check in workers
   # --------------------------------------------------------------------------
-  if ( defined $opt_mem )
+  if ( defined $opt_mem and $thread_num == 0)
   {
     mtr_error("Can't use --mem and --vardir at the same time ")
       if $opt_vardir;
@@ -569,7 +965,7 @@ sub command_line_setup {
     {
       if ( -d $fs )
       {
-	my $template= "var_${opt_mtr_build_thread}_XXXX";
+	my $template= "var_${opt_build_thread}_XXXX";
 	$opt_mem= tempdir( $template, DIR => $fs, CLEANUP => 0);
 	last;
       }
@@ -585,6 +981,11 @@ sub command_line_setup {
     $opt_vardir= $default_vardir;
   }
 
+  # If more than one parallel run, use a subdir of the selected var
+  if ($thread_num && $opt_parallel > 1) {
+    $opt_vardir.= "/".$thread_num;
+   }
+
   $path_vardir_trace= $opt_vardir;
   # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
   $path_vardir_trace=~ s/^\w://;
@@ -606,6 +1007,11 @@ sub command_line_setup {
   $opt_tmpdir=       "$opt_vardir/tmp" unless $opt_tmpdir;
   $opt_tmpdir =~ s,/+$,,;       # Remove ending slash if any
 
+  # If more than one parallel run, use a subdir of the selected tmpdir
+  if ($thread_num && $opt_parallel > 1 and $opt_tmpdir ne "$opt_vardir/tmp") {
+    $opt_tmpdir.= "/".$thread_num;
+   }
+
   # --------------------------------------------------------------------------
   # fast option
   # --------------------------------------------------------------------------
@@ -683,6 +1089,11 @@ sub command_line_setup {
   }
 
   # --------------------------------------------------------------------------
+  # Set timeout values
+  # --------------------------------------------------------------------------
+  $opt_start_timeout*= $opt_parallel;
+
+  #
   # Check valgrind arguments
   # --------------------------------------------------------------------------
   if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args)
@@ -738,6 +1149,16 @@ sub command_line_setup {
   $path_testlog=         "$opt_vardir/log/mysqltest.log";
   $path_current_testlog= "$opt_vardir/log/current_test";
 
+  mtr_report("Checking supported features...");
+
+  check_ndbcluster_support(\%mysqld_variables);
+  check_ssl_support(\%mysqld_variables);
+  check_debug_support(\%mysqld_variables);
+
+  executable_setup();
+
+  environment_setup();
+
 }
 
 
@@ -756,19 +1177,20 @@ sub command_line_setup {
 # http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html
 # But a fairly safe range seems to be 5001 - 32767
 #
-sub set_mtr_build_thread_ports($) {
-  my $mtr_build_thread= shift || 0;
+sub set_build_thread_ports($) {
+  my $build_thread= shift || 0;
 
-  if ( lc($mtr_build_thread) eq 'auto' ) {
-    print "Requesting build thread... ";
-    $mtr_build_thread=
+  if ( lc($build_thread) eq 'auto' ) {
+    mtr_report("Requesting build thread... ");
+    $build_thread=
       mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
-    print "got ".$mtr_build_thread."\n";
+    mtr_report(" - got $build_thread");
   }
-  $ENV{MTR_BUILD_THREAD}= $mtr_build_thread;
+  $ENV{MTR_BUILD_THREAD}= $build_thread;
+  $opt_build_thread= $build_thread;
 
   # Calculate baseport
-  $opt_baseport= $mtr_build_thread * 10 + 10000;
+  $opt_baseport= $build_thread * 10 + 10000;
   if ( $opt_baseport < 5001 or $opt_baseport + 9 >= 32767 )
   {
     mtr_error("MTR_BUILD_THREAD number results in a port",
@@ -776,7 +1198,7 @@ sub set_mtr_build_thread_ports($) {
               "($opt_baseport - $opt_baseport + 9)");
   }
 
-  mtr_report("Using MR_BUILD_THREAD $mtr_build_thread,",
+  mtr_report("Using MTR_BUILD_THREAD $build_thread,",
 	     "with reserved ports $opt_baseport..".($opt_baseport+9));
 
 }
@@ -1131,8 +1553,8 @@ sub environment_setup {
 
   $ENV{'UDF_EXAMPLE_LIB'}=
     ($lib_udf_example ? basename($lib_udf_example) : "");
-  $ENV{'UDF_EXAMPLE_LIB_OPT'}=
-    ($lib_udf_example ? "--plugin_dir=" . dirname($lib_udf_example) : "");
+  $ENV{'UDF_EXAMPLE_LIB_OPT'}= "--plugin-dir=".
+    ($lib_udf_example ? dirname($lib_udf_example) : "");
 
   # --------------------------------------------------------------------------
   # Add the path where mysqld will find ha_example.so
@@ -1143,9 +1565,9 @@ sub environment_setup {
 		      "$basedir/storage/example/.libs/ha_example.so",);
     $ENV{'EXAMPLE_PLUGIN'}=
       ($lib_example_plugin ? basename($lib_example_plugin) : "");
-    $ENV{'EXAMPLE_PLUGIN_OPT'}=
-      ($lib_example_plugin ?
-       "--plugin_dir=" . dirname($lib_example_plugin) : "");
+    $ENV{'EXAMPLE_PLUGIN_OPT'}= "--plugin-dir=".
+      ($lib_example_plugin ? dirname($lib_example_plugin) : "");
+
   }
 
   # --------------------------------------------------------------------------
@@ -1408,7 +1830,7 @@ sub remove_stale_vardir () {
 # Create var and the directories needed in var
 #
 sub setup_vardir() {
-  mtr_report("Creating var directory...");
+  mtr_report("Creating var directory '$opt_vardir'...");
 
   if ( $opt_vardir eq $default_vardir )
   {
@@ -1617,7 +2039,7 @@ sub ndbcluster_wait_started($$){
   mtr_init_args(\$args);
   mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
   mtr_add_arg($args, "--defaults-group-suffix=%s", $cluster->suffix());
-  mtr_add_arg($args, "--timeout=60");
+  mtr_add_arg($args, "--timeout=%d", $opt_start_timeout);
 
   if ($ndb_waiter_extra_opt)
   {
@@ -1796,76 +2218,6 @@ sub ndbcluster_start ($) {
 }
 
 
-#
-# Run the collected tests
-#
-my $suite_timeout_proc;
-sub run_tests {
-  my ($tests)= @_;
-
-  mtr_report();
-  mtr_print_thick_line();
-  mtr_print_header();
-
-  $suite_timeout_proc= My::SafeProcess->timer($opt_suite_timeout* 60);
-  foreach my $tinfo ( @$tests )
-  {
-    if (run_testcase_check_skip_test($tinfo))
-    {
-      next;
-    }
-
-    for my $repeat (1..$opt_repeat){
-
-      if (run_testcase($tinfo))
-      {
-	# Testcase failed, enter retry mode
-	my $retries= 1;
-	while ($retries < $opt_retry){
-	  mtr_report("\nRetrying, attempt($retries/$opt_retry)...\n");
-
-	  if (run_testcase($tinfo) <= 0)
-	  {
-	    # Testcase suceeded
-
-	    my $test_has_failed= $tinfo->{failures} || 0;
-	    if (!$test_has_failed){
-	      last;
-	    }
-	  }
-	  else
-	  {
-	    # Testcase failed
-
-	    # Limit number of test failures
-	    my $failures= $tinfo->{failures};
-	    if ($opt_retry > 1 and $failures >= $opt_retry_failure){
-	      mtr_report("Test has failed $failures times, no more retries!\n");
-	      last;
-	    }
-	  }
-	  $retries++;
-	}
-      }
-    }
-  }
-  # Kill the test suite timer
-  $suite_timeout_proc->kill();
-
-  mtr_print_line();
-
-  stop_all_servers();
-
-  if ( $opt_gcov )
-  {
-    gcov_collect(); # collect coverage information
-  }
-
-  mtr_report_stats($tests);
-
-}
-
-
 sub create_config_file_for_extern {
   my %opts=
     (
@@ -2013,7 +2365,7 @@ sub initialize_servers {
       remove_stale_vardir();
       setup_vardir();
 
-      mysql_install_db();
+      mysql_install_db(0);
     }
   }
   check_running_as_root();
@@ -2070,6 +2422,7 @@ sub sql_to_bootstrap {
 
 
 sub mysql_install_db {
+  my ($thread_num)= @_;
   my $data_dir= "$opt_vardir/install.db";
 
   mtr_report("Installing system database...");
@@ -2112,6 +2465,8 @@ sub mysql_install_db {
   # ----------------------------------------------------------------------
   $ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
 
+  return if $thread_num > 0; # Only generate MYSQLD_BOOTSTRAP_CMD in workers
+
   # ----------------------------------------------------------------------
   # Create the bootstrap.sql file
   # ----------------------------------------------------------------------
@@ -2270,25 +2625,111 @@ sub do_before_run_mysqltest($)
 }
 
 
+#
+# Check all server for sideffects
+#
+# RETURN VALUE
+#  0 ok
+#  1 Check failed
+#  >1 Fatal errro
+
 sub check_testcase($$)
 {
   my ($tinfo, $mode)= @_;
-  my $result;
+  my $tname= $tinfo->{name};
 
-  # Parallell( mysqlds(), run_check_testcase, check_testcase_failed );
+  # Start the mysqltest processes in parallel to save time
+  # also makes it possible to wait for any process to exit during the check
+  my %started;
   foreach my $mysqld ( mysqlds() )
   {
     if ( defined $mysqld->{'proc'} )
     {
-      if (run_check_testcase($tinfo, $mode, $mysqld))
+      my $proc= start_check_testcase($tinfo, $mode, $mysqld);
+      $started{$proc->pid()}= $proc;
+    }
+  }
+
+  # Return immediately if no check proceess was started
+  return 0 unless ( keys %started );
+
+  while (1){
+    my $result;
+    my $proc= My::SafeProcess->wait_any();
+    mtr_report("Got $proc");
+
+    if ( delete $started{$proc->pid()} ) {
+
+      my $err_file= $proc->user_data();
+      my $base_file= mtr_match_extension($err_file, "err"); # Trim extension
+
+      # One check testcase process returned
+      my $res= $proc->exit_status();
+
+      if ( $res == 0){
+	# Check completed without problem
+
+	# Remove the .err file the check generated
+	unlink($err_file);
+
+	# Remove the .result file the check generated
+	if ( $mode eq 'after' ){
+	  unlink("$base_file.result");
+	}
+
+	if ( keys(%started) == 0){
+	  # All checks completed
+	  return 0;
+	}
+	# Wait for next process to exit
+	next;
+      }
+      else
       {
-	# Check failed, mark the test case with that info
-	$tinfo->{'check_testcase_failed'}= 1;
-	$result= 1;
+	if ( $mode eq "after" and $res == 1 )
+	{
+	  # Test failed, grab the report mysqltest has created
+	  my $report= mtr_grab_file($err_file);
+	  $tinfo->{check}.=
+	    "\nThe check of testcase '$tname' failed, this is the\n".
+	      "diff between before and after:\n";
+	  $tinfo->{check}.= $report;
+
+	  # Check failed, mark the test case with that info
+	  $tinfo->{'check_testcase_failed'}= 1;
+	  $result= 1;
+	}
+	elsif ( $res )
+	{
+	  my $report= mtr_grab_file($err_file);
+	  $tinfo->{comment}.=
+	    "Could not execute 'check-testcase' $mode testcase '$tname':\n";
+	  $tinfo->{comment}.= $report;
+
+	  $result= 2;
+	}
+
+	# Remove the .err file the check generated
+	unlink($err_file);
+
+	# Remove the .result file the check generated
+	unlink("$base_file.result");
+
       }
     }
+    else {
+      # Unknown process returned, most likley a crash, abort everything
+      $tinfo->{comment}=
+	"Unexpected process $proc returned during ".
+	"check testcase $mode test";
+      $result= 3;
+    }
+
+    # Kill any check processes still running
+    map($_->kill(), values(%started));
+
+    return $result;
   }
-  return $result;
 }
 
 
@@ -2439,16 +2880,15 @@ sub run_testcase ($) {
   # ----------------------------------------------------------------------
   if ( $opt_start or $opt_start_dirty )
   {
-    $suite_timeout_proc->kill();
-    mtr_report("\nStarted", started(all_servers()));
-    mtr_report("Waiting for server(s) to exit...");
+    mtr_print("\nStarted", started(all_servers()));
+    mtr_print("Waiting for server(s) to exit...");
     my $proc= My::SafeProcess->wait_any();
     if ( grep($proc eq $_, started(all_servers())) )
     {
-      mtr_report("Server $proc died");
+      mtr_print("Server $proc died");
       exit(1);
     }
-    mtr_report("Unknown process $proc died");
+    mtr_print("Unknown process $proc died");
     exit(1);
   }
 
@@ -2456,9 +2896,14 @@ sub run_testcase ($) {
 
   do_before_run_mysqltest($tinfo);
 
-  if ( $opt_check_testcases )
-  {
-    check_testcase($tinfo, "before")
+  if ( $opt_check_testcases and check_testcase($tinfo, "before") ){
+    # Failed to record state of server or server crashed
+    report_failure_and_restart($tinfo);
+
+    # Stop the test case timer
+    $test_timeout_proc->kill();
+
+    return 1;
   }
 
   my $test= start_mysqltest($tinfo);
@@ -2492,15 +2937,23 @@ sub run_testcase ($) {
 	}
 	else
 	{
-	  mtr_report_test_passed($tinfo, $opt_timer);
+	  mtr_report_test_passed($tinfo);
 	}
 
-	if ( $opt_check_testcases and check_testcase($tinfo, "after"))
+	my $check_res;
+	if ( $opt_check_testcases and
+	     $check_res= check_testcase($tinfo, "after"))
 	{
-	  # Stop all servers that are known to be running
-	  stop_all_servers();
-	  clean_datadir();
-	  mtr_report("Resuming tests...\n");
+	  if ($check_res == 1) {
+	    # Test case had sideeffects, not fatal error, just continue
+	    stop_all_servers();
+	    mtr_report("Resuming tests...\n");
+	  }
+	  else {
+	    # Test case check failed fatally, probably a server crashed
+	    report_failure_and_restart($tinfo);
+	    return 1;
+	  }
 	}
       }
       elsif ( $res == 62 )
@@ -2584,15 +3037,6 @@ sub run_testcase ($) {
       return 1;
     }
 
-    # ----------------------------------------------------
-    # Check if test suite timer expired
-    # ----------------------------------------------------
-    if ( $proc eq $suite_timeout_proc )
-    {
-      mtr_report("Test suite timeout! Terminating...");
-      exit(1);
-    }
-
     mtr_error("Unhandled process $proc exited");
   }
   mtr_error("Should never come here");
@@ -2605,7 +3049,7 @@ sub run_testcase ($) {
 #  0 OK
 #  1 Check failed
 #
-sub run_check_warnings ($$) {
+sub start_check_warnings ($$) {
   my $tinfo=    shift;
   my $mysqld=   shift;
 
@@ -2640,37 +3084,17 @@ sub run_check_warnings ($$) {
   }
 
   my $errfile= "$opt_vardir/tmp/$name.err";
-  my $res= My::SafeProcess->run
+  my $proc= My::SafeProcess->new
     (
      name          => $name,
      path          => $exe_mysqltest,
      error         => $errfile,
      output        => $errfile,
      args          => \$args,
+     user_data     => $errfile,
     );
-
-  if ( $res == 0 )
-  {
-    my $report= mtr_grab_file($errfile);
-    # Log to var/log/warnings file
-    mtr_tofile("$opt_vardir/log/warnings",
-               $tname."\n",
-               $report);
-
-    $res= 1;
-    $tinfo->{'warnings'}.= $report;
-  }
-  elsif ( $res == 62 ) {
-    # Test case was ok and called "skip"
-    $res= 0;
-  }
-  elsif ( $res )
-  {
-    mtr_report("\nCould not execute 'check-warnings' for testcase '$tname':");
-    mtr_printfile($errfile);
-    $res= 0; # Ignore error
-  }
-  return $res;
+  mtr_verbose("Started $proc");
+  return $proc;
 }
 
 
@@ -2682,17 +3106,94 @@ sub check_warnings ($) {
   my ($tinfo)= @_;
   my $res= 0;
 
+  my $tname= $tinfo->{name};
+
   # Clear previous warnings
-  $tinfo->{warnings}= undef;
+  delete($tinfo->{warnings});
 
-  # Parallell( mysqlds(), run_check_warning, check_warning_failed);
+  # Start the mysqltest processes in parallel to save time
+  # also makes it possible to wait for any process to exit during the check
+  my %started;
   foreach my $mysqld ( mysqlds() )
   {
-    if (run_check_warnings($tinfo, $mysqld)){
-      $res= 1;
-      mtr_report();
+    if ( defined $mysqld->{'proc'} )
+    {
+      my $proc= start_check_warnings($tinfo, $mysqld);
+      $started{$proc->pid()}= $proc;
     }
   }
+
+  # Return immediately if no check proceess was started
+  return 0 unless ( keys %started );
+
+  while (1){
+    my $result= 0;
+    my $proc= My::SafeProcess->wait_any();
+    mtr_report("Got $proc");
+
+    if ( delete $started{$proc->pid()} ) {
+      # One check warning process returned
+      my $res= $proc->exit_status();
+      my $err_file= $proc->user_data();
+
+      if ( $res == 0 or $res == 62 ){
+
+	if ( $res == 0 ) {
+	  # Check completed with problem
+	  my $report= mtr_grab_file($err_file);
+	  # Log to var/log/warnings file
+	  mtr_tofile("$opt_vardir/log/warnings",
+		     $tname."\n".$report);
+
+	  $tinfo->{'warnings'}.= $report;
+	  $result= 1;
+	}
+
+	if ( $res == 62 ) {
+	  # Test case was ok and called "skip"
+	  ;
+	}
+	# Remove the .err file the check generated
+	unlink($err_file);
+
+	if ( keys(%started) == 0){
+	  # All checks completed
+	  return $result;
+	}
+	# Wait for next process to exit
+	next;
+      }
+      else
+      {
+	my $report= mtr_grab_file($err_file);
+	$tinfo->{comment}.=
+	  "Could not execute 'check-warnings' for testcase '$tname':";
+	$tinfo->{comment}.= $report;
+
+	$result= 2;
+      }
+      # Remove the .err file the check generated
+      unlink($err_file);
+    }
+    else {
+      # Unknown process returned, most likley a crash, abort everything
+      $tinfo->{comment}=
+	"Unexpected process $proc returned during ".
+	"check warnings";
+      $result= 3;
+    }
+
+    # Kill any check processes still running
+    map($_->kill(), values(%started));
+
+    return $result;
+  }
+
+
+
+
+  return $res;
+
   return $res;
 }
 
@@ -2747,10 +3248,41 @@ sub check_expected_crash_and_restart {
 }
 
 
+# Remove all files and subdirectories of a directory
+sub clean_dir {
+  my ($dir)= @_;
+  mtr_verbose("clean_dir: $dir");
+  finddepth(
+	  { no_chdir => 1,
+	    wanted => sub {
+	      if (-d $_){
+		# A dir
+		if ($_ eq $dir){
+		  # The dir to clean
+		  return;
+		} else {
+		  mtr_verbose("rmdir: '$_'");
+		  rmdir($_) or mtr_warning("rmdir($_) failed: $!");
+		}
+	      } else {
+		# Hopefully a file
+		mtr_verbose("unlink: '$_'");
+		unlink($_) or mtr_warning("unlink($_) failed: $!");
+	      }
+	    }
+	  },
+	    $dir);
+}
+
+
 sub clean_datadir {
 
   mtr_verbose("Cleaning datadirs...");
 
+  if (started(all_servers()) != 0){
+    mtr_error("Trying to clean datadir before all servers stopped");
+  }
+
   foreach my $cluster ( clusters() )
   {
     my $cluster_dir= "$opt_vardir/".$cluster->{name};
@@ -2769,55 +3301,22 @@ sub clean_datadir {
   }
 
   # Remove all files in tmp and var/tmp
-  rmtree("$opt_vardir/tmp");
-  mkpath("$opt_vardir/tmp");
+  clean_dir("$opt_vardir/tmp");
   if ($opt_tmpdir ne "$opt_vardir/tmp"){
-    rmtree($opt_tmpdir);
-    mkpath($opt_tmpdir);
+    clean_dir($opt_tmpdir);
   }
 }
 
 
 #
-# Limit number of core files saved
-#
-sub limit_cores_after_failure ($) {
-  my ($datadir)= @_;
-
-  # Look for core files
-  foreach my $core_file ( glob("$datadir/core*") )
-  {
-    my $core_name= basename($core_file);
-    if ($opt_max_save_core > 0 && $num_saved_cores >= $opt_max_save_core) {
-      # Delete file to avoid saving it  when the datadir is later saved
-      mtr_report(" - deleting '$core_name'",
-		 "($num_saved_cores/$opt_max_save_core)");
-      unlink("$core_file");
-    }
-    else {
-      mtr_report(" - found '$core_name'",
-		 "($num_saved_cores/$opt_max_save_core)");
-    }
-    ++$num_saved_cores;
-  }
-}
-
-#
 # Save datadir before it's removed
 #
 sub save_datadir_after_failure($$) {
   my ($dir, $savedir)= @_;
 
-  if ($opt_max_save_datadir > 0 &&
-      $num_saved_datadir >= $opt_max_save_datadir)
-  {
-    mtr_report(" - skipping '$dir'");
-  }
-  else {
-    mtr_report(" - saving '$dir'");
-    my $dir_name= basename($dir);
-    rename("$dir", "$savedir/$dir_name");
-  }
+  mtr_report(" - saving '$dir'");
+  my $dir_name= basename($dir);
+  rename("$dir", "$savedir/$dir_name");
 }
 
 
@@ -2832,19 +3331,19 @@ sub after_failure ($) {
   $save_dir.= "-$tinfo->{combination}"
     if defined $tinfo->{combination};
 
+  # Save savedir  path for server
+  $tinfo->{savedir}= $save_dir;
+
   mkpath($save_dir) if ! -d $save_dir;
 
   # Save the used my.cnf file
   copy($path_config_file, $save_dir);
 
+  # Copy the tmp dir
+  copytree("$opt_vardir/tmp/", "$save_dir/tmp/");
+
   if ( clusters() ) {
     foreach my $cluster ( clusters() ) {
-
-      foreach my $server ( ndbds($cluster), ndb_mgmds($cluster) ) {
-	my $data_dir= $server->value('DataDir');
-	limit_cores_after_failure($data_dir);
-      }
-
       my $cluster_dir= "$opt_vardir/".$cluster->{name};
       save_datadir_after_failure($cluster_dir, $save_dir);
     }
@@ -2852,33 +3351,43 @@ sub after_failure ($) {
   else {
     foreach my $mysqld ( mysqlds() ) {
       my $data_dir= $mysqld->value('datadir');
-      limit_cores_after_failure($data_dir);
       save_datadir_after_failure(dirname($data_dir), $save_dir);
     }
   }
-
-  $num_saved_datadir++;
-
-  clean_datadir();
 }
 
 
 sub report_failure_and_restart ($) {
   my $tinfo= shift;
 
-  mtr_report_test_failed($tinfo, $path_current_testlog);
-  print "\n";
-  if ( $opt_force )
-  {
-    # Stop all servers that are known to be running
-    stop_all_servers();
+  stop_all_servers();
 
-    after_failure($tinfo);
-    mtr_report("Resuming tests...\n");
-    return;
+  $tinfo->{'result'}= 'MTR_RES_FAILED';
+
+  my $test_failures= $tinfo->{'failures'} || 0;
+  $tinfo->{'failures'}=  $test_failures + 1;
+
+
+  my $logfile= $path_current_testlog;
+  if ( $tinfo->{comment} )
+  {
+    # The test failure has been detected by mysql-test-run.pl
+    # when starting the servers or due to other error, the reason for
+    # failing the test is saved in "comment"
+    ;
+  }
+  elsif ( defined $logfile and -f $logfile )
+  {
+    # Test failure was detected by test tool and its report
+    # about what failed has been saved to file. Save the report
+    # in tinfo
+    $tinfo->{logfile}= mtr_fromfile($logfile);
   }
-  mtr_error("Test '$tinfo->{'name'}' failed.",
-	    "To continue, re-run with '--force'");
+
+  after_failure($tinfo);
+
+  mtr_report_test($tinfo);
+
 }
 
 
@@ -3106,7 +3615,7 @@ sub mysqld_start ($$) {
 
 sub stop_all_servers () {
 
-  mtr_report("Stopping all servers...");
+  mtr_verbose("Stopping all servers...");
 
   # Kill all started servers
   My::SafeProcess::shutdown(0, # shutdown timeout 0 => kill
@@ -3273,12 +3782,32 @@ sub started { return grep(defined $_, ma
 sub stopped { return grep(!defined $_, map($_->{proc}, @_)); }
 
 
+sub envsubst {
+  my $string= shift;
+
+  if ( ! defined $ENV{$string} )
+  {
+    mtr_error(".opt file references '$string' which is not set");
+  }
+
+  return $ENV{$string};
+}
+
+
 sub get_extra_opts {
   my ($mysqld, $tinfo)= @_;
 
-  return
+  my $opts=
     $mysqld->option("#!use-slave-opt") ?
       $tinfo->{slave_opt} : $tinfo->{master_opt};
+
+  # Expand environment variables
+  foreach my $opt ( @$opts )
+  {
+    $opt =~ s/\$\{(\w+)\}/envsubst($1)/ge;
+    $opt =~ s/\$(\w+)/envsubst($1)/ge;
+  }
+  return $opts;
 }
 
 
@@ -3382,9 +3911,18 @@ sub start_servers($) {
     }
 
     # Copy datadir from installed system db
-    copytree("$opt_vardir/install.db", $datadir)
+    for my $path ( "$opt_vardir", "$opt_vardir/..") {
+      my $install_db= "$path/install.db";
+      copytree($install_db, $datadir)
+	if -d $install_db;
+    }
+    mtr_error("Failed to copy system db to '$datadir'")
       unless -d $datadir;
 
+    # Create the servers tmpdir
+    my $tmpdir= $mysqld->value('tmpdir');
+    mkpath($tmpdir) unless -d $tmpdir;
+
     # Write start of testcase to log file
     mark_log($mysqld->value('log-error'), $tinfo);
 
@@ -3449,10 +3987,9 @@ sub start_servers($) {
 # After testcase, run and compare with the recorded file, they should be equal!
 #
 # RETURN VALUE
-#  0 OK
-#  1 Check failed
+#  The newly started process
 #
-sub run_check_testcase ($$$) {
+sub start_check_testcase ($$$) {
   my $tinfo=    shift;
   my $mode=     shift;
   my $mysqld=   shift;
@@ -3477,28 +4014,17 @@ sub run_check_testcase ($$$) {
     mtr_add_arg($args, "--record");
   }
   my $errfile= "$opt_vardir/tmp/$name.err";
-  my $res= My::SafeProcess->run
+  my $proc= My::SafeProcess->new
     (
      name          => $name,
      path          => $exe_mysqltest,
      error         => $errfile,
      args          => \$args,
+     user_data     => $errfile,
     );
 
-  if ( $mode eq "after" and $res == 1 )
-  {
-    mtr_report("\nThe check of testcase '$tname' failed, this is the\n",
-	       "diff between before and after:\n");
-    # Test failed, display the report mysqltest has created
-    mtr_printfile($errfile);
-  }
-  elsif ( $res )
-  {
-    mtr_report("\nCould not execute 'check-testcase' $mode testcase '$tname':");
-    mtr_printfile($errfile);
-    mtr_report();
-  }
-  return $res;
+  mtr_report("Started $proc");
+  return $proc;
 }
 
 
@@ -3556,10 +4082,7 @@ sub start_mysqltest ($) {
     mtr_add_arg($args, "$exe_mysqltest");
   }
 
-  if ( $opt_timer )
-  {
-    mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
-  }
+  mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
 
   if ( $opt_compress )
   {
@@ -3884,7 +4407,10 @@ sub valgrind_arguments {
 # Usage
 #
 sub usage ($) {
-  my $message= shift;
+  my ($thread_num, $message)= @_;
+
+  # Only main thread should print usage
+  return if $thread_num != 0;
 
   if ( $message )
   {
@@ -4008,6 +4534,10 @@ Options for debugging the product
                         up disks for heavily crashing server). Defaults to
                         $opt_max_save_datadir, set to 0 for no limit. Set
                         it's default with MTR_MAX_SAVE_DATDIR
+  max-test-fail         Limit the number of test failurs before aborting
+                        the current test run. Defaults to
+                        $opt_max_test_fail, set to 0 for no limit. Set
+                        it's default with MTR_MAX_TEST_FAIL
 
 Options for valgrind
 

=== modified file 'mysql-test/r/character_set_database_func.result'
--- a/mysql-test/r/character_set_database_func.result	2008-04-14 15:21:18 +0000
+++ b/mysql-test/r/character_set_database_func.result	2008-05-30 09:12:07 +0000
@@ -59,14 +59,14 @@ USE test;
 CREATE TABLE t1 (a CHAR(4) CHARACTER SET utf8) ENGINE=MyISAM CHARACTER SET utf8;
 'Verify with latin';
 SET @@session.character_set_database = latin1;
-LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data_ln/charset_utf8.txt' INTO TABLE t1;
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/charset_utf8.txt' INTO TABLE t1;
 SELECT count(*) FROM t1 WHERE CHAR_LENGTH(a)>1;
 count(*)
 2433
 TRUNCATE TABLE t1;
 'Verify with utf8';
 SET @@session.character_set_database = utf8;
-LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data_ln/charset_utf8.txt' INTO TABLE t1;
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/charset_utf8.txt' INTO TABLE t1;
 SELECT count(*) FROM t1 WHERE CHAR_LENGTH(a)>1;
 count(*)
 1

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2008-03-12 10:54:23 +0000
+++ b/mysql-test/r/func_time.result	2008-08-04 14:30:50 +0000
@@ -1078,6 +1078,7 @@ Note	1003	select timestampdiff(WEEK,'200
 select time_format('100:00:00', '%H %k %h %I %l');
 time_format('100:00:00', '%H %k %h %I %l')
 100 100 04 04 4
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 create table t1 (a timestamp default '2005-05-05 01:01:01',
 b timestamp default '2005-05-05 01:01:01');
@@ -1121,6 +1122,7 @@ call t_sysdate();
 @a != @b
 1
 drop procedure t_sysdate;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 select timestampdiff(month,'2004-09-11','2004-09-11');
 timestampdiff(month,'2004-09-11','2004-09-11')
 0

=== modified file 'mysql-test/r/grant.result'
--- a/mysql-test/r/grant.result	2008-06-10 22:27:52 +0000
+++ b/mysql-test/r/grant.result	2008-08-04 14:30:50 +0000
@@ -1,3 +1,4 @@
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 drop table if exists t1;
 drop database if exists mysqltest;
@@ -1351,4 +1352,4 @@ DROP PROCEDURE sp3;
 DROP USER 'userbug33464'@'localhost';
 use test;
 DROP DATABASE dbbug33464;
-End of 5.1 tests
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;

=== modified file 'mysql-test/r/grant2.result'
--- a/mysql-test/r/grant2.result	2008-03-18 10:54:37 +0000
+++ b/mysql-test/r/grant2.result	2008-08-04 14:30:50 +0000
@@ -365,6 +365,7 @@ insert into mysql.user select * from t1;
 drop table t1, t2;
 drop database TESTDB;
 flush privileges;
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 grant all privileges on test.* to `a@`@localhost;
 grant execute on * to `a@`@localhost;
@@ -380,7 +381,7 @@ drop function f2;
 drop table t2;
 REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost;
 drop user `a@`@localhost;
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 drop database if exists mysqltest_1;
 drop database if exists mysqltest_2;
 drop user mysqltest_u1@localhost;

=== modified file 'mysql-test/r/innodb_max_dirty_pages_pct_func.result'
--- a/mysql-test/r/innodb_max_dirty_pages_pct_func.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/innodb_max_dirty_pages_pct_func.result	2008-07-06 17:14:41 +0000
@@ -1,4 +1,5 @@
 '#--------------------FN_DYNVARS_044_02-------------------------#'
+SET @old_innodb_max_dirty_pages_pct= @@global.innodb_max_dirty_pages_pct;
 SET @@global.innodb_max_dirty_pages_pct = 80;
 'connect (con1,localhost,root,,,,)'
 'connection con1'
@@ -28,3 +29,5 @@ DROP PROCEDURE add_records;
 DROP PROCEDURE add_until;
 DROP PROCEDURE check_pct;
 DROP FUNCTION dirty_pct;
+DROP TABLE t1;
+SET @@global.innodb_max_dirty_pages_pct = @old_innodb_max_dirty_pages_pct;

=== modified file 'mysql-test/r/innodb_notembedded.result'
--- a/mysql-test/r/innodb_notembedded.result	2006-11-17 20:30:28 +0000
+++ b/mysql-test/r/innodb_notembedded.result	2008-07-10 16:09:39 +0000
@@ -1,4 +1,5 @@
 drop table if exists t1;
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 create table t1 (col1 integer primary key, col2 integer) engine=innodb;
 insert t1 values (1,100);
@@ -19,4 +20,4 @@ rollback;
 rollback;
 drop table t1;
 drop function f1;
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;

=== modified file 'mysql-test/r/loaddata.result'
--- a/mysql-test/r/loaddata.result	2008-06-10 22:27:52 +0000
+++ b/mysql-test/r/loaddata.result	2008-08-04 14:30:50 +0000
@@ -212,7 +212,7 @@ set @@secure_file_priv= 0;
 ERROR HY000: Variable 'secure_file_priv' is a read only variable
 truncate table t1;
 load data infile 'MYSQL_TEST_DIR/t/loaddata.test' into table t1;
-ERROR HY000: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
+Got one of the listed errors
 select * from t1;
 a	b	c
 select load_file("MYSQL_TEST_DIR/t/loaddata.test");

=== modified file 'mysql-test/r/log_bin_trust_function_creators_func.result'
--- a/mysql-test/r/log_bin_trust_function_creators_func.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/log_bin_trust_function_creators_func.result	2008-07-10 16:09:39 +0000
@@ -3,6 +3,7 @@ drop table if exists t1;
 ## Creating new user tt ##
 CREATE user tt@localhost;
 ## Setting value of variable to 0 ##
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET @@global.log_bin_trust_function_creators = 0;
 ## Creating new table t2 ##
 create table t2 (a INT);
@@ -69,3 +70,5 @@ drop function f1;
 ## Dropping table t1 & t2 ##
 drop table t1,t2;
 ## Disconnecting both the connections ##
+DROP USER tt@localhost;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;

=== added file 'mysql-test/r/multi_range_count_basic_32.result'
--- a/mysql-test/r/multi_range_count_basic_32.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/multi_range_count_basic_32.result	2008-05-08 18:13:39 +0000
@@ -0,0 +1,192 @@
+SET @start_global_value = @@global.multi_range_count;
+SELECT @start_global_value;
+@start_global_value
+256
+SET @start_session_value = @@session.multi_range_count;
+SELECT @start_session_value;
+@start_session_value
+256
+'#--------------------FN_DYNVARS_090_01-------------------------#'
+SET @@global.multi_range_count = 100;
+SET @@global.multi_range_count = DEFAULT;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+256
+SET @@session.multi_range_count = 200;
+SET @@session.multi_range_count = DEFAULT;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+256
+'#--------------------FN_DYNVARS_090_02-------------------------#'
+SET @@global.multi_range_count = DEFAULT;
+SELECT @@global.multi_range_count = 256;
+@@global.multi_range_count = 256
+1
+SET @@session.multi_range_count = DEFAULT;
+SELECT @@session.multi_range_count = 256;
+@@session.multi_range_count = 256
+1
+'#--------------------FN_DYNVARS_090_03-------------------------#'
+SET @@global.multi_range_count = 1;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+SET @@global.multi_range_count = 60020;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+60020
+SET @@global.multi_range_count = 65535;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+65535
+SET @@global.multi_range_count = 4294967295;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967295
+SET @@global.multi_range_count = 4294967294;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967294
+'#--------------------FN_DYNVARS_090_04-------------------------#'
+SET @@session.multi_range_count = 1;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+1
+SET @@session.multi_range_count = 50050;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+50050
+SET @@session.multi_range_count = 65535;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+65535
+SET @@session.multi_range_count = 4294967295;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967295
+SET @@session.multi_range_count = 4294967294;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967294
+'#------------------FN_DYNVARS_090_05-----------------------#'
+SET @@global.multi_range_count = 0;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+SET @@global.multi_range_count = 4294967296;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '4294967296'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967295
+SET @@global.multi_range_count = -1024;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+SET @@global.multi_range_count = 429496729500;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '429496729500'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967295
+SET @@global.multi_range_count = 65530.34;
+ERROR 42000: Incorrect argument type to variable 'multi_range_count'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967295
+SET @@global.multi_range_count = test;
+ERROR 42000: Incorrect argument type to variable 'multi_range_count'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967295
+SET @@session.multi_range_count = 0;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+1
+SET @@session.multi_range_count = 4294967296;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '4294967296'
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967295
+SET @@session.multi_range_count = -1;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+1
+SET @@session.multi_range_count = 65530.34.;
+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 '.' at line 1
+SET @@session.multi_range_count = 4294967295021;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '4294967295021'
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967295
+'Bug # 34837: Errors are not coming on assigning invalid values to variable';
+SET @@session.multi_range_count = test;
+ERROR 42000: Incorrect argument type to variable 'multi_range_count'
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967295
+'#------------------FN_DYNVARS_090_06-----------------------#'
+SELECT @@global.multi_range_count = VARIABLE_VALUE 
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES 
+WHERE VARIABLE_NAME='multi_range_count';
+@@global.multi_range_count = VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_090_07-----------------------#'
+SELECT @@session.multi_range_count = VARIABLE_VALUE 
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES 
+WHERE VARIABLE_NAME='multi_range_count';
+@@session.multi_range_count = VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_090_08-----------------------#'
+SET @@global.multi_range_count = TRUE;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+SET @@global.multi_range_count = FALSE;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+'#---------------------FN_DYNVARS_090_09----------------------#'
+SET @@global.multi_range_count = 10;
+SELECT @@multi_range_count = @@global.multi_range_count;
+@@multi_range_count = @@global.multi_range_count
+0
+'#---------------------FN_DYNVARS_090_10----------------------#'
+SET @@multi_range_count = 100;
+SELECT @@multi_range_count = @@local.multi_range_count;
+@@multi_range_count = @@local.multi_range_count
+1
+SELECT @@local.multi_range_count = @@session.multi_range_count;
+@@local.multi_range_count = @@session.multi_range_count
+1
+'#---------------------FN_DYNVARS_090_11----------------------#'
+SET multi_range_count = 1;
+SELECT @@multi_range_count;
+@@multi_range_count
+1
+SELECT local.multi_range_count;
+ERROR 42S02: Unknown table 'local' in field list
+SELECT session.multi_range_count;
+ERROR 42S02: Unknown table 'session' in field list
+SELECT multi_range_count = @@session.multi_range_count;
+ERROR 42S22: Unknown column 'multi_range_count' in 'field list'
+SET @@global.multi_range_count = @start_global_value;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+256
+SET @@session.multi_range_count = @start_session_value;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+256

=== added file 'mysql-test/r/multi_range_count_basic_64.result'
--- a/mysql-test/r/multi_range_count_basic_64.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/multi_range_count_basic_64.result	2008-05-08 18:13:39 +0000
@@ -0,0 +1,184 @@
+SET @start_global_value = @@global.multi_range_count;
+SELECT @start_global_value;
+@start_global_value
+256
+SET @start_session_value = @@session.multi_range_count;
+SELECT @start_session_value;
+@start_session_value
+256
+'#--------------------FN_DYNVARS_090_01-------------------------#'
+SET @@global.multi_range_count = 100;
+SET @@global.multi_range_count = DEFAULT;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+256
+SET @@session.multi_range_count = 200;
+SET @@session.multi_range_count = DEFAULT;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+256
+'#--------------------FN_DYNVARS_090_02-------------------------#'
+SET @@global.multi_range_count = DEFAULT;
+SELECT @@global.multi_range_count = 256;
+@@global.multi_range_count = 256
+1
+SET @@session.multi_range_count = DEFAULT;
+SELECT @@session.multi_range_count = 256;
+@@session.multi_range_count = 256
+1
+'#--------------------FN_DYNVARS_090_03-------------------------#'
+SET @@global.multi_range_count = 1;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+SET @@global.multi_range_count = 60020;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+60020
+SET @@global.multi_range_count = 65535;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+65535
+SET @@global.multi_range_count = 4294967295;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967295
+SET @@global.multi_range_count = 4294967294;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967294
+'#--------------------FN_DYNVARS_090_04-------------------------#'
+SET @@session.multi_range_count = 1;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+1
+SET @@session.multi_range_count = 50050;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+50050
+SET @@session.multi_range_count = 65535;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+65535
+SET @@session.multi_range_count = 4294967295;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967295
+SET @@session.multi_range_count = 4294967294;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967294
+'#------------------FN_DYNVARS_090_05-----------------------#'
+SET @@global.multi_range_count = 0;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+SET @@global.multi_range_count = 4294967296;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+4294967296
+SET @@global.multi_range_count = -1024;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+SET @@global.multi_range_count = 429496729500;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+429496729500
+SET @@global.multi_range_count = 65530.34;
+ERROR 42000: Incorrect argument type to variable 'multi_range_count'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+429496729500
+SET @@global.multi_range_count = test;
+ERROR 42000: Incorrect argument type to variable 'multi_range_count'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+429496729500
+SET @@session.multi_range_count = 0;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+1
+SET @@session.multi_range_count = 4294967296;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967296
+SET @@session.multi_range_count = -1;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+1
+SET @@session.multi_range_count = 65530.34.;
+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 '.' at line 1
+SET @@session.multi_range_count = 4294967295021;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967295021
+'Bug # 34837: Errors are not coming on assigning invalid values to variable';
+SET @@session.multi_range_count = test;
+ERROR 42000: Incorrect argument type to variable 'multi_range_count'
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+4294967295021
+'#------------------FN_DYNVARS_090_06-----------------------#'
+SELECT @@global.multi_range_count = VARIABLE_VALUE 
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES 
+WHERE VARIABLE_NAME='multi_range_count';
+@@global.multi_range_count = VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_090_07-----------------------#'
+SELECT @@session.multi_range_count = VARIABLE_VALUE 
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES 
+WHERE VARIABLE_NAME='multi_range_count';
+@@session.multi_range_count = VARIABLE_VALUE
+1
+'#------------------FN_DYNVARS_090_08-----------------------#'
+SET @@global.multi_range_count = TRUE;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+SET @@global.multi_range_count = FALSE;
+Warnings:
+Warning	1292	Truncated incorrect multi_range_count value: '0'
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+1
+'#---------------------FN_DYNVARS_090_09----------------------#'
+SET @@global.multi_range_count = 10;
+SELECT @@multi_range_count = @@global.multi_range_count;
+@@multi_range_count = @@global.multi_range_count
+0
+'#---------------------FN_DYNVARS_090_10----------------------#'
+SET @@multi_range_count = 100;
+SELECT @@multi_range_count = @@local.multi_range_count;
+@@multi_range_count = @@local.multi_range_count
+1
+SELECT @@local.multi_range_count = @@session.multi_range_count;
+@@local.multi_range_count = @@session.multi_range_count
+1
+'#---------------------FN_DYNVARS_090_11----------------------#'
+SET multi_range_count = 1;
+SELECT @@multi_range_count;
+@@multi_range_count
+1
+SELECT local.multi_range_count;
+ERROR 42S02: Unknown table 'local' in field list
+SELECT session.multi_range_count;
+ERROR 42S02: Unknown table 'session' in field list
+SELECT multi_range_count = @@session.multi_range_count;
+ERROR 42S22: Unknown column 'multi_range_count' in 'field list'
+SET @@global.multi_range_count = @start_global_value;
+SELECT @@global.multi_range_count;
+@@global.multi_range_count
+256
+SET @@session.multi_range_count = @start_session_value;
+SELECT @@session.multi_range_count;
+@@session.multi_range_count
+256

=== modified file 'mysql-test/r/mysqlbinlog_base64.result'
--- a/mysql-test/r/mysqlbinlog_base64.result	2007-12-12 17:19:24 +0000
+++ b/mysql-test/r/mysqlbinlog_base64.result	2008-07-28 07:15:20 +0000
@@ -1,3 +1,4 @@
+reset master;
 create table t1 (a int);
 insert into t1 values (1);
 insert into t1 values (2);

=== modified file 'mysql-test/r/query_cache.result'
--- a/mysql-test/r/query_cache.result	2008-07-22 14:16:22 +0000
+++ b/mysql-test/r/query_cache.result	2008-08-04 14:30:50 +0000
@@ -1066,12 +1066,13 @@ create procedure `p1`()
 begin
 select a, f1() from t1;
 end//
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 call p1()//
 a	f1()
 1	2
 2	2
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET GLOBAL log_bin_trust_function_creators = @old_log_bin_trust_function_creators;
 drop procedure p1//
 drop function f1//
 drop table t1//

=== modified file 'mysql-test/r/query_cache_notembedded.result'
--- a/mysql-test/r/query_cache_notembedded.result	2007-10-16 13:05:05 +0000
+++ b/mysql-test/r/query_cache_notembedded.result	2008-08-04 14:30:50 +0000
@@ -315,6 +315,7 @@ drop procedure f2;
 drop procedure f3;
 drop procedure f4;
 drop table t1;
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 reset query cache;
 drop function if exists f1;
@@ -347,7 +348,7 @@ id
 drop table t1;
 drop function f1;
 set GLOBAL query_cache_size=0;
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators = @old_log_bin_trust_function_creators;
 DROP DATABASE IF EXISTS bug30269;
 FLUSH STATUS;
 CREATE DATABASE bug30269;

=== modified file 'mysql-test/r/rpl_max_binlog_size_func.result'
--- a/mysql-test/r/rpl_max_binlog_size_func.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/rpl_max_binlog_size_func.result	2008-05-30 09:12:07 +0000
@@ -1,5 +1,8 @@
 DROP TABLE IF EXISTS t1;
 '--- check if log file is rotated after 4096 bytes ----' 
+SET @saved_max_binlog_size= @@global.max_binlog_size;
 SET @@global.max_binlog_size = 4096;
 CREATE TABLE t1(a CHAR(5));
 'mylog.000002 exists'
+SET @@global.max_binlog_size= @saved_max_binlog_size;
+DROP TABLE t1;

=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2008-07-22 14:16:22 +0000
+++ b/mysql-test/r/subselect.result	2008-08-04 14:30:50 +0000
@@ -1656,6 +1656,15 @@ SELECT DISTINCT (SELECT a) FROM t1 LIMIT
 4
 5
 DROP TABLE t1;
+create table t1 (a int, b decimal(13, 3));
+insert into t1 values (1, 0.123);
+select a, (select max(b) from t1) into outfile "../../tmp/subselect.out.file.1" from t1;
+delete from t1;
+load data infile "../../tmp/subselect.out.file.1" into table t1;
+select * from t1;
+a	b
+1	0.123
+drop table t1;
 CREATE TABLE `t1` (
 `id` int(11) NOT NULL auto_increment,
 `id_cns` tinyint(3) unsigned NOT NULL default '0',

=== modified file 'mysql-test/r/subselect_no_mat.result'
--- a/mysql-test/r/subselect_no_mat.result	2008-07-10 23:29:27 +0000
+++ b/mysql-test/r/subselect_no_mat.result	2008-08-04 14:30:50 +0000
@@ -1660,6 +1660,15 @@ SELECT DISTINCT (SELECT a) FROM t1 LIMIT
 4
 5
 DROP TABLE t1;
+create table t1 (a int, b decimal(13, 3));
+insert into t1 values (1, 0.123);
+select a, (select max(b) from t1) into outfile "../../tmp/subselect.out.file.1" from t1;
+delete from t1;
+load data infile "../../tmp/subselect.out.file.1" into table t1;
+select * from t1;
+a	b
+1	0.123
+drop table t1;
 CREATE TABLE `t1` (
 `id` int(11) NOT NULL auto_increment,
 `id_cns` tinyint(3) unsigned NOT NULL default '0',

=== modified file 'mysql-test/r/subselect_no_opts.result'
--- a/mysql-test/r/subselect_no_opts.result	2008-07-10 23:29:27 +0000
+++ b/mysql-test/r/subselect_no_opts.result	2008-08-04 14:30:50 +0000
@@ -1660,6 +1660,15 @@ SELECT DISTINCT (SELECT a) FROM t1 LIMIT
 4
 5
 DROP TABLE t1;
+create table t1 (a int, b decimal(13, 3));
+insert into t1 values (1, 0.123);
+select a, (select max(b) from t1) into outfile "../../tmp/subselect.out.file.1" from t1;
+delete from t1;
+load data infile "../../tmp/subselect.out.file.1" into table t1;
+select * from t1;
+a	b
+1	0.123
+drop table t1;
 CREATE TABLE `t1` (
 `id` int(11) NOT NULL auto_increment,
 `id_cns` tinyint(3) unsigned NOT NULL default '0',

=== modified file 'mysql-test/r/subselect_no_semijoin.result'
--- a/mysql-test/r/subselect_no_semijoin.result	2008-07-10 23:29:27 +0000
+++ b/mysql-test/r/subselect_no_semijoin.result	2008-08-04 14:30:50 +0000
@@ -1660,6 +1660,15 @@ SELECT DISTINCT (SELECT a) FROM t1 LIMIT
 4
 5
 DROP TABLE t1;
+create table t1 (a int, b decimal(13, 3));
+insert into t1 values (1, 0.123);
+select a, (select max(b) from t1) into outfile "../../tmp/subselect.out.file.1" from t1;
+delete from t1;
+load data infile "../../tmp/subselect.out.file.1" into table t1;
+select * from t1;
+a	b
+1	0.123
+drop table t1;
 CREATE TABLE `t1` (
 `id` int(11) NOT NULL auto_increment,
 `id_cns` tinyint(3) unsigned NOT NULL default '0',

=== modified file 'mysql-test/r/timezone2.result'
--- a/mysql-test/r/timezone2.result	2007-03-09 10:12:31 +0000
+++ b/mysql-test/r/timezone2.result	2008-07-10 16:09:39 +0000
@@ -269,6 +269,7 @@ select * from t1;
 convert_tz(NULL, NULL, NULL)
 NULL
 drop table t1;
+SET @old_log_bin_trust_function_creators = @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 create table t1 (ldt datetime, udt datetime);
 create function f1(i datetime) returns datetime
@@ -284,7 +285,7 @@ ldt	ldt2
 2006-04-19 16:30:00	2006-04-19 16:30:00
 drop table t1;
 drop function f1;
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 DROP TABLE IF EXISTS t1;
 CREATE TABLE t1 (t TIMESTAMP);
 INSERT INTO t1 VALUES (NULL), (NULL);

=== modified file 'mysql-test/r/wait_timeout_func.result'
--- a/mysql-test/r/wait_timeout_func.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/wait_timeout_func.result	2008-07-06 17:07:30 +0000
@@ -6,6 +6,7 @@ id INT NOT NULL auto_increment,
 PRIMARY KEY (id),
 name VARCHAR(30)
 );
+SET @old_wait_timeout = @@global.wait_timeout;
 '#--------------------FN_DYNVARS_186_01-------------------------#'
 ## Creating new connection test_con1 ## 
 ## Setting value of variable to 5 ##
@@ -25,6 +26,8 @@ SET @@global.wait_timeout = 1;
 ## Creating new connection ## 
 INSERT into t1(name) values('Record_3');
 ## Using sleep to check timeout ##
-## We cannot test it further because the server stops due to wait_timeout ## 
+## We cannot test it further because the server closes the connection due to wait_timeout ## 
 SELECT * from t1;
 ERROR HY000: MySQL server has gone away
+DROP TABLE t1;
+SET @@global.wait_timeout = @old_wait_timeout;

=== renamed file 'mysql-test/suite/rpl/data/rpl_bug28618.dat' => 'mysql-test/std_data/rpl_bug28618.dat'
=== renamed file 'mysql-test/suite/rpl/data/rpl_mixed.dat' => 'mysql-test/std_data/rpl_mixed.dat'
=== modified file 'mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test'
--- a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test	2008-04-03 19:40:10 +0000
+++ b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test	2008-07-10 16:09:39 +0000
@@ -51,6 +51,6 @@ enable_warnings;
 remove_file $MYSQLD_DATADIR/slave-relay-bin.000001;
 remove_file $MYSQLD_DATADIR/slave-relay-bin.index;
 stop slave sql_thread;
-let $keep_connection=1;
+let $slave_keep_connection=1;
 source include/wait_for_slave_sql_to_stop.inc;
 

=== modified file 'mysql-test/suite/federated/federated_bug_25714.test'
--- a/mysql-test/suite/federated/federated_bug_25714.test	2008-06-10 22:27:52 +0000
+++ b/mysql-test/suite/federated/federated_bug_25714.test	2008-08-04 14:30:50 +0000
@@ -5,7 +5,6 @@ if (`select LENGTH("$MYSQL_BUG25714") = 
 {
   skip Need bug25714 test program;
 }
-
 connection default;
 
 # Disable concurrent inserts to avoid test failures when reading
@@ -54,8 +53,8 @@ DROP TABLE federated.t1;
 connection slave;
 DROP TABLE federated.t1;
 
+
 source federated_cleanup.inc;
 
 connection default;
-
 SET @@GLOBAL.CONCURRENT_INSERT= @OLD_CONCURRENT_INSERT;

=== modified file 'mysql-test/suite/parts/inc/partition_layout_check1.inc'
--- a/mysql-test/suite/parts/inc/partition_layout_check1.inc	2008-07-22 14:16:22 +0000
+++ b/mysql-test/suite/parts/inc/partition_layout_check1.inc	2008-08-04 14:30:50 +0000
@@ -1,12 +1,12 @@
 ################################################################################
-# inc/partition_layout_check1.inc                                              #
+# inc/partition_layout_check1.inc                                          #
 #                                                                              #
 # Purpose:                                                                     #
 #   Store the SHOW CREATE TABLE output and the list of files belonging to      #
 #   this table + print this into the protocol                                  #
 #   This script is only usefule when sourced within the partitioning tests.    #
 #                                                                              #
-# Attention: The routine inc/partition_layout_check2.inc is very similar       #
+# Attention: The routine inc/partition_layout_check2.inc is very similar   #
 #            to this one. So if something has to be changed here it            #
 #            might be necessary to do it also there                            #
 #                                                                              #

=== modified file 'mysql-test/suite/parts/inc/partition_layout_check2.inc'
--- a/mysql-test/suite/parts/inc/partition_layout_check2.inc	2008-07-22 14:16:22 +0000
+++ b/mysql-test/suite/parts/inc/partition_layout_check2.inc	2008-08-04 14:30:50 +0000
@@ -7,7 +7,7 @@
 #   since the call of inc/partition_layout_check1.inc                          #
 #   This script is only usefule when sourced within the partitioning tests.    #
 #                                                                              #
-# Attention: The routine inc/partition_layout_check1.inc is very similar       #
+# Attention: The routine inc/partition_layout_check1.inc is very similar   #
 #            to this one. So if something has to be changed here it            #
 #            might be necessary to do it also there                            #
 #                                                                              #

=== removed directory 'mysql-test/suite/rpl/data'
=== modified file 'mysql-test/suite/rpl/include/rpl_mixed_dml.inc'
--- a/mysql-test/suite/rpl/include/rpl_mixed_dml.inc	2008-04-08 06:34:40 +0000
+++ b/mysql-test/suite/rpl/include/rpl_mixed_dml.inc	2008-08-04 14:30:50 +0000
@@ -51,9 +51,8 @@ DELETE FROM t2 WHERE a = 2;
 
 --echo
 --echo ******************** LOAD DATA INFILE ********************
---copy_file suite/rpl/data/rpl_mixed.dat $MYSQLTEST_VARDIR/tmp/rpl_mixed.dat
-LOAD DATA INFILE '../../tmp/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;
---remove_file $MYSQLTEST_VARDIR/tmp/rpl_mixed.dat
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;
 SELECT * FROM t1 ORDER BY a;
 --source suite/rpl/include/rpl_mixed_check_select.inc
 --source suite/rpl/include/rpl_mixed_clear_tables.inc
@@ -329,6 +328,7 @@ DROP VIEW v2;
 --echo ******************** SHOW BINLOG EVENTS ********************
 --replace_column 2 # 5 #
 --replace_regex /Server ver: .+/Server ver: #/ /table_id: [0-9]+/table_id: #/ /COMMIT.+xid=[0-9]+.+/#/ /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 show binlog events from 1;
 sync_slave_with_master;
 # as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID

=== added file 'mysql-test/suite/rpl/r/rpl_bug26395.result'
--- a/mysql-test/suite/rpl/r/rpl_bug26395.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_bug26395.result	2008-07-10 16:09:39 +0000
@@ -0,0 +1,41 @@
+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;
+==== Initialize ====
+[on master]
+CREATE TABLE tinnodb (a INT) ENGINE = INNODB;
+SHOW CREATE TABLE tinnodb;
+Table	Create Table
+tinnodb	CREATE TABLE `tinnodb` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+set @old_debug= @@debug;
+set @@debug= 'd,do_not_write_xid';
+==== Test ====
+INSERT INTO tinnodb VALUES (1);
+SELECT * FROM tinnodb ORDER BY a;
+a
+1
+[on slave]
+==== Verify results on slave ====
+include/stop_slave.inc
+SELECT "" AS Slave_IO_State;
+Slave_IO_State
+
+SELECT "" AS Last_SQL_Error;
+Last_SQL_Error
+
+SELECT "" AS Last_IO_Error;
+Last_IO_Error
+
+SELECT * FROM tinnodb ORDER BY a;
+a
+==== Clean up ====
+[on master]
+DROP TABLE tinnodb;
+set @@debug= @old_debug;
+[on slave]
+DROP TABLE tinnodb;

=== modified file 'mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result'
--- a/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result	2008-07-03 20:14:21 +0000
+++ b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result	2008-08-04 14:30:50 +0000
@@ -92,7 +92,7 @@ Master D	4	D
 * Do failure for C and then make new connection B->D *
 STOP SLAVE;
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
-START SLAVE;
+include/start_slave.inc
 INSERT INTO t1 VALUES(6,'C',2);
 INSERT INTO t1(b,c) VALUES('B',2);
 INSERT INTO t1(b,c) VALUES('A',2);
@@ -119,7 +119,7 @@ Master D	8	D
 STOP SLAVE;
 STOP SLAVE;
 CHANGE MASTER TO master_host='127.0.0.1',master_port=MASTER_B_PORT,master_user='root',master_log_file='LOG_FILE',master_log_pos=LOG_POS;
-START SLAVE;
+include/start_slave.inc
 
 * Check data inserted before failure *
 SELECT 'Master A',a,b FROM t1 WHERE c = 2 ORDER BY a,b;
@@ -166,7 +166,7 @@ Master D	12	D
 *** Testing restoring scheme A->B->C->D->A after failure ***
 
 * Remove wrong event from C and restore B->C->D *
-STOP SLAVE;
+include/stop_slave.inc
 DELETE FROM t1 WHERE a = 6;
 START SLAVE;
 RESET MASTER;

=== modified file 'mysql-test/suite/rpl/r/rpl_flushlog_loop.result'
--- a/mysql-test/suite/rpl/r/rpl_flushlog_loop.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl/r/rpl_flushlog_loop.result	2008-08-04 14:30:50 +0000
@@ -18,11 +18,7 @@ start slave;
 stop slave;
 change master to master_host='127.0.0.1',master_user='root',
 master_password='',master_port=SLAVE_PORT;
-start slave;
-
-let $result_pattern= '%127.0.0.1%root%slave-bin.000001%slave-bin.000001%Yes%Yes%0%0%None%' ;
-
---source include/wait_slave_status.inc
+include/start_slave.inc
 FLUSH LOGS;
 SHOW SLAVE STATUS;
 Slave_IO_State	#

=== modified file 'mysql-test/suite/rpl/r/rpl_found_rows.result'
--- a/mysql-test/suite/rpl/r/rpl_found_rows.result	2008-07-22 14:16:22 +0000
+++ b/mysql-test/suite/rpl/r/rpl_found_rows.result	2008-08-04 14:30:50 +0000
@@ -103,10 +103,10 @@ DROP PROCEDURE just_log;
 DROP PROCEDURE calc_and_log;
 DROP FUNCTION log_rows;
 **** Resetting master and slave ****
-STOP SLAVE;
+include/stop_slave.inc
 RESET SLAVE;
 RESET MASTER;
-START SLAVE;
+include/start_slave.inc
 #### 2. Using mixed mode ####
 ==== 2.1. Checking a procedure ====
 **** On Master ****

=== modified file 'mysql-test/suite/rpl/r/rpl_init_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_init_slave.result	2008-01-14 07:41:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_init_slave.result	2008-07-10 16:09:39 +0000
@@ -5,8 +5,8 @@ reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
 set global max_connections=151;
-stop slave;
-start slave;
+include/stop_slave.inc
+include/start_slave.inc
 show variables like 'init_slave';
 Variable_name	Value
 init_slave	set global max_connections=500
@@ -25,6 +25,6 @@ set global init_connect="set @c=1";
 show variables like 'init_connect';
 Variable_name	Value
 init_connect	set @c=1
-stop slave;
+include/stop_slave.inc
 set global init_connect= @my_global_init_connect;
 set global max_connections= default;

=== modified file 'mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result'
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result	2008-06-10 22:27:52 +0000
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result	2008-08-04 14:30:50 +0000
@@ -103,7 +103,7 @@ DELETE FROM t1;
 DELETE FROM t2;
 
 ******************** LOAD DATA INFILE ********************
-LOAD DATA INFILE '../../tmp/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;
 SELECT * FROM t1 ORDER BY a;
 a	b
 10	line A
@@ -884,7 +884,7 @@ master-bin.000001	#	Query	1	#	use `test_
 master-bin.000001	#	Xid	1	#	#
 master-bin.000001	#	Query	1	#	use `test_rpl`; BEGIN
 master-bin.000001	#	Begin_load_query	1	#	;file_id=#;block_len=#
-master-bin.000001	#	Execute_load_query	1	#	use `test_rpl`; LOAD DATA INFILE '../../tmp/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;file_id=#
+master-bin.000001	#	Execute_load_query	1	#	use `test_rpl`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;file_id=#
 master-bin.000001	#	Xid	1	#	#
 master-bin.000001	#	Query	1	#	use `test_rpl`; BEGIN
 master-bin.000001	#	Query	1	#	use `test_rpl`; DELETE FROM t1

=== modified file 'mysql-test/suite/rpl/r/rpl_log_pos.result'
--- a/mysql-test/suite/rpl/r/rpl_log_pos.result	2008-01-14 07:38:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_log_pos.result	2008-07-10 16:09:39 +0000
@@ -7,7 +7,7 @@ start slave;
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB
 master-bin.000001	#	<Binlog_Do_DB>	<Binlog_Ignore_DB>
-stop slave;
+include/stop_slave.inc
 change master to master_log_pos=75;
 SHOW SLAVE STATUS;
 Slave_IO_State	#
@@ -49,7 +49,7 @@ Last_IO_Error	#
 Last_SQL_Errno	0
 Last_SQL_Error	
 start slave;
-stop slave;
+include/stop_slave.inc
 SHOW SLAVE STATUS;
 Slave_IO_State	#
 Master_Host	127.0.0.1

=== modified file 'mysql-test/suite/rpl/r/rpl_packet.result'
--- a/mysql-test/suite/rpl/r/rpl_packet.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl/r/rpl_packet.result	2008-08-04 14:30:50 +0000
@@ -8,8 +8,8 @@ drop database if exists DB_NAME_OF_MAX_L
 create database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
 SET @@global.max_allowed_packet=1024;
 SET @@global.net_buffer_length=1024;
-STOP SLAVE;
-START SLAVE;
+include/stop_slave.inc
+include/start_slave.inc
 select @@net_buffer_length, @@max_allowed_packet;
 @@net_buffer_length	@@max_allowed_packet
 1024	1024
@@ -27,8 +27,8 @@ SLAVE_RUNNING	ON
 drop database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
 SET @@global.max_allowed_packet=4096;
 SET @@global.net_buffer_length=4096;
-STOP SLAVE;
-START SLAVE;
+include/stop_slave.inc
+include/start_slave.inc
 CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM;
 INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
 aaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048');
 show slave status;

=== modified file 'mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result'
--- a/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result	2008-08-04 14:30:50 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+SET @old_binlog_format= @@global.binlog_format;
 SET BINLOG_FORMAT=MIXED;
 SET GLOBAL BINLOG_FORMAT=MIXED;
 SELECT @@GLOBAL.BINLOG_FORMAT, @@SESSION.BINLOG_FORMAT;
@@ -67,7 +68,6 @@ Master_Server_Id	1
 SHOW BINLOG EVENTS;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Format_desc	2	#	Server ver: VERSION, Binlog ver: 4
-slave-bin.000001	#	Query	2	#	use `test`; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9
 slave-bin.000001	#	Query	1	#	use `test`; CREATE TABLE t1 (a INT, b LONG)
 slave-bin.000001	#	Query	1	#	use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
 slave-bin.000001	#	Query	1	#	use `test`; BEGIN
@@ -75,3 +75,4 @@ slave-bin.000001	#	Table_map	1	#	table_i
 slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
 slave-bin.000001	#	Query	1	#	use `test`; COMMIT
 DROP TABLE IF EXISTS t1;
+SET @@global.binlog_format= @old_binlog_format;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result'
--- a/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result	2008-07-21 03:55:09 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result	2008-08-04 14:30:50 +0000
@@ -423,10 +423,10 @@ a	b	c
 **** On Master ****
 DELETE FROM t1;
 **** Resetting master and slave ****
-STOP SLAVE;
+include/stop_slave.inc
 RESET SLAVE;
 RESET MASTER;
-START SLAVE;
+include/start_slave.inc
 **** On Master ****
 INSERT INTO t1 VALUES ('K','K'), ('L','L'), ('M','M');
 **** On Master ****

=== modified file 'mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result'
--- a/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result	2008-07-21 03:55:09 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result	2008-08-04 14:30:50 +0000
@@ -423,10 +423,10 @@ a	b	c
 **** On Master ****
 DELETE FROM t1;
 **** Resetting master and slave ****
-STOP SLAVE;
+include/stop_slave.inc
 RESET SLAVE;
 RESET MASTER;
-START SLAVE;
+include/start_slave.inc
 **** On Master ****
 INSERT INTO t1 VALUES ('K','K'), ('L','L'), ('M','M');
 **** On Master ****

=== modified file 'mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result'
--- a/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result	2008-07-22 14:16:22 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result	2008-08-04 14:30:50 +0000
@@ -4,58 +4,18 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-create table t1 (a int not null primary key);
-insert into  t1 values (1);
-create table t2 (a int);
-insert into  t2 values (1);
-update t1, t2 set t1.a = 0 where t1.a = t2.a;
-show tables;
-Tables_in_test
-t1
-select * from t1;
-a
-0
-drop table t1;
-insert into t1 values (1);
-SHOW SLAVE STATUS;
-Slave_IO_State	#
-Master_Host	127.0.0.1
-Master_User	root
-Master_Port	MASTER_PORT
-Connect_Retry	1
-Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	1154
-Relay_Log_File	#
-Relay_Log_Pos	#
-Relay_Master_Log_File	master-bin.000001
-Slave_IO_Running	Yes
-Slave_SQL_Running	No
-Replicate_Do_DB	
-Replicate_Ignore_DB	
-Replicate_Do_Table	
-Replicate_Ignore_Table	#
-Replicate_Wild_Do_Table	
-Replicate_Wild_Ignore_Table	
-Last_Errno	1146
-Last_Error	Error 'Table 'test.t1' doesn't exist' on opening tables
-Skip_Counter	0
-Exec_Master_Log_Pos	942
-Relay_Log_Space	#
-Until_Condition	None
-Until_Log_File	
-Until_Log_Pos	0
-Master_SSL_Allowed	No
-Master_SSL_CA_File	
-Master_SSL_CA_Path	
-Master_SSL_Cert	
-Master_SSL_Cipher	
-Master_SSL_Key	
-Seconds_Behind_Master	#
-Master_SSL_Verify_Server_Cert	No
-Last_IO_Errno	#
-Last_IO_Error	#
-Last_SQL_Errno	1146
-Last_SQL_Error	Error 'Table 'test.t1' doesn't exist' on opening tables
-Replicate_Ignore_Server_Ids	
-Master_Server_Id	1
-drop table t1, t2;
+==== Setup table on master but not on slave ====
+[on master]
+CREATE TABLE t1 (a INT);
+[on slave]
+DROP TABLE t1;
+==== Modify table on master ====
+[on master]
+INSERT INTO t1 VALUES (1);
+==== Verify error on slave ====
+[on slave]
+Last_SQL_Error = Error 'Table 'test.t1' doesn't exist' on opening tables
+==== Clean up ====
+include/stop_slave.inc
+[on master]
+DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_log.result'
--- a/mysql-test/suite/rpl/r/rpl_row_log.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_log.result	2008-08-04 14:30:50 +0000
@@ -4,7 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-stop slave;
+include/stop_slave.inc
 reset master;
 reset slave;
 reset master;
@@ -113,11 +113,7 @@ Aberdeen
 Abernathy
 aberrant
 aberration
-start slave;
-
-let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%' ;
-
---source include/wait_slave_status.inc
+include/start_slave.inc
 select * from t1 order by 1 asc;
 word
 Aarhus
@@ -190,7 +186,8 @@ Abernathy
 aberrant
 aberration
 flush logs;
-stop slave;
+include/stop_slave.inc
+include/start_slave.inc
 create table t2 (n int)ENGINE=MyISAM;
 insert into t2 values (1);
 show binlog events from <binlog_start>;
@@ -220,7 +217,6 @@ show binary logs;
 Log_name	File_size
 master-bin.000001	1541
 master-bin.000002	517
-start slave;
 show binary logs;
 Log_name	File_size
 slave-bin.000001	1639

=== modified file 'mysql-test/suite/rpl/r/rpl_row_log_innodb.result'
--- a/mysql-test/suite/rpl/r/rpl_row_log_innodb.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_log_innodb.result	2008-08-04 14:30:50 +0000
@@ -4,7 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-stop slave;
+include/stop_slave.inc
 reset master;
 reset slave;
 reset master;
@@ -113,11 +113,7 @@ Aberdeen
 Abernathy
 aberrant
 aberration
-start slave;
-
-let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%' ;
-
---source include/wait_slave_status.inc
+include/start_slave.inc
 select * from t1 order by 1 asc;
 word
 Aarhus
@@ -190,7 +186,8 @@ Abernathy
 aberrant
 aberration
 flush logs;
-stop slave;
+include/stop_slave.inc
+include/start_slave.inc
 create table t2 (n int)ENGINE=InnoDB;
 insert into t2 values (1);
 show binlog events from <binlog_start>;
@@ -220,7 +217,6 @@ show binary logs;
 Log_name	File_size
 master-bin.000001	1457
 master-bin.000002	475
-start slave;
 show binary logs;
 Log_name	File_size
 slave-bin.000001	1537

=== modified file 'mysql-test/suite/rpl/r/rpl_row_stop_middle_update.result'
--- a/mysql-test/suite/rpl/r/rpl_row_stop_middle_update.result	2007-12-12 17:19:24 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_stop_middle_update.result	2008-07-10 16:09:39 +0000
@@ -13,4 +13,5 @@ select count(*) from t1;
 count(*)
 70
 drop table t1;
+include/stop_slave.inc
 drop table t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_until.result'
--- a/mysql-test/suite/rpl/r/rpl_row_until.result	2008-06-19 06:16:27 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_until.result	2008-08-04 14:30:50 +0000
@@ -4,7 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-stop slave;
+include/stop_slave.inc
 create table t1(n int not null auto_increment primary key);
 insert into t1 values (1),(2),(3),(4);
 drop table t1;
@@ -149,7 +149,7 @@ Last_IO_Error	#
 Last_SQL_Errno	0
 Last_SQL_Error	
 start slave;
-stop slave;
+include/stop_slave.inc
 start slave sql_thread until master_log_file='master-bin.000001', master_log_pos=740;
 SHOW SLAVE STATUS;
 Slave_IO_State	#

=== modified file 'mysql-test/suite/rpl/r/rpl_slave_grp_exec.result'
--- a/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result	2008-04-20 12:32:08 +0000
+++ b/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result	2008-07-10 16:09:39 +0000
@@ -44,9 +44,9 @@ a	b
 SELECT * FROM t2 ORDER BY a;
 a	b
 1	AA_for_row_or_YY_for_stmt_mixed
-STOP SLAVE;
+include/stop_slave.inc
 RENAME TABLE t3_bak TO t3;
-START SLAVE;
+include/start_slave.inc
 TRUNCATE t1;
 TRUNCATE t2;
 TRUNCATE t3;
@@ -78,9 +78,9 @@ SELECT * FROM t1 ORDER BY a;
 a	b
 SELECT * FROM t2 ORDER BY a;
 a	b
-STOP SLAVE;
+include/stop_slave.inc
 RENAME TABLE t3_bak TO t3;
-START SLAVE;
+include/start_slave.inc
 TRUNCATE t1;
 TRUNCATE t2;
 TRUNCATE t3;
@@ -116,8 +116,8 @@ SELECT * FROM t1 ORDER BY a;
 a	b
 SELECT * FROM t2 ORDER BY a;
 a	b
-STOP SLAVE;
+include/stop_slave.inc
 RENAME TABLE t3_bak TO t3;
-START SLAVE;
+include/start_slave.inc
 *** Clean up ***
 DROP TABLE t1,t2,t3;

=== modified file 'mysql-test/suite/rpl/r/rpl_slave_skip.result'
--- a/mysql-test/suite/rpl/r/rpl_slave_skip.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl/r/rpl_slave_skip.result	2008-08-04 14:30:50 +0000
@@ -170,7 +170,7 @@ BEGIN
 UPDATE t3 SET a =2, b = 'master only';
 END|
 **** On Slave ****
-STOP SLAVE;
+include/stop_slave.inc
 **** On Master ****
 UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1;
 DROP TRIGGER tr1;
@@ -192,7 +192,7 @@ a	b
 3	master/slave
 *** On Slave ***
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
+include/start_slave.inc
 SELECT * FROM t1 ORDER BY a;
 a	b
 1	master/slave
@@ -212,7 +212,7 @@ CREATE TABLE t4 (a INT, b VARCHAR(20)) E
 CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb;
 CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb;
 **** On Slave ****
-STOP SLAVE;
+include/stop_slave.inc
 *** On Master ***
 BEGIN;
 INSERT INTO t4 VALUES (2, 'master only');
@@ -238,7 +238,7 @@ a	b
 3	master/slave
 *** On Slave ***
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
+include/start_slave.inc
 SELECT * FROM t4 ORDER BY a;
 a	b
 3	master/slave
@@ -249,7 +249,7 @@ SELECT * FROM t6 ORDER BY a;
 a	b
 3	master/slave
 **** On Slave ****
-STOP SLAVE;
+include/stop_slave.inc
 *** On Master ***
 BEGIN;
 INSERT INTO t4 VALUES (6, 'master only');
@@ -281,7 +281,7 @@ a	b
 7	master only
 *** On Slave ***
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10;
-START SLAVE;
+include/start_slave.inc
 SELECT * FROM t4 ORDER BY a;
 a	b
 3	master/slave
@@ -291,7 +291,7 @@ a	b
 SELECT * FROM t6 ORDER BY a;
 a	b
 3	master/slave
-STOP SLAVE;
+include/stop_slave.inc
 SET AUTOCOMMIT=0;
 INSERT INTO t4 VALUES (4, 'master only');
 INSERT INTO t5 VALUES (4, 'master only');
@@ -327,7 +327,7 @@ a	b
 7	master only
 *** On Slave ***
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
+include/start_slave.inc
 SELECT * FROM t4 ORDER BY a;
 a	b
 3	master/slave
@@ -345,10 +345,10 @@ DROP TABLE t4, t5, t6;
 *** On Master ***
 CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam;
 *** On Slave ***
-STOP SLAVE;
+include/stop_slave.inc
 *** On Master ***
 SET SESSION BINLOG_FORMAT=STATEMENT;
-LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
 SELECT * FROM t10 ORDER BY a;
 a	b
 1	master only
@@ -356,7 +356,7 @@ a	b
 3	master only
 *** On Slave ***
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
+include/start_slave.inc
 SELECT * FROM t10 ORDER BY a;
 a	b
 DROP TABLE t10;

=== modified file 'mysql-test/suite/rpl/r/rpl_slave_status.result'
--- a/mysql-test/suite/rpl/r/rpl_slave_status.result	2008-06-10 22:27:52 +0000
+++ b/mysql-test/suite/rpl/r/rpl_slave_status.result	2008-08-04 14:30:50 +0000
@@ -9,9 +9,9 @@ start slave;
 grant replication slave on *.* to rpl@stripped identified by 'rpl';
 flush privileges;
 [on slave]
-stop slave;
+include/stop_slave.inc
 change master to master_user='rpl',master_password='rpl';
-start slave;
+include/start_slave.inc
 ==== Do replication as new user ====
 [on master]
 create table t1 (n int);
@@ -26,7 +26,7 @@ drop user rpl@stripped;
 flush privileges;
 [on slave]
 ==== Restart slave without privileges =====
-stop slave;
+include/stop_slave.inc
 start slave;
 ==== Verify that Slave_IO_Running = No ====
 Slave_IO_Running = No (should be No)

=== modified file 'mysql-test/suite/rpl/r/rpl_sp.result'
--- a/mysql-test/suite/rpl/r/rpl_sp.result	2008-06-10 22:27:52 +0000
+++ b/mysql-test/suite/rpl/r/rpl_sp.result	2008-08-04 14:30:50 +0000
@@ -191,8 +191,12 @@ begin
 return unix_timestamp();
 end|
 ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
+set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
+set global log_bin_trust_routine_creators=1;
+ERROR HY000: Unknown system variable 'log_bin_trust_routine_creators'
 set global log_bin_trust_function_creators=0;
 set global log_bin_trust_function_creators=1;
+set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 set global log_bin_trust_function_creators=1;
 create function fn2()
 returns int
@@ -546,8 +550,8 @@ insert into t values (1);
 return 0;
 end
 master-bin.000001	#	Query	#	#	use `mysqltest`; SELECT `mysqltest2`.`f1`()
-set global log_bin_trust_function_creators=0;
-set global log_bin_trust_function_creators=0;
+set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
+set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 drop database mysqltest;
 drop database mysqltest2;
 use test;

=== modified file 'mysql-test/suite/rpl/r/rpl_sp_effects.result'
--- a/mysql-test/suite/rpl/r/rpl_sp_effects.result	2007-10-30 11:49:42 +0000
+++ b/mysql-test/suite/rpl/r/rpl_sp_effects.result	2008-07-10 16:09:39 +0000
@@ -4,6 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 drop procedure if exists p1;
 drop procedure if exists p2;
 drop function if exists f1;
@@ -275,5 +276,5 @@ E
 drop table t2;
 drop procedure sp_bug26199;
 drop function sf_bug26199;
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 end of the tests

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_log.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_log.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_log.result	2008-08-04 14:30:50 +0000
@@ -4,7 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-stop slave;
+include/stop_slave.inc
 reset master;
 reset slave;
 reset master;
@@ -109,11 +109,7 @@ Aberdeen
 Abernathy
 aberrant
 aberration
-start slave;
-
-let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%' ;
-
---source include/wait_slave_status.inc
+include/start_slave.inc
 select * from t1 order by 1 asc;
 word
 Aarhus
@@ -186,7 +182,8 @@ Abernathy
 aberrant
 aberration
 flush logs;
-stop slave;
+include/stop_slave.inc
+include/start_slave.inc
 create table t2 (n int)ENGINE=MyISAM;
 insert into t2 values (1);
 show binlog events from <binlog_start>;
@@ -209,7 +206,6 @@ show binary logs;
 Log_name	File_size
 master-bin.000001	1348
 master-bin.000002	393
-start slave;
 show binary logs;
 Log_name	File_size
 slave-bin.000001	1451

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_until.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_until.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_until.result	2008-08-04 14:30:50 +0000
@@ -4,7 +4,10 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-stop slave;
+[on slave]
+include/stop_slave.inc
+==== Create some events on master ====
+[on master]
 create table t1(n int not null auto_increment primary key);
 insert into t1 values (1),(2),(3),(4);
 drop table t1;
@@ -12,6 +15,8 @@ create table t2(n int not null auto_incr
 insert into t2 values (1),(2);
 insert into t2 values (3),(4);
 drop table t2;
+==== Replicate one event at a time on slave ====
+[on slave]
 start slave until master_log_file='master-bin.000001', master_log_pos=323;
 select * from t1;
 n
@@ -108,7 +113,7 @@ Last_SQL_Errno	0
 Last_SQL_Error	
 Replicate_Ignore_Server_Ids	
 Master_Server_Id	1
-start slave until relay_log_file='slave-relay-bin.000003', relay_log_pos=746;
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746;
 select * from t2;
 n
 1
@@ -138,7 +143,7 @@ Skip_Counter	0
 Exec_Master_Log_Pos	#
 Relay_Log_Space	#
 Until_Condition	Relay
-Until_Log_File	slave-relay-bin.000003
+Until_Log_File	slave-relay-bin.000004
 Until_Log_Pos	746
 Master_SSL_Allowed	No
 Master_SSL_CA_File	
@@ -155,7 +160,9 @@ Last_SQL_Error	
 Replicate_Ignore_Server_Ids	
 Master_Server_Id	1
 start slave;
-stop slave;
+[on master]
+[on slave]
+include/stop_slave.inc
 start slave until master_log_file='master-bin.000001', master_log_pos=776;
 SHOW SLAVE STATUS;
 Slave_IO_State	#
@@ -198,6 +205,7 @@ Last_SQL_Errno	0
 Last_SQL_Error	
 Replicate_Ignore_Server_Ids	
 Master_Server_Id	1
+==== Test various error conditions ====
 start slave until master_log_file='master-bin', master_log_pos=561;
 ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
 start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;

=== modified file 'mysql-test/suite/rpl/r/rpl_variables.result'
--- a/mysql-test/suite/rpl/r/rpl_variables.result	2008-03-07 12:59:36 +0000
+++ b/mysql-test/suite/rpl/r/rpl_variables.result	2008-07-10 16:09:39 +0000
@@ -40,10 +40,10 @@ SET @user_num = 10;
 SET @user_text = 'Alunda';
 [on master]
 **** Resetting master and slave ****
-STOP SLAVE;
+include/stop_slave.inc
 RESET SLAVE;
 RESET MASTER;
-START SLAVE;
+include/start_slave.inc
 [on slave]
 SET @@global.init_slave = 'ant';
 [on master]

=== removed file 'mysql-test/suite/rpl/t/rpl000018-master.opt'
--- a/mysql-test/suite/rpl/t/rpl000018-master.opt	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl000018-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
--O max_binlog_size=4096

=== removed file 'mysql-test/suite/rpl/t/rpl000018-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl000018-slave.opt	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl000018-slave.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---skip-slave-start --abort-slave-event-count=1

=== added file 'mysql-test/suite/rpl/t/rpl_bug26395-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_bug26395-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug26395-master.opt	2008-07-06 10:53:25 +0000
@@ -0,0 +1 @@
+--innodb

=== added file 'mysql-test/suite/rpl/t/rpl_bug26395-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_bug26395-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug26395-slave.opt	2008-07-06 10:53:25 +0000
@@ -0,0 +1 @@
+--innodb

=== added file 'mysql-test/suite/rpl/t/rpl_bug26395.test'
--- a/mysql-test/suite/rpl/t/rpl_bug26395.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug26395.test	2008-07-10 16:09:39 +0000
@@ -0,0 +1,97 @@
+# ==== Purpose ====
+#
+# Tests that an autocommitted XA transaction where the master crashes
+# just before writing the XID log event is executed correctly.  The
+# master rolls back, so the slave should not execute statement.
+#
+# This test was previously part of rpl_ndb_transaction.test
+#
+#
+# ==== Method ====
+#
+# We want master to be alive so that it can replicate the statement to
+# the slave. So in the test case, we must not crash the
+# master. Instead, we fake the crash by just not writing the XID event
+# to the binlog. This is done by the @@debug='d,do_not_write_xid'
+# flag. This, in turn, requires us to do 'source
+# include/have_debug.inc'
+#
+# So, unlike if the master had crashed, the master *will* execute the
+# statement. But the slave should not execute it. Hence, after the
+# test is executed, the expected result on master is a table with one
+# row, and on slave a table with no rows.
+#
+# To simulate the slave correctly, we wait until everything up to but
+# not including the XID is replicated. This has to be done with
+# include/sync_slave_io_with_master.inc, not sync_slave_with_master,
+# since the latter waits until the slave *SQL* thread has caught up
+# with the master's position, which it will never do.
+#
+#
+# ==== Related bugs ====
+#
+# BUG#26395: if crash during autocommit update to transactional table on master, slave fails
+
+source include/have_innodb.inc;
+# have_debug is needed since we use the @@debug variable on master
+source include/have_debug.inc;
+source include/master-slave.inc;
+
+
+--echo ==== Initialize ====
+
+--echo [on master]
+--connection master
+
+CREATE TABLE tinnodb (a INT) ENGINE = INNODB;
+SHOW CREATE TABLE tinnodb;
+
+# do_not_write_xid stops the master from writing an XID event.
+set @old_debug= @@debug;
+set @@debug= 'd,do_not_write_xid';
+
+
+--echo ==== Test ====
+
+# Save the position up to which the slave SQL thread should execute.
+save_master_pos;
+
+# Execute query and check that the row made it to the table.
+INSERT INTO tinnodb VALUES (1);
+SELECT * FROM tinnodb ORDER BY a;
+
+# Sync slave's IO thread.
+--echo [on slave]
+source include/sync_slave_io_with_master.inc;
+
+# Sync slave's SQL thread.
+sync_with_master 0;
+
+
+--echo ==== Verify results on slave ====
+
+source include/stop_slave.inc;
+let $tmp= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1);
+eval SELECT "$tmp" AS Slave_IO_State;
+let $tmp= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+eval SELECT "$tmp" AS Last_SQL_Error;
+let $tmp= query_get_value("SHOW SLAVE STATUS", Last_IO_Error, 1);
+eval SELECT "$tmp" AS Last_IO_Error;
+SELECT * FROM tinnodb ORDER BY a;
+
+
+--echo ==== Clean up ====
+
+# Easiest to clean up master and slave separately, without
+# replication, since master and slave are out of sync.
+
+--echo [on master]
+connection master;
+DROP TABLE tinnodb;
+set @@debug= @old_debug;
+
+--echo [on slave]
+connection slave;
+DROP TABLE tinnodb;
+
+# Warning: do not add more tests here. The binlog is in a bad state.

=== modified file 'mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test'
--- a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test	2008-07-03 20:14:21 +0000
+++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test	2008-08-04 14:30:50 +0000
@@ -59,8 +59,7 @@ SELECT 'Master D',a,b FROM t1 WHERE c = 
 connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
 STOP SLAVE;
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
-START SLAVE;
---source include/wait_for_slave_to_start.inc
+source include/start_slave.inc;
 disconnect slave;
 --connection master_c
 INSERT INTO t1 VALUES(6,'C',2);
@@ -69,9 +68,7 @@ INSERT INTO t1 VALUES(6,'C',2);
 INSERT INTO t1(b,c) VALUES('B',2);
 # Wait while C will stop.
 --connection master_c
---let $slave_param= Slave_SQL_Running
---let $slave_param_value= No
---source include/wait_for_slave_param.inc
+source include/wait_for_slave_sql_to_stop.inc;
 --connection master_a
 INSERT INTO t1(b,c) VALUES('A',2);
 --connection master_d
@@ -107,8 +104,7 @@ STOP SLAVE;
 --replace_result $SLAVE_MYPORT MASTER_B_PORT $file_c LOG_FILE $pos_c LOG_POS 
 --eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT,master_user='root',master_log_file='$file_c',master_log_pos=$pos_c
 connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
-START SLAVE;
---source include/wait_for_slave_to_start.inc
+source include/start_slave.inc;
 disconnect slave;
 --connection master_b
 --sync_slave_with_master master_d
@@ -157,8 +153,7 @@ SELECT 'Master D',a,b FROM t1 WHERE c = 
 # distributed to other servers
 --echo * Remove wrong event from C and restore B->C->D *
 --connection master_d
-STOP SLAVE;
---source include/wait_for_slave_to_stop.inc
+source include/stop_slave.inc;
 --connection master_c
 DELETE FROM t1 WHERE a = 6;
 START SLAVE;

=== modified file 'mysql-test/suite/rpl/t/rpl_dual_pos_advance.test'
--- a/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test	2008-08-04 14:30:50 +0000
@@ -12,7 +12,7 @@ source include/have_innodb.inc;
 
 # set up "dual head"
 
-let $keep_connection= 1;
+let $slave_keep_connection= 1;
 connection slave;
 reset master;
 

=== modified file 'mysql-test/suite/rpl/t/rpl_flushlog_loop.test'
--- a/mysql-test/suite/rpl/t/rpl_flushlog_loop.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop.test	2008-08-04 14:30:50 +0000
@@ -29,13 +29,8 @@ stop slave;
 --replace_result $SLAVE_MYPORT SLAVE_PORT
 eval change master to master_host='127.0.0.1',master_user='root',
  master_password='',master_port=$SLAVE_MYPORT;
-start slave;
---source include/wait_for_slave_to_start.inc
-#
-#  Wait for start of slave IO and SQL threads
-#
-let $result_pattern= '%127.0.0.1%root%slave-bin.000001%slave-bin.000001%Yes%Yes%0%0%None%';
---source include/wait_slave_status.inc
+
+source include/start_slave.inc;
 
 #
 #  Flush logs of slave
@@ -79,8 +74,8 @@ source include/wait_for_slave_param.inc;
 --replace_column 1 # 8 # 9 # 16 # 23 # 33 # 34 # 35 #
 --query_vertical SHOW SLAVE STATUS
 
---connection master
+--disable_query_log
+connection master;
 DROP TABLE t1;
---sync_slave_with_master
-
-# End of test
+sync_slave_with_master;
+--enable_query_log

=== modified file 'mysql-test/suite/rpl/t/rpl_idempotency.test'
--- a/mysql-test/suite/rpl/t/rpl_idempotency.test	2008-04-08 14:51:26 +0000
+++ b/mysql-test/suite/rpl/t/rpl_idempotency.test	2008-07-10 16:09:39 +0000
@@ -207,9 +207,8 @@ select * from ti1 order by b /* must be 
 # foreign key: row is referenced
 
 --echo *** slave must stop
-source include/wait_for_slave_sql_to_stop.inc;
-
 connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
 
 let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
 disable_query_log;
@@ -240,11 +239,10 @@ delete from ti1 where b=3;
 
 connection master;
 insert into ti2 set a=3, b=3 /* offending write event */;
---echo *** slave must stop
-
-source include/wait_for_slave_sql_to_stop.inc;
 
+--echo *** slave must stop
 connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
 
 let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
 disable_query_log;
@@ -282,9 +280,8 @@ connection master;
 insert into ti1 set b=1 /* offending write event */;
 
 --echo *** slave must stop
-source include/wait_for_slave_sql_to_stop.inc;
-
 connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
 
 let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
 disable_query_log;
@@ -318,9 +315,8 @@ connection master;
 DELETE FROM t1 WHERE a = -2;
 
 --echo *** slave must stop
-source include/wait_for_slave_sql_to_stop.inc;
-
 connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
 
 let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
 disable_query_log;
@@ -337,9 +333,8 @@ set global slave_exec_mode='STRICT';
 connection master;
 DELETE FROM t2 WHERE a = -2;
 --echo *** slave must stop
-source include/wait_for_slave_sql_to_stop.inc;
-
 connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
 
 let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
 disable_query_log;
@@ -360,9 +355,8 @@ connection master;
 UPDATE t1 SET a = 1 WHERE a = -1;
 
 --echo *** slave must stop
-source include/wait_for_slave_sql_to_stop.inc;
-
 connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
 
 let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
 disable_query_log;
@@ -381,9 +375,8 @@ connection master;
 UPDATE t2 SET a = 1 WHERE a = -1;
 
 --echo *** slave must stop
-source include/wait_for_slave_sql_to_stop.inc;
-
 connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
 
 let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
 disable_query_log;

=== modified file 'mysql-test/suite/rpl/t/rpl_incident.test'
--- a/mysql-test/suite/rpl/t/rpl_incident.test	2008-06-23 21:23:41 +0000
+++ b/mysql-test/suite/rpl/t/rpl_incident.test	2008-08-04 14:30:50 +0000
@@ -14,7 +14,7 @@ REPLACE INTO t1 VALUES (4);
 SELECT * FROM t1;
 
 connection slave;
---source include/wait_for_slave_sql_to_stop.inc
+source include/wait_for_slave_sql_to_stop.inc;
 
 # The 4 should not be inserted into the table, since the incident log
 # event should have stop the slave.

=== modified file 'mysql-test/suite/rpl/t/rpl_init_slave.test'
--- a/mysql-test/suite/rpl/t/rpl_init_slave.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_init_slave.test	2008-08-04 14:30:50 +0000
@@ -7,17 +7,13 @@ source include/master-slave.inc;
 set global max_connections=151;
 
 connection slave;
-stop slave;
-source include/wait_for_slave_to_stop.inc;
-start slave;
-source include/wait_for_slave_to_start.inc;
+source include/stop_slave.inc;
+source include/start_slave.inc;
 
 connection master;
-save_master_pos;
-connection slave;
+sync_slave_with_master;
 show variables like 'init_slave';
 show variables like 'max_connections';
-sync_with_master;
 reset master;
 connection master;
 show variables like 'init_slave';
@@ -29,7 +25,7 @@ set global init_connect="set @c=1";
 show variables like 'init_connect';
 connection master;
 sync_slave_with_master;
-stop slave;
+source include/stop_slave.inc;
 
 # Restore changed global variable
 set global init_connect= @my_global_init_connect;

=== modified file 'mysql-test/suite/rpl/t/rpl_insert.test'
--- a/mysql-test/suite/rpl/t/rpl_insert.test	2008-05-29 15:44:11 +0000
+++ b/mysql-test/suite/rpl/t/rpl_insert.test	2008-08-04 14:30:50 +0000
@@ -13,6 +13,9 @@ USE mysqlslap;
 
 CREATE TABLE t1 (id INT, name VARCHAR(64)) ENGINE=MyISAM;
 
+sync_slave_with_master;
+connection master;
+
 let $query = "INSERT DELAYED INTO t1 VALUES (1, 'Dr. No'), (2, 'From Russia With Love'), (3, 'Goldfinger'), (4, 'Thunderball'), (5, 'You Only Live Twice')";
 --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";"
 

=== modified file 'mysql-test/suite/rpl/t/rpl_log_pos.test'
--- a/mysql-test/suite/rpl/t/rpl_log_pos.test	2008-01-14 07:38:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_log_pos.test	2008-07-10 16:09:39 +0000
@@ -13,20 +13,14 @@
 source include/master-slave.inc;
 source include/show_master_status.inc;
 sync_slave_with_master;
-stop slave;
---source include/wait_for_slave_to_stop.inc
+source include/stop_slave.inc;
 
 change master to master_log_pos=75;
 source include/show_slave_status2.inc;
 start slave;
-let $slave_param= Slave_SQL_Running;
-let $slave_param_value= Yes;
---source include/wait_for_slave_param.inc
-let $slave_param= Slave_IO_Running;
-let $slave_param_value= No;
---source include/wait_for_slave_param.inc
-stop slave;
---source include/wait_for_slave_to_stop.inc
+source include/wait_for_slave_sql_to_start.inc;
+source include/wait_for_slave_io_to_stop.inc;
+source include/stop_slave.inc;
 
 source include/show_slave_status.inc;
 connection master;

=== modified file 'mysql-test/suite/rpl/t/rpl_packet.test'
--- a/mysql-test/suite/rpl/t/rpl_packet.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_packet.test	2008-08-04 14:30:50 +0000
@@ -18,10 +18,8 @@ SET @@global.net_buffer_length=1024;
 
 # Restart slave for setting to take effect
 connection slave;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/stop_slave.inc;
+source include/start_slave.inc;
 
 # Reconnect to master for new setting to take effect
 disconnect master;
@@ -60,10 +58,8 @@ SET @@global.net_buffer_length=4096;
 
 # Restart slave for new setting to take effect
 connection slave;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/stop_slave.inc;
+source include/start_slave.inc;
 
 # Reconnect to master for new setting to take effect
 disconnect master;

=== modified file 'mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test'
--- a/mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test	2007-06-27 12:29:10 +0000
+++ b/mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test	2008-07-16 09:17:10 +0000
@@ -5,6 +5,8 @@
 # Test that the slave temporarily switches to ROW when seeing binrow
 # events when it is in STATEMENT or MIXED mode
 
+SET @old_binlog_format= @@global.binlog_format;
+
 SET BINLOG_FORMAT=MIXED;
 SET GLOBAL BINLOG_FORMAT=MIXED;
 SELECT @@GLOBAL.BINLOG_FORMAT, @@SESSION.BINLOG_FORMAT;
@@ -33,6 +35,7 @@ SHOW BINLOG EVENTS;
 
 connection master;
 DROP TABLE IF EXISTS t1;
+SET @@global.binlog_format= @old_binlog_format;
 
 # Let's compare. Note: If they match test will pass, if they do not match
 # the test will show that the diff statement failed and not reject file

=== removed file 'mysql-test/suite/rpl/t/rpl_row_inexist_tbl-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_inexist_tbl-slave.opt	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_inexist_tbl-slave.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---replicate-ignore-table=test.t2

=== modified file 'mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test'
--- a/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test	2007-06-27 12:29:10 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test	2008-07-10 16:09:39 +0000
@@ -1,33 +1,42 @@
-# Test to see what slave says when master is updating a table it does
-# not have
+# ==== Purpose ====
+#
+# Verify that slave gives an error message if master updates a table
+# that slave does not have.
+#
+# ==== Method ====
+#
+# Create a table on master, wait till it's on slave, remove it from
+# slave.  Then update the table on master.
+
 --source include/have_binlog_format_row.inc
 
 source include/master-slave.inc;
 
-connection master;
-create table t1 (a int not null primary key);
-insert into  t1 values (1);
-create table t2 (a int);
-insert into  t2 values (1);
-update t1, t2 set t1.a = 0 where t1.a = t2.a;
+--echo ==== Setup table on master but not on slave ====
+--echo [on master]
+CREATE TABLE t1 (a INT);
 
+--echo [on slave]
 sync_slave_with_master;
-# t2 should not have been replicated
-# t1 should have been properly updated 
-show tables;
-select * from t1;
-drop table t1;
+DROP TABLE t1;
 
+--echo ==== Modify table on master ====
+--echo [on master]
 connection master;
-insert into t1 values (1);
+INSERT INTO t1 VALUES (1);
 
+--echo ==== Verify error on slave ====
+--echo [on slave]
 connection slave;
 # slave should have stopped because can't find table t1
 --source include/wait_for_slave_sql_to_stop.inc
 # see if we have a good error message:
---replace_column 7 #
-source include/show_slave_status.inc;
+let $err= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
+--echo Last_SQL_Error = $err
+
+--echo ==== Clean up ====
+source include/stop_slave.inc;
 
-# cleanup
+--echo [on master]
 connection master;
-drop table t1, t2;
+DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test'
--- a/mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test	2008-07-03 20:14:21 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test	2008-08-04 14:30:50 +0000
@@ -15,12 +15,12 @@ save_master_pos;
 
 connection slave;
 
-# slave will automatically tell itself to stop thanks to the .opt
+# slave will automatically stop the sql thread thanks to the .opt
 # file; it will initiate the stop request after the first
 # Rows_log_event (out of 3) but should wait until the last one is
 # executed before stopping.
 
---source include/wait_for_slave_sql_to_stop.inc
+source include/wait_for_slave_sql_to_stop.inc;
 
 # check that we inserted all rows (waited until the last Rows event)
 select count(*) from t1;
@@ -28,4 +28,5 @@ select count(*) from t1;
 connection master;
 drop table t1;
 connection slave; # slave SQL thread is stopped
+source include/stop_slave.inc;
 drop table t1;

=== modified file 'mysql-test/suite/rpl/t/rpl_row_until.test'
--- a/mysql-test/suite/rpl/t/rpl_row_until.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_until.test	2008-08-04 14:30:50 +0000
@@ -10,9 +10,7 @@ let $VERSION=`select version()`;
 # stop slave before he will start replication also sync with master
 # for avoiding undetermenistic behaviour
 sync_slave_with_master;
-stop slave;
-# Make sure the slave sql and io thread has stopped
---source include/wait_for_slave_to_stop.inc
+--source include/stop_slave.inc
 
 connection master;
 # create some events on master
@@ -50,9 +48,7 @@ start slave;
 --source include/wait_for_slave_to_start.inc
 connection master;
 sync_slave_with_master;
-stop slave;
-# Make sure the slave sql and io thread has stopped
---source include/wait_for_slave_to_stop.inc
+--source include/stop_slave.inc
 
 # this should stop immediately as we are already there
 start slave sql_thread until master_log_file='master-bin.000001', master_log_pos=740;

=== modified file 'mysql-test/suite/rpl/t/rpl_server_id1.test'
--- a/mysql-test/suite/rpl/t/rpl_server_id1.test	2008-07-02 09:17:14 +0000
+++ b/mysql-test/suite/rpl/t/rpl_server_id1.test	2008-08-04 14:30:50 +0000
@@ -9,8 +9,7 @@ connection slave;
 reset master;
 
 # replicate ourselves
-stop slave;
-# source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 --replace_result $SLAVE_MYPORT SLAVE_PORT
 eval change master to master_port=$SLAVE_MYPORT;
 start slave;

=== modified file 'mysql-test/suite/rpl/t/rpl_slave_grp_exec.test'
--- a/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test	2008-04-20 12:32:08 +0000
+++ b/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test	2008-07-10 16:09:39 +0000
@@ -77,11 +77,9 @@ if (!`SELECT @@BINLOG_FORMAT = 'ROW'`) {
   SELECT * FROM t2 ORDER BY a;
 }
 
-STOP SLAVE;
---source include/wait_for_slave_to_stop.inc
+--source include/stop_slave.inc
 RENAME TABLE t3_bak TO t3;
-START SLAVE;
---source include/wait_for_slave_to_start.inc
+--source include/start_slave.inc
 
 --connection master
 TRUNCATE t1;
@@ -121,11 +119,9 @@ SHOW TABLES LIKE 't%';
 SELECT * FROM t1 ORDER BY a;
 SELECT * FROM t2 ORDER BY a;
 
-STOP SLAVE;
---source include/wait_for_slave_to_stop.inc
+--source include/stop_slave.inc
 RENAME TABLE t3_bak TO t3;
-START SLAVE;
---source include/wait_for_slave_to_start.inc
+--source include/start_slave.inc
 
 --connection master
 TRUNCATE t1;
@@ -167,11 +163,9 @@ SHOW TABLES LIKE 't%';
 SELECT * FROM t1 ORDER BY a;
 SELECT * FROM t2 ORDER BY a;
 
-STOP SLAVE;
---source include/wait_for_slave_to_stop.inc
+source include/stop_slave.inc;
 RENAME TABLE t3_bak TO t3;
-START SLAVE;
---source include/wait_for_slave_to_start.inc
+source include/start_slave.inc;
 
 # Clean up
 --echo *** Clean up ***

=== modified file 'mysql-test/suite/rpl/t/rpl_slave_skip.test'
--- a/mysql-test/suite/rpl/t/rpl_slave_skip.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_slave_skip.test	2008-08-04 14:30:50 +0000
@@ -114,8 +114,7 @@ DELIMITER ;|
 
 --echo **** On Slave ****
 sync_slave_with_master;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 
 --echo **** On Master ****
 connection master;
@@ -135,8 +134,7 @@ save_master_pos;
 --echo *** On Slave ***
 connection slave;
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/start_slave.inc;
 sync_with_master;
 
 SELECT * FROM t1 ORDER BY a;
@@ -160,8 +158,7 @@ CREATE TABLE t6 (a INT, b VARCHAR(20)) E
 
 --echo **** On Slave ****
 sync_slave_with_master;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 
 --echo *** On Master ***
 connection master;
@@ -186,8 +183,7 @@ save_master_pos;
 --echo *** On Slave ***
 connection slave;
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/start_slave.inc;
 sync_with_master;
 
 SELECT * FROM t4 ORDER BY a;
@@ -198,8 +194,7 @@ SELECT * FROM t6 ORDER BY a;
 
 --echo **** On Slave ****
 connection slave;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 
 --echo *** On Master ***
 connection master;
@@ -224,8 +219,7 @@ save_master_pos;
 --echo *** On Slave ***
 connection slave;
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/start_slave.inc;
 sync_with_master;
 
 SELECT * FROM t4 ORDER BY a;
@@ -236,8 +230,7 @@ SELECT * FROM t6 ORDER BY a;
 # And the same, but with autocommit = 0
 #
 connection slave;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 
 connection master;
 SET AUTOCOMMIT=0;
@@ -261,8 +254,7 @@ save_master_pos;
 --echo *** On Slave ***
 connection slave;
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/start_slave.inc;
 sync_with_master;
 
 SELECT * FROM t4 ORDER BY a;
@@ -284,16 +276,14 @@ CREATE TABLE t10 (a INT, b VARCHAR(20)) 
 
 --echo *** On Slave ***
 sync_slave_with_master;
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 
 --echo *** On Master ***
 connection master;
 SET SESSION BINLOG_FORMAT=STATEMENT;
-exec cp ./suite/rpl/data/rpl_bug28618.dat $MYSQLTEST_VARDIR/tmp/;
+
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
-remove_file $MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat;
+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
 
 SELECT * FROM t10 ORDER BY a;
 
@@ -302,8 +292,7 @@ save_master_pos;
 --echo *** On Slave ***
 connection slave;
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/start_slave.inc;
 sync_with_master;
 
 SELECT * FROM t10 ORDER BY a;

=== modified file 'mysql-test/suite/rpl/t/rpl_slave_status.test'
--- a/mysql-test/suite/rpl/t/rpl_slave_status.test	2008-07-22 14:16:22 +0000
+++ b/mysql-test/suite/rpl/t/rpl_slave_status.test	2008-08-04 14:30:50 +0000
@@ -27,11 +27,9 @@ grant replication slave on *.* to rpl@12
 flush privileges;
 --echo [on slave]
 sync_slave_with_master;
-stop slave;
-source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 change master to master_user='rpl',master_password='rpl';
-start slave;
-source include/wait_for_slave_to_start.inc;
+source include/start_slave.inc;
 
 --echo ==== Do replication as new user ====
 --echo [on master]
@@ -42,8 +40,6 @@ insert into t1 values (1);
 sync_slave_with_master;
 select * from t1;
 
-# 3. Delete new replication user
-# note: drop user will be replicated on slave
 --echo ==== Delete new replication user ====
 --echo [on master]
 connection master;
@@ -55,8 +51,7 @@ sync_slave_with_master;
 
 --echo ==== Restart slave without privileges =====
 # (slave.err will contain access denied error for this START SLAVE command)
-stop slave;
-source include/wait_for_slave_to_stop.inc;
+source include/stop_slave.inc;
 start slave;
 source include/wait_for_slave_sql_to_start.inc;
 
@@ -72,4 +67,3 @@ drop table t1;
 --echo [on master]
 connection master;
 drop table t1;
-

=== modified file 'mysql-test/suite/rpl/t/rpl_sp.test'
--- a/mysql-test/suite/rpl/t/rpl_sp.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_sp.test	2008-08-04 14:30:50 +0000
@@ -6,6 +6,7 @@
 source include/have_binlog_format_mixed.inc;
 source include/master-slave.inc;
 
+
 # we need a db != test, where we don't have automatic grants
 --disable_warnings
 drop database if exists mysqltest1;
@@ -235,10 +236,16 @@ begin
 end|
 delimiter ;|
 connection master;
+set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
+# test old variable name:
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+set global log_bin_trust_routine_creators=1;
+# now use new name:
 set global log_bin_trust_function_creators=0;
 set global log_bin_trust_function_creators=1;
 # slave needs it too otherwise will not execute what master allowed:
 connection slave;
+set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 set global log_bin_trust_function_creators=1;
 
 connection con1;
@@ -555,9 +562,10 @@ source include/show_binlog_events.inc;
 # Restore log_bin_trust_function_creators to its original value.
 # This is a cleanup for all parts above where we tested stored
 # functions and triggers.
-set global log_bin_trust_function_creators=0;
+connection slave;
+set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 connection master;
-set global log_bin_trust_function_creators=0;
+set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 
 # Clean up
 drop database mysqltest;

=== modified file 'mysql-test/suite/rpl/t/rpl_sp_effects.test'
--- a/mysql-test/suite/rpl/t/rpl_sp_effects.test	2007-10-30 09:31:03 +0000
+++ b/mysql-test/suite/rpl/t/rpl_sp_effects.test	2008-07-10 16:09:39 +0000
@@ -10,6 +10,8 @@
 # ****************************************************************
 connection master;
 
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
+
 # cleanup
 --disable_warnings
 drop procedure if exists p1;
@@ -254,8 +256,8 @@ drop table t2;
 drop procedure sp_bug26199;
 drop function sf_bug26199;
 
-sync_slave_with_master;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 
-SET GLOBAL log_bin_trust_function_creators = 0;
+sync_slave_with_master;
 
 --echo end of the tests

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_until.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_until.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_until.test	2008-08-04 14:30:50 +0000
@@ -1,3 +1,22 @@
+# ==== Purpose ====
+#
+# Verify that START SLAVE UNTIL replicates until the given binlog
+# position but not longer.  Verify that START SLAVE UNTIL with various
+# incorrect arguments gives an error.
+#
+# ==== Method ====
+#
+# On master, create a table and insert some rows.  On slave, START
+# SLAVE UNTIL so that it reads one event at a time, and check the
+# table and the slave status each time.
+#
+# Then, on slave, run START SLAVE UNTIL with incorrect arguments and
+# verify that it gives an error.
+#
+# ==== Related bugs ====
+#
+# Bug in this test: BUG#37717: rpl.rpl_stm_until 'stmt' fails sporadically on pushbuild
+
 -- source include/have_binlog_format_mixed_or_statement.inc
 -- source include/master-slave.inc
 
@@ -6,15 +25,16 @@
 # prepare version for substitutions
 let $VERSION=`select version()`;
 
-# stop slave before he will start replication also sync with master
-# for avoiding undetermenistic behaviour
+# Stop slave before it starts replication.  Also sync with master
+# to avoid nondeterministic behaviour.
+--echo [on slave]
 sync_slave_with_master;
-stop slave;
-# Make sure the slave sql and io thread has stopped
---source include/wait_for_slave_to_stop.inc
+--source include/stop_slave.inc
+
+--echo ==== Create some events on master ====
 
+--echo [on master]
 connection master;
-# create some events on master
 create table t1(n int not null auto_increment primary key);
 insert into t1 values (1),(2),(3),(4);
 drop table t1;
@@ -23,9 +43,13 @@ insert into t2 values (1),(2);
 insert into t2 values (3),(4);
 drop table t2;
 
+--echo ==== Replicate one event at a time on slave ====
+
 # try to replicate all queries until drop of t1
+--echo [on slave]
 connection slave;
 start slave until master_log_file='master-bin.000001', master_log_pos=323;
+--source include/wait_for_slave_io_to_start.inc
 --source include/wait_for_slave_sql_to_stop.inc
 # here table should be still not deleted
 select * from t1;
@@ -33,33 +57,36 @@ source include/show_slave_status2.inc;
 
 # this should fail right after start
 start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
+--source include/wait_for_slave_io_to_start.inc
 --source include/wait_for_slave_sql_to_stop.inc
 # again this table should be still not deleted
 select * from t1;
 source include/show_slave_status2.inc;
 
 # try replicate all up to and not including the second insert to t2;
-start slave until relay_log_file='slave-relay-bin.000003', relay_log_pos=746;
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746;
+--source include/wait_for_slave_io_to_start.inc
 --source include/wait_for_slave_sql_to_stop.inc
 select * from t2;
 source include/show_slave_status2.inc;
 
 # clean up
 start slave;
+--echo [on master]
 connection master;
+--echo [on slave]
 sync_slave_with_master;
-stop slave;
-# Make sure the slave sql and io thread has stopped
---source include/wait_for_slave_to_stop.inc
+--source include/stop_slave.inc
 
 # this should stop immediately as we are already there
 start slave until master_log_file='master-bin.000001', master_log_pos=776;
+--source include/wait_for_slave_io_to_start.inc
 --source include/wait_for_slave_sql_to_stop.inc
-# here the sql slave thread should be stopped
 --replace_result bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
 source include/show_slave_status2.inc;
 
-#testing various error conditions
+--echo ==== Test various error conditions ====
+
 --error 1277
 start slave until master_log_file='master-bin', master_log_pos=561;
 --error 1277
@@ -74,4 +101,3 @@ start slave until relay_log_file='slave-
 start slave sql_thread;
 start slave until master_log_file='master-bin.000001', master_log_pos=776;
 
-# End of 4.1 tests

=== modified file 'mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result'
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result	2008-07-17 19:11:37 +0000
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result	2008-08-04 14:30:50 +0000
@@ -183,7 +183,7 @@ Last_SQL_Error	<Last_SQL_Error>
 Replicate_Ignore_Server_Ids	
 Master_Server_Id	1
 set GLOBAL slave_transaction_retries=10;
-START SLAVE;
+include/start_slave.inc
 select * from t1 order by nid;
 nid	nom	prenom
 1	LOCK	ABC1

=== modified file 'mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test'
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test	2008-05-09 15:28:34 +0000
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test	2008-08-04 14:30:50 +0000
@@ -190,22 +190,21 @@ set GLOBAL slave_transaction_retries=1;
 --echo **** On Master ****
 UPDATE t1 SET `nom`="DEAD" WHERE `nid`=1;
 
+--echo **** On Slave ****
 # Wait for deadlock to be detected.
 # When detected, the slave will stop, so we just wait for it to stop.
+connection slave;
 source include/wait_for_slave_sql_to_stop.inc;
 
 # Replication should have stopped, since max retries were not enough.
 # verify with show slave status
---connection slave
---echo **** On Slave ****
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 <Slave_IO_State> 7 <Read_Master_Log_Pos> 8 <Relay_Log_File> 9 <Relay_Log_Pos> 16 <Replicate_Ignore_Table> 22 <Exec_Master_Log_Pos> 23 <Relay_Log_Space> 33 <Seconds_Behind_Master> 35 <Last_IO_Errno> 36 <Last_IO_Error> 37 <Last_SQL_Errno> 38 <Last_SQL_Error>
 --query_vertical SHOW SLAVE STATUS;
 
 # now set max retries high enough to succeed, and start slave again
 set GLOBAL slave_transaction_retries=10;
-START SLAVE;
-source include/wait_for_slave_to_start.inc;
+source include/start_slave.inc;
 # Wait for deadlock to be detected and retried.
 # We want to wait until at least one retry has been made, but before
 # the slave stops. currently, there is no safe way to do that: we

=== modified file 'mysql-test/suite/rpl_ndb_big/r/rpl_ndb_log.result'
--- a/mysql-test/suite/rpl_ndb_big/r/rpl_ndb_log.result	2008-07-22 14:16:22 +0000
+++ b/mysql-test/suite/rpl_ndb_big/r/rpl_ndb_log.result	2008-08-04 14:30:50 +0000
@@ -4,7 +4,7 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-stop slave;
+include/stop_slave.inc
 reset master;
 reset slave;
 reset master;
@@ -117,11 +117,7 @@ Aberdeen
 Abernathy
 aberrant
 aberration
-start slave;
-
-let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%' ;
-
---source include/wait_slave_status.inc
+include/start_slave.inc
 select * from t1 order by 1 asc;
 word
 Aarhus
@@ -194,7 +190,8 @@ Abernathy
 aberrant
 aberration
 flush logs;
-stop slave;
+include/stop_slave.inc
+include/start_slave.inc
 create table t2 (n int)ENGINE=NDB;
 insert into t2 values (1);
 show binlog events from <binlog_start>;

=== renamed file 'mysql-test/suite/rpl_ndb_big/r/rpl_ndb_transaction.result' => 'mysql-test/suite/rpl_ndb_big/r/rpl_ndb_mixed_engines_transactions.result'
--- a/mysql-test/suite/rpl_ndb_big/r/rpl_ndb_transaction.result	2008-06-27 12:39:40 +0000
+++ b/mysql-test/suite/rpl_ndb_big/r/rpl_ndb_mixed_engines_transactions.result	2008-08-04 14:30:50 +0000
@@ -22,89 +22,436 @@ Table	Create Table
 tndb	CREATE TABLE `tndb` (
   `a` int(11) DEFAULT NULL
 ) ENGINE=ndbcluster DEFAULT CHARSET=latin1
-==== Test 1: Non-XA Engines ====
---- on master ---
+[on master]
+==== Single-engine transactions ====
+---- autocommitted ----
 SET AUTOCOMMIT = 1;
-INSERT INTO tndb VALUES (1);
-INSERT INTO tmyisam VALUES (1);
-BEGIN;
+INSERT INTO tmyisam VALUES (0);
+INSERT INTO tinnodb VALUES (1);
 INSERT INTO tndb VALUES (2);
-INSERT INTO tndb VALUES (3);
-COMMIT;
+---- committed with BEGIN ----
 BEGIN;
-INSERT INTO tmyisam VALUES (2);
 INSERT INTO tmyisam VALUES (3);
+INSERT INTO tmyisam VALUES (4);
 COMMIT;
 BEGIN;
-INSERT INTO tndb VALUES (4);
-INSERT INTO tmyisam VALUES (4);
+INSERT INTO tinnodb VALUES (5);
+INSERT INTO tinnodb VALUES (6);
 COMMIT;
 BEGIN;
-INSERT INTO tndb VALUES (5);
-INSERT INTO tndb VALUES (6);
+INSERT INTO tndb VALUES (7);
+INSERT INTO tndb VALUES (8);
+COMMIT;
+---- rolled back with BEGIN ----
+BEGIN;
+INSERT INTO tmyisam VALUES (9);
+INSERT INTO tmyisam VALUES (10);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+BEGIN;
+INSERT INTO tinnodb VALUES (11);
+INSERT INTO tinnodb VALUES (12);
 ROLLBACK;
 BEGIN;
-INSERT INTO tmyisam VALUES (5);
-INSERT INTO tmyisam VALUES (6);
+INSERT INTO tndb VALUES (13);
+INSERT INTO tndb VALUES (14);
+ROLLBACK;
+---- committed with AUTOCOMMIT = 0 ----
+SET AUTOCOMMIT = 0;
+INSERT INTO tmyisam VALUES (15);
+INSERT INTO tmyisam VALUES (16);
+COMMIT;
+INSERT INTO tinnodb VALUES (17);
+INSERT INTO tinnodb VALUES (18);
+COMMIT;
+INSERT INTO tndb VALUES (19);
+INSERT INTO tndb VALUES (20);
+COMMIT;
+---- rolled back with AUTOCOMMIT = 0 ----
+INSERT INTO tmyisam VALUES (21);
+INSERT INTO tmyisam VALUES (22);
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
+INSERT INTO tinnodb VALUES (23);
+INSERT INTO tinnodb VALUES (24);
+ROLLBACK;
+INSERT INTO tndb VALUES (25);
+INSERT INTO tndb VALUES (26);
+ROLLBACK;
+SET AUTOCOMMIT = 1;
+==== MyISAM + InnoDB ====
+---- committed with BEGIN ----
 BEGIN;
-INSERT INTO tndb VALUES (7);
-INSERT INTO tmyisam VALUES (7);
+INSERT INTO tmyisam VALUES (27);
+INSERT INTO tinnodb VALUES (28);
+COMMIT;
+BEGIN;
+INSERT INTO tinnodb VALUES (29);
+INSERT INTO tmyisam VALUES (30);
+COMMIT;
+---- rolled back with BEGIN ----
+BEGIN;
+INSERT INTO tmyisam VALUES (31);
+INSERT INTO tinnodb VALUES (32);
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
-SELECT * FROM tndb ORDER BY a;
+BEGIN;
+INSERT INTO tinnodb VALUES (33);
+INSERT INTO tmyisam VALUES (34);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+---- committed with AUTOCOMMIT = 0 ----
+SET AUTOCOMMIT = 0;
+INSERT INTO tmyisam VALUES (35);
+INSERT INTO tinnodb VALUES (36);
+COMMIT;
+INSERT INTO tinnodb VALUES (37);
+INSERT INTO tmyisam VALUES (38);
+COMMIT;
+---- rolled back with AUTOCOMMIT = 0 ----
+INSERT INTO tmyisam VALUES (39);
+INSERT INTO tinnodb VALUES (40);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+INSERT INTO tinnodb VALUES (41);
+INSERT INTO tmyisam VALUES (42);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+SET AUTOCOMMIT = 1;
+==== MyISAM + NDB ====
+---- committed with BEGIN----
+BEGIN;
+INSERT INTO tmyisam VALUES (43);
+INSERT INTO tndb VALUES (44);
+COMMIT;
+BEGIN;
+INSERT INTO tndb VALUES (45);
+INSERT INTO tmyisam VALUES (46);
+COMMIT;
+---- rolled back with BEGIN ----
+BEGIN;
+INSERT INTO tmyisam VALUES (47);
+INSERT INTO tndb VALUES (48);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+BEGIN;
+INSERT INTO tndb VALUES (49);
+INSERT INTO tmyisam VALUES (50);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+---- committed with AUTOCOMMIT = 0 ----
+SET AUTOCOMMIT = 0;
+INSERT INTO tmyisam VALUES (51);
+INSERT INTO tndb VALUES (52);
+COMMIT;
+INSERT INTO tndb VALUES (53);
+INSERT INTO tmyisam VALUES (54);
+COMMIT;
+---- rolled back with AUTOCOMMIT = 0 ----
+INSERT INTO tmyisam VALUES (55);
+INSERT INTO tndb VALUES (56);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+INSERT INTO tndb VALUES (57);
+INSERT INTO tmyisam VALUES (58);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+SET AUTOCOMMIT = 1;
+==== InnoDB + NDB ====
+---- committed with BEGIN ----
+BEGIN;
+INSERT INTO tinnodb VALUES (59);
+INSERT INTO tndb VALUES (60);
+COMMIT;
+BEGIN;
+INSERT INTO tndb VALUES (61);
+INSERT INTO tinnodb VALUES (62);
+COMMIT;
+---- rolled back with BEGIN ----
+BEGIN;
+INSERT INTO tinnodb VALUES (63);
+INSERT INTO tndb VALUES (64);
+ROLLBACK;
+BEGIN;
+INSERT INTO tndb VALUES (65);
+INSERT INTO tinnodb VALUES (66);
+ROLLBACK;
+---- committed with AUTOCOMMIT = 0 ----
+SET AUTOCOMMIT = 0;
+INSERT INTO tinnodb VALUES (67);
+INSERT INTO tndb VALUES (68);
+COMMIT;
+INSERT INTO tndb VALUES (69);
+INSERT INTO tinnodb VALUES (70);
+COMMIT;
+---- rolled back with AUTOCOMMIT = 0 ----
+INSERT INTO tinnodb VALUES (71);
+INSERT INTO tndb VALUES (72);
+ROLLBACK;
+INSERT INTO tndb VALUES (73);
+INSERT INTO tinnodb VALUES (74);
+ROLLBACK;
+SET AUTOCOMMIT = 1;
+==== MyISAM + InnoDB + NDB ====
+---- committed with BEGIN ----
+BEGIN;
+INSERT INTO tmyisam VALUES (75);
+INSERT INTO tinnodb VALUES (76);
+INSERT INTO tndb VALUES (77);
+COMMIT;
+BEGIN;
+INSERT INTO tmyisam VALUES (78);
+INSERT INTO tndb VALUES (79);
+INSERT INTO tinnodb VALUES (80);
+COMMIT;
+BEGIN;
+INSERT INTO tinnodb VALUES (81);
+INSERT INTO tmyisam VALUES (82);
+INSERT INTO tndb VALUES (83);
+COMMIT;
+BEGIN;
+INSERT INTO tinnodb VALUES (84);
+INSERT INTO tndb VALUES (85);
+INSERT INTO tmyisam VALUES (86);
+COMMIT;
+BEGIN;
+INSERT INTO tndb VALUES (87);
+INSERT INTO tmyisam VALUES (88);
+INSERT INTO tinnodb VALUES (89);
+COMMIT;
+BEGIN;
+INSERT INTO tndb VALUES (90);
+INSERT INTO tinnodb VALUES (91);
+INSERT INTO tmyisam VALUES (92);
+COMMIT;
+---- rolled back with BEGIN ----
+BEGIN;
+INSERT INTO tmyisam VALUES (93);
+INSERT INTO tinnodb VALUES (94);
+INSERT INTO tndb VALUES (95);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+BEGIN;
+INSERT INTO tmyisam VALUES (96);
+INSERT INTO tndb VALUES (97);
+INSERT INTO tinnodb VALUES (98);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+BEGIN;
+INSERT INTO tinnodb VALUES (99);
+INSERT INTO tmyisam VALUES (100);
+INSERT INTO tndb VALUES (101);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+BEGIN;
+INSERT INTO tinnodb VALUES (102);
+INSERT INTO tndb VALUES (103);
+INSERT INTO tmyisam VALUES (104);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+BEGIN;
+INSERT INTO tndb VALUES (105);
+INSERT INTO tmyisam VALUES (106);
+INSERT INTO tinnodb VALUES (107);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+BEGIN;
+INSERT INTO tndb VALUES (108);
+INSERT INTO tinnodb VALUES (109);
+INSERT INTO tmyisam VALUES (110);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+---- committed with AUTOCOMMIT = 0 ----
+SET AUTOCOMMIT = 0;
+INSERT INTO tmyisam VALUES (111);
+INSERT INTO tinnodb VALUES (112);
+INSERT INTO tndb VALUES (113);
+COMMIT;
+INSERT INTO tmyisam VALUES (114);
+INSERT INTO tndb VALUES (115);
+INSERT INTO tinnodb VALUES (116);
+COMMIT;
+INSERT INTO tinnodb VALUES (117);
+INSERT INTO tmyisam VALUES (118);
+INSERT INTO tndb VALUES (119);
+COMMIT;
+INSERT INTO tinnodb VALUES (120);
+INSERT INTO tndb VALUES (121);
+INSERT INTO tmyisam VALUES (122);
+COMMIT;
+INSERT INTO tndb VALUES (123);
+INSERT INTO tmyisam VALUES (124);
+INSERT INTO tinnodb VALUES (125);
+COMMIT;
+INSERT INTO tndb VALUES (126);
+INSERT INTO tinnodb VALUES (127);
+INSERT INTO tmyisam VALUES (128);
+COMMIT;
+---- rolled back with AUTOCOMMIT = 0 ----
+INSERT INTO tmyisam VALUES (129);
+INSERT INTO tinnodb VALUES (130);
+INSERT INTO tndb VALUES (131);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+INSERT INTO tmyisam VALUES (132);
+INSERT INTO tndb VALUES (133);
+INSERT INTO tinnodb VALUES (134);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+INSERT INTO tinnodb VALUES (135);
+INSERT INTO tmyisam VALUES (136);
+INSERT INTO tndb VALUES (137);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+INSERT INTO tinnodb VALUES (138);
+INSERT INTO tndb VALUES (139);
+INSERT INTO tmyisam VALUES (140);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+INSERT INTO tndb VALUES (141);
+INSERT INTO tmyisam VALUES (142);
+INSERT INTO tinnodb VALUES (143);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+INSERT INTO tndb VALUES (144);
+INSERT INTO tinnodb VALUES (145);
+INSERT INTO tmyisam VALUES (146);
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+SET AUTOCOMMIT = 1;
+==== Verify the result ====
+SELECT * FROM tmyisam ORDER BY a;
 a
-1
-2
+0
 3
 4
-SELECT * FROM tmyisam ORDER BY a;
+9
+10
+15
+16
+21
+22
+27
+30
+31
+34
+35
+38
+39
+42
+43
+46
+47
+50
+51
+54
+55
+58
+75
+78
+82
+86
+88
+92
+93
+96
+100
+104
+106
+110
+111
+114
+118
+122
+124
+128
+129
+132
+136
+140
+142
+146
+SELECT * FROM tinnodb ORDER BY a;
 a
 1
-2
-3
-4
 5
 6
-7
---- on slave ---
+17
+18
+28
+29
+36
+37
+59
+62
+67
+70
+76
+80
+81
+84
+89
+91
+112
+116
+117
+120
+125
+127
 SELECT * FROM tndb ORDER BY a;
 a
-1
-2
-3
-4
-SELECT * FROM tmyisam ORDER BY a;
-a
-1
 2
-3
-4
-5
-6
 7
-==== Test 2: Master crash before writing XID event on XA engine ====
---- on master ---
-INSERT INTO tinnodb VALUES (1);
-SELECT * FROM tinnodb ORDER BY a;
-a
-1
---- on slave ---
-STOP SLAVE;
-SELECT "" AS Slave_IO_State;
-Slave_IO_State
-
-SELECT "" AS Last_SQL_Error;
-Last_SQL_Error
-
-SELECT "" AS Last_IO_Error;
-Last_IO_Error
-
-SELECT * FROM tinnodb ORDER BY a;
-a
---- on master ---
-DROP TABLE tmyisam, tinnodb, tndb;
+8
+19
+20
+44
+45
+52
+53
+60
+61
+68
+69
+77
+79
+83
+85
+87
+90
+113
+115
+119
+121
+123
+126
+[on slave]
+Comparing tables master:test.tmyisam and slave:test.tmyisam
+Comparing tables master:test.tinnodb and slave:test.tinnodb
+Comparing tables master:test.tndb and slave:test.tndb
+==== Clean up ====
+[on master]
 DROP TABLE tmyisam, tinnodb, tndb;
+[on slave]

=== modified file 'mysql-test/suite/rpl_ndb_big/r/rpl_row_basic_7ndb.result'
--- a/mysql-test/suite/rpl_ndb_big/r/rpl_row_basic_7ndb.result	2008-06-27 12:39:40 +0000
+++ b/mysql-test/suite/rpl_ndb_big/r/rpl_row_basic_7ndb.result	2008-08-04 14:30:50 +0000
@@ -423,10 +423,10 @@ a	b	c
 **** On Master ****
 DELETE FROM t1;
 **** Resetting master and slave ****
-STOP SLAVE;
+include/stop_slave.inc
 RESET SLAVE;
 RESET MASTER;
-START SLAVE;
+include/start_slave.inc
 **** On Master ****
 INSERT INTO t1 VALUES ('K','K'), ('L','L'), ('M','M');
 **** On Master ****

=== renamed file 'mysql-test/suite/rpl_ndb_big/t/rpl_ndb_transaction-master.opt' => 'mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions-master.opt'
--- a/mysql-test/suite/rpl_ndb_big/t/rpl_ndb_transaction-master.opt	2008-06-27 12:39:40 +0000
+++ b/mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions-master.opt	2008-08-04 14:30:50 +0000
@@ -1 +1 @@
---innodb --debug=d,do_not_write_xid
+--innodb

=== renamed file 'mysql-test/suite/rpl_ndb_big/t/rpl_ndb_transaction-slave.opt' => 'mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions-slave.opt'
=== renamed file 'mysql-test/suite/rpl_ndb_big/t/rpl_ndb_transaction.test' => 'mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions.test'
--- a/mysql-test/suite/rpl_ndb_big/t/rpl_ndb_transaction.test	2008-07-22 14:16:22 +0000
+++ b/mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions.test	2008-08-04 14:30:50 +0000
@@ -1,14 +1,31 @@
-# Tests that transactions are replicated correctly, with various
-# combinations of non-transactional and transactional non-XA tables.
-# Also tests that an XA transaction where the master crashes just
-# before writing the XID log event is executed correctly.  See below
-# for implementation details.
+# ==== Purpose ====
+#
+# Tests that transactions containing multiple table types are
+# replicated correctly to the slave.
+#
+# This test was previously part of rpl_ndb_transactions.
+#
+#
+# ==== Method ====
+#
+# Try all combinations of the following:
+#  - Committed/rollback transactions.
+#  - Transactions started by AUTOCOMMIT = 0 or BEGIN.
+#  - Transactions using myisam, innodb, or ndb tables, or combinations
+#    of them. For combinations, we use the engines in all possible
+#    orders.
+# For single-engine transactions, we also try with AUTOCOMMIT = 1.
+#
+#
+# ==== Related bugs ====
+#
+# BUG#26395: if crash during autocommit update to transactional table on master, slave fails
+
 
 source include/ndb_master-slave.inc;
 source include/have_innodb.inc;
 source include/have_ndb.inc;
 source include/have_innodb.inc;
-source include/have_debug.inc;
 
 CREATE TABLE tmyisam (a int) ENGINE = MYISAM;
 CREATE TABLE tinnodb (a int) ENGINE = INNODB;
@@ -19,115 +36,416 @@ SHOW CREATE TABLE tinnodb;
 SHOW CREATE TABLE tndb;
 
 
---echo ==== Test 1: Non-XA Engines ====
-# Test that everything works fine with non-XA engines.  We just try
-# all ways to do transactions involving ndb and/or myisam, with
-# rollback or commit.
+--echo [on master]
+
 
---echo --- on master ---
+--echo ==== Single-engine transactions ====
+
+--echo ---- autocommitted ----
 
 SET AUTOCOMMIT = 1;
 
-INSERT INTO tndb VALUES (1);
-INSERT INTO tmyisam VALUES (1);
+INSERT INTO tmyisam VALUES (0);
+INSERT INTO tinnodb VALUES (1);
+INSERT INTO tndb VALUES (2);
+
+--echo ---- committed with BEGIN ----
 
 BEGIN;
-INSERT INTO tndb VALUES (2);
-INSERT INTO tndb VALUES (3);
+INSERT INTO tmyisam VALUES (3);
+INSERT INTO tmyisam VALUES (4);
 COMMIT;
 
 BEGIN;
-INSERT INTO tmyisam VALUES (2);
-INSERT INTO tmyisam VALUES (3);
+INSERT INTO tinnodb VALUES (5);
+INSERT INTO tinnodb VALUES (6);
 COMMIT;
 
 BEGIN;
-INSERT INTO tndb VALUES (4);
-INSERT INTO tmyisam VALUES (4);
+INSERT INTO tndb VALUES (7);
+INSERT INTO tndb VALUES (8);
 COMMIT;
 
+--echo ---- rolled back with BEGIN ----
+
 BEGIN;
-INSERT INTO tndb VALUES (5);
-INSERT INTO tndb VALUES (6);
+INSERT INTO tmyisam VALUES (9);
+INSERT INTO tmyisam VALUES (10);
 ROLLBACK;
 
 BEGIN;
-INSERT INTO tmyisam VALUES (5);
-INSERT INTO tmyisam VALUES (6);
-#--warning 1196
+INSERT INTO tinnodb VALUES (11);
+INSERT INTO tinnodb VALUES (12);
 ROLLBACK;
 
 BEGIN;
-INSERT INTO tndb VALUES (7);
-INSERT INTO tmyisam VALUES (7);
-#--warning 1196
+INSERT INTO tndb VALUES (13);
+INSERT INTO tndb VALUES (14);
 ROLLBACK;
 
-SELECT * FROM tndb ORDER BY a;
-SELECT * FROM tmyisam ORDER BY a;
 
---echo --- on slave ---
---sync_slave_with_master
-SELECT * FROM tndb ORDER BY a;
-SELECT * FROM tmyisam ORDER BY a;
+--echo ---- committed with AUTOCOMMIT = 0 ----
 
+SET AUTOCOMMIT = 0;
 
---echo ==== Test 2: Master crash before writing XID event on XA engine ====
-# We now want to test the following scenario, to verify that BUG#26395
-# has been fixed:
-
-#   "master and slave have a transactional table that uses XA. Master
-#    has AUTOCOMMIT on and executes a statement (in this case an
-#    INSERT). Master crashes just before writing the XID event."
-
-# In this scenario, master will roll back, so slave should not execute
-# the statement, and slave should roll back later when master is
-# restarted.
-
-# However, we want the master to be alive so that we are sure it
-# replicates the statement to the slave. So in the test case, we must
-# therefore not crash the master. Instead, we fake the crash by just
-# not writing the XID event to the binlog. This is done by the
-# --debug=d,do_not_write_xid flag in the .opt file.
-
-# So, unlike if the master had crashed, the master *will* execute the
-# statement. But the slave should not execute it. Hence, after the
-# first test is executed, the expected result on master is a table
-# with one row, and on slave a table with no rows.
-
-# To simulate the slave correctly, we wait until everything up to the
-# XID is replicated. We cannot sync_slave_with_master, because that
-# would wait for the transaction to end. Instead, we wait for
-# "sufficiently long time". Then we stop the slave.
+INSERT INTO tmyisam VALUES (15);
+INSERT INTO tmyisam VALUES (16);
+COMMIT;
 
-# Note: since this puts the master binlog in an inconsistent state,
-# this should be the last test of the file.
+INSERT INTO tinnodb VALUES (17);
+INSERT INTO tinnodb VALUES (18);
+COMMIT;
 
---echo --- on master ---
---connection master
+INSERT INTO tndb VALUES (19);
+INSERT INTO tndb VALUES (20);
+COMMIT;
 
-INSERT INTO tinnodb VALUES (1);
-SELECT * FROM tinnodb ORDER BY a;
+--echo ---- rolled back with AUTOCOMMIT = 0 ----
+
+INSERT INTO tmyisam VALUES (21);
+INSERT INTO tmyisam VALUES (22);
+ROLLBACK;
 
---echo --- on slave ---
---connection slave
---sleep 3
-STOP SLAVE;
-source include/wait_for_slave_to_stop.inc;
-let $tmp= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1);
-eval SELECT "$tmp" AS Slave_IO_State;
-let $tmp= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
-eval SELECT "$tmp" AS Last_SQL_Error;
-let $tmp= query_get_value("SHOW SLAVE STATUS", Last_IO_Error, 1);
-eval SELECT "$tmp" AS Last_IO_Error;
+INSERT INTO tinnodb VALUES (23);
+INSERT INTO tinnodb VALUES (24);
+ROLLBACK;
+
+INSERT INTO tndb VALUES (25);
+INSERT INTO tndb VALUES (26);
+ROLLBACK;
+
+SET AUTOCOMMIT = 1;
+
+
+--echo ==== MyISAM + InnoDB ====
+
+--echo ---- committed with BEGIN ----
+
+BEGIN;
+INSERT INTO tmyisam VALUES (27);
+INSERT INTO tinnodb VALUES (28);
+COMMIT;
+
+BEGIN;
+INSERT INTO tinnodb VALUES (29);
+INSERT INTO tmyisam VALUES (30);
+COMMIT;
+
+--echo ---- rolled back with BEGIN ----
+
+BEGIN;
+INSERT INTO tmyisam VALUES (31);
+INSERT INTO tinnodb VALUES (32);
+ROLLBACK;
+
+BEGIN;
+INSERT INTO tinnodb VALUES (33);
+INSERT INTO tmyisam VALUES (34);
+ROLLBACK;
+
+--echo ---- committed with AUTOCOMMIT = 0 ----
+
+SET AUTOCOMMIT = 0;
+
+INSERT INTO tmyisam VALUES (35);
+INSERT INTO tinnodb VALUES (36);
+COMMIT;
+
+INSERT INTO tinnodb VALUES (37);
+INSERT INTO tmyisam VALUES (38);
+COMMIT;
+
+--echo ---- rolled back with AUTOCOMMIT = 0 ----
+
+INSERT INTO tmyisam VALUES (39);
+INSERT INTO tinnodb VALUES (40);
+ROLLBACK;
+
+INSERT INTO tinnodb VALUES (41);
+INSERT INTO tmyisam VALUES (42);
+ROLLBACK;
+
+SET AUTOCOMMIT = 1;
+
+
+--echo ==== MyISAM + NDB ====
+
+--echo ---- committed with BEGIN----
+
+BEGIN;
+INSERT INTO tmyisam VALUES (43);
+INSERT INTO tndb VALUES (44);
+COMMIT;
+
+BEGIN;
+INSERT INTO tndb VALUES (45);
+INSERT INTO tmyisam VALUES (46);
+COMMIT;
+
+--echo ---- rolled back with BEGIN ----
+
+BEGIN;
+INSERT INTO tmyisam VALUES (47);
+INSERT INTO tndb VALUES (48);
+ROLLBACK;
+
+BEGIN;
+INSERT INTO tndb VALUES (49);
+INSERT INTO tmyisam VALUES (50);
+ROLLBACK;
+
+--echo ---- committed with AUTOCOMMIT = 0 ----
+
+SET AUTOCOMMIT = 0;
+
+INSERT INTO tmyisam VALUES (51);
+INSERT INTO tndb VALUES (52);
+COMMIT;
+
+INSERT INTO tndb VALUES (53);
+INSERT INTO tmyisam VALUES (54);
+COMMIT;
+
+--echo ---- rolled back with AUTOCOMMIT = 0 ----
+
+INSERT INTO tmyisam VALUES (55);
+INSERT INTO tndb VALUES (56);
+ROLLBACK;
+
+INSERT INTO tndb VALUES (57);
+INSERT INTO tmyisam VALUES (58);
+ROLLBACK;
+
+SET AUTOCOMMIT = 1;
+
+
+--echo ==== InnoDB + NDB ====
+
+--echo ---- committed with BEGIN ----
+
+BEGIN;
+INSERT INTO tinnodb VALUES (59);
+INSERT INTO tndb VALUES (60);
+COMMIT;
+
+BEGIN;
+INSERT INTO tndb VALUES (61);
+INSERT INTO tinnodb VALUES (62);
+COMMIT;
+
+--echo ---- rolled back with BEGIN ----
+
+BEGIN;
+INSERT INTO tinnodb VALUES (63);
+INSERT INTO tndb VALUES (64);
+ROLLBACK;
+
+BEGIN;
+INSERT INTO tndb VALUES (65);
+INSERT INTO tinnodb VALUES (66);
+ROLLBACK;
+
+--echo ---- committed with AUTOCOMMIT = 0 ----
+
+SET AUTOCOMMIT = 0;
+
+INSERT INTO tinnodb VALUES (67);
+INSERT INTO tndb VALUES (68);
+COMMIT;
+
+INSERT INTO tndb VALUES (69);
+INSERT INTO tinnodb VALUES (70);
+COMMIT;
+
+--echo ---- rolled back with AUTOCOMMIT = 0 ----
+
+INSERT INTO tinnodb VALUES (71);
+INSERT INTO tndb VALUES (72);
+ROLLBACK;
+
+INSERT INTO tndb VALUES (73);
+INSERT INTO tinnodb VALUES (74);
+ROLLBACK;
+
+SET AUTOCOMMIT = 1;
+
+
+--echo ==== MyISAM + InnoDB + NDB ====
+
+--echo ---- committed with BEGIN ----
+
+BEGIN;
+INSERT INTO tmyisam VALUES (75);
+INSERT INTO tinnodb VALUES (76);
+INSERT INTO tndb VALUES (77);
+COMMIT;
+
+BEGIN;
+INSERT INTO tmyisam VALUES (78);
+INSERT INTO tndb VALUES (79);
+INSERT INTO tinnodb VALUES (80);
+COMMIT;
+
+BEGIN;
+INSERT INTO tinnodb VALUES (81);
+INSERT INTO tmyisam VALUES (82);
+INSERT INTO tndb VALUES (83);
+COMMIT;
+
+BEGIN;
+INSERT INTO tinnodb VALUES (84);
+INSERT INTO tndb VALUES (85);
+INSERT INTO tmyisam VALUES (86);
+COMMIT;
+
+BEGIN;
+INSERT INTO tndb VALUES (87);
+INSERT INTO tmyisam VALUES (88);
+INSERT INTO tinnodb VALUES (89);
+COMMIT;
+
+BEGIN;
+INSERT INTO tndb VALUES (90);
+INSERT INTO tinnodb VALUES (91);
+INSERT INTO tmyisam VALUES (92);
+COMMIT;
+
+--echo ---- rolled back with BEGIN ----
+
+BEGIN;
+INSERT INTO tmyisam VALUES (93);
+INSERT INTO tinnodb VALUES (94);
+INSERT INTO tndb VALUES (95);
+ROLLBACK;
+
+BEGIN;
+INSERT INTO tmyisam VALUES (96);
+INSERT INTO tndb VALUES (97);
+INSERT INTO tinnodb VALUES (98);
+ROLLBACK;
+
+BEGIN;
+INSERT INTO tinnodb VALUES (99);
+INSERT INTO tmyisam VALUES (100);
+INSERT INTO tndb VALUES (101);
+ROLLBACK;
+
+BEGIN;
+INSERT INTO tinnodb VALUES (102);
+INSERT INTO tndb VALUES (103);
+INSERT INTO tmyisam VALUES (104);
+ROLLBACK;
+
+BEGIN;
+INSERT INTO tndb VALUES (105);
+INSERT INTO tmyisam VALUES (106);
+INSERT INTO tinnodb VALUES (107);
+ROLLBACK;
+
+BEGIN;
+INSERT INTO tndb VALUES (108);
+INSERT INTO tinnodb VALUES (109);
+INSERT INTO tmyisam VALUES (110);
+ROLLBACK;
+
+--echo ---- committed with AUTOCOMMIT = 0 ----
+
+SET AUTOCOMMIT = 0;
+
+INSERT INTO tmyisam VALUES (111);
+INSERT INTO tinnodb VALUES (112);
+INSERT INTO tndb VALUES (113);
+COMMIT;
+
+INSERT INTO tmyisam VALUES (114);
+INSERT INTO tndb VALUES (115);
+INSERT INTO tinnodb VALUES (116);
+COMMIT;
+
+INSERT INTO tinnodb VALUES (117);
+INSERT INTO tmyisam VALUES (118);
+INSERT INTO tndb VALUES (119);
+COMMIT;
+
+INSERT INTO tinnodb VALUES (120);
+INSERT INTO tndb VALUES (121);
+INSERT INTO tmyisam VALUES (122);
+COMMIT;
+
+INSERT INTO tndb VALUES (123);
+INSERT INTO tmyisam VALUES (124);
+INSERT INTO tinnodb VALUES (125);
+COMMIT;
+
+INSERT INTO tndb VALUES (126);
+INSERT INTO tinnodb VALUES (127);
+INSERT INTO tmyisam VALUES (128);
+COMMIT;
+
+--echo ---- rolled back with AUTOCOMMIT = 0 ----
+
+INSERT INTO tmyisam VALUES (129);
+INSERT INTO tinnodb VALUES (130);
+INSERT INTO tndb VALUES (131);
+ROLLBACK;
+
+INSERT INTO tmyisam VALUES (132);
+INSERT INTO tndb VALUES (133);
+INSERT INTO tinnodb VALUES (134);
+ROLLBACK;
+
+INSERT INTO tinnodb VALUES (135);
+INSERT INTO tmyisam VALUES (136);
+INSERT INTO tndb VALUES (137);
+ROLLBACK;
+
+INSERT INTO tinnodb VALUES (138);
+INSERT INTO tndb VALUES (139);
+INSERT INTO tmyisam VALUES (140);
+ROLLBACK;
+
+INSERT INTO tndb VALUES (141);
+INSERT INTO tmyisam VALUES (142);
+INSERT INTO tinnodb VALUES (143);
+ROLLBACK;
+
+INSERT INTO tndb VALUES (144);
+INSERT INTO tinnodb VALUES (145);
+INSERT INTO tmyisam VALUES (146);
+ROLLBACK;
+
+SET AUTOCOMMIT = 1;
+
+
+--echo ==== Verify the result ====
+
+SELECT * FROM tmyisam ORDER BY a;
 SELECT * FROM tinnodb ORDER BY a;
+SELECT * FROM tndb ORDER BY a;
+
+--echo [on slave]
+--sync_slave_with_master
+
+let $diff_table_1=master:test.tmyisam;
+let $diff_table_2=slave:test.tmyisam;
+source include/diff_tables.inc;
 
-# Clean up. We cannot do it on master and replicate over, because
-# master binlog is in a bad state after last test. So we do it both on
-# master and on slave.
---echo --- on master ---
+let $diff_table_1=master:test.tinnodb;
+let $diff_table_2=slave:test.tinnodb;
+source include/diff_tables.inc;
+
+let $diff_table_1=master:test.tndb;
+let $diff_table_2=slave:test.tndb;
+source include/diff_tables.inc;
+
+
+--echo ==== Clean up ====
+
+--echo [on master]
 connection master;
 DROP TABLE tmyisam, tinnodb, tndb;
 
-connection slave;
-DROP TABLE tmyisam, tinnodb, tndb;
+--echo [on slave]
+sync_slave_with_master;
+
+source include/master-slave-end.inc;

=== modified file 'mysql-test/t/backup_myisam1.test'
--- a/mysql-test/t/backup_myisam1.test	2008-07-22 18:08:06 +0000
+++ b/mysql-test/t/backup_myisam1.test	2008-08-04 14:30:50 +0000
@@ -3,6 +3,11 @@
 
 --source include/not_embedded.inc
 
+disable_query_log;
+call mtr.add_supression("Backup:");
+call mtr.add_supression("Restore:");
+enable_query_log;
+
 #
 # Cleanup from former test cases
 #

=== modified file 'mysql-test/t/backup_security.test'
--- a/mysql-test/t/backup_security.test	2008-07-22 18:08:06 +0000
+++ b/mysql-test/t/backup_security.test	2008-08-04 14:30:50 +0000
@@ -7,6 +7,11 @@
 
 --source include/not_embedded.inc
 
+disable_query_log;
+call mtr.add_supression("Backup:");
+call mtr.add_supression("Restore:");
+enable_query_log;
+
 --disable_warnings
 DROP DATABASE IF EXISTS backup_test;
 --enable_warnings

=== modified file 'mysql-test/t/character_set_database_func.test'
--- a/mysql-test/t/character_set_database_func.test	2008-04-16 08:23:07 +0000
+++ b/mysql-test/t/character_set_database_func.test	2008-05-30 09:12:07 +0000
@@ -92,14 +92,14 @@ CREATE TABLE t1 (a CHAR(4) CHARACTER SET
 --echo 'Verify with latin';
 SET @@session.character_set_database = latin1;
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data_ln/charset_utf8.txt' INTO TABLE t1;
+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/charset_utf8.txt' INTO TABLE t1;
 SELECT count(*) FROM t1 WHERE CHAR_LENGTH(a)>1;
 TRUNCATE TABLE t1;
 
 --echo 'Verify with utf8';
 SET @@session.character_set_database = utf8;
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data_ln/charset_utf8.txt' INTO TABLE t1;
+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/charset_utf8.txt' INTO TABLE t1;
 SELECT count(*) FROM t1 WHERE CHAR_LENGTH(a)>1;
 
 --disable_warnings

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2008-07-22 14:16:22 +0000
+++ b/mysql-test/t/disabled.def	2008-08-04 14:30:50 +0000
@@ -45,3 +45,98 @@ tmp_table_size_basic_32     : Bug#36878 
 backup_triggers_and_events  : Bug#37762 2008-07-01 rafal Test fails on remove_file for unknown reasons
 backup_tablespace           : Bug#36973 2008-07-01 rafal
 backup_no_be                : Bug#38023 2008-07-16 rafal Test triggers valgrind warnings described in the bug
+thread_cache_size_func : Bug#36733 main.thread_cache_size_func fails randomly
+binlog_cache_size_basic_32            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+bulk_insert_buffer_size_basic_32      : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+delayed_insert_limit_basic_32         : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+delayed_queue_size_basic_32           : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+innodb_concurrency_tickets_basic_32   : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+innodb_max_purge_lag_basic_32         : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+innodb_sync_spin_loops_basic_32       : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+join_buffer_size_basic_32             : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+key_buffer_size_basic_32              : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+key_cache_age_threshold_basic_32      : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+key_cache_block_size_basic_32         : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+key_cache_division_limit_basic_32     : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+log_warnings_basic_32                 : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_binlog_cache_size_basic_32        : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_connect_errors_basic_32           : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_heap_table_size_basic_32          : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_seeks_for_key_basic_32            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_tmp_tables_basic_32               : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_write_lock_count_basic_32         : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+min_examined_row_limit_basic_32       : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+multi_range_count_basic_32            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+myisam_max_sort_file_size_basic_32    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+myisam_repair_threads_basic_32        : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+myisam_sort_buffer_size_basic_32      : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+net_retry_count_basic_32              : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_alloc_block_size_basic_32       : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_cache_limit_basic_32            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_cache_min_res_unit_basic_32     : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_cache_size_basic_32             : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_prealloc_size_basic_32          : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+range_alloc_block_size_basic_32       : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+rpl_recovery_rank_basic_32            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+server_id_basic_32                    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+slave_transaction_retries_basic_32    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+sort_buffer_size_basic_32             : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+sync_binlog_basic_32                  : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+timestamp_basic_32                    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+tmp_table_size_basic_32               : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+transaction_alloc_block_size_basic_32 : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+transaction_prealloc_size_basic_32    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+wait_timeout_basic_32                 : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+binlog_cache_size_basic_64            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+bulk_insert_buffer_size_basic_64      : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+delayed_insert_limit_basic_64         : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+delayed_queue_size_basic_64           : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+innodb_concurrency_tickets_basic_64   : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+innodb_max_purge_lag_basic_64         : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+innodb_sync_spin_loops_basic_64       : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+join_buffer_size_basic_64             : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+key_buffer_size_basic_64              : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+key_cache_age_threshold_basic_64      : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+key_cache_block_size_basic_64         : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+key_cache_division_limit_basic_64     : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+log_warnings_basic_64                 : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_binlog_cache_size_basic_64        : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_connect_errors_basic_64           : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_heap_table_size_basic_64          : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_seeks_for_key_basic_64            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_tmp_tables_basic_64               : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+max_write_lock_count_basic_64         : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+min_examined_row_limit_basic_64       : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+multi_range_count_basic_64            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+myisam_max_sort_file_size_basic_64    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+myisam_repair_threads_basic_64        : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+myisam_sort_buffer_size_basic_64      : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+net_retry_count_basic_64              : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_alloc_block_size_basic_64       : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_cache_limit_basic_64            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_cache_min_res_unit_basic_64     : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_cache_size_basic_64             : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_prealloc_size_basic_64          : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+range_alloc_block_size_basic_64       : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+rpl_recovery_rank_basic_64            : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+server_id_basic_64                    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+slave_transaction_retries_basic_64    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+sort_buffer_size_basic_64             : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+sync_binlog_basic_64                  : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+timestamp_basic_64                    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+tmp_table_size_basic_64               : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+transaction_alloc_block_size_basic_64 : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+transaction_prealloc_size_basic_64    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+wait_timeout_basic_64                 : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+wait_timeout_func                     : BUG#36873 2008-07-06 sven wait_timeout_func.test fails randomly
+delayed_insert_limit_func             : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+event_scheduler_func                  : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+innodb_max_dirty_pages_pct_func       : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+interactive_timeout_func              : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+query_cache_wlock_invalidate_func     : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+rpl_init_slave_func                   : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+rpl_max_binlog_size_func              : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+slow_query_log_func                   : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+sql_low_priority_updates_func         : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+timestamp_func                        : BUG#37962 2008-07-08 sven *_func tests containing sleeps/race conditions
+log_output_func                       : BUG#37766 2008-07-10 sven main.log_output_func randomly fails in pushbuild

=== modified file 'mysql-test/t/error_simulation.test'
--- a/mysql-test/t/error_simulation.test	2008-04-03 08:27:56 +0000
+++ b/mysql-test/t/error_simulation.test	2008-08-04 14:30:50 +0000
@@ -31,5 +31,6 @@ SELECT MAX(a) FROM t1 GROUP BY a,b;
 
 set tmp_table_size=default;
 DROP TABLE t1;
-
-
+disable_query_log;
+set debug='';
+enable_query_log;

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2008-02-27 15:13:12 +0000
+++ b/mysql-test/t/func_time.test	2008-07-10 16:09:39 +0000
@@ -606,6 +606,7 @@ select time_format('100:00:00', '%H %k %
 # Bug #12562: Make SYSDATE behave like it does in Oracle: always the current
 #             time, regardless of magic to make NOW() always the same for the
 #             entirety of a statement.
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 
 create table t1 (a timestamp default '2005-05-05 01:01:01',
@@ -656,6 +657,7 @@ end;
 delimiter ;//
 call t_sysdate();
 drop procedure t_sysdate;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 
 #
 # Bug #13534: timestampdiff() returned incorrect results across leap years

=== modified file 'mysql-test/t/grant.test'
--- a/mysql-test/t/grant.test	2008-06-10 22:27:52 +0000
+++ b/mysql-test/t/grant.test	2008-08-04 14:30:50 +0000
@@ -3,6 +3,7 @@
 # Grant tests not performed with embedded server
 -- source include/not_embedded.inc
 
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 
 # Cleanup
@@ -1468,4 +1469,4 @@ use test;
 DROP DATABASE dbbug33464;
 
 
---echo End of 5.1 tests
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;

=== modified file 'mysql-test/t/grant2.test'
--- a/mysql-test/t/grant2.test	2007-09-27 09:32:59 +0000
+++ b/mysql-test/t/grant2.test	2008-07-10 16:09:39 +0000
@@ -488,6 +488,7 @@ flush privileges;
 # BUG#13310 incorrect user parsing by SP
 #
 
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 
 grant all privileges on test.* to `a@`@localhost;
@@ -512,7 +513,7 @@ connection default;
 REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost;
 drop user `a@`@localhost;
 
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 
 
 #

=== modified file 'mysql-test/t/innodb_max_dirty_pages_pct_func.test'
--- a/mysql-test/t/innodb_max_dirty_pages_pct_func.test	2008-04-10 13:14:28 +0000
+++ b/mysql-test/t/innodb_max_dirty_pages_pct_func.test	2008-07-06 17:14:41 +0000
@@ -25,6 +25,8 @@
 # Check if setting innodb_max_dirty_pages_pct is changed in new connection# 
 ###########################################################################
 
+SET @old_innodb_max_dirty_pages_pct= @@global.innodb_max_dirty_pages_pct;
+
 SET @@global.innodb_max_dirty_pages_pct = 80;
 --echo 'connect (con1,localhost,root,,,,)'
 connect (con1,localhost,root,,,,);
@@ -157,6 +159,8 @@ DROP PROCEDURE add_records;
 DROP PROCEDURE add_until;
 DROP PROCEDURE check_pct;
 DROP FUNCTION dirty_pct;
+DROP TABLE t1;
+SET @@global.innodb_max_dirty_pages_pct = @old_innodb_max_dirty_pages_pct;
 
 ##################################################################
 # End of functionality Testing for innodb_max_dirty_pages_pct    #

=== modified file 'mysql-test/t/innodb_notembedded.test'
--- a/mysql-test/t/innodb_notembedded.test	2006-11-17 20:30:28 +0000
+++ b/mysql-test/t/innodb_notembedded.test	2008-07-10 16:09:39 +0000
@@ -5,6 +5,8 @@
 drop table if exists t1;
 --enable_warnings
 
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
+
 connect (a,localhost,root,,);
 connect (b,localhost,root,,);
 
@@ -39,4 +41,4 @@ drop table t1;
 drop function f1;
 disconnect a;
 disconnect b;
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;

=== modified file 'mysql-test/t/loaddata.test'
--- a/mysql-test/t/loaddata.test	2008-04-03 19:40:10 +0000
+++ b/mysql-test/t/loaddata.test	2008-07-04 09:33:34 +0000
@@ -163,7 +163,7 @@ set @@secure_file_priv= 0;
 # Test "load data"
 truncate table t1;
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT, ER_TEXTFILE_NOT_READABLE
 eval load data infile '$MYSQL_TEST_DIR/t/loaddata.test' into table t1;
 select * from t1;
 

=== modified file 'mysql-test/t/log_bin_trust_function_creators_func.test'
--- a/mysql-test/t/log_bin_trust_function_creators_func.test	2008-04-10 13:14:28 +0000
+++ b/mysql-test/t/log_bin_trust_function_creators_func.test	2008-07-10 16:09:39 +0000
@@ -35,6 +35,7 @@ drop table if exists t1;
 CREATE user tt@localhost;
 
 --echo ## Setting value of variable to 0 ##
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET @@global.log_bin_trust_function_creators = 0;
 
 --echo ## Creating new table t2 ##
@@ -119,3 +120,7 @@ drop table t1,t2;
 --echo ## Disconnecting both the connections ##
 disconnect test_con2;
 
+connection default;
+
+DROP USER tt@localhost;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;

=== added file 'mysql-test/t/multi_range_count_basic_32.test'
--- a/mysql-test/t/multi_range_count_basic_32.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/multi_range_count_basic_32.test	2008-05-08 18:13:39 +0000
@@ -0,0 +1,9 @@
+################################################################################
+# Created by Horst Hunger      2008-05-07                                      #
+#                                                                              #
+# Wrapper for 32 bit machines                                                  #
+################################################################################
+
+--source include/have_32bit.inc
+--source include/multi_range_count_basic.inc
+

=== added file 'mysql-test/t/multi_range_count_basic_64.test'
--- a/mysql-test/t/multi_range_count_basic_64.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/multi_range_count_basic_64.test	2008-05-08 18:13:39 +0000
@@ -0,0 +1,9 @@
+################################################################################
+# Created by Horst Hunger      2008-05-07                                      #
+#                                                                              #
+# Wrapper for 64 bit machines                                                  #
+################################################################################
+
+--source include/have_64bit.inc
+--source include/multi_range_count_basic.inc
+

=== modified file 'mysql-test/t/mysqlbinlog_base64.test'
--- a/mysql-test/t/mysqlbinlog_base64.test	2008-01-08 10:02:42 +0000
+++ b/mysql-test/t/mysqlbinlog_base64.test	2008-07-28 07:15:20 +0000
@@ -1,5 +1,10 @@
 -- source include/have_binlog_format_row.inc
 #
+# Reset master to cleanup binlog
+#
+reset master;
+
+#
 #  Write different events to binlog
 #
 create table t1 (a int);

=== modified file 'mysql-test/t/query_cache.test'
--- a/mysql-test/t/query_cache.test	2008-07-22 14:16:22 +0000
+++ b/mysql-test/t/query_cache.test	2008-08-04 14:30:50 +0000
@@ -788,9 +788,10 @@ create procedure `p1`()
 begin
  select a, f1() from t1;
 end//
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 call p1()//
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET GLOBAL log_bin_trust_function_creators = @old_log_bin_trust_function_creators;
 drop procedure p1//
 drop function f1//
 

=== modified file 'mysql-test/t/query_cache_notembedded.test'
--- a/mysql-test/t/query_cache_notembedded.test	2008-05-29 15:44:11 +0000
+++ b/mysql-test/t/query_cache_notembedded.test	2008-08-04 14:30:50 +0000
@@ -184,6 +184,8 @@ drop table t1;
 #
 # bug#14767: INSERT in SF + concurrent SELECT with query cache
 #
+connection default;
+SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 
 reset query cache;
@@ -225,7 +227,7 @@ disconnect con2;
 connection default;
 
 set GLOBAL query_cache_size=0;
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators = @old_log_bin_trust_function_creators;
 
 #
 # Bug #30269 Query cache eats memory

=== modified file 'mysql-test/t/rpl_init_slave_func.test'
--- a/mysql-test/t/rpl_init_slave_func.test	2008-04-10 13:14:28 +0000
+++ b/mysql-test/t/rpl_init_slave_func.test	2008-07-10 16:09:39 +0000
@@ -73,8 +73,7 @@ sync_with_master;
 
 SET @@global.init_slave = "SET @a=5";
 
-stop slave;
---wait_for_slave_to_stop
+source include/stop_slave.inc;
 reset slave;
 # Clean up old test tables
 --disable_warnings

=== modified file 'mysql-test/t/rpl_max_binlog_size_func.test'
--- a/mysql-test/t/rpl_max_binlog_size_func.test	2008-06-10 22:27:52 +0000
+++ b/mysql-test/t/rpl_max_binlog_size_func.test	2008-08-04 14:30:50 +0000
@@ -12,6 +12,7 @@ DROP TABLE IF EXISTS t1;
 --echo '--- check if log file is rotated after 4096 bytes ----' 
 #==============================================================
 
+SET @saved_max_binlog_size= @@global.max_binlog_size;
 SET @@global.max_binlog_size = 4096;
 CREATE TABLE t1(a CHAR(5));
 
@@ -28,10 +29,15 @@ dec $a;
 
 # if log file is not created then this will fail
 let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
 --file_exists $MYSQLD_DATADIR/mylog.000002
 
 --echo 'mylog.000002 exists'
 
+SET @@global.max_binlog_size= @saved_max_binlog_size;
+
+DROP TABLE t1;
+
 ###############################################################################
 # End of functionality testing for max_binlog_size                            #
 ###############################################################################

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2008-07-22 14:16:22 +0000
+++ b/mysql-test/t/subselect.test	2008-08-04 14:30:50 +0000
@@ -1035,6 +1035,23 @@ SELECT DISTINCT (SELECT a) FROM t1 LIMIT
 DROP TABLE t1;
 
 #
+# Bug 2198
+#
+
+create table t1 (a int, b decimal(13, 3)); 
+insert into t1 values (1, 0.123);
+let $outfile_abs= $MYSQLTEST_VARDIR/tmp/subselect.out.file.1;
+let $outfile_rel= ../../tmp/subselect.out.file.1;
+--error 0,1
+--remove_file $outfile_abs
+eval select a, (select max(b) from t1) into outfile "$outfile_rel" from t1;
+delete from t1;
+eval load data infile "$outfile_rel" into table t1;
+--remove_file $outfile_abs
+select * from t1;
+drop table t1;
+
+#
 # Bug 2479
 #
 

=== modified file 'mysql-test/t/timezone2.test'
--- a/mysql-test/t/timezone2.test	2007-03-09 10:12:31 +0000
+++ b/mysql-test/t/timezone2.test	2008-07-10 16:09:39 +0000
@@ -228,6 +228,7 @@ drop table t1;
 # Test for bug #11081 "Using a CONVERT_TZ function in a stored function
 # or trigger fails".
 #
+SET @old_log_bin_trust_function_creators = @@global.log_bin_trust_function_creators;
 SET GLOBAL log_bin_trust_function_creators = 1;
 
 create table t1 (ldt datetime, udt datetime);
@@ -243,7 +244,7 @@ select ldt, f1(udt) as ldt2 from t1;
 drop table t1;
 drop function f1;
 
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 
 # End of 5.0 tests
 

=== modified file 'mysql-test/t/wait_timeout_func.test'
--- a/mysql-test/t/wait_timeout_func.test	2008-04-11 19:59:33 +0000
+++ b/mysql-test/t/wait_timeout_func.test	2008-07-06 17:07:30 +0000
@@ -37,6 +37,8 @@ PRIMARY KEY (id),
 name VARCHAR(30)
 );
 
+SET @old_wait_timeout = @@global.wait_timeout;
+
 
 --echo '#--------------------FN_DYNVARS_186_01-------------------------#'
 #######################################################################
@@ -97,7 +99,10 @@ INSERT into t1(name) values('Record_3');
 --echo ## Using sleep to check timeout ##
 sleep 5;
 
---echo ## We cannot test it further because the server stops due to wait_timeout ## 
+--echo ## We cannot test it further because the server closes the connection due to wait_timeout ## 
 --Error 2006
 SELECT * from t1;
 
+connection default;
+DROP TABLE t1;
+SET @@global.wait_timeout = @old_wait_timeout;

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2008-07-22 18:30:36 +0000
+++ b/sql/set_var.cc	2008-08-04 14:30:50 +0000
@@ -1345,13 +1345,12 @@ static bool get_unsigned(THD *thd, set_v
 
 bool sys_var_int_ptr::check(THD *thd, set_var *var)
 {
-  var->save_result.ulong_value= (ulong) var->value->val_int();
-  return 0;
+  return get_unsigned(thd, var);
 }
 
 bool sys_var_int_ptr::update(THD *thd, set_var *var)
 {
-  *value= (uint) var->save_result.ulong_value;
+  *value= (uint) var->save_result.ulonglong_value;
   return 0;
 }
 

Thread
bzr push into mysql-6.0-backup branch (hezx:2691 to 2692) Bug#38374He Zhenxing5 Aug