List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:October 29 2010 9:48am
Subject:bzr push into mysql-5.5-runtime branch (jon.hauglid:3174 to 3175)
View as plain text  
 3175 Jon Olav Hauglid	2010-10-29 [merge]
      Merge from mysql-5.5-bugteam to mysql-5.5-runtime
      No conflicts

    added:
      mysql-test/suite/innodb/r/innodb_bug57255.result
      mysql-test/suite/innodb/t/innodb_bug57255.test
    modified:
      client/mysqltest.cc
      include/my_getopt.h
      include/mysql/plugin_auth.h
      mysql-test/extra/binlog_tests/implicit.test
      mysql-test/extra/rpl_tests/create_recursive_construct.inc
      mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test
      mysql-test/extra/rpl_tests/rpl_loaddata.test
      mysql-test/include/check_concurrent_insert.inc
      mysql-test/include/check_no_concurrent_insert.inc
      mysql-test/include/get_relay_log_pos.inc
      mysql-test/include/kill_query.inc
      mysql-test/include/kill_query_and_diff_master_slave.inc
      mysql-test/include/setup_fake_relay_log.inc
      mysql-test/include/show_events.inc
      mysql-test/include/show_rpl_debug_info.inc
      mysql-test/include/wait_for_slave_io_error.inc
      mysql-test/include/wait_for_slave_param.inc
      mysql-test/include/wait_for_slave_sql_error.inc
      mysql-test/include/wait_for_status_var.inc
      mysql-test/lib/mtr_misc.pl
      mysql-test/lib/mtr_process.pl
      mysql-test/mysql-test-run.pl
      mysql-test/r/ps.result
      mysql-test/r/signal.result
      mysql-test/r/sp-error.result
      mysql-test/r/trigger.result
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/binlog/t/disabled.def
      mysql-test/suite/funcs_1/r/innodb_trig_08.result
      mysql-test/suite/funcs_1/r/memory_trig_08.result
      mysql-test/suite/funcs_1/r/myisam_trig_08.result
      mysql-test/suite/perfschema/include/setup_helper.inc
      mysql-test/suite/perfschema/r/dml_threads.result
      mysql-test/suite/perfschema/r/func_file_io.result
      mysql-test/suite/perfschema/r/schema.result
      mysql-test/suite/perfschema/r/selects.result
      mysql-test/suite/perfschema/t/dml_threads.test
      mysql-test/suite/perfschema/t/func_file_io.test
      mysql-test/suite/perfschema/t/selects.test
      mysql-test/suite/perfschema/t/thread_cache.test
      mysql-test/suite/rpl/r/rpl_row_trig003.result
      mysql-test/suite/rpl/t/rpl_killed_ddl.test
      mysql-test/t/disabled.def
      mysql-test/t/mysqltest.test
      mysql-test/t/ps.test
      mysql-test/t/sp-error.test
      mysql-test/t/wait_timeout.test
      mysys/my_getopt.c
      plugin/auth/dialog.c
      plugin/auth/test_plugin.c
      scripts/mysql_system_tables.sql
      sql/field.cc
      sql/field.h
      sql/item_subselect.cc
      sql/rpl_record.cc
      sql/sp_head.cc
      sql/sp_head.h
      sql/sql_acl.cc
      sql/sql_lex.h
      sql/sql_partition.cc
      sql/sql_partition_admin.cc
      sql/sql_prepare.cc
      sql/sql_show.cc
      storage/innobase/CMakeLists.txt
      storage/innobase/buf/buf0buf.c
      storage/innobase/dict/dict0load.c
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/ha_innodb.h
      storage/innobase/ibuf/ibuf0ibuf.c
      storage/innobase/include/buf0buf.h
      storage/innobase/include/buf0buf.ic
      storage/innobase/include/db0err.h
      storage/innobase/include/dict0load.h
      storage/innobase/include/dict0mem.h
      storage/innobase/include/que0que.h
      storage/innobase/include/sync0sync.h
      storage/innobase/include/trx0undo.h
      storage/innobase/os/os0file.c
      storage/innobase/os/os0sync.c
      storage/innobase/row/row0merge.c
      storage/innobase/row/row0mysql.c
      storage/innobase/srv/srv0start.c
      storage/innobase/trx/trx0trx.c
      storage/innobase/trx/trx0undo.c
      storage/innobase/ut/ut0ut.c
      storage/perfschema/table_threads.cc
      storage/perfschema/table_threads.h
      support-files/mysql.spec.sh
 3174 Konstantin Osipov	2010-10-27
      Remove a dead declaration.

    modified:
      sql/sql_base.h
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-10-20 19:02:59 +0000
+++ b/client/mysqltest.cc	2010-10-26 06:31:22 +0000
@@ -5883,7 +5883,7 @@ int read_line(char *buf, int size)
       /* Could be a multibyte character */
       /* This code is based on the code in "sql_load.cc" */
 #ifdef USE_MB
-      int charlen = my_mbcharlen(charset_info, c);
+      int charlen = my_mbcharlen(charset_info, (unsigned char) c);
       /* We give up if multibyte character is started but not */
       /* completed before we pass buf_end */
       if ((charlen > 1) && (p + charlen) <= buf_end)
@@ -5895,16 +5895,16 @@ int read_line(char *buf, int size)
 
 	for (i= 1; i < charlen; i++)
 	{
+	  c= my_getc(cur_file->file);
 	  if (feof(cur_file->file))
 	    goto found_eof;
-	  c= my_getc(cur_file->file);
 	  *p++ = c;
 	}
 	if (! my_ismbchar(charset_info, mb_start, p))
 	{
 	  /* It was not a multiline char, push back the characters */
 	  /* We leave first 'c', i.e. pretend it was a normal char */
-	  while (p > mb_start)
+	  while (p-1 > mb_start)
 	    my_ungetc(*--p);
 	}
       }
@@ -9965,6 +9965,7 @@ void free_pointer_array(POINTER_ARRAY *p
 void replace_dynstr_append_mem(DYNAMIC_STRING *ds,
                                const char *val, int len)
 {
+  char lower[512];
 #ifdef __WIN__
   fix_win_paths(val, len);
 #endif
@@ -9972,7 +9973,6 @@ void replace_dynstr_append_mem(DYNAMIC_S
   if (display_result_lower) 
   {
     /* Convert to lower case, and do this first */
-    char lower[512];
     char *c= lower;
     for (const char *v= val;  *v;  v++)
       *c++= my_tolower(charset_info, *v);

=== modified file 'include/my_getopt.h'
--- a/include/my_getopt.h	2010-06-11 01:30:49 +0000
+++ b/include/my_getopt.h	2010-10-25 12:30:07 +0000
@@ -39,6 +39,13 @@ C_MODE_START
 #define GET_ASK_ADDR	 128
 #define GET_TYPE_MASK	 127
 
+/**
+  Enumeration of the my_option::arg_type attributes.
+  It should be noted that for historical reasons variables with the combination
+  arg_type=NO_ARG, my_option::var_type=GET_BOOL still accepts
+  arguments. This is someone counter intuitive and care should be taken
+  if the code is refactored.
+*/
 enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
 
 struct st_typelib;

=== modified file 'include/mysql/plugin_auth.h'
--- a/include/mysql/plugin_auth.h	2010-09-20 16:38:27 +0000
+++ b/include/mysql/plugin_auth.h	2010-10-27 15:12:17 +0000
@@ -90,8 +90,8 @@ typedef struct st_mysql_server_auth_info
   int  password_used;
 
   /**
-    Set to the name of the connected client if it can be resolved, or to 
-    the address otherwise
+    Set to the name of the connected client host, if it can be resolved, 
+    or to its IP address otherwise.
   */
   const char *host_or_ip;
 
@@ -107,7 +107,7 @@ typedef struct st_mysql_server_auth_info
 */
 struct st_mysql_auth
 {
-  int interface_version;                        /**< version plugin uses */
+  int interface_version;                        /** version plugin uses */
   /**
     A plugin that a client must use for authentication with this server
     plugin. Can be NULL to mean "any plugin".

=== modified file 'mysql-test/extra/binlog_tests/implicit.test'
--- a/mysql-test/extra/binlog_tests/implicit.test	2009-09-23 11:20:48 +0000
+++ b/mysql-test/extra/binlog_tests/implicit.test	2010-10-21 07:37:10 +0000
@@ -6,7 +6,7 @@ INSERT INTO t1 VALUES (1);
 source include/show_binlog_events.inc;
 eval $statement;
 source include/show_binlog_events.inc;
-if (`select '$cleanup' != ''`) {
+if ($cleanup) {
   eval $cleanup;
 }
 
@@ -22,7 +22,7 @@ INSERT INTO t1 VALUES (3);
 source include/show_binlog_events.inc;
 COMMIT;
 source include/show_binlog_events.inc;
-if (`select '$cleanup' != ''`) {
+if ($cleanup) {
   eval $cleanup;
 }
 

=== modified file 'mysql-test/extra/rpl_tests/create_recursive_construct.inc'
--- a/mysql-test/extra/rpl_tests/create_recursive_construct.inc	2010-08-30 06:03:28 +0000
+++ b/mysql-test/extra/rpl_tests/create_recursive_construct.inc	2010-10-21 09:20:53 +0000
@@ -285,10 +285,10 @@ if (`SELECT $CRC_ARG_type = 7`) {
 }
 
 ######## execute! ########
-if (`SELECT '$CRC_RET_stmt_sidef' != ''`) {
+if ($CRC_RET_stmt_sidef) {
   --echo
   --echo Invoking $CRC_RET_desc.
-  if (`SELECT '$CRC_create' != ''`) {
+  if ($CRC_create) {
     --eval $CRC_create
   }
 
@@ -365,7 +365,7 @@ if (`SELECT '$CRC_RET_stmt_sidef' != ''`
 
 # Invoke created object, discarding the return value. This should not
 # give any warning.
-if (`SELECT '$CRC_RET_sel_retval' != ''`) {
+if ($CRC_RET_sel_retval) {
   --echo * Invoke statement so that return value is dicarded: expect no warning.
   --disable_result_log
   --eval $CRC_RET_sel_retval

=== modified file 'mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test'
--- a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test	2010-05-28 02:57:45 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test	2010-10-21 13:24:31 +0000
@@ -34,7 +34,7 @@
 #
 
 connection slave;
-if (`SELECT $debug_sync_action = ''`)
+if (!$debug_sync_action)
 {
     --die Cannot continue. Please set value for debug_sync_action.
 }

=== modified file 'mysql-test/extra/rpl_tests/rpl_loaddata.test'
--- a/mysql-test/extra/rpl_tests/rpl_loaddata.test	2010-08-03 03:49:14 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test	2010-10-26 06:31:22 +0000
@@ -25,7 +25,7 @@ CALL mtr.add_suppression("Unsafe stateme
 # MTR is not case-sensitive.
 let $lower_stmt_head= load data;
 let $UPPER_STMT_HEAD= LOAD DATA;
-if (`SELECT '$lock_option' <> ''`)
+if ($lock_option)
 {
   #if $lock_option is null, an extra blank is added into the statement,
   #this will change the result of rpl_loaddata test case. so $lock_option

=== modified file 'mysql-test/include/check_concurrent_insert.inc'
--- a/mysql-test/include/check_concurrent_insert.inc	2010-06-17 13:31:51 +0000
+++ b/mysql-test/include/check_concurrent_insert.inc	2010-10-21 13:24:31 +0000
@@ -23,7 +23,7 @@
 # Reset DEBUG_SYNC facility for safety.
 set debug_sync= "RESET";
 
-if (`SELECT '$restore_table' <> ''`)
+if ($restore_table)
 {
 --eval create temporary table t_backup select * from $restore_table;
 }
@@ -82,7 +82,7 @@ connection default;
 
 --eval delete from $table where i = 0;
 
-if (`SELECT '$restore_table' <> ''`)
+if ($restore_table)
 {
 --eval truncate table $restore_table;
 --eval insert into $restore_table select * from t_backup;

=== modified file 'mysql-test/include/check_no_concurrent_insert.inc'
--- a/mysql-test/include/check_no_concurrent_insert.inc	2010-08-06 11:29:37 +0000
+++ b/mysql-test/include/check_no_concurrent_insert.inc	2010-10-21 13:24:31 +0000
@@ -23,7 +23,7 @@
 # Reset DEBUG_SYNC facility for safety.
 set debug_sync= "RESET";
 
-if (`SELECT '$restore_table' <> ''`)
+if ($restore_table)
 {
 --eval create temporary table t_backup select * from $restore_table;
 }
@@ -68,7 +68,7 @@ if (!$success)
 
 --eval delete from $table where i = 0;
 
-if (`SELECT '$restore_table' <> ''`)
+if ($restore_table)
 {
 --eval truncate table $restore_table;
 --eval insert into $restore_table select * from t_backup;

=== modified file 'mysql-test/include/get_relay_log_pos.inc'
--- a/mysql-test/include/get_relay_log_pos.inc	2010-05-26 14:34:25 +0000
+++ b/mysql-test/include/get_relay_log_pos.inc	2010-10-21 07:37:10 +0000
@@ -10,12 +10,12 @@
 #   # at this point, get_relay_log_pos.inc sets $relay_log_pos. echo position
 #   # in $relay_log_file: $relay_log_pos. 
 
-if (`SELECT '$relay_log_file' = ''`)
+if (!$relay_log_file)
 {
   --die 'variable $relay_log_file is null'
 }
 
-if (`SELECT '$master_log_pos' = ''`)
+if (!$master_log_pos)
 {
   --die 'variable $master_log_pos is null'
 }

=== modified file 'mysql-test/include/kill_query.inc'
--- a/mysql-test/include/kill_query.inc	2009-12-10 03:44:19 +0000
+++ b/mysql-test/include/kill_query.inc	2010-10-21 13:24:31 +0000
@@ -44,7 +44,7 @@ connection master;
 # kill the query that is waiting
 eval kill query $connection_id;
 
-if (`SELECT '$debug_lock' != ''`)
+if ($debug_lock)
 {
   # release the lock to allow binlog continue
   eval SELECT RELEASE_LOCK($debug_lock);
@@ -57,7 +57,7 @@ reap;
 
 connection master;
 
-if (`SELECT '$debug_lock' != ''`)
+if ($debug_lock)
 {
   # get lock again to make the next query wait
   eval SELECT GET_LOCK($debug_lock, 10);

=== modified file 'mysql-test/include/kill_query_and_diff_master_slave.inc'
--- a/mysql-test/include/kill_query_and_diff_master_slave.inc	2009-03-27 05:19:50 +0000
+++ b/mysql-test/include/kill_query_and_diff_master_slave.inc	2010-10-21 13:24:31 +0000
@@ -25,7 +25,7 @@ source include/kill_query.inc;
 connection master;
 disable_query_log;
 disable_result_log;
-if (`SELECT '$debug_lock' != ''`)
+if ($debug_lock)
 {
   eval SELECT RELEASE_LOCK($debug_lock);
 }
@@ -36,8 +36,8 @@ source include/diff_master_slave.inc;
 
 # Acquire the debug lock again if used
 connection master;
-disable_query_log; disable_result_log; if (`SELECT '$debug_lock' !=
-''`) { eval SELECT GET_LOCK($debug_lock, 10); } enable_result_log;
-enable_query_log;
+disable_query_log; disable_result_log;
+if ($debug_lock) { eval SELECT GET_LOCK($debug_lock, 10); }
+enable_result_log; enable_query_log;
 
 connection $connection_name;

=== modified file 'mysql-test/include/setup_fake_relay_log.inc'
--- a/mysql-test/include/setup_fake_relay_log.inc	2010-09-20 08:08:32 +0000
+++ b/mysql-test/include/setup_fake_relay_log.inc	2010-10-21 13:24:31 +0000
@@ -56,7 +56,7 @@ if (`SELECT "$_sql_running" = "Yes" OR "
 # Read server variables.
 let $MYSQLD_DATADIR= `SELECT @@datadir`;
 let $_fake_filename= query_get_value(SHOW VARIABLES LIKE 'relay_log', Value, 1);
-if (`SELECT '$_fake_filename' = ''`) {
+if (!$_fake_filename) {
   --echo Badly written test case: relay_log variable is empty. Please use the
   --echo server option --relay-log=FILE.
 }

=== modified file 'mysql-test/include/show_events.inc'
--- a/mysql-test/include/show_events.inc	2010-05-26 14:34:25 +0000
+++ b/mysql-test/include/show_events.inc	2010-10-25 12:07:28 +0000
@@ -18,13 +18,15 @@ if ($is_relay_log)
   --let $_statement=show relaylog events
 }
 
-if (`SELECT '$binlog_file' <> ''`)
+if ($binlog_file)
 {
   --let $_statement= $_statement in '$binlog_file'
 }
 
 --let $_statement= $_statement from $binlog_start
 
+# Cannot use if($binlog_limit) since the variable may begin with a 0
+
 if (`SELECT '$binlog_limit' <> ''`)
 {
   --let $_statement= $_statement limit $binlog_limit

=== modified file 'mysql-test/include/show_rpl_debug_info.inc'
--- a/mysql-test/include/show_rpl_debug_info.inc	2010-05-24 13:54:08 +0000
+++ b/mysql-test/include/show_rpl_debug_info.inc	2010-10-21 13:24:31 +0000
@@ -48,13 +48,13 @@ let $binlog_name= query_get_value("SHOW
 eval SHOW BINLOG EVENTS IN '$binlog_name';
 
 let $_master_con= $master_connection;
-if (`SELECT '$_master_con' = ''`)
+if (!$_master_con)
 {
   if (`SELECT '$_con' = 'slave'`)
   {
     let $_master_con= master;
   }
-  if (`SELECT '$_master_con' = ''`)
+  if (!$_master_con)
   {
     --echo Unable to determine master connection. No debug info printed for master.
     --echo Please fix the test case by setting $master_connection before sourcing
@@ -62,7 +62,7 @@ if (`SELECT '$_master_con' = ''`)
   }
 }
 
-if (`SELECT '$_master_con' != ''`)
+if ($_master_con)
 {
 
   let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1);

=== modified file 'mysql-test/include/wait_for_slave_io_error.inc'
--- a/mysql-test/include/wait_for_slave_io_error.inc	2010-05-28 03:21:20 +0000
+++ b/mysql-test/include/wait_for_slave_io_error.inc	2010-10-21 13:24:31 +0000
@@ -31,7 +31,7 @@
 # $master_connection
 #   See wait_for_slave_param.inc for description.
 
-if (`SELECT '$slave_io_errno' = ''`) {
+if (!$slave_io_errno) {
   --die !!!ERROR IN TEST: you must set \$slave_io_errno before sourcing wait_for_slave_io_error.inc
 }
 

=== 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-10-21 13:24:31 +0000
@@ -53,7 +53,7 @@ if (!$_slave_timeout_counter)
 let $slave_tcnt= $_slave_timeout_counter;
 
 let $_slave_param_comparison= $slave_param_comparison;
-if (`SELECT '$_slave_param_comparison' = ''`)
+if (!$_slave_param_comparison)
 {
   let $_slave_param_comparison= =;
 }
@@ -73,7 +73,7 @@ while (`SELECT NOT('$_show_slave_status_
 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 ****
-  if (`SELECT '$slave_error_message' != ''`)
+  if ($slave_error_message)
   {
     --echo Message: $slave_error_message
   }

=== modified file 'mysql-test/include/wait_for_slave_sql_error.inc'
--- a/mysql-test/include/wait_for_slave_sql_error.inc	2010-05-24 13:54:08 +0000
+++ b/mysql-test/include/wait_for_slave_sql_error.inc	2010-10-21 13:24:31 +0000
@@ -24,7 +24,7 @@
 # $master_connection
 #   See wait_for_slave_param.inc for description.
 
-if (`SELECT '$slave_sql_errno' = ''`) {
+if (!$slave_sql_errno) {
   --die !!!ERROR IN TEST: you must set \$slave_sql_errno before sourcing wait_for_slave_sql_error.inc
 }
 

=== modified file 'mysql-test/include/wait_for_status_var.inc'
--- a/mysql-test/include/wait_for_status_var.inc	2010-05-24 13:54:08 +0000
+++ b/mysql-test/include/wait_for_status_var.inc	2010-10-21 13:24:31 +0000
@@ -45,7 +45,7 @@ if (!$_status_timeout_counter)
 }
 
 let $_status_var_comparsion= $status_var_comparsion;
-if (`SELECT '$_status_var_comparsion' = ''`)
+if (!$_status_var_comparsion)
 {
   let $_status_var_comparsion= =;
 }

=== modified file 'mysql-test/lib/mtr_misc.pl'
--- a/mysql-test/lib/mtr_misc.pl	2010-06-07 08:47:04 +0000
+++ b/mysql-test/lib/mtr_misc.pl	2010-10-19 12:08:46 +0000
@@ -33,6 +33,13 @@ sub mtr_exe_maybe_exists(@);
 sub mtr_milli_sleep($);
 sub start_timer($);
 sub has_expired($);
+sub init_timers();
+sub mark_time_used($);
+sub add_total_times($);
+sub print_times_used($$);
+sub print_total_times($);
+
+our $opt_report_times;
 
 ##############################################################################
 #
@@ -205,4 +212,81 @@ sub start_timer ($) { return time + $_[0
 
 sub has_expired ($) { return $_[0] && time gt $_[0]; }
 
+# Below code is for time usage reporting
+
+use Time::HiRes qw(gettimeofday);
+
+my %time_used= (
+  'collect' => 0,
+  'restart' => 0,
+  'check'   => 0,
+  'ch-warn' => 0,
+  'test'    => 0,
+  'init'    => 0,
+);
+
+my %time_text= (
+ 'collect' => "Collecting test cases",
+ 'restart' => "Server stop/start",
+ 'check'   => "Check-testcase",
+ 'ch-warn' => "Check for warnings",
+ 'test'    => "Test execution",
+ 'init'    => "Initialization etc.",
+);
+
+# Counts number of reports from workers
+
+my $time_totals= 0;
+
+my $last_timer_set;
+
+sub init_timers() {
+  $last_timer_set= gettimeofday();
+}
+
+sub mark_time_used($) {
+  my ($name)= @_;
+  return unless $opt_report_times;
+  die "Unknown timer $name" unless exists $time_used{$name};
+
+  my $curr_time= gettimeofday();
+  $time_used{$name}+= int (($curr_time - $last_timer_set) * 1000 + .5);
+  $last_timer_set= $curr_time;
+}
+
+sub add_total_times($) {
+  my ($dummy, $num, @line)= split (" ", $_[0]);
+
+  $time_totals++;
+  foreach my $elem (@line) {
+    my ($name, $spent)= split (":", $elem);
+    $time_used{$name}+= $spent;
+  }
+}
+
+sub print_times_used($$) {
+  my ($server, $num)= @_;
+  return unless $opt_report_times;
+
+  my $output= "SPENT $num";
+  foreach my $name (keys %time_used) {
+    my $spent= $time_used{$name};
+    $output.= " $name:$spent";
+  }
+  print $server $output . "\n";
+}
+
+sub print_total_times($) {
+  # Don't print if we haven't received all worker data
+  return if $time_totals != $_[0];
+
+  foreach my $name (keys %time_used)
+  {
+    my $spent= $time_used{$name}/1000;
+    my $text= $time_text{$name};
+    print ("Spent $spent seconds on $text\n");
+  }
+}
+
+
 1;

=== modified file 'mysql-test/lib/mtr_process.pl'
--- a/mysql-test/lib/mtr_process.pl	2010-06-14 09:31:22 +0000
+++ b/mysql-test/lib/mtr_process.pl	2010-10-12 11:13:23 +0000
@@ -116,18 +116,20 @@ sub sleep_until_file_created ($$$) {
       return 1;
     }
 
+    my $seconds= ($loop * $sleeptime) / 1000;
+
     # Check if it died after the fork() was successful
     if ( defined $proc and ! $proc->wait_one(0) )
     {
-      mtr_warning("Process $proc died");
+      mtr_warning("Process $proc died after mysql-test-run waited $seconds " .
+		  "seconds for $pidfile to be created.");
       return 0;
     }
 
     mtr_debug("Sleep $sleeptime milliseconds waiting for $pidfile");
 
     # Print extra message every 60 seconds
-    my $seconds= ($loop * $sleeptime) / 1000;
-    if ( $seconds > 1 and int($seconds * 10) % 600 == 0 )
+    if ( $seconds > 1 && int($seconds * 10) % 600 == 0 && $seconds < $timeout )
     {
       my $left= $timeout - $seconds;
       mtr_warning("Waited $seconds seconds for $pidfile to be created, " .
@@ -138,6 +140,8 @@ sub sleep_until_file_created ($$$) {
 
   }
 
+  mtr_warning("Timeout after mysql-test-run waited $timeout seconds " .
+	      "for the process $proc to create a pid file.");
   return 0;
 }
 

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2010-10-20 14:56:09 +0000
+++ b/mysql-test/mysql-test-run.pl	2010-10-26 06:31:22 +0000
@@ -201,6 +201,7 @@ sub using_extern { return (keys %opts_ex
 our $opt_fast= 0;
 our $opt_force;
 our $opt_mem= $ENV{'MTR_MEM'};
+our $opt_clean_vardir= $ENV{'MTR_CLEAN_VARDIR'};
 
 our $opt_gcov;
 our $opt_gcov_exe= "gcov";
@@ -241,6 +242,7 @@ my $opt_skip_core;
 our $opt_check_testcases= 1;
 my $opt_mark_progress;
 my $opt_max_connections;
+our $opt_report_times= 0;
 
 my $opt_sleep;
 
@@ -354,8 +356,11 @@ sub main {
     }
   }
 
+  init_timers();
+
   mtr_report("Collecting tests...");
   my $tests= collect_test_cases($opt_reorder, $opt_suites, \@opt_cases, \@opt_skip_test_list);
+  mark_time_used('collect');
 
   if ( $opt_report_features ) {
     # Put "report features" as the first test to run
@@ -424,6 +429,7 @@ sub main {
 	$opt_tmpdir= "$opt_tmpdir/$child_num";
       }
 
+      init_timers();
       run_worker($server_port, $child_num);
       exit(1);
     }
@@ -436,6 +442,8 @@ sub main {
   mtr_print_thick_line();
   mtr_print_header();
 
+  mark_time_used('init');
+
   my $completed= run_test_server($server, $tests, $opt_parallel);
 
   exit(0) if $opt_start_exit;
@@ -481,8 +489,12 @@ sub main {
 		 $opt_gcov_msg, $opt_gcov_err);
   }
 
+  print_total_times($opt_parallel) if $opt_report_times;
+
   mtr_report_stats("Completed", $completed);
 
+  remove_vardir_subs() if $opt_clean_vardir;
+
   exit(0);
 }
 
@@ -613,13 +625,15 @@ sub run_test_server ($$$) {
 	  if ($test_has_failed and $retries <= $opt_retry){
 	    # Test should be run one more time unless it has failed
 	    # too many times already
+	    my $tname= $result->{name};
 	    my $failures= $result->{failures};
 	    if ($opt_retry > 1 and $failures >= $opt_retry_failure){
-	      mtr_report("\nTest has failed $failures times,",
+	      mtr_report("\nTest $tname has failed $failures times,",
 			 "no more retries!\n");
 	    }
 	    else {
-	      mtr_report("\nRetrying test, attempt($retries/$opt_retry)...\n");
+	      mtr_report("\nRetrying test $tname, ".
+			 "attempt($retries/$opt_retry)...\n");
 	      delete($result->{result});
 	      $result->{retries}= $retries+1;
 	      $result->write_test($sock, 'TESTCASE');
@@ -655,6 +669,9 @@ sub run_test_server ($$$) {
 	elsif ($line eq 'START'){
 	  ; # Send first test
 	}
+	elsif ($line =~ /^SPENT/) {
+	  add_total_times($line);
+	}
 	else {
 	  mtr_error("Unknown response: '$line' from client");
 	}
@@ -786,7 +803,9 @@ sub run_worker ($) {
   # Ask server for first test
   print $server "START\n";
 
-  while(my $line= <$server>){
+  mark_time_used('init');
+
+  while (my $line= <$server>){
     chomp($line);
     if ($line eq 'TESTCASE'){
       my $test= My::Test::read_test($server);
@@ -804,16 +823,20 @@ sub run_worker ($) {
       # Send it back, now with results set
       #$test->print_test();
       $test->write_test($server, 'TESTRESULT');
+      mark_time_used('restart');
     }
     elsif ($line eq 'BYE'){
       mtr_report("Server said BYE");
       stop_all_servers($opt_shutdown_timeout);
+      mark_time_used('restart');
       if ($opt_valgrind_mysqld) {
         valgrind_exit_reports();
       }
       if ( $opt_gprof ) {
 	gprof_collect (find_mysqld($basedir), keys %gprof_dirs);
       }
+      mark_time_used('init');
+      print_times_used($server, $thread_num);
       exit(0);
     }
     else {
@@ -954,6 +977,7 @@ sub command_line_setup {
              'tmpdir=s'                 => \$opt_tmpdir,
              'vardir=s'                 => \$opt_vardir,
              'mem'                      => \$opt_mem,
+	     'clean-vardir'             => \$opt_clean_vardir,
              'client-bindir=s'          => \$path_client_bindir,
              'client-libdir=s'          => \$path_client_libdir,
 
@@ -986,6 +1010,7 @@ sub command_line_setup {
 	     'timediff'                 => \&report_option,
 	     'max-connections=i'        => \$opt_max_connections,
 	     'default-myisam!'          => \&collect_option,
+	     'report-times'             => \$opt_report_times,
 
              'help|h'                   => \$opt_usage,
              'list-options'             => \$opt_list_options,
@@ -2256,6 +2281,12 @@ sub environment_setup {
 }
 
 
+sub remove_vardir_subs() {
+  foreach my $sdir ( glob("$opt_vardir/*") ) {
+    mtr_verbose("Removing subdir $sdir");
+    rmtree($sdir);
+  }
+}
 
 #
 # Remove var and any directories in var/ created by previous
@@ -2300,11 +2331,7 @@ sub remove_stale_vardir () {
 	mtr_error("The destination for symlink $opt_vardir does not exist")
 	  if ! -d readlink($opt_vardir);
 
-	foreach my $bin ( glob("$opt_vardir/*") )
-	{
-	  mtr_verbose("Removing bin $bin");
-	  rmtree($bin);
-	}
+	remove_vardir_subs();
       }
     }
     else
@@ -3222,6 +3249,7 @@ sub check_testcase($$)
 
 	if ( keys(%started) == 0){
 	  # All checks completed
+	  mark_time_used('check');
 	  return 0;
 	}
 	# Wait for next process to exit
@@ -3237,7 +3265,8 @@ sub check_testcase($$)
 	    "\nMTR's internal check of the test case '$tname' failed.
 This means that the test case does not preserve the state that existed
 before the test case was executed.  Most likely the test case did not
-do a proper clean-up.
+do a proper clean-up. It could also be caused by the previous test run
+by this thread, if the server wasn't restarted.
 This is the diff of the states of the servers before and after the
 test case was executed:\n";
 	  $tinfo->{check}.= $report;
@@ -3279,6 +3308,11 @@ test case was executed:\n";
     # Kill any check processes still running
     map($_->kill(), values(%started));
 
+    mtr_warning("Check-testcase failed, this could also be caused by the" .
+		" previous test run by this worker thread")
+      if $result > 1 && $mode eq "before";
+    mark_time_used('check');
+
     return $result;
   }
 
@@ -3588,6 +3622,7 @@ sub run_testcase ($) {
       return 1;
     }
   }
+  mark_time_used('restart');
 
   # --------------------------------------------------------------------
   # If --start or --start-dirty given, stop here to let user manually
@@ -3640,6 +3675,8 @@ sub run_testcase ($) {
 
   do_before_run_mysqltest($tinfo);
 
+  mark_time_used('init');
+
   if ( $opt_check_testcases and check_testcase($tinfo, "before") ){
     # Failed to record state of server or server crashed
     report_failure_and_restart($tinfo);
@@ -3686,6 +3723,7 @@ sub run_testcase ($) {
     }
     mtr_verbose("Got $proc");
 
+    mark_time_used('test');
     # ----------------------------------------------------
     # Was it the test program that exited
     # ----------------------------------------------------
@@ -3912,7 +3950,9 @@ sub get_log_from_proc ($$) {
   foreach my $mysqld (mysqlds()) {
     if ($mysqld->{proc} eq $proc) {
       my @srv_lines= extract_server_log($mysqld->value('#log-error'), $name);
-      $srv_log= "\nServer log from this test:\n" . join ("", @srv_lines);
+      $srv_log= "\nServer log from this test:\n" .
+	"----------SERVER LOG START-----------\n". join ("", @srv_lines) .
+	"----------SERVER LOG END-------------\n";
       last;
     }
   }
@@ -4089,6 +4129,7 @@ sub check_warnings ($) {
 
 	if ( keys(%started) == 0){
 	  # All checks completed
+	  mark_time_used('ch-warn');
 	  return $result;
 	}
 	# Wait for next process to exit
@@ -4121,6 +4162,7 @@ sub check_warnings ($) {
     # Kill any check processes still running
     map($_->kill(), values(%started));
 
+    mark_time_used('ch-warn');
     return $result;
   }
 
@@ -5084,6 +5126,8 @@ sub start_mysqltest ($) {
   my $exe= $exe_mysqltest;
   my $args;
 
+  mark_time_used('init');
+
   mtr_init_args(\$args);
 
   mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
@@ -5565,6 +5609,8 @@ Options to control directories to use
                         for tmpfs (/dev/shm)
                         The option can also be set using environment
                         variable MTR_MEM=[DIR]
+  clean-vardir          Clean vardir if tests were successful and if
+                        running in "memory". Otherwise this option is ignored
   client-bindir=PATH    Path to the directory where client binaries are located
   client-libdir=PATH    Path to the directory where client libraries are located
 
@@ -5724,6 +5770,8 @@ Misc options
   default-myisam        Set default storage engine to MyISAM for non-innodb
                         tests. This is needed after switching default storage
                         engine to InnoDB.
+  report-times          Report how much time has been spent on different
+                        phases of test execution.
 HERE
   exit(1);
 

=== modified file 'mysql-test/r/ps.result'
--- a/mysql-test/r/ps.result	2010-08-16 15:16:07 +0000
+++ b/mysql-test/r/ps.result	2010-10-06 10:02:11 +0000
@@ -3005,6 +3005,44 @@ EXECUTE stmt;
 1
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
+#
+# Bug#54494 crash with explain extended and prepared statements
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1),(2);
+PREPARE stmt FROM 'EXPLAIN EXTENDED SELECT 1 FROM t1 RIGHT JOIN t1 t2 ON 1';
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
+Warnings:
+Note	1003	select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
+Warnings:
+Note	1003	select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+#
+# Bug#54488 crash when using explain and prepared statements with subqueries
+#
+CREATE TABLE t1(f1 INT);
+INSERT INTO t1 VALUES (1),(1);
+PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))';
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
+2	SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+3	SUBQUERY	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesort
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
+2	SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+3	SUBQUERY	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesort
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
 
 End of 5.1 tests.
 

=== modified file 'mysql-test/r/signal.result'
--- a/mysql-test/r/signal.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/signal.result	2010-10-26 11:48:08 +0000
@@ -1379,9 +1379,6 @@ MESSAGE_TEXT = msg,
 MYSQL_ERRNO = 1012;
 end $$
 insert into t1 values (1), (2) $$
-Warnings:
-Warning	1012	This trigger SIGNAL a warning, a=1
-Warning	1012	This trigger SIGNAL a warning, a=2
 drop trigger t1_ai $$
 create trigger t1_ai after insert on t1 for each row
 begin
@@ -1416,11 +1413,7 @@ MESSAGE_TEXT = NEW.msg,
 MYSQL_ERRNO = NEW.errno;
 end $$
 insert into t1 set errno=1012, msg='Warning message 1 in trigger' $$
-Warnings:
-Warning	1012	Warning message 1 in trigger
 insert into t1 set errno=1013, msg='Warning message 2 in trigger' $$
-Warnings:
-Warning	1013	Warning message 2 in trigger
 drop table t1 $$
 drop table if exists t1 $$
 drop procedure if exists p1 $$

=== modified file 'mysql-test/r/sp-error.result'
--- a/mysql-test/r/sp-error.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/sp-error.result	2010-10-26 11:48:08 +0000
@@ -1877,9 +1877,6 @@ DROP PROCEDURE p1;
 #
 # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger
 #
-
-# - Case 1
-
 CREATE TABLE t1(a INT, b INT);
 INSERT INTO t1 VALUES (1, 2);
 CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
@@ -1889,40 +1886,13 @@ SET NEW.a = 10;
 SET NEW.a = 99999999999;
 END|
 UPDATE t1 SET b = 20;
-Warnings:
-Warning	1264	Out of range value for column 'a' at row 1
 SHOW WARNINGS;
 Level	Code	Message
-Warning	1264	Out of range value for column 'a' at row 1
 SELECT * FROM t1;
 a	b
 10	20
 DROP TRIGGER t1_bu;
 DROP TABLE t1;
-
-# - Case 2
-
-CREATE TABLE t1(a INT);
-CREATE TABLE t2(b CHAR(1));
-CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
-BEGIN
-INSERT INTO t2 VALUES('ab'); # Produces a warning.
-INSERT INTO t2 VALUES('b');  # Does not produce a warning,
-# previous warning should be cleared.
-END|
-INSERT INTO t1 VALUES(0);
-SHOW WARNINGS;
-Level	Code	Message
-SELECT * FROM t1;
-a
-0
-SELECT * FROM t2;
-b
-a
-b
-DROP TRIGGER t1_bi;
-DROP TABLE t1;
-DROP TABLE t2;
 #
 # Bug#9857: Stored procedures: handler for sqlwarning ignored
 #
@@ -1961,3 +1931,64 @@ Warning	1365	Division by 0
 DROP PROCEDURE p1;
 DROP PROCEDURE p2;
 SET sql_mode = @sql_mode_saved;
+#
+# Bug#55850: Trigger warnings not cleared.
+#
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP PROCEDURE IF EXISTS p1;
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT,
+d SMALLINT, e SMALLINT, f SMALLINT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999);
+CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
+INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999);
+CREATE PROCEDURE p1()
+INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+CALL p1();
+Warnings:
+Warning	1264	Out of range value for column 'x' at row 1
+Warning	1264	Out of range value for column 'y' at row 1
+Warning	1264	Out of range value for column 'z' at row 1
+
+SHOW WARNINGS;
+Level	Code	Message
+Warning	1264	Out of range value for column 'x' at row 1
+Warning	1264	Out of range value for column 'y' at row 1
+Warning	1264	Out of range value for column 'z' at row 1
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;
+# ----------------------------------------------------------------------
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+INSERT INTO t2 VALUES(
+CAST('111111 ' AS SIGNED),
+CAST('222222 ' AS SIGNED),
+NULL);
+END|
+CREATE PROCEDURE p1()
+INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+CALL p1();
+ERROR 23000: Column 'c' cannot be null
+
+SHOW WARNINGS;
+Level	Code	Message
+Warning	1264	Out of range value for column 'x' at row 1
+Warning	1264	Out of range value for column 'y' at row 1
+Warning	1264	Out of range value for column 'z' at row 1
+Warning	1292	Truncated incorrect INTEGER value: '111111 '
+Warning	1264	Out of range value for column 'a' at row 1
+Warning	1292	Truncated incorrect INTEGER value: '222222 '
+Warning	1264	Out of range value for column 'b' at row 1
+Error	1048	Column 'c' cannot be null
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;

=== modified file 'mysql-test/r/trigger.result'
--- a/mysql-test/r/trigger.result	2010-08-25 10:22:34 +0000
+++ b/mysql-test/r/trigger.result	2010-10-26 11:48:08 +0000
@@ -1072,8 +1072,6 @@ SELECT @x;
 NULL
 SET @x=2;
 UPDATE t1 SET i1 = @x;
-Warnings:
-Warning	1365	Division by 0
 SELECT @x;
 @x
 NULL
@@ -1085,9 +1083,6 @@ SELECT @x;
 NULL
 SET @x=4;
 UPDATE t1 SET i1 = @x;
-Warnings:
-Warning	1365	Division by 0
-Warning	1365	Division by 0
 SELECT @x;
 @x
 NULL
@@ -1198,8 +1193,6 @@ Warnings:
 Warning	1365	Division by 0
 create trigger t1_bi before insert on t1 for each row set @a:=1/0|
 insert into t1 values(20, 20)|
-Warnings:
-Warning	1365	Division by 0
 drop trigger t1_bi|
 create trigger t1_bi before insert on t1 for each row
 begin
@@ -1218,8 +1211,6 @@ set @a:=1/0;
 end|
 set @check=0, @t4_bi_called=0, @t4_bu_called=0|
 insert into t1 values(30, 30)|
-Warnings:
-Warning	1365	Division by 0
 select @check, @t4_bi_called, @t4_bu_called|
 @check	@t4_bi_called	@t4_bu_called
 2	1	1
@@ -2090,12 +2081,8 @@ SELECT 1 FROM t1 c WHERE
 END//
 SET @bug51650 = 1;
 INSERT IGNORE INTO t2 VALUES();
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 INSERT IGNORE INTO t1 SET b = '777';
 INSERT IGNORE INTO t2 SET a = '111';
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 SET @bug51650 = 1;
 INSERT IGNORE INTO t2 SET a = '777';
 DROP TRIGGER trg1;
@@ -2177,8 +2164,6 @@ SELECT 'ab' INTO a;
 SELECT 'a' INTO a;
 END|
 INSERT INTO t1 VALUES (1);
-Warnings:
-Warning	1265	Data truncated for column 'a' at row 1
 DROP TRIGGER trg1;
 DROP TABLE t1;
 DROP TRIGGER IF EXISTS trg1;
@@ -2196,20 +2181,12 @@ DECLARE trg2 CHAR;
 SELECT 'ab' INTO trg2;
 END|
 INSERT INTO t1 VALUES (0);
-Warnings:
-Warning	1265	Data truncated for column 'trg1' at row 1
-Warning	1265	Data truncated for column 'trg2' at row 1
 SELECT * FROM t1;
 a
 0
 SHOW WARNINGS;
 Level	Code	Message
 INSERT INTO t1 VALUES (1),(2);
-Warnings:
-Warning	1265	Data truncated for column 'trg1' at row 1
-Warning	1265	Data truncated for column 'trg2' at row 1
-Warning	1265	Data truncated for column 'trg1' at row 1
-Warning	1265	Data truncated for column 'trg2' at row 1
 DROP TRIGGER trg1;
 DROP TRIGGER trg2;
 DROP TABLE t1;

=== modified file 'mysql-test/suite/binlog/t/binlog_unsafe.test'
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-08-30 06:03:28 +0000
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test	2010-10-21 09:20:53 +0000
@@ -321,7 +321,7 @@ while (`SELECT $unsafe_type < 9`) {
             --source extra/rpl_tests/create_recursive_construct.inc
 
             # Drop created object.
-            if (`SELECT '$drop_3' != ''`) {
+            if ($drop_3) {
               --eval $drop_3
             }
             --inc $call_type_3
@@ -330,7 +330,7 @@ while (`SELECT $unsafe_type < 9`) {
         } # if (!is_toplevel_2)
 
         # Drop created object.
-        if (`SELECT '$drop_2' != ''`) {
+        if ($drop_2) {
           --eval $drop_2
         }
         --inc $call_type_2
@@ -338,7 +338,7 @@ while (`SELECT $unsafe_type < 9`) {
     } # if (!is_toplevel_1)
 
     # Drop created object.
-    if (`SELECT '$drop_1' != ''`) {
+    if ($drop_1) {
       --eval $drop_1
     }
     --inc $call_type_1

=== modified file 'mysql-test/suite/binlog/t/disabled.def'
--- a/mysql-test/suite/binlog/t/disabled.def	2010-08-10 11:32:54 +0000
+++ b/mysql-test/suite/binlog/t/disabled.def	2010-10-27 05:34:48 +0000
@@ -9,6 +9,5 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-
-binlog_truncate_innodb	    : BUG#42643 2009-02-06 mats Changes to InnoDB requires to complete fix for BUG#36763
+binlog_truncate_innodb	: BUG#57291 2010-10-20 anitha Originally disabled due to BUG#42643. Product bug fixed, but test changes needed
 binlog_spurious_ddl_errors  : BUG#54195 2010-06-03 alik binlog_spurious_ddl_errors.test fails, thus disabled

=== modified file 'mysql-test/suite/funcs_1/r/innodb_trig_08.result'
--- a/mysql-test/suite/funcs_1/r/innodb_trig_08.result	2010-03-19 08:56:26 +0000
+++ b/mysql-test/suite/funcs_1/r/innodb_trig_08.result	2010-10-27 07:16:52 +0000
@@ -353,8 +353,6 @@ B	Test 3.5.8.5-case	00191	0000000016	C=o
 C	Test 3.5.8.5-case	00200	0000000001	C=one
 Insert into tb3 (f120, f122, f136)
 values ('d', 'Test 3.5.8.5-case', 152);
-Warnings:
-Warning	1265	Data truncated for column 'f120' at row 1
 select f120, f122, f136, f144, @test_var
 from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 f120	f122	f136	f144	@test_var
@@ -364,8 +362,6 @@ B	Test 3.5.8.5-case	00191	0000000016	1*0
 C	Test 3.5.8.5-case	00200	0000000001	1*0000099999
 Insert into tb3 (f120, f122, f136, f144)
 values ('e', 'Test 3.5.8.5-case', 200, 8);
-Warnings:
-Warning	1265	Data truncated for column 'f120' at row 1
 select f120, f122, f136, f144, @test_var
 from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 f120	f122	f136	f144	@test_var

=== modified file 'mysql-test/suite/funcs_1/r/memory_trig_08.result'
--- a/mysql-test/suite/funcs_1/r/memory_trig_08.result	2010-03-19 08:56:26 +0000
+++ b/mysql-test/suite/funcs_1/r/memory_trig_08.result	2010-10-27 07:16:52 +0000
@@ -354,8 +354,6 @@ B	Test 3.5.8.5-case	00191	0000000016	C=o
 C	Test 3.5.8.5-case	00200	0000000001	C=one
 Insert into tb3 (f120, f122, f136)
 values ('d', 'Test 3.5.8.5-case', 152);
-Warnings:
-Warning	1265	Data truncated for column 'f120' at row 1
 select f120, f122, f136, f144, @test_var
 from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 f120	f122	f136	f144	@test_var
@@ -365,8 +363,6 @@ B	Test 3.5.8.5-case	00191	0000000016	1*0
 C	Test 3.5.8.5-case	00200	0000000001	1*0000099999
 Insert into tb3 (f120, f122, f136, f144)
 values ('e', 'Test 3.5.8.5-case', 200, 8);
-Warnings:
-Warning	1265	Data truncated for column 'f120' at row 1
 select f120, f122, f136, f144, @test_var
 from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 f120	f122	f136	f144	@test_var

=== modified file 'mysql-test/suite/funcs_1/r/myisam_trig_08.result'
--- a/mysql-test/suite/funcs_1/r/myisam_trig_08.result	2010-03-19 08:56:26 +0000
+++ b/mysql-test/suite/funcs_1/r/myisam_trig_08.result	2010-10-27 07:16:52 +0000
@@ -354,8 +354,6 @@ B	Test 3.5.8.5-case	00191	0000000016	C=o
 C	Test 3.5.8.5-case	00200	0000000001	C=one
 Insert into tb3 (f120, f122, f136)
 values ('d', 'Test 3.5.8.5-case', 152);
-Warnings:
-Warning	1265	Data truncated for column 'f120' at row 1
 select f120, f122, f136, f144, @test_var
 from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 f120	f122	f136	f144	@test_var
@@ -365,8 +363,6 @@ B	Test 3.5.8.5-case	00191	0000000016	1*0
 C	Test 3.5.8.5-case	00200	0000000001	1*0000099999
 Insert into tb3 (f120, f122, f136, f144)
 values ('e', 'Test 3.5.8.5-case', 200, 8);
-Warnings:
-Warning	1265	Data truncated for column 'f120' at row 1
 select f120, f122, f136, f144, @test_var
 from tb3 where f122 = 'Test 3.5.8.5-case' order by f120,f136;
 f120	f122	f136	f144	@test_var

=== added file 'mysql-test/suite/innodb/r/innodb_bug57255.result'
--- a/mysql-test/suite/innodb/r/innodb_bug57255.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug57255.result	2010-10-06 10:41:26 +0000
@@ -0,0 +1,10 @@
+create table A(id int not null primary key) engine=innodb;
+create table B(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references A(id) on delete cascade) engine=innodb;
+create table C(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references B(id) on delete cascade) engine=innodb;
+insert into A values(1), (2);
+DELETE FROM A where id = 1;
+DELETE FROM C where f1 = 2;
+DELETE FROM A where id = 1;
+DROP TABLE C;
+DROP TABLE B;
+DROP TABLE A;

=== added file 'mysql-test/suite/innodb/t/innodb_bug57255.test'
--- a/mysql-test/suite/innodb/t/innodb_bug57255.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug57255.test	2010-10-06 10:41:26 +0000
@@ -0,0 +1,36 @@
+# Test Bug #57255. Cascade deletes that affect different rows should not
+# result in DB_FOREIGN_EXCEED_MAX_CASCADE error
+
+--source include/have_innodb.inc
+
+create table A(id int not null primary key) engine=innodb;
+
+create table B(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references A(id) on delete cascade) engine=innodb;
+
+create table C(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references B(id) on delete cascade) engine=innodb;
+
+insert into A values(1), (2);
+
+--disable_query_log
+let $i=257;
+while ($i)
+{
+insert into B(f1) values(1);
+dec $i;
+}
+let $i=486;
+while ($i)
+{
+insert into C(f1) values(2);
+dec $i;
+}
+--enable_query_log
+
+# Following Deletes should not report error
+DELETE FROM A where id = 1;
+DELETE FROM C where f1 = 2;
+DELETE FROM A where id = 1;
+
+DROP TABLE C;
+DROP TABLE B;
+DROP TABLE A;

=== modified file 'mysql-test/suite/perfschema/include/setup_helper.inc'
--- a/mysql-test/suite/perfschema/include/setup_helper.inc	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/include/setup_helper.inc	2010-10-07 00:03:27 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 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
@@ -10,8 +10,8 @@
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# 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
 
@@ -26,17 +26,17 @@ update performance_schema.SETUP_CONSUMER
 connect (con1, localhost, root, , );
 
 let $con1_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID in (select connection_id())`;
+  where PROCESSLIST_ID = connection_id()`;
 
 connect (con2, localhost, root, , );
 
 let $con2_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID in (select connection_id())`;
+  where PROCESSLIST_ID = connection_id()`;
 
 connect (con3, localhost, root, , );
 
 let $con3_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID in (select connection_id())`;
+  where PROCESSLIST_ID = connection_id()`;
 
 connection default;
 

=== modified file 'mysql-test/suite/perfschema/r/dml_threads.result'
--- a/mysql-test/suite/perfschema/r/dml_threads.result	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/r/dml_threads.result	2010-10-07 00:03:27 +0000
@@ -1,12 +1,12 @@
 select * from performance_schema.THREADS
 where name like 'Thread/%' limit 1;
-THREAD_ID	ID	NAME
+THREAD_ID	PROCESSLIST_ID	NAME
 #	#	#
 select * from performance_schema.THREADS
 where name='FOO';
-THREAD_ID	ID	NAME
+THREAD_ID	PROCESSLIST_ID	NAME
 insert into performance_schema.THREADS
-set name='FOO', thread_id=1, id=2;
+set name='FOO', thread_id=1, processlist_id=2;
 ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'THREADS'
 update performance_schema.THREADS
 set thread_id=12;

=== modified file 'mysql-test/suite/perfschema/r/func_file_io.result'
--- a/mysql-test/suite/perfschema/r/func_file_io.result	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/r/func_file_io.result	2010-10-07 00:03:27 +0000
@@ -94,24 +94,9 @@ FROM performance_schema.EVENTS_WAITS_SUM
 WHERE COUNT_STAR > 0
 ORDER BY SUM_TIMER_WAIT DESC
 LIMIT 10;
-SELECT i.user, SUM(TIMER_WAIT) SUM_WAIT
-# ((TIME_TO_SEC(TIMEDIFF(NOW(), i.startup_time)) * 1000) / SUM(TIMER_WAIT)) * 100 WAIT_PERCENTAGE
-FROM performance_schema.EVENTS_WAITS_HISTORY_LONG h
-INNER JOIN performance_schema.THREADS p USING (THREAD_ID)
-LEFT JOIN information_schema.PROCESSLIST i USING (ID)
-GROUP BY i.user
-ORDER BY SUM_WAIT DESC
-LIMIT 20;
 SELECT h.EVENT_NAME, SUM(h.TIMER_WAIT) TOTAL_WAIT
 FROM performance_schema.EVENTS_WAITS_HISTORY_LONG h
 INNER JOIN performance_schema.THREADS p USING (THREAD_ID)
-WHERE p.ID = 1
+WHERE p.PROCESSLIST_ID = 1
 GROUP BY h.EVENT_NAME
 HAVING TOTAL_WAIT > 0;
-SELECT i.user, h.operation, SUM(NUMBER_OF_BYTES) bytes
-FROM performance_schema.EVENTS_WAITS_HISTORY_LONG h
-INNER JOIN performance_schema.THREADS p USING (THREAD_ID)
-LEFT JOIN information_schema.PROCESSLIST i USING (ID)
-GROUP BY i.user, h.operation
-HAVING BYTES > 0
-ORDER BY i.user, h.operation;

=== modified file 'mysql-test/suite/perfschema/r/schema.result'
--- a/mysql-test/suite/perfschema/r/schema.result	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/r/schema.result	2010-10-27 07:34:03 +0000
@@ -195,6 +195,6 @@ show create table THREADS;
 Table	Create Table
 THREADS	CREATE TABLE `THREADS` (
   `THREAD_ID` int(11) NOT NULL,
-  `ID` int(11) NOT NULL,
-  `NAME` varchar(64) NOT NULL
+  `PROCESSLIST_ID` int(11) DEFAULT NULL,
+  `NAME` varchar(128) NOT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8

=== modified file 'mysql-test/suite/perfschema/r/selects.result'
--- a/mysql-test/suite/perfschema/r/selects.result	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/r/selects.result	2010-10-07 00:03:27 +0000
@@ -84,22 +84,22 @@ id	c
 13	[EVENT_ID]
 DROP TRIGGER t_ps_trigger;
 DROP PROCEDURE IF EXISTS t_ps_proc;
-CREATE PROCEDURE t_ps_proc(IN tid INT, OUT pid INT)
+CREATE PROCEDURE t_ps_proc(IN conid INT, OUT pid INT)
 BEGIN
-SELECT id FROM performance_schema.THREADS
-WHERE THREAD_ID = tid INTO pid;
+SELECT thread_id FROM performance_schema.THREADS
+WHERE PROCESSLIST_ID = conid INTO pid;
 END;
 |
-CALL t_ps_proc(0, @p_id);
+CALL t_ps_proc(connection_id(), @p_id);
 DROP FUNCTION IF EXISTS t_ps_proc;
-CREATE FUNCTION t_ps_func(tid INT) RETURNS int
+CREATE FUNCTION t_ps_func(conid INT) RETURNS int
 BEGIN
-return (SELECT id FROM performance_schema.THREADS
-WHERE THREAD_ID = tid);
+return (SELECT thread_id FROM performance_schema.THREADS
+WHERE PROCESSLIST_ID = conid);
 END;
 |
-SELECT t_ps_func(0) = @p_id;
-t_ps_func(0) = @p_id
+SELECT t_ps_func(connection_id()) = @p_id;
+t_ps_func(connection_id()) = @p_id
 1
 SELECT * FROM t_event;
 EVENT_ID

=== modified file 'mysql-test/suite/perfschema/t/dml_threads.test'
--- a/mysql-test/suite/perfschema/t/dml_threads.test	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/t/dml_threads.test	2010-10-07 00:03:27 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 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
@@ -10,8 +10,8 @@
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# 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
 
@@ -28,7 +28,7 @@ select * from performance_schema.THREADS
 --replace_result '\'threads' '\'THREADS'
 --error ER_TABLEACCESS_DENIED_ERROR
 insert into performance_schema.THREADS
-  set name='FOO', thread_id=1, id=2;
+  set name='FOO', thread_id=1, processlist_id=2;
 
 --replace_result '\'threads' '\'THREADS'
 --error ER_TABLEACCESS_DENIED_ERROR

=== modified file 'mysql-test/suite/perfschema/t/func_file_io.test'
--- a/mysql-test/suite/perfschema/t/func_file_io.test	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/t/func_file_io.test	2010-10-07 00:03:27 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2009 Sun Microsystems, Inc
+# Copyright (c) 2008, 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
@@ -10,8 +10,8 @@
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
 
 ##
 ## WL#4814, 4.1.4 FILE IO
@@ -154,16 +154,16 @@ LIMIT 10;
 # Total and average wait time for different users
 #
 
---disable_result_log
-SELECT i.user, SUM(TIMER_WAIT) SUM_WAIT
-# ((TIME_TO_SEC(TIMEDIFF(NOW(), i.startup_time)) * 1000) / SUM(TIMER_WAIT)) * 100 WAIT_PERCENTAGE
-FROM performance_schema.EVENTS_WAITS_HISTORY_LONG h
-INNER JOIN performance_schema.THREADS p USING (THREAD_ID)
-LEFT JOIN information_schema.PROCESSLIST i USING (ID)
-GROUP BY i.user
-ORDER BY SUM_WAIT DESC
-LIMIT 20;
---enable_result_log
+## --disable_result_log
+## SELECT i.user, SUM(TIMER_WAIT) SUM_WAIT
+## # ((TIME_TO_SEC(TIMEDIFF(NOW(), i.startup_time)) * 1000) / SUM(TIMER_WAIT)) * 100 WAIT_PERCENTAGE
+## FROM performance_schema.EVENTS_WAITS_HISTORY_LONG h
+## INNER JOIN performance_schema.THREADS p USING (THREAD_ID)
+## LEFT JOIN information_schema.PROCESSLIST i USING (ID)
+## GROUP BY i.user
+## ORDER BY SUM_WAIT DESC
+## LIMIT 20;
+## --enable_result_log
 
 #
 # Total and average wait times for different events for a session
@@ -172,7 +172,7 @@ LIMIT 20;
 SELECT h.EVENT_NAME, SUM(h.TIMER_WAIT) TOTAL_WAIT
 FROM performance_schema.EVENTS_WAITS_HISTORY_LONG h
 INNER JOIN performance_schema.THREADS p USING (THREAD_ID)
-WHERE p.ID = 1
+WHERE p.PROCESSLIST_ID = 1
 GROUP BY h.EVENT_NAME
 HAVING TOTAL_WAIT > 0;
 --enable_result_log
@@ -181,12 +181,12 @@ HAVING TOTAL_WAIT > 0;
 # Which user reads and writes data
 #
 
---disable_result_log
-SELECT i.user, h.operation, SUM(NUMBER_OF_BYTES) bytes
-FROM performance_schema.EVENTS_WAITS_HISTORY_LONG h
-INNER JOIN performance_schema.THREADS p USING (THREAD_ID)
-LEFT JOIN information_schema.PROCESSLIST i USING (ID)
-GROUP BY i.user, h.operation
-HAVING BYTES > 0
-ORDER BY i.user, h.operation;
---enable_result_log
+## --disable_result_log
+## SELECT i.user, h.operation, SUM(NUMBER_OF_BYTES) bytes
+## FROM performance_schema.EVENTS_WAITS_HISTORY_LONG h
+## INNER JOIN performance_schema.THREADS p USING (THREAD_ID)
+## LEFT JOIN information_schema.PROCESSLIST i USING (ID)
+## GROUP BY i.user, h.operation
+## HAVING BYTES > 0
+## ORDER BY i.user, h.operation;
+## --enable_result_log

=== modified file 'mysql-test/suite/perfschema/t/selects.test'
--- a/mysql-test/suite/perfschema/t/selects.test	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/t/selects.test	2010-10-07 00:03:27 +0000
@@ -136,17 +136,17 @@ DROP PROCEDURE IF EXISTS t_ps_proc;
 --enable_warnings
 delimiter |;
 
-CREATE PROCEDURE t_ps_proc(IN tid INT, OUT pid INT)
+CREATE PROCEDURE t_ps_proc(IN conid INT, OUT pid INT)
 BEGIN
-   SELECT id FROM performance_schema.THREADS
-   WHERE THREAD_ID = tid INTO pid;
+   SELECT thread_id FROM performance_schema.THREADS
+   WHERE PROCESSLIST_ID = conid INTO pid;
 END;
 
 |
 
 delimiter ;|
 
-CALL t_ps_proc(0, @p_id);
+CALL t_ps_proc(connection_id(), @p_id);
 
 # FUNCTION
 
@@ -155,17 +155,17 @@ DROP FUNCTION IF EXISTS t_ps_proc;
 --enable_warnings
 delimiter |;
 
-CREATE FUNCTION t_ps_func(tid INT) RETURNS int
+CREATE FUNCTION t_ps_func(conid INT) RETURNS int
 BEGIN
-   return (SELECT id FROM performance_schema.THREADS
-           WHERE THREAD_ID = tid);
+   return (SELECT thread_id FROM performance_schema.THREADS
+           WHERE PROCESSLIST_ID = conid);
 END;
 
 |
 
 delimiter ;|
 
-SELECT t_ps_func(0) = @p_id;
+SELECT t_ps_func(connection_id()) = @p_id;
 
 # We might reach this point too early which means the event scheduler has not
 # execute our "t_ps_event". Therefore we poll till the record was inserted

=== modified file 'mysql-test/suite/perfschema/t/thread_cache.test'
--- a/mysql-test/suite/perfschema/t/thread_cache.test	2010-08-12 14:08:52 +0000
+++ b/mysql-test/suite/perfschema/t/thread_cache.test	2010-10-07 00:03:27 +0000
@@ -31,14 +31,14 @@ connect (con1, localhost, root, , );
 let $con1_ID=`select connection_id()`;
 
 let $con1_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID = connection_id()`;
+  where PROCESSLIST_ID = connection_id()`;
 
 connect (con2, localhost, root, , );
 
 let $con2_ID=`select connection_id()`;
 
 let $con2_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID = connection_id()`;
+  where PROCESSLIST_ID = connection_id()`;
 
 connection default;
 
@@ -59,7 +59,7 @@ connect (con3, localhost, root, , );
 let $con3_ID=`select connection_id()`;
 
 let $con3_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID = connection_id()`;
+  where PROCESSLIST_ID = connection_id()`;
 
 disconnect con3;
 disconnect con1;
@@ -83,14 +83,14 @@ connect (con1, localhost, root, , );
 let $con1_ID=`select connection_id()`;
 
 let $con1_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID = connection_id()`;
+  where PROCESSLIST_ID = connection_id()`;
 
 connect (con2, localhost, root, , );
 
 let $con2_ID=`select connection_id()`;
 
 let $con2_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID = connection_id()`;
+  where PROCESSLIST_ID = connection_id()`;
 
 connection default;
 
@@ -109,7 +109,7 @@ connect (con3, localhost, root, , );
 let $con3_ID=`select connection_id()`;
 
 let $con3_THREAD_ID=`select thread_id from performance_schema.THREADS
-  where ID = connection_id()`;
+  where PROCESSLIST_ID = connection_id()`;
 
 disconnect con3;
 disconnect con1;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_trig003.result'
--- a/mysql-test/suite/rpl/r/rpl_row_trig003.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_trig003.result	2010-10-26 11:48:08 +0000
@@ -69,15 +69,9 @@ INSERT INTO test.t2 VALUES(NULL,0,'Testi
 UPDATE test.t1 SET b1 = 0 WHERE b1 = 1;
 INSERT INTO test.t2 VALUES(NULL,1,'This is an after update test.', 'If this works, total will not be zero on the master or slave',1.4321,5.221,0,YEAR(NOW()),NOW());
 UPDATE test.t2 SET b1 = 0 WHERE b1 = 1;
-Warnings:
-Error	1329	No data - zero rows fetched, selected, or processed
 INSERT INTO test.t1 VALUES(NULL,1,'add some more test data test.', 'and hope for the best', 3.321,5.221,0,YEAR(NOW()),NOW());
 DELETE FROM test.t1 WHERE id = 1;
-Warnings:
-Error	1329	No data - zero rows fetched, selected, or processed
 DELETE FROM test.t2 WHERE id = 1;
-Warnings:
-Error	1329	No data - zero rows fetched, selected, or processed
 DROP TRIGGER test.t1_bi;
 DROP TRIGGER test.t2_ai;
 DROP TRIGGER test.t1_bu;

=== modified file 'mysql-test/suite/rpl/t/rpl_killed_ddl.test'
--- a/mysql-test/suite/rpl/t/rpl_killed_ddl.test	2010-02-06 10:28:06 +0000
+++ b/mysql-test/suite/rpl/t/rpl_killed_ddl.test	2010-10-21 13:24:31 +0000
@@ -119,7 +119,7 @@ echo [on master];
 
 # This will block the execution of a statement at the DBUG_SYNC_POINT
 # with given lock name
-if (`SELECT '$debug_lock' != ''`)
+if ($debug_lock)
 {
   disable_query_log;
   disable_result_log;

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2010-10-22 11:58:09 +0000
+++ b/mysql-test/t/disabled.def	2010-10-29 09:46:18 +0000
@@ -10,8 +10,7 @@
 #
 ##############################################################################
 lowercase_table3         : Bug#54845 2010-06-30 alik main.lowercase_table3 on Mac OSX
-mysqlhotcopy_myisam      : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
-mysqlhotcopy_archive     : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
 query_cache_28249        : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
-sp_sync                  : Bug#48157 2010-02-06 5.5-m3 demands a differnt solution
 ctype_utf8mb4_ndb	: Bug#55799, Bug#51907, disabled by Konstantin 2010-08-06
+main.mysqlhotcopy_myisam : Bug#56817 2010-10-21 anitha mysqlhotcopy* fails
+main.mysqlhotcopy_archive: Bug#56817 2010-10-21 anitha mysqlhotcopy* fails

=== modified file 'mysql-test/t/mysqltest.test'
--- a/mysql-test/t/mysqltest.test	2010-09-28 14:00:11 +0000
+++ b/mysql-test/t/mysqltest.test	2010-10-19 12:13:05 +0000
@@ -331,7 +331,7 @@ eval select $mysql_errno as "after_!errn
 --exec illegal_command
 --cat_file does_not_exist
 --perl
-  exit(1);
+  exit(2);
 EOF
 
 # ----------------------------------------------------------------------------

=== modified file 'mysql-test/t/ps.test'
--- a/mysql-test/t/ps.test	2010-04-29 20:33:06 +0000
+++ b/mysql-test/t/ps.test	2010-10-06 10:02:11 +0000
@@ -3079,7 +3079,27 @@ EXECUTE stmt;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
 
-###########################################################################
+--echo #
+--echo # Bug#54494 crash with explain extended and prepared statements
+--echo #
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1),(2);
+PREPARE stmt FROM 'EXPLAIN EXTENDED SELECT 1 FROM t1 RIGHT JOIN t1 t2 ON 1';
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#54488 crash when using explain and prepared statements with subqueries
+--echo #
+CREATE TABLE t1(f1 INT);
+INSERT INTO t1 VALUES (1),(1);
+PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))';
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
 
 --echo 
 --echo End of 5.1 tests.

=== modified file 'mysql-test/t/sp-error.test'
--- a/mysql-test/t/sp-error.test	2010-07-30 15:28:36 +0000
+++ b/mysql-test/t/sp-error.test	2010-10-26 11:48:08 +0000
@@ -2719,10 +2719,6 @@ DROP PROCEDURE p1;
 --echo # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger
 --echo #
 
---echo
---echo # - Case 1
---echo
-
 CREATE TABLE t1(a INT, b INT);
 INSERT INTO t1 VALUES (1, 2);
 
@@ -2747,36 +2743,6 @@ SELECT * FROM t1;
 DROP TRIGGER t1_bu;
 DROP TABLE t1;
 
---echo
---echo # - Case 2
---echo
-
-CREATE TABLE t1(a INT);
-CREATE TABLE t2(b CHAR(1));
-
-delimiter |;
-
-CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
-BEGIN
-  INSERT INTO t2 VALUES('ab'); # Produces a warning.
-
-  INSERT INTO t2 VALUES('b');  # Does not produce a warning,
-                               # previous warning should be cleared.
-END|
-
-delimiter ;|
-
-INSERT INTO t1 VALUES(0);
-
-SHOW WARNINGS;
-
-SELECT * FROM t1;
-SELECT * FROM t2;
-
-DROP TRIGGER t1_bi;
-DROP TABLE t1;
-DROP TABLE t2;
-
 --echo #
 --echo # Bug#9857: Stored procedures: handler for sqlwarning ignored
 --echo #
@@ -2813,3 +2779,83 @@ SHOW WARNINGS;
 DROP PROCEDURE p1;
 DROP PROCEDURE p2;
 SET sql_mode = @sql_mode_saved;
+
+--echo #
+--echo # Bug#55850: Trigger warnings not cleared.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT,
+                d SMALLINT, e SMALLINT, f SMALLINT);
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+  INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999);
+
+CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
+  INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999);
+
+CREATE PROCEDURE p1()
+  INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+# What happened before the patch was:
+#  - INSERT INTO t1 added 3 warnings about overflow in 'x', 'y' and 'z' columns;
+#  - t1_bi run and added 3 warnings about overflow in 'a', 'b' and 'c' columns;
+#  - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns;
+# => we had 9 warnings.
+#
+# Now what happens is:
+#  - INSERT INTO t1 adds 3 warnings about overflow in 'x', 'y' and 'z' columns;
+#  - t1_bi adds 3 warnings about overflow in 'a', 'b' and 'c' columns;
+#  - The warnings added by triggers are cleared;
+#  - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns;
+#  - The warnings added by triggers are cleared;
+# => we have 3 warnings.
+
+--echo
+CALL p1();
+
+--echo
+SHOW WARNINGS;
+
+--echo
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;
+
+--echo # ----------------------------------------------------------------------
+
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL);
+
+delimiter |;
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+  INSERT INTO t2 VALUES(
+    CAST('111111 ' AS SIGNED),
+    CAST('222222 ' AS SIGNED),
+    NULL);
+END|
+
+delimiter ;|
+
+CREATE PROCEDURE p1()
+  INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+--echo
+--error ER_BAD_NULL_ERROR
+CALL p1();
+
+--echo
+SHOW WARNINGS;
+
+--echo
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;

=== modified file 'mysql-test/t/wait_timeout.test'
--- a/mysql-test/t/wait_timeout.test	2009-03-06 14:56:17 +0000
+++ b/mysql-test/t/wait_timeout.test	2010-10-19 11:54:28 +0000
@@ -53,7 +53,7 @@ while (!`select @aborted_clients`)
   dec $retries;
   if (!$retries)
   {
-    Failed to detect that client has been aborted;
+    die Failed to detect that client has been aborted;
   }
 }
 --enable_query_log
@@ -108,7 +108,7 @@ while (!`select @aborted_clients`)
   dec $retries;
   if (!$retries)
   {
-    Failed to detect that client has been aborted;
+    die Failed to detect that client has been aborted;
   }
 }
 --enable_query_log

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2010-09-28 15:15:58 +0000
+++ b/mysys/my_getopt.c	2010-10-25 12:30:07 +0000
@@ -360,14 +360,6 @@ int handle_options(int *argc, char ***ar
 	  }
 	  return EXIT_OPTION_DISABLED;
 	}
-	if (must_be_var && optp->arg_type == NO_ARG)
-	{
-	  if (my_getopt_print_errors)
-            my_getopt_error_reporter(ERROR_LEVEL, 
-                                     "%s: option '%s' cannot take an argument",
-                                     my_progname, optp->name);
-	  return EXIT_NO_ARGUMENT_ALLOWED;
-	}
         error= 0;
 	value= optp->var_type & GET_ASK_ADDR ?
 	  (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp, &error) :
@@ -377,6 +369,11 @@ int handle_options(int *argc, char ***ar
 
 	if (optp->arg_type == NO_ARG)
 	{
+	  /*
+	    Due to historical reasons GET_BOOL var_types still accepts arguments
+	    despite the NO_ARG arg_type attribute. This can seems a bit unintuitive
+	    and care should be taken when refactoring this code.
+	  */
 	  if (optend && (optp->var_type & GET_TYPE_MASK) != GET_BOOL)
 	  {
 	    if (my_getopt_print_errors)
@@ -391,7 +388,7 @@ int handle_options(int *argc, char ***ar
 	      Set bool to 1 if no argument or if the user has used
 	      --enable-'option-name'.
 	      *optend was set to '0' if one used --disable-option
-	      */
+	    */
 	    (*argc)--;
 	    if (!optend || *optend == '1' ||
 		!my_strcasecmp(&my_charset_latin1, optend, "true"))
@@ -418,10 +415,9 @@ int handle_options(int *argc, char ***ar
 	else if (optp->arg_type == REQUIRED_ARG && !optend)
 	{
 	  /* Check if there are more arguments after this one,
-
-             Note: options loaded from config file that requires value
-             should always be in the form '--option=value'.
-           */
+       Note: options loaded from config file that requires value
+       should always be in the form '--option=value'.
+    */
 	  if (!is_cmdline_arg || !*++pos)
 	  {
 	    if (my_getopt_print_errors)

=== modified file 'plugin/auth/dialog.c'
--- a/plugin/auth/dialog.c	2010-10-08 00:53:00 +0000
+++ b/plugin/auth/dialog.c	2010-10-27 15:12:17 +0000
@@ -52,7 +52,7 @@
 
 /**
   first byte of the question string is the question "type".
-  It can be a "ordinary" or a "password" question.
+  It can be an "ordinary" or a "password" question.
   The last bit set marks a last question in the authentication exchange.
 */
 #define ORDINARY_QUESTION       "\2"
@@ -176,7 +176,7 @@ mysql_declare_plugin_end;
   This plugin performs a dialog with the user, asking questions and
   reading answers. Depending on the client it may be desirable to do it
   using GUI, or console, with or without curses, or read answers
-  from a smardcard, for example.
+  from a smartcard, for example.
 
   To support all this variety, the dialog plugin has a callback function
   "authentication_dialog_ask". If the client has a function of this name
@@ -256,7 +256,7 @@ static int perform_dialog(MYSQL_PLUGIN_V
         in mysql_change_user() the client sends the first packet, so
         the first vio->read_packet() does nothing (pkt == 0).
 
-        We send the "password", assuming the client knows what its doing.
+        We send the "password", assuming the client knows what it's doing.
         (in other words, the dialog plugin should be only set as a default
         authentication plugin on the client if the first question
         asks for a password - which will be sent in clear text, by the way)

=== modified file 'plugin/auth/test_plugin.c'
--- a/plugin/auth/test_plugin.c	2010-10-04 12:54:41 +0000
+++ b/plugin/auth/test_plugin.c	2010-10-27 15:12:17 +0000
@@ -17,22 +17,12 @@
 /**
   @file
 
-  dialog client authentication plugin with examples
+  Test driver for the mysql-test/t/plugin_auth.test
 
-  dialog is a general purpose client authentication plugin, it simply
-  asks the user the question, as provided by the server and reports
-  the answer back to the server. No encryption is involved,
-  the answers are sent in clear text.
-
-  Two examples are provided: two_questions server plugin, that asks
-  the password and an "Are you sure?" question with a reply "yes, of course".
-  It demonstrates the usage of "password" (input is hidden) and "ordinary"
-  (input can be echoed) questions, and how to mark the last question,
-  to avoid an extra roundtrip.
-
-  And three_attempts plugin that gives the user three attempts to enter
-  a correct password. It shows the situation when a number of questions
-  is not known in advance.
+  This is a set of test plugins used to test the external authentication 
+  implementation.
+  See the above test file for more details.
+  This test plugin is based on the dialog plugin example.
 */
 
 #include <my_global.h>
@@ -55,7 +45,7 @@
 /********************* SERVER SIDE ****************************************/
 
 /**
-  dialog test plugin mimicing the ordinary auth mechanism. Used to test the auth plugin API
+  dialog test plugin mimicking the ordinary auth mechanism. Used to test the auth plugin API
 */
 static int auth_test_plugin(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
 {
@@ -150,10 +140,10 @@ static int test_plugin_client(MYSQL_PLUG
         in mysql_change_user() the client sends the first packet, so
         the first vio->read_packet() does nothing (pkt == 0).
 
-        We send the "password", assuming the client knows what its doing.
+        We send the "password", assuming the client knows what it's doing.
         (in other words, the dialog plugin should be only set as a default
         authentication plugin on the client if the first question
-        asks for a password - which will be sent in cleat text, by the way)
+        asks for a password - which will be sent in clear text, by the way)
       */
       reply= mysql->passwd;
     }

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2010-09-20 14:17:32 +0000
+++ b/scripts/mysql_system_tables.sql	2010-10-07 00:03:27 +0000
@@ -467,8 +467,8 @@ DROP PREPARE stmt;
 
 SET @l1="CREATE TABLE performance_schema.THREADS(";
 SET @l2="THREAD_ID INTEGER not null,";
-SET @l3="ID INTEGER not null,";
-SET @l4="NAME VARCHAR(64) not null";
+SET @l3="PROCESSLIST_ID INTEGER,";
+SET @l4="NAME VARCHAR(128) not null";
 SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";
 
 SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2010-10-19 06:45:18 +0000
+++ b/sql/field.cc	2010-10-27 21:12:45 +0000
@@ -7725,12 +7725,6 @@ void Field_blob::sql_type(String &res) c
 uchar *Field_blob::pack(uchar *to, const uchar *from,
                         uint max_length, bool low_byte_first)
 {
-  DBUG_ENTER("Field_blob::pack");
-  DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx;"
-                       " max_length: %u; low_byte_first: %d",
-                       (ulong) to, (ulong) from,
-                       max_length, low_byte_first));
-  DBUG_DUMP("record", from, table->s->reclength);
   uchar *save= ptr;
   ptr= (uchar*) from;
   uint32 length=get_length();			// Length of from string
@@ -7751,8 +7745,7 @@ uchar *Field_blob::pack(uchar *to, const
     memcpy(to+packlength, from,length);
   }
   ptr=save;					// Restore org row pointer
-  DBUG_DUMP("packed", to, packlength + length);
-  DBUG_RETURN(to+packlength+length);
+  return to+packlength+length;
 }
 
 
@@ -8396,6 +8389,50 @@ uint Field_enum::is_equal(Create_field *
 }
 
 
+uchar *Field_enum::pack(uchar *to, const uchar *from,
+                        uint max_length, bool low_byte_first)
+{
+  DBUG_ENTER("Field_enum::pack");
+  DBUG_PRINT("debug", ("packlength: %d", packlength));
+  DBUG_DUMP("from", from, packlength);
+
+  switch (packlength)
+  {
+  case 1:
+    *to = *from;
+    DBUG_RETURN(to + 1);
+  case 2: DBUG_RETURN(pack_int16(to, from, low_byte_first));
+  case 3: DBUG_RETURN(pack_int24(to, from, low_byte_first));
+  case 4: DBUG_RETURN(pack_int32(to, from, low_byte_first));
+  case 8: DBUG_RETURN(pack_int64(to, from, low_byte_first));
+  default:
+    DBUG_ASSERT(0);
+  }
+}
+
+const uchar *Field_enum::unpack(uchar *to, const uchar *from,
+                                uint param_data, bool low_byte_first)
+{
+  DBUG_ENTER("Field_enum::unpack");
+  DBUG_PRINT("debug", ("packlength: %d", packlength));
+  DBUG_DUMP("from", from, packlength);
+
+  switch (packlength)
+  {
+  case 1:
+    *to = *from;
+    DBUG_RETURN(from + 1);
+
+  case 2: DBUG_RETURN(unpack_int16(to, from, low_byte_first));
+  case 3: DBUG_RETURN(unpack_int24(to, from, low_byte_first));
+  case 4: DBUG_RETURN(unpack_int32(to, from, low_byte_first));
+  case 8: DBUG_RETURN(unpack_int64(to, from, low_byte_first));
+  default:
+    DBUG_ASSERT(0);
+  }
+}
+
+
 /**
   @return
   returns 1 if the fields are equally defined

=== modified file 'sql/field.h'
--- a/sql/field.h	2010-07-23 20:17:55 +0000
+++ b/sql/field.h	2010-10-06 17:20:18 +0000
@@ -554,6 +554,48 @@ private:
   { return 0; }
 
 protected:
+  static void handle_int16(uchar *to, const uchar *from,
+                           bool low_byte_first_from, bool low_byte_first_to)
+  {
+    int16 val;
+#ifdef WORDS_BIGENDIAN
+    if (low_byte_first_from)
+      val = sint2korr(from);
+    else
+#endif
+      shortget(val, from);
+
+#ifdef WORDS_BIGENDIAN
+    if (low_byte_first_to)
+      int2store(to, val);
+    else
+#endif
+      shortstore(to, val);
+  }
+
+  static void handle_int24(uchar *to, const uchar *from,
+                           bool low_byte_first_from, bool low_byte_first_to)
+  {
+    int32 val;
+#ifdef WORDS_BIGENDIAN
+    if (low_byte_first_from)
+      val = sint3korr(from);
+    else
+#endif
+      val= (from[0] << 16) + (from[1] << 8) + from[2];
+
+#ifdef WORDS_BIGENDIAN
+    if (low_byte_first_to)
+      int2store(to, val);
+    else
+#endif
+    {
+      to[0]= 0xFF & (val >> 16);
+      to[1]= 0xFF & (val >> 8);
+      to[2]= 0xFF & val;
+    }
+  }
+
   /*
     Helper function to pack()/unpack() int32 values
   */
@@ -598,6 +640,32 @@ protected:
       longlongstore(to, val);
   }
 
+  uchar *pack_int16(uchar *to, const uchar *from, bool low_byte_first_to)
+  {
+    handle_int16(to, from, table->s->db_low_byte_first, low_byte_first_to);
+    return to  + sizeof(int16);
+  }
+
+  const uchar *unpack_int16(uchar* to, const uchar *from,
+                            bool low_byte_first_from)
+  {
+    handle_int16(to, from, low_byte_first_from, table->s->db_low_byte_first);
+    return from + sizeof(int16);
+  }
+
+  uchar *pack_int24(uchar *to, const uchar *from, bool low_byte_first_to)
+  {
+    handle_int24(to, from, table->s->db_low_byte_first, low_byte_first_to);
+    return to + 3;
+  }
+
+  const uchar *unpack_int24(uchar* to, const uchar *from,
+                            bool low_byte_first_from)
+  {
+    handle_int24(to, from, low_byte_first_from, table->s->db_low_byte_first);
+    return from + 3;
+  }
+
   uchar *pack_int32(uchar *to, const uchar *from, bool low_byte_first_to)
   {
     handle_int32(to, from, table->s->db_low_byte_first, low_byte_first_to);
@@ -918,41 +986,13 @@ public:
   virtual uchar *pack(uchar* to, const uchar *from,
                       uint max_length, bool low_byte_first)
   {
-    int16 val;
-#ifdef WORDS_BIGENDIAN
-    if (table->s->db_low_byte_first)
-      val = sint2korr(from);
-    else
-#endif
-      shortget(val, from);
-
-#ifdef WORDS_BIGENDIAN
-    if (low_byte_first)
-      int2store(to, val);
-    else
-#endif
-      shortstore(to, val);
-    return to + sizeof(val);
+    return pack_int16(to, from, low_byte_first);
   }
 
   virtual const uchar *unpack(uchar* to, const uchar *from,
                               uint param_data, bool low_byte_first)
   {
-    int16 val;
-#ifdef WORDS_BIGENDIAN
-    if (low_byte_first)
-      val = sint2korr(from);
-    else
-#endif
-      shortget(val, from);
-
-#ifdef WORDS_BIGENDIAN
-    if (table->s->db_low_byte_first)
-      int2store(to, val);
-    else
-#endif
-      shortstore(to, val);
-    return from + sizeof(val);
+    return unpack_int16(to, from, low_byte_first);
   }
 };
 
@@ -1895,6 +1935,12 @@ public:
   bool has_charset(void) const { return TRUE; }
   /* enum and set are sorted as integers */
   CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
+
+  virtual uchar *pack(uchar *to, const uchar *from,
+                      uint max_length, bool low_byte_first);
+  virtual const uchar *unpack(uchar *to, const uchar *from,
+                              uint param_data, bool low_byte_first);
+
 private:
   int do_save_field_metadata(uchar *first_byte);
   uint is_equal(Create_field *new_field);

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2010-09-09 15:00:33 +0000
+++ b/sql/item_subselect.cc	2010-10-06 10:02:11 +0000
@@ -1911,18 +1911,22 @@ int subselect_single_select_engine::exec
     }
     if (!select_lex->uncacheable && thd->lex->describe && 
         !(join->select_options & SELECT_DESCRIBE) && 
-        join->need_tmp && item->const_item())
+        join->need_tmp)
     {
-      /*
-        Force join->join_tmp creation, because this subquery will be replaced
-        by a simple select from the materialization temp table by optimize()
-        called by EXPLAIN and we need to preserve the initial query structure
-        so we can display it.
-       */
-      select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
-      select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
-      if (join->init_save_join_tab())
-        DBUG_RETURN(1);                        /* purecov: inspected */
+      item->update_used_tables();
+      if (item->const_item())
+      {
+        /*
+          Force join->join_tmp creation, because this subquery will be replaced
+          by a simple select from the materialization temp table by optimize()
+          called by EXPLAIN and we need to preserve the initial query structure
+          so we can display it.
+        */
+        select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
+        select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
+        if (join->init_save_join_tab())
+          DBUG_RETURN(1);                        /* purecov: inspected */
+      }
     }
     if (item->engine_changed)
     {

=== modified file 'sql/rpl_record.cc'
--- a/sql/rpl_record.cc	2010-07-24 13:31:48 +0000
+++ b/sql/rpl_record.cc	2010-10-06 17:20:18 +0000
@@ -78,8 +78,6 @@ pack_row(TABLE *table, MY_BITMAP const*
   unsigned int null_mask= 1U;
   for ( ; (field= *p_field) ; p_field++)
   {
-    DBUG_PRINT("debug", ("null_mask=%d; null_ptr=%p; row_data=%p; null_byte_count=%d",
-                         null_mask, null_ptr, row_data, null_byte_count));
     if (bitmap_is_set(cols, p_field - table->field))
     {
       my_ptrdiff_t offset;
@@ -110,6 +108,7 @@ pack_row(TABLE *table, MY_BITMAP const*
                              field->field_name, field->real_type(),
                              (ulong) old_pack_ptr, (ulong) pack_ptr,
                              (int) (pack_ptr - old_pack_ptr)));
+        DBUG_DUMP("packed_data", old_pack_ptr, pack_ptr - old_pack_ptr);
       }
 
       null_mask <<= 1;
@@ -380,8 +379,11 @@ unpack_row(Relay_log_info const *rli,
       }
       DBUG_ASSERT(null_mask & 0xFF); // One of the 8 LSB should be set
 
-      if (!((null_bits & null_mask) && tabledef->maybe_null(i)))
-        pack_ptr+= tabledef->calc_field_size(i, (uchar *) pack_ptr);
+      if (!((null_bits & null_mask) && tabledef->maybe_null(i))) {
+        uint32 len= tabledef->calc_field_size(i, (uchar *) pack_ptr);
+        DBUG_DUMP("field_data", pack_ptr, len);
+        pack_ptr+= len;
+      }
       null_mask <<= 1;
     }
   }

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2010-10-21 08:41:13 +0000
+++ b/sql/sp_head.cc	2010-10-27 07:32:26 +0000
@@ -1176,10 +1176,17 @@ find_handler_after_execution(THD *thd, s
 /**
   Execute the routine. The main instruction jump loop is there.
   Assume the parameters already set.
+
+  @param thd                  Thread context.
+  @param merge_da_on_success  Flag specifying if Warning Info should be
+                              propagated to the caller on Completion
+                              Condition or not.
+
   @todo
     - Will write this SP statement into binlog separately
     (TODO: consider changing the condition to "not inside event union")
 
+  @return Error status.
   @retval
     FALSE  on success
   @retval
@@ -1187,7 +1194,7 @@ find_handler_after_execution(THD *thd, s
 */
 
 bool
-sp_head::execute(THD *thd)
+sp_head::execute(THD *thd, bool merge_da_on_success)
 {
   DBUG_ENTER("sp_head::execute");
   char saved_cur_db_name_buf[NAME_LEN+1];
@@ -1481,8 +1488,15 @@ sp_head::execute(THD *thd)
   thd->stmt_arena= old_arena;
   state= EXECUTED;
 
-  /* Restore the caller's original warning information area. */
-  saved_warning_info->merge_with_routine_info(thd, thd->warning_info);
+  /*
+    Restore the caller's original warning information area:
+      - warnings generated during trigger execution should not be
+        propagated to the caller on success;
+      - if there was an exception during execution, warning info should be
+        propagated to the caller in any case.
+  */
+  if (err_status || merge_da_on_success)
+    saved_warning_info->merge_with_routine_info(thd, thd->warning_info);
   thd->warning_info= saved_warning_info;
 
  done:
@@ -1704,7 +1718,7 @@ sp_head::execute_trigger(THD *thd,
 
   thd->spcont= nctx;
 
-  err_status= execute(thd);
+  err_status= execute(thd, FALSE);
 
 err_with_cleanup:
   thd->restore_active_arena(&call_arena, &backup_arena);
@@ -1921,7 +1935,7 @@ sp_head::execute_function(THD *thd, Item
   */
   thd->set_n_backup_active_arena(&call_arena, &backup_arena);
 
-  err_status= execute(thd);
+  err_status= execute(thd, TRUE);
 
   thd->restore_active_arena(&call_arena, &backup_arena);
 
@@ -2154,7 +2168,7 @@ sp_head::execute_procedure(THD *thd, Lis
 #endif
 
   if (!err_status)
-    err_status= execute(thd);
+    err_status= execute(thd, TRUE);
 
   if (save_log_general)
     thd->variables.option_bits &= ~OPTION_LOG_OFF;

=== modified file 'sql/sp_head.h'
--- a/sql/sp_head.h	2010-08-16 15:16:07 +0000
+++ b/sql/sp_head.h	2010-10-26 11:48:08 +0000
@@ -527,7 +527,7 @@ private:
   HASH m_sptabs;
 
   bool
-  execute(THD *thd);
+  execute(THD *thd, bool merge_da_on_success);
 
   /**
     Perform a forward flow analysis in the generated code.

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2010-10-20 19:02:59 +0000
+++ b/sql/sql_acl.cc	2010-10-25 15:11:58 +0000
@@ -8091,6 +8091,24 @@ static bool send_plugin_request_packet(M
     DBUG_RETURN (1);
   }
 
+  /*
+    If we're dealing with an older client we can't just send a change plugin
+    packet to re-initiate the authentication handshake, because the client 
+    won't understand it. The good thing is that we don't need to : the old client
+    expects us to just check the user credentials here, which we can do by just reading
+    the cached data that are placed there by parse_com_change_user_packet() 
+    In this case we just do nothing and behave as if normal authentication
+    should continue.
+  */
+  if (!(mpvio->client_capabilities & CLIENT_PLUGIN_AUTH))
+  {
+    DBUG_PRINT("info", ("old client sent a COM_CHANGE_USER"));
+    DBUG_ASSERT(mpvio->cached_client_reply.pkt);
+    /* get the status back so the read can process the cached result */
+    mpvio->status= MPVIO_EXT::RESTART; 
+    DBUG_RETURN(0);
+  }
+
   DBUG_PRINT("info", ("requesting client to use the %s plugin", 
                       client_auth_plugin));
   DBUG_RETURN(net_write_command(net, switch_plugin_request_buf[0],
@@ -8574,8 +8592,16 @@ static int server_mpvio_write_packet(MYS
   int res;
 
   DBUG_ENTER("server_mpvio_write_packet");
-  /* reset cached_client_reply */
-  mpvio->cached_client_reply.pkt= 0;
+  /* 
+    Reset cached_client_reply if not an old client doing mysql_change_user, 
+    as this is where the password from COM_CHANGE_USER is stored.
+  */
+  if (!((!(mpvio->client_capabilities & CLIENT_PLUGIN_AUTH)) && 
+        mpvio->status == MPVIO_EXT::RESTART &&
+        mpvio->cached_client_reply.plugin == 
+        ((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin
+        ))
+    mpvio->cached_client_reply.pkt= 0;
   /* for the 1st packet we wrap plugin data into the handshake packet */
   if (mpvio->packets_written == 0)
     res= send_server_handshake_packet(mpvio, (char*) packet, packet_len);
@@ -8641,6 +8667,15 @@ static int server_mpvio_read_packet(MYSQ
       mpvio->packets_read++;
       DBUG_RETURN ((int) mpvio->cached_client_reply.pkt_len);
     }
+
+    /* older clients don't support change of client plugin request */
+    if (!(mpvio->client_capabilities & CLIENT_PLUGIN_AUTH))
+    {
+      mpvio->status= MPVIO_EXT::FAILURE;
+      pkt_len= packet_error;
+      goto err;
+    }
+
     /*
       But if the client has used the wrong plugin, the cached data are
       useless. Furthermore, we have to send a "change plugin" request

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2010-10-06 14:34:28 +0000
+++ b/sql/sql_lex.h	2010-10-25 15:08:27 +0000
@@ -1389,6 +1389,7 @@ public:
     STMT_ACCESS_TABLE_COUNT
   };
 
+#ifndef DBUG_OFF
   static inline const char *stmt_accessed_table_string(enum_stmt_accessed_table accessed_table)
   {
     switch (accessed_table)
@@ -1422,7 +1423,10 @@ public:
         DBUG_ASSERT(0);
       break;
     }
+    MY_ASSERT_UNREACHABLE();
+    return "";
   }
+#endif  /* DBUG */
                
   #define BINLOG_DIRECT_ON 0xF0    /* unsafe when
                                       --binlog-direct-non-trans-updates

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2010-10-20 19:02:59 +0000
+++ b/sql/sql_partition.cc	2010-10-27 07:32:26 +0000
@@ -166,12 +166,13 @@ int get_part_iter_for_interval_via_walki
                                            uint min_len, uint max_len,
                                            uint flags,
                                            PARTITION_ITERATOR *part_iter);
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
 static int cmp_rec_and_tuple(part_column_list_val *val, uint32 nvals_in_rec);
 static int cmp_rec_and_tuple_prune(part_column_list_val *val,
                                    uint32 n_vals_in_rec,
                                    bool tail_is_min);
 
-#ifdef WITH_PARTITION_STORAGE_ENGINE
 /*
   Convert constants in VALUES definition to the character set the
   corresponding field uses.

=== modified file 'sql/sql_partition_admin.cc'
--- a/sql/sql_partition_admin.cc	2010-10-06 14:34:28 +0000
+++ b/sql/sql_partition_admin.cc	2010-10-28 10:08:09 +0000
@@ -18,7 +18,9 @@
 #include "sql_lex.h"                        // Sql_statement
 #include "sql_admin.h"                      // Analyze/Check/.._table_statement
 #include "sql_partition_admin.h"            // Alter_table_*_partition
+#ifdef WITH_PARTITION_STORAGE_ENGINE
 #include "ha_partition.h"                   // ha_partition
+#endif
 #include "sql_base.h"                       // open_and_lock_tables
 
 #ifndef WITH_PARTITION_STORAGE_ENGINE

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2010-08-18 09:35:41 +0000
+++ b/sql/sql_prepare.cc	2010-09-29 11:48:57 +0000
@@ -2420,11 +2420,15 @@ void reinit_stmt_before_use(THD *thd, LE
         sl->where= sl->prep_where->copy_andor_structure(thd);
         sl->where->cleanup();
       }
+      else
+        sl->where= NULL;
       if (sl->prep_having)
       {
         sl->having= sl->prep_having->copy_andor_structure(thd);
         sl->having->cleanup();
       }
+      else
+        sl->having= NULL;
       DBUG_ASSERT(sl->join == 0);
       ORDER *order;
       /* Fix GROUP list */

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-10-14 16:56:56 +0000
+++ b/sql/sql_show.cc	2010-10-27 07:32:26 +0000
@@ -98,11 +98,13 @@ static TYPELIB grant_types = { sizeof(gr
 static void store_key_options(THD *thd, String *packet, TABLE *table,
                               KEY *key_info);
 
+#ifdef WITH_PARTITION_STORAGE_ENGINE
 static void get_cs_converted_string_value(THD *thd,
                                           String *input_str,
                                           String *output_str,
                                           CHARSET_INFO *cs,
                                           bool use_hex);
+#endif
 
 static void
 append_algorithm(TABLE_LIST *table, String *buff);
@@ -7850,6 +7852,7 @@ void initialize_information_schema_acl()
                                                 &is_internal_schema_access);
 }
 
+#ifdef WITH_PARTITION_STORAGE_ENGINE
 /*
   Convert a string in character set in column character set format
   to utf8 character set if possible, the utf8 character set string
@@ -7941,3 +7944,4 @@ static void get_cs_converted_string_valu
   }
   return;
 }
+#endif

=== modified file 'storage/innobase/CMakeLists.txt'
--- a/storage/innobase/CMakeLists.txt	2010-10-21 07:45:44 +0000
+++ b/storage/innobase/CMakeLists.txt	2010-10-27 06:54:20 +0000
@@ -13,7 +13,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
-# This is the CMakeLists for InnoDB Plugin
+# This is the CMakeLists for InnoDB
 
 INCLUDE(CheckFunctionExists)
 INCLUDE(CheckCSourceCompiles)
@@ -254,29 +254,7 @@ IF(WITH_INNODB)
   SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
 ENDIF()
 
-
-#The plugin's CMakeLists.txt still needs to work with previous versions of MySQL.
-IF(EXISTS ${SOURCE_DIR}/storage/mysql_storage_engine.cmake)
-	# Old plugin support on Windows only, 
-	# use tricks to force ha_innodb.dll name for DLL
-	INCLUDE(${SOURCE_DIR}/storage/mysql_storage_engine.cmake)
-	MYSQL_STORAGE_ENGINE(INNOBASE)
-	GET_TARGET_PROPERTY(LIB_LOCATION ha_innobase LOCATION)
-	IF(LIB_LOCATION)
-		SET_TARGET_PROPERTIES(ha_innobase PROPERTIES OUTPUT_NAME ha_innodb)
-	ENDIF()
-ELSEIF (MYSQL_VERSION_ID LESS "50137")
-	# Windows only, no plugin support
-	IF (NOT SOURCE_SUBLIBS)
-		ADD_DEFINITIONS(-DMYSQL_SERVER)
-		ADD_LIBRARY(innobase STATIC ${INNOBASE_SOURCES})
-		# Require mysqld_error.h, which is built as part of the GenError
-		ADD_DEPENDENCIES(innobase GenError)
-	ENDIF()
-ELSE()
-	# New plugin support, cross-platform ,  base name for shared module is "ha_innodb"
-	MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE 
-		DEFAULT
-		MODULE_OUTPUT_NAME ha_innodb
-		LINK_LIBRARIES ${ZLIB_LIBRARY})
-ENDIF()
+MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE 
+  DEFAULT
+  MODULE_OUTPUT_NAME ha_innodb
+  LINK_LIBRARIES ${ZLIB_LIBRARY})

=== modified file 'storage/innobase/buf/buf0buf.c'
--- a/storage/innobase/buf/buf0buf.c	2010-10-20 11:46:28 +0000
+++ b/storage/innobase/buf/buf0buf.c	2010-10-27 18:50:45 +0000
@@ -246,8 +246,8 @@ static const int WAIT_FOR_READ	= 5000;
 /** Number of attemtps made to read in a page in the buffer pool */
 static const ulint BUF_PAGE_READ_MAX_RETRIES = 100;
 
-/** The buffer buf_pool of the database */
-UNIV_INTERN buf_pool_t*	buf_pool_ptr[MAX_BUFFER_POOLS];
+/** The buffer pools of the database */
+UNIV_INTERN buf_pool_t*	buf_pool_ptr;
 
 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 static ulint	buf_dbg_counter	= 0; /*!< This is used to insert validation
@@ -858,7 +858,7 @@ buf_block_init(
 
 	block->frame = frame;
 
-	block->page.buf_pool = buf_pool;
+	block->page.buf_pool_index = buf_pool_index(buf_pool);
 	block->page.state = BUF_BLOCK_NOT_USED;
 	block->page.buf_fix_count = 0;
 	block->page.io_fix = BUF_IO_NONE;
@@ -1280,8 +1280,6 @@ buf_pool_free_instance(
 	mem_free(buf_pool->chunks);
 	hash_table_free(buf_pool->page_hash);
 	hash_table_free(buf_pool->zip_hash);
-	mem_free(buf_pool);
-	buf_pool = NULL;
 }
 
 /********************************************************************//**
@@ -1294,25 +1292,23 @@ buf_pool_init(
 	ulint	total_size,	/*!< in: size of the total pool in bytes */
 	ulint	n_instances)	/*!< in: number of instances */
 {
-	ulint	i;
+	ulint		i;
+	const ulint	size	= total_size / n_instances;
+
+	ut_ad(n_instances > 0);
+	ut_ad(n_instances <= MAX_BUFFER_POOLS);
+	ut_ad(n_instances == srv_buf_pool_instances);
 
 	/* We create an extra buffer pool instance, this instance is used
 	for flushing the flush lists, to keep track of n_flush for all
 	the buffer pools and also used as a waiting object during flushing. */
-	for (i = 0; i < n_instances; i++) {
-		buf_pool_t*	ptr;
-		ulint		size;
-
-		ptr = mem_zalloc(sizeof(*ptr));
+	buf_pool_ptr = mem_zalloc(n_instances * sizeof *buf_pool_ptr);
 
-		size = total_size / n_instances;
-
-		buf_pool_ptr[i] = ptr;
+	for (i = 0; i < n_instances; i++) {
+		buf_pool_t*	ptr	= &buf_pool_ptr[i];
 
 		if (buf_pool_init_instance(ptr, size, i) != DB_SUCCESS) {
 
-			mem_free(buf_pool_ptr[i]);
-
 			/* Free all the instances created so far. */
 			buf_pool_free(i);
 
@@ -1341,8 +1337,10 @@ buf_pool_free(
 
 	for (i = 0; i < n_instances; i++) {
 		buf_pool_free_instance(buf_pool_from_array(i));
-		buf_pool_ptr[i] = NULL;
 	}
+
+	mem_free(buf_pool_ptr);
+	buf_pool_ptr = NULL;
 }
 
 /********************************************************************//**
@@ -3685,7 +3683,7 @@ err_exit:
 		bpage = buf_buddy_alloc(buf_pool, sizeof *bpage, &lru);
 
 		/* Initialize the buf_pool pointer. */
-		bpage->buf_pool = buf_pool;
+		bpage->buf_pool_index = buf_pool_index(buf_pool);
 
 		/* If buf_buddy_alloc() allocated storage from the LRU list,
 		it released and reacquired buf_pool->mutex.  Thus, we must

=== modified file 'storage/innobase/dict/dict0load.c'
--- a/storage/innobase/dict/dict0load.c	2010-10-21 03:07:42 +0000
+++ b/storage/innobase/dict/dict0load.c	2010-10-29 04:55:43 +0000
@@ -1718,13 +1718,24 @@ err_exit:
 
 	err = dict_load_indexes(table, heap);
 
+	/* Initialize table foreign_child value. Its value could be
+	changed when dict_load_foreigns() is called below */
+	table->fk_max_recusive_level = 0;
+
 	/* If the force recovery flag is set, we open the table irrespective
 	of the error condition, since the user may want to dump data from the
 	clustered index. However we load the foreign key information only if
 	all indexes were loaded. */
 	if (!cached) {
 	} else if (err == DB_SUCCESS) {
-		err = dict_load_foreigns(table->name, TRUE);
+		err = dict_load_foreigns(table->name, TRUE, TRUE);
+
+		if (err != DB_SUCCESS) {
+			dict_table_remove_from_cache(table);
+			table = NULL;
+		} else {
+			table->fk_max_recusive_level = 0;
+		}
 	} else if (!srv_force_recovery) {
 		dict_table_remove_from_cache(table);
 		table = NULL;
@@ -1952,8 +1963,12 @@ dict_load_foreign(
 /*==============*/
 	const char*	id,	/*!< in: foreign constraint id as a
 				null-terminated string */
-	ibool		check_charsets)
+	ibool		check_charsets,
 				/*!< in: TRUE=check charset compatibility */
+	ibool		check_recursive)
+				/*!< in: Whether to record the foreign table
+				parent count to avoid unlimited recursive
+				load of chained foreign tables */
 {
 	dict_foreign_t*	foreign;
 	dict_table_t*	sys_foreign;
@@ -1967,6 +1982,8 @@ dict_load_foreign(
 	ulint		len;
 	ulint		n_fields_and_type;
 	mtr_t		mtr;
+	dict_table_t*	for_table;
+	dict_table_t*	ref_table;
 
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
@@ -2051,11 +2068,54 @@ dict_load_foreign(
 
 	dict_load_foreign_cols(id, foreign);
 
-	/* If the foreign table is not yet in the dictionary cache, we
-	have to load it so that we are able to make type comparisons
-	in the next function call. */
+	ref_table = dict_table_check_if_in_cache_low(
+			foreign->referenced_table_name);
 
-	dict_table_get_low(foreign->foreign_table_name);
+	/* We could possibly wind up in a deep recursive calls if
+	we call dict_table_get_low() again here if there
+	is a chain of tables concatenated together with
+	foreign constraints. In such case, each table is
+	both a parent and child of the other tables, and
+	act as a "link" in such table chains.
+	To avoid such scenario, we would need to check the
+	number of ancesters the current table has. If that
+	exceeds DICT_FK_MAX_CHAIN_LEN, we will stop loading
+	the child table.
+	Foreign constraints are loaded in a Breath First fashion,
+	that is, the index on FOR_NAME is scanned first, and then
+	index on REF_NAME. So foreign constrains in which
+	current table is a child (foreign table) are loaded first,
+	and then those constraints where current table is a
+	parent (referenced) table.
+	Thus we could check the parent (ref_table) table's
+	reference count (fk_max_recusive_level) to know how deep the
+	recursive call is. If the parent table (ref_table) is already
+	loaded, and its fk_max_recusive_level is larger than
+	DICT_FK_MAX_CHAIN_LEN, we will stop the recursive loading
+	by skipping loading the child table. It will not affect foreign
+	constraint check for DMLs since child table will be loaded
+	at that time for the constraint check. */
+	if (!ref_table
+	    || ref_table->fk_max_recusive_level < DICT_FK_MAX_RECURSIVE_LOAD) {
+
+		/* If the foreign table is not yet in the dictionary cache, we
+		have to load it so that we are able to make type comparisons
+		in the next function call. */
+
+		for_table = dict_table_get_low(foreign->foreign_table_name);
+
+		if (for_table && ref_table && check_recursive) {
+			/* This is to record the longest chain of ancesters
+			this table has, if the parent has more ancesters
+			than this table has, record it after add 1 (for this
+			parent */
+			if (ref_table->fk_max_recusive_level
+			    >= for_table->fk_max_recusive_level) {
+				for_table->fk_max_recusive_level =
+					 ref_table->fk_max_recusive_level + 1;
+			}
+		}
+	}
 
 	/* Note that there may already be a foreign constraint object in
 	the dictionary cache for this constraint: then the following
@@ -2080,6 +2140,8 @@ ulint
 dict_load_foreigns(
 /*===============*/
 	const char*	table_name,	/*!< in: table name */
+	ibool		check_recursive,/*!< in: Whether to check recursive
+					load of tables chained by FK */
 	ibool		check_charsets)	/*!< in: TRUE=check charset
 					compatibility */
 {
@@ -2181,7 +2243,7 @@ loop:
 
 	/* Load the foreign constraint definition to the dictionary cache */
 
-	err = dict_load_foreign(id, check_charsets);
+	err = dict_load_foreign(id, check_charsets, check_recursive);
 
 	if (err != DB_SUCCESS) {
 		btr_pcur_close(&pcur);
@@ -2209,6 +2271,11 @@ load_next_index:
 
 		mtr_start(&mtr);
 
+		/* Switch to scan index on REF_NAME, fk_max_recusive_level
+		already been updated when scanning FOR_NAME index, no need to
+		update again */
+		check_recursive = FALSE;
+
 		goto start_load;
 	}
 

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2010-10-21 11:22:27 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2010-10-27 13:41:26 +0000
@@ -95,10 +95,6 @@ extern "C" {
 #  define MYSQL_PLUGIN_IMPORT /* nothing */
 # endif /* MYSQL_PLUGIN_IMPORT */
 
-#if MYSQL_VERSION_ID < 50124
-bool check_global_access(THD *thd, ulong want_access);
-#endif /* MYSQL_VERSION_ID < 50124 */
-
 /** to protect innobase_open_files */
 static mysql_mutex_t innobase_share_mutex;
 /** to force correct commit order in binlog */
@@ -240,7 +236,6 @@ static PSI_mutex_info all_innodb_mutexes
 	{&ibuf_mutex_key, "ibuf_mutex", 0},
 	{&ibuf_pessimistic_insert_mutex_key,
 		 "ibuf_pessimistic_insert_mutex", 0},
-	{&ios_mutex_key, "ios_mutex", 0},
 	{&kernel_mutex_key, "kernel_mutex", 0},
 	{&log_sys_mutex_key, "log_sys_mutex", 0},
 #  ifdef UNIV_MEM_DEBUG
@@ -900,6 +895,19 @@ convert_error_code_to_mysql(
 	case DB_INTERRUPTED:
 		my_error(ER_QUERY_INTERRUPTED, MYF(0));
 		/* fall through */
+
+	case DB_FOREIGN_EXCEED_MAX_CASCADE:
+		push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+				    HA_ERR_ROW_IS_REFERENCED,
+				    "InnoDB: Cannot delete/update "
+				    "rows with cascading foreign key "
+				    "constraints that exceed max "
+				    "depth of %d. Please "
+				    "drop extra constraints and try "
+				    "again", DICT_FK_MAX_RECURSIVE_LOAD);
+
+		/* fall through */
+
 	case DB_ERROR:
 	default:
 		return(-1); /* unspecified error */
@@ -1886,11 +1894,7 @@ innobase_convert_identifier(
 				FALSE=id is an UTF-8 string */
 {
 	char nz[NAME_LEN + 1];
-#if MYSQL_VERSION_ID >= 50141
 	char nz2[NAME_LEN + 1 + EXPLAIN_FILENAME_MAX_EXTRA_LENGTH];
-#else /* MYSQL_VERSION_ID >= 50141 */
-	char nz2[NAME_LEN + 1 + sizeof srv_mysql50_table_name_prefix];
-#endif /* MYSQL_VERSION_ID >= 50141 */
 
 	const char*	s	= id;
 	int		q;
@@ -1908,13 +1912,9 @@ innobase_convert_identifier(
 		nz[idlen] = 0;
 
 		s = nz2;
-#if MYSQL_VERSION_ID >= 50141
 		idlen = explain_filename((THD*) thd, nz, nz2, sizeof nz2,
 					 EXPLAIN_PARTITIONS_AS_COMMENT);
 		goto no_quote;
-#else /* MYSQL_VERSION_ID >= 50141 */
-		idlen = filename_to_tablename(nz, nz2, sizeof nz2);
-#endif /* MYSQL_VERSION_ID >= 50141 */
 	}
 
 	/* See if the identifier needs to be quoted. */
@@ -1925,9 +1925,7 @@ innobase_convert_identifier(
 	}
 
 	if (q == EOF) {
-#if MYSQL_VERSION_ID >= 50141
 no_quote:
-#endif /* MYSQL_VERSION_ID >= 50141 */
 		if (UNIV_UNLIKELY(idlen > buflen)) {
 			idlen = buflen;
 		}

=== modified file 'storage/innobase/handler/ha_innodb.h'
--- a/storage/innobase/handler/ha_innodb.h	2010-10-18 12:16:23 +0000
+++ b/storage/innobase/handler/ha_innodb.h	2010-10-27 06:54:20 +0000
@@ -276,14 +276,13 @@ int thd_binlog_format(const MYSQL_THD th
 */
 void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all);
 
-#if MYSQL_VERSION_ID > 50140
 /**
   Check if binary logging is filtered for thread's current db.
   @param  thd   Thread handle
   @retval 1 the query is not filtered, 0 otherwise.
 */
 bool thd_binlog_filter_ok(const MYSQL_THD thd);
-#endif /* MYSQL_VERSION_ID > 50140 */
+
 /**
   Check if the query may generate row changes which
   may end up in the binary.

=== modified file 'storage/innobase/ibuf/ibuf0ibuf.c'
--- a/storage/innobase/ibuf/ibuf0ibuf.c	2010-10-19 06:44:38 +0000
+++ b/storage/innobase/ibuf/ibuf0ibuf.c	2010-10-27 22:06:20 +0000
@@ -1363,12 +1363,12 @@ ibuf_add_ops(
 	const ulint*	ops)	/*!< in: operation counts */
 
 {
+	ulint	i;
+
 #ifndef HAVE_ATOMIC_BUILTINS
 	ut_ad(mutex_own(&ibuf_mutex));
 #endif /* !HAVE_ATOMIC_BUILTINS */
 
-	ulint	i;
-
 	for (i = 0; i < IBUF_OP_COUNT; i++) {
 #ifdef HAVE_ATOMIC_BUILTINS
 		os_atomic_increment_ulint(&arr[i], ops[i]);

=== modified file 'storage/innobase/include/buf0buf.h'
--- a/storage/innobase/include/buf0buf.h	2010-10-20 11:46:28 +0000
+++ b/storage/innobase/include/buf0buf.h	2010-10-27 06:56:56 +0000
@@ -69,7 +69,7 @@ Created 11/5/1995 Heikki Tuuri
 #define BUF_POOL_WATCH_SIZE 1		/*!< Maximum number of concurrent
 					buffer pool watches */
 
-extern	buf_pool_t*	buf_pool_ptr[MAX_BUFFER_POOLS]; /*!< The buffer pools
+extern	buf_pool_t*	buf_pool_ptr;	/*!< The buffer pools
 					of the database */
 #ifdef UNIV_DEBUG
 extern ibool		buf_debug_prints;/*!< If this is set TRUE, the program
@@ -1034,6 +1034,15 @@ buf_page_address_fold(
 	ulint	space,	/*!< in: space id */
 	ulint	offset)	/*!< in: offset of the page within space */
 	__attribute__((const));
+/********************************************************************//**
+Calculates the index of a buffer pool to the buf_pool[] array.
+@return	the position of the buffer pool in buf_pool[] */
+UNIV_INLINE
+ulint
+buf_pool_index(
+/*===========*/
+	const buf_pool_t*	buf_pool)	/*!< in: buffer pool */
+	__attribute__((nonnull, const));
 /******************************************************************//**
 Returns the buffer pool instance given a page instance
 @return buf_pool */
@@ -1065,8 +1074,9 @@ Returns the buffer pool instance given i
 UNIV_INLINE
 buf_pool_t*
 buf_pool_from_array(
-/*====================*/
-	ulint	index);	/*!< in: array index to get buffer pool instance from */
+/*================*/
+	ulint	index);		/*!< in: array index to get
+				buffer pool instance from */
 /******************************************************************//**
 Returns the control block of a file page, NULL if not found.
 @return	block, NULL if not found */
@@ -1204,8 +1214,13 @@ struct buf_page_struct{
 	unsigned	io_fix:2;	/*!< type of pending I/O operation;
 					also protected by buf_pool->mutex
 					@see enum buf_io_fix */
-	unsigned	buf_fix_count:25;/*!< count of how manyfold this block
+	unsigned	buf_fix_count:19;/*!< count of how manyfold this block
 					is currently bufferfixed */
+	unsigned	buf_pool_index:6;/*!< index number of the buffer pool
+					that this block belongs to */
+# if MAX_BUFFER_POOLS > 64
+#  error "MAX_BUFFER_POOLS > 64; redefine buf_pool_index:6"
+# endif
 	/* @} */
 #endif /* !UNIV_HOTBACKUP */
 	page_zip_des_t	zip;		/*!< compressed page; zip.data
@@ -1324,8 +1339,6 @@ struct buf_page_struct{
 					frees a page in buffer pool */
 # endif /* UNIV_DEBUG_FILE_ACCESSES */
 #endif /* !UNIV_HOTBACKUP */
-	buf_pool_t*	buf_pool;	/*!< buffer pool instance this
-					page belongs to */
 };
 
 /** The buffer control block structure */

=== modified file 'storage/innobase/include/buf0buf.ic'
--- a/storage/innobase/include/buf0buf.ic	2010-06-22 15:58:28 +0000
+++ b/storage/innobase/include/buf0buf.ic	2010-10-27 06:56:56 +0000
@@ -46,6 +46,48 @@ buf_pool_get_curr_size(void)
 	return(srv_buf_pool_curr_size);
 }
 
+/********************************************************************//**
+Calculates the index of a buffer pool to the buf_pool[] array.
+@return	the position of the buffer pool in buf_pool[] */
+UNIV_INLINE
+ulint
+buf_pool_index(
+/*===========*/
+	const buf_pool_t*	buf_pool)	/*!< in: buffer pool */
+{
+	ulint	i = buf_pool - buf_pool_ptr;
+	ut_ad(i < MAX_BUFFER_POOLS);
+	ut_ad(i < srv_buf_pool_instances);
+	return(i);
+}
+
+/******************************************************************//**
+Returns the buffer pool instance given a page instance
+@return buf_pool */
+UNIV_INLINE
+buf_pool_t*
+buf_pool_from_bpage(
+/*================*/
+	const buf_page_t*	bpage) /*!< in: buffer pool page */
+{
+	ulint	i;
+	i = bpage->buf_pool_index;
+	ut_ad(i < srv_buf_pool_instances);
+	return(&buf_pool_ptr[i]);
+}
+
+/******************************************************************//**
+Returns the buffer pool instance given a block instance
+@return buf_pool */
+UNIV_INLINE
+buf_pool_t*
+buf_pool_from_block(
+/*================*/
+	const buf_block_t*	block) /*!< in: block */
+{
+	return(buf_pool_from_bpage(&block->page));
+}
+
 /*********************************************************************//**
 Gets the current size of buffer buf_pool in pages.
 @return size in pages*/
@@ -886,33 +928,6 @@ buf_block_buf_fix_dec(
 }
 
 /******************************************************************//**
-Returns the buffer pool instance given a page instance
-@return buf_pool */
-UNIV_INLINE
-buf_pool_t*
-buf_pool_from_bpage(
-/*================*/
-	const buf_page_t*	bpage) /*!< in: buffer pool page */
-{
-	/* Every page must be in some buffer pool. */
-	ut_ad(bpage->buf_pool != NULL);
-
-	return(bpage->buf_pool);
-}
-
-/******************************************************************//**
-Returns the buffer pool instance given a block instance
-@return buf_pool */
-UNIV_INLINE
-buf_pool_t*
-buf_pool_from_block(
-/*================*/
-	const buf_block_t*	block) /*!< in: block */
-{
-	return(buf_pool_from_bpage(&block->page));
-}
-
-/******************************************************************//**
 Returns the buffer pool instance given space and offset of page
 @return buffer pool */
 UNIV_INLINE
@@ -929,7 +944,7 @@ buf_pool_get(
 	ignored_offset = offset >> 6; /* 2log of BUF_READ_AHEAD_AREA (64)*/
 	fold = buf_page_address_fold(space, ignored_offset);
 	index = fold % srv_buf_pool_instances;
-	return buf_pool_ptr[index];
+	return(&buf_pool_ptr[index]);
 }
 
 /******************************************************************//**
@@ -939,10 +954,12 @@ UNIV_INLINE
 buf_pool_t*
 buf_pool_from_array(
 /*================*/
-	ulint	index) 		/*!< in: array index to get
+	ulint	index)		/*!< in: array index to get
 				buffer pool instance from */
 {
-	return buf_pool_ptr[index];
+	ut_ad(index < MAX_BUFFER_POOLS);
+	ut_ad(index < srv_buf_pool_instances);
+	return(&buf_pool_ptr[index]);
 }
 
 /******************************************************************//**

=== modified file 'storage/innobase/include/db0err.h'
--- a/storage/innobase/include/db0err.h	2010-08-13 12:23:54 +0000
+++ b/storage/innobase/include/db0err.h	2010-10-06 13:55:34 +0000
@@ -101,6 +101,9 @@ enum db_err {
 					requested but this storage does not
 					exist itself or the stats for a given
 					table do not exist */
+	DB_FOREIGN_EXCEED_MAX_CASCADE,	/* Foreign key constraint related
+					cascading delete/update exceeds
+					maximum allowed depth */
 
 	/* The following are partial failure codes */
 	DB_FAIL = 1000,

=== modified file 'storage/innobase/include/dict0load.h'
--- a/storage/innobase/include/dict0load.h	2010-09-02 13:57:59 +0000
+++ b/storage/innobase/include/dict0load.h	2010-10-06 13:55:34 +0000
@@ -200,6 +200,8 @@ ulint
 dict_load_foreigns(
 /*===============*/
 	const char*	table_name,	/*!< in: table name */
+	ibool		check_recursive,/*!< in: Whether to check recursive
+					load of tables chained by FK */
 	ibool		check_charsets);/*!< in: TRUE=check charsets
 					compatibility */
 /********************************************************************//**

=== modified file 'storage/innobase/include/dict0mem.h'
--- a/storage/innobase/include/dict0mem.h	2010-08-13 12:23:54 +0000
+++ b/storage/innobase/include/dict0mem.h	2010-10-06 13:55:34 +0000
@@ -116,6 +116,21 @@ ROW_FORMAT=REDUNDANT. */
 						in table->flags. */
 /* @} */
 
+/** Tables could be chained together with Foreign key constraint. When
+first load the parent table, we would load all of its descedents.
+This could result in rescursive calls and out of stack error eventually.
+DICT_FK_MAX_RECURSIVE_LOAD defines the maximum number of recursive loads,
+when exceeded, the child table will not be loaded. It will be loaded when
+the foreign constraint check needs to be run. */
+#define DICT_FK_MAX_RECURSIVE_LOAD	255
+
+/** Similarly, when tables are chained together with foreign key constraints
+with on cascading delete/update clause, delete from parent table could
+result in recursive cascading calls. This defines the maximum number of
+such cascading deletes/updates allowed. When exceeded, the delete from
+parent table will fail, and user has to drop excessive foreign constraint
+before proceeds. */
+#define FK_MAX_CASCADE_DEL		255
 
 /**********************************************************************//**
 Creates a table memory object.
@@ -469,6 +484,12 @@ struct dict_table_struct{
 				NOT allowed until this count gets to zero;
 				MySQL does NOT itself check the number of
 				open handles at drop */
+	unsigned	fk_max_recusive_level:8;
+				/*!< maximum recursive level we support when
+				loading tables chained together with FK
+				constraints. If exceeds this level, we will
+				stop loading child table into memory along with
+				its parent table */
 	ulint		n_foreign_key_checks_running;
 				/*!< count of how many foreign key check
 				operations are currently being performed

=== modified file 'storage/innobase/include/que0que.h'
--- a/storage/innobase/include/que0que.h	2010-08-13 12:23:54 +0000
+++ b/storage/innobase/include/que0que.h	2010-10-06 13:55:34 +0000
@@ -381,6 +381,9 @@ struct que_thr_struct{
 					thus far */
 	ulint		lock_state;	/*!< lock state of thread (table or
 					row) */
+	ulint		fk_cascade_depth; /*!< maximum cascading call depth
+					supported for foreign key constraint
+					related delete/updates */
 };
 
 #define QUE_THR_MAGIC_N		8476583

=== modified file 'storage/innobase/include/sync0sync.h'
--- a/storage/innobase/include/sync0sync.h	2010-07-21 14:22:29 +0000
+++ b/storage/innobase/include/sync0sync.h	2010-10-22 06:34:57 +0000
@@ -85,7 +85,6 @@ extern mysql_pfs_key_t	hash_table_mutex_
 extern mysql_pfs_key_t	ibuf_bitmap_mutex_key;
 extern mysql_pfs_key_t	ibuf_mutex_key;
 extern mysql_pfs_key_t	ibuf_pessimistic_insert_mutex_key;
-extern mysql_pfs_key_t	ios_mutex_key;
 extern mysql_pfs_key_t	log_sys_mutex_key;
 extern mysql_pfs_key_t	log_flush_order_mutex_key;
 extern mysql_pfs_key_t	kernel_mutex_key;

=== modified file 'storage/innobase/include/trx0undo.h'
--- a/storage/innobase/include/trx0undo.h	2010-07-21 14:22:29 +0000
+++ b/storage/innobase/include/trx0undo.h	2010-10-27 01:45:58 +0000
@@ -262,8 +262,6 @@ UNIV_INTERN
 page_t*
 trx_undo_set_state_at_finish(
 /*=========================*/
-	trx_rseg_t*	rseg,	/*!< in: rollback segment memory object */
-	trx_t*		trx,	/*!< in: transaction */
 	trx_undo_t*	undo,	/*!< in: undo log memory copy */
 	mtr_t*		mtr);	/*!< in: mtr */
 /******************************************************************//**

=== modified file 'storage/innobase/os/os0file.c'
--- a/storage/innobase/os/os0file.c	2010-10-19 14:30:06 +0000
+++ b/storage/innobase/os/os0file.c	2010-10-28 05:54:25 +0000
@@ -2400,7 +2400,10 @@ os_file_read_func(
 	ulint		i;
 #endif /* !UNIV_HOTBACKUP */
 
+	/* On 64-bit Windows, ulint is 64 bits. But offset and n should be
+	no more than 32 bits. */
 	ut_a((offset & 0xFFFFFFFFUL) == offset);
+	ut_a((n & 0xFFFFFFFFUL) == n);
 
 	os_n_file_reads++;
 	os_bytes_read_since_printout += n;
@@ -2526,7 +2529,10 @@ os_file_read_no_error_handling_func(
 	ulint		i;
 #endif /* !UNIV_HOTBACKUP */
 
+	/* On 64-bit Windows, ulint is 64 bits. But offset and n should be
+	no more than 32 bits. */
 	ut_a((offset & 0xFFFFFFFFUL) == offset);
+	ut_a((n & 0xFFFFFFFFUL) == n);
 
 	os_n_file_reads++;
 	os_bytes_read_since_printout += n;
@@ -2658,7 +2664,10 @@ os_file_write_func(
 	ulint		i;
 #endif /* !UNIV_HOTBACKUP */
 
-	ut_a((offset & 0xFFFFFFFF) == offset);
+	/* On 64-bit Windows, ulint is 64 bits. But offset and n should be
+	no more than 32 bits. */
+	ut_a((offset & 0xFFFFFFFFUL) == offset);
+	ut_a((n & 0xFFFFFFFFUL) == n);
 
 	os_n_file_writes++;
 
@@ -3621,6 +3630,10 @@ os_aio_array_reserve_slot(
 	ulint		slots_per_seg;
 	ulint		local_seg;
 
+#ifdef WIN_ASYNC_IO
+	ut_a((len & 0xFFFFFFFFUL) == len);
+#endif
+
 	/* No need of a mutex. Only reading constant fields */
 	slots_per_seg = array->n_slots / array->n_segments;
 
@@ -3996,6 +4009,9 @@ os_aio_func(
 	ut_ad(n % OS_FILE_LOG_BLOCK_SIZE == 0);
 	ut_ad(offset % OS_FILE_LOG_BLOCK_SIZE == 0);
 	ut_ad(os_aio_validate());
+#ifdef WIN_ASYNC_IO
+	ut_ad((n & 0xFFFFFFFFUL) == n);
+#endif
 
 	wake_later = mode & OS_AIO_SIMULATED_WAKE_LATER;
 	mode = mode & (~OS_AIO_SIMULATED_WAKE_LATER);
@@ -4271,16 +4287,18 @@ os_aio_windows_handle(
 					    __FILE__, __LINE__);
 #endif
 
+		ut_a((slot->len & 0xFFFFFFFFUL) == slot->len);
+
 		switch (slot->type) {
 		case OS_FILE_WRITE:
 			ret = WriteFile(slot->file, slot->buf,
-					slot->len, &len,
+					(DWORD) slot->len, &len,
 					&(slot->control));
 
 			break;
 		case OS_FILE_READ:
 			ret = ReadFile(slot->file, slot->buf,
-				       slot->len, &len,
+				       (DWORD) slot->len, &len,
 				       &(slot->control));
 
 			break;

=== modified file 'storage/innobase/os/os0sync.c'
--- a/storage/innobase/os/os0sync.c	2010-10-18 06:05:44 +0000
+++ b/storage/innobase/os/os0sync.c	2010-10-28 17:12:23 +0000
@@ -136,20 +136,30 @@ os_cond_wait_timed(
 #ifndef __WIN__
 	const struct timespec*	abstime		/*!< in: timeout */
 #else
-	ulint			time_in_ms	/*!< in: timeout in
+	DWORD			time_in_ms	/*!< in: timeout in
 						milliseconds*/
 #endif /* !__WIN__ */
 )
 {
 #ifdef __WIN__
-	BOOL			ret;
+	BOOL	ret;
+	DWORD	err;
 
 	ut_a(sleep_condition_variable != NULL);
 
 	ret = sleep_condition_variable(cond, mutex, time_in_ms);
 
-	if (!ret && GetLastError() == WAIT_TIMEOUT) {
-		return(TRUE);
+	if (!ret) {
+		err = GetLastError();
+		/* From http://msdn.microsoft.com/en-us/library/ms686301%28VS.85%29.aspx,
+		"Condition variables are subject to spurious wakeups
+		(those not associated with an explicit wake) and stolen wakeups
+		(another thread manages to run before the woken thread)."
+		Check for both types of timeouts.
+		Conditions are checked by the caller.*/
+		if ((err == WAIT_TIMEOUT) || (err == ERROR_TIMEOUT)) {
+			return(TRUE);
+		}
 	}
 
 	ut_a(ret);
@@ -163,12 +173,15 @@ os_cond_wait_timed(
 	switch (ret) {
 	case 0:
 	case ETIMEDOUT:
-	       	break;
+	/* We play it safe by checking for EINTR even though
+	according to the POSIX documentation it can't return EINTR. */
+	case EINTR:
+		break;
 
 	default:
 		fprintf(stderr, "  InnoDB: pthread_cond_timedwait() returned: "
 				"%d: abstime={%lu,%lu}\n",
-			       	ret, abstime->tv_sec, abstime->tv_nsec);
+				ret, (ulong) abstime->tv_sec, (ulong) abstime->tv_nsec);
 		ut_error;
 	}
 
@@ -655,7 +668,7 @@ os_event_wait_time_low(
 		ut_a(event);
 
 		if (time_in_usec != OS_SYNC_INFINITE_TIME) {
-			time_in_ms = time_in_ms / 1000;
+			time_in_ms = time_in_usec / 1000;
 			err = WaitForSingleObject(event->handle, time_in_ms);
 		} else {
 			err = WaitForSingleObject(event->handle, INFINITE);
@@ -663,7 +676,7 @@ os_event_wait_time_low(
 
 		if (err == WAIT_OBJECT_0) {
 			return(0);
-		} else if (err == WAIT_TIMEOUT) {
+		} else if ((err == WAIT_TIMEOUT) || (err == ERROR_TIMEOUT)) {
 			return(OS_SYNC_TIME_EXCEEDED);
 		}
 

=== modified file 'storage/innobase/row/row0merge.c'
--- a/storage/innobase/row/row0merge.c	2010-08-13 12:23:54 +0000
+++ b/storage/innobase/row/row0merge.c	2010-10-06 13:55:34 +0000
@@ -2418,7 +2418,7 @@ row_merge_rename_tables(
 		goto err_exit;
 	}
 
-	err = dict_load_foreigns(old_name, TRUE);
+	err = dict_load_foreigns(old_name, FALSE, TRUE);
 
 	if (err != DB_SUCCESS) {
 err_exit:

=== modified file 'storage/innobase/row/row0mysql.c'
--- a/storage/innobase/row/row0mysql.c	2010-10-19 06:35:14 +0000
+++ b/storage/innobase/row/row0mysql.c	2010-10-27 13:41:26 +0000
@@ -635,6 +635,13 @@ handle_new_error:
 		      "InnoDB: " REFMAN "forcing-recovery.html"
 		      " for help.\n", stderr);
 		break;
+	case DB_FOREIGN_EXCEED_MAX_CASCADE:
+		fprintf(stderr, "InnoDB: Cannot delete/update rows with"
+			" cascading foreign key constraints that exceed max"
+			" depth of %lu\n"
+			"Please drop excessive foreign constraints"
+			" and try again\n", (ulong) DICT_FK_MAX_RECURSIVE_LOAD);
+		break;
 	default:
 		fprintf(stderr, "InnoDB: unknown error code %lu\n",
 			(ulong) err);
@@ -1440,11 +1447,15 @@ row_update_for_mysql(
 run_again:
 	thr->run_node = node;
 	thr->prev_node = node;
+	thr->fk_cascade_depth = 0;
 
 	row_upd_step(thr);
 
 	err = trx->error_state;
 
+	/* Reset fk_cascade_depth back to 0 */
+	thr->fk_cascade_depth = 0;
+
 	if (err != DB_SUCCESS) {
 		que_thr_stop_for_mysql(thr);
 
@@ -1640,12 +1651,27 @@ row_update_cascade_for_mysql(
 	trx_t*	trx;
 
 	trx = thr_get_trx(thr);
+
+	/* Increment fk_cascade_depth to record the recursive call depth on
+	a single update/delete that affects multiple tables chained
+	together with foreign key relations. */
+	thr->fk_cascade_depth++;
+
+	if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) {
+		return (DB_FOREIGN_EXCEED_MAX_CASCADE);
+	}
 run_again:
 	thr->run_node = node;
 	thr->prev_node = node;
 
 	row_upd_step(thr);
 
+	/* The recursive call for cascading update/delete happens
+	in above row_upd_step(), reset the counter once we come
+	out of the recursive call, so it does not accumulate for
+	different row deletes */
+	thr->fk_cascade_depth = 0;
+
 	err = trx->error_state;
 
 	/* Note that the cascade node is a subnode of another InnoDB
@@ -2120,7 +2146,7 @@ row_table_add_foreign_constraints(
 					      name, reject_fks);
 	if (err == DB_SUCCESS) {
 		/* Check that also referencing constraints are ok */
-		err = dict_load_foreigns(name, TRUE);
+		err = dict_load_foreigns(name, FALSE, TRUE);
 	}
 
 	if (err != DB_SUCCESS) {
@@ -2813,15 +2839,6 @@ row_truncate_table_for_mysql(
 
 	trx->table_id = table->id;
 
-	/* Lock all index trees for this table, as we will
-	truncate the table/index and possibly change their metadata.
-	All DML/DDL are blocked by table level lock, with
-	a few exceptions such as queries into information schema
-	about the table, MySQL could try to access index stats
-	for this kind of query, we need to use index locks to
-	sync up */
-	dict_table_x_lock_indexes(table);
-
 	if (table->space && !table->dir_path_of_temp_table) {
 		/* Discard and create the single-table tablespace. */
 		ulint	space	= table->space;
@@ -2834,6 +2851,11 @@ row_truncate_table_for_mysql(
 
 			dict_hdr_get_new_id(NULL, NULL, &space);
 
+			/* Lock all index trees for this table. We must
+			do so after dict_hdr_get_new_id() to preserve
+			the latch order */
+			dict_table_x_lock_indexes(table);
+
 			if (space == ULINT_UNDEFINED
 			    || fil_create_new_single_table_tablespace(
 				    space, table->name, FALSE, flags,
@@ -2867,6 +2889,15 @@ row_truncate_table_for_mysql(
 					FIL_IBD_FILE_INITIAL_SIZE, &mtr);
 			mtr_commit(&mtr);
 		}
+	} else {
+		/* Lock all index trees for this table, as we will
+		truncate the table/index and possibly change their metadata.
+		All DML/DDL are blocked by table level lock, with
+		a few exceptions such as queries into information schema
+		about the table, MySQL could try to access index stats
+		for this kind of query, we need to use index locks to
+		sync up */
+		dict_table_x_lock_indexes(table);
 	}
 
 	/* scan SYS_INDEXES for all indexes of the table */
@@ -3992,7 +4023,7 @@ end:
 		an ALTER, not in a RENAME. */
 
 		err = dict_load_foreigns(
-			new_name, !old_is_tmp || trx->check_foreigns);
+			new_name, FALSE, !old_is_tmp || trx->check_foreigns);
 
 		if (err != DB_SUCCESS) {
 			ut_print_timestamp(stderr);

=== modified file 'storage/innobase/srv/srv0start.c'
--- a/storage/innobase/srv/srv0start.c	2010-10-14 11:39:42 +0000
+++ b/storage/innobase/srv/srv0start.c	2010-10-22 06:34:57 +0000
@@ -120,11 +120,6 @@ UNIV_INTERN enum srv_shutdown_state	srv_
 /** Files comprising the system tablespace */
 static os_file_t	files[1000];
 
-/** Mutex protecting the ios count */
-static mutex_t		ios_mutex;
-/** Count of I/O operations in io_handler_thread() */
-static ulint		ios;
-
 /** io_handler_thread parameters for thread identification */
 static ulint		n[SRV_MAX_N_IO_THREADS + 6];
 /** io_handler_thread identifiers */
@@ -152,11 +147,6 @@ UNIV_INTERN mysql_pfs_key_t	srv_master_t
 UNIV_INTERN mysql_pfs_key_t	srv_purge_thread_key;
 #endif /* UNIV_PFS_THREAD */
 
-#ifdef UNIV_PFS_MUTEX
-/* Key to register ios_mutex_key with performance schema */
-UNIV_INTERN mysql_pfs_key_t	ios_mutex_key;
-#endif /* UNIV_PFS_MUTEX */
-
 /*********************************************************************//**
 Convert a numeric string that optionally ends in G or M, to a number
 containing megabytes.
@@ -491,10 +481,6 @@ io_handler_thread(
 
 	while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
 		fil_aio_wait(segment);
-
-		mutex_enter(&ios_mutex);
-		ios++;
-		mutex_exit(&ios_mutex);
 	}
 
 	/* We count the number of threads in os_thread_exit(). A created
@@ -998,10 +984,6 @@ skip_size_check:
 				srv_data_file_is_raw_partition[i] != 0);
 	}
 
-	ios = 0;
-
-	mutex_create(ios_mutex_key, &ios_mutex, SYNC_NO_ORDER_CHECK);
-
 	return(DB_SUCCESS);
 }
 

=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c	2010-10-21 11:22:27 +0000
+++ b/storage/innobase/trx/trx0trx.c	2010-10-27 01:45:58 +0000
@@ -753,8 +753,7 @@ trx_commit_off_kernel(
 		mutex_enter(&(rseg->mutex));
 
 		if (trx->insert_undo != NULL) {
-			trx_undo_set_state_at_finish(
-				rseg, trx, trx->insert_undo, &mtr);
+			trx_undo_set_state_at_finish(trx->insert_undo, &mtr);
 		}
 
 		undo = trx->update_undo;
@@ -769,7 +768,7 @@ trx_commit_off_kernel(
 			transaction commit for this transaction. */
 
 			update_hdr_page = trx_undo_set_state_at_finish(
-				rseg, trx, undo, &mtr);
+				undo, &mtr);
 
 			/* We have to do the cleanup for the update log while
 			holding the rseg mutex because update log headers

=== modified file 'storage/innobase/trx/trx0undo.c'
--- a/storage/innobase/trx/trx0undo.c	2010-10-01 13:36:35 +0000
+++ b/storage/innobase/trx/trx0undo.c	2010-10-27 01:45:58 +0000
@@ -1798,8 +1798,6 @@ UNIV_INTERN
 page_t*
 trx_undo_set_state_at_finish(
 /*=========================*/
-	trx_rseg_t*	rseg,	/*!< in: rollback segment memory object */
-	trx_t*		trx __attribute__((unused)), /*!< in: transaction */
 	trx_undo_t*	undo,	/*!< in: undo log memory copy */
 	mtr_t*		mtr)	/*!< in: mtr */
 {
@@ -1808,10 +1806,8 @@ trx_undo_set_state_at_finish(
 	page_t*		undo_page;
 	ulint		state;
 
-	ut_ad(trx);
 	ut_ad(undo);
 	ut_ad(mtr);
-	ut_ad(mutex_own(&rseg->mutex));
 
 	if (undo->id >= TRX_RSEG_N_SLOTS) {
 		fprintf(stderr, "InnoDB: Error: undo->id is %lu\n",
@@ -1830,19 +1826,7 @@ trx_undo_set_state_at_finish(
 	    && mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE)
 	       < TRX_UNDO_PAGE_REUSE_LIMIT) {
 
-		/* This is a heuristic to avoid the problem of all UNDO
-		slots ending up in one of the UNDO lists. Previously if
-		the server crashed with all the slots in one of the lists,
-		transactions that required the slots of a different type
-		would fail for lack of slots. */
-
-		if (UT_LIST_GET_LEN(rseg->update_undo_list) < 500
-		    && UT_LIST_GET_LEN(rseg->insert_undo_list) < 500) {
-
-			state = TRX_UNDO_CACHED;
-		} else {
-			state = TRX_UNDO_TO_FREE;
-		}
+		state = TRX_UNDO_CACHED;
 
 	} else if (undo->type == TRX_UNDO_INSERT) {
 

=== modified file 'storage/innobase/ut/ut0ut.c'
--- a/storage/innobase/ut/ut0ut.c	2010-06-22 15:58:28 +0000
+++ b/storage/innobase/ut/ut0ut.c	2010-10-06 13:55:34 +0000
@@ -693,6 +693,8 @@ ut_strerr(
 		return("Lock structs have exhausted the buffer pool");
 	case DB_FOREIGN_DUPLICATE_KEY:
 		return("Foreign key activated with duplicate keys");
+	case DB_FOREIGN_EXCEED_MAX_CASCADE:
+		return("Foreign key cascade delete/update exceeds max depth");
 	case DB_TOO_MANY_CONCURRENT_TRXS:
 		return("Too many concurrent transactions");
 	case DB_UNSUPPORTED:

=== modified file 'storage/perfschema/table_threads.cc'
--- a/storage/perfschema/table_threads.cc	2010-08-12 14:08:52 +0000
+++ b/storage/perfschema/table_threads.cc	2010-10-07 00:03:27 +0000
@@ -34,13 +34,13 @@ static const TABLE_FIELD_TYPE field_type
     { NULL, 0}
   },
   {
-    { C_STRING_WITH_LEN("ID") },
+    { C_STRING_WITH_LEN("PROCESSLIST_ID") },
     { C_STRING_WITH_LEN("int(11)") },
     { NULL, 0}
   },
   {
     { C_STRING_WITH_LEN("NAME") },
-    { C_STRING_WITH_LEN("varchar(64)") },
+    { C_STRING_WITH_LEN("varchar(128)") },
     { NULL, 0}
   }
 };
@@ -140,7 +140,7 @@ void table_threads::make_row(PFS_thread
 }
 
 int table_threads::read_row_values(TABLE *table,
-                                   unsigned char *,
+                                   unsigned char *buf,
                                    Field **fields,
                                    bool read_all)
 {
@@ -150,7 +150,8 @@ int table_threads::read_row_values(TABLE
     return HA_ERR_RECORD_DELETED;
 
   /* Set the null bits */
-  DBUG_ASSERT(table->s->null_bytes == 0);
+  DBUG_ASSERT(table->s->null_bytes == 1);
+  buf[0]= 0;
 
   for (; (f= *fields) ; fields++)
   {
@@ -161,7 +162,7 @@ int table_threads::read_row_values(TABLE
       case 0: /* THREAD_ID */
         set_field_ulong(f, m_row.m_thread_internal_id);
         break;
-      case 1: /* ID */
+      case 1: /* PROCESSLIST_ID */
         set_field_ulong(f, m_row.m_thread_id);
         break;
       case 2: /* NAME */

=== modified file 'storage/perfschema/table_threads.h'
--- a/storage/perfschema/table_threads.h	2010-08-12 14:08:52 +0000
+++ b/storage/perfschema/table_threads.h	2010-10-07 00:03:27 +0000
@@ -36,7 +36,7 @@ struct row_threads
 {
   /** Column THREAD_ID. */
   ulong m_thread_internal_id;
-  /** Column ID. */
+  /** Column PROCESSLIST_ID. */
   ulong m_thread_id;
   /** Column NAME. */
   const char *m_name;
@@ -79,7 +79,7 @@ private:
 
   /** Current row. */
   row_threads m_row;
-  /** True is the current row exists. */
+  /** True if the current row exists. */
   bool m_row_exists;
   /** Current position. */
   PFS_simple_index m_pos;

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2010-08-17 13:54:18 +0000
+++ b/support-files/mysql.spec.sh	2010-10-06 13:23:46 +0000
@@ -974,11 +974,17 @@ echo "====="
 %attr(755, root, root) %{_libdir}/mysql/plugin/mypluglib.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so
+%attr(755, root, root) %{_libdir}/mysql/plugin/auth.so
+%attr(755, root, root) %{_libdir}/mysql/plugin/auth_socket.so
+%attr(755, root, root) %{_libdir}/mysql/plugin/auth_test_plugin.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/debug/adt_null.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/debug/libdaemon_example.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/debug/mypluglib.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_master.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_slave.so
+%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth.so
+%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_socket.so
+%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_test_plugin.so
 
 %if %{WITH_TCMALLOC}
 %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target}
@@ -1075,6 +1081,10 @@ echo "====="
 # merging BK trees)
 ##############################################################################
 %changelog
+* Wed Oct 6 2010 Georgi Kodinov <georgi.godinov@stripped>
+
+- Added example external authentication (WL#1054) plugin binaries
+
 * Wed Aug 11 2010 Joerg Bruehe <joerg.bruehe@stripped>
 
 - With a recent spec file cleanup, names have changed: A "-community" part was dropped.

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-runtime branch (jon.hauglid:3174 to 3175) Jon Olav Hauglid29 Oct