List:Commits« Previous MessageNext Message »
From:Marc Alff Date:July 25 2011 6:12pm
Subject:bzr push into mysql-trunk-wl5378 branch (marc.alff:3364 to 3365)
View as plain text  
 3365 Marc Alff	2011-07-25 [merge]
      Merge mysql-trunk --> mysl-trunk-wl53878

    added:
      mysql-test/suite/perfschema/include/stage_cleanup.inc
      mysql-test/suite/perfschema/include/stage_setup.inc
      mysql-test/suite/perfschema/r/stage_mdl_function.result
      mysql-test/suite/perfschema/r/stage_mdl_global.result
      mysql-test/suite/perfschema/r/stage_mdl_procedure.result
      mysql-test/suite/perfschema/r/stage_mdl_table.result
      mysql-test/suite/perfschema/t/stage_mdl_function.test
      mysql-test/suite/perfschema/t/stage_mdl_global.test
      mysql-test/suite/perfschema/t/stage_mdl_procedure.test
      mysql-test/suite/perfschema/t/stage_mdl_table.test
    modified:
      client/mysql.cc
      client/mysql_upgrade.c
      client/mysqladmin.cc
      client/mysqlcheck.c
      client/mysqldump.c
      client/mysqlimport.c
      client/mysqlshow.c
      client/mysqltest.cc
      cmake/create_initial_db.cmake.in
      config.h.cmake
      configure.cmake
      dbug/dbug_analyze.c
      dbug/my_main.c
      dbug/tests.c
      include/my_sys.h
      mysql-test/collections/default.weekly
      mysql-test/r/func_if.result
      mysql-test/r/merge.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/parser.result
      mysql-test/suite/innodb/r/innodb_bug54044.result
      mysql-test/suite/innodb/t/innodb_bug54044.test
      mysql-test/suite/perfschema/r/ortho_iter.result
      mysql-test/suite/perfschema/r/privilege_table_io.result
      mysql-test/suite/perfschema/r/query_cache.result
      mysql-test/suite/perfschema/r/start_server_innodb.result
      mysql-test/suite/perfschema/r/start_server_no_cond_class.result
      mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
      mysql-test/suite/perfschema/r/start_server_no_file_class.result
      mysql-test/suite/perfschema/r/start_server_no_file_inst.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
      mysql-test/suite/perfschema/r/start_server_no_setup_actors.result
      mysql-test/suite/perfschema/r/start_server_no_setup_objects.result
      mysql-test/suite/perfschema/r/start_server_no_stages_history.result
      mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result
      mysql-test/suite/perfschema/r/start_server_no_statement_class.result
      mysql-test/suite/perfschema/r/start_server_no_statements_history.result
      mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result
      mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
      mysql-test/suite/perfschema/r/start_server_no_table_inst.result
      mysql-test/suite/perfschema/r/start_server_no_thread_class.result
      mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
      mysql-test/suite/perfschema/r/start_server_off.result
      mysql-test/suite/perfschema/r/start_server_on.result
      mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_off.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result
      mysql-test/suite/sys_vars/r/innodb_buffer_pool_filename_basic.result
      mysql-test/suite/sys_vars/t/innodb_buffer_pool_filename_basic.test
      mysql-test/t/func_if.test
      mysql-test/t/merge.test
      mysql-test/t/parser.test
      mysys/my_init.c
      mysys/my_static.c
      mysys/mysys_priv.h
      mysys/thr_lock.c
      plugin/semisync/semisync_master.cc
      plugin/semisync/semisync_master.h
      plugin/semisync/semisync_master_plugin.cc
      sql/CMakeLists.txt
      sql/binlog.cc
      sql/event_queue.cc
      sql/event_queue.h
      sql/event_scheduler.cc
      sql/event_scheduler.h
      sql/events.cc
      sql/events.h
      sql/field.cc
      sql/gen_lex_hash.cc
      sql/item_cmpfunc.cc
      sql/item_cmpfunc.h
      sql/mdl.cc
      sql/mdl.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/replication.h
      sql/rpl_master.cc
      sql/rpl_rli.cc
      sql/rpl_slave.cc
      sql/sql_base.cc
      sql/sql_cache.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_lex.cc
      sql/table.cc
      storage/innobase/fil/fil0fil.c
      storage/myisammrg/ha_myisammrg.cc
      storage/myisammrg/myrg_open.c
      storage/perfschema/pfs_server.h
      support-files/mysql.spec.sh
      unittest/gunit/CMakeLists.txt
      unittest/gunit/opt_trace-t.cc
      unittest/gunit/test_mdl_context_owner.h
 3364 Marc Alff	2011-07-25
      Improved tests

    modified:
      mysql-test/suite/perfschema/include/event_aggregate_cleanup.inc
      mysql-test/suite/perfschema/include/event_aggregate_load.inc
      mysql-test/suite/perfschema/include/event_aggregate_setup.inc
      mysql-test/suite/perfschema/include/table_aggregate_cleanup.inc
      mysql-test/suite/perfschema/include/table_aggregate_load.inc
      mysql-test/suite/perfschema/include/table_aggregate_setup.inc
      mysql-test/suite/perfschema/r/event_aggregate.result
      mysql-test/suite/perfschema/r/event_aggregate_no_h.result
      mysql-test/suite/perfschema/r/event_aggregate_no_u.result
      mysql-test/suite/perfschema/r/event_aggregate_no_u_no_h.result
      mysql-test/suite/perfschema/r/event_aggregate_no_uh.result
      mysql-test/suite/perfschema/r/event_aggregate_no_uh_no_h.result
      mysql-test/suite/perfschema/r/event_aggregate_no_uh_no_u.result
      mysql-test/suite/perfschema/r/event_aggregate_no_uh_no_u_no_h.result
      mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_off.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2011-07-03 23:56:47 +0000
+++ b/client/mysql.cc	2011-07-22 08:10:35 +0000
@@ -1289,7 +1289,7 @@ int main(int argc,char *argv[])
 	  mysql_thread_id(&mysql), server_version_string(&mysql));
   put_info((char*) glob_buffer.ptr(),INFO_INFO);
 
-  put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"), INFO_INFO);
+  put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"), INFO_INFO);
 
 #ifdef HAVE_READLINE
   initialize_readline((char*) my_progname);
@@ -1719,7 +1719,7 @@ static void usage(int version)
 
   if (version)
     return;
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   printf("Usage: %s [OPTIONS] [database]\n", my_progname);
   my_print_help(my_long_options);
   print_defaults("my", load_default_groups);

=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2011-06-30 15:50:45 +0000
+++ b/client/mysql_upgrade.c	2011-07-22 08:10:35 +0000
@@ -243,6 +243,7 @@ get_one_option(int optid, const struct m
   switch (optid) {
 
   case '?':
+    puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
     printf("%s  Ver %s Distrib %s, for %s (%s)\n",
            my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
     puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));

=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2011-06-30 15:50:45 +0000
+++ b/client/mysqladmin.cc	2011-07-22 08:10:35 +0000
@@ -696,7 +696,7 @@ static int execute_commands(MYSQL *mysql
     case ADMIN_VER:
       new_line=1;
       print_version();
-      puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+      puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
       printf("Server version\t\t%s\n", mysql_get_server_info(mysql));
       printf("Protocol version\t%d\n", mysql_get_proto_info(mysql));
       printf("Connection\t\t%s\n",mysql_get_host_info(mysql));
@@ -1094,7 +1094,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   puts("Administration program for the mysqld daemon.");
   printf("Usage: %s [OPTIONS] command command....\n", my_progname);
   my_print_help(my_long_options);

=== modified file 'client/mysqlcheck.c'
--- a/client/mysqlcheck.c	2011-06-30 15:50:45 +0000
+++ b/client/mysqlcheck.c	2011-07-22 08:10:35 +0000
@@ -228,7 +228,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   puts("This program can be used to CHECK (-c, -m, -C), REPAIR (-r), ANALYZE (-a),");
   puts("or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be");
   puts("used at the same time. Not all options are supported by all storage engines.");

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2011-07-04 00:25:46 +0000
+++ b/client/mysqldump.c	2011-07-22 08:10:35 +0000
@@ -55,6 +55,8 @@
 
 #include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
 
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
 /* Exit codes */
 
 #define EX_USAGE 1
@@ -603,7 +605,7 @@ static void short_usage_sub(void)
 static void usage(void)
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   puts("Dumping structure and contents of MySQL databases and tables.");
   short_usage_sub();
   print_defaults("my",load_default_groups);

=== modified file 'client/mysqlimport.c'
--- a/client/mysqlimport.c	2011-06-30 15:50:45 +0000
+++ b/client/mysqlimport.c	2011-07-22 08:10:35 +0000
@@ -18,14 +18,8 @@
 /*
 **	   mysqlimport.c  - Imports all given files
 **			    into a table(s).
-**
-**			   *************************
-**			   *			   *
-**			   * AUTHOR: Monty & Jani  *
-**			   * DATE:   June 24, 1997 *
-**			   *			   *
-**			   *************************
 */
+
 #define IMPORT_VERSION "3.7"
 
 #include "client_priv.h"
@@ -44,6 +38,8 @@ pthread_mutex_t counter_mutex;
 pthread_cond_t count_threshhold;
 #endif
 
+#include <welcome_copyright_notice.h>   /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
 static void db_error_with_table(MYSQL *mysql, char *table);
 static void db_error(MYSQL *mysql);
 static char *field_escape(char *to,const char *from,uint length);
@@ -207,7 +203,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   printf("\
 Loads tables from text files in various formats.  The base name of the\n\
 text file must be the name of the table that should be used.\n\

=== modified file 'client/mysqlshow.c'
--- a/client/mysqlshow.c	2011-06-30 15:50:45 +0000
+++ b/client/mysqlshow.c	2011-07-22 08:10:35 +0000
@@ -270,7 +270,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010)"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011)"));
   puts("Shows the structure of a MySQL database (databases, tables, and columns).\n");
   printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname);
   puts("\n\

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2011-07-20 10:29:12 +0000
+++ b/client/mysqltest.cc	2011-07-22 08:10:35 +0000
@@ -22,13 +22,6 @@
   http://dev.mysql.com/doc/mysqltest/en/index.html
 
   Please keep the test framework tools identical in all versions!
-
-  Written by:
-  Sasha Pachev <sasha@stripped>
-  Matt Wagner  <matt@stripped>
-  Monty
-  Jani
-  Holyfoot
 */
 
 #define MTEST_VERSION "3.3"
@@ -6424,7 +6417,7 @@ void print_version(void)
 void usage()
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   printf("Runs a test against the mysql server and compares output with a results file.\n\n");
   printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname);
   my_print_help(my_long_options);
@@ -7896,6 +7889,7 @@ void display_opt_trace(struct st_connect
 {
   if (!disable_query_log &&
       opt_trace_protocol_enabled &&
+      !cn->pending &&
       !command->expected_errors.count &&
       match_re(&opt_trace_re, command->query))
   {
@@ -7910,11 +7904,11 @@ void display_opt_trace(struct st_connect
     command->query_len= query_str.length;
     command->end= strend(command->query);
 
-    /* sorted trace is not readable at all*/
-    my_bool save_display_result_sorted= display_result_sorted;
+    /* Sorted trace is not readable at all, don't bother to lower case */
+    /* No need to keep old values, will be reset anyway */
     display_result_sorted= FALSE;
+    display_result_lower= FALSE;
     run_query(cn, command, flags);
-    display_result_sorted= save_display_result_sorted;
 
     dynstr_free(&query_str);
     *command= save_command;
@@ -7925,6 +7919,7 @@ void display_opt_trace(struct st_connect
 void run_explain(struct st_connection *cn, struct st_command *command, int flags)
 {
   if (explain_protocol_enabled &&
+      (flags & QUERY_REAP_FLAG) &&
       !command->expected_errors.count &&
       match_re(&explain_re, command->query))
   {

=== modified file 'cmake/create_initial_db.cmake.in'
--- a/cmake/create_initial_db.cmake.in	2011-06-30 15:50:45 +0000
+++ b/cmake/create_initial_db.cmake.in	2011-07-25 09:26:08 +0000
@@ -54,11 +54,11 @@ SET(BOOTSTRAP_COMMAND
   --no-defaults 
   ${CONSOLE}
   --bootstrap
-  --default-storage-engine=myisam
   --lc-messages-dir=${CMAKE_CURRENT_BINARY_DIR}/share
   --basedir=.
   --datadir=.
   --default-storage-engine=MyISAM
+  --default-temp-storage-engine=MyISAM
   --loose-skip-innodb
   --loose-skip-ndbcluster
   --max_allowed_packet=8M

=== modified file 'config.h.cmake'
--- a/config.h.cmake	2011-07-19 15:11:15 +0000
+++ b/config.h.cmake	2011-07-21 16:22:39 +0000
@@ -216,7 +216,6 @@
 #cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
 #cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
 #cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1
-#cmakedefine HAVE_PTHREAD_INIT 1
 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1
 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1
 #cmakedefine HAVE_PTHREAD_KILL 1

=== modified file 'configure.cmake'
--- a/configure.cmake	2011-07-03 23:56:47 +0000
+++ b/configure.cmake	2011-07-21 16:22:39 +0000
@@ -384,7 +384,6 @@ CHECK_FUNCTION_EXISTS (pthread_attr_sets
 CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
 CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
 CHECK_FUNCTION_EXISTS (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK)
-CHECK_FUNCTION_EXISTS (pthread_init HAVE_PTHREAD_INIT)
 CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE)
 CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK)
 CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK)

=== modified file 'dbug/dbug_analyze.c'
--- a/dbug/dbug_analyze.c	2011-01-11 09:09:21 +0000
+++ b/dbug/dbug_analyze.c	2011-07-21 16:22:39 +0000
@@ -571,9 +571,6 @@ int main (int argc, char **argv)
     FILE *infile;
     FILE *outfile = {stdout};
 
-#if defined(HAVE_PTHREAD_INIT)
-  pthread_init();                       /* Must be called before DBUG_ENTER */
-#endif
   my_thread_global_init(); 
   {
     DBUG_ENTER ("main");

=== modified file 'dbug/my_main.c'
--- a/dbug/my_main.c	2011-01-11 09:09:21 +0000
+++ b/dbug/my_main.c	2011-07-21 16:22:39 +0000
@@ -16,9 +16,6 @@ char *argv[];
 {
   register int result, ix;
   extern int factorial(int);
-#if defined(HAVE_PTHREAD_INIT)
-  pthread_init();			/* Must be called before DBUG_ENTER */
-#endif
   my_thread_global_init();
 
   {

=== modified file 'dbug/tests.c'
--- a/dbug/tests.c	2011-01-11 09:09:21 +0000
+++ b/dbug/tests.c	2011-07-21 16:22:39 +0000
@@ -44,9 +44,6 @@ int main (int argc, char *argv[])
   if (argc == 1)
     return 0;
 
-#if defined(HAVE_PTHREAD_INIT)
-  pthread_init();                       /* Must be called before DBUG_ENTER */
-#endif
   my_thread_global_init();
 
   dup2(1, 2);

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2011-07-19 15:11:15 +0000
+++ b/include/my_sys.h	2011-07-21 16:27:14 +0000
@@ -228,8 +228,8 @@ extern void (*fatal_error_handler_hook)(
 extern uint my_file_limit;
 extern ulong my_thread_stack_size;
 
-extern const char *(*proc_info_hook)(void *, const char *, const char *,
-                                     const char *, const unsigned int);
+extern void (*proc_info_hook)(void *, const PSI_stage_info *, PSI_stage_info *,
+                              const char *, const char *, const unsigned int);
 
 #ifdef HAVE_LARGE_PAGES
 extern my_bool my_use_large_pages;

=== modified file 'mysql-test/collections/default.weekly'
--- a/mysql-test/collections/default.weekly	2011-07-18 10:05:14 +0000
+++ b/mysql-test/collections/default.weekly	2011-07-25 04:38:18 +0000
@@ -45,31 +45,31 @@ perl mysql-test-run.pl --timer --force -
 # Repeat daily run
 # big-test option for normal runs 
 # Default suites in modes normal, binlog format mixed/row,embedded and ps-protocol
-perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=normal  --vardir=var-normal-big  --report-features --skip-test-list=collections/disabled-daily.list --unit-tests
-perl mysql-test-run.pl --force --timer  parallel=auto --experimental=collections/default.experimental --comment=n_mix  --vardir=var-n_mix  --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer  parallel=auto --experimental=collections/default.experimental --comment=row  --vardir=var-row  --mysqld=--binlog-format=row --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=normal  --vardir=var-normal-big  --report-features --skip-test-list=collections/disabled-daily.list --unit-tests
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=n_mix  --vardir=var-n_mix  --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=row  --vardir=var-row  --mysqld=--binlog-format=row --skip-test-list=collections/disabled-daily.list
 perl mysql-test-run.pl --force --timer   --parallel=auto --experimental=collections/default.experimental --comment=ps_row  --vardir=var-ps_row  --mysqld=--binlog-format=row     --ps-protocol --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer  parallel=auto --experimental=collections/default.experimental --comment=embedded  --vardir=var-embedded  --embedded
-perl mysql-test-run.pl --force --timer  parallel=auto --experimental=collections/default.experimental --comment=ps  --vardir=var-ps  --ps-protocol --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=embedded  --vardir=var-embedded  --embedded
+perl mysql-test-run.pl --force --timer  --parallel=auto --experimental=collections/default.experimental --comment=ps  --vardir=var-ps  --ps-protocol --skip-test-list=collections/disabled-daily.list
 
 # Run the suites that are not part of the default - funcs_2, parts, stress, jp, nist
-perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=funcs2-big  --vardir=var-funcs2-big  --suite=funcs_2
-perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=partitions-big  --vardir=var-parts-big --suite=parts
-perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=stress-big --vardir=var-stress-big  --suite=stress
-perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=jp-big --vardir=var-jp-big --suite=jp
-perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=nist-big  --vardir=var-nist-big --suite=nist
-perl mysql-test-run.pl --force --timer --testcase-timeout=60 parallel=auto --experimental=collections/default.experimental --comment=nist+ps --vardir=var-ps_nist  --suite=nist  --ps-protocol
+perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=funcs2-big  --vardir=var-funcs2-big  --suite=funcs_2
+perl mysql-test-run.pl --force --timer  --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=partitions-big  --vardir=var-parts-big --suite=parts
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=stress-big --vardir=var-stress-big  --suite=stress
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=jp-big --vardir=var-jp-big --suite=jp
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=nist-big  --vardir=var-nist-big --suite=nist
+perl mysql-test-run.pl --force --timer --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=nist+ps --vardir=var-ps_nist  --suite=nist  --ps-protocol
 
 
 # Additional  replication configurations
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=all_binlog_checksum --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --force --timer parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay --vardir=var-rpl_crash_safe_relay --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_master --vardir=var-rpl_crash_safe_master --suite=rpl --mysqld=--master-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay --vardir=var-rpl_crash_safe_relay --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_master --vardir=var-rpl_crash_safe_master --suite=rpl --mysqld=--master-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
 
 #Engine independent tests
-perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 parallel=auto  --comment=eits-tests-myisam-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam  --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force parallel=auto --comment=eits-rpl-binlog-row-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force parallel=auto  --comment=eits-rpl-binlog-mixed-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 parallel=auto --comment=eits-tests-innodb-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-innodb-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force parallel=auto --comment=eits-rpl-binlog-row-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --timer --force parallel=auto --comment=eits-rpl-binlog-mixed-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 --parallel=auto  --comment=eits-tests-myisam-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam  --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-row-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --parallel=auto  --comment=eits-rpl-binlog-mixed-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 --parallel=auto --comment=eits-tests-innodb-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-innodb-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-row-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=row --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-mixed-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list

=== modified file 'mysql-test/r/func_if.result'
--- a/mysql-test/r/func_if.result	2011-07-19 15:11:15 +0000
+++ b/mysql-test/r/func_if.result	2011-07-21 15:11:09 +0000
@@ -212,3 +212,17 @@ hello
 SELECT if(1, NULL, (SELECT min('hello')));
 if(1, NULL, (SELECT min('hello')))
 NULL
+#
+# Bug#12532830 
+# SIGFPE OR ASSERTION (PRECISION <= ((9 * 9) - 8*2)) && (DEC <= 30)
+#
+select
+sum(distinct(if('a',
+(select adddate(elt(convert(9999999999999999999999999999999999999,decimal(64,0)),count(*)),
+interval 1 day))
+, .1))) as foo;
+foo
+0.1
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: 'a'
+Warning	1292	Truncated incorrect DOUBLE value: 'a'

=== modified file 'mysql-test/r/merge.result'
--- a/mysql-test/r/merge.result	2011-03-26 10:56:27 +0000
+++ b/mysql-test/r/merge.result	2011-07-22 15:52:42 +0000
@@ -904,7 +904,8 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table 'test.t1' doesn't exist
+test.tm1	check	Error	Table 'test.t1' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 CREATE TABLE t1(a INT);
@@ -912,7 +913,7 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table 'test.t2' doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 CREATE TABLE t2(a BLOB);
@@ -920,7 +921,7 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Warning	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 ALTER TABLE t2 MODIFY a INT;
@@ -3635,7 +3636,7 @@ test.t1	analyze	Error	Unable to open und
 test.t1	analyze	error	Corrupt
 CHECK TABLE t1;
 Table	Op	Msg_type	Msg_text
-test.t1	check	Error	Table 'test.t_not_exists' doesn't exist
+test.t1	check	Error	Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist
 test.t1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.t1	check	error	Corrupt
 CHECKSUM TABLE t1;
@@ -3651,7 +3652,7 @@ test.t1	optimize	Error	Unable to open un
 test.t1	optimize	error	Corrupt
 REPAIR TABLE t1;
 Table	Op	Msg_type	Msg_text
-test.t1	repair	Error	Table 'test.t_not_exists' doesn't exist
+test.t1	repair	Error	Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist
 test.t1	repair	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.t1	repair	error	Corrupt
 REPAIR TABLE t1 USE_FRM;
@@ -3678,6 +3679,40 @@ ERROR HY000: Table 't1' was locked with
 UNLOCK TABLES;
 DROP TABLE m1, t1;
 #
+# Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL
+#                           PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1"
+#
+drop tables if exists t1, t2, t3, t4, m1;
+create table t1(id int) engine=myisam;
+create view t3 as select 1 as id;
+create table t4(id int) engine=memory;
+create table m1(id int) engine=merge union=(t1,t2,t3,t4);
+select * from m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+# The below CHECK and REPAIR TABLE statements should
+# report all problems with underlying tables: 
+# - absence of 't2',
+# - missing base table for 't3',
+# - wrong engine of 't4'.
+check table m1;
+Table	Op	Msg_type	Msg_text
+test.m1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	error	Corrupt
+repair table m1;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	error	Corrupt
+# Clean-up.
+drop tables m1, t1, t4;
+drop view t3;
+End of 5.5 tests
+#
 # Additional coverage for refactoring which is made as part
 # of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege
 # to allow temp table operations".
@@ -3766,4 +3801,3 @@ ERROR HY000: Unable to open underlying t
 DROP TRIGGER trg1;
 DROP TABLE t1;
 DROP TABLE m1;
-End of 6.0 tests

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2011-07-20 15:51:03 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2011-07-25 18:11:52 +0000
@@ -946,7 +946,7 @@ performance-schema-max-mutex-classes 200
 performance-schema-max-mutex-instances 1000000
 performance-schema-max-rwlock-classes 30
 performance-schema-max-rwlock-instances 1000000
-performance-schema-max-stage-classes 100
+performance-schema-max-stage-classes 150
 performance-schema-max-statement-classes 165
 performance-schema-max-table-handles 10000
 performance-schema-max-table-instances 1000

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2011-07-20 15:51:03 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2011-07-25 18:11:52 +0000
@@ -950,7 +950,7 @@ performance-schema-max-mutex-classes 200
 performance-schema-max-mutex-instances 1000000
 performance-schema-max-rwlock-classes 30
 performance-schema-max-rwlock-instances 1000000
-performance-schema-max-stage-classes 100
+performance-schema-max-stage-classes 150
 performance-schema-max-statement-classes 165
 performance-schema-max-table-handles 10000
 performance-schema-max-table-instances 1000

=== modified file 'mysql-test/r/parser.result'
--- a/mysql-test/r/parser.result	2010-09-09 13:04:25 +0000
+++ b/mysql-test/r/parser.result	2011-07-25 10:54:06 +0000
@@ -655,3 +655,7 @@ drop tablespace ndb_ts1 engine=myisam;
 ERROR HY000: Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP'
 drop tablespace ndb_ts1;
 ERROR HY000: Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP'
+CREATE TABLE t (id INT PRIMARY KEY);
+ALTER TABLE t RENAME TO `t1';;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`t1'' at line 1
+DROP TABLE t;

=== modified file 'mysql-test/suite/innodb/r/innodb_bug54044.result'
--- a/mysql-test/suite/innodb/r/innodb_bug54044.result	2010-06-29 07:14:20 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug54044.result	2011-07-22 09:32:04 +0000
@@ -1,3 +1,12 @@
 CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB
 AS SELECT IF(NULL  IS NOT NULL, NULL, NULL);
-ERROR HY000: Can't create table 'test.table_54044' (errno: -1)
+SHOW CREATE TABLE table_54044;
+Table	Create Table
+table_54044	CREATE TEMPORARY TABLE `table_54044` (
+  `IF(NULL  IS NOT NULL, NULL, NULL)` binary(0) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE table_54044;
+CREATE TABLE tmp ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL);
+ERROR HY000: Can't create table 'test.tmp' (errno: -1)
+CREATE TABLE tmp ENGINE = INNODB AS SELECT GREATEST(NULL, NULL);
+ERROR HY000: Can't create table 'test.tmp' (errno: -1)

=== modified file 'mysql-test/suite/innodb/t/innodb_bug54044.test'
--- a/mysql-test/suite/innodb/t/innodb_bug54044.test	2010-06-29 07:14:20 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug54044.test	2011-07-22 09:32:04 +0000
@@ -3,9 +3,17 @@
 
 --source include/have_innodb.inc
 
-# This 'create table' operation should fail because of
-# using NULL datatype
---error ER_CANT_CREATE_TABLE
+# This 'create table' operation no longer uses the NULL datatype.
+
 CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB
  AS SELECT IF(NULL  IS NOT NULL, NULL, NULL); 
+SHOW CREATE TABLE table_54044;
+DROP TABLE table_54044;
 
+# These 'create table' operations should fail because of
+# using NULL datatype
+
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE tmp ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL);
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE tmp ENGINE = INNODB AS SELECT GREATEST(NULL, NULL);

=== added file 'mysql-test/suite/perfschema/include/stage_cleanup.inc'
--- a/mysql-test/suite/perfschema/include/stage_cleanup.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/include/stage_cleanup.inc	2011-07-21 16:27:14 +0000
@@ -0,0 +1,46 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for the performance schema
+
+# ================================
+# HELPER include/stage_cleanup.inc
+# ================================
+
+--disable_query_log
+revoke all privileges, grant option from user1@localhost;
+revoke all privileges, grant option from user2@localhost;
+revoke all privileges, grant option from user3@localhost;
+revoke all privileges, grant option from user4@localhost;
+drop user user1@localhost;
+drop user user2@localhost;
+drop user user3@localhost;
+drop user user4@localhost;
+flush privileges;
+
+drop procedure dump_thread;
+drop procedure dump_one_thread;
+
+truncate table performance_schema.setup_actors;
+insert into performance_schema.setup_actors
+  select * from test.setup_actors;
+drop table test.setup_actors;
+drop table test.t1;
+
+update performance_schema.threads set instrumented='YES';
+update performance_schema.setup_instruments set enabled='YES', timed='YES';
+
+--enable_query_log
+

=== added file 'mysql-test/suite/perfschema/include/stage_setup.inc'
--- a/mysql-test/suite/perfschema/include/stage_setup.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/include/stage_setup.inc	2011-07-21 16:27:14 +0000
@@ -0,0 +1,156 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
+# Tests for the performance schema
+
+# =============
+# DOCUMENTATION
+# =============
+
+# Verify critical stages of a statement
+#
+# The tests are written with the following helpers:
+# - include/stage_setup.inc
+# - include/stage_cleanup.inc
+#
+# Helpers are intended to be used as follows.
+#
+# A Typical test t/stage_xxx.test will consist of:
+# --source ../include/stage_setup.inc
+# ... test specific payload ...
+# --source ../include/stage_cleanup.inc
+# and a t/stage_xxx-master.opt file
+#
+# ==============================
+# HELPER include/stage_setup.inc
+# ==============================
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# The file with expected results fits only to a run without
+# ps-protocol/sp-protocol/cursor-protocol/view-protocol.
+if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL
+            + $VIEW_PROTOCOL > 0`)
+{
+   --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled
+}
+
+--disable_query_log
+
+grant ALL on *.* to user1@localhost;
+grant ALL on *.* to user2@localhost;
+grant ALL on *.* to user3@localhost;
+grant ALL on *.* to user4@localhost;
+
+flush privileges;
+
+# Save the setup
+
+--disable_warnings
+drop table if exists test.setup_actors;
+drop table if exists test.t1;
+--enable_warnings
+
+create table test.t1(a varchar(64));
+
+create table test.setup_actors as
+  select * from performance_schema.setup_actors;
+
+# Only instrument the user connections
+truncate table performance_schema.setup_actors;
+insert into performance_schema.setup_actors
+  set host= 'localhost', user= 'user1', role= '%';
+insert into performance_schema.setup_actors
+  set host= 'localhost', user= 'user2', role= '%';
+insert into performance_schema.setup_actors
+  set host= 'localhost', user= 'user3', role= '%';
+insert into performance_schema.setup_actors
+  set host= 'localhost', user= 'user4', role= '%';
+
+update performance_schema.threads set instrumented='NO';
+
+# Only instrument a few events of each kind
+update performance_schema.setup_instruments set enabled='YES', timed='YES';
+
+# Start from a known clean state, to avoid noise from previous tests
+flush tables;
+flush status;
+truncate performance_schema.events_stages_summary_by_thread_by_event_name;
+truncate performance_schema.events_stages_summary_global_by_event_name;
+truncate performance_schema.events_stages_history;
+truncate performance_schema.events_stages_history_long;
+truncate performance_schema.events_statements_summary_by_thread_by_event_name;
+truncate performance_schema.events_statements_summary_global_by_event_name;
+truncate performance_schema.events_statements_history;
+truncate performance_schema.events_statements_history_long;
+
+--disable_warnings
+drop procedure if exists dump_thread;
+drop procedure if exists dump_one_thread;
+--enable_warnings
+
+delimiter $$;
+
+create procedure dump_thread()
+begin
+  call dump_one_thread('user1');
+  call dump_one_thread('user2');
+  call dump_one_thread('user3');
+  call dump_one_thread('user4');
+end
+$$
+
+create procedure dump_one_thread(in username varchar(64))
+begin
+  declare my_thread_id int;
+  declare my_statement_id int;
+
+  set my_thread_id = (select thread_id from performance_schema.threads
+                        where processlist_user=username);
+
+  if (my_thread_id is not null) then
+  begin
+    # Dump the current statement for this thread
+    select username, event_name, sql_text
+      from performance_schema.events_statements_current
+      where thread_id = my_thread_id;
+
+    # Get the current statement
+    set my_statement_id = (select event_id from
+      performance_schema.events_statements_current
+      where thread_id = my_thread_id);
+      
+    # Dump the stages for this statement
+    select username, event_name, nesting_event_type
+      from performance_schema.events_stages_current
+      where thread_id = my_thread_id
+      and nesting_event_id = my_statement_id
+      order by event_id asc;
+    select username, event_name, nesting_event_type
+      from performance_schema.events_stages_history
+      where thread_id = my_thread_id
+      and nesting_event_id = my_statement_id
+      order by event_id asc;
+  end;
+  else
+    select username, "not found" as status;
+  end if;
+end
+$$
+
+delimiter ;$$
+
+--enable_query_log

=== modified file 'mysql-test/suite/perfschema/r/ortho_iter.result'
--- a/mysql-test/suite/perfschema/r/ortho_iter.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/ortho_iter.result	2011-07-25 18:11:52 +0000
@@ -111,7 +111,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/privilege_table_io.result'
--- a/mysql-test/suite/perfschema/r/privilege_table_io.result	2011-07-18 09:49:22 +0000
+++ b/mysql-test/suite/perfschema/r/privilege_table_io.result	2011-07-25 18:11:52 +0000
@@ -35,7 +35,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/query_cache.result'
--- a/mysql-test/suite/perfschema/r/query_cache.result	2011-02-15 17:14:15 +0000
+++ b/mysql-test/suite/perfschema/r/query_cache.result	2011-07-21 16:27:14 +0000
@@ -38,7 +38,7 @@ spins
 NULL
 select name from performance_schema.setup_instruments order by name limit 1;
 name
-stage/sql/After create
+stage/mysys/Waiting for table level lock
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	1
@@ -53,7 +53,7 @@ spins
 NULL
 select name from performance_schema.setup_instruments order by name limit 1;
 name
-stage/sql/After create
+stage/mysys/Waiting for table level lock
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	1

=== added file 'mysql-test/suite/perfschema/r/stage_mdl_function.result'
--- a/mysql-test/suite/perfschema/r/stage_mdl_function.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/stage_mdl_function.result	2011-07-21 16:27:14 +0000
@@ -0,0 +1,34 @@
+drop function if exists test.f1;
+create function test.f1() returns int
+return 1;
+begin;
+select test.f1();
+test.f1()
+1
+drop function test.f1;
+call dump_one_thread('user1');
+username	event_name	sql_text
+user1	statement/sql/select	select test.f1()
+username	event_name	nesting_event_type
+username	event_name	nesting_event_type
+user1	stage/sql/System lock	STATEMENT
+user1	stage/sql/init	STATEMENT
+user1	stage/sql/optimizing	STATEMENT
+user1	stage/sql/executing	STATEMENT
+user1	stage/sql/Opening tables	STATEMENT
+user1	stage/sql/end	STATEMENT
+user1	stage/sql/query end	STATEMENT
+user1	stage/sql/closing tables	STATEMENT
+user1	stage/sql/freeing items	STATEMENT
+user1	stage/sql/cleaning up	STATEMENT
+call dump_one_thread('user2');
+username	event_name	sql_text
+user2	statement/sql/drop_function	drop function test.f1
+username	event_name	nesting_event_type
+user2	stage/sql/Waiting for stored function metadata lock	STATEMENT
+username	event_name	nesting_event_type
+user2	stage/sql/init	STATEMENT
+select f1();
+f1()
+1
+commit;

=== added file 'mysql-test/suite/perfschema/r/stage_mdl_global.result'
--- a/mysql-test/suite/perfschema/r/stage_mdl_global.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/stage_mdl_global.result	2011-07-21 16:27:14 +0000
@@ -0,0 +1,24 @@
+flush tables with read lock;
+insert into test.t1 values (1), (2), (3);
+call dump_one_thread('user1');
+username	event_name	sql_text
+user1	statement/sql/flush	flush tables with read lock
+username	event_name	nesting_event_type
+username	event_name	nesting_event_type
+user1	stage/sql/init	STATEMENT
+user1	stage/sql/Waiting for query cache lock	STATEMENT
+user1	stage/sql/init	STATEMENT
+user1	stage/sql/query end	STATEMENT
+user1	stage/sql/closing tables	STATEMENT
+user1	stage/sql/freeing items	STATEMENT
+user1	stage/sql/cleaning up	STATEMENT
+call dump_one_thread('user2');
+username	event_name	sql_text
+user2	statement/sql/insert	insert into test.t1 values (1), (2), (3)
+username	event_name	nesting_event_type
+user2	stage/sql/Waiting for global read lock	STATEMENT
+username	event_name	nesting_event_type
+user2	stage/sql/init	STATEMENT
+user2	stage/sql/checking permissions	STATEMENT
+user2	stage/sql/Opening tables	STATEMENT
+unlock tables;

=== added file 'mysql-test/suite/perfschema/r/stage_mdl_procedure.result'
--- a/mysql-test/suite/perfschema/r/stage_mdl_procedure.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/stage_mdl_procedure.result	2011-07-21 16:27:14 +0000
@@ -0,0 +1,42 @@
+drop function if exists test.f1;
+drop procedure if exists test.p1;
+create function test.f1() returns int
+begin
+call test.p1();
+return 1;
+end
+$$
+create procedure test.p1()
+begin end;
+begin;
+select test.f1();
+test.f1()
+1
+drop procedure test.p1;
+call dump_one_thread('user1');
+username	event_name	sql_text
+user1	statement/sql/select	select test.f1()
+username	event_name	nesting_event_type
+username	event_name	nesting_event_type
+user1	stage/sql/executing	STATEMENT
+user1	stage/sql/Opening tables	STATEMENT
+user1	stage/sql/query end	STATEMENT
+user1	stage/sql/closing tables	STATEMENT
+user1	stage/sql/Opening tables	STATEMENT
+user1	stage/sql/end	STATEMENT
+user1	stage/sql/query end	STATEMENT
+user1	stage/sql/closing tables	STATEMENT
+user1	stage/sql/freeing items	STATEMENT
+user1	stage/sql/cleaning up	STATEMENT
+call dump_one_thread('user2');
+username	event_name	sql_text
+user2	statement/sql/drop_procedure	drop procedure test.p1
+username	event_name	nesting_event_type
+user2	stage/sql/Waiting for stored procedure metadata lock	STATEMENT
+username	event_name	nesting_event_type
+user2	stage/sql/init	STATEMENT
+select test.f1();
+test.f1()
+1
+commit;
+drop function test.f1;

=== added file 'mysql-test/suite/perfschema/r/stage_mdl_table.result'
--- a/mysql-test/suite/perfschema/r/stage_mdl_table.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/stage_mdl_table.result	2011-07-21 16:27:14 +0000
@@ -0,0 +1,37 @@
+begin;
+insert into test.t1 values (1), (2), (3);
+commit;
+begin;
+select * from test.t1 for update;
+a
+1
+2
+3
+alter table test.t1 add column (b int);
+call dump_one_thread('user1');
+username	event_name	sql_text
+user1	statement/sql/select	select * from test.t1 for update
+username	event_name	nesting_event_type
+username	event_name	nesting_event_type
+user1	stage/sql/optimizing	STATEMENT
+user1	stage/sql/statistics	STATEMENT
+user1	stage/sql/preparing	STATEMENT
+user1	stage/sql/executing	STATEMENT
+user1	stage/sql/Sending data	STATEMENT
+user1	stage/sql/end	STATEMENT
+user1	stage/sql/query end	STATEMENT
+user1	stage/sql/closing tables	STATEMENT
+user1	stage/sql/freeing items	STATEMENT
+user1	stage/sql/cleaning up	STATEMENT
+call dump_one_thread('user2');
+username	event_name	sql_text
+user2	statement/sql/alter_table	alter table test.t1 add column (b int)
+username	event_name	nesting_event_type
+user2	stage/sql/Waiting for table metadata lock	STATEMENT
+username	event_name	nesting_event_type
+user2	stage/sql/init	STATEMENT
+user2	stage/sql/checking permissions	STATEMENT
+user2	stage/sql/checking permissions	STATEMENT
+user2	stage/sql/init	STATEMENT
+user2	stage/sql/Opening tables	STATEMENT
+commit;

=== modified file 'mysql-test/suite/perfschema/r/start_server_innodb.result'
--- a/mysql-test/suite/perfschema/r/start_server_innodb.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_innodb.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	0
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	0
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	0
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	0
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_actors.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_objects.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_stages_history.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_statement_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_statement_class.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_statement_class.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	0
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_statements_history.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_hdl.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	0
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	0

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_off.result'
--- a/mysql-test/suite/perfschema/r/start_server_off.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_off.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/start_server_on.result'
--- a/mysql-test/suite/perfschema/r/start_server_on.result	2011-05-07 04:28:13 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_on.result	2011-07-25 18:11:52 +0000
@@ -79,7 +79,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -58,7 +58,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -58,7 +58,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -56,7 +56,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -55,7 +55,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -56,7 +56,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -55,7 +55,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_off.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_off.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_off.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -58,7 +58,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -58,7 +58,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -60,7 +60,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -59,7 +59,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -60,7 +60,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -59,7 +59,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -58,7 +58,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -58,7 +58,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -60,7 +60,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -59,7 +59,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -60,7 +60,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -59,7 +59,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -60,7 +60,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -59,7 +59,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -60,7 +60,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -59,7 +59,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -58,7 +58,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -58,7 +58,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -57,7 +57,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result	2011-07-25 18:11:52 +0000
@@ -60,7 +60,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result	2011-07-25 18:11:52 +0000
@@ -59,7 +59,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result	2011-07-25 18:11:52 +0000
@@ -60,7 +60,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result	2011-07-25 17:40:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result	2011-07-25 18:11:52 +0000
@@ -59,7 +59,7 @@ performance_schema_max_mutex_classes	200
 performance_schema_max_mutex_instances	5000
 performance_schema_max_rwlock_classes	30
 performance_schema_max_rwlock_instances	5000
-performance_schema_max_stage_classes	100
+performance_schema_max_stage_classes	150
 performance_schema_max_statement_classes	165
 performance_schema_max_table_handles	1000
 performance_schema_max_table_instances	500

=== added file 'mysql-test/suite/perfschema/t/stage_mdl_function.test'
--- a/mysql-test/suite/perfschema/t/stage_mdl_function.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/stage_mdl_function.test	2011-07-25 14:05:36 +0000
@@ -0,0 +1,78 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for the performance schema
+#
+
+--source ../include/stage_setup.inc
+
+connect (con1, localhost, user1, , );
+
+--disable_warnings
+drop function if exists test.f1;
+--enable_warnings
+
+create function test.f1() returns int
+  return 1;
+
+begin;
+select test.f1();
+
+connect (con2, localhost, user2, , );
+
+# Will wait on con1, "Waiting for stored function metadata lock"
+--send
+drop function test.f1;
+
+--connection default
+
+# user1: Wait for the statement to complete
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+  and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the drop function to block
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
+  and PROCESSLIST_STATE = 'Waiting for stored function metadata lock';
+--source include/wait_condition.inc
+
+call dump_one_thread('user1');
+call dump_one_thread('user2');
+
+--connection con1
+select f1();
+commit;
+
+--disconnect con1
+
+--connection con2
+--reap
+
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnect to complete
+let $wait_condition=
+  select count(*) = 0 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
+--source include/wait_condition.inc
+
+--source ../include/stage_cleanup.inc
+

=== added file 'mysql-test/suite/perfschema/t/stage_mdl_global.test'
--- a/mysql-test/suite/perfschema/t/stage_mdl_global.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/stage_mdl_global.test	2011-07-25 14:05:36 +0000
@@ -0,0 +1,69 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for the performance schema
+#
+
+--source ../include/stage_setup.inc
+
+connect (con1, localhost, user1, , );
+
+flush tables with read lock;
+
+connect (con2, localhost, user2, , );
+
+# Will wait on con1, "Waiting for global read lock"
+--send
+insert into test.t1 values (1), (2), (3);
+
+--connection default
+
+# user1: Wait for the statement to complete
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+  and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the insert to block
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
+  and PROCESSLIST_STATE = 'Waiting for global read lock';
+--source include/wait_condition.inc
+
+call dump_one_thread('user1');
+call dump_one_thread('user2');
+
+--connection con1
+unlock tables;
+
+--disconnect con1
+
+--connection con2
+--reap
+
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnects to complete
+let $wait_condition=
+  select count(*) = 0 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
+--source include/wait_condition.inc
+
+--source ../include/stage_cleanup.inc
+

=== added file 'mysql-test/suite/perfschema/t/stage_mdl_procedure.test'
--- a/mysql-test/suite/perfschema/t/stage_mdl_procedure.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/stage_mdl_procedure.test	2011-07-25 14:05:36 +0000
@@ -0,0 +1,94 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for the performance schema
+#
+
+--source ../include/stage_setup.inc
+
+connect (con1, localhost, user1, , );
+
+--disable_warnings
+drop function if exists test.f1;
+drop procedure if exists test.p1;
+--enable_warnings
+
+delimiter $$;
+
+create function test.f1() returns int
+begin
+  call test.p1();
+  return 1;
+end
+$$
+
+delimiter ;$$
+
+create procedure test.p1()
+begin end;
+
+begin;
+# The procedure is in a sub statement,
+# so that the current transaction keeps a reference to it.
+select test.f1();
+
+connect (con2, localhost, user2, , );
+
+# Will wait on con1, "Waiting for stored procedure metadata lock"
+--send
+drop procedure test.p1;
+
+--connection default
+
+# user1: Wait for the statement to complete
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+  and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the drop procedure to block
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
+  and PROCESSLIST_STATE = 'Waiting for stored procedure metadata lock';
+--source include/wait_condition.inc
+
+call dump_one_thread('user1');
+call dump_one_thread('user2');
+
+--connection con1
+select test.f1();
+commit;
+
+--disconnect con1
+
+--connection con2
+--reap
+
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnect to complete
+let $wait_condition=
+  select count(*) = 0 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
+--source include/wait_condition.inc
+
+drop function test.f1;
+
+--source ../include/stage_cleanup.inc
+

=== added file 'mysql-test/suite/perfschema/t/stage_mdl_table.test'
--- a/mysql-test/suite/perfschema/t/stage_mdl_table.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/stage_mdl_table.test	2011-07-25 14:05:36 +0000
@@ -0,0 +1,74 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for the performance schema
+#
+
+--source ../include/stage_setup.inc
+
+connect (con1, localhost, user1, , );
+
+begin;
+insert into test.t1 values (1), (2), (3);
+commit;
+
+begin;
+select * from test.t1 for update;
+
+connect (con2, localhost, user2, , );
+
+# Will wait on con1, "Waiting for table metadata lock"
+--send
+alter table test.t1 add column (b int);
+
+--connection default
+
+# user1: Wait for the statement to complete
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+  and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the alter to block
+let $wait_condition=
+  select count(*) = 1 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
+  and PROCESSLIST_STATE = 'Waiting for table metadata lock';
+--source include/wait_condition.inc
+
+call dump_one_thread('user1');
+call dump_one_thread('user2');
+
+--connection con1
+commit;
+
+--disconnect con1
+
+--connection con2
+--reap
+
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnects to complete
+let $wait_condition=
+  select count(*) = 0 from performance_schema.threads
+  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
+--source include/wait_condition.inc
+
+--source ../include/stage_cleanup.inc
+

=== modified file 'mysql-test/suite/sys_vars/r/innodb_buffer_pool_filename_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_buffer_pool_filename_basic.result	2011-06-23 06:48:48 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_filename_basic.result	2011-07-25 17:25:37 +0000
@@ -3,6 +3,7 @@ SELECT @orig;
 @orig
 ib_buffer_pool
 SET GLOBAL innodb_buffer_pool_dump_now = ON;
+SET @orig = @@global.innodb_buffer_pool_filename;
 SET GLOBAL innodb_buffer_pool_filename = 'innodb_foobar_dump';
 SET GLOBAL innodb_buffer_pool_dump_now = ON;
 SET GLOBAL innodb_buffer_pool_filename = @orig;

=== modified file 'mysql-test/suite/sys_vars/t/innodb_buffer_pool_filename_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_filename_basic.test	2011-06-23 06:48:48 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_filename_basic.test	2011-07-25 17:25:37 +0000
@@ -4,7 +4,7 @@
 
 -- source include/have_innodb.inc
 
-# Check the default value and save for later restoration
+# Check the default value
 SET @orig = @@global.innodb_buffer_pool_filename;
 SELECT @orig;
 
@@ -24,6 +24,15 @@ let $wait_condition =
 
 # Try with a non-default filename
 
+# Restart the server so that the status gets reset to something other than
+# 'Buffer pool(s) dump completed at ', otherwise the following wait_condition
+# gets satisfied before the following dump has completed and --file_exists
+# fails
+-- source include/restart_mysqld.inc
+
+# Save for later restoration
+SET @orig = @@global.innodb_buffer_pool_filename;
+
 SET GLOBAL innodb_buffer_pool_filename = 'innodb_foobar_dump';
 
 SET GLOBAL innodb_buffer_pool_dump_now = ON;

=== modified file 'mysql-test/t/func_if.test'
--- a/mysql-test/t/func_if.test	2011-06-30 12:57:20 +0000
+++ b/mysql-test/t/func_if.test	2011-07-21 15:11:09 +0000
@@ -187,3 +187,15 @@ SELECT if(0, (SELECT min('hello')), NULL
 SELECT if(1, (SELECT min('hello')), NULL);
 SELECT if(0, NULL, (SELECT min('hello')));
 SELECT if(1, NULL, (SELECT min('hello')));
+
+--echo #
+--echo # Bug#12532830 
+--echo # SIGFPE OR ASSERTION (PRECISION <= ((9 * 9) - 8*2)) && (DEC <= 30)
+--echo #
+
+let $nines= 9999999999999999999999999999999999999;
+eval select
+sum(distinct(if('a',
+                (select adddate(elt(convert($nines,decimal(64,0)),count(*)),
+                                interval 1 day))
+                , .1))) as foo;

=== modified file 'mysql-test/t/merge.test'
--- a/mysql-test/t/merge.test	2011-03-26 10:56:27 +0000
+++ b/mysql-test/t/merge.test	2011-07-22 15:52:42 +0000
@@ -2800,6 +2800,34 @@ DROP TABLE m1, t1;
 
 
 --echo #
+--echo # Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL
+--echo #                           PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1"
+--echo #
+--disable_warnings
+drop tables if exists t1, t2, t3, t4, m1;
+--enable_warnings
+create table t1(id int) engine=myisam;
+create view t3 as select 1 as id;
+create table t4(id int) engine=memory;
+create table m1(id int) engine=merge union=(t1,t2,t3,t4);
+--error ER_WRONG_MRG_TABLE
+select * from m1;
+--echo # The below CHECK and REPAIR TABLE statements should
+--echo # report all problems with underlying tables: 
+--echo # - absence of 't2',
+--echo # - missing base table for 't3',
+--echo # - wrong engine of 't4'.
+check table m1;
+repair table m1;
+--echo # Clean-up.
+drop tables m1, t1, t4;
+drop view t3;
+
+
+--echo End of 5.5 tests
+
+
+--echo #
 --echo # Additional coverage for refactoring which is made as part
 --echo # of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege
 --echo # to allow temp table operations".
@@ -2877,7 +2905,6 @@ DROP TRIGGER trg1;
 DROP TABLE t1;
 DROP TABLE m1;
 
---echo End of 6.0 tests
 
 --disable_result_log
 --disable_query_log

=== modified file 'mysql-test/t/parser.test'
--- a/mysql-test/t/parser.test	2010-06-17 16:58:30 +0000
+++ b/mysql-test/t/parser.test	2011-07-25 10:54:06 +0000
@@ -776,3 +776,12 @@ drop logfile group ndb_lg1;
 drop tablespace ndb_ts1 engine=myisam;
 -- error ER_ILLEGAL_HA_CREATE_OPTION
 drop tablespace ndb_ts1;
+
+#
+# Bug#12546960 - 60993: NAME QUOTED WITH QUOTE INSTEAD OF BACKTICK 
+#                       GIVES NO SYNTAX ERROR
+#
+CREATE TABLE t (id INT PRIMARY KEY);
+--error ER_PARSE_ERROR
+--query ALTER TABLE t RENAME TO `t1';
+DROP TABLE t;

=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2011-06-30 15:50:45 +0000
+++ b/mysys/my_init.c	2011-07-21 21:37:55 +0000
@@ -19,6 +19,7 @@
 #include <m_string.h>
 #include <m_ctype.h>
 #include <signal.h>
+#include <mysql/psi/mysql_stage.h>
 #ifdef __WIN__
 #ifdef _MSC_VER
 #include <locale.h>
@@ -99,10 +100,6 @@ my_bool my_init(void)
   fastmutex_global_init();              /* Must be called early */
 #endif
 
-#if defined(HAVE_PTHREAD_INIT)
-  pthread_init();			/* Must be called before DBUG_ENTER */
-#endif
-
   /* $HOME is needed early to parse configuration files located in ~/ */
   if ((home_dir= getenv("HOME")) != 0)
     home_dir= intern_filename(home_dir_buff, home_dir);
@@ -538,6 +535,14 @@ static PSI_file_info all_mysys_files[]=
   { &key_file_cnf, "cnf", 0}
 };
 
+PSI_stage_info stage_waiting_for_table_level_lock=
+{0, "Waiting for table level lock", 0};
+
+PSI_stage_info *all_mysys_stages[]=
+{
+  & stage_waiting_for_table_level_lock
+};
+
 void my_init_mysys_psi_keys()
 {
   const char* category= "mysys";
@@ -556,6 +561,9 @@ void my_init_mysys_psi_keys()
 
   count= sizeof(all_mysys_files)/sizeof(all_mysys_files[0]);
   mysql_file_register(category, all_mysys_files, count);
+
+  count= array_elements(all_mysys_stages);
+  mysql_stage_register(category, all_mysys_stages, count);
 }
 #endif /* HAVE_PSI_INTERFACE */
 

=== modified file 'mysys/my_static.c'
--- a/mysys/my_static.c	2011-07-05 08:15:52 +0000
+++ b/mysys/my_static.c	2011-07-21 16:27:14 +0000
@@ -74,18 +74,19 @@ void (*error_handler_hook)(uint error, c
 void (*fatal_error_handler_hook)(uint error, const char *str, myf MyFlags)=
   my_message_stderr;
 
-static const char *proc_info_dummy(void *a __attribute__((unused)),
-                                   const char *b __attribute__((unused)),
-                                   const char *c __attribute__((unused)),
-                                   const char *d __attribute__((unused)),
-                                   const unsigned int e __attribute__((unused)))
+static void proc_info_dummy(void *a __attribute__((unused)),
+                            const PSI_stage_info *b __attribute__((unused)),
+                            PSI_stage_info *c __attribute__((unused)),
+                            const char *d __attribute__((unused)),
+                            const char *e __attribute__((unused)),
+                            const unsigned int f __attribute__((unused)))
 {
-  return 0;
+  return;
 }
 
 /* this is to be able to call set_thd_proc_info from the C code */
-const char *(*proc_info_hook)(void *, const char *, const char *, const char *,
-                              const unsigned int)= proc_info_dummy;
+void (*proc_info_hook)(void *, const PSI_stage_info *, PSI_stage_info *,
+                       const char *, const char *, const unsigned int)= proc_info_dummy;
 
 #if defined(ENABLED_DEBUG_SYNC)
 /**

=== modified file 'mysys/mysys_priv.h'
--- a/mysys/mysys_priv.h	2011-06-30 15:50:45 +0000
+++ b/mysys/mysys_priv.h	2011-07-21 16:27:14 +0000
@@ -52,6 +52,8 @@ extern PSI_cond_key key_COND_alarm, key_
 extern PSI_thread_key key_thread_alarm;
 #endif /* USE_ALARM_THREAD */
 
+extern PSI_stage_info stage_waiting_for_table_level_lock;
+
 #endif /* HAVE_PSI_INTERFACE */
 
 extern mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;

=== modified file 'mysys/thr_lock.c'
--- a/mysys/thr_lock.c	2011-06-30 15:50:45 +0000
+++ b/mysys/thr_lock.c	2011-07-21 16:27:14 +0000
@@ -400,7 +400,7 @@ wait_for_lock(struct st_lock_list *wait,
   mysql_cond_t *cond= &thread_var->suspend;
   struct timespec wait_timeout;
   enum enum_thr_lock_result result= THR_LOCK_ABORTED;
-  const char *old_proc_info;
+  PSI_stage_info old_stage;
   DBUG_ENTER("wait_for_lock");
 
   /*
@@ -439,8 +439,9 @@ wait_for_lock(struct st_lock_list *wait,
   thread_var->current_cond=  cond;
   data->cond= cond;
 
-  old_proc_info= proc_info_hook(NULL, "Waiting for table level lock",
-                                __func__, __FILE__, __LINE__);
+  proc_info_hook(NULL, &stage_waiting_for_table_level_lock,
+                 &old_stage,
+                 __func__, __FILE__, __LINE__);
 
   /*
     Since before_lock_wait potentially can create more threads to
@@ -530,7 +531,7 @@ wait_for_lock(struct st_lock_list *wait,
   thread_var->current_cond=  0;
   mysql_mutex_unlock(&thread_var->mutex);
 
-  proc_info_hook(NULL, old_proc_info, __func__, __FILE__, __LINE__);
+  proc_info_hook(NULL, &old_stage, NULL, __func__, __FILE__, __LINE__);
 
   DBUG_RETURN(result);
 }

=== modified file 'plugin/semisync/semisync_master.cc'
--- a/plugin/semisync/semisync_master.cc	2011-06-30 15:46:53 +0000
+++ b/plugin/semisync/semisync_master.cc	2011-07-21 16:27:14 +0000
@@ -608,7 +608,7 @@ int ReplSemiSyncMaster::commitTrx(const
     struct timespec start_ts;
     struct timespec abstime;
     int wait_result;
-    const char *old_msg= 0;
+    PSI_stage_info old_stage;
 
     set_timespec(start_ts, 0);
 
@@ -616,8 +616,9 @@ int ReplSemiSyncMaster::commitTrx(const
     lock();
 
     /* This must be called after acquired the lock */
-    old_msg= thd_enter_cond(NULL, &COND_binlog_send_, &LOCK_binlog_,
-                            "Waiting for semi-sync ACK from slave");
+    THD_ENTER_COND(NULL, &COND_binlog_send_, &LOCK_binlog_,
+                   & stage_waiting_for_semi_sync_ack_from_slave,
+                   & old_stage);
 
     /* This is the real check inside the mutex. */
     if (!getMasterEnabled() || !is_on())
@@ -763,7 +764,7 @@ int ReplSemiSyncMaster::commitTrx(const
 
     /* The lock held will be released by thd_exit_cond, so no need to
        call unlock() here */
-    thd_exit_cond(NULL, old_msg);
+    THD_EXIT_COND(NULL, & old_stage);
   }
 
   return function_exit(kWho, 0);

=== modified file 'plugin/semisync/semisync_master.h'
--- a/plugin/semisync/semisync_master.h	2011-06-30 15:46:53 +0000
+++ b/plugin/semisync/semisync_master.h	2011-07-21 16:27:14 +0000
@@ -26,6 +26,8 @@ extern PSI_mutex_key key_ss_mutex_LOCK_b
 extern PSI_cond_key key_ss_cond_COND_binlog_send_;
 #endif
 
+extern PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave;
+
 struct TranxNode {
   char             log_name_[FN_REFLEN];
   my_off_t          log_pos_;

=== modified file 'plugin/semisync/semisync_master_plugin.cc'
--- a/plugin/semisync/semisync_master_plugin.cc	2011-06-30 15:50:45 +0000
+++ b/plugin/semisync/semisync_master_plugin.cc	2011-07-21 16:27:14 +0000
@@ -354,6 +354,16 @@ static PSI_cond_info all_semisync_conds[
 {
   { &key_ss_cond_COND_binlog_send_, "COND_binlog_send_", 0}
 };
+#endif /* HAVE_PSI_INTERFACE */
+
+PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave=
+{ 0, "Waiting for semi-sync ACK from slave", 0};
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_stage_info *all_semisync_stages[]=
+{
+  & stage_waiting_for_semi_sync_ack_from_slave
+};
 
 static void init_semisync_psi_keys(void)
 {
@@ -365,6 +375,9 @@ static void init_semisync_psi_keys(void)
 
   count= array_elements(all_semisync_conds);
   mysql_cond_register(category, all_semisync_conds, count);
+
+  count= array_elements(all_semisync_stages);
+  mysql_stage_register(category, all_semisync_stages, count);
 }
 #endif /* HAVE_PSI_INTERFACE */
 

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2011-07-20 10:29:12 +0000
+++ b/sql/CMakeLists.txt	2011-07-22 07:21:40 +0000
@@ -207,7 +207,7 @@ ADD_LIBRARY(slave ${SLAVE_SOURCE})
 ADD_DEPENDENCIES(slave GenError)
 ADD_LIBRARY(sqlgunitlib
   filesort_utils.cc mdl.cc sql_list.cc sql_string.cc thr_malloc.cc
-  opt_trace.cc)
+  )
 ADD_DEPENDENCIES(sqlgunitlib GenError)
 
 

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2011-06-09 08:58:41 +0000
+++ b/sql/binlog.cc	2011-07-21 16:27:14 +0000
@@ -4255,15 +4255,14 @@ err:
 
 void MYSQL_BIN_LOG::wait_for_update_relay_log(THD* thd)
 {
-  const char *old_msg;
+  PSI_stage_info old_stage;
   DBUG_ENTER("wait_for_update_relay_log");
 
-  old_msg= thd->enter_cond(&update_cond, &LOCK_log,
-                           "Slave has read all relay log; "
-                           "waiting for the slave I/O "
-                           "thread to update it" );
+  thd->ENTER_COND(&update_cond, &LOCK_log,
+                  &stage_slave_has_read_all_relay_log,
+                  &old_stage);
   mysql_cond_wait(&update_cond, &LOCK_log);
-  thd->exit_cond(old_msg);
+  thd->EXIT_COND(&old_stage);
   DBUG_VOID_RETURN;
 }
 

=== modified file 'sql/event_queue.cc'
--- a/sql/event_queue.cc	2011-06-30 15:50:45 +0000
+++ b/sql/event_queue.cc	2011-07-21 16:27:14 +0000
@@ -544,9 +544,6 @@ Event_queue::dbug_dump_queue(time_t now)
 #endif
 }
 
-static const char *queue_empty_msg= "Waiting on empty queue";
-static const char *queue_wait_msg= "Waiting for next activation";
-
 /*
   Checks whether the top of the queue is elligible for execution and
   returns an Event_job_data instance in case it should be executed.
@@ -593,7 +590,7 @@ Event_queue::get_top_for_execution_if_ti
       mysql_audit_release(thd);
 
       /* Wait on condition until signaled. Release LOCK_queue while waiting. */
-      cond_wait(thd, NULL, queue_empty_msg, SCHED_FUNC, __LINE__);
+      cond_wait(thd, NULL, & stage_waiting_on_empty_queue, SCHED_FUNC, __FILE__, __LINE__);
 
       continue;
     }
@@ -615,7 +612,7 @@ Event_queue::get_top_for_execution_if_ti
       /* Release any held audit resources before waiting */
       mysql_audit_release(thd);
 
-      cond_wait(thd, &top_time, queue_wait_msg, SCHED_FUNC, __LINE__);
+      cond_wait(thd, &top_time, &stage_waiting_for_next_activation, SCHED_FUNC, __FILE__, __LINE__);
 
       continue;
     }
@@ -746,16 +743,16 @@ Event_queue::unlock_data(const char *fun
 */
 
 void
-Event_queue::cond_wait(THD *thd, struct timespec *abstime, const char* msg,
-                       const char *func, uint line)
+Event_queue::cond_wait(THD *thd, struct timespec *abstime, const PSI_stage_info *stage,
+                       const char *src_func, const char *src_file, uint src_line)
 {
   DBUG_ENTER("Event_queue::cond_wait");
   waiting_on_cond= TRUE;
-  mutex_last_unlocked_at_line= line;
+  mutex_last_unlocked_at_line= src_line;
   mutex_queue_data_locked= FALSE;
-  mutex_last_unlocked_in_func= func;
+  mutex_last_unlocked_in_func= src_func;
 
-  thd->enter_cond(&COND_queue_state, &LOCK_event_queue, msg);
+  thd->enter_cond(&COND_queue_state, &LOCK_event_queue, stage, NULL, src_func, src_file, src_line);
 
   if (!thd->killed)
   {
@@ -765,8 +762,8 @@ Event_queue::cond_wait(THD *thd, struct
       mysql_cond_timedwait(&COND_queue_state, &LOCK_event_queue, abstime);
   }
 
-  mutex_last_locked_in_func= func;
-  mutex_last_locked_at_line= line;
+  mutex_last_locked_in_func= src_func;
+  mutex_last_locked_at_line= src_line;
   mutex_queue_data_locked= TRUE;
   waiting_on_cond= FALSE;
 
@@ -774,8 +771,8 @@ Event_queue::cond_wait(THD *thd, struct
     This will free the lock so we need to relock. Not the best thing to
     do but we need to obey cond_wait()
   */
-  thd->exit_cond("");
-  lock_data(func, line);
+  thd->exit_cond(NULL, src_func, src_file, src_line);
+  lock_data(src_func, src_line);
 
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/event_queue.h'
--- a/sql/event_queue.h	2011-06-30 15:50:45 +0000
+++ b/sql/event_queue.h	2011-07-21 16:27:14 +0000
@@ -94,8 +94,8 @@ private:
   unlock_data(const char *func, uint line);
 
   void
-  cond_wait(THD *thd, struct timespec *abstime, const char* msg,
-            const char *func, uint line);
+  cond_wait(THD *thd, struct timespec *abstime, const PSI_stage_info *stage,
+            const char *src_func, const char *src_file, uint src_line);
 
   void
   find_n_remove_event(LEX_STRING db, LEX_STRING name);

=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc	2011-07-03 23:56:47 +0000
+++ b/sql/event_scheduler.cc	2011-07-21 16:27:14 +0000
@@ -38,8 +38,8 @@
 
 #define LOCK_DATA()       lock_data(SCHED_FUNC, __LINE__)
 #define UNLOCK_DATA()     unlock_data(SCHED_FUNC, __LINE__)
-#define COND_STATE_WAIT(mythd, abstime, msg) \
-        cond_wait(mythd, abstime, msg, SCHED_FUNC, __LINE__)
+#define COND_STATE_WAIT(mythd, abstime, stage) \
+        cond_wait(mythd, abstime, stage, SCHED_FUNC, __FILE__, __LINE__)
 
 extern pthread_attr_t connection_attrib;
 
@@ -622,7 +622,7 @@ Event_scheduler::stop()
   {
     /* Synchronously wait until the scheduler stops. */
     while (state != INITIALIZED)
-      COND_STATE_WAIT(thd, NULL, "Waiting for the scheduler to stop");
+      COND_STATE_WAIT(thd, NULL, &stage_waiting_for_scheduler_to_stop);
     goto end;
   }
 
@@ -657,7 +657,7 @@ Event_scheduler::stop()
     /* thd could be 0x0, when shutting down */
     sql_print_information("Event Scheduler: "
                           "Waiting for the scheduler thread to reply");
-    COND_STATE_WAIT(thd, NULL, "Waiting scheduler to stop");
+    COND_STATE_WAIT(thd, NULL, &stage_waiting_for_scheduler_to_stop);
   } while (state == STOPPING);
   DBUG_PRINT("info", ("Scheduler thread has cleaned up. Set state to INIT"));
   sql_print_information("Event Scheduler: Stopped");
@@ -751,16 +751,17 @@ Event_scheduler::unlock_data(const char
 */
 
 void
-Event_scheduler::cond_wait(THD *thd, struct timespec *abstime, const char* msg,
-                           const char *func, uint line)
+Event_scheduler::cond_wait(THD *thd, struct timespec *abstime, const PSI_stage_info *stage,
+                           const char *src_func, const char *src_file, uint src_line)
 {
   DBUG_ENTER("Event_scheduler::cond_wait");
   waiting_on_cond= TRUE;
-  mutex_last_unlocked_at_line= line;
+  mutex_last_unlocked_at_line= src_line;
   mutex_scheduler_data_locked= FALSE;
-  mutex_last_unlocked_in_func= func;
+  mutex_last_unlocked_in_func= src_func;
   if (thd)
-    thd->enter_cond(&COND_state, &LOCK_scheduler_state, msg);
+    thd->enter_cond(&COND_state, &LOCK_scheduler_state, stage,
+                    NULL, src_func, src_file, src_line);
 
   DBUG_PRINT("info", ("mysql_cond_%swait", abstime? "timed":""));
   if (!abstime)
@@ -773,11 +774,11 @@ Event_scheduler::cond_wait(THD *thd, str
       This will free the lock so we need to relock. Not the best thing to
       do but we need to obey cond_wait()
     */
-    thd->exit_cond("");
+    thd->exit_cond(NULL, src_func, src_file, src_line);
     LOCK_DATA();
   }
-  mutex_last_locked_in_func= func;
-  mutex_last_locked_at_line= line;
+  mutex_last_locked_in_func= src_func;
+  mutex_last_locked_at_line= src_line;
   mutex_scheduler_data_locked= TRUE;
   waiting_on_cond= FALSE;
   DBUG_VOID_RETURN;

=== modified file 'sql/event_scheduler.h'
--- a/sql/event_scheduler.h	2011-06-30 15:50:45 +0000
+++ b/sql/event_scheduler.h	2011-07-21 16:27:14 +0000
@@ -114,8 +114,8 @@ private:
   unlock_data(const char *func, uint line);
 
   void
-  cond_wait(THD *thd, struct timespec *abstime, const char* msg,
-            const char *func, uint line);
+  cond_wait(THD *thd, struct timespec *abstime, const PSI_stage_info *stage,
+            const char *src_func, const char *src_file, uint src_line);
 
   mysql_mutex_t LOCK_scheduler_state;
 

=== modified file 'sql/events.cc'
--- a/sql/events.cc	2011-07-04 00:25:46 +0000
+++ b/sql/events.cc	2011-07-21 16:27:14 +0000
@@ -945,6 +945,19 @@ static PSI_thread_info all_events_thread
   { &key_thread_event_scheduler, "event_scheduler", PSI_FLAG_GLOBAL},
   { &key_thread_event_worker, "event_worker", 0}
 };
+#endif /* HAVE_PSI_INTERFACE */
+
+PSI_stage_info stage_waiting_on_empty_queue= { 0, "Waiting on empty queue", 0};
+PSI_stage_info stage_waiting_for_next_activation= { 0, "Waiting for next activation", 0};
+PSI_stage_info stage_waiting_for_scheduler_to_stop= { 0, "Waiting for the scheduler to stop", 0};
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_stage_info *all_events_stages[]=
+{
+  & stage_waiting_on_empty_queue,
+  & stage_waiting_for_next_activation,
+  & stage_waiting_for_scheduler_to_stop
+};
 
 static void init_events_psi_keys(void)
 {
@@ -959,6 +972,10 @@ static void init_events_psi_keys(void)
 
   count= array_elements(all_events_threads);
   mysql_thread_register(category, all_events_threads, count);
+
+  count= array_elements(all_events_stages);
+  mysql_stage_register(category, all_events_stages, count);
+
 }
 #endif /* HAVE_PSI_INTERFACE */
 

=== modified file 'sql/events.h'
--- a/sql/events.h	2010-11-18 16:34:56 +0000
+++ b/sql/events.h	2011-07-21 16:27:14 +0000
@@ -31,6 +31,11 @@ extern PSI_cond_key key_event_scheduler_
 extern PSI_thread_key key_thread_event_scheduler, key_thread_event_worker;
 #endif /* HAVE_PSI_INTERFACE */
 
+/* Always defined, for SHOW PROCESSLIST. */
+extern PSI_stage_info stage_waiting_on_empty_queue;
+extern PSI_stage_info stage_waiting_for_next_activation;
+extern PSI_stage_info stage_waiting_for_scheduler_to_stop;
+
 #include "sql_string.h"                         /* LEX_STRING */
 #include "my_time.h"                            /* interval_type */
 

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2011-07-04 00:25:46 +0000
+++ b/sql/field.cc	2011-07-21 15:11:09 +0000
@@ -9190,8 +9190,9 @@ void Create_field::init_for_tmp_table(en
     pack_flag= FIELDFLAG_INTERVAL;
     break;
 
-  case MYSQL_TYPE_DECIMAL:
   case MYSQL_TYPE_NEWDECIMAL:
+    DBUG_ASSERT(decimals_arg <= DECIMAL_MAX_SCALE);
+  case MYSQL_TYPE_DECIMAL:
   case MYSQL_TYPE_FLOAT:
   case MYSQL_TYPE_DOUBLE:
     pack_flag= FIELDFLAG_NUMBER |

=== modified file 'sql/gen_lex_hash.cc'
--- a/sql/gen_lex_hash.cc	2011-06-30 15:50:45 +0000
+++ b/sql/gen_lex_hash.cc	2011-07-22 08:10:35 +0000
@@ -1,4 +1,5 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/*
+   Copyright (c) 2000, 2011, 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
@@ -84,6 +85,8 @@ So, we can read full search-structure as
 #include <stdio.h>
 #include <string.h>
 
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
 struct hash_lex_struct
 {
   int first_char;
@@ -373,24 +376,9 @@ int main(int argc,char **argv)
   /* Broken up to indicate that it's not advice to you, gentle reader. */
   printf("/*\n\n  Do " "not " "edit " "this " "file " "directly!\n\n*/\n");
 
-  printf("\
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.\n\
-\n\
-   This program is free software; you can redistribute it and/or modify\n\
-   it under the terms of the GNU General Public License as published by\n\
-   the Free Software Foundation; version 2 of the License.\n\
-\n\
-   This program is distributed in the hope that it will be useful,\n\
-   but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\
-   GNU General Public License for more details.\n\
-\n\
-   You should have received a copy of the GNU General Public License\n\
-   along with this program; see the file COPYING. If not, write to the\n\
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston\n\
-   MA  02110-1301  USA. */\n\
-\n\
-");
+  puts("/*");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
+  puts("*/");
 
   /* Broken up to indicate that it's not advice to you, gentle reader. */
   printf("/* Do " "not " "edit " "this " "file!  This is generated by "

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2011-07-19 15:11:15 +0000
+++ b/sql/item_cmpfunc.cc	2011-07-21 15:11:09 +0000
@@ -2720,37 +2720,43 @@ Item_func_if::fix_fields(THD *thd, Item
 }
 
 
-void
-Item_func_if::fix_length_and_dec()
+void Item_func_if::cache_type_info(Item *source)
 {
-  maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-  decimals= max(args[1]->decimals, args[2]->decimals);
-  unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
+  collation.set(source->collation);
+  cached_field_type=  source->field_type();
+  cached_result_type= source->result_type();
+  decimals=           source->decimals;
+  max_length=         source->max_length;
+  maybe_null=         source->maybe_null;
+  unsigned_flag=      source->unsigned_flag;
+}
 
-  enum Item_result arg1_type=args[1]->result_type();
-  enum Item_result arg2_type=args[2]->result_type();
-  bool null1=args[1]->const_item() && args[1]->null_value;
-  bool null2=args[2]->const_item() && args[2]->null_value;
 
-  if (null1 && args[2]->type() != NULL_ITEM)
+void
+Item_func_if::fix_length_and_dec()
+{
+  // Let IF(cond, expr, NULL) and IF(cond, NULL, expr) inherit type from expr.
+  if (args[1]->type() == NULL_ITEM)
   {
-    cached_result_type= arg2_type;
-    collation.set(args[2]->collation);
-    cached_field_type= args[2]->field_type();
-    max_length= args[2]->max_length;
+    cache_type_info(args[2]);
+    maybe_null= true;
+    // If both arguments are NULL, make resulting type BINARY(0).
+    if (args[2]->type() == NULL_ITEM)
+      cached_field_type= MYSQL_TYPE_STRING;
     return;
   }
-
-  if (null2 && args[1]->type() != NULL_ITEM)
+  if (args[2]->type() == NULL_ITEM)
   {
-    cached_result_type= arg1_type;
-    collation.set(args[1]->collation);
-    cached_field_type= args[1]->field_type();
-    max_length= args[1]->max_length;
+    cache_type_info(args[1]);
+    maybe_null= true;
     return;
   }
 
   agg_result_type(&cached_result_type, args + 1, 2);
+  maybe_null= args[1]->maybe_null || args[2]->maybe_null;
+  decimals= max(args[1]->decimals, args[2]->decimals);
+  unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
+
   if (cached_result_type == STRING_RESULT)
   {
     if (agg_arg_charsets_for_string_result(collation, args + 1, 2))

=== modified file 'sql/item_cmpfunc.h'
--- a/sql/item_cmpfunc.h	2011-07-19 15:11:15 +0000
+++ b/sql/item_cmpfunc.h	2011-07-21 15:11:09 +0000
@@ -818,6 +818,8 @@ public:
   void fix_length_and_dec();
   uint decimal_precision() const;
   const char *func_name() const { return "if"; }
+private:
+  void cache_type_info(Item *source);
 };
 
 

=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc	2011-06-30 15:50:45 +0000
+++ b/sql/mdl.cc	2011-07-21 16:27:14 +0000
@@ -20,6 +20,7 @@
 #include <mysqld_error.h>
 #include <mysql/plugin.h>
 #include <mysql/service_thd_wait.h>
+#include <mysql/psi/mysql_stage.h>
 
 #ifdef HAVE_PSI_INTERFACE
 static PSI_mutex_key key_MDL_map_mutex;
@@ -63,6 +64,8 @@ static void init_mdl_psi_keys(void)
 
   count= array_elements(all_mdl_conds);
   mysql_cond_register("sql", all_mdl_conds, count);
+
+  MDL_key::init_psi_keys();
 }
 #endif /* HAVE_PSI_INTERFACE */
 
@@ -72,18 +75,35 @@ static void init_mdl_psi_keys(void)
   belonging to certain namespace.
 */
 
-const char *MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]=
+PSI_stage_info MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]=
 {
-  "Waiting for global read lock",
-  "Waiting for schema metadata lock",
-  "Waiting for table metadata lock",
-  "Waiting for stored function metadata lock",
-  "Waiting for stored procedure metadata lock",
-  "Waiting for trigger metadata lock",
-  "Waiting for event metadata lock",
-  "Waiting for commit lock"
+  {0, "Waiting for global read lock", 0},
+  {0, "Waiting for schema metadata lock", 0},
+  {0, "Waiting for table metadata lock", 0},
+  {0, "Waiting for stored function metadata lock", 0},
+  {0, "Waiting for stored procedure metadata lock", 0},
+  {0, "Waiting for trigger metadata lock", 0},
+  {0, "Waiting for event metadata lock", 0},
+  {0, "Waiting for commit lock", 0}
 };
 
+#ifdef HAVE_PSI_INTERFACE
+void MDL_key::init_psi_keys()
+{
+  int i;
+  int count;
+  PSI_stage_info *info;
+
+  count= array_elements(MDL_key::m_namespace_to_wait_state_name);
+  for (i= 0; i<count; i++)
+  {
+    /* mysql_stage_register wants an array of pointers, registering 1 by 1. */
+    info= & MDL_key::m_namespace_to_wait_state_name[i];
+    mysql_stage_register("sql", &info, 1);
+  }
+}
+#endif
+
 static bool mdl_initialized= 0;
 
 
@@ -962,16 +982,17 @@ void MDL_wait::reset_status()
 
 MDL_wait::enum_wait_status
 MDL_wait::timed_wait(MDL_context_owner *owner, struct timespec *abs_timeout,
-                     bool set_status_on_timeout, const char *wait_state_name)
+                     bool set_status_on_timeout,
+                     const PSI_stage_info *wait_state_name)
 {
-  const char *old_msg;
+  PSI_stage_info old_stage;
   enum_wait_status result;
   int wait_result= 0;
 
   mysql_mutex_lock(&m_LOCK_wait_status);
 
-  old_msg= owner->enter_cond(&m_COND_wait_status, &m_LOCK_wait_status,
-                             wait_state_name);
+  owner->ENTER_COND(&m_COND_wait_status, &m_LOCK_wait_status,
+                    wait_state_name, & old_stage);
   thd_wait_begin(NULL, THD_WAIT_META_DATA_LOCK);
   while (!m_wait_status && !owner->is_killed() &&
          wait_result != ETIMEDOUT && wait_result != ETIME)
@@ -1002,7 +1023,7 @@ MDL_wait::timed_wait(MDL_context_owner *
   }
   result= m_wait_status;
 
-  owner->exit_cond(old_msg);
+  owner->EXIT_COND(& old_stage);
 
   return result;
 }

=== modified file 'sql/mdl.h'
--- a/sql/mdl.h	2011-07-04 00:25:46 +0000
+++ b/sql/mdl.h	2011-07-21 16:27:14 +0000
@@ -35,6 +35,23 @@ class MDL_context;
 class MDL_lock;
 class MDL_ticket;
 
+/**
+  @def ENTER_COND(C, M, S, O)
+  Start a wait on a condition.
+  @param C the condition to wait on
+  @param M the associated mutex
+  @param S the new stage to enter
+  @param O the previous stage
+  @sa EXIT_COND().
+*/
+#define ENTER_COND(C, M, S, O) enter_cond(C, M, S, O, __func__, __FILE__, __LINE__)
+
+/**
+  @def EXIT_COND(S)
+  End a wait on a condition
+  @param S the new stage to enter
+*/
+#define EXIT_COND(S) exit_cond(S, __func__, __FILE__, __LINE__)
 
 /**
    An interface to separate the MDL module from the THD, and the rest of the
@@ -47,11 +64,38 @@ public:
   virtual ~MDL_context_owner() {}
 
   /**
-     @see THD::enter_cond() and THD::exit_cond()
-   */
-  virtual const char* enter_cond(mysql_cond_t *cond, mysql_mutex_t* mutex,
-                                 const char* msg) = 0;
-  virtual void exit_cond(const char* old_msg) = 0;
+    Enter a condition wait.
+    For @c enter_cond() / @c exit_cond() to work the mutex must be held before
+    @c enter_cond(); this mutex is then released by @c exit_cond().
+    Usage must be: lock mutex; enter_cond(); your code; exit_cond().
+    @param cond the condition to wait on
+    @param mutex the associated mutex
+    @param [in] stage the stage to enter, or NULL
+    @param [out] old_stage the previous stage, or NULL
+    @param src_function function name of the caller
+    @param src_file file name of the caller
+    @param src_line line number of the caller
+    @sa ENTER_COND(), THD::enter_cond()
+    @sa EXIT_COND(), THD::exit_cond()
+  */
+  virtual void enter_cond(mysql_cond_t *cond, mysql_mutex_t *mutex,
+                          const PSI_stage_info *stage, PSI_stage_info *old_stage,
+                          const char *src_function, const char *src_file,
+                          int src_line) = 0;
+
+  /**
+    @def EXIT_COND(S)
+    End a wait on a condition
+    @param [in] stage the new stage to enter
+    @param src_function function name of the caller
+    @param src_file file name of the caller
+    @param src_line line number of the caller
+    @sa ENTER_COND(), THD::enter_cond()
+    @sa EXIT_COND(), THD::exit_cond()
+  */
+  virtual void exit_cond(const PSI_stage_info *stage,
+                         const char *src_function, const char *src_file,
+                         int src_line) = 0;
   /**
      Has the owner thread been killed?
    */
@@ -223,6 +267,10 @@ enum enum_mdl_duration {
 class MDL_key
 {
 public:
+#ifdef HAVE_PSI_INTERFACE
+  static void init_psi_keys();
+#endif
+
   /**
     Object namespaces.
     Sic: when adding a new member to this enum make sure to
@@ -318,16 +366,16 @@ public:
     Get thread state name to be used in case when we have to
     wait on resource identified by key.
   */
-  const char * get_wait_state_name() const
+  const PSI_stage_info * get_wait_state_name() const
   {
-    return m_namespace_to_wait_state_name[(int)mdl_namespace()];
+    return & m_namespace_to_wait_state_name[(int)mdl_namespace()];
   }
 
 private:
   uint16 m_length;
   uint16 m_db_name_length;
   char m_ptr[MAX_MDLKEY_LENGTH];
-  static const char * m_namespace_to_wait_state_name[NAMESPACE_END];
+  static PSI_stage_info m_namespace_to_wait_state_name[NAMESPACE_END];
 private:
   MDL_key(const MDL_key &);                     /* not implemented */
   MDL_key &operator=(const MDL_key &);          /* not implemented */
@@ -628,7 +676,8 @@ public:
   void reset_status();
   enum_wait_status timed_wait(MDL_context_owner *owner,
                               struct timespec *abs_timeout,
-                              bool signal_timeout, const char *wait_state_name);
+                              bool signal_timeout,
+                              const PSI_stage_info *wait_state_name);
 private:
   /**
     Condvar which is used for waiting until this context's pending

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-07-19 15:11:15 +0000
+++ b/sql/mysqld.cc	2011-07-22 08:10:35 +0000
@@ -4147,7 +4147,7 @@ static int init_server_components()
     }
   }
 
-  proc_info_hook= set_thd_proc_info;
+  proc_info_hook= set_thd_stage_info;
 
 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
   /*
@@ -8481,6 +8481,7 @@ PSI_stage_info stage_logging_slow_query=
 PSI_stage_info stage_making_temp_file_append_before_load_data= { 0, "Making temporary file (append) before replaying LOAD DATA INFILE.", 0};
 PSI_stage_info stage_making_temp_file_create_before_load_data= { 0, "Making temporary file (create) before replaying LOAD DATA INFILE.", 0};
 PSI_stage_info stage_manage_keys= { 0, "manage keys", 0};
+PSI_stage_info stage_master_has_sent_all_binlog_to_slave= { 0, "Master has sent all binlog to slave; waiting for binlog to be updated", 0};
 PSI_stage_info stage_opening_tables= { 0, "Opening tables", 0};
 PSI_stage_info stage_optimizing= { 0, "optimizing", 0};
 PSI_stage_info stage_preparing= { 0, "preparing", 0};
@@ -8500,6 +8501,7 @@ PSI_stage_info stage_sending_binlog_even
 PSI_stage_info stage_sending_cached_result_to_client= { 0, "sending cached result to client", 0};
 PSI_stage_info stage_sending_data= { 0, "Sending data", 0};
 PSI_stage_info stage_setup= { 0, "setup", 0};
+PSI_stage_info stage_slave_has_read_all_relay_log= { 0, "Slave has read all relay log; waiting for the slave I/O thread to update it", 0};
 PSI_stage_info stage_sorting_for_group= { 0, "Sorting for group", 0};
 PSI_stage_info stage_sorting_for_order= { 0, "Sorting for order", 0};
 PSI_stage_info stage_sorting_result= { 0, "Sorting result", 0};
@@ -8523,8 +8525,13 @@ PSI_stage_info stage_waiting_for_handler
 PSI_stage_info stage_waiting_for_insert= { 0, "Waiting for INSERT", 0};
 PSI_stage_info stage_waiting_for_master_to_send_event= { 0, "Waiting for master to send event", 0};
 PSI_stage_info stage_waiting_for_master_update= { 0, "Waiting for master update", 0};
+PSI_stage_info stage_waiting_for_relay_log_space= { 0, "Waiting for the slave SQL thread to free enough relay log space", 0};
 PSI_stage_info stage_waiting_for_slave_mutex_on_exit= { 0, "Waiting for slave mutex on exit", 0};
+PSI_stage_info stage_waiting_for_slave_thread_to_start= { 0, "Waiting for slave thread to start", 0};
+PSI_stage_info stage_waiting_for_table_flush= { 0, "Waiting for table flush", 0};
+PSI_stage_info stage_waiting_for_query_cache_lock= { 0, "Waiting for query cache lock", 0};
 PSI_stage_info stage_waiting_for_the_next_event_in_relay_log= { 0, "Waiting for the next event in relay log", 0};
+PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position= { 0, "Waiting for the slave SQL thread to advance position", 0};
 PSI_stage_info stage_waiting_to_finalize_termination= { 0, "Waiting to finalize termination", 0};
 PSI_stage_info stage_waiting_to_get_readlock= { 0, "Waiting to get readlock", 0};
 
@@ -8573,6 +8580,7 @@ PSI_stage_info *all_server_stages[]=
   & stage_making_temp_file_append_before_load_data,
   & stage_making_temp_file_create_before_load_data,
   & stage_manage_keys,
+  & stage_master_has_sent_all_binlog_to_slave,
   & stage_opening_tables,
   & stage_optimizing,
   & stage_preparing,
@@ -8592,6 +8600,7 @@ PSI_stage_info *all_server_stages[]=
   & stage_sending_cached_result_to_client,
   & stage_sending_data,
   & stage_setup,
+  & stage_slave_has_read_all_relay_log,
   & stage_sorting_for_group,
   & stage_sorting_for_order,
   & stage_sorting_result,
@@ -8616,7 +8625,11 @@ PSI_stage_info *all_server_stages[]=
   & stage_waiting_for_master_to_send_event,
   & stage_waiting_for_master_update,
   & stage_waiting_for_slave_mutex_on_exit,
+  & stage_waiting_for_slave_thread_to_start,
+  & stage_waiting_for_table_flush,
+  & stage_waiting_for_query_cache_lock,
   & stage_waiting_for_the_next_event_in_relay_log,
+  & stage_waiting_for_the_slave_thread_to_advance_position,
   & stage_waiting_to_finalize_termination,
   & stage_waiting_to_get_readlock
 };

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2011-07-19 15:11:15 +0000
+++ b/sql/mysqld.h	2011-07-21 16:27:14 +0000
@@ -354,6 +354,7 @@ extern PSI_stage_info stage_logging_slow
 extern PSI_stage_info stage_making_temp_file_append_before_load_data;
 extern PSI_stage_info stage_making_temp_file_create_before_load_data;
 extern PSI_stage_info stage_manage_keys;
+extern PSI_stage_info stage_master_has_sent_all_binlog_to_slave;
 extern PSI_stage_info stage_opening_tables;
 extern PSI_stage_info stage_optimizing;
 extern PSI_stage_info stage_preparing;
@@ -373,6 +374,7 @@ extern PSI_stage_info stage_sending_binl
 extern PSI_stage_info stage_sending_cached_result_to_client;
 extern PSI_stage_info stage_sending_data;
 extern PSI_stage_info stage_setup;
+extern PSI_stage_info stage_slave_has_read_all_relay_log;
 extern PSI_stage_info stage_sorting_for_group;
 extern PSI_stage_info stage_sorting_for_order;
 extern PSI_stage_info stage_sorting_result;
@@ -396,8 +398,13 @@ extern PSI_stage_info stage_waiting_for_
 extern PSI_stage_info stage_waiting_for_insert;
 extern PSI_stage_info stage_waiting_for_master_to_send_event;
 extern PSI_stage_info stage_waiting_for_master_update;
+extern PSI_stage_info stage_waiting_for_relay_log_space;
 extern PSI_stage_info stage_waiting_for_slave_mutex_on_exit;
+extern PSI_stage_info stage_waiting_for_slave_thread_to_start;
+extern PSI_stage_info stage_waiting_for_query_cache_lock;
+extern PSI_stage_info stage_waiting_for_table_flush;
 extern PSI_stage_info stage_waiting_for_the_next_event_in_relay_log;
+extern PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position;
 extern PSI_stage_info stage_waiting_to_finalize_termination;
 extern PSI_stage_info stage_waiting_to_get_readlock;
 

=== modified file 'sql/replication.h'
--- a/sql/replication.h	2011-06-30 15:50:45 +0000
+++ b/sql/replication.h	2011-07-21 16:27:14 +0000
@@ -470,10 +470,19 @@ MYSQL *rpl_connect_master(MYSQL *mysql);
    @param cond     The condition the thread is going to wait for
    @param mutex    The mutex associated with the condition, this must be
                    held before call this function
-   @param msg      The new process message for the thread
+   @param stage    The new process message for the thread
+   @param old_stage The old process message for the thread
+   @param src_function The caller source function name
+   @param src_file The caller source file name
+   @param src_line The caller source line number
 */
-const char* thd_enter_cond(MYSQL_THD thd, mysql_cond_t *cond,
-                           mysql_mutex_t *mutex, const char *msg);
+void thd_enter_cond(MYSQL_THD thd, mysql_cond_t *cond, mysql_mutex_t *mutex,
+                    const PSI_stage_info *stage, PSI_stage_info *old_stage,
+                    const char *src_function, const char *src_file,
+                    int src_line);
+
+#define THD_ENTER_COND(P1, P2, P3, P4, P5) \
+  thd_enter_cond(P1, P2, P3, P4, P5, __func__, __FILE__, __LINE__)
 
 /**
    Set thread leaving a condition
@@ -482,10 +491,18 @@ const char* thd_enter_cond(MYSQL_THD thd
    condition.
 
    @param thd      The thread entering the condition, NULL means current thread
-   @param old_msg  The process message, ususally this should be the old process
+   @param stage    The process message, ususally this should be the old process
                    message before calling @f thd_enter_cond
+   @param src_function The caller source function name
+   @param src_file The caller source file name
+   @param src_line The caller source line number
 */
-void thd_exit_cond(MYSQL_THD thd, const char *old_msg);
+void thd_exit_cond(MYSQL_THD thd, const PSI_stage_info *stage,
+                   const char *src_function, const char *src_file,
+                   int src_line);
+
+#define THD_EXIT_COND(P1, P2) \
+  thd_exit_cond(P1, P2, __func__, __FILE__, __LINE__)
 
 /**
    Get the value of user variable as an integer.

=== modified file 'sql/rpl_master.cc'
--- a/sql/rpl_master.cc	2011-06-09 08:58:41 +0000
+++ b/sql/rpl_master.cc	2011-07-21 16:27:14 +0000
@@ -1100,7 +1100,7 @@ impossible position";
 #ifndef DBUG_OFF
           ulong hb_info_counter= 0;
 #endif
-          const char* old_msg= thd->proc_info;
+          PSI_stage_info old_stage;
           signal_cnt= mysql_bin_log.signal_cnt;
           do 
           {
@@ -1109,9 +1109,9 @@ impossible position";
               DBUG_ASSERT(heartbeat_ts && heartbeat_period != 0);
               set_timespec_nsec(*heartbeat_ts, heartbeat_period);
             }
-            thd->enter_cond(log_cond, log_lock,
-                            "Master has sent all binlog to slave; "
-                            "waiting for binlog to be updated");
+            thd->ENTER_COND(log_cond, log_lock,
+                            &stage_master_has_sent_all_binlog_to_slave,
+                            &old_stage);
             ret= mysql_bin_log.wait_for_update_bin_log(thd, heartbeat_ts);
             DBUG_ASSERT(ret == 0 || (heartbeat_period != 0 && coord != NULL));
             if (ret == ETIMEDOUT || ret == ETIME)
@@ -1128,14 +1128,14 @@ impossible position";
               /* reset transmit packet for the heartbeat event */
               if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg))
               {
-                thd->exit_cond(old_msg);
+                thd->EXIT_COND(&old_stage);
                 goto err;
               }
               if (send_heartbeat_event(net, packet, coord, current_checksum_alg))
               {
                 errmsg = "Failed on my_net_write()";
                 my_errno= ER_UNKNOWN_ERROR;
-                thd->exit_cond(old_msg);
+                thd->EXIT_COND(&old_stage);
                 goto err;
               }
             }
@@ -1144,7 +1144,7 @@ impossible position";
               DBUG_PRINT("wait",("binary log received update or a broadcast signal caught"));
             }
           } while (signal_cnt == mysql_bin_log.signal_cnt && !thd->killed);
-          thd->exit_cond(old_msg);
+          thd->EXIT_COND(&old_stage);
         }
         break;
             

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2011-06-30 15:50:45 +0000
+++ b/sql/rpl_rli.cc	2011-07-21 16:27:14 +0000
@@ -410,7 +410,7 @@ int Relay_log_info::wait_for_pos(THD* th
   ulong init_abort_pos_wait;
   int error=0;
   struct timespec abstime; // for timeout checking
-  const char *msg;
+  PSI_stage_info old_stage;
   DBUG_ENTER("Relay_log_info::wait_for_pos");
 
   if (!inited)
@@ -421,9 +421,9 @@ int Relay_log_info::wait_for_pos(THD* th
 
   set_timespec(abstime,timeout);
   mysql_mutex_lock(&data_lock);
-  msg= thd->enter_cond(&data_cond, &data_lock,
-                       "Waiting for the slave SQL thread to "
-                       "advance position");
+  thd->ENTER_COND(&data_cond, &data_lock,
+                  &stage_waiting_for_the_slave_thread_to_advance_position,
+                  &old_stage);
   /*
      This function will abort when it notices that some CHANGE MASTER or
      RESET MASTER has changed the master info.
@@ -567,7 +567,7 @@ int Relay_log_info::wait_for_pos(THD* th
   }
 
 err:
-  thd->exit_cond(msg);
+  thd->EXIT_COND(&old_stage);
   DBUG_PRINT("exit",("killed: %d  abort: %d  slave_running: %d \
 improper_arguments: %d  timed_out: %d",
                      thd->killed_errno(),

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-07-20 10:24:14 +0000
+++ b/sql/rpl_slave.cc	2011-07-21 16:27:14 +0000
@@ -852,8 +852,10 @@ int start_slave_thread(
     while (start_id == *slave_run_id && thd != NULL)
     {
       DBUG_PRINT("sleep",("Waiting for slave thread to start"));
-      const char *old_msg= thd->enter_cond(start_cond, cond_lock,
-                                           "Waiting for slave thread to start");
+      PSI_stage_info saved_stage= {0, "", 0};
+      thd->ENTER_COND(start_cond, cond_lock,
+                      & stage_waiting_for_slave_thread_to_start,
+                      & saved_stage);
       /*
         It is not sufficient to test this at loop bottom. We must test
         it after registering the mutex in enter_cond(). If the kill
@@ -863,7 +865,7 @@ int start_slave_thread(
       */
       if (!thd->killed)
         mysql_cond_wait(start_cond, cond_lock);
-      thd->exit_cond(old_msg);
+      thd->EXIT_COND(& saved_stage);
       mysql_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
       if (thd->killed)
       {
@@ -1819,20 +1821,20 @@ static bool wait_for_relay_log_space(Rel
 {
   bool slave_killed=0;
   Master_info* mi = rli->mi;
-  const char *save_proc_info;
+  PSI_stage_info old_stage;
   THD* thd = mi->info_thd;
   DBUG_ENTER("wait_for_relay_log_space");
 
   mysql_mutex_lock(&rli->log_space_lock);
-  save_proc_info= thd->enter_cond(&rli->log_space_cond,
-                                  &rli->log_space_lock,
-                                  "\
-Waiting for the slave SQL thread to free enough relay log space");
+  thd->ENTER_COND(&rli->log_space_cond,
+                  &rli->log_space_lock,
+                  &stage_waiting_for_relay_log_space,
+                  &old_stage);
   while (rli->log_space_limit < rli->log_space_total &&
          !(slave_killed=io_slave_killed(thd,mi)) &&
          !rli->ignore_log_space_limit)
     mysql_cond_wait(&rli->log_space_cond, &rli->log_space_lock);
-  thd->exit_cond(save_proc_info);
+  thd->EXIT_COND(&old_stage);
   DBUG_RETURN(slave_killed);
 }
 
@@ -2079,11 +2081,11 @@ bool show_master_info(THD* thd, Master_i
       non-volotile members like mi->info_thd, which is guarded by the mutex.
     */
     mysql_mutex_lock(&mi->run_lock);
-    protocol->store(mi->info_thd ? mi->info_thd->proc_info : "", &my_charset_bin);
+    protocol->store(mi->info_thd ? mi->info_thd->get_proc_info() : "", &my_charset_bin);
     mysql_mutex_unlock(&mi->run_lock);
 
     mysql_mutex_lock(&mi->rli->run_lock);
-    const char *slave_sql_running_state= mi->rli->info_thd ? mi->rli->info_thd->proc_info : "";
+    const char *slave_sql_running_state= mi->rli->info_thd ? mi->rli->info_thd->get_proc_info() : "";
     mysql_mutex_unlock(&mi->rli->run_lock);
 
     mysql_mutex_lock(&mi->data_lock);
@@ -2371,7 +2373,6 @@ static inline bool slave_sleep(THD *thd,
 {
   bool ret;
   struct timespec abstime;
-  const char *old_proc_info;
   mysql_mutex_t *lock= &info->sleep_lock;
   mysql_cond_t *cond= &info->sleep_cond;
 
@@ -2379,7 +2380,7 @@ static inline bool slave_sleep(THD *thd,
   set_timespec(abstime, seconds);
 
   mysql_mutex_lock(lock);
-  old_proc_info= thd->enter_cond(cond, lock, thd->proc_info);
+  thd->ENTER_COND(cond, lock, NULL, NULL);
 
   while (! (ret= func(thd, info)))
   {
@@ -2389,7 +2390,7 @@ static inline bool slave_sleep(THD *thd,
   }
 
   /* Implicitly unlocks the mutex. */
-  thd->exit_cond(old_proc_info);
+  thd->EXIT_COND(NULL);
 
   return ret;
 }

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2011-07-20 14:40:52 +0000
+++ b/sql/sql_base.cc	2011-07-22 15:52:42 +0000
@@ -88,6 +88,69 @@ bool No_such_table_error_handler::safely
   return ((m_handled_errors > 0) && (m_unhandled_errors == 0));
 }
 
+
+/**
+  This internal handler is used to trap ER_NO_SUCH_TABLE and
+  ER_WRONG_MRG_TABLE errors during CHECK/REPAIR TABLE for MERGE
+  tables.
+*/
+
+class Repair_mrg_table_error_handler : public Internal_error_handler
+{
+public:
+  Repair_mrg_table_error_handler()
+    : m_handled_errors(false), m_unhandled_errors(false)
+  {}
+
+  bool handle_condition(THD *thd,
+                        uint sql_errno,
+                        const char* sqlstate,
+                        MYSQL_ERROR::enum_warning_level level,
+                        const char* msg,
+                        MYSQL_ERROR ** cond_hdl);
+
+  /**
+    Returns TRUE if there were ER_NO_SUCH_/WRONG_MRG_TABLE and there
+    were no unhandled errors. FALSE otherwise.
+  */
+  bool safely_trapped_errors()
+  {
+    /*
+      Check for m_handled_errors is here for extra safety.
+      It can be useful in situation when call to open_table()
+      fails because some error which was suppressed by another
+      error handler (e.g. in case of MDL deadlock which we
+      decided to solve by back-off and retry).
+    */
+    return (m_handled_errors && (! m_unhandled_errors));
+  }
+
+private:
+  bool m_handled_errors;
+  bool m_unhandled_errors;
+};
+
+
+bool
+Repair_mrg_table_error_handler::handle_condition(THD *,
+                                                 uint sql_errno,
+                                                 const char*,
+                                                 MYSQL_ERROR::enum_warning_level level,
+                                                 const char*,
+                                                 MYSQL_ERROR ** cond_hdl)
+{
+  *cond_hdl= NULL;
+  if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_WRONG_MRG_TABLE)
+  {
+    m_handled_errors= true;
+    return TRUE;
+  }
+
+  m_unhandled_errors= true;
+  return FALSE;
+}
+
+
 /**
   @defgroup Data_Dictionary Data Dictionary
   @{
@@ -4430,6 +4493,24 @@ open_and_process_table(THD *thd, LEX *le
     thd->pop_internal_handler();
     safe_to_ignore_table= no_such_table_handler.safely_trapped_errors();
   }
+  else if (tables->parent_l && (thd->open_options & HA_OPEN_FOR_REPAIR))
+  {
+    /*
+      Also fail silently for underlying tables of a MERGE table if this
+      table is opened for CHECK/REPAIR TABLE statement. This is needed
+      to provide complete list of problematic underlying tables in
+      CHECK/REPAIR TABLE output.
+    */
+    Repair_mrg_table_error_handler repair_mrg_table_handler;
+    thd->push_internal_handler(&repair_mrg_table_handler);
+
+    error= open_temporary_table(thd, tables);
+    if (!error && !tables->table)
+      error= open_table(thd, tables, new_frm_mem, ot_ctx);
+
+    thd->pop_internal_handler();
+    safe_to_ignore_table= repair_mrg_table_handler.safely_trapped_errors();
+  }
   else
   {
     if (tables->parent_l)

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2011-06-30 15:50:45 +0000
+++ b/sql/sql_cache.cc	2011-07-21 16:27:14 +0000
@@ -408,23 +408,28 @@ TODO list:
 struct Query_cache_wait_state
 {
   THD *m_thd;
-  const char *m_proc_info;
+  PSI_stage_info m_old_stage;
+  const char *m_func;
+  const char *m_file;
+  int m_line;
 
   Query_cache_wait_state(THD *thd, const char *func,
                          const char *file, unsigned int line)
   : m_thd(thd),
-    m_proc_info(NULL)
+    m_old_stage(),
+    m_func(func), m_file(file), m_line(line)
   {
     if (m_thd)
-      m_proc_info= set_thd_proc_info(m_thd,
-                                     "Waiting for query cache lock",
-                                     func, file, line);
+      set_thd_stage_info(m_thd,
+                         &stage_waiting_for_query_cache_lock,
+                         &m_old_stage,
+                         m_func, m_file, m_line);
   }
 
   ~Query_cache_wait_state()
   {
     if (m_thd)
-      set_thd_proc_info(m_thd, m_proc_info, NULL, NULL, 0);
+      set_thd_stage_info(m_thd, &m_old_stage, NULL, m_func, m_file, m_line);
   }
 };
 

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-07-20 07:19:42 +0000
+++ b/sql/sql_class.cc	2011-07-21 16:27:14 +0000
@@ -495,42 +495,83 @@ const char *set_thd_proc_info(void *thd_
                               const char *calling_file,
                               const unsigned int calling_line)
 {
-  THD *thd= (THD *) thd_arg;
+  PSI_stage_info old_stage;
+  PSI_stage_info new_stage;
 
-  if (!thd)
+  old_stage.m_key= 0;
+  old_stage.m_name= info;
+
+  set_thd_stage_info(thd_arg, & old_stage, & new_stage,
+                     calling_function, calling_file, calling_line);
+
+  return new_stage.m_name;
+}
+
+extern "C"
+void set_thd_stage_info(void *opaque_thd,
+                        const PSI_stage_info *new_stage,
+                        PSI_stage_info *old_stage,
+                        const char *calling_func,
+                        const char *calling_file,
+                        const unsigned int calling_line)
+{
+  THD *thd= (THD*) opaque_thd;
+  if (thd == NULL)
     thd= current_thd;
 
-  const char *old_info= thd->proc_info;
-  DBUG_PRINT("proc_info", ("%s:%d  %s", calling_file, calling_line, info));
+  thd->enter_stage(new_stage, old_stage, calling_func, calling_file, calling_line);
+}
+
+void THD::enter_stage(const PSI_stage_info *new_stage,
+                      PSI_stage_info *old_stage,
+                      const char *calling_func,
+                      const char *calling_file,
+                      const unsigned int calling_line)
+{
+  DBUG_PRINT("THD::enter_stage", ("%s:%d", calling_file, calling_line));
+
+  if (old_stage != NULL)
+  {
+    old_stage->m_key= m_current_stage_key;
+    old_stage->m_name= proc_info;
+  }
+
+  if (new_stage != NULL)
+  {
+    const char *msg= new_stage->m_name;
 
 #if defined(ENABLED_PROFILING)
-  thd->profiling.status_change(info,
-                               calling_function, calling_file, calling_line);
+    profiling.status_change(msg, calling_func, calling_file, calling_line);
 #endif
-  thd->proc_info= info;
+
+    m_current_stage_key= new_stage->m_key;
+    proc_info= msg;
+
 #ifdef HAVE_PSI_THREAD_INTERFACE
-  PSI_CALL(set_thread_state)(info);
+    PSI_CALL(set_thread_state)(msg);
+    MYSQL_SET_STAGE(m_current_stage_key, calling_file, calling_line);
 #endif
-  return old_info;
+  }
+  return;
 }
 
 extern "C"
-const char* thd_enter_cond(MYSQL_THD thd, mysql_cond_t *cond,
-                           mysql_mutex_t *mutex, const char *msg)
+void thd_enter_cond(MYSQL_THD thd, mysql_cond_t *cond, mysql_mutex_t *mutex,
+                    const PSI_stage_info *stage, PSI_stage_info *old_stage)
 {
   if (!thd)
     thd= current_thd;
 
-  return thd->enter_cond(cond, mutex, msg);
+  return thd->ENTER_COND(cond, mutex, stage, old_stage);
 }
 
 extern "C"
-void thd_exit_cond(MYSQL_THD thd, const char *old_msg)
+void thd_exit_cond(MYSQL_THD thd, const PSI_stage_info *stage)
 {
   if (!thd)
     thd= current_thd;
 
-  thd->exit_cond(old_msg);
+  thd->EXIT_COND(stage);
   return;
 }
 

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-07-20 10:29:12 +0000
+++ b/sql/sql_class.h	2011-07-21 16:27:14 +0000
@@ -38,6 +38,30 @@
 #include <mysql/psi/mysql_stage.h>
 #include <mysql/psi/mysql_statement.h>
 
+/**
+  The meat of thd_proc_info(THD*, char*), a macro that packs the last
+  three calling-info parameters.
+*/
+extern "C"
+const char *set_thd_proc_info(void *thd_arg, const char *info,
+                              const char *calling_func,
+                              const char *calling_file,
+                              const unsigned int calling_line);
+
+#define thd_proc_info(thd, msg) \
+  set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
+
+extern "C"
+void set_thd_stage_info(void *thd,
+                        const PSI_stage_info *new_stage,
+                        PSI_stage_info *old_stage,
+                        const char *calling_func,
+                        const char *calling_file,
+                        const unsigned int calling_line);
+                        
+#define THD_STAGE_INFO(thd, stage) \
+  (thd)->enter_stage(& stage, NULL, __func__, __FILE__, __LINE__)
+
 class Reprepare_observer;
 class Relay_log_info;
 
@@ -1793,6 +1817,19 @@ public:
   */
   const char *proc_info;
 
+private:
+  unsigned int m_current_stage_key;
+
+public:
+  void enter_stage(const PSI_stage_info *stage,
+                   PSI_stage_info *old_stage,
+                   const char *calling_func,
+                   const char *calling_file,
+                   const unsigned int calling_line);
+
+  const char *get_proc_info() const
+  { return proc_info; }
+
   /*
     Used in error messages to tell user in what part of MySQL we found an
     error. E. g. when where= "having clause", if fix_fields() fails, user
@@ -2562,22 +2599,20 @@ public:
 
   // Begin implementation of MDL_context_owner interface.
 
-  /*
-    For enter_cond() / exit_cond() to work the mutex must be got before
-    enter_cond(); this mutex is then released by exit_cond().
-    Usage must be: lock mutex; enter_cond(); your code; exit_cond().
-  */
-  inline const char* enter_cond(mysql_cond_t *cond, mysql_mutex_t* mutex,
-                                const char* msg)
+  inline void
+  enter_cond(mysql_cond_t *cond, mysql_mutex_t* mutex,
+             const PSI_stage_info *stage, PSI_stage_info *old_stage,
+             const char *src_function, const char *src_file,
+             int src_line)
   {
-    const char* old_msg = proc_info;
     mysql_mutex_assert_owner(mutex);
     mysys_var->current_mutex = mutex;
     mysys_var->current_cond = cond;
-    proc_info = msg;
-    return old_msg;
+    enter_stage(stage, old_stage, src_function, src_file, src_line);
   }
-  inline void exit_cond(const char* old_msg)
+  inline void exit_cond(const PSI_stage_info *stage,
+                        const char *src_function, const char *src_file,
+                        int src_line)
   {
     /*
       Putting the mutex unlock in thd->exit_cond() ensures that
@@ -2589,7 +2624,7 @@ public:
     mysql_mutex_lock(&mysys_var->mutex);
     mysys_var->current_mutex = 0;
     mysys_var->current_cond = 0;
-    proc_info = old_msg;
+    enter_stage(stage, NULL, src_function, src_file, src_line);
     mysql_mutex_unlock(&mysys_var->mutex);
     return;
   }
@@ -4147,23 +4182,4 @@ inline bool add_group_to_list(THD *thd,
 
 #endif /* MYSQL_SERVER */
 
-/**
-  The meat of thd_proc_info(THD*, char*), a macro that packs the last
-  three calling-info parameters.
-*/
-extern "C"
-const char *set_thd_proc_info(void *thd_arg, const char *info,
-                              const char *calling_func,
-                              const char *calling_file,
-                              const unsigned int calling_line);
-
-#define thd_proc_info(thd, msg) \
-  set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
-
-#define THD_STAGE_INFO(thd, stage) \
-  { \
-    set_thd_proc_info(thd, stage.m_name, __func__, __FILE__, __LINE__); \
-    MYSQL_SET_STAGE(stage.m_key, __FILE__, __LINE__); \
-  }
-
 #endif /* SQL_CLASS_INCLUDED */

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2011-07-07 09:45:10 +0000
+++ b/sql/sql_lex.cc	2011-07-25 10:54:06 +0000
@@ -1219,8 +1219,12 @@ int lex_one_token(void *arg, void *yythd
     {
       uint double_quotes= 0;
       char quote_char= c;                       // Used char
-      while ((c=lip->yyGet()))
+      for(;;)
       {
+        c= lip->yyGet();
+        if (c == 0)
+          return ABORT_SYM;                     // Unmatched quotes
+
 	int var_length;
 	if ((var_length= my_mbcharlen(cs, c)) == 1)
 	{

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-07-19 15:11:15 +0000
+++ b/sql/table.cc	2011-07-21 16:27:14 +0000
@@ -3305,7 +3305,7 @@ bool TABLE_SHARE::wait_for_old_version(T
   mdl_context->find_deadlock();
 
   wait_status= mdl_context->m_wait.timed_wait(thd, abstime, TRUE,
-                                              "Waiting for table flush");
+                                              &stage_waiting_for_table_flush);
 
   mdl_context->done_waiting_for();
 

=== modified file 'storage/innobase/fil/fil0fil.c'
--- a/storage/innobase/fil/fil0fil.c	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/fil/fil0fil.c	2011-07-25 09:54:47 +0000
@@ -2717,7 +2717,6 @@ fil_create_new_single_table_tablespace(
 	char*			path;
 	ibool			success;
 	os_file_create_t	create_mode;
-	os_file_create_t	error_ignore;
 
 	ut_a(space_id > 0);
 	ut_a(space_id < SRV_LOG_SPACE_FIRST_ID);
@@ -2740,8 +2739,6 @@ fil_create_new_single_table_tablespace(
 	path. It might not have the same value as the one when building the
 	table definition */
 
-	error_ignore = srv_file_per_table ? OS_FILE_ON_ERROR_NO_EXIT : 0;
-
 	create_mode = srv_file_per_table
 		    ? OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT
 		    : OS_FILE_CREATE;

=== modified file 'storage/myisammrg/ha_myisammrg.cc'
--- a/storage/myisammrg/ha_myisammrg.cc	2011-07-04 00:25:46 +0000
+++ b/storage/myisammrg/ha_myisammrg.cc	2011-07-22 15:52:42 +0000
@@ -155,9 +155,14 @@ extern "C" void myrg_print_wrong_table(c
   buf[db.length]= '.';
   memcpy(buf + db.length + 1, name.str, name.length);
   buf[db.length + name.length + 1]= 0;
-  push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                      ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE),
-                      buf);
+  /*
+    Push an error to be reported as part of CHECK/REPAIR result-set.
+    Note that calling my_error() from handler is a hack which is kept
+    here to avoid refactoring. Normally engines should report errors
+    through return value which will be interpreted by caller using
+    handler::print_error() call.
+  */
+  my_error(ER_ADMIN_WRONG_MRG_TABLE, MYF(0), buf);
 }
 
 
@@ -594,8 +599,7 @@ public:
 
   @return       pointer to open MyISAM table structure
     @retval     !=NULL                  OK, returning pointer
-    @retval     NULL, my_errno == 0     Ok, no more child tables
-    @retval     NULL, my_errno != 0     error
+    @retval     NULL,                   Error.
 
   @detail
     This function retrieves the MyISAM table handle from the
@@ -615,22 +619,23 @@ extern "C" MI_INFO *myisammrg_attach_chi
   MI_INFO       *myisam= NULL;
   DBUG_ENTER("myisammrg_attach_children_callback");
 
-  if (!child_l)
-  {
-    DBUG_PRINT("myrg", ("No more children to attach"));
-    my_errno= 0; /* Ok, no more child tables. */
-    goto end;
-  }
+  /*
+    Number of children in the list and MYRG_INFO::tables_count,
+    which is used by caller of this function, should always match.
+  */
+  DBUG_ASSERT(child_l);
+
   child= child_l->table;
 
+  /* Prepare for next child. */
+  param->next();
+
   if (!child)
   {
-    DBUG_PRINT("myrg", ("Child table does not exist"));
-    my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
+    DBUG_PRINT("error", ("failed to open underlying table '%s'.'%s'",
+                         child_l->db, child_l->table_name));
     goto end;
   }
-  /* Prepare for next child. */
-  param->next();
 
   /*
     Do a quick compatibility check. The table def version is set when
@@ -661,7 +666,6 @@ extern "C" MI_INFO *myisammrg_attach_chi
   {
     DBUG_PRINT("error", ("temporary table mismatch parent: %d  child: %d",
                          parent->s->tmp_table, child->s->tmp_table));
-    my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
     goto end;
   }
 
@@ -672,12 +676,27 @@ extern "C" MI_INFO *myisammrg_attach_chi
     DBUG_PRINT("error", ("no MyISAM handle for child table: '%s'.'%s' 0x%lx",
                          child->s->db.str, child->s->table_name.str,
                          (long) child));
-    my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
   }
-  DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx  my_errno: %d",
-                      my_errno ? 0L : (long) myisam, my_errno));
+
+  DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx", (long) myisam));
 
  end:
+
+  if (!myisam &&
+      (current_thd->open_options & HA_OPEN_FOR_REPAIR))
+  {
+    char buf[2*NAME_LEN + 1 + 1];
+    strxnmov(buf, sizeof(buf) - 1, child_l->db, ".", child_l->table_name, NULL);
+    /*
+      Push an error to be reported as part of CHECK/REPAIR result-set.
+      Note that calling my_error() from handler is a hack which is kept
+      here to avoid refactoring. Normally engines should report errors
+      through return value which will be interpreted by caller using
+      handler::print_error() call.
+    */
+    my_error(ER_ADMIN_WRONG_MRG_TABLE, MYF(0), buf);
+  }
+
   DBUG_RETURN(myisam);
 }
 
@@ -791,12 +810,6 @@ int ha_myisammrg::attach_children(void)
   /* Must call this with children list in place. */
   DBUG_ASSERT(this->table->pos_in_table_list->next_global == this->children_l);
 
-  /*
-    'my_errno' is set by myisammrg_attach_children_callback() in
-    case of an error.
-  */
-  my_errno= 0;
-
   if (myrg_attach_children(this->file, this->test_if_locked |
                            current_thd->open_options,
                            myisammrg_attach_children_callback, &param,

=== modified file 'storage/myisammrg/myrg_open.c'
--- a/storage/myisammrg/myrg_open.c	2011-06-30 15:50:45 +0000
+++ b/storage/myisammrg/myrg_open.c	2011-07-22 15:52:42 +0000
@@ -385,6 +385,7 @@ int myrg_attach_children(MYRG_INFO *m_in
   uint       UNINIT_VAR(key_parts);
   uint       min_keys;
   my_bool    bad_children= FALSE;
+  my_bool    first_child= TRUE;
   DBUG_ENTER("myrg_attach_children");
   DBUG_PRINT("myrg", ("handle_locking: %d", handle_locking));
 
@@ -399,16 +400,26 @@ int myrg_attach_children(MYRG_INFO *m_in
   errpos= 0;
   file_offset= 0;
   min_keys= 0;
-  child_nr= 0;
-  while ((myisam= (*callback)(callback_param)))
+  for (child_nr= 0; child_nr < m_info->tables; child_nr++)
   {
+    if (! (myisam= (*callback)(callback_param)))
+    {
+      if (handle_locking & HA_OPEN_FOR_REPAIR)
+      {
+        /* An appropriate error should've been already pushed by callback. */
+        bad_children= TRUE;
+        continue;
+      }
+      goto bad_children;
+    }
+
     DBUG_PRINT("myrg", ("child_nr: %u  table: '%s'",
                         child_nr, myisam->filename));
-    DBUG_ASSERT(child_nr < m_info->tables);
 
     /* Special handling when the first child is attached. */
-    if (!child_nr)
+    if (first_child)
     {
+      first_child= FALSE;
       m_info->reclength= myisam->s->base.reclength;
       min_keys=  myisam->s->base.keys;
       key_parts= myisam->s->base.key_parts;
@@ -456,14 +467,11 @@ int myrg_attach_children(MYRG_INFO *m_in
     for (idx= 0; idx < key_parts; idx++)
       m_info->rec_per_key_part[idx]+= (myisam->s->state.rec_per_key_part[idx] /
                                        m_info->tables);
-    child_nr++;
   }
 
   if (bad_children)
     goto bad_children;
-  /* Note: callback() resets my_errno, so it is safe to check it here */
-  if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF)
-    goto err;
+
   if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L)
   {
     my_errno= HA_ERR_RECORD_FILE_FULL;

=== modified file 'storage/perfschema/pfs_server.h'
--- a/storage/perfschema/pfs_server.h	2011-07-07 19:06:44 +0000
+++ b/storage/perfschema/pfs_server.h	2011-07-25 18:11:52 +0000
@@ -82,7 +82,7 @@
   #define PFS_MAX_ACCOUNT 100
 #endif
 #ifndef PFS_MAX_STAGE_CLASS
-  #define PFS_MAX_STAGE_CLASS 100
+  #define PFS_MAX_STAGE_CLASS 150
 #endif
 #ifndef PFS_STAGES_HISTORY_SIZE
   #define PFS_STAGES_HISTORY_SIZE 10

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2011-07-07 15:29:36 +0000
+++ b/support-files/mysql.spec.sh	2011-07-22 08:37:51 +0000
@@ -1121,6 +1121,7 @@ echo "====="
 # ----------------------------------------------------------------------------
 %files -n MySQL-embedded%{product_suffix}
 %defattr(-, root, root, 0755)
+%attr(755, root, root) %{_bindir}/mysql_embedded
 %attr(644, root, root) %{_libdir}/mysql/libmysqld.a
 %attr(644, root, root) %{_libdir}/mysql/libmysqld-debug.a
 
@@ -1130,6 +1131,10 @@ echo "====="
 # merging BK trees)
 ##############################################################################
 %changelog
+* Thu Jul 21 2011 Sunanda Menon <sunanda.menon@stripped>
+
+- Fix bug#12561297: Added the MySQL embedded binary
+
 * Thu Jul 07 2011 Joerg Bruehe <joerg.bruehe@stripped>
 
 - Fix bug#45415: "rpm upgrade recreates test database"

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2011-07-20 14:40:52 +0000
+++ b/unittest/gunit/CMakeLists.txt	2011-07-22 07:21:40 +0000
@@ -212,7 +212,6 @@ SET(TESTS
   mdl_mytap
   my_bitmap
   my_regex
-  opt_trace
   sql_list
   sql_plist
   thread_utils
@@ -223,6 +222,7 @@ SET(SERVER_TESTS
   item
   my_decimal
   opt_range
+  opt_trace
 )
 
 FOREACH(test ${TESTS})

=== modified file 'unittest/gunit/opt_trace-t.cc'
--- a/unittest/gunit/opt_trace-t.cc	2011-07-19 15:11:15 +0000
+++ b/unittest/gunit/opt_trace-t.cc	2011-07-22 07:21:40 +0000
@@ -25,12 +25,11 @@
 
 #include <opt_trace.h>
 #include <mysys_err.h>                          // for testing of OOM
+#include "mysqld.h"                             // system_charset_info
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>                           // for WEXITSTATUS
 #endif
 
-CHARSET_INFO *system_charset_info= &my_charset_utf8_general_ci;
-
 namespace {
 
 const ulonglong all_features= Opt_trace_context::default_features;
@@ -86,6 +85,10 @@ class TraceContentTest : public ::testin
 public:
   Opt_trace_context trace;
 protected:
+  static void SetUpTestCase()
+  {
+    system_charset_info= &my_charset_utf8_general_ci;
+  }
   virtual void SetUp()
   {
     error_handler_hook= my_error_handler;

=== modified file 'unittest/gunit/test_mdl_context_owner.h'
--- a/unittest/gunit/test_mdl_context_owner.h	2011-01-27 15:31:18 +0000
+++ b/unittest/gunit/test_mdl_context_owner.h	2011-07-21 22:49:31 +0000
@@ -25,15 +25,22 @@ public:
   Test_MDL_context_owner()
     : m_current_mutex(NULL)
   {}
-  virtual const char* enter_cond(mysql_cond_t *cond,
-                                 mysql_mutex_t* mutex,
-                                 const char* msg)
+  virtual void enter_cond(mysql_cond_t *cond,
+                          mysql_mutex_t* mutex,
+                          const PSI_stage_info *stage,
+                          PSI_stage_info *old_stage,
+                          const char *src_function,
+                          const char *src_file,
+                          int src_line)
   {
     m_current_mutex= mutex;
-    return NULL;
+    return;
   }
 
-  virtual void exit_cond(const char* old_msg)
+  virtual void exit_cond(const PSI_stage_info *stage,
+                         const char *src_function,
+                         const char *src_file,
+                         int src_line)
   {
     mysql_mutex_unlock(m_current_mutex);
   }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5378 branch (marc.alff:3364 to 3365) Marc Alff26 Jul