List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:September 23 2010 8:50am
Subject:bzr push into mysql-next-mr-opt-team branch (tor.didriksen:3219 to 3220)
View as plain text  
 3220 Tor Didriksen	2010-09-23 [merge]
      Auto-merge: next-mr-opt-backporting => next-mr-opt-team

    added:
      mysql-test/include/rpl_assert.inc
      mysql-test/suite/perfschema/r/checksum.result
      mysql-test/suite/perfschema/t/checksum.test
    modified:
      dbug/dbug.c
      include/mysql/service_my_snprintf.h
      libservices/HOWTO
      mysql-test/extra/rpl_tests/delayed_slave_wait_on_query.inc
      mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test
      mysql-test/include/wait_for_slave_param.inc
      mysql-test/r/variables.result
      mysql-test/suite/perfschema/r/server_init.result
      mysql-test/suite/perfschema/t/server_init.test
      mysql-test/suite/rpl/r/rpl_delayed_slave.result
      mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
      mysql-test/suite/rpl/t/rpl_delayed_slave.test
      mysql-test/suite/rpl/t/rpl_mixed_binlog_max_cache_size-master.opt
      mysql-test/suite/rpl/t/rpl_row_binlog_max_cache_size-master.opt
      mysql-test/suite/rpl/t/rpl_stm_binlog_max_cache_size-master.opt
      mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic.result
      mysql-test/suite/sys_vars/t/max_binlog_cache_size_basic.test
      mysql-test/t/variables.test
      mysql-test/valgrind.supp
      packaging/WiX/mysql_server.wxs.in
      sql/binlog.cc
      sql/binlog.h
      sql/mysqld.cc
      sql/rpl_master.cc
      sql/rpl_rli.cc
      sql/rpl_slave.cc
      sql/share/errmsg-utf8.txt
      sql/sql_binlog.cc
      sql/sql_plugin.cc
      sql/sql_select.cc
      sql/sql_select.h
      sql/sys_vars.cc
      storage/perfschema/pfs_engine_table.cc
      storage/perfschema/table_events_waits.cc
      storage/perfschema/table_events_waits.h
      strings/my_vsnprintf.c
      unittest/mysys/my_vsnprintf-t.c
 3219 Tor Didriksen	2010-09-20 [merge]
      Automerge from next-mr-opt-backporting

    modified:
      mysql-test/include/subquery_sj.inc
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_jcl6.result
      mysql-test/r/subquery_sj_all_jcl7.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_jcl6.result
      mysql-test/r/subquery_sj_dupsweed_jcl7.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_jcl6.result
      mysql-test/r/subquery_sj_firstmatch_jcl7.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_jcl6.result
      mysql-test/r/subquery_sj_loosescan_jcl7.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_jcl6.result
      mysql-test/r/subquery_sj_mat_jcl7.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_jcl6.result
      mysql-test/r/subquery_sj_none_jcl7.result
      sql/item_subselect.cc
      sql/sql_select.cc
=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c	2010-07-15 11:41:37 +0000
+++ b/dbug/dbug.c	2010-09-15 11:51:29 +0000
@@ -1335,15 +1335,11 @@ void _db_doprnt_(const char *format,...)
  * This function is intended as a
  * vfprintf clone with consistent, platform independent output for 
  * problematic formats like %p, %zd and %lld.
- * However: full functionality for my_vsnprintf has not been backported yet,
- * so code using "%g" or "%f" will have undefined behaviour.
  */
 static void DbugVfprintf(FILE *stream, const char* format, va_list args)
 {
   char cvtbuf[1024];
-  size_t len;
-  /* Do not use my_vsnprintf, it does not support "%g". */
-  len = vsnprintf(cvtbuf, sizeof(cvtbuf), format, args);
+  (void) my_vsnprintf(cvtbuf, sizeof(cvtbuf), format, args);
   (void) fprintf(stream, "%s\n", cvtbuf);
 }
 

=== modified file 'include/mysql/service_my_snprintf.h'
--- a/include/mysql/service_my_snprintf.h	2010-07-20 19:34:20 +0000
+++ b/include/mysql/service_my_snprintf.h	2010-09-15 11:33:22 +0000
@@ -53,7 +53,7 @@
   <length modifier> can be 'l', 'll', or 'z'.
 
   Supported formats are 's' (null pointer is accepted, printed as
-  "(null)"), 'b' (extension, see below), 'c', 'd', 'u', 'x', 'o',
+  "(null)"), 'b' (extension, see below), 'c', 'd', 'i', 'u', 'x', 'o',
   'X', 'p' (works as 0x%x).
 
   Standard syntax for positional arguments $n is supported.

=== modified file 'libservices/HOWTO'
--- a/libservices/HOWTO	2009-11-02 20:05:42 +0000
+++ b/libservices/HOWTO	2010-09-21 13:05:38 +0000
@@ -71,7 +71,7 @@ it should also declare all the accompany
     #define VERSION_foo 0x0100
 ==================================================================
 
-7. create a new file libservices/foo_service.h using the following template:
+7. create a new file libservices/foo_service.c using the following template:
 ==================================================================
   /* GPL header */
   #include <service_versions.h>

=== modified file 'mysql-test/extra/rpl_tests/delayed_slave_wait_on_query.inc'
--- a/mysql-test/extra/rpl_tests/delayed_slave_wait_on_query.inc	2010-06-21 10:44:26 +0000
+++ b/mysql-test/extra/rpl_tests/delayed_slave_wait_on_query.inc	2010-09-16 11:00:57 +0000
@@ -10,21 +10,32 @@
 # - After one and a half delay, check the status. It should not be
 #   delaying and the query should be executed.
 #
+#
 # ==== Usage ====
 #
+# --let $query_number= 4
 # --source extra/rpl_tests/delayed_slave_wait_on_query.inc
+#
+# Parameters:
+# $query_number
+#   The value of the 'b' column in t1 for the row inserted by the query
+#   we are waiting for.
 
 connection master;
+
 --echo [on slave]
 --let $slave_timeout= $time1
-
 --source include/sync_slave_io_with_master.inc
 --echo # sleep 1*T
 --sleep $time1
 
---echo # Expect query not executed and status is 'Waiting until MASTER_DELAY...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
---source include/show_delayed_slave_state.inc
+--let $assert_text= Query $query_number should not be executed
+--let $assert_cond= MAX(b) < $query_number FROM t1
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be 'Waiting until MASTER_DELAY...'
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Waiting until MASTER_DELAY%"
+--source include/rpl_assert.inc
 
 --echo # sleep 1*T
 --sleep $time1
@@ -32,8 +43,13 @@ SELECT * FROM t1 ORDER BY b DESC LIMIT 1
 --echo # sync with master (with timeout 1*T)
 --source include/sync_with_master.inc
 
---echo # Expect query executed and status is 'Has read all relay log...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
---source include/show_delayed_slave_state.inc
+--let $assert_text= Query $query_number should be executed
+--let $assert_cond= MAX(b) = $query_number FROM t1
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be 'Has read all relay log...'
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Slave has read all relay log%"
+--source include/rpl_assert.inc
+
 
 --source include/check_slave_is_running.inc

=== modified file 'mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test'
--- a/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test	2010-06-30 20:56:21 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test	2010-09-06 16:21:15 +0000
@@ -1,11 +1,13 @@
 ########################################################################################
-#    This test verifies if the binlog is not corrupted when the cache buffer is not
-#    big enough to accommodate the changes and is divided in five steps:
+#    This test does two things. First it verifies if the binlog is not corrupted when
+#    the cache buffer is not big enough to accommodate the changes and is divided in
+#    five steps:
 #
 #    1 - Single Statements:
-#    1.1 - Single statement on transactional table.
-#    1.2 - Single statement on non-transactional table. 
-#    1.3 - Single statement on both transactional and non-transactional tables.
+#      1.1 - Single statement on transactional table.
+#      1.2 - Single statement on non-transactional table. 
+#      1.3 - Single statement on both transactional and non-transactional tables.
+#
 #    In both 1.2 and 1.3, an incident event is logged to notify the user that the
 #    master and slave are diverging.
 #
@@ -19,10 +21,14 @@
 #    table. In this case, a failure means that the statement does not get into
 #    the cache and an incident event is logged to notify the user that the master
 #    and slave are diverging.
-#    
+#
+#    Then it checks what happens when we try to set BINLOG_CACHE_SIZE to a value that
+#    is greater than MAX_BINLOG_CACHE_SIZE and vice-versa. In both cases, We expect
+#    that BINLOG_CACHE_SIZE will be set to MAX_BINLOG_CACHE_SIZE. (BUG#55377)
 ########################################################################################
 
 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression("Option binlog_cache_size ");
 
 CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
 CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
@@ -374,10 +380,29 @@ let $diff_statement= SELECT * FROM t1;
 --source include/diff_master_slave.inc
 
 --echo ########################################################################################
+--echo #                       CHECK MAX_BINLOG_CACHE_SIZE and BINLOG_CACHE_SIZE
+--echo ########################################################################################
+#
+# Checking what happens when we try to set BINLOG_CACHE_SIZE to a value that is
+# greater than MAX_BINLOG_CACHE_SIZE and vice-versa. In both cases, We expect
+# that BINLOG_CACHE_SIZE will be set to MAX_BINLOG_CACHE_SIZE. (BUG#55377)
+# 
+connection master;
+
+SET @@GLOBAL.MAX_BINLOG_CACHE_SIZE= 8192;
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+SET @@GLOBAL.BINLOG_CACHE_SIZE= 16384;
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+SET @@GLOBAL.MAX_BINLOG_CACHE_SIZE= 4096;
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+
+--echo ########################################################################################
 --echo #                                        CLEAN
 --echo ########################################################################################
 
-connection master;
 DROP TABLE t1;
 DROP TABLE t2;
 DROP TABLE t3;

=== added file 'mysql-test/include/rpl_assert.inc'
--- a/mysql-test/include/rpl_assert.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/rpl_assert.inc	2010-09-16 11:00:57 +0000
@@ -0,0 +1,118 @@
+# ==== Purpose ====
+#
+# Check if a condition holds, fail with debug info if not.
+#
+# The condition is parsed before executed. The following constructs
+# are supported:
+#
+#   [SQL STATEMENT, COLUMN, ROW]
+#     The square bracket is replaced by the result from SQL STATEMENT,
+#     in the given COLUMN and ROW.
+#
+#   <1>
+#     This is a shorthand for the result of the first executed square
+#     bracket. <2> is a shorthand for the second executed square
+#     bracket, and so on.
+#
+# ==== Usage ====
+#
+# --let $assert_text= Relay_Log_Pos must be smaller than pos.
+# --let $assert_cond= [SHOW SLAVE STATUS, Relay_Log_Pos, 1] >= $min_pos AND <1> <= $max_pos
+# [--let $assert_quiet= 1]
+# [--let $rpl_debug= 1]
+# --source include/rpl_assert.inc
+#
+# Parameters:
+#
+# $assert_text
+#   Text that describes what is being checked. By default, this text
+#   is written to the query log.
+#
+# $assert_cond
+#   Condition to check.  See above for details about the format.  The
+#   condition will be executed as `SELECT $assert_cond`.  Note: this
+#   condition is parsed using SQL statements, quoted inside single
+#   quotes, so it must not contain single quotes itself (use double
+#   quotes for strings).
+#
+# $assert_quiet
+#   Do not print $assert_text to the query log.
+#
+# $rpl_debug
+#   Print extra debug info.
+
+
+if ($rpl_debug)
+{
+  --echo # debug: assert_text='$assert_text' assert_cond='$assert_cond'
+}
+
+# Sanity-check input
+if (`SELECT "$assert_text" = ""`)
+{
+  --die ERROR IN TEST: the mysqltest variable rpl_test must be set
+}
+
+# Evaluate square brackets in cond.
+--let $_rpl_assert_substmt_number= 1
+--let $_rpl_interpolated_cond= $assert_cond
+--let $_rpl_assert_lbracket= `SELECT LOCATE('[', '$_rpl_interpolated_cond')`
+while ($_rpl_assert_lbracket)
+{
+  # Get position of right bracket
+  --let $_rpl_assert_rbracket= `SELECT LOCATE(']', '$_rpl_interpolated_cond')`
+  if (!$_rpl_assert_rbracket)
+  {
+    --echo BUG IN TEST: Mismatching square brackets in assert_cond: '$assert_cond'
+    --die BUG IN TEST: Mismatching square brackets in $assert_cond
+  }
+  # Get sub-statement and result of it
+  --let $_rpl_assert_substmt= `SELECT SUBSTRING('$_rpl_interpolated_cond', $_rpl_assert_lbracket + 1, $_rpl_assert_rbracket - $_rpl_assert_lbracket - 1)`
+  --let $_rpl_assert_substmt_result= query_get_value($_rpl_assert_substmt)
+  if ($rpl_debug)
+  {
+    --echo # debug: sub-statement='$_rpl_assert_substmt' result='$rpl_assert_result'
+  }
+  # Replace sub-statement by its result
+  --let $_rpl_interpolated_cond= `SELECT REPLACE('$_rpl_interpolated_cond', '[$_rpl_assert_substmt]', '$_rpl_assert_substmt_result')`
+  # Replace result references by result
+  --let $_rpl_interpolated_cond= `SELECT REPLACE('$_rpl_interpolated_cond', '<$_rpl_assert_substmt_number>', '$_rpl_assert_substmt_result')`
+
+  --let $_rpl_assert_lbracket= `SELECT LOCATE('[', '$_rpl_interpolated_cond')`
+
+  --inc $_rpl_assert_substmt_number
+}
+
+if ($rpl_debug)
+{
+  --echo # debug: interpolated_cond='$_rpl_interpolated_cond'
+}
+
+# Execute.
+--let $_rpl_assert_result= `SELECT $_rpl_interpolated_cond`
+
+if ($rpl_debug)
+{
+  --echo # debug: result='$_rpl_assert_result'
+}
+
+# Check.
+if (!$_rpl_assert_result)
+{
+  --echo ######## Test assertion failed: $assert_text ########
+  --echo Dumping debug info:
+  --source include/show_rpl_debug_info.inc
+  --echo Assertion text: '$assert_text'
+  --echo Assertion condition: '$assert_cond'
+  --echo Assertion condition, interpolated: '$_rpl_interpolated_cond'
+  --echo Assertion result: '$_rpl_assert_result'
+  --die Test assertion failed in rpl_assertion.inc
+}
+
+if (!$assert_quiet)
+{
+  --echo # Asserted this: $assert_text
+}
+
+--let $assert_text=
+--let $assert_cond=

=== modified file 'mysql-test/include/wait_for_slave_param.inc'
--- a/mysql-test/include/wait_for_slave_param.inc	2010-05-26 14:34:25 +0000
+++ b/mysql-test/include/wait_for_slave_param.inc	2010-09-16 11:00:57 +0000
@@ -25,7 +25,7 @@
 #
 # $slave_timeout
 #   The default timeout is 5 minutes. You can change the timeout by
-#   setting $slave_timeout. The unit is tenths of seconds.
+#   setting $slave_timeout. The unit is seconds.
 #
 # $master_connection
 #   If the timeout is reached, debug info is given by calling SHOW
@@ -47,10 +47,12 @@
 let $_slave_timeout_counter= $slave_timeout;
 if (!$_slave_timeout_counter)
 {
-  let $_slave_timeout_counter= 3000;
+  let $_slave_timeout_counter= 300;
 }
 # Save resulting counter for later use.
 let $slave_tcnt= $_slave_timeout_counter;
+# Convert to deci-seconds
+let $_slave_timeout_counter= `SELECT 10 * $_slave_timeout_counter`;
 
 let $_slave_param_comparison= $slave_param_comparison;
 if (`SELECT '$_slave_param_comparison' = ''`)
@@ -72,7 +74,7 @@ while (`SELECT NOT('$_show_slave_status_
 # This has to be outside the loop until BUG#41913 has been fixed
 if (!$_slave_timeout_counter)
 {
-  --echo **** ERROR: timeout after $slave_tcnt deci-seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
+  --echo **** ERROR: timeout after $slave_tcnt seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
   if (`SELECT '$slave_error_message' != ''`)
   {
     --echo Message: $slave_error_message
@@ -80,5 +82,5 @@ if (!$_slave_timeout_counter)
   --echo Current connection is '$CURRENT_CONNECTION'
   echo Note: the following output may have changed since the failure was detected;
   source include/show_rpl_debug_info.inc;
-  die;
+  die timeout in wait_for_slave_param.inc;
 }

=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2010-08-04 10:34:01 +0000
+++ b/mysql-test/r/variables.result	2010-09-20 12:12:36 +0000
@@ -1,5 +1,4 @@
 drop table if exists t1,t2;
-set @my_binlog_cache_size         =@@global.binlog_cache_size;
 set @my_connect_timeout           =@@global.connect_timeout;
 set @my_delayed_insert_timeout    =@@global.delayed_insert_timeout;
 set @my_delayed_queue_size        =@@global.delayed_queue_size;
@@ -7,6 +6,7 @@ set @my_flush                     =@@glo
 set @my_flush_time                =@@global.flush_time;
 set @my_key_buffer_size           =@@global.key_buffer_size;
 set @my_max_binlog_cache_size     =@@global.max_binlog_cache_size;
+set @my_binlog_cache_size         =@@global.binlog_cache_size;
 set @my_max_binlog_size           =@@global.max_binlog_size;
 set @my_max_connect_errors        =@@global.max_connect_errors;
 set @my_max_connections           =@@global.max_connections;
@@ -1035,7 +1035,6 @@ Warnings:
 Warning	1292	Truncated incorrect join_buffer_size value: '1'
 set @save_join_buffer_size=@@join_buffer_size;
 set join_buffer_size=@save_join_buffer_size;
-set global binlog_cache_size         =@my_binlog_cache_size;
 set global connect_timeout           =@my_connect_timeout;
 set global delayed_insert_timeout    =@my_delayed_insert_timeout;
 set global delayed_queue_size        =@my_delayed_queue_size;
@@ -1043,6 +1042,7 @@ set global flush                     =@m
 set global flush_time                =@my_flush_time;
 set global key_buffer_size           =@my_key_buffer_size;
 set global max_binlog_cache_size     =@my_max_binlog_cache_size;
+set global binlog_cache_size         =@my_binlog_cache_size;
 set global max_binlog_size           =@my_max_binlog_size;
 set global max_connect_errors        =@my_max_connect_errors;
 set global max_connections           =@my_max_connections;

=== added file 'mysql-test/suite/perfschema/r/checksum.result'
--- a/mysql-test/suite/perfschema/r/checksum.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/checksum.result	2010-09-15 18:20:48 +0000
@@ -0,0 +1,34 @@
+checksum table performance_schema.COND_INSTANCES;
+checksum table performance_schema.EVENTS_WAITS_CURRENT;
+checksum table performance_schema.EVENTS_WAITS_HISTORY;
+checksum table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME;
+checksum table performance_schema.FILE_INSTANCES;
+checksum table performance_schema.FILE_SUMMARY_BY_EVENT_NAME;
+checksum table performance_schema.FILE_SUMMARY_BY_INSTANCE;
+checksum table performance_schema.MUTEX_INSTANCES;
+checksum table performance_schema.PERFORMANCE_TIMERS;
+checksum table performance_schema.RWLOCK_INSTANCES;
+checksum table performance_schema.SETUP_CONSUMERS;
+checksum table performance_schema.SETUP_INSTRUMENTS;
+checksum table performance_schema.SETUP_TIMERS;
+checksum table performance_schema.THREADS;
+checksum table performance_schema.COND_INSTANCES extended;
+checksum table performance_schema.EVENTS_WAITS_CURRENT extended;
+checksum table performance_schema.EVENTS_WAITS_HISTORY extended;
+checksum table performance_schema.EVENTS_WAITS_HISTORY_LONG extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME extended;
+checksum table performance_schema.FILE_INSTANCES extended;
+checksum table performance_schema.FILE_SUMMARY_BY_EVENT_NAME extended;
+checksum table performance_schema.FILE_SUMMARY_BY_INSTANCE extended;
+checksum table performance_schema.MUTEX_INSTANCES extended;
+checksum table performance_schema.PERFORMANCE_TIMERS extended;
+checksum table performance_schema.RWLOCK_INSTANCES extended;
+checksum table performance_schema.SETUP_CONSUMERS extended;
+checksum table performance_schema.SETUP_INSTRUMENTS extended;
+checksum table performance_schema.SETUP_TIMERS extended;
+checksum table performance_schema.THREADS extended;

=== modified file 'mysql-test/suite/perfschema/r/server_init.result'
--- a/mysql-test/suite/perfschema/r/server_init.result	2010-08-20 08:48:59 +0000
+++ b/mysql-test/suite/perfschema/r/server_init.result	2010-09-17 16:43:02 +0000
@@ -112,18 +112,10 @@ where name like "wait/synch/mutex/sql/LO
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOG_INFO::lock";
-count(name)
-1
-select count(name) from MUTEX_INSTANCES
 where name like "wait/synch/mutex/sql/Query_cache::structure_guard_mutex";
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state";
-count(name)
-1
-select count(name) from MUTEX_INSTANCES
 where name like "wait/synch/mutex/sql/LOCK_event_metadata";
 count(name)
 1
@@ -140,15 +132,15 @@ where name like "wait/synch/mutex/sql/Cv
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_xid_cache";
+where name like "wait/synch/mutex/sql/LOCK_audit_mask";
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_plugin";
+where name like "wait/synch/mutex/sql/LOCK_xid_cache";
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
-where name like "wait/synch/mutex/sql/LOCK_gdl";
+where name like "wait/synch/mutex/sql/LOCK_plugin";
 count(name)
 1
 select count(name) from MUTEX_INSTANCES
@@ -204,10 +196,6 @@ where name like "wait/synch/cond/sql/Que
 count(name)
 1
 select count(name) from COND_INSTANCES
-where name like "wait/synch/cond/sql/Event_scheduler::COND_state";
-count(name)
-1
-select count(name) from COND_INSTANCES
 where name like "wait/synch/cond/sql/COND_queue_state";
 count(name)
 1

=== added file 'mysql-test/suite/perfschema/t/checksum.test'
--- a/mysql-test/suite/perfschema/t/checksum.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/checksum.test	2010-09-15 18:20:48 +0000
@@ -0,0 +1,64 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# The checksum value itself is random (data is volatile),
+# just testing that this does not crash
+#
+--disable_result_log
+
+checksum table performance_schema.COND_INSTANCES;
+checksum table performance_schema.EVENTS_WAITS_CURRENT;
+checksum table performance_schema.EVENTS_WAITS_HISTORY;
+checksum table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME;
+checksum table performance_schema.FILE_INSTANCES;
+checksum table performance_schema.FILE_SUMMARY_BY_EVENT_NAME;
+checksum table performance_schema.FILE_SUMMARY_BY_INSTANCE;
+checksum table performance_schema.MUTEX_INSTANCES;
+checksum table performance_schema.PERFORMANCE_TIMERS;
+checksum table performance_schema.RWLOCK_INSTANCES;
+checksum table performance_schema.SETUP_CONSUMERS;
+checksum table performance_schema.SETUP_INSTRUMENTS;
+checksum table performance_schema.SETUP_TIMERS;
+checksum table performance_schema.THREADS;
+
+checksum table performance_schema.COND_INSTANCES extended;
+checksum table performance_schema.EVENTS_WAITS_CURRENT extended;
+checksum table performance_schema.EVENTS_WAITS_HISTORY extended;
+checksum table performance_schema.EVENTS_WAITS_HISTORY_LONG extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME extended;
+checksum table performance_schema.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME extended;
+checksum table performance_schema.FILE_INSTANCES extended;
+checksum table performance_schema.FILE_SUMMARY_BY_EVENT_NAME extended;
+checksum table performance_schema.FILE_SUMMARY_BY_INSTANCE extended;
+checksum table performance_schema.MUTEX_INSTANCES extended;
+checksum table performance_schema.PERFORMANCE_TIMERS extended;
+checksum table performance_schema.RWLOCK_INSTANCES extended;
+checksum table performance_schema.SETUP_CONSUMERS extended;
+checksum table performance_schema.SETUP_INSTRUMENTS extended;
+checksum table performance_schema.SETUP_TIMERS extended;
+checksum table performance_schema.THREADS extended;
+
+--enable_result_log
+

=== modified file 'mysql-test/suite/perfschema/t/server_init.test'
--- a/mysql-test/suite/perfschema/t/server_init.test	2010-08-20 08:48:59 +0000
+++ b/mysql-test/suite/perfschema/t/server_init.test	2010-09-17 16:43:02 +0000
@@ -43,10 +43,6 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/mysys/THR_LOCK_myisam";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/mysys/THR_LOCK_myisam_log";
-
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/mysys/THR_LOCK_heap";
 
@@ -83,11 +79,6 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_delayed_insert";
 
-# Named LOCK_uuid_short in 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/LOCK_uuid_short";
-
-# Named LOCK_uuid_generator in 5.5, LOCK_uuid_short in 6.0
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_uuid_generator";
 
@@ -127,14 +118,16 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_server_started";
 
-select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/LOG_INFO::lock";
+# LOG_INFO object are created on demand, and are not global.
+# select count(name) from MUTEX_INSTANCES
+#  where name like "wait/synch/mutex/sql/LOG_INFO::lock";
 
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/Query_cache::structure_guard_mutex";
 
-select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state";
+# The event scheduler may be disabled
+# select count(name) from MUTEX_INSTANCES
+#  where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state";
 
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_event_metadata";
@@ -145,16 +138,11 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_user_locks";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/LOCK_mdl";
-
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/Cversion_lock";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/LOCK_audit_mask";
+select count(name) from MUTEX_INSTANCES
+ where name like "wait/synch/mutex/sql/LOCK_audit_mask";
 
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_xid_cache";
@@ -162,28 +150,13 @@ select count(name) from MUTEX_INSTANCES
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/LOCK_plugin";
 
-select count(name) from MUTEX_INSTANCES
- where name like "wait/synch/mutex/sql/LOCK_gdl";
+# Not a global variable, may be destroyed already.
+# select count(name) from MUTEX_INSTANCES
+#  where name like "wait/synch/mutex/sql/LOCK_gdl";
 
 select count(name) from MUTEX_INSTANCES
  where name like "wait/synch/mutex/sql/tz_LOCK";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/slave_start";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML_active";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from MUTEX_INSTANCES
-#  where name like "wait/synch/mutex/sql/BML_class::THR_LOCK_BML_get";
-
 # Verify that these global rwlocks have been properly initilized in sql
 
 select count(name) from RWLOCK_INSTANCES
@@ -224,25 +197,10 @@ select count(name) from COND_INSTANCES
 select count(name) from COND_INSTANCES
  where name like "wait/synch/cond/sql/Query_cache::COND_cache_status_changed";
 
-select count(name) from COND_INSTANCES
- where name like "wait/synch/cond/sql/Event_scheduler::COND_state";
+# The event scheduler may be disabled
+# select count(name) from COND_INSTANCES
+#  where name like "wait/synch/cond/sql/Event_scheduler::COND_state";
 
 select count(name) from COND_INSTANCES
  where name like "wait/synch/cond/sql/COND_queue_state";
 
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from COND_INSTANCES
-#  where name like "wait/synch/cond/sql/COND_mdl";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from COND_INSTANCES
-#  where name like "wait/synch/cond/sql/BML_class::COND_BML";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from COND_INSTANCES
-#  where name like "wait/synch/cond/sql/BML_class::COND_BML_registered";
-
-# Does not exist in mysql 5.5, 6.0 only
-# select count(name) from COND_INSTANCES
-#  where name like "wait/synch/cond/sql/BML_class::COND_BML_release";
-

=== modified file 'mysql-test/suite/rpl/r/rpl_delayed_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_delayed_slave.result	2010-06-21 12:32:29 +0000
+++ b/mysql-test/suite/rpl/r/rpl_delayed_slave.result	2010-09-16 11:00:57 +0000
@@ -7,145 +7,135 @@ start slave;
 call mtr.add_suppression("Unsafe statement written to the binary log using statement format");
 call mtr.add_suppression("Unsafe statement written to the binary log using statement format");
 [on master]
-CREATE TABLE t1 (a VARCHAR(100), b INT AUTO_INCREMENT PRIMARY KEY);
+CREATE TABLE t1 (a VARCHAR(100), b INT);
+INSERT INTO t1 VALUES ("zero", 0);
 ==== Normal setup ====
 [on slave]
 include/stop_slave.inc
 # CHANGE MASTER TO MASTER_DELAY = 2*T
-# Checking that delay is what we set it to
-# Expect status to be ''
-SELECT STATE FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY ID DESC LIMIT 1;
-STATE
-
 include/start_slave.inc
+# Asserted this: SHOW SLAVE STATUS should return the same delay that we set with CHANGE MASTER
 [on master]
-INSERT INTO t1(a) VALUES ('normal setup');
+INSERT INTO t1 VALUES ('normal setup', 1);
 [on slave]
 # sleep 1*T
-# Expect query not executed and status is 'Waiting until MASTER_DELAY...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-Slave_SQL_Running_State='Waiting until MASTER_DELAY seconds after master executed event'; SQL_Remaining_Delay is greater than zero; SQL thread is behind IO thread
+# Asserted this: Query 1 should not be executed
+# Asserted this: Status should be 'Waiting until MASTER_DELAY...'
 # sleep 1*T
 # sync with master (with timeout 1*T)
-# Expect query executed and status is 'Has read all relay log...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-normal setup	1
-Slave_SQL_Running_State='Slave has read all relay log; waiting for the slave I/O thread to update it'; SQL_Remaining_Delay is NULL; SQL thread is in sync with IO thread
+# Asserted this: Query 1 should be executed
+# Asserted this: Status should be 'Has read all relay log...'
 Checking that both slave threads are running.
 ==== Slave lags "naturally" after master ====
 [on master]
 # CREATE FUNCTION delay_on_slave(time_units INT) RETURNS INT BEGIN IF @@server_id = 2 THEN RETURN SLEEP(time_units * T); ELSE RETURN 0; END IF; END
-INSERT INTO t1(a) SELECT delay_on_slave(3);
+INSERT INTO t1 SELECT delay_on_slave(3), 2;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
-INSERT INTO t1(a) VALUES ('slave is already lagging: this statement should execute immediately');
-INSERT INTO t1(a) SELECT delay_on_slave(2);
+INSERT INTO t1 VALUES ('slave is already lagging: this statement should execute immediately', 3);
+INSERT INTO t1 SELECT delay_on_slave(2), 4;
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
 [on slave]
 # sleep 1*T
-# Expect no query executed and status is 'Waiting until MASTER_DELAY...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-normal setup	1
-Slave_SQL_Running_State='Waiting until MASTER_DELAY seconds after master executed event'; SQL_Remaining_Delay is greater than zero; SQL thread is behind IO thread
+# Asserted this: No query executed
+# Asserted this: Status should be 'Waiting until MASTER_DELAY...'
 # wait for first query to execute
 # sleep 1*T
-# Expect second query executed and status is executing third query (i.e., 'User sleep')
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-slave is already lagging: this statement should execute immediately	3
-Slave_SQL_Running_State='User sleep'; SQL_Remaining_Delay is NULL; SQL thread is behind IO thread
+# Asserted this: Second query executed
+# Asserted this: Status should be executing third query (i.e., 'User sleep')
 # sleep 2*T
-# Expect query executed and status is 'Has read all relay log...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-0	4
-Slave_SQL_Running_State='Slave has read all relay log; waiting for the slave I/O thread to update it'; SQL_Remaining_Delay is NULL; SQL thread is in sync with IO thread
+# Asserted this: Third query executed
+# Asserted this: Status should be 'Has read all relay log...'
 ==== Seconds_Behind_Master ====
 # Bring slave to sync.
 include/stop_slave.inc
 CHANGE MASTER TO MASTER_DELAY = 0;
 include/start_slave.inc
-INSERT INTO t1(a) VALUES ('Syncing slave');
+INSERT INTO t1 VALUES ('Syncing slave', 5);
 include/stop_slave.inc
 # CHANGE MASTER TO MASTER_DELAY = 2*T
 include/start_slave.inc
-INSERT INTO t1(a) VALUES (delay_on_slave(1));
+INSERT INTO t1 VALUES (delay_on_slave(1), 6);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave.
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
 # sleep 1*T
+# Asserted this: Seconds_Behind_Master should be between 0 and the 2*T
 # sleep 1*T
-==== STOP SLAVE and START SLAVE ====
+# Asserted this: Seconds_Behind_Master should be at least 2*T
+==== STOP SLAVE / START SLAVE + DML ====
 include/stop_slave.inc
 # CHANGE MASTER TO MASTER_DELAY = 3*T
 include/start_slave.inc
-# Checking that delay is what we set it to
 [on master]
-INSERT INTO t1(a) VALUES ('stop slave and start slave');
+INSERT INTO t1 VALUES ('stop slave and start slave: DML', 7);
 [on slave]
 # sleep 1*T
-SET @before_stop_slave= UNIX_TIMESTAMP();
 include/stop_slave.inc
-# STOP SLAVE finished in time.
-# Expect query not executed and status is ''
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-0	6
-Slave_SQL_Running_State=''; SQL_Remaining_Delay is NULL; SQL thread is behind IO thread
+# Asserted this: STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish
+# Asserted this: SQL thread position should not increase after STOP SLAVE
+# Asserted this: Query should not be executed after STOP SLAVE
+# Asserted this: Status should be '' after STOP SLAVE
 include/start_slave.inc
-# START SLAVE finished in time.
+# Asserted this: START SLAVE should finish quickly
 [on slave]
 # sleep 1*T
-# Expect query not executed and status is 'Waiting until MASTER_DELAY...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-0	6
-Slave_SQL_Running_State='Waiting until MASTER_DELAY seconds after master executed event'; SQL_Remaining_Delay is greater than zero; SQL thread is behind IO thread
+# Asserted this: Query 7 should not be executed
+# Asserted this: Status should be 'Waiting until MASTER_DELAY...'
 # sleep 1*T
 # sync with master (with timeout 1*T)
-# Expect query executed and status is 'Has read all relay log...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-stop slave and start slave	7
-Slave_SQL_Running_State='Slave has read all relay log; waiting for the slave I/O thread to update it'; SQL_Remaining_Delay is NULL; SQL thread is in sync with IO thread
+# Asserted this: Query 7 should be executed
+# Asserted this: Status should be 'Has read all relay log...'
+Checking that both slave threads are running.
+==== STOP SLAVE / START SLAVE + DDL ====
+This verifies BUG#56442
+[on master]
+CREATE TABLE t_check_dml_not_executed_prematurely (a INT);
+[on slave]
+# sleep 1*T
+include/stop_slave.inc
+# Asserted this: STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish
+# Asserted this: SQL thread position should not increase after STOP SLAVE
+# Asserted this: Query should not be executed after STOP SLAVE
+# Asserted this: Status should be '' after STOP SLAVE
+include/start_slave.inc
+# Asserted this: START SLAVE should finish quickly
+# sleep 1*T
+# Asserted this: DDL Query should not be executed after START SLAVE
+# Asserted this: Status should be 'Waiting until MASTER_DELAY...'
+# sleep 1*T
+# sync with master (with timeout 1*T)
+# Asserted this: DDL Query should be executed
+# Asserted this: Status should be 'Has read all relay log...'
 Checking that both slave threads are running.
 ==== Change back to no delay ====
 [on slave]
 include/stop_slave.inc
 CHANGE MASTER TO MASTER_DELAY = 0;
-# Expect delay is 0.
-SQL_Delay='0'
+# Asserted this: Delay should be 0 when we set it to 0
 include/start_slave.inc
 [on master]
-INSERT INTO t1(a) VALUES ('change back to no delay');
+INSERT INTO t1 VALUES ('change back to no delay', 8);
 [on slave]
 # sleep 1*T
-# Expect query executed and status is 'Has read all relay log...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
-a	b
-change back to no delay	8
-Slave_SQL_Running_State='Slave has read all relay log; waiting for the slave I/O thread to update it'; SQL_Remaining_Delay is NULL; SQL thread is in sync with IO thread
+# Asserted this: Query should be executed
+# Asserted this: Status should be 'Slave has read all relay log...'
 ==== Reset delay with RESET SLAVE ====
 include/stop_slave.inc
 CHANGE MASTER TO MASTER_DELAY = 71;
 include/start_slave.inc
-# Expect delay is 71
-SQL_Delay='71'
+# Asserted this: Delay should be 71 when we set it to 71
 include/stop_slave.inc
 RESET SLAVE;
 [on master]
 RESET MASTER;
 [on slave]
 include/start_slave.inc
-# Expect delay is 0
-SQL_Delay='0'
-==== Set a bad value for the delay ====
+# Asserted this: Delay should be 0 after RESET SLAVE
+==== Set an invalid value for the delay ====
 include/stop_slave.inc
 # Expect error for setting negative delay
 CHANGE MASTER TO MASTER_DELAY = -1;
@@ -162,6 +152,6 @@ CHANGE MASTER TO MASTER_DELAY = 0;
 include/start_slave.inc
 ==== Clean up ====
 [on master]
-DROP TABLE t1;
+DROP TABLE t1, t_check_dml_not_executed_prematurely;
 DROP FUNCTION delay_on_slave;
 [on slave]

=== modified file 'mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result	2010-08-30 06:38:09 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result	2010-09-17 11:32:06 +0000
@@ -5,6 +5,7 @@ reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression("Option binlog_cache_size ");
 CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
 CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
 CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
@@ -120,6 +121,34 @@ Got one of the listed errors
 COMMIT;
 source include/diff_master_slave.inc;
 ########################################################################################
+#                       CHECK MAX_BINLOG_CACHE_SIZE and BINLOG_CACHE_SIZE
+########################################################################################
+SET @@GLOBAL.MAX_BINLOG_CACHE_SIZE= 8192;
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	8192
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	4096
+SET @@GLOBAL.BINLOG_CACHE_SIZE= 16384;
+Warnings:
+Warning	1709	Option binlog_cache_size (16384) is greater than max_binlog_cache_size (8192); setting binlog_cache_size equal to max_binlog_cache_size.
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	8192
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	8192
+SET @@GLOBAL.MAX_BINLOG_CACHE_SIZE= 4096;
+Warnings:
+Warning	1709	Option binlog_cache_size (8192) is greater than max_binlog_cache_size (4096); setting binlog_cache_size equal to max_binlog_cache_size.
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	4096
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	4096
+########################################################################################
 #                                        CLEAN
 ########################################################################################
 DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result	2010-08-30 06:38:09 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result	2010-09-17 11:32:06 +0000
@@ -5,6 +5,7 @@ reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression("Option binlog_cache_size ");
 CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
 CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
 CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
@@ -123,6 +124,34 @@ Got one of the listed errors
 COMMIT;
 source include/diff_master_slave.inc;
 ########################################################################################
+#                       CHECK MAX_BINLOG_CACHE_SIZE and BINLOG_CACHE_SIZE
+########################################################################################
+SET @@GLOBAL.MAX_BINLOG_CACHE_SIZE= 8192;
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	8192
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	4096
+SET @@GLOBAL.BINLOG_CACHE_SIZE= 16384;
+Warnings:
+Warning	1709	Option binlog_cache_size (16384) is greater than max_binlog_cache_size (8192); setting binlog_cache_size equal to max_binlog_cache_size.
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	8192
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	8192
+SET @@GLOBAL.MAX_BINLOG_CACHE_SIZE= 4096;
+Warnings:
+Warning	1709	Option binlog_cache_size (8192) is greater than max_binlog_cache_size (4096); setting binlog_cache_size equal to max_binlog_cache_size.
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	4096
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	4096
+########################################################################################
 #                                        CLEAN
 ########################################################################################
 DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result	2010-08-30 06:38:09 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result	2010-09-17 11:32:06 +0000
@@ -5,6 +5,7 @@ reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+call mtr.add_suppression("Option binlog_cache_size ");
 CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
 CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
 CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
@@ -120,6 +121,34 @@ Got one of the listed errors
 COMMIT;
 source include/diff_master_slave.inc;
 ########################################################################################
+#                       CHECK MAX_BINLOG_CACHE_SIZE and BINLOG_CACHE_SIZE
+########################################################################################
+SET @@GLOBAL.MAX_BINLOG_CACHE_SIZE= 8192;
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	8192
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	4096
+SET @@GLOBAL.BINLOG_CACHE_SIZE= 16384;
+Warnings:
+Warning	1709	Option binlog_cache_size (16384) is greater than max_binlog_cache_size (8192); setting binlog_cache_size equal to max_binlog_cache_size.
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	8192
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	8192
+SET @@GLOBAL.MAX_BINLOG_CACHE_SIZE= 4096;
+Warnings:
+Warning	1709	Option binlog_cache_size (8192) is greater than max_binlog_cache_size (4096); setting binlog_cache_size equal to max_binlog_cache_size.
+SHOW VARIABLES LIKE 'MAX_BINLOG_CACHE_SIZE';
+Variable_name	Value
+max_binlog_cache_size	4096
+SHOW VARIABLES LIKE 'BINLOG_CACHE_SIZE';
+Variable_name	Value
+binlog_cache_size	4096
+########################################################################################
 #                                        CLEAN
 ########################################################################################
 DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/t/rpl_delayed_slave.test'
--- a/mysql-test/suite/rpl/t/rpl_delayed_slave.test	2010-09-04 00:24:29 +0000
+++ b/mysql-test/suite/rpl/t/rpl_delayed_slave.test	2010-09-16 11:00:57 +0000
@@ -6,7 +6,7 @@
 #  - Verify that slave has executed the events after but not before the
 #    delay timeout.
 #
-#  - Verify that delay is correct works when slave is already lagging
+#  - Verify that delay is correct when slave is already lagging
 #    due to slow queries.
 #
 #  - Verify that Seconds_Behind_Master is greater than or equal to the
@@ -44,6 +44,7 @@
 # BUG#28760: Simulating a replication lag
 # [duplicate] BUG#22072: configurable delayed replication
 # [duplicate] BUG#21639: Add Replication Delay parameter
+# BUG#56442: Slave executes delayed statements when STOP SLAVE is issued
 #
 # ==== Issues with this Test Case ====
 #
@@ -79,7 +80,8 @@ if (`SELECT '$max_query_execution_time' 
 
 
 --echo [on master]
-CREATE TABLE t1 (a VARCHAR(100), b INT AUTO_INCREMENT PRIMARY KEY);
+CREATE TABLE t1 (a VARCHAR(100), b INT);
+INSERT INTO t1 VALUES ("zero", 0);
 
 
 --echo ==== Normal setup ====
@@ -94,23 +96,17 @@ CREATE TABLE t1 (a VARCHAR(100), b INT A
 eval CHANGE MASTER TO MASTER_DELAY = $time2;
 --enable_query_log
 
---echo # Checking that delay is what we set it to
---let $delay= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1)
-if (`SELECT $delay != $time2`) {
-  --echo Delay is wrong! Expected $time2, got $delay
-  --source include/show_rpl_debug_info.inc
-  --die wrong delay
-}
-
---echo # Expect status to be ''
-SELECT STATE FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY ID DESC LIMIT 1;
-
 --source include/start_slave.inc
 
+--let $assert_text= SHOW SLAVE STATUS should return the same delay that we set with CHANGE MASTER
+--let $assert_cond= [SHOW SLAVE STATUS, SQL_Delay, 1] = $time2
+--source include/rpl_assert.inc
+
 --echo [on master]
 --connection master
-INSERT INTO t1(a) VALUES ('normal setup');
+INSERT INTO t1 VALUES ('normal setup', 1);
 
+--let $query_number= 1
 --source extra/rpl_tests/delayed_slave_wait_on_query.inc
 
 
@@ -124,20 +120,24 @@ INSERT INTO t1(a) VALUES ('normal setup'
 --eval CREATE FUNCTION delay_on_slave(time_units INT) RETURNS INT BEGIN IF @@server_id = 2 THEN RETURN SLEEP(time_units * $time1); ELSE RETURN 0; END IF; END
 --enable_query_log
 
-INSERT INTO t1(a) SELECT delay_on_slave(3);
+INSERT INTO t1 SELECT delay_on_slave(3), 2;
 
 --save_master_pos
-INSERT INTO t1(a) VALUES ('slave is already lagging: this statement should execute immediately');
-INSERT INTO t1(a) SELECT delay_on_slave(2);
+INSERT INTO t1 VALUES ('slave is already lagging: this statement should execute immediately', 3);
+INSERT INTO t1 SELECT delay_on_slave(2), 4;
 
 --echo [on slave]
 --source include/sync_slave_io_with_master.inc
 --echo # sleep 1*T
 --sleep $time1
 
---echo # Expect no query executed and status is 'Waiting until MASTER_DELAY...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
---source include/show_delayed_slave_state.inc
+--let $assert_text= No query executed
+--let $assert_cond= MAX(b) = 1 FROM t1
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be 'Waiting until MASTER_DELAY...'
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Waiting until MASTER_DELAY%"
+--source include/rpl_assert.inc
 
 --echo # wait for first query to execute
 --sync_with_master
@@ -145,27 +145,35 @@ SELECT * FROM t1 ORDER BY b DESC LIMIT 1
 --echo # sleep 1*T
 --sleep $time1
 
---echo # Expect second query executed and status is executing third query (i.e., 'User sleep')
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
---source include/show_delayed_slave_state.inc
+--let $assert_text= Second query executed
+--let $assert_cond= MAX(b) = 3 FROM t1
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be executing third query (i.e., 'User sleep')
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" = "User sleep"
+--source include/rpl_assert.inc
 
 --echo # sleep 2*T
 --sleep $time2
 
---echo # Expect query executed and status is 'Has read all relay log...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
---source include/show_delayed_slave_state.inc
+--let $assert_text= Third query executed
+--let $assert_cond= MAX(b) = 4 FROM t1
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be 'Has read all relay log...'
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Slave has read all relay log%"
+--source include/rpl_assert.inc
 
 
 --echo ==== Seconds_Behind_Master ====
 
 --echo # Bring slave to sync.
 --source include/stop_slave.inc
-eval CHANGE MASTER TO MASTER_DELAY = 0;
+CHANGE MASTER TO MASTER_DELAY = 0;
 --source include/start_slave.inc
 
 --connection master
-INSERT INTO t1(a) VALUES ('Syncing slave');
+INSERT INTO t1 VALUES ('Syncing slave', 5);
 --sync_slave_with_master
 
 --source include/stop_slave.inc
@@ -176,39 +184,28 @@ eval CHANGE MASTER TO MASTER_DELAY = $ti
 --source include/start_slave.inc
 
 --connection master
-INSERT INTO t1(a) VALUES (delay_on_slave(1));
+INSERT INTO t1 VALUES (delay_on_slave(1), 6);
 --save_master_pos
 --connection slave
 
 --echo # sleep 1*T
 --sleep $time1
 
-let $bug_53167_is_fixed= 1;
-if ($bug_53167_is_fixed) {
-  --let $seconds_behind_master= query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1)
-  # The value of Seconds_Behind_Master will be zero
-  # before the first non-FD event is executed.
-  if (`SELECT $seconds_behind_master < 0 OR $seconds_behind_master >= $time2`) {
-    --echo Seconds_Behind_Master was $seconds_behind_master. Expected that 0 =< Seconds_Behind_Master < SQL_Delay = $time2
-    --source include/show_rpl_debug_info.inc
-    --die Seconds_Behind_Master was wrong
-  }
-}
+--let $assert_cond= [SHOW SLAVE STATUS, Seconds_Behind_Master, 1] >= 0 AND <1> < $time2
+--let $assert_text= Seconds_Behind_Master should be between 0 and the 2*T
+--source include/rpl_assert.inc
 
 --echo # sleep 1*T
 --sleep $time1
 
---let $seconds_behind_master= query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1)
-if (`SELECT $seconds_behind_master < $time2`) {
-  --echo Seconds_Behind_Master was $seconds_behind_master. Expected it to be >= SQL_Delay = $time2
-  --source include/show_rpl_debug_info.inc
-  --die Seconds_Behind_Master was < SQL_Delay
-}
+--let $assert_cond= [SHOW SLAVE STATUS, Seconds_Behind_Master, 1] >= $time2
+--let $assert_text= Seconds_Behind_Master should be at least 2*T
+--source include/rpl_assert.inc
 
 --sync_with_master
 
 
---echo ==== STOP SLAVE and START SLAVE ====
+--echo ==== STOP SLAVE / START SLAVE + DML ====
 
 # Set up a longer delay.
 --source include/stop_slave.inc
@@ -220,71 +217,141 @@ eval CHANGE MASTER TO MASTER_DELAY = $ti
 
 --source include/start_slave.inc
 
---echo # Checking that delay is what we set it to
---let $delay= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1)
-if (`SELECT $delay != $time3`) {
-  --echo Delay is wrong! Expected $time2, got $delay
-  --source include/show_rpl_debug_info.inc
-  --die wrong delay
-}
-
 --echo [on master]
 --connection master
-INSERT INTO t1(a) VALUES ('stop slave and start slave');
+INSERT INTO t1 VALUES ('stop slave and start slave: DML', 7);
 
 --echo [on slave]
 --connection slave
 --echo # sleep 1*T
 --sleep $time1
-SET @before_stop_slave= UNIX_TIMESTAMP();
+--let $timestamp_before_stop= `SELECT UNIX_TIMESTAMP()`
+--let $relay_log_pos_before_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
 --source include/stop_slave.inc
-if (`SELECT UNIX_TIMESTAMP() - @before_stop_slave >= $time1`)
-{
-  --source include/show_rpl_debug_info.inc
-  --die STOP SLAVE did not finish in time
-}
---echo # STOP SLAVE finished in time.
 
---echo # Expect query not executed and status is ''
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
---source include/show_delayed_slave_state.inc
+--let $assert_text= STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish
+--let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1
+--source include/rpl_assert.inc
+
+--let $assert_text= SQL thread position should not increase after STOP SLAVE
+--let $assert_cond= [SHOW SLAVE STATUS, Relay_Log_Pos, 1] = $relay_log_pos_before_stop
+--source include/rpl_assert.inc
+
+--let $assert_text= Query should not be executed after STOP SLAVE
+--let $assert_cond= MAX(b) = 6 FROM t1
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be '' after STOP SLAVE
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" = ""
+--source include/rpl_assert.inc
 
 --source include/start_slave.inc
-if (`SELECT UNIX_TIMESTAMP() - @before_stop_slave >= $time1`)
-{
-  --source include/show_rpl_debug_info.inc
-  --die START SLAVE did not finish in time
-}
---echo # START SLAVE finished in time.
 
+--let $assert_text= START SLAVE should finish quickly
+--let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1
+--source include/rpl_assert.inc
+
+--let $query_number= 7
 --source extra/rpl_tests/delayed_slave_wait_on_query.inc
 
 
+--echo ==== STOP SLAVE / START SLAVE + DDL ====
+
+--echo This verifies BUG#56442
+
+--echo [on master]
+--connection master
+CREATE TABLE t_check_dml_not_executed_prematurely (a INT);
+--source include/save_master_pos.inc
+
+--echo [on slave]
+--connection slave
+--echo # sleep 1*T
+--sleep $time1
+
+--let $timestamp_before_stop= `SELECT UNIX_TIMESTAMP()`
+--let $relay_log_pos_before_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+--source include/stop_slave.inc
+
+--let $assert_text= STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish
+--let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1
+--source include/rpl_assert.inc
+
+--let $assert_text= SQL thread position should not increase after STOP SLAVE
+--let $assert_cond= [SHOW SLAVE STATUS, Relay_Log_Pos, 1] = $relay_log_pos_before_stop
+--source include/rpl_assert.inc
+
+--let $assert_text= Query should not be executed after STOP SLAVE
+--let $assert_cond= COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = "t_check_dml_not_executed_prematurely"
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be '' after STOP SLAVE
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" = ""
+--source include/rpl_assert.inc
+
+--source include/start_slave.inc
+
+--let $assert_text= START SLAVE should finish quickly
+--let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1
+--source include/rpl_assert.inc
+
+--echo # sleep 1*T
+--sleep $time1
+
+--let $assert_text= DDL Query should not be executed after START SLAVE
+--let $assert_cond= COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = "t_check_dml_not_executed_prematurely"
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be 'Waiting until MASTER_DELAY...'
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Waiting until MASTER_DELAY%"
+--source include/rpl_assert.inc
+
+--echo # sleep 1*T
+--sleep $time1
+
+--echo # sync with master (with timeout 1*T)
+--source include/sync_with_master.inc
+
+--let $assert_text= DDL Query should be executed
+--let $assert_cond= COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = "t_check_dml_not_executed_prematurely"
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be 'Has read all relay log...'
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Slave has read all relay log%"
+--source include/rpl_assert.inc
+
+--source include/check_slave_is_running.inc
+
+
 --echo ==== Change back to no delay ====
 
 --echo [on slave]
 --connection slave
 --source include/stop_slave.inc
-eval CHANGE MASTER TO MASTER_DELAY = 0;
+CHANGE MASTER TO MASTER_DELAY = 0;
 
---echo # Expect delay is 0.
---let $delay= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1)
---echo SQL_Delay='$delay'
+--let $assert_text= Delay should be 0 when we set it to 0
+--let $assert_cond= [SHOW SLAVE STATUS, SQL_Delay, 1] = 0
+--source include/rpl_assert.inc
 
 --source include/start_slave.inc
 
 --echo [on master]
 --connection master
-INSERT INTO t1(a) VALUES ('change back to no delay');
+INSERT INTO t1 VALUES ('change back to no delay', 8);
 
 --echo [on slave]
 --source include/sync_slave_io_with_master.inc
 --echo # sleep 1*T
 --sleep $time1
 
---echo # Expect query executed and status is 'Has read all relay log...'
-SELECT * FROM t1 ORDER BY b DESC LIMIT 1;
---source include/show_delayed_slave_state.inc
+--let $assert_text= Query should be executed
+--let $assert_cond= MAX(b) = 8 FROM t1
+--source include/rpl_assert.inc
+
+--let $assert_text= Status should be 'Slave has read all relay log...'
+--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" Like "Slave has read all relay log%"
+--source include/rpl_assert.inc
 
 
 --echo ==== Reset delay with RESET SLAVE ====
@@ -293,9 +360,9 @@ SELECT * FROM t1 ORDER BY b DESC LIMIT 1
 CHANGE MASTER TO MASTER_DELAY = 71;
 --source include/start_slave.inc
 
---echo # Expect delay is 71
---let $delay= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1)
---echo SQL_Delay='$delay'
+--let $assert_text= Delay should be 71 when we set it to 71
+--let $assert_cond= [SHOW SLAVE STATUS, SQL_Delay, 1] = 71
+--source include/rpl_assert.inc
 
 --source include/stop_slave.inc
 RESET SLAVE;
@@ -306,12 +373,12 @@ RESET MASTER;
 --connection slave
 --source include/start_slave.inc
 
---echo # Expect delay is 0
---let $delay= query_get_value(SHOW SLAVE STATUS, SQL_Delay, 1)
---echo SQL_Delay='$delay'
+--let $assert_text= Delay should be 0 after RESET SLAVE
+--let $assert_cond= [SHOW SLAVE STATUS, SQL_Delay, 1] = 0
+--source include/rpl_assert.inc
 
 
---echo ==== Set a bad value for the delay ====
+--echo ==== Set an invalid value for the delay ====
 
 --source include/stop_slave.inc
 
@@ -340,7 +407,7 @@ CHANGE MASTER TO MASTER_DELAY = 0;
 
 --echo [on master]
 --connection master
-DROP TABLE t1;
+DROP TABLE t1, t_check_dml_not_executed_prematurely;
 DROP FUNCTION delay_on_slave;
 
 --echo [on slave]

=== modified file 'mysql-test/suite/rpl/t/rpl_mixed_binlog_max_cache_size-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_mixed_binlog_max_cache_size-master.opt	2009-11-03 19:02:56 +0000
+++ b/mysql-test/suite/rpl/t/rpl_mixed_binlog_max_cache_size-master.opt	2010-09-06 16:21:15 +0000
@@ -1 +1 @@
---binlog_cache_size=4096 --max_binlog_cache_size=7680
+--binlog_cache_size=15360 --max_binlog_cache_size=7680 --default-storage-engine=MyISAM

=== modified file 'mysql-test/suite/rpl/t/rpl_row_binlog_max_cache_size-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_binlog_max_cache_size-master.opt	2010-06-17 20:51:35 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_binlog_max_cache_size-master.opt	2010-09-06 16:21:15 +0000
@@ -1 +1 @@
---binlog_cache_size=4096 --max_binlog_cache_size=7680 --default-storage-engine=MyISAM
+--binlog_cache_size=15360 --max_binlog_cache_size=7680 --default-storage-engine=MyISAM

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_binlog_max_cache_size-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_stm_binlog_max_cache_size-master.opt	2009-11-03 19:02:56 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_binlog_max_cache_size-master.opt	2010-09-06 16:21:15 +0000
@@ -1 +1 @@
---binlog_cache_size=4096 --max_binlog_cache_size=7680
+--binlog_cache_size=15360 --max_binlog_cache_size=7680 --default-storage-engine=MyISAM

=== modified file 'mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic.result'
--- a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic.result	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic.result	2010-09-20 12:12:36 +0000
@@ -1,17 +1,22 @@
-SET @start_value = @@global.max_binlog_cache_size;
-SELECT @start_value;
-@start_value
+SET @start_max_binlog_cache_size = @@global.max_binlog_cache_size;
+SELECT @start_max_binlog_cache_size;
+@start_max_binlog_cache_size
 18446744073709547520
+SET @start_binlog_cache_size = @@global.binlog_cache_size;
+SELECT @start_binlog_cache_size;
+@start_binlog_cache_size
+32768
 '#--------------------FN_DYNVARS_072_01------------------------#'
 SET @@global.max_binlog_cache_size = 5000;
 Warnings:
 Warning	1292	Truncated incorrect max_binlog_cache_size value: '5000'
+Warning	1709	Option binlog_cache_size (32768) is greater than max_binlog_cache_size (4096); setting binlog_cache_size equal to max_binlog_cache_size.
 SET @@global.max_binlog_cache_size = DEFAULT;
 SELECT @@global.max_binlog_cache_size;
 @@global.max_binlog_cache_size
 18446744073709547520
 '#---------------------FN_DYNVARS_072_02-------------------------#'
-SET @@global.max_binlog_cache_size = @start_value;
+SET @@global.max_binlog_cache_size = @start_max_binlog_cache_size;
 SELECT @@global.max_binlog_cache_size = 4294967295;
 @@global.max_binlog_cache_size = 4294967295
 0
@@ -146,7 +151,11 @@ SELECT global.max_binlog_cache_size;
 ERROR 42S02: Unknown table 'global' in field list
 SELECT max_binlog_cache_size = @@session.max_binlog_cache_size;
 ERROR 42S22: Unknown column 'max_binlog_cache_size' in 'field list'
-SET @@global.max_binlog_cache_size = @start_value;
+SET @@global.max_binlog_cache_size = @start_max_binlog_cache_size;
 SELECT @@global.max_binlog_cache_size;
 @@global.max_binlog_cache_size
 18446744073709547520
+SET @@global.binlog_cache_size= @start_binlog_cache_size;
+SELECT @@global.binlog_cache_size;
+@@global.binlog_cache_size
+32768

=== modified file 'mysql-test/suite/sys_vars/t/max_binlog_cache_size_basic.test'
--- a/mysql-test/suite/sys_vars/t/max_binlog_cache_size_basic.test	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/t/max_binlog_cache_size_basic.test	2010-09-20 12:12:36 +0000
@@ -35,10 +35,14 @@
 
 ######################################################################## 
 # Saving initial value of max_binlog_cache_size in a temporary variable#
+# We also save binlog_cache_size because its value cannot be greater   #
+# than max_binlog_cache_size. (BUG#55377)                              #
 ######################################################################## 
 
-SET @start_value = @@global.max_binlog_cache_size;
-SELECT @start_value;
+SET @start_max_binlog_cache_size = @@global.max_binlog_cache_size;
+SELECT @start_max_binlog_cache_size;
+SET @start_binlog_cache_size = @@global.binlog_cache_size;
+SELECT @start_binlog_cache_size;
 
 
 --echo '#--------------------FN_DYNVARS_072_01------------------------#'
@@ -56,7 +60,7 @@ SELECT @@global.max_binlog_cache_size;
 #     Verify default value of variable        #
 ############################################### 
 
-SET @@global.max_binlog_cache_size = @start_value;
+SET @@global.max_binlog_cache_size = @start_max_binlog_cache_size;
 SELECT @@global.max_binlog_cache_size = 4294967295;
 
 --echo '#--------------------FN_DYNVARS_072_03------------------------#'
@@ -174,8 +178,10 @@ SELECT max_binlog_cache_size = @@session
 #   Restore initial value    #
 ##############################
 
-SET @@global.max_binlog_cache_size = @start_value;
+SET @@global.max_binlog_cache_size = @start_max_binlog_cache_size;
 SELECT @@global.max_binlog_cache_size;
+SET @@global.binlog_cache_size= @start_binlog_cache_size;
+SELECT @@global.binlog_cache_size;
 
 
 ######################################################################## 

=== modified file 'mysql-test/t/variables.test'
--- a/mysql-test/t/variables.test	2010-07-27 15:01:56 +0000
+++ b/mysql-test/t/variables.test	2010-09-20 12:12:36 +0000
@@ -8,7 +8,6 @@ drop table if exists t1,t2;
 #
 # Bug#19263: variables.test doesn't clean up after itself (I/II -- save)
 #
-set @my_binlog_cache_size         =@@global.binlog_cache_size;
 set @my_connect_timeout           =@@global.connect_timeout;
 set @my_delayed_insert_timeout    =@@global.delayed_insert_timeout;
 set @my_delayed_queue_size        =@@global.delayed_queue_size;
@@ -16,6 +15,7 @@ set @my_flush                     =@@glo
 set @my_flush_time                =@@global.flush_time;
 set @my_key_buffer_size           =@@global.key_buffer_size;
 set @my_max_binlog_cache_size     =@@global.max_binlog_cache_size;
+set @my_binlog_cache_size         =@@global.binlog_cache_size;
 set @my_max_binlog_size           =@@global.max_binlog_size;
 set @my_max_connect_errors        =@@global.max_connect_errors;
 set @my_max_connections           =@@global.max_connections;
@@ -806,7 +806,6 @@ set join_buffer_size=@save_join_buffer_s
 # Bug #19263: variables.test doesn't clean up after itself (II/II --
 # restore)
 #
-set global binlog_cache_size         =@my_binlog_cache_size;
 set global connect_timeout           =@my_connect_timeout;
 set global delayed_insert_timeout    =@my_delayed_insert_timeout;
 set global delayed_queue_size        =@my_delayed_queue_size;
@@ -814,6 +813,7 @@ set global flush                     =@m
 set global flush_time                =@my_flush_time;
 set global key_buffer_size           =@my_key_buffer_size;
 set global max_binlog_cache_size     =@my_max_binlog_cache_size;
+set global binlog_cache_size         =@my_binlog_cache_size;
 set global max_binlog_size           =@my_max_binlog_size;
 set global max_connect_errors        =@my_max_connect_errors;
 set global max_connections           =@my_max_connections;

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp	2010-06-07 09:14:56 +0000
+++ b/mysql-test/valgrind.supp	2010-09-14 21:51:35 +0000
@@ -745,3 +745,28 @@
    Memcheck:Addr1
    fun:buf_buddy_relocate
 }
+
+#
+# See related Bug#56666
+# Race condition between the server main thread and the kill server thread.
+#
+# Because of this race condition, the call to shutdown_performance_schema()
+# was commented in sql/mysqld.cc, causing the reported leaks.
+#
+
+{
+   missing shutdown_performance_schema 1
+   Memcheck:Leak
+   fun:malloc
+   fun:_Z10pfs_mallocmi
+}
+
+{
+   missing shutdown_performance_schema 2
+   Memcheck:Leak
+   fun:malloc
+   fun:my_malloc
+   fun:_lf_alloc_new
+   fun:lf_hash_insert
+}
+

=== modified file 'packaging/WiX/mysql_server.wxs.in'
--- a/packaging/WiX/mysql_server.wxs.in	2010-07-24 16:18:39 +0000
+++ b/packaging/WiX/mysql_server.wxs.in	2010-09-21 09:13:38 +0000
@@ -21,7 +21,9 @@
     <Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
 
     <!-- Upgrade -->
+    
     <Upgrade Id="49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3">
+      <?if '@PATCH@' != '0'?>
       <UpgradeVersion 
         Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0"
         IncludeMinimum="yes"
@@ -29,6 +31,7 @@
         Property="OLDERVERSIONBEINGUPGRADED"
         MigrateFeatures="yes"
         />
+      <?endif?>
       <UpgradeVersion 
         Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@"
         OnlyDetect="yes"

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2010-09-04 00:24:29 +0000
+++ b/sql/binlog.cc	2010-09-17 13:22:22 +0000
@@ -242,6 +242,32 @@ private:
   binlog_cache_mngr(const binlog_cache_mngr& info);
 };
 
+/**
+  Checks if the BINLOG_CACHE_SIZE's value is greater than MAX_BINLOG_CACHE_SIZE.
+  If this happens, the BINLOG_CACHE_SIZE is set to MAX_BINLOG_CACHE_SIZE.
+*/
+void check_binlog_cache_size(THD *thd)
+{
+  if (binlog_cache_size > max_binlog_cache_size)
+  {
+    if (thd)
+    {
+      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                          ER_BINLOG_CACHE_SIZE_GREATER_THAN_MAX,
+                          ER(ER_BINLOG_CACHE_SIZE_GREATER_THAN_MAX),
+                          (ulong) binlog_cache_size,
+                          (ulong) max_binlog_cache_size);
+    }
+    else
+    {
+      sql_print_warning(ER_DEFAULT(ER_BINLOG_CACHE_SIZE_GREATER_THAN_MAX),
+                        (ulong) binlog_cache_size,
+                        (ulong) max_binlog_cache_size);
+    }
+    binlog_cache_size= max_binlog_cache_size;
+  }
+}
+
  /*
   Save position of binary log transaction cache.
 
@@ -3542,11 +3568,8 @@ int MYSQL_BIN_LOG::wait_for_update_bin_l
                                            const struct timespec *timeout)
 {
   int ret= 0;
-  const char* old_msg = thd->proc_info;
   DBUG_ENTER("wait_for_update_bin_log");
-  old_msg= thd->enter_cond(&update_cond, &LOCK_log,
-                           "Master has sent all binlog to slave; "
-                           "waiting for binlog to be updated");
+
   if (!timeout)
     mysql_cond_wait(&update_cond, &LOCK_log);
   else

=== modified file 'sql/binlog.h'
--- a/sql/binlog.h	2010-08-26 14:29:22 +0000
+++ b/sql/binlog.h	2010-09-17 13:22:22 +0000
@@ -228,6 +228,7 @@ public:
   inline char* get_log_fname() { return log_file_name; }
   inline char* get_name() { return name; }
   inline mysql_mutex_t* get_log_lock() { return &LOCK_log; }
+  inline mysql_cond_t* get_log_cond() { return &update_cond; }
   inline IO_CACHE* get_log_file() { return &log_file; }
 
   inline void lock_index() { mysql_mutex_lock(&LOCK_index);}
@@ -260,5 +261,6 @@ int check_binlog_magic(IO_CACHE* log, co
 bool purge_master_logs(THD* thd, const char* to_log);
 bool purge_master_logs_before_date(THD* thd, time_t purge_time);
 bool show_binlog_events(THD *thd, MYSQL_BIN_LOG *binary_log);
+void check_binlog_cache_size(THD *thd);
 
 #endif /* BINLOG_H_INCLUDED */

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-09-08 07:10:51 +0000
+++ b/sql/mysqld.cc	2010-09-17 11:32:06 +0000
@@ -1395,6 +1395,12 @@ static void mysqld_exit(int exit_code)
   mysql_audit_finalize();
   clean_up_mutexes();
   clean_up_error_log_mutex();
+#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
+  /*
+    Bug#56666 needs to be fixed before calling:
+    shutdown_performance_schema();
+  */
+#endif
   my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
   exit(exit_code); /* purecov: inspected */
 }
@@ -2729,6 +2735,11 @@ pthread_handler_t signal_hand(void *arg 
       if (!abort_loop)
       {
 	abort_loop=1;				// mark abort for threads
+#ifdef HAVE_PSI_INTERFACE
+        /* Delete the instrumentation for the signal thread */
+        if (likely(PSI_server != NULL))
+          PSI_server->delete_current_thread();
+#endif
 #ifdef USE_ONE_SIGNAL_HAND
 	pthread_t tmp;
         if (mysql_thread_create(0, /* Not instrumented */
@@ -4663,6 +4674,8 @@ int mysqld_main(int argc, char **argv)
   if (opt_bootstrap) /* If running with bootstrap, do not start replication. */
     opt_skip_slave_start= 1;
 
+  check_binlog_cache_size(NULL);
+
   binlog_unsafe_map_init();
   /*
     init_slave() must be called after the thread keys are created.
@@ -4749,6 +4762,15 @@ int mysqld_main(int argc, char **argv)
 #endif
 #endif /* __WIN__ */
 
+#ifdef HAVE_PSI_INTERFACE
+  /*
+    Disable the main thread instrumentation,
+    to avoid recording events during the shutdown.
+  */
+  if (PSI_server)
+    PSI_server->delete_current_thread();
+#endif
+
   /* Wait until cleanup is done */
   mysql_mutex_lock(&LOCK_thread_count);
   while (!ready_to_exit)
@@ -4766,18 +4788,6 @@ int mysqld_main(int argc, char **argv)
   }
 #endif
   clean_up(1);
-#ifdef HAVE_PSI_INTERFACE
-  /*
-    Disable the instrumentation, to avoid recording events
-    during the shutdown.
-  */
-  if (PSI_server)
-  {
-    PSI_server->delete_current_thread();
-    PSI_server= NULL;
-  }
-  shutdown_performance_schema();
-#endif
   mysqld_exit(0);
 }
 

=== modified file 'sql/rpl_master.cc'
--- a/sql/rpl_master.cc	2010-07-29 11:30:51 +0000
+++ b/sql/rpl_master.cc	2010-09-17 12:31:54 +0000
@@ -511,6 +511,7 @@ void mysql_binlog_send(THD* thd, char* l
   const char *errmsg = "Unknown error";
   NET* net = &thd->net;
   mysql_mutex_t *log_lock;
+  mysql_cond_t *log_cond;
   bool binlog_can_be_corrupted= FALSE;
 #ifndef DBUG_OFF
   int left_events = max_binlog_dump_events;
@@ -654,7 +655,8 @@ impossible position";
     mysql_bin_log, and it's already inited, and it will be destroyed
     only at shutdown).
   */
-  log_lock = mysql_bin_log.get_log_lock();
+  log_lock= mysql_bin_log.get_log_lock();
+  log_cond= mysql_bin_log.get_log_cond();
   if (pos > BIN_LOG_HEADER_SIZE)
   {
     /* reset transmit packet for the event read from binary log
@@ -889,6 +891,7 @@ impossible position";
 #ifndef DBUG_OFF
           ulong hb_info_counter= 0;
 #endif
+          const char* old_msg= thd->proc_info;
           signal_cnt= mysql_bin_log.signal_cnt;
           do 
           {
@@ -897,6 +900,9 @@ impossible position";
               DBUG_ASSERT(heartbeat_ts && heartbeat_period != 0);
               set_timespec_nsec(*heartbeat_ts, heartbeat_period);
             }
+            thd->enter_cond(log_cond, log_lock,
+                            "Master has sent all binlog to slave; "
+                            "waiting for binlog to be updated");
             ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts);
             DBUG_ASSERT(ret == 0 || (heartbeat_period != 0 && coord != NULL));
             if (ret == ETIMEDOUT || ret == ETIME)
@@ -912,12 +918,15 @@ impossible position";
 #endif
               /* reset transmit packet for the heartbeat event */
               if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg))
+              {
+                thd->exit_cond(old_msg);
                 goto err;
+              }
               if (send_heartbeat_event(net, packet, coord))
               {
                 errmsg = "Failed on my_net_write()";
                 my_errno= ER_UNKNOWN_ERROR;
-                mysql_mutex_unlock(log_lock);
+                thd->exit_cond(old_msg);
                 goto err;
               }
             }
@@ -926,7 +935,7 @@ impossible position";
               DBUG_PRINT("wait",("binary log received update or a broadcast signal caught"));
             }
           } while (signal_cnt == mysql_bin_log.signal_cnt && !thd->killed);
-          mysql_mutex_unlock(log_lock);
+          thd->exit_cond(old_msg);
         }
         break;
             

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2010-09-01 02:51:08 +0000
+++ b/sql/rpl_rli.cc	2010-09-17 11:32:06 +0000
@@ -45,9 +45,9 @@ Relay_log_info::Relay_log_info(bool is_s
    inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE),
    until_log_pos(0), retried_trans(0),
    tables_to_lock(0), tables_to_lock_count(0),
-   last_event_start_time(0),
+   rows_query_ev(NULL), last_event_start_time(0),
    sql_delay(0), sql_delay_end(0),
-   m_flags(0), rows_query_ev(NULL)
+   m_flags(0)
 {
   DBUG_ENTER("Relay_log_info::Relay_log_info");
 

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2010-09-04 00:24:29 +0000
+++ b/sql/rpl_slave.cc	2010-09-16 11:00:57 +0000
@@ -2244,6 +2244,26 @@ static int init_slave_thread(THD* thd, S
 }
 
 
+/**
+  Sleep for the given amount of time. If the sleep is interrupted,
+  continue sleeping unless the THD has been killed.
+
+  @param thd The THD object passed as first parameter to
+  (*thread_killed).
+
+  @param sec The number of seconds to sleep.
+
+  @param thread_killed Pointer to function that checks if the thread
+  has been killed or not.
+
+  @param thread_killed_arg Pointer passed as second parameter to
+  (*thread_killed).
+
+  @retval 0 If we slept the given number of seconds and THD was not
+  killed.
+
+  @retval 1 If sleep was interrupted and THD killed.
+*/
 static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed,
                       void* thread_killed_arg)
 {
@@ -2442,17 +2462,21 @@ static int has_temporary_error(THD *thd)
 /**
   If this is a lagging slave (specified with CHANGE MASTER TO MASTER_DELAY = X), delays accordingly. Also unlocks rli->data_lock.
 
-  Design note: this is the place to unlock rli->data_lock here since
-  it should be held when reading delay info from rli, but it should
-  not be held while sleeping.
+  Design note: this is the place to unlock rli->data_lock. The lock
+  must be held when reading delay info from rli, but it should not be
+  held while sleeping.
 
   @param ev Event that is about to be executed.
 
   @param thd The sql thread's THD object.
 
   @param rli The sql thread's Relay_log_info structure.
+
+  @retval 0 If the delay timed out and the event shall be executed.
+
+  @retval nonzero If the delay was interrupted and the event shall be skipped.
 */
-static void sql_delay_event(Log_event *ev, THD *thd, Relay_log_info *rli)
+static int sql_delay_event(Log_event *ev, THD *thd, Relay_log_info *rli)
 {
   long sql_delay= rli->get_sql_delay();
 
@@ -2490,15 +2514,14 @@ static void sql_delay_event(Log_event *e
                           nap_time));
       rli->start_sql_delay(sql_delay_end);
       mysql_mutex_unlock(&rli->data_lock);
-      safe_sleep(thd, nap_time, (CHECK_KILLED_FUNC)sql_slave_killed,
-                 (void*)rli);
-      DBUG_VOID_RETURN;
+      DBUG_RETURN(safe_sleep(thd, nap_time,
+                             (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli));
     }
   }
 
   mysql_mutex_unlock(&rli->data_lock);
 
-  DBUG_VOID_RETURN;
+  DBUG_RETURN(0);
 }
 
 
@@ -2598,7 +2621,8 @@ int apply_event_and_update_pos(Log_event
   if (reason == Log_event::EVENT_SKIP_NOT)
   {
     // Sleeps if needed, and unlocks rli->data_lock.
-    sql_delay_event(ev, thd, rli);
+    if (sql_delay_event(ev, thd, rli))
+      DBUG_RETURN(0);
     exec_res= ev->apply_event(rli);
   }
   else

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2010-09-09 10:58:40 +0000
+++ b/sql/share/errmsg-utf8.txt	2010-09-17 11:32:06 +0000
@@ -6389,3 +6389,6 @@ ER_ROW_DOES_NOT_MATCH_PARTITION
   swe "Hittade rad som inte passar i partitionen"
 ER_WARN_INDEX_NOT_APPLICABLE
   eng "Cannot use %-.64s access on index '%-.64s' due to type or collation conversion on field '%-.64s'"
+
+ER_BINLOG_CACHE_SIZE_GREATER_THAN_MAX
+  eng "Option binlog_cache_size (%lu) is greater than max_binlog_cache_size (%lu); setting binlog_cache_size equal to max_binlog_cache_size."

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2010-09-01 02:51:08 +0000
+++ b/sql/sql_binlog.cc	2010-09-21 11:32:50 +0000
@@ -147,7 +147,7 @@ void mysql_client_binlog_statement(THD* 
     Allocation
   */
 
-  int err;
+  int err= 0;
   Relay_log_info *rli;
   rli= thd->rli_fake;
   if (!rli && (rli= thd->rli_fake= new Relay_log_info(FALSE)))
@@ -264,8 +264,6 @@ void mysql_client_binlog_statement(THD* 
       */
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
       err= ev->apply_event(rli);
-#else
-      err= 0;
 #endif
       /*
         Format_description_log_event should not be deleted because it

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2010-08-23 17:43:34 +0000
+++ b/sql/sql_plugin.cc	2010-09-21 21:27:43 +0000
@@ -519,7 +519,7 @@ static st_plugin_dl *plugin_dl_add(const
       /* no op */;
 
     cur= (struct st_mysql_plugin*)
-          my_malloc(i*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
+      my_malloc((i+1)*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
     if (!cur)
     {
       free_plugin_mem(&plugin_dl);

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-09-20 14:06:02 +0000
+++ b/sql/sql_select.cc	2010-09-22 11:37:38 +0000
@@ -1276,12 +1276,13 @@ bool might_do_join_buffering(uint join_c
   /* 
      (1) sj_tab is not a const table
   */
-  return (sj_tab-sj_tab->join->join_tab != sj_tab->join->const_tables && // (1)
+  int sj_tabno= sj_tab - sj_tab->join->join_tab;
+  return (sj_tabno >= (int)sj_tab->join->const_tables && // (1)
           sj_tab->use_quick != QS_DYNAMIC_RANGE && 
-          ((join_cache_level != 0U && sj_tab->type == JT_ALL) ||
-           (join_cache_level > 4U && 
+          ((join_cache_level != 0 && sj_tab->type == JT_ALL) ||
+           (join_cache_level > 4 && 
             (sj_tab->type == JT_REF || 
-             sj_tab->type == JT_EQ_REF || 
+             sj_tab->type == JT_EQ_REF ||
              sj_tab->type == JT_CONST))));
 }
 
@@ -4490,6 +4491,14 @@ make_join_statistics(JOIN *join, TABLE_L
   if (!stat || !stat_ref || !table_vector)
     DBUG_RETURN(1);				// Eom /* purecov: inspected */
 
+  if (!(join->positions=
+        new (join->thd->mem_root) POSITION[table_count+1]))
+    DBUG_RETURN(TRUE);
+
+  if (!(join->best_positions=
+        new (join->thd->mem_root) POSITION[table_count+1]))
+    DBUG_RETURN(TRUE);
+
   join->best_ref=stat_vector;
 
   stat_end=stat+table_count;

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2010-09-06 17:56:05 +0000
+++ b/sql/sql_select.h	2010-09-22 11:37:38 +0000
@@ -1369,7 +1369,7 @@ enum_nested_loop_state sub_select_sjm(JO
      advance_sj_state() for details.
 */
 
-typedef struct st_position
+typedef struct st_position : public Sql_alloc
 {
   /*
     The "fanout" -  number of output rows that will be produced (after
@@ -1613,7 +1613,7 @@ public:
   */
   ha_rows  fetch_limit;
   /* Finally picked QEP. This is result of join optimization */
-  POSITION best_positions[MAX_TABLES+1];
+  POSITION *best_positions;
 
 /******* Join optimization state members start *******/
   /*
@@ -1623,7 +1623,7 @@ public:
   TABLE_LIST *emb_sjm_nest;
   
   /* Current join optimization state */
-  POSITION positions[MAX_TABLES+1];
+  POSITION *positions;
   
   /*
     Bitmap of nested joins embedding the position at the end of the current 

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2010-09-01 13:13:01 +0000
+++ b/sql/sys_vars.cc	2010-09-17 11:32:06 +0000
@@ -235,6 +235,12 @@ static Sys_var_charptr Sys_basedir(
        READ_ONLY GLOBAL_VAR(mysql_home_ptr), CMD_LINE(REQUIRED_ARG, 'b'),
        IN_FS_CHARSET, DEFAULT(0));
 
+static bool fix_binlog_cache_size(sys_var *self, THD *thd, enum_var_type type)
+{
+  check_binlog_cache_size(thd);
+  return false;
+}
+
 static Sys_var_ulong Sys_binlog_cache_size(
        "binlog_cache_size", "The size of the cache to "
        "hold the SQL statements for the binary log during a "
@@ -242,7 +248,9 @@ static Sys_var_ulong Sys_binlog_cache_si
        "transactions you can increase this to get more performance",
        GLOBAL_VAR(binlog_cache_size),
        CMD_LINE(REQUIRED_ARG),
-       VALID_RANGE(IO_SIZE, ULONG_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE));
+       VALID_RANGE(IO_SIZE, ULONG_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE),
+       NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
+       ON_UPDATE(fix_binlog_cache_size));
 
 static bool check_has_super(sys_var *self, THD *thd, set_var *var)
 {
@@ -1055,7 +1063,9 @@ static Sys_var_ulonglong Sys_max_binlog_
        GLOBAL_VAR(max_binlog_cache_size), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(IO_SIZE, ULONGLONG_MAX),
        DEFAULT((ULONGLONG_MAX/IO_SIZE)*IO_SIZE),
-       BLOCK_SIZE(IO_SIZE));
+       BLOCK_SIZE(IO_SIZE),
+       NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
+       ON_UPDATE(fix_binlog_cache_size));
 
 static bool fix_max_binlog_size(sys_var *self, THD *thd, enum_var_type type)
 {

=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc	2010-08-12 15:25:01 +0000
+++ b/storage/perfschema/pfs_engine_table.cc	2010-09-20 20:59:48 +0000
@@ -223,6 +223,8 @@ int PFS_engine_table::read_row(TABLE *ta
                                Field **fields)
 {
   my_bitmap_map *org_bitmap;
+  Field *f;
+  Field **fields_reset;
 
   /*
     Make sure the table structure is as expected before mapping
@@ -240,6 +242,16 @@ int PFS_engine_table::read_row(TABLE *ta
 
   /* We internally write to Fields to support the read interface */
   org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
+
+  /*
+    Some callers of the storage engine interface do not honor the
+    f->is_null() flag, and will attempt to read the data itself.
+    A known offender is mysql_checksum_table().
+    For robustness, reset every field.
+  */
+  for (fields_reset= fields; (f= *fields_reset) ; fields_reset++)
+    f->reset();
+
   int result= read_row_values(table, buf, fields, read_all);
   dbug_tmp_restore_column_map(table->write_set, org_bitmap);
 

=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc	2010-08-12 10:21:22 +0000
+++ b/storage/perfschema/table_events_waits.cc	2010-09-15 20:46:26 +0000
@@ -187,7 +187,7 @@ void table_events_waits_common::clear_ob
 */
 void table_events_waits_common::make_row(bool thread_own_wait,
                                          PFS_thread *pfs_thread,
-                                         PFS_events_waits *wait)
+                                         volatile PFS_events_waits *wait)
 {
   pfs_lock lock;
   PFS_thread *safe_thread;
@@ -260,21 +260,27 @@ void table_events_waits_common::make_row
       m_row.m_object_type= "TEMPORARY TABLE";
       m_row.m_object_type_length= 15;
     }
-    memcpy(m_row.m_object_schema, wait->m_schema_name,
-           wait->m_schema_name_length);
     m_row.m_object_schema_length= wait->m_schema_name_length;
-    memcpy(m_row.m_object_name, wait->m_object_name,
-           wait->m_object_name_length);
+    if (unlikely((m_row.m_object_schema_length == 0) ||
+                 (m_row.m_object_schema_length > sizeof(m_row.m_object_schema))))
+      return;
+    memcpy(m_row.m_object_schema, wait->m_schema_name, m_row.m_object_schema_length);
     m_row.m_object_name_length= wait->m_object_name_length;
+    if (unlikely((m_row.m_object_name_length == 0) ||
+                 (m_row.m_object_name_length > sizeof(m_row.m_object_name))))
+      return;
+    memcpy(m_row.m_object_name, wait->m_object_name, m_row.m_object_name_length);
     safe_class= &global_table_class;
     break;
   case WAIT_CLASS_FILE:
     m_row.m_object_type= "FILE";
     m_row.m_object_type_length= 4;
     m_row.m_object_schema_length= 0;
-    memcpy(m_row.m_object_name, wait->m_object_name,
-           wait->m_object_name_length);
     m_row.m_object_name_length= wait->m_object_name_length;
+    if (unlikely((m_row.m_object_name_length == 0) ||
+                 (m_row.m_object_name_length > sizeof(m_row.m_object_name))))
+      return;
+    memcpy(m_row.m_object_name, wait->m_object_name, m_row.m_object_name_length);
     safe_class= sanitize_file_class((PFS_file_class*) wait->m_class);
     break;
   case NO_WAIT_CLASS:

=== modified file 'storage/perfschema/table_events_waits.h'
--- a/storage/perfschema/table_events_waits.h	2010-07-23 17:08:41 +0000
+++ b/storage/perfschema/table_events_waits.h	2010-09-15 20:46:26 +0000
@@ -139,7 +139,7 @@ protected:
   void clear_object_columns();
 
   void make_row(bool thread_own_wait, PFS_thread *pfs_thread,
-                PFS_events_waits *wait);
+                volatile PFS_events_waits *wait);
 
   /** Current row. */
   row_events_waits m_row;

=== modified file 'strings/my_vsnprintf.c'
--- a/strings/my_vsnprintf.c	2009-12-28 12:54:16 +0000
+++ b/strings/my_vsnprintf.c	2010-09-15 11:33:22 +0000
@@ -255,7 +255,7 @@ static char *process_int_arg(char *to, c
   if ((to_length= (size_t) (end-to)) < 16 || length)
     store_start= buff;
 
-  if (arg_type == 'd')
+  if (arg_type == 'd' || arg_type == 'i')
     store_end= longlong10_to_str(par, store_start, -10);
   else if (arg_type == 'u')
     store_end= longlong10_to_str(par, store_start, 10);
@@ -399,6 +399,7 @@ start:
         args_arr[i].double_arg= va_arg(ap, double);
         break;
       case 'd':
+      case 'i':
       case 'u':
       case 'x':
       case 'X':
@@ -406,7 +407,7 @@ start:
       case 'p':
         if (args_arr[i].have_longlong)
           args_arr[i].longlong_arg= va_arg(ap,longlong);
-        else if (args_arr[i].arg_type == 'd')
+        else if (args_arr[i].arg_type == 'd' || args_arr[i].arg_type == 'i')
           args_arr[i].longlong_arg= va_arg(ap, int);
         else
           args_arr[i].longlong_arg= va_arg(ap, uint);
@@ -458,6 +459,7 @@ start:
         break;
       }
       case 'd':
+      case 'i':
       case 'u':
       case 'x':
       case 'X':
@@ -472,7 +474,7 @@ start:
 
         if (args_arr[print_arr[i].arg_idx].have_longlong)
           larg = args_arr[print_arr[i].arg_idx].longlong_arg;
-        else if (print_arr[i].arg_type == 'd')
+        else if (print_arr[i].arg_type == 'd' || print_arr[i].arg_type == 'i' )
           larg = (int) args_arr[print_arr[i].arg_idx].longlong_arg;
         else
           larg= (uint) args_arr[print_arr[i].arg_idx].longlong_arg;
@@ -615,8 +617,8 @@ size_t my_vsnprintf_ex(CHARSET_INFO *cs,
       to= process_dbl_arg(to, end, width, d, *fmt);
       continue;
     }
-    else if (*fmt == 'd' || *fmt == 'u' || *fmt == 'x' || *fmt == 'X' ||
-             *fmt == 'p' || *fmt == 'o')
+    else if (*fmt == 'd' || *fmt == 'i' || *fmt == 'u' || *fmt == 'x' || 
+             *fmt == 'X' || *fmt == 'p' || *fmt == 'o')
     {
       /* Integer parameter */
       longlong larg;
@@ -625,7 +627,7 @@ size_t my_vsnprintf_ex(CHARSET_INFO *cs,
 
       if (have_longlong)
         larg = va_arg(ap,longlong);
-      else if (*fmt == 'd')
+      else if (*fmt == 'd' || *fmt == 'i')
         larg = va_arg(ap, int);
       else
         larg= va_arg(ap, uint);

=== modified file 'unittest/mysys/my_vsnprintf-t.c'
--- a/unittest/mysys/my_vsnprintf-t.c	2009-12-28 12:54:16 +0000
+++ b/unittest/mysys/my_vsnprintf-t.c	2010-09-15 11:33:22 +0000
@@ -31,7 +31,7 @@ void test1(const char *res, const char *
 
 int main(void)
 {
-  plan(54);
+  plan(58);
 
   test1("Constant string",
         "Constant string");
@@ -44,6 +44,8 @@ int main(void)
         "Format specifier c %c", '!');
   test1("Format specifier d 1",
         "Format specifier d %d", 1);
+  test1("Format specifier i 1",
+        "Format specifier i %i", 1);
   test1("Format specifier u 2",
         "Format specifier u %u", 2);
   test1("Format specifier o 375",
@@ -77,6 +79,9 @@ int main(void)
   test1("Length modifiers work: 1 * -1 * 2 * 3",
         "Length modifiers work: %d * %ld * %lld * %zd", 1, -1L, 2LL, (size_t)3);
 
+  test1("Length modifiers work: 1 * -1 * 2 * 3",
+        "Length modifiers work: %i * %li * %lli * %zd", 1, -1L, 2LL, (size_t)3);
+
   test1("long long X: 123456789abcdef0",
         "long long X: %llx", 0x123456789abcdef0LL);
 
@@ -121,6 +126,10 @@ int main(void)
         "Hello int, %d", 1);
   test1("Hello int, -1",
         "Hello int, %d", -1);
+  test1("Hello int, 1",
+        "Hello int, %i", 1);
+  test1("Hello int, -1",
+        "Hello int, %i", -1);
   test1("Hello string 'I am a string'",
         "Hello string '%s'", "I am a string");
   test1("Hello hack hack hack hack hack hack hack 1",


Attachment: [text/bzr-bundle] bzr/tor.didriksen@oracle.com-20100923083552-ykikhmuzvvatvohy.bundle
Thread
bzr push into mysql-next-mr-opt-team branch (tor.didriksen:3219 to 3220) Tor Didriksen23 Sep