List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:August 16 2011 4:59am
Subject:bzr push into mysql-trunk branch (chris.powers:3368 to 3369) WL#4896
View as plain text  
 3369 Christopher Powers	2011-08-15 [merge]
      WL#4896 "Performance Schema Net IO"
      
      Local merge with mysql-trunk

    removed:
      mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result.THIS
      mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result.THIS
      mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result.THIS
      mysql-test/suite/perfschema/r/schema_lc0.result.THIS
      mysql-test/suite/perfschema/r/schema_lc1.result.THIS
      mysql-test/suite/perfschema/r/schema_lc2.result.THIS
    added:
      client/mysql_plugin.c
      mysql-test/include/daemon_example_bad_format.ini
      mysql-test/include/daemon_example_bad_soname.ini
      mysql-test/r/mysql_plugin.result
      mysql-test/suite/innodb/r/innodb_bug59733.result
      mysql-test/suite/innodb/t/innodb_bug59733.test
      mysql-test/t/mysql_plugin-master.opt
      mysql-test/t/mysql_plugin.test
      plugin/daemon_example/daemon_example.ini
    modified:
      client/CMakeLists.txt
      include/my_global.h
      mysql-test/include/join_cache.inc
      mysql-test/include/plugin.defs
      mysql-test/include/range.inc
      mysql-test/mysql-test-run.pl
      mysql-test/r/group_by.result
      mysql-test/r/information_schema.result
      mysql-test/r/innodb_icp_all.result
      mysql-test/r/innodb_mrr_all.result
      mysql-test/r/innodb_mrr_cost_all.result
      mysql-test/r/join_cache_jcl0.result
      mysql-test/r/join_cache_jcl1.result
      mysql-test/r/join_cache_jcl2.result
      mysql-test/r/join_cache_jcl3.result
      mysql-test/r/join_cache_jcl4.result
      mysql-test/r/join_cache_jcl5.result
      mysql-test/r/join_cache_jcl6.result
      mysql-test/r/join_cache_jcl7.result
      mysql-test/r/join_cache_jcl8.result
      mysql-test/r/myisam_icp_all.result
      mysql-test/r/myisam_mrr_all.result
      mysql-test/r/myisam_mrr_cost_all.result
      mysql-test/r/range_all.result
      mysql-test/r/range_icp.result
      mysql-test/r/range_icp_mrr.result
      mysql-test/r/range_mrr.result
      mysql-test/r/range_mrr_cost.result
      mysql-test/r/range_none.result
      mysql-test/r/sp_trans.result
      mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test
      mysql-test/t/group_by.test
      mysql-test/t/information_schema.test
      mysql-test/t/sp_trans.test
      plugin/daemon_example/CMakeLists.txt
      sql/field.h
      sql/handler.cc
      sql/handler.h
      sql/mysqld.cc
      sql/opt_range.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_join_cache.cc
      sql/sql_parse.cc
      sql/sql_select.cc
      sql/sql_select.h
      sql/sql_show.cc
      sql/sql_test.cc
      sql/sql_yacc.yy
      storage/innobase/btr/btr0btr.c
      storage/innobase/btr/btr0cur.c
      storage/innobase/btr/btr0pcur.c
      storage/innobase/btr/btr0sea.c
      storage/innobase/dict/dict0crea.c
      storage/innobase/dict/dict0dict.c
      storage/innobase/ibuf/ibuf0ibuf.c
      storage/innobase/include/btr0btr.h
      storage/innobase/include/btr0btr.ic
      storage/innobase/include/sync0sync.h
      storage/innobase/read/read0read.c
      storage/innobase/row/row0sel.c
      storage/innobase/sync/sync0sync.c
      support-files/mysql.spec.sh
 3368 Christopher Powers	2011-08-15
      WL#4896 "Performance Schema Net IO"
      
      - Changes per code review
      - Disabled UNION tests in socket_summary_by_instance_func.
        These tests do not take into account variations in the size of
        result set metadata. 

    modified:
      include/mysql/psi/psi.h
      mysql-test/suite/perfschema/r/socket_summary_by_instance_func.result
      mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test
      storage/perfschema/pfs.cc
      storage/perfschema/table_ews_by_thread_by_event_name.cc
=== modified file 'client/CMakeLists.txt'
--- a/client/CMakeLists.txt	2011-06-30 15:46:53 +0000
+++ b/client/CMakeLists.txt	2011-07-19 14:17:58 +0000
@@ -54,6 +54,9 @@ ADD_DEPENDENCIES(mysql_upgrade GenFixPri
 MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c)
 TARGET_LINK_LIBRARIES(mysqlshow mysqlclient)
 
+MYSQL_ADD_EXECUTABLE(mysql_plugin mysql_plugin.c)
+TARGET_LINK_LIBRARIES(mysql_plugin mysqlclient)
+
 MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc)
 TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient)
 
@@ -69,7 +72,7 @@ IF(WIN32)
   MYSQL_ADD_EXECUTABLE(echo echo.c)
 ENDIF(WIN32)
 
-SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap 
+SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap mysql_plugin 
 PROPERTIES HAS_CXX TRUE)
 
 ADD_DEFINITIONS(-DHAVE_DLOPEN)

=== added file 'client/mysql_plugin.c'
--- a/client/mysql_plugin.c	1970-01-01 00:00:00 +0000
+++ b/client/mysql_plugin.c	2011-08-11 16:48:00 +0000
@@ -0,0 +1,1192 @@
+/*
+   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
+*/
+
+#include <m_string.h>
+#include <mysql.h>
+#include <my_getopt.h>
+#include <my_dir.h>
+#include <my_global.h>
+#include <stdio.h>
+#include <string.h>
+
+
+#define SHOW_VERSION "1.0.0"
+#define PRINT_VERSION do { printf("%s  Ver %s Distrib %s\n",    \
+                        my_progname, SHOW_VERSION, MYSQL_SERVER_VERSION);    \
+                      } while(0)
+
+/* Global variables. */
+static uint my_end_arg= 0;
+static uint opt_verbose=0;
+static uint opt_no_defaults= 0;
+static uint opt_print_defaults= 0;
+static char *opt_datadir=0, *opt_basedir=0,
+            *opt_plugin_dir=0, *opt_plugin_ini=0,
+            *opt_mysqld=0, *opt_my_print_defaults=0;
+static char bootstrap[FN_REFLEN];
+
+
+/* plugin struct */
+struct st_plugin
+{
+  const char *name;           /* plugin name */
+  const char *so_name;        /* plugin so (library) name */
+  const char *components[16]; /* components to load */
+} plugin_data;
+
+
+/* Options */
+static struct my_option my_long_options[] =
+{
+  {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
+    0, 0, 0, 0, 0, 0},
+  {"basedir", 'b', "The basedir for the server.",
+    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"datadir", 'd', "The datadir for the server.",
+    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"plugin-dir", 'p', "The plugin dir for the server.",
+    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"plugin-ini", 'i', "Read plugin information from configuration file "
+   "specified instead of from <plugin-dir>/<plugin_name>.ini.",
+    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"no-defaults", 'n', "Do not read values from configuration file.",
+    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"print-defaults", 'P', "Show default values from configuration file.",
+    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"mysqld", 'm', "Path to mysqld executable. Example: /sbin/temp1/mysql/bin",
+    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"my-print-defaults", 'f', "Path to my_print_defaults executable. "
+   "Example: /source/temp11/extra",
+    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"verbose", 'v',
+    "More verbose output; you can use this multiple times to get even more "
+    "verbose output.",
+    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
+    NO_ARG, 0, 0, 0, 0, 0, 0},
+  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+
+
+/* Methods */
+static int process_options(int argc, char *argv[], char *operation);
+static int check_access();
+static int find_tool(const char *tool_name, char *tool_path);
+static int find_plugin(char *tp_path);
+static int build_bootstrap_file(char *operation, char *bootstrap);
+static int dump_bootstrap_file(char *bootstrap_file);
+static int bootstrap_server(char *server_path, char *bootstrap_file);
+
+
+int main(int argc,char *argv[])
+{
+  int error= 0;
+  char tp_path[FN_REFLEN];
+  char server_path[FN_REFLEN];
+  char operation[16];
+
+  MY_INIT(argv[0]);
+  plugin_data.name= 0; // initialize name
+  
+  /*
+    The following operations comprise the method for enabling or disabling
+    a plugin. We begin by processing the command options then check the
+    directories specified for --datadir, --basedir, --plugin-dir, and
+    --plugin-ini (if specified). If the directories are Ok, we then look
+    for the mysqld executable and the plugin soname. Finally, we build a
+    bootstrap command file for use in bootstraping the server.
+    
+    If any step fails, the method issues an error message and the tool exits.
+    
+      1) Parse, execute, and verify command options.
+      2) Check access to directories.
+      3) Look for mysqld executable.
+      4) Look for the plugin.
+      5) Build a bootstrap file with commands to enable or disable plugin.
+      
+  */
+  if ((error= process_options(argc, argv, operation)) ||
+      (error= check_access()) ||
+      (error= find_tool("mysqld" FN_EXEEXT, server_path)) ||
+      (error= find_plugin(tp_path)) ||
+      (error= build_bootstrap_file(operation, bootstrap)))
+    goto exit;
+  
+  /* Dump the bootstrap file if --verbose specified. */
+  if (opt_verbose && ((error= dump_bootstrap_file(bootstrap))))
+    goto exit;
+  
+  /* Start the server in bootstrap mode and execute bootstrap commands */
+  error= bootstrap_server(server_path, bootstrap);
+
+exit:
+  /* Remove file */
+  my_delete(bootstrap, MYF(0));
+  if (opt_verbose && error == 0)
+  {
+    printf("# Operation succeeded.\n");
+  }
+
+  my_end(my_end_arg);
+  exit(error ? 1 : 0);
+  return 0;        /* No compiler warnings */
+}
+
+
+/**
+  Get a temporary file name.
+
+  @param[out]  filename   The file name of the temporary file
+  @param[in]   ext        An extension for the file (optional)
+
+  @retval int error = 1, success = 0
+*/
+
+static int make_tempfile(char *filename, const char *ext)
+{
+  int fd= 0;
+
+  if ((fd=create_temp_file(filename, NullS, ext, O_CREAT | O_WRONLY,
+         MYF(MY_WME))) < 0)
+  {
+    fprintf(stderr, "ERROR: Cannot generate temporary file. Error code: %d.\n",
+            fd);
+    return 1;
+  }
+  my_close(fd, MYF(0));
+  return 0;
+}
+
+
+/**
+  Get the value of an option from a string read from my_print_defaults output.
+
+  @param[in]  line   The line (string) read from the file
+  @param[in]  item   The option to search for (e.g. --datadir)
+
+  @returns NULL if not found, string containing value if found
+*/
+
+static char *get_value(char *line, const char *item)
+{
+  char *destination= 0;
+  int item_len= (int)strlen(item);
+  int line_len = (int)strlen(line);
+
+  if ((strncasecmp(line, item, item_len) == 0))
+  {
+    int start= 0;
+    char *s= 0;
+
+    s = line + item_len + 1;
+    destination= my_strndup(s, line_len - start, MYF(MY_FAE));
+    destination[line_len - item_len - 2]= 0;
+  }
+  return destination;
+}
+
+
+/**
+  Run a command in a shell.
+
+  This function will attempt to execute the command specified by using the
+  popen() method to open a shell and execute the command passed and store the
+  output in a result file. If the --verbose option was specified, it will open
+  the result file and print the contents to stdout.
+
+  @param[in]  cmd   The command to execute.
+  @param[in]  mode  The mode for popen() (e.g. "r", "w", "rw")
+
+  @return int error code or 0 for success.
+*/
+
+static int run_command(char* cmd, const char *mode)
+{
+  char buf[512]= {0};
+  FILE *res_file;
+  int error;
+
+  if (!(res_file= popen(cmd, mode)))
+    return -1;
+
+  if (opt_verbose)
+  {
+    while (fgets(buf, sizeof(buf), res_file))
+    {
+      fprintf(stdout, "%s", buf);
+    }
+  }
+  error= pclose(res_file);
+  return error;
+}
+
+
+#ifdef __WIN__
+/**
+  Check to see if there are spaces in a path.
+  
+  @param[in]  path  The Windows path to examine.
+
+  @retval int spaces found = 1, no spaces = 0
+*/
+static int has_spaces(const char *path)
+{
+  if (strchr(path, ' ') != NULL)
+    return 1;
+  return 0;
+}
+
+
+/**
+  Convert a Unix path to a Windows path.
+ 
+  @param[in]  path  The Windows path to examine.
+
+  @returns string containing path with / changed to \\
+*/
+static char *convert_path(const char *argument)
+{
+  /* Convert / to \\ to make Windows paths */
+  char *winfilename= my_strdup(argument, MYF(MY_FAE));
+  char *pos, *end;
+  int length= strlen(argument);
+
+  for (pos= winfilename, end= pos+length ; pos < end ; pos++)
+  {
+    if (*pos == '/')
+    {
+      *pos= '\\';
+    }
+  }
+  return winfilename;
+}
+
+
+/**
+  Add quotes if the path has spaces in it.
+
+  @param[in]  path  The Windows path to examine.
+
+  @returns string containing excaped quotes if spaces found in path
+*/
+static char *add_quotes(const char *path)
+{
+  char windows_cmd_friendly[FN_REFLEN];
+
+  if (has_spaces(path))
+    snprintf(windows_cmd_friendly, sizeof(windows_cmd_friendly),
+             "\"%s\"", path);
+  else
+    snprintf(windows_cmd_friendly, sizeof(windows_cmd_friendly),
+             "%s", path);
+  return my_strdup(windows_cmd_friendly, MYF(MY_FAE));
+}
+#endif
+
+
+/**
+  Get the default values from the my.cnf file.
+
+  This method gets the default values for the following parameters:
+
+  --datadir
+  --basedir
+  --plugin-dir
+  --plugin-ini
+
+  These values are used if the user has not specified a value.
+
+  @retval int error = 1, success = 0
+*/
+
+static int get_default_values()
+{
+  char tool_path[FN_REFLEN];
+  char defaults_cmd[FN_REFLEN];
+  char defaults_file[FN_REFLEN];
+  char line[FN_REFLEN];
+  int error= 0;
+  int ret= 0;
+  FILE *file= 0;
+
+  memset(tool_path, 0, FN_REFLEN);
+  if ((error= find_tool("my_print_defaults" FN_EXEEXT, tool_path)))
+    goto exit;
+  else
+  {
+    if ((error= make_tempfile(defaults_file, "txt")))
+      goto exit;
+
+#ifdef __WIN__
+    {
+      char *format_str= 0;
+  
+      if (has_spaces(tool_path) || has_spaces(defaults_file))
+        format_str = "\"%s mysqld > %s\"";
+      else
+        format_str = "%s mysqld > %s";
+  
+      snprintf(defaults_cmd, sizeof(defaults_cmd), format_str,
+               add_quotes(tool_path), add_quotes(defaults_file));
+      if (opt_verbose)
+      {
+        printf("# my_print_defaults found: %s\n", tool_path);
+      }
+    }
+#else
+    snprintf(defaults_cmd, sizeof(defaults_cmd),
+             "%s mysqld > %s", tool_path, defaults_file);
+#endif
+
+    /* Execute the command */
+    if (opt_verbose)
+    {
+      printf("# Command: %s\n", defaults_cmd);
+    }
+    error= run_command(defaults_cmd, "r");
+    if (error)
+    {
+      fprintf(stderr, "ERROR: my_print_defaults failed. Error code: %d.\n",
+              ret);
+      goto exit;
+    }
+    /* Now open the file and read the defaults we want. */
+    file= fopen(defaults_file, "r");
+    while (fgets(line, FN_REFLEN, file) != NULL)
+    {
+      char *value= 0;
+
+      if ((opt_datadir == 0) && ((value= get_value(line, "--datadir"))))
+      {
+        opt_datadir= my_strdup(value, MYF(MY_FAE));
+      }
+      if ((opt_basedir == 0) && ((value= get_value(line, "--basedir"))))
+      {
+        opt_basedir= my_strdup(value, MYF(MY_FAE));
+      }
+      if ((opt_plugin_dir == 0) && ((value= get_value(line, "--plugin_dir"))))
+      {
+        opt_plugin_dir= my_strdup(value, MYF(MY_FAE));
+      }
+      if ((opt_plugin_ini == 0) && ((value= get_value(line, "--plugin_ini"))))
+      {
+        opt_plugin_ini= my_strdup(value, MYF(MY_FAE));
+      }
+    }
+  }
+exit:
+  if (file)
+  {
+    fclose(file);
+    /* Remove file */
+    my_delete(defaults_file, MYF(0));
+  }
+  return error;
+}
+
+
+/**
+  Print usage.
+*/
+
+static void usage(void)
+{
+  PRINT_VERSION;
+  puts("Copyright (c) 2011, Oracle and/or its affiliates. "
+       "All rights reserved.\n");
+  puts("Enable or disable plugins.");
+  printf("\nUsage: %s [options] <plugin> ENABLE|DISABLE\n\nOptions:\n",
+     my_progname);
+  my_print_help(my_long_options);
+  puts("\n");
+}
+
+
+/**
+  Print the default values as read from the my.cnf file.
+
+  This method displays the default values for the following parameters:
+
+  --datadir
+  --basedir
+  --plugin-dir
+  --plugin-ini
+
+*/
+
+static void print_default_values(void)
+{
+  printf("%s would have been started with the following arguments:\n",
+         my_progname);
+  get_default_values();
+  if (opt_datadir)
+  {
+    printf("--datadir=%s ", opt_datadir);
+  }
+  if (opt_basedir)
+  {
+    printf("--basedir=%s ", opt_basedir);
+  }
+  if (opt_plugin_dir)
+  {
+    printf("--plugin_dir=%s ", opt_plugin_dir);
+  }
+  if (opt_plugin_ini)
+  {
+    printf("--plugin_ini=%s ", opt_plugin_ini);
+  }
+  if (opt_mysqld)
+  {
+    printf("--mysqld=%s ", opt_mysqld);
+  }
+  if (opt_my_print_defaults)
+  {
+    printf("--my_print_defaults=%s ", opt_my_print_defaults);
+  }
+  printf("\n");
+}
+
+
+/**
+  Process the arguments and identify an option and store its value.
+
+  @param[in]  optid      The single character shortcut for the argument.
+  @param[in]  my_option  Structure of legal options.
+  @param[in]  argument   The argument value to process.
+*/
+
+static my_bool
+get_one_option(int optid,
+               const struct my_option *opt __attribute__((unused)),
+               char *argument)
+{
+  switch(optid) {
+  case 'n':
+    opt_no_defaults++;
+    break;
+  case 'P':
+    opt_print_defaults++;
+    print_default_values();
+    break;
+  case 'v':
+    opt_verbose++;
+    break;
+  case 'V':
+    PRINT_VERSION;
+    exit(0);
+    break;
+  case '?':
+  case 'I':          /* Info */
+    usage();
+    exit(0);
+  case 'd':
+    opt_datadir= my_strdup(argument, MYF(MY_FAE));
+    break;
+  case 'b':
+    opt_basedir= my_strdup(argument, MYF(MY_FAE));
+    break;
+  case 'p':
+    opt_plugin_dir= my_strdup(argument, MYF(MY_FAE));
+    break;
+  case 'i':
+    opt_plugin_ini= my_strdup(argument, MYF(MY_FAE));
+    break;
+  case 'm':
+    opt_mysqld= my_strdup(argument, MYF(MY_FAE));
+    break;
+  case 'f':
+    opt_my_print_defaults= my_strdup(argument, MYF(MY_FAE));
+    break;
+  }
+  return 0;
+}
+
+
+/**
+  Check to see if a file exists.
+
+  @param[in]  filename  File to locate.
+
+  @retval int file not found = 1, file found = 0
+*/
+
+static int file_exists(char * filename)
+{
+  MY_STAT stat_arg;
+
+  if (!my_stat(filename, &stat_arg, MYF(0)))
+  {
+    return 0;
+  }
+  return 1;
+}
+
+
+/**
+  Search a specific path and sub directory for a file name.
+
+  @param[in]  base_path  Original path to use.
+  @param[in]  tool_name  Name of the tool to locate.
+  @param[in]  subdir     The sub directory to search.
+  @param[out] tool_path  If tool found, return complete path.
+
+  @retval int error = 1, success = 0
+*/
+
+static int search_dir(const char * base_path, const char *tool_name,
+                      const char *subdir, char *tool_path)
+{
+  char new_path[FN_REFLEN];
+  char source_path[FN_REFLEN];
+
+  strcpy(source_path, base_path);
+  strcat(source_path, subdir);
+  fn_format(new_path, tool_name, source_path, "", MY_UNPACK_FILENAME);
+  if (file_exists(new_path))
+  {
+    strcpy(tool_path, new_path);
+    return 1;
+  }
+  return 0;
+}
+
+
+/**
+  Search known common paths and sub directories for a file name.
+
+  @param[in]  base_path  Original path to use.
+  @param[in]  tool_name  Name of the tool to locate.
+  @param[out] tool_path  If tool found, return complete path.
+
+  @retval int error = 1, success = 0
+*/
+
+static int search_paths(const char *base_path, const char *tool_name,
+                        char *tool_path)
+{
+  int i= 0;
+
+  static const char *paths[]= {
+    "", "/share/",  "/scripts/", "/bin/", "/sbin/", "/libexec/",
+    "/mysql/", "/sql/",
+  };
+  for (i = 0 ; i < (int)array_elements(paths); i++)
+  {
+    if (search_dir(base_path, tool_name, paths[i], tool_path))
+    {
+      return 1;
+    }
+  }
+  return 0;
+}
+
+
+/**
+  Read the plugin ini file.
+
+  This function attempts to read the plugin config file from the plugin_dir
+  path saving the data in the the st_plugin structure. If the file is not
+  found or the file cannot be read, an error is generated.
+
+  @retval int error = 1, success = 0
+*/
+
+static int load_plugin_data(char *plugin_name, char *config_file)
+{
+  FILE *file_ptr;
+  char path[FN_REFLEN];
+  char line[1024];
+  char *reason= 0;
+  char *res;
+  int i= -1;
+
+  if (opt_plugin_ini == 0)
+  {
+    fn_format(path, config_file, opt_plugin_dir, "", MYF(0));
+    opt_plugin_ini= my_strdup(path, MYF(MY_FAE));
+  }
+  if (!file_exists(opt_plugin_ini))
+  {
+    reason= (char *)"File does not exist.";
+    goto error;
+  }
+
+  file_ptr= fopen(opt_plugin_ini, "r");
+  if (file_ptr == NULL)
+  {
+    reason= (char *)"Cannot open file.";
+    goto error;
+  }
+
+  /* save name */
+  plugin_data.name= my_strdup(plugin_name, MYF(MY_WME));
+
+  /* Read plugin components */
+  while (i < 16)
+  {
+    res= fgets(line, sizeof(line), file_ptr);
+    /* strip /n */
+    if (line[strlen(line)-1] == '\n')
+    {
+      line[strlen(line)-1]= '\0';
+    }
+    if (res == NULL)
+    {
+      if (i < 1)
+      {
+        reason= (char *)"Bad format in plugin configuration file.";
+        fclose(file_ptr);
+        goto error;        
+      }
+      break;
+    }
+    if ((line[0] == '#') || (line[0] == '\n')) // skip comment and blank lines
+    {
+      continue;
+    }
+    if (i == -1) // if first pass, read this line as so_name
+    {
+      /* Add proper file extension for soname */
+      strcat(line, FN_SOEXT);
+      /* save so_name */
+      plugin_data.so_name= my_strdup(line, MYF(MY_WME|MY_ZEROFILL));
+      i++;
+    }
+    else
+    {
+      if (strlen(line) > 0)
+      {
+        plugin_data.components[i]= my_strdup(line, MYF(MY_WME));
+        i++;
+      }
+      else
+      {
+        plugin_data.components[i]= NULL;
+      }
+    }
+  }
+  
+  fclose(file_ptr);
+  return 0;
+
+error:
+  fprintf(stderr, "ERROR: Cannot read plugin config file %s. %s\n",
+          plugin_name, reason);
+  return 1;
+}
+
+
+/**
+  Check the options for validity.
+
+  This function checks the arguments for validity issuing the appropriate
+  error message if arguments are missing or invalid. On success, @operation
+  is set to either "ENABLE" or "DISABLE".
+
+  @param[in]  argc       The number of arguments.
+  @param[in]  argv       The arguments.
+  @param[out] operation  The operation chosen (enable|disable)
+
+  @retval int error = 1, success = 0
+*/
+
+static int check_options(int argc, char **argv, char *operation)
+{
+  int i= 0;                    // loop counter
+  int num_found= 0;            // number of options found (shortcut loop)
+  char config_file[FN_REFLEN]; // configuration file name
+  char plugin_name[FN_REFLEN]; // plugin name
+  
+  /* Form prefix strings for the options. */
+  const char *basedir_prefix = "--basedir=";
+  int basedir_len= strlen(basedir_prefix);
+  const char *datadir_prefix = "--datadir=";
+  int datadir_len= strlen(datadir_prefix);
+  const char *plugin_dir_prefix = "--plugin_dir=";
+  int plugin_dir_len= strlen(plugin_dir_prefix);
+
+  strcpy(plugin_name, "");
+  for (i = 0; i < argc && num_found < 5; i++)
+  {
+
+    if (!argv[i])
+    {
+      continue;
+    }
+    if ((strcasecmp(argv[i], "ENABLE") == 0) ||
+        (strcasecmp(argv[i], "DISABLE") == 0))
+    {
+      strcpy(operation, argv[i]);
+      num_found++;
+    }
+    else if ((strncasecmp(argv[i], basedir_prefix, basedir_len) == 0) &&
+             !opt_basedir)
+    {
+      opt_basedir= my_strndup(argv[i]+basedir_len,
+                              strlen(argv[i])-basedir_len, MYF(MY_FAE));
+      num_found++;
+    }
+    else if ((strncasecmp(argv[i], datadir_prefix, datadir_len) == 0) &&
+             !opt_datadir)
+    {
+      opt_datadir= my_strndup(argv[i]+datadir_len,
+                              strlen(argv[i])-datadir_len, MYF(MY_FAE));
+      num_found++;
+    }
+    else if ((strncasecmp(argv[i], plugin_dir_prefix, plugin_dir_len) == 0) &&
+             !opt_plugin_dir)
+    {
+      opt_plugin_dir= my_strndup(argv[i]+plugin_dir_len,
+                                 strlen(argv[i])-plugin_dir_len, MYF(MY_FAE));
+      num_found++;
+    }
+    /* read the plugin config file and check for match against argument */
+    else
+    {
+      strcpy(plugin_name, argv[i]);
+      strcpy(config_file, argv[i]);
+      strcat(config_file, ".ini");
+    }
+  }
+
+  if (!opt_basedir)
+  {
+    fprintf(stderr, "ERROR: Missing --basedir option.\n");
+    return 1;
+  }
+
+  if (!opt_datadir)
+  {
+    fprintf(stderr, "ERROR: Missing --datadir option.\n");
+    return 1;
+  }
+
+  if (!opt_plugin_dir)
+  {
+    fprintf(stderr, "ERROR: Missing --plugin_dir option.\n");
+    return 1;
+  }
+  /* If a plugin was specified, read the config file. */
+  else if (strlen(plugin_name) > 0) 
+  {
+    if (load_plugin_data(plugin_name, config_file))
+    {
+      return 1;
+    }
+    if (strcasecmp(plugin_data.name, plugin_name) != 0)
+    {
+      fprintf(stderr, "ERROR: plugin name requested does not match config "
+              "file data.\n");
+      return 1;
+    }
+  }
+  else
+  {
+    fprintf(stderr, "ERROR: No plugin specified.\n");
+    return 1;
+  }
+
+  if ((strlen(operation) == 0))
+  {
+    fprintf(stderr, "ERROR: missing operation. Please specify either "
+            "'<plugin> ENABLE' or '<plugin> DISABLE'.\n");
+    return 1;
+  }
+
+  return 0;
+}
+
+
+/**
+  Parse, execute, and verify command options.
+  
+  This method handles all of the option processing including the optional
+  features for displaying data (--print-defaults, --help ,etc.) that do not
+  result in an attempt to ENABLE or DISABLE of a plugin.
+  
+  @param[in]   arc        Count of arguments
+  @param[in]   argv       Array of arguments
+  @param[out]  operation  Operation (ENABLE or DISABLE)
+  
+  @retval int error = 1, success = 0, exit program = -1
+*/
+
+static int process_options(int argc, char *argv[], char *operation)
+{
+  int error= 0;
+  int i= 0;
+  
+  /* Parse and execute command-line options */
+  if ((error= handle_options(&argc, &argv, my_long_options, get_one_option)))
+    goto exit;
+
+  /* If the print defaults option used, exit. */
+  if (opt_print_defaults)
+  {
+    error= -1;
+    goto exit;
+  }
+
+  /* Add a trailing directory separator if not present */
+  if (opt_basedir)
+  {
+    i= (int)strlength(opt_basedir);
+    if (opt_basedir[i-1] != FN_LIBCHAR || opt_basedir[i-1] != FN_LIBCHAR2)
+#ifdef __WIN__
+      if (opt_basedir[i-1] != '/')
+        strcat(opt_basedir, "//");
+#else
+      strcat(opt_basedir, FN_DIRSEP);
+#endif
+  }
+  
+  /*
+    If the user did not specify the option to skip loading defaults from a
+    config file and the required options are not present or there was an error
+    generated when the defaults were read from the file, exit.
+  */
+  if (!opt_no_defaults && ((error= get_default_values())))
+  {
+    error= -1;
+    goto exit;
+  }
+
+  /*
+   Check to ensure required options are present and validate the operation.
+   Note: this method also validates the plugin specified by attempting to
+   read a configuration file named <plugin_name>.ini from the --plugin-dir
+   or --plugin-ini location if the --plugin-ini option presented.
+  */
+  strcpy(operation, "");
+  if ((error = check_options(argc, argv, operation)))
+  {
+    goto exit;
+  }
+
+  if (opt_verbose)
+  {
+    printf("#    basedir = %s\n", opt_basedir);
+    printf("# plugin_dir = %s\n", opt_plugin_dir);
+    printf("#    datadir = %s\n", opt_datadir);
+    printf("# plugin_ini = %s\n", opt_plugin_ini);
+  }
+
+exit:
+  return error;
+}
+
+
+/**
+  Check access
+  
+  This method checks to ensure all of the directories (opt_basedir,
+  opt_plugin_dir, opt_datadir, and opt_plugin_ini) are accessible by
+  the user.
+  
+  @retval int error = 1, success = 0
+*/
+
+static int check_access()
+{
+  int error= 0;
+  
+  if ((error= my_access(opt_basedir, F_OK)))
+  {
+    fprintf(stderr, "ERROR: Cannot access basedir at '%s'.\n",
+            opt_basedir);
+    goto exit;
+  }
+  if ((error= my_access(opt_plugin_dir, F_OK)))
+  {
+    fprintf(stderr, "ERROR: Cannot access plugin_dir at '%s'.\n",
+            opt_plugin_dir);
+    goto exit;
+  }
+  if ((error= my_access(opt_datadir, F_OK)))
+  {
+    fprintf(stderr, "ERROR: Cannot access datadir at '%s'.\n",
+            opt_datadir);
+    goto exit;
+  }
+  if ((error= my_access(opt_plugin_ini, F_OK)))
+  {
+    fprintf(stderr, "ERROR: Cannot access plugin config file at '%s'.\n",
+            opt_plugin_ini);
+    goto exit;
+  }
+  if ((error= my_access(opt_mysqld, F_OK)))
+  {
+    fprintf(stderr, "ERROR: Cannot access mysqld path '%s'.\n",
+            opt_mysqld);
+    goto exit;
+  }
+  if ((error= my_access(opt_my_print_defaults, F_OK)))
+  {
+    fprintf(stderr, "ERROR: Cannot access my-print-defaults path '%s'.\n",
+            opt_my_print_defaults);
+    goto exit;
+  }
+
+exit:
+  return error;
+}
+
+
+/**
+  Locate the tool and form tool path.
+
+  @param[in]  tool_name  Name of the tool to locate.
+  @param[out] tool_path  If tool found, return complete path.
+
+  @retval int error = 1, success = 0
+*/
+
+static int find_tool(const char *tool_name, char *tool_path)
+{
+  int i= 0;
+
+  const char *paths[]= {
+    opt_basedir, opt_mysqld, opt_my_print_defaults, "/usr",
+    "/usr/local/mysql", "/usr/sbin", "/usr/share", "/extra", "/extra/debug",
+    "/extra/release", "/bin", "/usr/bin", "/mysql/bin"
+  };
+  for (i= 0; i < (int)array_elements(paths); i++)
+  {
+    if (paths[i] && (search_paths(paths[i], tool_name, tool_path)))
+      goto found;
+  }
+  fprintf(stderr, "WARNING: Cannot find %s.\n", tool_name);
+  return 1;
+found:
+  if (opt_verbose)
+    printf("# Found tool '%s' as '%s'.\n", tool_name, tool_path);
+  return 0;
+}
+
+
+/**
+  Find the plugin library.
+
+  This function attempts to use the @c plugin_dir option passed on the
+  command line to locate the plugin.
+
+  @param[out] tp_path   The actual path to plugin with FN_SOEXT applied.
+
+  @retval int error = 1, success = 0
+*/
+
+static int find_plugin(char *tp_path)
+{
+  /* Check for existance of plugin */
+  fn_format(tp_path, plugin_data.so_name, opt_plugin_dir, "", MYF(0));
+  if (!file_exists(tp_path))
+  {
+    fprintf(stderr, "ERROR: The plugin library is missing or in a different"
+            " location.\n");
+    return 1;
+  }
+  else if (opt_verbose)
+  {
+    printf("# Found plugin '%s' as '%s'\n", plugin_data.name, tp_path);
+  }
+  return 0;
+}
+
+
+/**
+  Build the boostrap file.
+  
+  Create a new file and populate it with SQL commands to ENABLE or DISABLE
+  the plugin via INSERT and DELETE operations on the mysql.plugin table.
+
+  param[in]  operation  The type of operation (ENABLE or DISABLE)
+  param[out] bootstrap  A FILE* pointer
+  
+  @retval int error = 1, success = 0
+*/
+
+static int build_bootstrap_file(char *operation, char *bootstrap)
+{
+  int error= 0;
+  FILE *file= 0;
+  
+  /*
+    Perform plugin operation : ENABLE or DISABLE
+
+    The following creates a temporary bootstrap file and populates it with
+    the appropriate SQL commands for the operation. For ENABLE, INSERT
+    statements are created. For DISABLE, DELETE statements are created. The
+    values for these statements are derived from the plugin_data read from the
+    <plugin_name>.ini configuration file. Once the file is built, a call to
+    mysqld is made in read only, bootstrap modes to read the SQL statements
+    and execute them.
+  */
+  if ((error= make_tempfile(bootstrap, "sql")))
+  {
+    /* Fail if we cannot create a temporary file for the bootstrap commands. */
+    fprintf(stderr, "ERROR: Cannot create bootstrap file.\n");
+    goto exit;
+  }
+  if ((file= fopen(bootstrap, "w+")) == NULL)
+  {
+    fprintf(stderr, "ERROR: Cannot open bootstrap file for writing.\n");
+    error= 1;
+    goto exit;
+  }
+  if (strcasecmp(operation, "enable") == 0)
+  {
+    int i= 0;
+    fprintf(file, "INSERT IGNORE INTO mysql.plugin VALUES ");
+    for (i= 0; i < (int)array_elements(plugin_data.components); i++)
+    {
+      /* stop when we read the end of the symbol list - marked with NULL */
+      if (plugin_data.components[i] == NULL)
+      {
+        break;
+      }
+      if (i > 0)
+      {
+        fprintf(file, ", ");
+      }
+      fprintf(file, "('%s','%s')",
+              plugin_data.components[i], plugin_data.so_name);
+    }
+    fprintf(file, ";\n");
+    if (opt_verbose)
+    {
+      printf("# Enabling %s...\n", plugin_data.name);
+    }
+  }
+  else
+  {
+    fprintf(file,
+            "DELETE FROM mysql.plugin WHERE name = '%s';", plugin_data.name);
+    if (opt_verbose)
+    {
+      printf("# Disabling %s...\n", plugin_data.name);
+    }
+  }
+  
+exit:
+  fclose(file);
+  return error;
+}
+
+
+/**
+  Dump bootstrap file.
+  
+  Read the contents of the bootstrap file and print it out.
+  
+  @param[in]  bootstrap_file  Name of bootstrap file to read
+  
+  @retval int error = 1, success = 0
+*/
+
+static int dump_bootstrap_file(char *bootstrap_file)
+{
+  char *ret= 0;
+  int error= 0;
+  char query_str[512];
+  FILE *file= 0;
+
+  if ((file= fopen(bootstrap_file, "r")) == NULL)
+  {
+    fprintf(stderr, "ERROR: Cannot open bootstrap file for reading.\n");
+    error= 1;
+    goto exit;
+  }
+  ret= fgets(query_str, 512, file);
+  if (ret == 0)
+  {
+    fprintf(stderr, "ERROR: Cannot read bootstrap file.\n");
+    error= 1;
+    goto exit;
+  }
+  printf("# Query: %s", query_str);
+
+exit:
+  if (file)
+  {
+    fclose(file);
+  }
+  return error;
+}
+
+
+/**
+  Bootstrap the server
+  
+  Create a command line sequence to launch mysqld in bootstrap mode. This
+  will allow mysqld to launch a minimal server instance to read and
+  execute SQL commands from a file piped in (the boostrap file). We use
+  the --no-defaults option to skip reading values from the config file.
+
+  The bootstrap mode skips loading of plugins and many other subsystems.
+  This allows the mysql_plugin tool to insert the correct rows into the
+  mysql.plugin table (for ENABLE) or delete the rows (for DISABLE). Once
+  the server is launched in normal mode, the plugin will be loaded
+  (for ENABLE) or not loaded (for DISABLE). In this way, we avoid the
+  (sometimes) complicated LOAD PLUGIN commands.
+
+  @param[in]  server_path     Path to server executable
+  @param[in]  bootstrap_file  Name of bootstrap file to read
+
+  @retval int error = 1, success = 0
+*/
+
+static int bootstrap_server(char *server_path, char *bootstrap_file)
+{
+  char bootstrap_cmd[FN_REFLEN];
+  int error= 0;
+  int ret= 0;
+
+#ifdef __WIN__
+  char *format_str= 0;
+  char *verbose_str= "";
+  
+  if (opt_verbose)
+    strcat(verbose_str, "--console");
+  if (has_spaces(opt_datadir) || has_spaces(opt_basedir) ||
+      has_spaces(bootstrap_file))
+    format_str= "\"%s %s --bootstrap --datadir=%s --basedir=%s < %s\"";
+  else 
+    format_str= "%s %s --bootstrap --datadir=%s --basedir=%s < %s";
+
+  snprintf(bootstrap_cmd, sizeof(bootstrap_cmd), format_str,
+           add_quotes(convert_path(server_path)), verbose_str,
+           add_quotes(opt_datadir), add_quotes(opt_basedir),
+           add_quotes(bootstrap_file));
+#else
+  snprintf(bootstrap_cmd, sizeof(bootstrap_cmd),
+           "%s --no-defaults --bootstrap --datadir=%s --basedir=%s"
+           " < %s", server_path, opt_datadir, opt_basedir, bootstrap_file);
+#endif
+
+  /* Execute the command */
+  if (opt_verbose)
+  {
+    printf("# Command: %s\n", bootstrap_cmd);
+  }
+  error= run_command(bootstrap_cmd, "r");
+  if (error)
+    fprintf(stderr,
+            "ERROR: Unexpected result from bootstrap. Error code: %d.\n",
+            ret);
+  
+  return error;
+}

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2011-07-04 00:25:46 +0000
+++ b/include/my_global.h	2011-08-11 16:48:00 +0000
@@ -599,6 +599,8 @@ typedef SOCKET_SIZE_TYPE size_socket;
 #define FN_LIBCHAR	'\\'
 #define FN_LIBCHAR2	'/'
 #define FN_DIRSEP       "/\\"               /* Valid directory separators */
+#define FN_EXEEXT   ".exe"
+#define FN_SOEXT    ".dll"
 #define FN_ROOTDIR	"\\"
 #define FN_DEVCHAR	':'
 #define FN_NETWORK_DRIVES	/* Uses \\ to indicate network drives */
@@ -607,6 +609,8 @@ typedef SOCKET_SIZE_TYPE size_socket;
 #define FN_LIBCHAR	'/'
 #define FN_LIBCHAR2	'/'
 #define FN_DIRSEP       "/"     /* Valid directory separators */
+#define FN_EXEEXT   ""
+#define FN_SOEXT    ".so"
 #define FN_ROOTDIR	"/"
 #endif
 

=== added file 'mysql-test/include/daemon_example_bad_format.ini'
--- a/mysql-test/include/daemon_example_bad_format.ini	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/daemon_example_bad_format.ini	2011-07-19 14:27:15 +0000
@@ -0,0 +1,8 @@
+#
+# Plugin configuration file. Place the following on a separate line:
+#
+# library binary file name (without .so or .dll)
+# component_name
+# [component_name] - additional components in plugin
+#
+libdaemon_example   

=== added file 'mysql-test/include/daemon_example_bad_soname.ini'
--- a/mysql-test/include/daemon_example_bad_soname.ini	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/daemon_example_bad_soname.ini	2011-07-19 14:27:15 +0000
@@ -0,0 +1,9 @@
+#
+# Plugin configuration file. Place the following on a separate line:
+#
+# library binary file name (without .so or .dll)
+# component_name
+# [component_name] - additional components in plugin
+#
+libdaemon_BADNAME
+daemon_BADNAME

=== modified file 'mysql-test/include/join_cache.inc'
--- a/mysql-test/include/join_cache.inc	2011-06-24 13:09:12 +0000
+++ b/mysql-test/include/join_cache.inc	2011-08-05 14:47:50 +0000
@@ -1763,9 +1763,6 @@ set @@join_buffer_size=default;
 --echo # JCL>=5 AND MRR ENABLED"
 --echo
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
-
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
    col_varchar_key varchar(1) NOT NULL,    
    KEY col_int_key (col_int_key),
@@ -1797,15 +1794,11 @@ eval explain $query;
 eval $query;
 
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 --echo
 --echo # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 --echo
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
-
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -1857,15 +1850,11 @@ eval explain $query;
 eval $query;
 
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 --echo
 --echo # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 --echo
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
-
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
  pk int(11) NOT NULL,
@@ -1904,4 +1893,29 @@ eval explain $query;
 eval $query;
 
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+--echo
+--echo # BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+--echo # JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+--echo
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+
+let $query=SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+  as t4_i FROM t1
+  LEFT JOIN t2 ON t1.k = t2.pk
+  LEFT JOIN t3 ON t3.i
+  LEFT JOIN t4 ON t4.pk = t2.pk;
+
+eval EXPLAIN $query;
+eval $query;
+
+DROP TABLE t1, t2, t3, t4; 

=== modified file 'mysql-test/include/plugin.defs'
--- a/mysql-test/include/plugin.defs	2011-05-30 13:55:44 +0000
+++ b/mysql-test/include/plugin.defs	2011-07-19 14:17:58 +0000
@@ -39,3 +39,4 @@ ha_archive         storage/archive    AR
 ha_blackhole       storage/blackhole  BLACKHOLE_PLUGIN
 ha_federated       storage/federated  FEDERATED_PLUGIN
 mypluglib          plugin/fulltext    SIMPLE_PARSER
+libdaemon_example  plugin/daemon_example DAEMONEXAMPLE

=== modified file 'mysql-test/include/range.inc'
--- a/mysql-test/include/range.inc	2011-05-19 12:03:55 +0000
+++ b/mysql-test/include/range.inc	2011-08-05 14:30:29 +0000
@@ -1503,3 +1503,34 @@ let $query= SELECT * FROM t100 WHERE I <
 --eval $query
 
 DROP TABLE t10,t100;
+
+--echo #
+--echo # BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
+--echo # AFTER FLUSH TABLES [-INT VS NULL]
+--echo #
+CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (-100,1),(1,6);
+
+CREATE TABLE t2 (
+  col_int_key INT,
+  col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT",
+  pk INT NOT NULL,
+  PRIMARY KEY (pk),
+  KEY (col_int_key)
+) ENGINE=InnoDB;
+
+INSERT INTO t2 VALUES
+(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8);
+
+let $query=SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+
+eval EXPLAIN $query;
+eval $query;
+--echo # need FLUSH so that InnoDB statistics change and thus plan changes
+FLUSH TABLES;
+eval EXPLAIN $query;
+eval $query;
+
+DROP TABLE t1,t2;

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2011-08-05 10:26:13 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-08-15 08:58:05 +0000
@@ -168,6 +168,7 @@ my $opt_suites;
 
 our $opt_verbose= 0;  # Verbose output, enable with --verbose
 our $exe_mysql;
+our $exe_mysql_plugin;
 our $exe_mysqladmin;
 our $exe_mysqltest;
 our $exe_libtool;
@@ -1967,6 +1968,7 @@ sub executable_setup () {
   # Look for the client binaries
   $exe_mysqladmin=     mtr_exe_exists("$path_client_bindir/mysqladmin");
   $exe_mysql=          mtr_exe_exists("$path_client_bindir/mysql");
+  $exe_mysql_plugin=   mtr_exe_exists("$path_client_bindir/mysql_plugin");
 
   $exe_mysql_embedded= mtr_exe_maybe_exists("$basedir/libmysqld/examples/mysql_embedded");
 
@@ -2374,6 +2376,7 @@ sub environment_setup {
   $ENV{'MYSQLADMIN'}=               native_path($exe_mysqladmin);
   $ENV{'MYSQL_CLIENT_TEST'}=        mysql_client_test_arguments();
   $ENV{'EXE_MYSQL'}=                $exe_mysql;
+  $ENV{'MYSQL_PLUGIN'}=             $exe_mysql_plugin;
   $ENV{'MYSQL_EMBEDDED'}=           $exe_mysql_embedded;
 
   # ----------------------------------------------------

=== modified file 'mysql-test/r/group_by.result'
--- a/mysql-test/r/group_by.result	2011-07-22 07:53:39 +0000
+++ b/mysql-test/r/group_by.result	2011-08-15 08:58:05 +0000
@@ -1987,3 +1987,18 @@ EXECUTE stmt;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1, t2;
 # End of Bug #11766429
+#
+# Bug#12798270: ASSERTION `!TAB->SORTED' FAILED IN JOIN_READ_KEY2
+#
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (pk int PRIMARY KEY);
+INSERT INTO t2 VALUES (10);
+CREATE VIEW v1 AS SELECT t2.pk FROM t2;
+SELECT v1.pk
+FROM t1 LEFT JOIN v1 ON t1.i = v1.pk 
+GROUP BY v1.pk;
+pk
+DROP VIEW v1;
+DROP TABLE t1,t2;
+# End of Bug#12798270

=== modified file 'mysql-test/r/information_schema.result'
--- a/mysql-test/r/information_schema.result	2011-08-10 07:06:02 +0000
+++ b/mysql-test/r/information_schema.result	2011-08-11 18:53:46 +0000
@@ -1902,5 +1902,119 @@ unlock tables;
 drop table t1;
 drop view v1;
 #
+# Test for bug #12828477 - "MDL SUBSYSTEM CREATES BIG OVERHEAD FOR
+#                           CERTAIN QUERIES TO INFORMATION_SCHEMA".
+#
+# Check that metadata locks which are acquired during the process
+# of opening tables/.FRMs/.TRG files while filling I_S table are
+# not kept to the end of statement. Keeping the locks has caused
+# performance problems in cases when big number of tables (.FRMs
+# or .TRG files) were scanned as cost of new lock acquisition has
+# increased linearly.
+drop database if exists mysqltest;
+create database mysqltest;
+use mysqltest;
+create table t0 (i int);
+create table t1 (j int);
+create table t2 (k int);
+#
+# Test that we don't keep locks in case when we to fill
+# I_S table we perform full-blown table open.
+#
+# Acquire lock on 't2' so upcoming RENAME is
+# blocked.
+lock tables t2 read;
+#
+# Switching to connection 'con12828477_1'. 
+#
+# The below RENAME should wait on 't2' while
+# keeping X lock on 't1'.
+rename table t1 to t3, t2 to t1, t3 to t2;
+#
+# Switching to connection 'con12828477_2'. 
+#
+# Wait while the above RENAME is blocked.
+# Issue query to I_S which will open 't0' and get
+# blocked on 't1' because of RENAME.
+select table_name, auto_increment from information_schema.tables where table_schema='mysqltest';
+#
+# Switching to connection 'con12828477_3'. 
+#
+# Wait while the above SELECT is blocked.
+#
+# Check that it holds no lock on 't0' so it can be renamed.
+rename table t0 to t4;
+#
+# Switching to connection 'default'.
+#
+#
+# Unblock the first RENAME.
+unlock tables;
+#
+# Switching to connection 'con12828477_1'. 
+#
+# Reap the first RENAME
+#
+# Switching to connection 'con12828477_2'. 
+#
+# Reap SELECT to I_S.
+table_name	auto_increment
+t0	NULL
+t1	NULL
+t2	NULL
+#
+# Switching to connection 'default'.
+#
+#
+# Now test that we don't keep locks in case when we to fill
+# I_S table we read .FRM or .TRG file only (this was the case
+# for which problem existed).
+#
+rename table t4 to t0;
+# Acquire lock on 't2' so upcoming RENAME is
+# blocked.
+lock tables t2 read;
+#
+# Switching to connection 'con12828477_1'. 
+#
+# The below RENAME should wait on 't2' while
+# keeping X lock on 't1'.
+rename table t1 to t3, t2 to t1, t3 to t2;
+#
+# Switching to connection 'con12828477_2'. 
+#
+# Wait while the above RENAME is blocked.
+# Issue query to I_S which will open 't0' and get
+# blocked on 't1' because of RENAME.
+select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest';
+#
+# Switching to connection 'con12828477_3'. 
+#
+# Wait while the above SELECT is blocked.
+#
+# Check that it holds no lock on 't0' so it can be renamed.
+rename table t0 to t4;
+#
+# Switching to connection 'default'.
+#
+#
+# Unblock the first RENAME.
+unlock tables;
+#
+# Switching to connection 'con12828477_1'. 
+#
+# Reap the first RENAME
+#
+# Switching to connection 'con12828477_2'. 
+#
+# Reap SELECT to I_S.
+event_object_table	trigger_name
+#
+# Switching to connection 'default'.
+#
+#
+# Clean-up.
+drop database mysqltest;
+#
 # End of 5.5 tests
 #

=== modified file 'mysql-test/r/innodb_icp_all.result'
--- a/mysql-test/r/innodb_icp_all.result	2011-06-09 06:22:39 +0000
+++ b/mysql-test/r/innodb_icp_all.result	2011-08-05 11:39:08 +0000
@@ -912,5 +912,30 @@ AND (a1.a != a2.a OR a1.b IS NULL);
 pk
 DROP VIEW v1;
 DROP TABLE t1;
+#
+# BUG#12601961 "SEGFAULT IN HANDLER::COMPARE_KEY2"
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL, 
+i1 INTEGER NOT NULL,
+c1 VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,3,'j'), (20,8,'e');
+EXPLAIN SELECT alias2.i1
+FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2
+ON alias2.pk AND alias2.pk <= alias1.c1
+WHERE alias2.pk = 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	alias1	ALL	NULL	NULL	NULL	NULL	2	
+1	SIMPLE	alias2	const	PRIMARY	PRIMARY	4	const	1	Using index condition
+SELECT alias2.i1
+FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2
+ON alias2.pk AND alias2.pk <= alias1.c1
+WHERE alias2.pk = 1;
+i1
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: 'j'
+DROP TABLE t1;
 set default_storage_engine= @save_storage_engine;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/innodb_mrr_all.result'
--- a/mysql-test/r/innodb_mrr_all.result	2011-07-19 15:11:15 +0000
+++ b/mysql-test/r/innodb_mrr_all.result	2011-08-05 11:39:08 +0000
@@ -389,18 +389,21 @@ set @read_rnd_buffer_size_save= @@read_r
 set read_rnd_buffer_size=64;
 create table t1(a int);
 insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t2(a char(8), b char(8), c char(8), filler char(100), key(a,b,c) );
+create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) );
 insert into t2 select 
 concat('a-', 1000 + A.a, '-a'),
 concat('b-', 1000 + B.a, '-b'),
 concat('c-', 1000 + C.a, '-c'),
 'filler'
 from t1 A, t1 B, t1 C;
-explain
-select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
+EXPLAIN select count(length(a) + length(filler))
+from t2 force index (k1)
+where a>='a-1000-a' and a <'a-1001-a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	a	a	9	NULL	99	Using index condition; Using MRR
-select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
+1	SIMPLE	t2	range	k1	k1	9	NULL	99	Using index condition; Using MRR
+select count(length(a) + length(filler))
+from t2 force index (k1)
+where a>='a-1000-a' and a <'a-1001-a';
 count(length(a) + length(filler))
 100
 drop table t2;

=== modified file 'mysql-test/r/innodb_mrr_cost_all.result'
--- a/mysql-test/r/innodb_mrr_cost_all.result	2011-07-19 15:11:15 +0000
+++ b/mysql-test/r/innodb_mrr_cost_all.result	2011-08-05 11:39:08 +0000
@@ -389,18 +389,21 @@ set @read_rnd_buffer_size_save= @@read_r
 set read_rnd_buffer_size=64;
 create table t1(a int);
 insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t2(a char(8), b char(8), c char(8), filler char(100), key(a,b,c) );
+create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) );
 insert into t2 select 
 concat('a-', 1000 + A.a, '-a'),
 concat('b-', 1000 + B.a, '-b'),
 concat('c-', 1000 + C.a, '-c'),
 'filler'
 from t1 A, t1 B, t1 C;
-explain
-select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
+EXPLAIN select count(length(a) + length(filler))
+from t2 force index (k1)
+where a>='a-1000-a' and a <'a-1001-a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	a	a	9	NULL	99	Using index condition
-select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
+1	SIMPLE	t2	range	k1	k1	9	NULL	99	Using index condition
+select count(length(a) + length(filler))
+from t2 force index (k1)
+where a>='a-1000-a' and a <'a-1001-a';
 count(length(a) + length(filler))
 100
 drop table t2;

=== modified file 'mysql-test/r/join_cache_jcl0.result'
--- a/mysql-test/r/join_cache_jcl0.result	2011-07-22 07:53:39 +0000
+++ b/mysql-test/r/join_cache_jcl0.result	2011-08-12 09:05:18 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+NULL	NULL	NULL	NULL
+1	1	9	-1
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_jcl1.result'
--- a/mysql-test/r/join_cache_jcl1.result	2011-07-22 07:53:39 +0000
+++ b/mysql-test/r/join_cache_jcl1.result	2011-08-12 09:05:18 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+NULL	NULL	NULL	NULL
+1	1	9	-1
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_jcl2.result'
--- a/mysql-test/r/join_cache_jcl2.result	2011-07-22 07:53:39 +0000
+++ b/mysql-test/r/join_cache_jcl2.result	2011-08-12 09:05:18 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+NULL	NULL	NULL	NULL
+1	1	9	-1
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_jcl3.result'
--- a/mysql-test/r/join_cache_jcl3.result	2011-07-22 07:53:39 +0000
+++ b/mysql-test/r/join_cache_jcl3.result	2011-08-12 09:05:18 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, regular buffers)
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+NULL	NULL	NULL	NULL
+1	1	9	-1
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_jcl4.result'
--- a/mysql-test/r/join_cache_jcl4.result	2011-07-22 07:53:39 +0000
+++ b/mysql-test/r/join_cache_jcl4.result	2011-08-12 09:05:18 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+NULL	NULL	NULL	NULL
+1	1	9	-1
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_jcl5.result'
--- a/mysql-test/r/join_cache_jcl5.result	2011-06-24 13:09:12 +0000
+++ b/mysql-test/r/join_cache_jcl5.result	2011-08-05 14:47:50 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, regular buffers)
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	Using join buffer (BKA, regular buffers)
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+1	1	9	-1
+NULL	NULL	NULL	NULL
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_jcl6.result'
--- a/mysql-test/r/join_cache_jcl6.result	2011-06-24 13:09:12 +0000
+++ b/mysql-test/r/join_cache_jcl6.result	2011-08-05 14:47:50 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	Using join buffer (BKA, incremental buffers)
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+1	1	9	-1
+NULL	NULL	NULL	NULL
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_jcl7.result'
--- a/mysql-test/r/join_cache_jcl7.result	2011-06-24 13:09:12 +0000
+++ b/mysql-test/r/join_cache_jcl7.result	2011-08-05 14:47:50 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, regular buffers)
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	Using join buffer (BKA_UNIQUE, regular buffers)
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+1	1	9	-1
+NULL	NULL	NULL	NULL
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_jcl8.result'
--- a/mysql-test/r/join_cache_jcl8.result	2011-06-24 13:09:12 +0000
+++ b/mysql-test/r/join_cache_jcl8.result	2011-08-05 14:47:50 +0000
@@ -2443,8 +2443,6 @@ set @@join_buffer_size=default;
 # BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH
 # JCL>=5 AND MRR ENABLED"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (  col_int_key int(11) NOT NULL,
 col_varchar_key varchar(1) NOT NULL,    
 KEY col_int_key (col_int_key),
@@ -2478,12 +2476,9 @@ field1	field2
 NULL	0
 2003-08-21 00:00:00	4
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (
 col_int_key int(11) NOT NULL,
 col_datetime_key datetime NOT NULL,
@@ -2555,12 +2550,9 @@ w	0	18
 x	0	14
 y	2	7
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
 
 # BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5"
 
-SET @old_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='mrr=on,mrr_cost_based=off';
 CREATE TABLE t1 (col_varchar_key varchar(1));
 CREATE TABLE t2 (
 pk int(11) NOT NULL,
@@ -2611,6 +2603,36 @@ NULL	7
 NULL	8
 NULL	9
 DROP TABLE t1,t2;
-SET @@optimizer_switch=@old_optimizer_switch;
+
+# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT
+# JCL=6 ONLY [NULL VERSUS NULL+#INTS]
+
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t1 VALUES (6,NULL,6),(0,1,11);
+INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL);
+INSERT INTO t3 VALUES (2,3,0),(3,4,4);
+INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL);
+EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	k	5	NULL	2	Using index
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.k	1	Using index
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	4	test.t2.pk	1	Using join buffer (BKA_UNIQUE, incremental buffers)
+SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
+as t4_i FROM t1
+LEFT JOIN t2 ON t1.k = t2.pk
+LEFT JOIN t3 ON t3.i
+LEFT JOIN t4 ON t4.pk = t2.pk;
+t2_pk	t4_pk	t4_k	t4_i
+1	1	9	-1
+NULL	NULL	NULL	NULL
+DROP TABLE t1, t2, t3, t4;
 set optimizer_join_cache_level = default;
 set optimizer_switch = default;

=== modified file 'mysql-test/r/myisam_icp_all.result'
--- a/mysql-test/r/myisam_icp_all.result	2011-06-09 06:22:39 +0000
+++ b/mysql-test/r/myisam_icp_all.result	2011-08-05 11:39:08 +0000
@@ -907,4 +907,7 @@ AND (a1.a != a2.a OR a1.b IS NULL);
 pk
 DROP VIEW v1;
 DROP TABLE t1;
+#
+# BUG#12601961 "SEGFAULT IN HANDLER::COMPARE_KEY2"
+#
 set optimizer_switch=default;

=== modified file 'mysql-test/r/myisam_mrr_all.result'
--- a/mysql-test/r/myisam_mrr_all.result	2011-07-19 15:11:15 +0000
+++ b/mysql-test/r/myisam_mrr_all.result	2011-08-05 11:39:08 +0000
@@ -392,18 +392,21 @@ set @read_rnd_buffer_size_save= @@read_r
 set read_rnd_buffer_size=64;
 create table t1(a int);
 insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t2(a char(8), b char(8), c char(8), filler char(100), key(a,b,c) );
+create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) );
 insert into t2 select 
 concat('a-', 1000 + A.a, '-a'),
 concat('b-', 1000 + B.a, '-b'),
 concat('c-', 1000 + C.a, '-c'),
 'filler'
 from t1 A, t1 B, t1 C;
-explain
-select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
+EXPLAIN select count(length(a) + length(filler))
+from t2 force index (k1)
+where a>='a-1000-a' and a <'a-1001-a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	a	a	9	NULL	92	Using index condition; Using MRR
-select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
+1	SIMPLE	t2	range	k1	k1	9	NULL	92	Using index condition; Using MRR
+select count(length(a) + length(filler))
+from t2 force index (k1)
+where a>='a-1000-a' and a <'a-1001-a';
 count(length(a) + length(filler))
 100
 drop table t2;

=== modified file 'mysql-test/r/myisam_mrr_cost_all.result'
--- a/mysql-test/r/myisam_mrr_cost_all.result	2011-07-19 15:11:15 +0000
+++ b/mysql-test/r/myisam_mrr_cost_all.result	2011-08-05 11:39:08 +0000
@@ -392,18 +392,21 @@ set @read_rnd_buffer_size_save= @@read_r
 set read_rnd_buffer_size=64;
 create table t1(a int);
 insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t2(a char(8), b char(8), c char(8), filler char(100), key(a,b,c) );
+create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) );
 insert into t2 select 
 concat('a-', 1000 + A.a, '-a'),
 concat('b-', 1000 + B.a, '-b'),
 concat('c-', 1000 + C.a, '-c'),
 'filler'
 from t1 A, t1 B, t1 C;
-explain
-select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
+EXPLAIN select count(length(a) + length(filler))
+from t2 force index (k1)
+where a>='a-1000-a' and a <'a-1001-a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	a	a	9	NULL	92	Using index condition
-select count(length(a) + length(filler)) from t2 where a>='a-1000-a' and a <'a-1001-a';
+1	SIMPLE	t2	range	k1	k1	9	NULL	92	Using index condition
+select count(length(a) + length(filler))
+from t2 force index (k1)
+where a>='a-1000-a' and a <'a-1001-a';
 count(length(a) + length(filler))
 100
 drop table t2;

=== added file 'mysql-test/r/mysql_plugin.result'
--- a/mysql-test/r/mysql_plugin.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/mysql_plugin.result	2011-08-09 12:58:18 +0000
@@ -0,0 +1,110 @@
+#
+# Ensure the plugin isn't loaded.
+#
+SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name;
+name	dl
+#
+# Enable the plugin...
+#
+#
+# Ensure the plugin is now loaded.
+#
+SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name;
+name	dl
+daemon_example	libdaemon_example.so
+#
+# Disable the plugin...
+#
+#
+# Ensure the plugin isn't loaded.
+#
+SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name;
+name	dl
+#
+# Attempt to load non-existant plugin
+#
+ERROR: Cannot read plugin config file NOT_THERE_AT_ALL. File does not exist.
+#
+# Attempt to use non-existant plugin.ini file
+#
+ERROR: Cannot read plugin config file daemon_example. File does not exist.
+# 
+# Attempt to omit the plugin
+#
+ERROR: No plugin specified.
+# 
+# Attempt to omit DISABLE|ENABLE
+#
+ERROR: missing operation. Please specify either '<plugin> ENABLE' or '<plugin> DISABLE'.
+# 
+# Attempt to use bad paths - datadir
+#
+ERROR: Cannot access datadir at '/data_not_there/'.
+# 
+# Attempt to use bad paths - basedir
+#
+ERROR: Cannot access basedir at '/basedir_not_there/'.
+# 
+# Attempt to use bad paths - plugin_dir
+#
+ERROR: Cannot read plugin config file daemon_example. File does not exist.
+# 
+# Attempt to use bad paths - mysqld
+#
+ERROR: Cannot access mysqld path '/mysqld_not_there/'.
+# 
+# Attempt to use bad paths - my_print_defaults
+#
+ERROR: Cannot access my-print-defaults path '/my_print_defaults_not_there/'.
+# 
+# Missing library
+#
+ERROR: The plugin library is missing or in a different location.
+# 
+# Bad format for config file
+#
+ERROR: Cannot read plugin config file daemon_example. Bad format in plugin configuration file.
+# 
+# Missing base_dir option
+#
+ERROR: Missing --basedir option.
+# 
+# Missing data_dir option
+#
+ERROR: Missing --datadir option.
+# 
+# Missing plugin_dir option
+#
+ERROR: Missing --plugin_dir option.
+#
+# Show the help.
+#
+mysql_plugin  Ver V.V.VV Distrib XX.XX.XX
+Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+Enable or disable plugins.
+
+Usage: mysql_plugin [options] <plugin> ENABLE|DISABLE
+
+Options:
+  -?, --help          Display this help and exit.
+  -b, --basedir=name  The basedir for the server.
+  -d, --datadir=name  The datadir for the server.
+  -p, --plugin-dir=name 
+                      The plugin dir for the server.
+  -i, --plugin-ini=name 
+                      Read plugin information from configuration file specified
+                      instead of from <plugin-dir>/<plugin_name>.ini.
+  -n, --no-defaults   Do not read values from configuration file.
+  -P, --print-defaults 
+                      Show default values from configuration file.
+  -m, --mysqld=name   Path to mysqld executable. Example: /sbin/temp1/mysql/bin
+  -f, --my-print-defaults=name 
+                      Path to my_print_defaults executable. Example:
+                      /source/temp11/extra
+  -v, --verbose       More verbose output; you can use this multiple times to
+                      get even more verbose output.
+  -V, --version       Output version information and exit.
+
+
+mysql_plugin  Ver V.V.VV Distrib XX.XX.XX

=== modified file 'mysql-test/r/range_all.result'
--- a/mysql-test/r/range_all.result	2011-05-26 09:20:09 +0000
+++ b/mysql-test/r/range_all.result	2011-08-05 14:30:29 +0000
@@ -1873,4 +1873,40 @@ SELECT * FROM t100 WHERE I <> 6 OR (I <>
 K	I	J
 101	8	26
 DROP TABLE t10,t100;
+#
+# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
+# AFTER FLUSH TABLES [-INT VS NULL]
+#
+CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (-100,1),(1,6);
+CREATE TABLE t2 (
+col_int_key INT,
+col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT",
+pk INT NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8);
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ref	PRIMARY,col_int_key	col_int_key	5	test.t1.col_int	1	Using index condition
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+# need FLUSH so that InnoDB statistics change and thus plan changes
+FLUSH TABLES;
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Range checked for each record (index map: 0x3)
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_icp.result'
--- a/mysql-test/r/range_icp.result	2011-05-19 12:03:55 +0000
+++ b/mysql-test/r/range_icp.result	2011-08-05 14:30:29 +0000
@@ -1873,4 +1873,40 @@ SELECT * FROM t100 WHERE I <> 6 OR (I <>
 K	I	J
 101	8	26
 DROP TABLE t10,t100;
+#
+# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
+# AFTER FLUSH TABLES [-INT VS NULL]
+#
+CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (-100,1),(1,6);
+CREATE TABLE t2 (
+col_int_key INT,
+col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT",
+pk INT NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8);
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ref	PRIMARY,col_int_key	col_int_key	5	test.t1.col_int	1	Using index condition
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+# need FLUSH so that InnoDB statistics change and thus plan changes
+FLUSH TABLES;
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Range checked for each record (index map: 0x3)
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_icp_mrr.result'
--- a/mysql-test/r/range_icp_mrr.result	2011-05-19 12:03:55 +0000
+++ b/mysql-test/r/range_icp_mrr.result	2011-08-05 14:30:29 +0000
@@ -1873,4 +1873,40 @@ SELECT * FROM t100 WHERE I <> 6 OR (I <>
 K	I	J
 101	8	26
 DROP TABLE t10,t100;
+#
+# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
+# AFTER FLUSH TABLES [-INT VS NULL]
+#
+CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (-100,1),(1,6);
+CREATE TABLE t2 (
+col_int_key INT,
+col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT",
+pk INT NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8);
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ref	PRIMARY,col_int_key	col_int_key	5	test.t1.col_int	1	Using index condition
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+# need FLUSH so that InnoDB statistics change and thus plan changes
+FLUSH TABLES;
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Range checked for each record (index map: 0x3)
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_mrr.result'
--- a/mysql-test/r/range_mrr.result	2011-05-19 12:03:55 +0000
+++ b/mysql-test/r/range_mrr.result	2011-08-05 14:30:29 +0000
@@ -1873,4 +1873,40 @@ SELECT * FROM t100 WHERE I <> 6 OR (I <>
 K	I	J
 101	8	26
 DROP TABLE t10,t100;
+#
+# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
+# AFTER FLUSH TABLES [-INT VS NULL]
+#
+CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (-100,1),(1,6);
+CREATE TABLE t2 (
+col_int_key INT,
+col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT",
+pk INT NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8);
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ref	PRIMARY,col_int_key	col_int_key	5	test.t1.col_int	1	Using where
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+# need FLUSH so that InnoDB statistics change and thus plan changes
+FLUSH TABLES;
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Range checked for each record (index map: 0x3)
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_mrr_cost.result'
--- a/mysql-test/r/range_mrr_cost.result	2011-05-19 12:03:55 +0000
+++ b/mysql-test/r/range_mrr_cost.result	2011-08-05 14:30:29 +0000
@@ -1873,4 +1873,40 @@ SELECT * FROM t100 WHERE I <> 6 OR (I <>
 K	I	J
 101	8	26
 DROP TABLE t10,t100;
+#
+# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
+# AFTER FLUSH TABLES [-INT VS NULL]
+#
+CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (-100,1),(1,6);
+CREATE TABLE t2 (
+col_int_key INT,
+col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT",
+pk INT NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8);
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ref	PRIMARY,col_int_key	col_int_key	5	test.t1.col_int	1	Using where
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+# need FLUSH so that InnoDB statistics change and thus plan changes
+FLUSH TABLES;
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Range checked for each record (index map: 0x3)
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_none.result'
--- a/mysql-test/r/range_none.result	2011-05-19 12:03:55 +0000
+++ b/mysql-test/r/range_none.result	2011-08-05 14:30:29 +0000
@@ -1872,4 +1872,40 @@ SELECT * FROM t100 WHERE I <> 6 OR (I <>
 K	I	J
 101	8	26
 DROP TABLE t10,t100;
+#
+# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
+# AFTER FLUSH TABLES [-INT VS NULL]
+#
+CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (-100,1),(1,6);
+CREATE TABLE t2 (
+col_int_key INT,
+col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT",
+pk INT NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8);
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ref	PRIMARY,col_int_key	col_int_key	5	test.t1.col_int	1	Using where
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+# need FLUSH so that InnoDB statistics change and thus plan changes
+FLUSH TABLES;
+EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	SIMPLE	t2	ALL	PRIMARY,col_int_key	NULL	NULL	NULL	6	Range checked for each record (index map: 0x3)
+SELECT t1.*,t2.* FROM t1 straight_join t2
+ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk;
+col_int	pk	col_int_key	col_varchar	pk
+1	6	1	GOOD	1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/sp_trans.result'
--- a/mysql-test/r/sp_trans.result	2011-07-28 08:31:36 +0000
+++ b/mysql-test/r/sp_trans.result	2011-08-08 17:07:51 +0000
@@ -554,6 +554,52 @@ f1	bug13575(f1)
 3	ccc
 drop function bug13575|
 drop table t3|
+SELECT @@GLOBAL.default_storage_engine INTO @old_engine|
+SET @@GLOBAL.default_storage_engine=InnoDB|
+SET @@SESSION.default_storage_engine=InnoDB|
+SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'|
+Variable_name	Value
+default_storage_engine	InnoDB
+SHOW SESSION VARIABLES LIKE 'default_storage_engine'|
+Variable_name	Value
+default_storage_engine	InnoDB
+CREATE PROCEDURE bug11758414()
+BEGIN
+SET @@GLOBAL.default_storage_engine="MyISAM";
+SET @@SESSION.default_storage_engine="MyISAM"; 
+# show defaults at execution time / that setting them worked
+SHOW GLOBAL VARIABLES LIKE 'default_storage_engine';
+SHOW SESSION VARIABLES LIKE 'default_storage_engine';
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int) ENGINE=InnoDB;
+# show we're heeding the default (at run-time, not parse-time!)
+ SHOW CREATE TABLE t1;
+ # show that we didn't break explicit override with ENGINE=...
+SHOW CREATE TABLE t2;
+END;
+|
+CALL bug11758414|
+Variable_name	Value
+default_storage_engine	MyISAM
+Variable_name	Value
+default_storage_engine	MyISAM
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'|
+Variable_name	Value
+default_storage_engine	MyISAM
+SHOW SESSION VARIABLES LIKE 'default_storage_engine'|
+Variable_name	Value
+default_storage_engine	MyISAM
+DROP PROCEDURE bug11758414|
+DROP TABLE t1, t2|
+SET @@GLOBAL.default_storage_engine=@old_engine|
 #
 # End of 5.1 tests
 #

=== added file 'mysql-test/suite/innodb/r/innodb_bug59733.result'
--- a/mysql-test/suite/innodb/r/innodb_bug59733.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug59733.result	2011-08-15 09:18:34 +0000
@@ -0,0 +1,18 @@
+CREATE TABLE bug59733(a INT AUTO_INCREMENT PRIMARY KEY,b CHAR(1))ENGINE=InnoDB;
+INSERT INTO bug59733 VALUES(0,'x');
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+CREATE INDEX b ON bug59733 (b);
+DELETE FROM bug59733 WHERE (a%100)=0;
+DROP INDEX b ON bug59733;
+CREATE INDEX b ON bug59733 (b);
+DROP TABLE bug59733;

=== added file 'mysql-test/suite/innodb/t/innodb_bug59733.test'
--- a/mysql-test/suite/innodb/t/innodb_bug59733.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug59733.test	2011-08-15 09:18:34 +0000
@@ -0,0 +1,53 @@
+#
+# Bug #59733 Possible deadlock when buffered changes are to be discarded
+# in buf_page_create
+#
+-- source include/have_innodb.inc
+
+-- disable_query_log
+# The flag innodb_change_buffering_debug is only available in debug builds.
+# It instructs InnoDB to try to evict pages from the buffer pool when
+# change buffering is possible, so that the change buffer will be used
+# whenever possible.
+-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
+SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug;
+-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
+SET GLOBAL innodb_change_buffering_debug = 1;
+-- enable_query_log
+
+CREATE TABLE bug59733(a INT AUTO_INCREMENT PRIMARY KEY,b CHAR(1))ENGINE=InnoDB;
+
+# Create enough rows for the table, so that the insert buffer will be
+# used. There must be multiple index pages, because changes to the
+# root page are never buffered.
+
+INSERT INTO bug59733 VALUES(0,'x');
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+INSERT INTO bug59733 SELECT 0,b FROM bug59733;
+
+# Create the secondary index for which changes will be buffered.
+CREATE INDEX b ON bug59733 (b);
+
+# This should be buffered, if innodb_change_buffering_debug = 1 is in effect.
+DELETE FROM bug59733 WHERE (a%100)=0;
+
+# Drop the index in order to get free pages with orphaned buffered changes.
+DROP INDEX b ON bug59733;
+
+# Create the index and attempt to reuse pages for which buffered changes exist.
+CREATE INDEX b ON bug59733 (b);
+
+DROP TABLE bug59733;
+
+-- disable_query_log
+-- error 0, ER_UNKNOWN_SYSTEM_VARIABLE
+SET GLOBAL innodb_change_buffering_debug = @innodb_change_buffering_debug_orig;

=== removed file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result.THIS'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result.THIS	2011-05-18 18:42:30 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result.THIS	1970-01-01 00:00:00 +0000
@@ -1,288 +0,0 @@
-drop table if exists test.user_table;
-drop procedure if exists test.user_proc;
-drop function if exists test.user_func;
-drop event if exists test.user_event;
-"Testing mysql_upgrade with TABLE performance_schema.user_table"
-create table test.user_table(a int);
-use performance_schema;
-show tables like "user_table";
-Tables_in_performance_schema (user_table)
-user_table
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-show tables like "user_table";
-Tables_in_performance_schema (user_table)
-user_table
-use test;
-drop table test.user_table;
-"Testing mysql_upgrade with VIEW performance_schema.user_view"
-create view test.user_view as select "Not supposed to be here";
-use performance_schema;
-show tables like "user_view";
-Tables_in_performance_schema (user_view)
-user_view
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-show tables like "user_view";
-Tables_in_performance_schema (user_view)
-user_view
-use test;
-drop view test.user_view;
-"Testing mysql_upgrade with PROCEDURE performance_schema.user_proc"
-create procedure test.user_proc()
-select "Not supposed to be here";
-update mysql.proc set db='performance_schema' where name='user_proc';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.proc where db='performance_schema';
-name
-user_proc
-update mysql.proc set db='test' where name='user_proc';
-drop procedure test.user_proc;
-"Testing mysql_upgrade with FUNCTION performance_schema.user_func"
-create function test.user_func() returns integer
-return 0;
-update mysql.proc set db='performance_schema' where name='user_func';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.proc where db='performance_schema';
-name
-user_func
-update mysql.proc set db='test' where name='user_func';
-drop function test.user_func;
-"Testing mysql_upgrade with EVENT performance_schema.user_event"
-create event test.user_event on schedule every 1 day do
-select "not supposed to be here";
-update mysql.event set db='performance_schema' where name='user_event';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.event where db='performance_schema';
-name
-user_event
-update mysql.event set db='test' where name='user_event';
-drop event test.user_event;

=== removed file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result.THIS'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result.THIS	2011-05-18 18:42:30 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result.THIS	1970-01-01 00:00:00 +0000
@@ -1,288 +0,0 @@
-drop table if exists test.user_table;
-drop procedure if exists test.user_proc;
-drop function if exists test.user_func;
-drop event if exists test.user_event;
-"Testing mysql_upgrade with TABLE performance_schema.user_table"
-create table test.user_table(a int);
-use performance_schema;
-show tables like "user_table";
-Tables_in_performance_schema (user_table)
-user_table
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-show tables like "user_table";
-Tables_in_performance_schema (user_table)
-user_table
-use test;
-drop table test.user_table;
-"Testing mysql_upgrade with VIEW performance_schema.user_view"
-create view test.user_view as select "Not supposed to be here";
-use performance_schema;
-show tables like "user_view";
-Tables_in_performance_schema (user_view)
-user_view
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-show tables like "user_view";
-Tables_in_performance_schema (user_view)
-user_view
-use test;
-drop view test.user_view;
-"Testing mysql_upgrade with PROCEDURE performance_schema.user_proc"
-create procedure test.user_proc()
-select "Not supposed to be here";
-update mysql.proc set db='performance_schema' where name='user_proc';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.proc where db='performance_schema';
-name
-user_proc
-update mysql.proc set db='test' where name='user_proc';
-drop procedure test.user_proc;
-"Testing mysql_upgrade with FUNCTION performance_schema.user_func"
-create function test.user_func() returns integer
-return 0;
-update mysql.proc set db='performance_schema' where name='user_func';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.proc where db='performance_schema';
-name
-user_func
-update mysql.proc set db='test' where name='user_func';
-drop function test.user_func;
-"Testing mysql_upgrade with EVENT performance_schema.user_event"
-create event test.user_event on schedule every 1 day do
-select "not supposed to be here";
-update mysql.event set db='performance_schema' where name='user_event';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.event where db='performance_schema';
-name
-user_event
-update mysql.event set db='test' where name='user_event';
-drop event test.user_event;

=== removed file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result.THIS'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result.THIS	2011-05-18 18:42:30 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result.THIS	1970-01-01 00:00:00 +0000
@@ -1,288 +0,0 @@
-drop table if exists test.user_table;
-drop procedure if exists test.user_proc;
-drop function if exists test.user_func;
-drop event if exists test.user_event;
-"Testing mysql_upgrade with TABLE performance_schema.user_table"
-create table test.user_table(a int);
-use performance_schema;
-show tables like "user_table";
-Tables_in_performance_schema (user_table)
-user_table
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-show tables like "user_table";
-Tables_in_performance_schema (user_table)
-user_table
-use test;
-drop table test.user_table;
-"Testing mysql_upgrade with VIEW performance_schema.user_view"
-create view test.user_view as select "Not supposed to be here";
-use performance_schema;
-show tables like "user_view";
-Tables_in_performance_schema (user_view)
-user_view
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-show tables like "user_view";
-Tables_in_performance_schema (user_view)
-user_view
-use test;
-drop view test.user_view;
-"Testing mysql_upgrade with PROCEDURE performance_schema.user_proc"
-create procedure test.user_proc()
-select "Not supposed to be here";
-update mysql.proc set db='performance_schema' where name='user_proc';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.proc where db='performance_schema';
-name
-user_proc
-update mysql.proc set db='test' where name='user_proc';
-drop procedure test.user_proc;
-"Testing mysql_upgrade with FUNCTION performance_schema.user_func"
-create function test.user_func() returns integer
-return 0;
-update mysql.proc set db='performance_schema' where name='user_func';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.proc where db='performance_schema';
-name
-user_func
-update mysql.proc set db='test' where name='user_func';
-drop function test.user_func;
-"Testing mysql_upgrade with EVENT performance_schema.user_event"
-create event test.user_event on schedule every 1 day do
-select "not supposed to be here";
-update mysql.event set db='performance_schema' where name='user_event';
-ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 94: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 118: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 142: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 155: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 168: Table 'events_waits_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 181: Table 'events_waits_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 195: Table 'events_waits_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 208: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 220: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 229: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 240: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 252: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 261: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 275: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 285: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 295: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 304: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 312: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 321: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 331: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 339: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 384: Table 'table_io_waits_summary_by_index_usage' already exists
-ERROR 1050 (42S01) at line 428: Table 'table_io_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 507: Table 'table_lock_waits_summary_by_table' already exists
-ERROR 1050 (42S01) at line 527: Table 'threads' already exists
-ERROR 1050 (42S01) at line 542: Table 'events_stages_current' already exists
-ERROR 1050 (42S01) at line 557: Table 'events_stages_history' already exists
-ERROR 1050 (42S01) at line 572: Table 'events_stages_history_long' already exists
-ERROR 1050 (42S01) at line 585: Table 'events_stages_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 598: Table 'events_stages_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 611: Table 'events_stages_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 625: Table 'events_stages_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 637: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 680: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 723: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 766: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 798: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 830: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 895: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 926: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 935: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 944: Table 'users' already exists
-ERROR 1050 (42S01) at line 954: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1374: Unexpected content found in the performance_schema database.
-FATAL ERROR: Upgrade failed
-select name from mysql.event where db='performance_schema';
-name
-user_event
-update mysql.event set db='test' where name='user_event';
-drop event test.user_event;

=== removed file 'mysql-test/suite/perfschema/r/schema_lc0.result.THIS'
--- a/mysql-test/suite/perfschema/r/schema_lc0.result.THIS	2011-05-18 18:42:30 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc0.result.THIS	1970-01-01 00:00:00 +0000
@@ -1,856 +0,0 @@
-show databases like 'performance_schema';
-Database (performance_schema)
-performance_schema
-show create database performance_schema;
-Database	Create Database
-performance_schema	CREATE DATABASE `performance_schema` /*!40100 DEFAULT CHARACTER SET utf8 */
-use performance_schema;
-show tables;
-Tables_in_performance_schema
-accounts
-cond_instances
-events_stages_current
-events_stages_history
-events_stages_history_long
-events_stages_summary_by_account_by_event_name
-events_stages_summary_by_host_by_event_name
-events_stages_summary_by_thread_by_event_name
-events_stages_summary_by_user_by_event_name
-events_stages_summary_global_by_event_name
-events_statements_current
-events_statements_history
-events_statements_history_long
-events_statements_summary_by_account_by_event_name
-events_statements_summary_by_host_by_event_name
-events_statements_summary_by_thread_by_event_name
-events_statements_summary_by_user_by_event_name
-events_statements_summary_global_by_event_name
-events_waits_current
-events_waits_history
-events_waits_history_long
-events_waits_summary_by_account_by_event_name
-events_waits_summary_by_host_by_event_name
-events_waits_summary_by_instance
-events_waits_summary_by_thread_by_event_name
-events_waits_summary_by_user_by_event_name
-events_waits_summary_global_by_event_name
-file_instances
-file_summary_by_event_name
-file_summary_by_instance
-hosts
-mutex_instances
-objects_summary_global_by_type
-performance_timers
-rwlock_instances
-setup_actors
-setup_consumers
-setup_instruments
-setup_objects
-setup_timers
-table_io_waits_summary_by_index_usage
-table_io_waits_summary_by_table
-table_lock_waits_summary_by_table
-threads
-users
-show create table accounts;
-Table	Create Table
-accounts	CREATE TABLE `accounts` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table cond_instances;
-Table	Create Table
-cond_instances	CREATE TABLE `cond_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_current;
-Table	Create Table
-events_stages_current	CREATE TABLE `events_stages_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_history;
-Table	Create Table
-events_stages_history	CREATE TABLE `events_stages_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_history_long;
-Table	Create Table
-events_stages_history_long	CREATE TABLE `events_stages_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_host_by_event_name;
-Table	Create Table
-events_stages_summary_by_host_by_event_name	CREATE TABLE `events_stages_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_thread_by_event_name;
-Table	Create Table
-events_stages_summary_by_thread_by_event_name	CREATE TABLE `events_stages_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_user_by_event_name;
-Table	Create Table
-events_stages_summary_by_user_by_event_name	CREATE TABLE `events_stages_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_account_by_event_name;
-Table	Create Table
-events_stages_summary_by_account_by_event_name	CREATE TABLE `events_stages_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_global_by_event_name;
-Table	Create Table
-events_stages_summary_global_by_event_name	CREATE TABLE `events_stages_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_current;
-Table	Create Table
-events_statements_current	CREATE TABLE `events_statements_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_history;
-Table	Create Table
-events_statements_history	CREATE TABLE `events_statements_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_history_long;
-Table	Create Table
-events_statements_history_long	CREATE TABLE `events_statements_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_host_by_event_name;
-Table	Create Table
-events_statements_summary_by_host_by_event_name	CREATE TABLE `events_statements_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_thread_by_event_name;
-Table	Create Table
-events_statements_summary_by_thread_by_event_name	CREATE TABLE `events_statements_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_user_by_event_name;
-Table	Create Table
-events_statements_summary_by_user_by_event_name	CREATE TABLE `events_statements_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_account_by_event_name;
-Table	Create Table
-events_statements_summary_by_account_by_event_name	CREATE TABLE `events_statements_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_global_by_event_name;
-Table	Create Table
-events_statements_summary_global_by_event_name	CREATE TABLE `events_statements_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_current;
-Table	Create Table
-events_waits_current	CREATE TABLE `events_waits_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_history;
-Table	Create Table
-events_waits_history	CREATE TABLE `events_waits_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_history_long;
-Table	Create Table
-events_waits_history_long	CREATE TABLE `events_waits_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_host_by_event_name;
-Table	Create Table
-events_waits_summary_by_host_by_event_name	CREATE TABLE `events_waits_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_instance;
-Table	Create Table
-events_waits_summary_by_instance	CREATE TABLE `events_waits_summary_by_instance` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_thread_by_event_name;
-Table	Create Table
-events_waits_summary_by_thread_by_event_name	CREATE TABLE `events_waits_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_user_by_event_name;
-Table	Create Table
-events_waits_summary_by_user_by_event_name	CREATE TABLE `events_waits_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_account_by_event_name;
-Table	Create Table
-events_waits_summary_by_account_by_event_name	CREATE TABLE `events_waits_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_global_by_event_name;
-Table	Create Table
-events_waits_summary_global_by_event_name	CREATE TABLE `events_waits_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_instances;
-Table	Create Table
-file_instances	CREATE TABLE `file_instances` (
-  `FILE_NAME` varchar(512) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `OPEN_COUNT` int(10) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_summary_by_event_name;
-Table	Create Table
-file_summary_by_event_name	CREATE TABLE `file_summary_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_READ` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_summary_by_instance;
-Table	Create Table
-file_summary_by_instance	CREATE TABLE `file_summary_by_instance` (
-  `FILE_NAME` varchar(512) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_READ` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table hosts;
-Table	Create Table
-hosts	CREATE TABLE `hosts` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table mutex_instances;
-Table	Create Table
-mutex_instances	CREATE TABLE `mutex_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table objects_summary_global_by_type;
-Table	Create Table
-objects_summary_global_by_type	CREATE TABLE `objects_summary_global_by_type` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table performance_timers;
-Table	Create Table
-performance_timers	CREATE TABLE `performance_timers` (
-  `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL,
-  `TIMER_FREQUENCY` bigint(20) DEFAULT NULL,
-  `TIMER_RESOLUTION` bigint(20) DEFAULT NULL,
-  `TIMER_OVERHEAD` bigint(20) DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table rwlock_instances;
-Table	Create Table
-rwlock_instances	CREATE TABLE `rwlock_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `WRITE_LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL,
-  `READ_LOCKED_BY_COUNT` int(10) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_actors;
-Table	Create Table
-setup_actors	CREATE TABLE `setup_actors` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%',
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%',
-  `ROLE` char(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%'
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_consumers;
-Table	Create Table
-setup_consumers	CREATE TABLE `setup_consumers` (
-  `NAME` varchar(64) NOT NULL,
-  `ENABLED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_instruments;
-Table	Create Table
-setup_instruments	CREATE TABLE `setup_instruments` (
-  `NAME` varchar(128) NOT NULL,
-  `ENABLED` enum('YES','NO') NOT NULL,
-  `TIMED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_objects;
-Table	Create Table
-setup_objects	CREATE TABLE `setup_objects` (
-  `OBJECT_TYPE` enum('TABLE') NOT NULL DEFAULT 'TABLE',
-  `OBJECT_SCHEMA` varchar(64) DEFAULT '%',
-  `OBJECT_NAME` varchar(64) NOT NULL DEFAULT '%',
-  `TIMED` enum('YES','NO') NOT NULL DEFAULT 'YES'
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_timers;
-Table	Create Table
-setup_timers	CREATE TABLE `setup_timers` (
-  `NAME` varchar(64) NOT NULL,
-  `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_io_waits_summary_by_index_usage;
-Table	Create Table
-table_io_waits_summary_by_index_usage	CREATE TABLE `table_io_waits_summary_by_index_usage` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_io_waits_summary_by_table;
-Table	Create Table
-table_io_waits_summary_by_table	CREATE TABLE `table_io_waits_summary_by_table` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_lock_waits_summary_by_table;
-Table	Create Table
-table_lock_waits_summary_by_table	CREATE TABLE `table_lock_waits_summary_by_table` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table threads;
-Table	Create Table
-threads	CREATE TABLE `threads` (
-  `THREAD_ID` int(11) NOT NULL,
-  `NAME` varchar(128) NOT NULL,
-  `TYPE` varchar(10) NOT NULL,
-  `PROCESSLIST_ID` int(11) DEFAULT NULL,
-  `PROCESSLIST_USER` varchar(16) DEFAULT NULL,
-  `PROCESSLIST_HOST` varchar(60) DEFAULT NULL,
-  `PROCESSLIST_DB` varchar(64) DEFAULT NULL,
-  `PROCESSLIST_COMMAND` varchar(16) DEFAULT NULL,
-  `PROCESSLIST_TIME` bigint(20) DEFAULT NULL,
-  `PROCESSLIST_STATE` varchar(64) DEFAULT NULL,
-  `PROCESSLIST_INFO` longtext,
-  `PARENT_THREAD_ID` int(11) DEFAULT NULL,
-  `ROLE` varchar(64) DEFAULT NULL,
-  `INSTRUMENTED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table users;
-Table	Create Table
-users	CREATE TABLE `users` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8

=== removed file 'mysql-test/suite/perfschema/r/schema_lc1.result.THIS'
--- a/mysql-test/suite/perfschema/r/schema_lc1.result.THIS	2011-05-18 18:42:30 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc1.result.THIS	1970-01-01 00:00:00 +0000
@@ -1,856 +0,0 @@
-show databases like 'performance_schema';
-Database (performance_schema)
-performance_schema
-show create database performance_schema;
-Database	Create Database
-performance_schema	CREATE DATABASE `performance_schema` /*!40100 DEFAULT CHARACTER SET utf8 */
-use performance_schema;
-show tables;
-Tables_in_performance_schema
-accounts
-cond_instances
-events_stages_current
-events_stages_history
-events_stages_history_long
-events_stages_summary_by_account_by_event_name
-events_stages_summary_by_host_by_event_name
-events_stages_summary_by_thread_by_event_name
-events_stages_summary_by_user_by_event_name
-events_stages_summary_global_by_event_name
-events_statements_current
-events_statements_history
-events_statements_history_long
-events_statements_summary_by_account_by_event_name
-events_statements_summary_by_host_by_event_name
-events_statements_summary_by_thread_by_event_name
-events_statements_summary_by_user_by_event_name
-events_statements_summary_global_by_event_name
-events_waits_current
-events_waits_history
-events_waits_history_long
-events_waits_summary_by_account_by_event_name
-events_waits_summary_by_host_by_event_name
-events_waits_summary_by_instance
-events_waits_summary_by_thread_by_event_name
-events_waits_summary_by_user_by_event_name
-events_waits_summary_global_by_event_name
-file_instances
-file_summary_by_event_name
-file_summary_by_instance
-hosts
-mutex_instances
-objects_summary_global_by_type
-performance_timers
-rwlock_instances
-setup_actors
-setup_consumers
-setup_instruments
-setup_objects
-setup_timers
-table_io_waits_summary_by_index_usage
-table_io_waits_summary_by_table
-table_lock_waits_summary_by_table
-threads
-users
-show create table accounts;
-Table	Create Table
-accounts	CREATE TABLE `accounts` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table cond_instances;
-Table	Create Table
-cond_instances	CREATE TABLE `cond_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_current;
-Table	Create Table
-events_stages_current	CREATE TABLE `events_stages_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_history;
-Table	Create Table
-events_stages_history	CREATE TABLE `events_stages_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_history_long;
-Table	Create Table
-events_stages_history_long	CREATE TABLE `events_stages_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_host_by_event_name;
-Table	Create Table
-events_stages_summary_by_host_by_event_name	CREATE TABLE `events_stages_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_thread_by_event_name;
-Table	Create Table
-events_stages_summary_by_thread_by_event_name	CREATE TABLE `events_stages_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_user_by_event_name;
-Table	Create Table
-events_stages_summary_by_user_by_event_name	CREATE TABLE `events_stages_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_account_by_event_name;
-Table	Create Table
-events_stages_summary_by_account_by_event_name	CREATE TABLE `events_stages_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_global_by_event_name;
-Table	Create Table
-events_stages_summary_global_by_event_name	CREATE TABLE `events_stages_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_current;
-Table	Create Table
-events_statements_current	CREATE TABLE `events_statements_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_history;
-Table	Create Table
-events_statements_history	CREATE TABLE `events_statements_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_history_long;
-Table	Create Table
-events_statements_history_long	CREATE TABLE `events_statements_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_host_by_event_name;
-Table	Create Table
-events_statements_summary_by_host_by_event_name	CREATE TABLE `events_statements_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_thread_by_event_name;
-Table	Create Table
-events_statements_summary_by_thread_by_event_name	CREATE TABLE `events_statements_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_user_by_event_name;
-Table	Create Table
-events_statements_summary_by_user_by_event_name	CREATE TABLE `events_statements_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_account_by_event_name;
-Table	Create Table
-events_statements_summary_by_account_by_event_name	CREATE TABLE `events_statements_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_global_by_event_name;
-Table	Create Table
-events_statements_summary_global_by_event_name	CREATE TABLE `events_statements_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_current;
-Table	Create Table
-events_waits_current	CREATE TABLE `events_waits_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_history;
-Table	Create Table
-events_waits_history	CREATE TABLE `events_waits_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_history_long;
-Table	Create Table
-events_waits_history_long	CREATE TABLE `events_waits_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_host_by_event_name;
-Table	Create Table
-events_waits_summary_by_host_by_event_name	CREATE TABLE `events_waits_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_instance;
-Table	Create Table
-events_waits_summary_by_instance	CREATE TABLE `events_waits_summary_by_instance` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_thread_by_event_name;
-Table	Create Table
-events_waits_summary_by_thread_by_event_name	CREATE TABLE `events_waits_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_user_by_event_name;
-Table	Create Table
-events_waits_summary_by_user_by_event_name	CREATE TABLE `events_waits_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_account_by_event_name;
-Table	Create Table
-events_waits_summary_by_account_by_event_name	CREATE TABLE `events_waits_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_global_by_event_name;
-Table	Create Table
-events_waits_summary_global_by_event_name	CREATE TABLE `events_waits_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_instances;
-Table	Create Table
-file_instances	CREATE TABLE `file_instances` (
-  `FILE_NAME` varchar(512) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `OPEN_COUNT` int(10) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_summary_by_event_name;
-Table	Create Table
-file_summary_by_event_name	CREATE TABLE `file_summary_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_READ` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_summary_by_instance;
-Table	Create Table
-file_summary_by_instance	CREATE TABLE `file_summary_by_instance` (
-  `FILE_NAME` varchar(512) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_READ` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table hosts;
-Table	Create Table
-hosts	CREATE TABLE `hosts` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table mutex_instances;
-Table	Create Table
-mutex_instances	CREATE TABLE `mutex_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table objects_summary_global_by_type;
-Table	Create Table
-objects_summary_global_by_type	CREATE TABLE `objects_summary_global_by_type` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table performance_timers;
-Table	Create Table
-performance_timers	CREATE TABLE `performance_timers` (
-  `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL,
-  `TIMER_FREQUENCY` bigint(20) DEFAULT NULL,
-  `TIMER_RESOLUTION` bigint(20) DEFAULT NULL,
-  `TIMER_OVERHEAD` bigint(20) DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table rwlock_instances;
-Table	Create Table
-rwlock_instances	CREATE TABLE `rwlock_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `WRITE_LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL,
-  `READ_LOCKED_BY_COUNT` int(10) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_actors;
-Table	Create Table
-setup_actors	CREATE TABLE `setup_actors` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%',
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%',
-  `ROLE` char(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%'
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_consumers;
-Table	Create Table
-setup_consumers	CREATE TABLE `setup_consumers` (
-  `NAME` varchar(64) NOT NULL,
-  `ENABLED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_instruments;
-Table	Create Table
-setup_instruments	CREATE TABLE `setup_instruments` (
-  `NAME` varchar(128) NOT NULL,
-  `ENABLED` enum('YES','NO') NOT NULL,
-  `TIMED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_objects;
-Table	Create Table
-setup_objects	CREATE TABLE `setup_objects` (
-  `OBJECT_TYPE` enum('TABLE') NOT NULL DEFAULT 'TABLE',
-  `OBJECT_SCHEMA` varchar(64) DEFAULT '%',
-  `OBJECT_NAME` varchar(64) NOT NULL DEFAULT '%',
-  `TIMED` enum('YES','NO') NOT NULL DEFAULT 'YES'
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_timers;
-Table	Create Table
-setup_timers	CREATE TABLE `setup_timers` (
-  `NAME` varchar(64) NOT NULL,
-  `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_io_waits_summary_by_index_usage;
-Table	Create Table
-table_io_waits_summary_by_index_usage	CREATE TABLE `table_io_waits_summary_by_index_usage` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_io_waits_summary_by_table;
-Table	Create Table
-table_io_waits_summary_by_table	CREATE TABLE `table_io_waits_summary_by_table` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_lock_waits_summary_by_table;
-Table	Create Table
-table_lock_waits_summary_by_table	CREATE TABLE `table_lock_waits_summary_by_table` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table threads;
-Table	Create Table
-threads	CREATE TABLE `threads` (
-  `THREAD_ID` int(11) NOT NULL,
-  `NAME` varchar(128) NOT NULL,
-  `TYPE` varchar(10) NOT NULL,
-  `PROCESSLIST_ID` int(11) DEFAULT NULL,
-  `PROCESSLIST_USER` varchar(16) DEFAULT NULL,
-  `PROCESSLIST_HOST` varchar(60) DEFAULT NULL,
-  `PROCESSLIST_DB` varchar(64) DEFAULT NULL,
-  `PROCESSLIST_COMMAND` varchar(16) DEFAULT NULL,
-  `PROCESSLIST_TIME` bigint(20) DEFAULT NULL,
-  `PROCESSLIST_STATE` varchar(64) DEFAULT NULL,
-  `PROCESSLIST_INFO` longtext,
-  `PARENT_THREAD_ID` int(11) DEFAULT NULL,
-  `ROLE` varchar(64) DEFAULT NULL,
-  `INSTRUMENTED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table users;
-Table	Create Table
-users	CREATE TABLE `users` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8

=== removed file 'mysql-test/suite/perfschema/r/schema_lc2.result.THIS'
--- a/mysql-test/suite/perfschema/r/schema_lc2.result.THIS	2011-05-18 18:42:30 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc2.result.THIS	1970-01-01 00:00:00 +0000
@@ -1,856 +0,0 @@
-show databases like 'performance_schema';
-Database (performance_schema)
-performance_schema
-show create database performance_schema;
-Database	Create Database
-performance_schema	CREATE DATABASE `performance_schema` /*!40100 DEFAULT CHARACTER SET utf8 */
-use performance_schema;
-show tables;
-Tables_in_performance_schema
-accounts
-cond_instances
-events_stages_current
-events_stages_history
-events_stages_history_long
-events_stages_summary_by_account_by_event_name
-events_stages_summary_by_host_by_event_name
-events_stages_summary_by_thread_by_event_name
-events_stages_summary_by_user_by_event_name
-events_stages_summary_global_by_event_name
-events_statements_current
-events_statements_history
-events_statements_history_long
-events_statements_summary_by_account_by_event_name
-events_statements_summary_by_host_by_event_name
-events_statements_summary_by_thread_by_event_name
-events_statements_summary_by_user_by_event_name
-events_statements_summary_global_by_event_name
-events_waits_current
-events_waits_history
-events_waits_history_long
-events_waits_summary_by_account_by_event_name
-events_waits_summary_by_host_by_event_name
-events_waits_summary_by_instance
-events_waits_summary_by_thread_by_event_name
-events_waits_summary_by_user_by_event_name
-events_waits_summary_global_by_event_name
-file_instances
-file_summary_by_event_name
-file_summary_by_instance
-hosts
-mutex_instances
-objects_summary_global_by_type
-performance_timers
-rwlock_instances
-setup_actors
-setup_consumers
-setup_instruments
-setup_objects
-setup_timers
-table_io_waits_summary_by_index_usage
-table_io_waits_summary_by_table
-table_lock_waits_summary_by_table
-threads
-users
-show create table accounts;
-Table	Create Table
-accounts	CREATE TABLE `accounts` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table cond_instances;
-Table	Create Table
-cond_instances	CREATE TABLE `cond_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_current;
-Table	Create Table
-events_stages_current	CREATE TABLE `events_stages_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_history;
-Table	Create Table
-events_stages_history	CREATE TABLE `events_stages_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_history_long;
-Table	Create Table
-events_stages_history_long	CREATE TABLE `events_stages_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_host_by_event_name;
-Table	Create Table
-events_stages_summary_by_host_by_event_name	CREATE TABLE `events_stages_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_thread_by_event_name;
-Table	Create Table
-events_stages_summary_by_thread_by_event_name	CREATE TABLE `events_stages_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_user_by_event_name;
-Table	Create Table
-events_stages_summary_by_user_by_event_name	CREATE TABLE `events_stages_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_by_account_by_event_name;
-Table	Create Table
-events_stages_summary_by_account_by_event_name	CREATE TABLE `events_stages_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_stages_summary_global_by_event_name;
-Table	Create Table
-events_stages_summary_global_by_event_name	CREATE TABLE `events_stages_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_current;
-Table	Create Table
-events_statements_current	CREATE TABLE `events_statements_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_history;
-Table	Create Table
-events_statements_history	CREATE TABLE `events_statements_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_history_long;
-Table	Create Table
-events_statements_history_long	CREATE TABLE `events_statements_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SQL_TEXT` longtext,
-  `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) DEFAULT NULL,
-  `MYSQL_ERRNO` int(11) DEFAULT NULL,
-  `RETURNED_SQLSTATE` varchar(5) DEFAULT NULL,
-  `MESSAGE_TEXT` varchar(128) DEFAULT NULL,
-  `ERRORS` bigint(20) unsigned NOT NULL,
-  `WARNINGS` bigint(20) unsigned NOT NULL,
-  `ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_host_by_event_name;
-Table	Create Table
-events_statements_summary_by_host_by_event_name	CREATE TABLE `events_statements_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_thread_by_event_name;
-Table	Create Table
-events_statements_summary_by_thread_by_event_name	CREATE TABLE `events_statements_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_user_by_event_name;
-Table	Create Table
-events_statements_summary_by_user_by_event_name	CREATE TABLE `events_statements_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_by_account_by_event_name;
-Table	Create Table
-events_statements_summary_by_account_by_event_name	CREATE TABLE `events_statements_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_statements_summary_global_by_event_name;
-Table	Create Table
-events_statements_summary_global_by_event_name	CREATE TABLE `events_statements_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,
-  `SUM_ERRORS` bigint(20) unsigned NOT NULL,
-  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,
-  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,
-  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,
-  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,
-  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,
-  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_current;
-Table	Create Table
-events_waits_current	CREATE TABLE `events_waits_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_history;
-Table	Create Table
-events_waits_history	CREATE TABLE `events_waits_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_history_long;
-Table	Create Table
-events_waits_history_long	CREATE TABLE `events_waits_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `NESTING_EVENT_TYPE` enum('STATEMENT','STAGE','WAIT') DEFAULT NULL,
-  `OPERATION` varchar(32) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_host_by_event_name;
-Table	Create Table
-events_waits_summary_by_host_by_event_name	CREATE TABLE `events_waits_summary_by_host_by_event_name` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_instance;
-Table	Create Table
-events_waits_summary_by_instance	CREATE TABLE `events_waits_summary_by_instance` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_thread_by_event_name;
-Table	Create Table
-events_waits_summary_by_thread_by_event_name	CREATE TABLE `events_waits_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_user_by_event_name;
-Table	Create Table
-events_waits_summary_by_user_by_event_name	CREATE TABLE `events_waits_summary_by_user_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_account_by_event_name;
-Table	Create Table
-events_waits_summary_by_account_by_event_name	CREATE TABLE `events_waits_summary_by_account_by_event_name` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_global_by_event_name;
-Table	Create Table
-events_waits_summary_global_by_event_name	CREATE TABLE `events_waits_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_instances;
-Table	Create Table
-file_instances	CREATE TABLE `file_instances` (
-  `FILE_NAME` varchar(512) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `OPEN_COUNT` int(10) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_summary_by_event_name;
-Table	Create Table
-file_summary_by_event_name	CREATE TABLE `file_summary_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_READ` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_summary_by_instance;
-Table	Create Table
-file_summary_by_instance	CREATE TABLE `file_summary_by_instance` (
-  `FILE_NAME` varchar(512) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_READ` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table hosts;
-Table	Create Table
-hosts	CREATE TABLE `hosts` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table mutex_instances;
-Table	Create Table
-mutex_instances	CREATE TABLE `mutex_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table objects_summary_global_by_type;
-Table	Create Table
-objects_summary_global_by_type	CREATE TABLE `objects_summary_global_by_type` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table performance_timers;
-Table	Create Table
-performance_timers	CREATE TABLE `performance_timers` (
-  `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL,
-  `TIMER_FREQUENCY` bigint(20) DEFAULT NULL,
-  `TIMER_RESOLUTION` bigint(20) DEFAULT NULL,
-  `TIMER_OVERHEAD` bigint(20) DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table rwlock_instances;
-Table	Create Table
-rwlock_instances	CREATE TABLE `rwlock_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `WRITE_LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL,
-  `READ_LOCKED_BY_COUNT` int(10) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_actors;
-Table	Create Table
-setup_actors	CREATE TABLE `setup_actors` (
-  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%',
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%',
-  `ROLE` char(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '%'
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_consumers;
-Table	Create Table
-setup_consumers	CREATE TABLE `setup_consumers` (
-  `NAME` varchar(64) NOT NULL,
-  `ENABLED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_instruments;
-Table	Create Table
-setup_instruments	CREATE TABLE `setup_instruments` (
-  `NAME` varchar(128) NOT NULL,
-  `ENABLED` enum('YES','NO') NOT NULL,
-  `TIMED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_objects;
-Table	Create Table
-setup_objects	CREATE TABLE `setup_objects` (
-  `OBJECT_TYPE` enum('TABLE') NOT NULL DEFAULT 'TABLE',
-  `OBJECT_SCHEMA` varchar(64) DEFAULT '%',
-  `OBJECT_NAME` varchar(64) NOT NULL DEFAULT '%',
-  `TIMED` enum('YES','NO') NOT NULL DEFAULT 'YES'
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_timers;
-Table	Create Table
-setup_timers	CREATE TABLE `setup_timers` (
-  `NAME` varchar(64) NOT NULL,
-  `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_io_waits_summary_by_index_usage;
-Table	Create Table
-table_io_waits_summary_by_index_usage	CREATE TABLE `table_io_waits_summary_by_index_usage` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `INDEX_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_io_waits_summary_by_table;
-Table	Create Table
-table_io_waits_summary_by_table	CREATE TABLE `table_io_waits_summary_by_table` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
-  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
-  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table table_lock_waits_summary_by_table;
-Table	Create Table
-table_lock_waits_summary_by_table	CREATE TABLE `table_lock_waits_summary_by_table` (
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(64) DEFAULT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table threads;
-Table	Create Table
-threads	CREATE TABLE `threads` (
-  `THREAD_ID` int(11) NOT NULL,
-  `NAME` varchar(128) NOT NULL,
-  `TYPE` varchar(10) NOT NULL,
-  `PROCESSLIST_ID` int(11) DEFAULT NULL,
-  `PROCESSLIST_USER` varchar(16) DEFAULT NULL,
-  `PROCESSLIST_HOST` varchar(60) DEFAULT NULL,
-  `PROCESSLIST_DB` varchar(64) DEFAULT NULL,
-  `PROCESSLIST_COMMAND` varchar(16) DEFAULT NULL,
-  `PROCESSLIST_TIME` bigint(20) DEFAULT NULL,
-  `PROCESSLIST_STATE` varchar(64) DEFAULT NULL,
-  `PROCESSLIST_INFO` longtext,
-  `PARENT_THREAD_ID` int(11) DEFAULT NULL,
-  `ROLE` varchar(64) DEFAULT NULL,
-  `INSTRUMENTED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table users;
-Table	Create Table
-users	CREATE TABLE `users` (
-  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
-  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8

=== modified file 'mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test'
--- a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test	2011-08-16 03:57:30 +0000
+++ b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test	2011-08-16 04:58:21 +0000
@@ -446,7 +446,8 @@ AND
 # MLML: Ask Chris, if this is really correct.
 
 if(`SELECT COUNT(*) FROM mysqltest.socket_summary_by_instance_detail
-    WHERE NOT ( $my_rules )`)
+    WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+    AND NOT ( $my_rules )`)
 {
    --enable_query_log
    --enable_result_log

=== modified file 'mysql-test/t/group_by.test'
--- a/mysql-test/t/group_by.test	2011-06-10 09:52:57 +0000
+++ b/mysql-test/t/group_by.test	2011-08-11 05:52:13 +0000
@@ -1382,3 +1382,24 @@ DEALLOCATE PREPARE stmt;
 DROP TABLE t1, t2;
 
 --echo # End of Bug #11766429
+
+--echo #
+--echo # Bug#12798270: ASSERTION `!TAB->SORTED' FAILED IN JOIN_READ_KEY2
+--echo #
+
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES (1);
+
+CREATE TABLE t2 (pk int PRIMARY KEY);
+INSERT INTO t2 VALUES (10);
+
+CREATE VIEW v1 AS SELECT t2.pk FROM t2;
+
+SELECT v1.pk
+FROM t1 LEFT JOIN v1 ON t1.i = v1.pk 
+GROUP BY v1.pk;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
+
+--echo # End of Bug#12798270

=== modified file 'mysql-test/t/information_schema.test'
--- a/mysql-test/t/information_schema.test	2011-07-18 09:49:22 +0000
+++ b/mysql-test/t/information_schema.test	2011-08-11 18:53:46 +0000
@@ -1581,11 +1581,6 @@ drop function f1;
 disconnect con7;
 
 
-
-
-# Wait till all disconnects are completed
---source include/wait_until_count_sessions.inc
-
 #
 # Bug #43834    Assertion in Natural_join_column::db_name() on an I_S query
 #
@@ -1649,5 +1644,185 @@ drop view v1;
 
 
 --echo #
+--echo # Test for bug #12828477 - "MDL SUBSYSTEM CREATES BIG OVERHEAD FOR
+--echo #                           CERTAIN QUERIES TO INFORMATION_SCHEMA".
+--echo #
+--echo # Check that metadata locks which are acquired during the process
+--echo # of opening tables/.FRMs/.TRG files while filling I_S table are
+--echo # not kept to the end of statement. Keeping the locks has caused
+--echo # performance problems in cases when big number of tables (.FRMs
+--echo # or .TRG files) were scanned as cost of new lock acquisition has
+--echo # increased linearly.
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+create database mysqltest;
+use mysqltest;
+create table t0 (i int);
+create table t1 (j int);
+create table t2 (k int);
+
+--echo #
+--echo # Test that we don't keep locks in case when we to fill
+--echo # I_S table we perform full-blown table open.
+--echo #
+
+--echo # Acquire lock on 't2' so upcoming RENAME is
+--echo # blocked.
+lock tables t2 read;
+
+--echo #
+--echo # Switching to connection 'con12828477_1'. 
+--echo #
+connect (con12828477_1, localhost, root,,mysqltest);
+--echo # The below RENAME should wait on 't2' while
+--echo # keeping X lock on 't1'.
+--send rename table t1 to t3, t2 to t1, t3 to t2
+
+--echo #
+--echo # Switching to connection 'con12828477_2'. 
+--echo #
+connect (con12828477_2, localhost, root,,mysqltest);
+--echo # Wait while the above RENAME is blocked.
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Waiting for table metadata lock" and
+        info = "rename table t1 to t3, t2 to t1, t3 to t2";
+--source include/wait_condition.inc
+
+--echo # Issue query to I_S which will open 't0' and get
+--echo # blocked on 't1' because of RENAME.
+--send select table_name, auto_increment from information_schema.tables where table_schema='mysqltest'
+
+--echo #
+--echo # Switching to connection 'con12828477_3'. 
+--echo #
+connect (con12828477_3, localhost, root,,mysqltest);
+--echo # Wait while the above SELECT is blocked.
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Waiting for table metadata lock" and
+        info = "select table_name, auto_increment from information_schema.tables where table_schema='mysqltest'";
+--source include/wait_condition.inc
+
+--echo #
+--echo # Check that it holds no lock on 't0' so it can be renamed.
+rename table t0 to t4;
+
+--echo #
+--echo # Switching to connection 'default'.
+--echo #
+connection default;
+--echo #
+--echo # Unblock the first RENAME.
+unlock tables;
+
+--echo #
+--echo # Switching to connection 'con12828477_1'. 
+--echo #
+connection con12828477_1;
+--echo # Reap the first RENAME
+--reap
+
+--echo #
+--echo # Switching to connection 'con12828477_2'. 
+--echo #
+connection con12828477_2;
+--echo # Reap SELECT to I_S.
+--reap
+
+--echo #
+--echo # Switching to connection 'default'.
+--echo #
+connection default;
+
+--echo #
+--echo # Now test that we don't keep locks in case when we to fill
+--echo # I_S table we read .FRM or .TRG file only (this was the case
+--echo # for which problem existed).
+--echo #
+
+rename table t4 to t0;
+--echo # Acquire lock on 't2' so upcoming RENAME is
+--echo # blocked.
+lock tables t2 read;
+
+--echo #
+--echo # Switching to connection 'con12828477_1'. 
+--echo #
+connection con12828477_1;
+--echo # The below RENAME should wait on 't2' while
+--echo # keeping X lock on 't1'.
+--send rename table t1 to t3, t2 to t1, t3 to t2
+
+--echo #
+--echo # Switching to connection 'con12828477_2'. 
+--echo #
+connection con12828477_2;
+--echo # Wait while the above RENAME is blocked.
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Waiting for table metadata lock" and
+        info = "rename table t1 to t3, t2 to t1, t3 to t2";
+--source include/wait_condition.inc
+
+--echo # Issue query to I_S which will open 't0' and get
+--echo # blocked on 't1' because of RENAME.
+--send select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest'
+
+--echo #
+--echo # Switching to connection 'con12828477_3'. 
+--echo #
+connection con12828477_3;
+--echo # Wait while the above SELECT is blocked.
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Waiting for table metadata lock" and
+        info = "select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest'";
+--source include/wait_condition.inc
+
+--echo #
+--echo # Check that it holds no lock on 't0' so it can be renamed.
+rename table t0 to t4;
+
+--echo #
+--echo # Switching to connection 'default'.
+--echo #
+connection default;
+--echo #
+--echo # Unblock the first RENAME.
+unlock tables;
+
+--echo #
+--echo # Switching to connection 'con12828477_1'. 
+--echo #
+connection con12828477_1;
+--echo # Reap the first RENAME
+--reap
+
+--echo #
+--echo # Switching to connection 'con12828477_2'. 
+--echo #
+connection con12828477_2;
+--echo # Reap SELECT to I_S.
+--reap
+
+--echo #
+--echo # Switching to connection 'default'.
+--echo #
+connection default;
+disconnect con12828477_1;
+disconnect con12828477_2;
+disconnect con12828477_3;
+
+--echo #
+--echo # Clean-up.
+drop database mysqltest;
+
+
+--echo #
 --echo # End of 5.5 tests
 --echo #
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc

=== added file 'mysql-test/t/mysql_plugin-master.opt'
--- a/mysql-test/t/mysql_plugin-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysql_plugin-master.opt	2011-07-19 14:17:58 +0000
@@ -0,0 +1 @@
+--plugin-dir=$DAEMONEXAMPLE_DIR

=== added file 'mysql-test/t/mysql_plugin.test'
--- a/mysql-test/t/mysql_plugin.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysql_plugin.test	2011-08-12 10:49:38 +0000
@@ -0,0 +1,318 @@
+#
+# Test mysql_plugin tool
+#
+# This test contains test cases for testing the mysql_plugin client with
+# the daemon_example plugin. Test cases include tests for:
+#
+#   - successful enable/disable
+#   - incorrect paths
+#   - missing paths/options
+#
+# Implementation Notes
+#
+# The mysql_plugin tool now accepts --mysqld the path to mysqld server. The
+# mysqld path is extracted from MYSQLD_BOOTSTRAP_CMD line. We also extract
+# the path of MYSQLD_BASEDIR (where mysql exists) and use it for the errmsg
+# file. The directories differ between Windows and Unix but the Perl script
+# included below will pick as per platform.
+#
+# The test is also designed to issue the --skip directive if the location of
+# the mysqld, my_print_defaults, or daemon_example.ini files cannot be found.
+#
+
+--source include/not_embedded.inc
+
+# Add the datadir, basedir, plugin_dir to the bootstrap command
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $MYSQL_BASEDIR= `select @@basedir`;
+let $MYSQL_ERRMSG_BASEDIR=`select @@lc_messages_dir`;
+let $PLUGIN_DIR=`select @@plugin_dir`;
+
+--disable_abort_on_error
+
+# Perl script to extract the location of the basedir from environment
+# variables. This is needed to ensure the test will run on the PB machines
+# designed to test release as well as debug builds. It also checks for the
+# location of the my_print_defaults and daemon_example.ini files.
+
+perl;
+use File::Basename;
+  my ($mysqld)= split " ", $ENV{MYSQLD_BOOTSTRAP_CMD};
+  my $mysqld_basedir=dirname($mysqld);
+  my $my_print_defaults= $ENV{MYSQL_MY_PRINT_DEFAULTS};
+  my $my_print_defaults_basedir=dirname($my_print_defaults);
+  my $daemonexample_ini= "$ENV{DAEMONEXAMPLE_DIR}/daemon_example.ini";
+  my $plugindir_ini= "$ENV{PLUGIN_DIR}/daemon_example.ini";
+  my $notfound= "";
+  open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mysqld.inc") or die;
+  print FILE "let \$MYSQLD= $mysqld;\n";
+  print FILE "let \$MYSQLD_BASEDIR= $mysqld_basedir;\n";
+  print FILE "let \$MYSQL_MY_PRINT_DEFAULTS_BASEDIR= $my_print_defaults_basedir;\n";
+  if ((!-e $daemonexample_ini) || (!-r $daemonexample_ini))
+  {
+    print FILE "let \$DAEMONEXAMPLE_DIR= $not_found;\n";
+  }
+  if ((!-e $plugindir_ini) || (!-r $plugindir_ini))
+  {
+    print FILE "let \$PLUGIN_DIR= $not_found;\n";
+  }
+  close FILE;
+EOF
+
+
+source $MYSQL_TMP_DIR/mysqld.inc;
+remove_file $MYSQL_TMP_DIR/mysqld.inc;
+
+# The mysql_plugin tool expects a directory structure like in the installed
+# mysql version, so errmsg.sys will be copied to "basedir/share", we create
+# and remove this structure. 
+
+--mkdir $MYSQLD_BASEDIR/share
+--mkdir $MYSQLD_BASEDIR/share/mysql
+--copy_file $MYSQL_ERRMSG_BASEDIR/english/errmsg.sys $MYSQLD_BASEDIR/share/errmsg.sys
+--copy_file $MYSQL_ERRMSG_BASEDIR/english/errmsg.sys $MYSQLD_BASEDIR/share/mysql/errmsg.sys
+
+# The mysql_plugin tool now accepts --my-print-defaults which points to the
+# executable my_print_defaults.exe we can get this path from the variable
+# $MYSQL_MY_PRINT_DEFAULTS.
+
+# Check for my_print_defaults location. Skip if not found.
+if ($MYSQL_MY_PRINT_DEFAULTS_BASEDIR == '')
+{
+  --skip Test requires known location of my_print_defaults executable.
+}
+
+# Check for mysqld location. Skip if not found.
+if ($MYSQLD == '')
+{
+  --skip Test requires known location of mysqld executable.
+}
+
+# Check for daemon_example.ini location. Skip if not found in either
+# the plugin_dir path or the daemon_example_dir path.
+if ($PLUGIN_DIR == '')
+{
+  if ($DAEMONEXAMPLE_DIR == '')
+  {
+    --skip Test requires known location of daemon_example.ini file.  
+  }
+  let $PLUGIN_DIR = $DAEMONEXAMPLE_DIR;
+}
+
+# Build client command for reuse.
+
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN --datadir=$MYSQLD_DATADIR --basedir=$MYSQLD_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+
+--echo #
+--echo # Ensure the plugin isn't loaded.
+--echo #
+SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name;
+
+--echo #
+--echo # Enable the plugin...
+--echo #
+let $expect_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+# MTR will remove this file later, but this might be too late.
+--error 0,1
+--remove_file $expect_file
+--write_file $expect_file
+wait
+EOF
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+
+#
+# Enable the plugin
+#
+--exec $MYSQL_PLUGIN_CMD ENABLE daemon_example
+
+#
+# Ensure enabling an enabled plugin doesn't fail
+--exec $MYSQL_PLUGIN_CMD ENABLE daemon_example
+
+#
+# Restart the server
+#
+--append_file $expect_file
+restart
+EOF
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--echo #
+--echo # Ensure the plugin is now loaded.
+--echo #
+--replace_regex /\.dll/.so/
+SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name;
+
+--echo #
+--echo # Disable the plugin...
+--echo #
+# MTR will remove this file later, but this might be too late.
+--error 0,1
+--remove_file $expect_file
+--write_file $expect_file
+wait
+EOF
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+
+#
+# Disable the plugin
+#
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example
+
+#
+# Restart the server
+#
+--append_file $expect_file
+restart
+EOF
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--echo #
+--echo # Ensure the plugin isn't loaded.
+--echo #
+SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name;
+
+#
+# Stop the server for error conditions
+#
+let $expect_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+# MTR will remove this file later, but this might be too late.
+--error 0,1
+--remove_file $expect_file
+--write_file $expect_file
+wait
+EOF
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+
+--echo #
+--echo # Attempt to load non-existant plugin
+--echo #
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE NOT_THERE_AT_ALL 2>&1
+
+--echo #
+--echo # Attempt to use non-existant plugin.ini file
+--echo #
+--error 1,2,7,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example --plugin-ini=/NOT/THERE/pi.ini 2>&1
+
+--echo # 
+--echo # Attempt to omit the plugin
+--echo #
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE 2>&1
+
+--echo # 
+--echo # Attempt to omit DISABLE|ENABLE
+--echo #
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD daemon_example 2>&1
+
+--echo # 
+--echo # Attempt to use bad paths - datadir
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=/data_not_there/ --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo # 
+--echo # Attempt to use bad paths - basedir
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=/basedir_not_there/ --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo # 
+--echo # Attempt to use bad paths - plugin_dir
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=/plugin_not_there/ --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo # 
+--echo # Attempt to use bad paths - mysqld
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=/mysqld_not_there/ --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo # 
+--echo # Attempt to use bad paths - my_print_defaults
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=/my_print_defaults_not_there/;
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+
+--echo # 
+--echo # Missing library
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --plugin-ini=$MYSQL_TEST_DIR/include/daemon_example_bad_soname.ini --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo # 
+--echo # Bad format for config file
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --plugin-ini=$MYSQL_TEST_DIR/include/daemon_example_bad_format.ini --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo # 
+--echo # Missing base_dir option
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,139,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo # 
+--echo # Missing data_dir option
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,139,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo # 
+--echo # Missing plugin_dir option
+--echo #
+let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQL_DATADIR --basedir=$MYSQL_BASEDIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
+--error 1,2,139,256
+--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
+
+--echo #
+--echo # Show the help.
+--echo #
+replace_result $MYSQL_PLUGIN mysql_plugin;
+--replace_regex /Ver [0-9.]+ Distrib [0-9.]+/Ver V.V.VV Distrib XX.XX.XX/ /XX-m[0-9]+/XX/
+--exec $MYSQL_PLUGIN --help
+
+replace_result $MYSQL_PLUGIN mysql_plugin;
+--replace_regex /Ver [0-9.]+ Distrib [0-9.]+/Ver V.V.VV Distrib XX.XX.XX/ /XX-m[0-9]+/XX/
+--exec $MYSQL_PLUGIN --version
+
+#
+# Restart the server
+#
+--append_file $expect_file
+restart
+EOF
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+#
+# Cleanup
+# MTR will remove this file later, but this might be too late.
+--error 0,1
+--remove_file $expect_file
+
+# Cleanup the share folder in the binary path.
+--remove_file $MYSQLD_BASEDIR/share/errmsg.sys
+--rmdir $MYSQLD_BASEDIR/share/mysql
+--rmdir $MYSQLD_BASEDIR/share
+
+--enable_abort_on_error

=== modified file 'mysql-test/t/sp_trans.test'
--- a/mysql-test/t/sp_trans.test	2010-10-06 14:34:28 +0000
+++ b/mysql-test/t/sp_trans.test	2011-08-08 17:07:51 +0000
@@ -598,6 +598,39 @@ select distinct f1, bug13575(f1) from t3
 drop function bug13575|
 drop table t3|
 
+#
+# BUG#11758414: Default storage_engine not honored when set
+#               from within a stored procedure
+#
+SELECT @@GLOBAL.default_storage_engine INTO @old_engine|
+SET @@GLOBAL.default_storage_engine=InnoDB|
+SET @@SESSION.default_storage_engine=InnoDB|
+# show defaults at define-time
+SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'|
+SHOW SESSION VARIABLES LIKE 'default_storage_engine'|
+CREATE PROCEDURE bug11758414()
+BEGIN
+ SET @@GLOBAL.default_storage_engine="MyISAM";
+ SET @@SESSION.default_storage_engine="MyISAM"; 
+ # show defaults at execution time / that setting them worked
+ SHOW GLOBAL VARIABLES LIKE 'default_storage_engine';
+ SHOW SESSION VARIABLES LIKE 'default_storage_engine';
+ CREATE TABLE t1 (id int);
+ CREATE TABLE t2 (id int) ENGINE=InnoDB;
+ # show we're heeding the default (at run-time, not parse-time!)
+ SHOW CREATE TABLE t1;
+ # show that we didn't break explicit override with ENGINE=...
+ SHOW CREATE TABLE t2;
+END;
+|
+CALL bug11758414|
+# show that changing defaults within SP stuck
+SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'|
+SHOW SESSION VARIABLES LIKE 'default_storage_engine'|
+DROP PROCEDURE bug11758414|
+DROP TABLE t1, t2|
+SET @@GLOBAL.default_storage_engine=@old_engine|
+
 --echo #
 --echo # End of 5.1 tests
 --echo #

=== modified file 'plugin/daemon_example/CMakeLists.txt'
--- a/plugin/daemon_example/CMakeLists.txt	2010-08-12 15:19:57 +0000
+++ b/plugin/daemon_example/CMakeLists.txt	2011-07-19 14:17:58 +0000
@@ -15,3 +15,5 @@
 
 MYSQL_ADD_PLUGIN(daemon_example daemon_example.cc
   MODULE_ONLY MODULE_OUTPUT_NAME "libdaemon_example")
+
+INSTALL(FILES daemon_example.ini DESTINATION ${INSTALL_PLUGINDIR})

=== added file 'plugin/daemon_example/daemon_example.ini'
--- a/plugin/daemon_example/daemon_example.ini	1970-01-01 00:00:00 +0000
+++ b/plugin/daemon_example/daemon_example.ini	2011-07-19 14:24:14 +0000
@@ -0,0 +1,9 @@
+#
+# Plugin configuration file. Place the following on a separate line:
+#
+# library binary file name (without .so or .dll)
+# component_name
+# [component_name] - additional components in plugin
+#
+libdaemon_example
+daemon_example

=== modified file 'sql/field.h'
--- a/sql/field.h	2011-07-28 10:54:44 +0000
+++ b/sql/field.h	2011-08-05 10:33:08 +0000
@@ -264,7 +264,17 @@ public:
   */
   virtual void sql_type(String &str) const =0;
   inline bool is_null(my_ptrdiff_t row_offset= 0)
-  { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : table->null_row; }
+  {
+    /*
+      If the field is NULLable, it has a valid null_ptr pointer, and its
+      NULLity is recorded in the "null_bit" bit of null_ptr[row_offset].
+      Otherwise, it can still be NULL, if it belongs to the inner table of an
+      outer join and the row is NULL-complemented: that case is recorded in
+      TABLE::null_row.
+    */
+    return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) :
+      table->null_row;
+  }
   inline bool is_real_null(my_ptrdiff_t row_offset= 0)
     { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : 0; }
   inline bool is_null_in_record(const uchar *record)

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-08-05 10:26:13 +0000
+++ b/sql/handler.cc	2011-08-15 08:58:05 +0000
@@ -2150,7 +2150,7 @@ handler *handler::clone(const char *name
 
 
 
-void handler::ha_statistic_increment(ulong SSV::*offset) const
+void handler::ha_statistic_increment(ulonglong SSV::*offset) const
 {
   status_var_increment(table->in_use->status_var.*offset);
 }

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-08-05 10:26:13 +0000
+++ b/sql/handler.h	2011-08-15 08:58:05 +0000
@@ -2171,7 +2171,7 @@ public:
 
 protected:
   /* Service methods for use by storage engines. */
-  void ha_statistic_increment(ulong SSV::*offset) const;
+  void ha_statistic_increment(ulonglong SSV::*offset) const;
   void **ha_data(THD *) const;
   THD *ha_thd(void) const;
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-08-03 18:29:12 +0000
+++ b/sql/mysqld.cc	2011-08-16 04:58:21 +0000
@@ -6479,18 +6479,18 @@ static int show_net_compression(THD *thd
 
 static int show_starttime(THD *thd, SHOW_VAR *var, char *buff)
 {
-  var->type= SHOW_LONG;
+  var->type= SHOW_LONGLONG;
   var->value= buff;
-  *((long *)buff)= (long) (thd->query_start() - server_start_time);
+  *((longlong *)buff)= (longlong) (thd->query_start() - server_start_time);
   return 0;
 }
 
 #ifdef ENABLED_PROFILING
 static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff)
 {
-  var->type= SHOW_LONG;
+  var->type= SHOW_LONGLONG;
   var->value= buff;
-  *((long *)buff)= (long) (thd->query_start() - flush_status_time);
+  *((longlong *)buff)= (longlong) (thd->query_start() - flush_status_time);
   return 0;
 }
 #endif
@@ -6987,31 +6987,31 @@ SHOW_VAR status_vars[]= {
   {"Com",                      (char*) com_status_vars, SHOW_ARRAY},
   {"Compression",              (char*) &show_net_compression, SHOW_FUNC},
   {"Connections",              (char*) &thread_id,              SHOW_LONG_NOFLUSH},
-  {"Created_tmp_disk_tables",  (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
-  {"Created_tmp_files",        (char*) &my_tmp_file_created,  SHOW_LONG},
-  {"Created_tmp_tables",       (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS},
+  {"Created_tmp_disk_tables",  (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONGLONG_STATUS},
+  {"Created_tmp_files",        (char*) &my_tmp_file_created, SHOW_LONG},
+  {"Created_tmp_tables",       (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONGLONG_STATUS},
   {"Delayed_errors",           (char*) &delayed_insert_errors,  SHOW_LONG},
   {"Delayed_insert_threads",   (char*) &delayed_insert_threads, SHOW_LONG_NOFLUSH},
   {"Delayed_writes",           (char*) &delayed_insert_writes,  SHOW_LONG},
   {"Flush_commands",           (char*) &refresh_version,        SHOW_LONG_NOFLUSH},
-  {"Handler_commit",           (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
-  {"Handler_delete",           (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-  {"Handler_discover",         (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONG_STATUS},
-  {"Handler_external_lock",    (char*) offsetof(STATUS_VAR, ha_external_lock_count), SHOW_LONG_STATUS},
-  {"Handler_mrr_init",         (char*) offsetof(STATUS_VAR, ha_multi_range_read_init_count),  SHOW_LONG_STATUS},
-  {"Handler_prepare",          (char*) offsetof(STATUS_VAR, ha_prepare_count),  SHOW_LONG_STATUS},
-  {"Handler_read_first",       (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS},
-  {"Handler_read_key",         (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS},
-  {"Handler_read_last",        (char*) offsetof(STATUS_VAR, ha_read_last_count), SHOW_LONG_STATUS},
-  {"Handler_read_next",        (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
-  {"Handler_read_prev",        (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
-  {"Handler_read_rnd",         (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
-  {"Handler_read_rnd_next",    (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
-  {"Handler_rollback",         (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS},
-  {"Handler_savepoint",        (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS},
-  {"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
-  {"Handler_update",           (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
-  {"Handler_write",            (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
+  {"Handler_commit",           (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONGLONG_STATUS},
+  {"Handler_delete",           (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONGLONG_STATUS},
+  {"Handler_discover",         (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONGLONG_STATUS},
+  {"Handler_external_lock",    (char*) offsetof(STATUS_VAR, ha_external_lock_count), SHOW_LONGLONG_STATUS},
+  {"Handler_mrr_init",         (char*) offsetof(STATUS_VAR, ha_multi_range_read_init_count),  SHOW_LONGLONG_STATUS},
+  {"Handler_prepare",          (char*) offsetof(STATUS_VAR, ha_prepare_count),  SHOW_LONGLONG_STATUS},
+  {"Handler_read_first",       (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONGLONG_STATUS},
+  {"Handler_read_key",         (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONGLONG_STATUS},
+  {"Handler_read_last",        (char*) offsetof(STATUS_VAR, ha_read_last_count), SHOW_LONGLONG_STATUS},
+  {"Handler_read_next",        (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONGLONG_STATUS},
+  {"Handler_read_prev",        (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONGLONG_STATUS},
+  {"Handler_read_rnd",         (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONGLONG_STATUS},
+  {"Handler_read_rnd_next",    (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONGLONG_STATUS},
+  {"Handler_rollback",         (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONGLONG_STATUS},
+  {"Handler_savepoint",        (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONGLONG_STATUS},
+  {"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONGLONG_STATUS},
+  {"Handler_update",           (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONGLONG_STATUS},
+  {"Handler_write",            (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONGLONG_STATUS},
   {"Key_blocks_not_flushed",   (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
   {"Key_blocks_unused",        (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
   {"Key_blocks_used",          (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
@@ -7027,8 +7027,8 @@ SHOW_VAR status_vars[]= {
   {"Open_table_definitions",   (char*) &show_table_definitions, SHOW_FUNC},
   {"Open_tables",              (char*) &show_open_tables,       SHOW_FUNC},
   {"Opened_files",             (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH},
-  {"Opened_tables",            (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
-  {"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
+  {"Opened_tables",            (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONGLONG_STATUS},
+  {"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONGLONG_STATUS},
   {"Prepared_stmt_count",      (char*) &show_prepared_stmt_count, SHOW_FUNC},
 #ifdef HAVE_QUERY_CACHE
   {"Qcache_free_blocks",       (char*) &query_cache.free_memory_blocks, SHOW_LONG_NOFLUSH},
@@ -7041,12 +7041,12 @@ SHOW_VAR status_vars[]= {
   {"Qcache_total_blocks",      (char*) &query_cache.total_blocks, SHOW_LONG_NOFLUSH},
 #endif /*HAVE_QUERY_CACHE*/
   {"Queries",                  (char*) &show_queries,            SHOW_FUNC},
-  {"Questions",                (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS},
-  {"Select_full_join",         (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONG_STATUS},
-  {"Select_full_range_join",   (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONG_STATUS},
-  {"Select_range",             (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONG_STATUS},
-  {"Select_range_check",       (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
-  {"Select_scan",        (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
+  {"Questions",                (char*) offsetof(STATUS_VAR, questions), SHOW_LONGLONG_STATUS},
+  {"Select_full_join",         (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONGLONG_STATUS},
+  {"Select_full_range_join",   (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONGLONG_STATUS},
+  {"Select_range",             (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONGLONG_STATUS},
+  {"Select_range_check",       (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONGLONG_STATUS},
+  {"Select_scan",              (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONGLONG_STATUS},
   {"Slave_open_temp_tables",   (char*) &slave_open_temp_tables, SHOW_LONG},
 #ifdef HAVE_REPLICATION
   {"Slave_retried_transactions",(char*) &show_slave_retried_trans, SHOW_FUNC},
@@ -7056,11 +7056,11 @@ SHOW_VAR status_vars[]= {
   {"Slave_running",            (char*) &show_slave_running,     SHOW_FUNC},
 #endif
   {"Slow_launch_threads",      (char*) &slow_launch_threads,    SHOW_LONG},
-  {"Slow_queries",             (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
-  {"Sort_merge_passes",        (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
-  {"Sort_range",         (char*) offsetof(STATUS_VAR, filesort_range_count), SHOW_LONG_STATUS},
-  {"Sort_rows",          (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONG_STATUS},
-  {"Sort_scan",          (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONG_STATUS},
+  {"Slow_queries",             (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONGLONG_STATUS},
+  {"Sort_merge_passes",        (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONGLONG_STATUS},
+  {"Sort_range",               (char*) offsetof(STATUS_VAR, filesort_range_count), SHOW_LONGLONG_STATUS},
+  {"Sort_rows",                (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONGLONG_STATUS},
+  {"Sort_scan",                (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONGLONG_STATUS},
 #ifdef HAVE_OPENSSL
 #ifndef EMBEDDED_LIBRARY
   {"Ssl_accept_renegotiates",  (char*) &show_ssl_ctx_sess_accept_renegotiate, SHOW_FUNC},

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2011-07-28 10:54:44 +0000
+++ b/sql/opt_range.cc	2011-08-05 14:30:29 +0000
@@ -1545,7 +1545,13 @@ end:
   head->prepare_for_position();
   head->file= org_file;
   bitmap_copy(&column_bitmap, head->read_set);
-  head->column_bitmaps_set(&column_bitmap, &column_bitmap);
+
+  /*
+    We have prepared a column_bitmap which get_next() will use. To do this we
+    used TABLE::read_set/write_set as playground; restore them to their
+    original value to not pollute other scans.
+  */
+  head->column_bitmaps_set(save_read_set, save_write_set);
 
   DBUG_RETURN(0);
 
@@ -1588,9 +1594,16 @@ int QUICK_ROR_INTERSECT_SELECT::init_ror
   }
   while ((quick= quick_it++))
   {
+#ifndef DBUG_OFF
+    const MY_BITMAP * const save_read_set= quick->head->read_set;
+    const MY_BITMAP * const save_write_set= quick->head->write_set;
+#endif
     if (quick->init_ror_merged_scan(FALSE))
       DBUG_RETURN(1);
     quick->file->extra(HA_EXTRA_KEYREAD_PRESERVE_FIELDS);
+    // Sets are shared by all members of "quick_selects" so must not change
+    DBUG_ASSERT(quick->head->read_set == save_read_set);
+    DBUG_ASSERT(quick->head->write_set == save_write_set);
     /* All merged scans share the same record buffer in intersection. */
     quick->record= head->record[0];
   }

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-08-03 18:29:12 +0000
+++ b/sql/sql_class.cc	2011-08-16 04:58:21 +0000
@@ -680,8 +680,8 @@ char *thd_security_context(THD *thd, cha
   const char *proc_info= thd->proc_info;
 
   len= my_snprintf(header, sizeof(header),
-                   "MySQL thread id %lu, query id %lu",
-                   thd->thread_id, (ulong) thd->query_id);
+                   "MySQL thread id %lu, OS thread handle 0x%lx, query id %lu",
+                   thd->thread_id, (ulong) thd->real_id, (ulong) thd->query_id);
   str.length(0);
   str.append(header, len);
 
@@ -1405,23 +1405,26 @@ THD::~THD()
    from_var     from this array
 
   NOTES
-    This function assumes that all variables are long/ulong.
+    This function assumes that all variables are longlong/ulonglong.
     If this assumption will change, then we have to explictely add
     the other variables after the while loop
 */
 
 void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
 {
-  ulong *end= (ulong*) ((uchar*) to_var +
-                        offsetof(STATUS_VAR, last_system_status_var) +
-			sizeof(ulong));
-  ulong *to= (ulong*) to_var, *from= (ulong*) from_var;
+  int        c;
+  ulonglong *end= (ulonglong*) ((uchar*) to_var +
+                                offsetof(STATUS_VAR, last_system_status_var) +
+                                sizeof(ulonglong));
+  ulonglong *to= (ulonglong*) to_var, *from= (ulonglong*) from_var;
 
   while (to != end)
     *(to++)+= *(from++);
 
-  to_var->bytes_received+= from_var->bytes_received;
-  to_var->bytes_sent+= from_var->bytes_sent;
+  to_var->com_other+= from_var->com_other;
+
+  for (c= 0; c< SQLCOM_END; c++)
+    to_var->com_stat[(uint) c] += from_var->com_stat[(uint) c];
 }
 
 /*
@@ -1434,22 +1437,27 @@ void add_to_status(STATUS_VAR *to_var, S
     dec_var      minus this array
   
   NOTE
-    This function assumes that all variables are long/ulong.
+    This function assumes that all variables are longlong/ulonglong.
 */
 
 void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
                         STATUS_VAR *dec_var)
 {
-  ulong *end= (ulong*) ((uchar*) to_var + offsetof(STATUS_VAR,
-						  last_system_status_var) +
-			sizeof(ulong));
-  ulong *to= (ulong*) to_var, *from= (ulong*) from_var, *dec= (ulong*) dec_var;
+  int        c;
+  ulonglong *end= (ulonglong*) ((uchar*) to_var + offsetof(STATUS_VAR,
+                                                           last_system_status_var) +
+                                sizeof(ulonglong));
+  ulonglong *to= (ulonglong*) to_var,
+            *from= (ulonglong*) from_var,
+            *dec= (ulonglong*) dec_var;
 
   while (to != end)
     *(to++)+= *(from++) - *(dec++);
 
-  to_var->bytes_received+= from_var->bytes_received - dec_var->bytes_received;;
-  to_var->bytes_sent+= from_var->bytes_sent - dec_var->bytes_sent;
+  to_var->com_other+= from_var->com_other - dec_var->com_other;
+
+  for (c= 0; c< SQLCOM_END; c++)
+    to_var->com_stat[(uint) c] += from_var->com_stat[(uint) c] -dec_var->com_stat[(uint) c];
 }
 
 

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-08-02 08:14:26 +0000
+++ b/sql/sql_class.h	2011-08-11 08:47:53 +0000
@@ -554,70 +554,75 @@ typedef struct system_variables
 
 typedef struct system_status_var
 {
-  ulong com_other;
-  ulong com_stat[(uint) SQLCOM_END];
-  ulong created_tmp_disk_tables;
-  ulong created_tmp_tables;
-  ulong ha_commit_count;
-  ulong ha_delete_count;
-  ulong ha_read_first_count;
-  ulong ha_read_last_count;
-  ulong ha_read_key_count;
-  ulong ha_read_next_count;
-  ulong ha_read_prev_count;
-  ulong ha_read_rnd_count;
-  ulong ha_read_rnd_next_count;
+  ulonglong created_tmp_disk_tables;
+  ulonglong created_tmp_tables;
+  ulonglong ha_commit_count;
+  ulonglong ha_delete_count;
+  ulonglong ha_read_first_count;
+  ulonglong ha_read_last_count;
+  ulonglong ha_read_key_count;
+  ulonglong ha_read_next_count;
+  ulonglong ha_read_prev_count;
+  ulonglong ha_read_rnd_count;
+  ulonglong ha_read_rnd_next_count;
   /*
     This number doesn't include calls to the default implementation and
     calls made by range access. The intent is to count only calls made by
     BatchedKeyAccess.
   */
-  ulong ha_multi_range_read_init_count;
-  ulong ha_rollback_count;
-  ulong ha_update_count;
-  ulong ha_write_count;
-  ulong ha_prepare_count;
-  ulong ha_discover_count;
-  ulong ha_savepoint_count;
-  ulong ha_savepoint_rollback_count;
-  ulong ha_external_lock_count;
+  ulonglong ha_multi_range_read_init_count;
+  ulonglong ha_rollback_count;
+  ulonglong ha_update_count;
+  ulonglong ha_write_count;
+  ulonglong ha_prepare_count;
+  ulonglong ha_discover_count;
+  ulonglong ha_savepoint_count;
+  ulonglong ha_savepoint_rollback_count;
+  ulonglong ha_external_lock_count;
 
+#if 0
+  /* Tatiana thinks this may be dead now. */
   /* KEY_CACHE parts. These are copies of the original */
-  ulong key_blocks_changed;
-  ulong key_blocks_used;
-  ulong key_cache_r_requests;
-  ulong key_cache_read;
-  ulong key_cache_w_requests;
-  ulong key_cache_write;
+  ulonglong key_blocks_changed;
+  ulonglong key_blocks_used;
+  ulonglong key_cache_r_requests;
+  ulonglong key_cache_read;
+  ulonglong key_cache_w_requests;
+  ulonglong key_cache_write;
   /* END OF KEY_CACHE parts */
+#endif
 
-  ulong opened_tables;
-  ulong opened_shares;
-  ulong select_full_join_count;
-  ulong select_full_range_join_count;
-  ulong select_range_count;
-  ulong select_range_check_count;
-  ulong select_scan_count;
-  ulong long_query_count;
-  ulong filesort_merge_passes;
-  ulong filesort_range_count;
-  ulong filesort_rows;
-  ulong filesort_scan_count;
+  ulonglong opened_tables;
+  ulonglong opened_shares;
+  ulonglong select_full_join_count;
+  ulonglong select_full_range_join_count;
+  ulonglong select_range_count;
+  ulonglong select_range_check_count;
+  ulonglong select_scan_count;
+  ulonglong long_query_count;
+  ulonglong filesort_merge_passes;
+  ulonglong filesort_range_count;
+  ulonglong filesort_rows;
+  ulonglong filesort_scan_count;
   /* Prepared statements and binary protocol */
-  ulong com_stmt_prepare;
-  ulong com_stmt_reprepare;
-  ulong com_stmt_execute;
-  ulong com_stmt_send_long_data;
-  ulong com_stmt_fetch;
-  ulong com_stmt_reset;
-  ulong com_stmt_close;
+  ulonglong com_stmt_prepare;
+  ulonglong com_stmt_reprepare;
+  ulonglong com_stmt_execute;
+  ulonglong com_stmt_send_long_data;
+  ulonglong com_stmt_fetch;
+  ulonglong com_stmt_reset;
+  ulonglong com_stmt_close;
+
+  ulonglong bytes_received;
+  ulonglong bytes_sent;
   /*
     Number of statements sent from the client
   */
-  ulong questions;
+  ulonglong questions;
+
+  ulong com_other;
+  ulong com_stat[(uint) SQLCOM_END];
 
-  ulonglong bytes_received;
-  ulonglong bytes_sent;
   /*
     IMPORTANT!
     SEE last_system_status_var DEFINITION BELOW.

=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc	2011-07-20 08:46:04 +0000
+++ b/sql/sql_join_cache.cc	2011-07-29 09:02:31 +0000
@@ -1257,12 +1257,18 @@ bool JOIN_CACHE::get_record()
     prev_rec_ptr= prev_cache->get_rec_ref(pos);
   }
   curr_rec_pos= pos;
-  res= (read_all_record_fields() == -1);
+  res= (read_some_record_fields() == -1);
   if (!res) 
   { // There are more records to read
     pos+= referenced_fields*size_of_fld_ofs;
     if (prev_cache)
+    {
+      /*
+        read_some_record_fields() didn't read fields stored in previous
+        buffers, read them now:
+      */
       prev_cache->get_record_by_pos(prev_rec_ptr);
+    }
   } 
   return res; 
 }
@@ -1290,7 +1296,7 @@ void JOIN_CACHE::get_record_by_pos(uchar
 {
   uchar *save_pos= pos;
   pos= rec_ptr;
-  read_all_record_fields();
+  read_some_record_fields();
   pos= save_pos;
   if (prev_cache)
   {
@@ -1332,35 +1338,37 @@ bool JOIN_CACHE::get_match_flag_by_pos(u
 }
 
 
-/* 
-  Read all flag and data fields of a record from the join buffer
+/**
+  Read some flag and data fields of a record from the join buffer.
 
-  SYNOPSIS
-    read_all_record_fields()
+  Reads all fields (flag and data fields) stored in this join buffer, for the
+  current record (at 'pos'). If the buffer is incremental, fields of this
+  record which are stored in previous join buffers are _not_ read so remain
+  unknown: caller must then make sure to call this function on previous
+  buffers too.
+
+  The fields are read starting from the position 'pos' which is
+  supposed to point to the beginning of the first record field.
+  The function increments the value of 'pos' by the length of the
+  read data.
 
-  DESCRIPTION
-    The function reads all flag and data fields of a record from the join
-    buffer into the corresponding record buffers.
-    The fields are read starting from the position 'pos' which is
-    supposed to point to the beginning og the first record field.
-    The function increments the value of 'pos' by the length of the
-    read data. 
+  Flag fields are copied back to their source; data fields are copied to the
+  record's buffer.
 
-  RETURN
-    (-1) - if there are no more records in the join buffer
-    length of the data read from the join buffer - otherwise
+  @retval (-1)   if there are no more records in the join buffer
+  @retval <>(-1) length of the data read from the join buffer
 */
 
-int JOIN_CACHE::read_all_record_fields()
+int JOIN_CACHE::read_some_record_fields()
 {
   uchar *init_pos= pos;
   
   if (pos > last_rec_pos || !records)
     return -1;
 
-  /* First match flag, read null bitmaps and null_row flag for each table */
-  read_flag_fields();
- 
+  // First match flag, read null bitmaps and null_row flag
+  read_some_flag_fields();
+
   /* Now read the remaining table fields if needed */
   CACHE_FIELD *copy= field_descr+flag_fields;
   CACHE_FIELD *copy_end= field_descr+fields;
@@ -1372,26 +1380,22 @@ int JOIN_CACHE::read_all_record_fields()
 }
 
 
-/* 
-  Read all flag fields of a record from the join buffer
+/**
+  Read some flag fields of a record from the join buffer.
 
-  SYNOPSIS
-    read_flag_fields()
+  Reads all flag fields stored in this join buffer, for the current record (at
+  'pos'). If the buffer is incremental, flag fields of this record which are
+  stored in previous join buffers are _not_ read so remain unknown: caller
+  must then make sure to call this function on previous buffers too.
+
+  The flag fields are read starting from the position 'pos'.
+  The function increments the value of 'pos' by the length of the
+  read data.
 
-  DESCRIPTION
-    The function reads all flag fields of a record from the join
-    buffer into the corresponding record buffers.
-    The fields are read starting from the position 'pos'.
-    The function increments the value of 'pos' by the length of the
-    read data. 
-
-  RETURN
-    length of the data read from the join buffer
+  Flag fields are copied back to their source.
 */
-
-uint JOIN_CACHE::read_flag_fields()
+void JOIN_CACHE::read_some_flag_fields()
 {
-  uchar *init_pos= pos;
   CACHE_FIELD *copy= field_descr;
   CACHE_FIELD *copy_end= copy+flag_fields;
   for ( ; copy < copy_end; copy++)
@@ -1399,7 +1403,6 @@ uint JOIN_CACHE::read_flag_fields()
     memcpy(copy->str, pos, copy->length);
     pos+= copy->length;
   }
-  return (pos-init_pos);
 }
 
 
@@ -2366,6 +2369,29 @@ JOIN_CACHE_BKA::init_join_matching_recor
 }
 
 
+/**
+  Reads all flag fields of a positioned record from the join buffer.
+  Including all flag fields (of this record) stored in the previous join
+  buffers.
+
+  @param rec_ptr  position of the first field of the record in the join buffer
+ */
+void JOIN_CACHE::read_all_flag_fields_by_pos(uchar *rec_ptr)
+{
+  uchar * const save_pos= pos;
+  pos= rec_ptr;
+  read_some_flag_fields();                      // moves 'pos'...
+  pos= save_pos;                                // ... so we restore it.
+  if (prev_cache)
+  {
+    // position of this record in previous join buffer:
+    rec_ptr= prev_cache->get_rec_ref(rec_ptr);
+    // recurse into previous buffer to read missing flag fields
+    prev_cache->read_all_flag_fields_by_pos(rec_ptr);
+  }
+}
+
+
 /* 
   Get the key built over the next record from BKA join buffer
 
@@ -2412,7 +2438,7 @@ uint JOIN_CACHE_BKA::get_next_key(uchar
 
   /*
     Read keys until find non-ignorable one or EOF.
-    Unlike in JOIN_CACHE::read_all_record_fields()), pos>=last_rec_pos means
+    Unlike in JOIN_CACHE::read_some_record_fields()), pos>=last_rec_pos means
     EOF, because we are not at fields' start, and previous record's fields
     might be empty.
   */
@@ -2424,13 +2450,20 @@ uint JOIN_CACHE_BKA::get_next_key(uchar
     init_pos= pos;
 
     /* Read a reference to the previous cache if any */
+    uchar *prev_rec_ptr;
     if (prev_cache)
+    {
       pos+= prev_cache->get_size_of_rec_offset();
+      // position of this record in previous buffer:
+      prev_rec_ptr= prev_cache->get_rec_ref(pos);
+    }
 
     curr_rec_pos= pos;
 
-    /* Read all flag fields of the record */
-    read_flag_fields();
+    // Read all flag fields of the record, in two steps:
+    read_some_flag_fields();      // 1) flag fields stored in this buffer
+    if (prev_cache)               // 2) flag fields stored in previous buffers
+      prev_cache->read_all_flag_fields_by_pos(prev_rec_ptr);
 
     if (use_emb_key)
     {
@@ -2672,15 +2705,18 @@ bool JOIN_CACHE_BKA_UNIQUE::put_record()
     /* Build the key over the fields read into the record buffers */ 
     cp_buffer_from_ref(join->thd, join_tab->table, ref);
     key= ref->key_buff;
-    /*
-      If the row just read into the buffer has a NULL-value for one of
-      the ref-columns and the join comparison function for that column
-      is '=' (in contrast to '<=>'), it's impossible with a join match
-      for this row. The key is therefore not inserted into the hash
-      table.
-    */
     if (ref->impossible_null_ref())
+    {
+      /*
+        The row just put into the buffer has a NULL-value for one of
+        the ref-columns and the ref access is NULL-rejecting, this key cannot
+        give a match. So we don't insert it into the hash table.
+        We still stored the record into the buffer (put_record() call above),
+        or we would later miss NULL-complementing of this record.
+      */
+      DBUG_PRINT("info", ("JOIN_CACHE_BKA_UNIQUE::put_record null_rejected"));
       return is_full;
+    }
   }
 
   /* Look for the key in the hash table */

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-08-11 03:11:58 +0000
+++ b/sql/sql_parse.cc	2011-08-16 04:58:21 +0000
@@ -2558,6 +2558,13 @@ case SQLCOM_PREPARE:
       goto end_with_restore_list;
 #endif
     /*
+      If no engine type was given, work out the default now
+      rather than at parse-time.
+    */
+    if (!(create_info.used_fields & HA_CREATE_USED_ENGINE))
+      create_info.db_type= create_info.options & HA_LEX_CREATE_TMP_TABLE ?
+              ha_default_temp_handlerton(thd) : ha_default_handlerton(thd);
+    /*
       If we are using SET CHARSET without DEFAULT, add an implicit
       DEFAULT to not confuse old users. (This may change).
     */

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-08-05 10:26:13 +0000
+++ b/sql/sql_select.cc	2011-08-15 08:58:05 +0000
@@ -12185,7 +12185,11 @@ make_join_readinfo(JOIN *join, ulonglong
     tab->read_record.unlock_row= rr_unlock_row;
     tab->next_select=sub_select;		/* normal select */
     tab->cache_idx_cond= 0;
-    tab->sorted= sorted;
+    /*
+      For eq_ref there is at most one join match for each row from
+      previous tables so ordering is not useful.
+    */
+    tab->sorted= (tab->type != JT_EQ_REF) ? sorted : false;
     sorted= false;                              // only first must be sorted
     table->status= STATUS_GARBAGE | STATUS_NOT_FOUND;
     pick_table_access_method (tab);

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2011-07-20 10:29:12 +0000
+++ b/sql/sql_select.h	2011-07-29 09:02:31 +0000
@@ -897,11 +897,14 @@ protected:
   /* Shall skip record from the join buffer if its match flag is on */
   virtual bool skip_record_if_match();
 
-  /*  Read all flag and data fields of a record from the join buffer */
-  int read_all_record_fields();
-  
-  /* Read all flag fields of a record from the join buffer */
-  uint read_flag_fields();
+  /* Read some flag and data fields of a record from the join buffer */
+  int read_some_record_fields();
+
+  /* Read some flag fields of a record from the join buffer */
+  void read_some_flag_fields();
+
+  /* Read all flag fields of the record which is at position rec_ptr */
+  void read_all_flag_fields_by_pos(uchar *rec_ptr);
 
   /* Read a data record field from the join buffer */
   uint read_record_field(CACHE_FIELD *copy, bool last_record);

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-08-02 08:34:30 +0000
+++ b/sql/sql_show.cc	2011-08-11 18:53:46 +0000
@@ -3168,6 +3168,10 @@ end:
   */
   thd->temporary_tables= NULL;
   close_thread_tables(thd);
+  /*
+    Release metadata lock we might have acquired.
+    See comment in fill_schema_table_from_frm() for details.
+  */
   thd->mdl_context.rollback_to_savepoint(open_tables_state_backup->mdl_system_tables_svp);
 
   thd->lex= old_lex;
@@ -3350,6 +3354,9 @@ try_acquire_high_prio_shared_mdl_lock(TH
   @param[in]      db_name                  database name
   @param[in]      table_name               table name
   @param[in]      schema_table_idx         I_S table index
+  @param[in]      open_tables_state_backup Open_tables_state object which is used
+                                           to save/restore original state of metadata
+                                           locks.
   @param[in]      can_deadlock             Indicates that deadlocks are possible
                                            due to metadata locks, so to avoid
                                            them we should not wait in case if
@@ -3367,6 +3374,7 @@ static int fill_schema_table_from_frm(TH
                                       LEX_STRING *db_name,
                                       LEX_STRING *table_name,
                                       enum enum_schema_tables schema_table_idx,
+                                      Open_tables_backup *open_tables_state_backup,
                                       bool can_deadlock)
 {
   TABLE *table= tables->table;
@@ -3512,13 +3520,27 @@ end_share:
 
 end_unlock:
   mysql_mutex_unlock(&LOCK_open);
-  /*
-    Don't release the MDL lock, it can be part of a transaction.
-    If it is not, it will be released by the call to
-    MDL_context::rollback_to_savepoint() in the caller.
-  */
 
 end:
+  /*
+    Release metadata lock we might have acquired.
+
+    Without this step metadata locks acquired for each table processed
+    will be accumulated. In situation when a lot of tables are processed
+    by I_S query this will result in transaction with too many metadata
+    locks. As result performance of acquisition of new lock will suffer.
+
+    Of course, the fact that we don't hold metadata lock on tables which
+    were processed till the end of I_S query makes execution less isolated
+    from concurrent DDL. Consequently one might get 'dirty' results from
+    such a query. But we have never promised serializability of I_S queries
+    anyway.
+
+    We don't have any tables open since we took backup, so rolling back to
+    savepoint is safe.
+  */
+  DBUG_ASSERT(thd->open_tables == NULL);
+  thd->mdl_context.rollback_to_savepoint(open_tables_state_backup->mdl_system_tables_svp);
   thd->clear_error();
   return res;
 }
@@ -3769,6 +3791,7 @@ int get_all_tables(THD *thd, TABLE_LIST
               int res= fill_schema_table_from_frm(thd, tables, schema_table,
                                                   db_name, table_name,
                                                   schema_table_idx,
+                                                  &open_tables_state_backup,
                                                   can_deadlock);
 
               thd->pop_internal_handler();

=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc	2011-07-19 15:11:15 +0000
+++ b/sql/sql_test.cc	2011-08-11 08:47:53 +0000
@@ -571,13 +571,13 @@ void mysql_print_status()
   process_key_caches(print_key_cache_status);
   mysql_mutex_lock(&LOCK_status);
   printf("\nhandler status:\n\
-read_key:   %10lu\n\
-read_next:  %10lu\n\
-read_rnd    %10lu\n\
-read_first: %10lu\n\
-write:      %10lu\n\
-delete      %10lu\n\
-update:     %10lu\n",
+read_key:   %10llu\n\
+read_next:  %10llu\n\
+read_rnd    %10llu\n\
+read_first: %10llu\n\
+write:      %10llu\n\
+delete      %10llu\n\
+update:     %10llu\n",
 	 tmp.ha_read_key_count,
 	 tmp.ha_read_next_count,
 	 tmp.ha_read_rnd_count,
@@ -591,7 +591,7 @@ Opened tables: %10lu\n\
 Open tables:   %10lu\n\
 Open files:    %10lu\n\
 Open streams:  %10lu\n",
-	 tmp.opened_tables,
+	 (ulong) tmp.opened_tables,
 	 (ulong) cached_open_tables(),
 	 (ulong) my_file_opened,
 	 (ulong) my_stream_opened);

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-08-05 10:26:13 +0000
+++ b/sql/sql_yacc.yy	2011-08-15 08:58:05 +0000
@@ -2073,9 +2073,6 @@ create:
             lex->change=NullS;
             memset(&lex->create_info, 0, sizeof(lex->create_info));
             lex->create_info.options=$2 | $4;
-            lex->create_info.db_type=
-              lex->create_info.options & HA_LEX_CREATE_TMP_TABLE ?
-              ha_default_temp_handlerton(thd) : ha_default_handlerton(thd);
             lex->create_info.default_table_charset= NULL;
             lex->name.str= 0;
             lex->name.length= 0;
@@ -2086,7 +2083,8 @@ create:
             THD *thd= YYTHD;
             LEX *lex= thd->lex;
             lex->current_select= &lex->select_lex; 
-            if (!lex->create_info.db_type)
+            if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) &&
+                !lex->create_info.db_type)
             {
               lex->create_info.db_type=
                 lex->create_info.options & HA_LEX_CREATE_TMP_TABLE ?
@@ -5082,8 +5080,7 @@ create_table_option:
           ENGINE_SYM opt_equal storage_engines
           {
             Lex->create_info.db_type= $3;
-            if ($3)
-              Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
+            Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
           }
         | MAX_ROWS opt_equal ulonglong_num
           {
@@ -6883,6 +6880,11 @@ alter_list_item:
           {
             LEX *lex=Lex;
             lex->alter_info.flags|= ALTER_OPTIONS;
+            if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) &&
+                !lex->create_info.db_type)
+            {
+              lex->create_info.used_fields&= ~HA_CREATE_USED_ENGINE;
+            }
           }
         | FORCE_SYM
           {

=== modified file 'storage/innobase/btr/btr0btr.c'
--- a/storage/innobase/btr/btr0btr.c	2011-06-16 13:15:48 +0000
+++ b/storage/innobase/btr/btr0btr.c	2011-08-15 09:34:39 +0000
@@ -691,7 +691,8 @@ btr_root_block_get(
 	zip_size = dict_table_zip_size(index->table);
 	root_page_no = dict_index_get_page(index);
 
-	block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr);
+	block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH,
+			      index, mtr);
 	ut_a((ibool)!!page_is_comp(buf_block_get_frame(block))
 	     == dict_table_is_comp(index->table));
 #ifdef UNIV_BTR_DEBUG
@@ -892,7 +893,7 @@ btr_page_alloc_for_ibuf(
 				 dict_table_zip_size(index->table),
 				 node_addr.page, RW_X_LATCH, mtr);
 	new_page = buf_block_get_frame(new_block);
-	buf_block_dbg_add_level(new_block, SYNC_TREE_NODE_NEW);
+	buf_block_dbg_add_level(new_block, SYNC_IBUF_TREE_NODE_NEW);
 
 	flst_remove(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
 		    new_page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE,
@@ -1140,7 +1141,7 @@ btr_node_ptr_get_child(
 	page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets);
 
 	return(btr_block_get(space, dict_table_zip_size(index->table),
-			     page_no, RW_X_LATCH, mtr));
+			     page_no, RW_X_LATCH, index, mtr));
 }
 
 /************************************************************//**
@@ -1313,7 +1314,8 @@ btr_create(
 			space, 0,
 			IBUF_HEADER + IBUF_TREE_SEG_HEADER, mtr);
 
-		buf_block_dbg_add_level(ibuf_hdr_block, SYNC_TREE_NODE_NEW);
+		buf_block_dbg_add_level(
+			ibuf_hdr_block, SYNC_IBUF_TREE_NODE_NEW);
 
 		ut_ad(buf_block_get_page_no(ibuf_hdr_block)
 		      == IBUF_HEADER_PAGE_NO);
@@ -1351,10 +1353,9 @@ btr_create(
 	page_no = buf_block_get_page_no(block);
 	frame = buf_block_get_frame(block);
 
-	buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
-
 	if (type & DICT_IBUF) {
 		/* It is an insert buffer tree: initialize the free list */
+		buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW);
 
 		ut_ad(page_no == IBUF_TREE_ROOT_PAGE_NO);
 
@@ -1362,6 +1363,8 @@ btr_create(
 	} else {
 		/* It is a non-ibuf tree: create a file segment for leaf
 		pages */
+		buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
+
 		if (!fseg_create(space, page_no,
 				 PAGE_HEADER + PAGE_BTR_SEG_LEAF, mtr)) {
 			/* Not enough space for new segment, free root
@@ -1433,7 +1436,8 @@ btr_free_but_not_root(
 leaf_loop:
 	mtr_start(&mtr);
 
-	root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, &mtr);
+	root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH,
+			    NULL, &mtr);
 #ifdef UNIV_BTR_DEBUG
 	ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
 				    + root, space));
@@ -1455,7 +1459,8 @@ leaf_loop:
 top_loop:
 	mtr_start(&mtr);
 
-	root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, &mtr);
+	root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH,
+			    NULL, &mtr);
 #ifdef UNIV_BTR_DEBUG
 	ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
 				    + root, space));
@@ -1481,13 +1486,13 @@ btr_free_root(
 	ulint	zip_size,	/*!< in: compressed page size in bytes
 				or 0 for uncompressed pages */
 	ulint	root_page_no,	/*!< in: root page number */
-	mtr_t*	mtr)		/*!< in: a mini-transaction which has already
-				been started */
+	mtr_t*	mtr)		/*!< in/out: mini-transaction */
 {
 	buf_block_t*	block;
 	fseg_header_t*	header;
 
-	block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr);
+	block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH,
+			      NULL, mtr);
 
 	btr_search_drop_page_hash_index(block);
 
@@ -2368,9 +2373,8 @@ btr_attach_half_pages(
 	/* Update page links of the level */
 
 	if (prev_page_no != FIL_NULL) {
-		buf_block_t*	prev_block = btr_block_get(space, zip_size,
-							   prev_page_no,
-							   RW_X_LATCH, mtr);
+		buf_block_t*	prev_block = btr_block_get(
+			space, zip_size, prev_page_no, RW_X_LATCH, index, mtr);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(page_is_comp(prev_block->frame) == page_is_comp(page));
 		ut_a(btr_page_get_next(prev_block->frame, mtr)
@@ -2383,9 +2387,8 @@ btr_attach_half_pages(
 	}
 
 	if (next_page_no != FIL_NULL) {
-		buf_block_t*	next_block = btr_block_get(space, zip_size,
-							   next_page_no,
-							   RW_X_LATCH, mtr);
+		buf_block_t*	next_block = btr_block_get(
+			space, zip_size, next_page_no, RW_X_LATCH, index, mtr);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(page_is_comp(next_block->frame) == page_is_comp(page));
 		ut_a(btr_page_get_prev(next_block->frame, mtr)
@@ -2808,17 +2811,42 @@ func_exit:
 	return(rec);
 }
 
+#ifdef UNIV_SYNC_DEBUG
+/*************************************************************//**
+Removes a page from the level list of pages.
+@param space	in: space where removed
+@param zip_size	in: compressed page size in bytes, or 0 for uncompressed
+@param page	in/out: page to remove
+@param index	in: index tree
+@param mtr	in/out: mini-transaction */
+# define btr_level_list_remove(space,zip_size,page,index,mtr)		\
+	btr_level_list_remove_func(space,zip_size,page,index,mtr)
+#else /* UNIV_SYNC_DEBUG */
+/*************************************************************//**
+Removes a page from the level list of pages.
+@param space	in: space where removed
+@param zip_size	in: compressed page size in bytes, or 0 for uncompressed
+@param page	in/out: page to remove
+@param index	in: index tree
+@param mtr	in/out: mini-transaction */
+# define btr_level_list_remove(space,zip_size,page,index,mtr)		\
+	btr_level_list_remove_func(space,zip_size,page,mtr)
+#endif /* UNIV_SYNC_DEBUG */
+
 /*************************************************************//**
 Removes a page from the level list of pages. */
-static
+static __attribute__((nonnull))
 void
-btr_level_list_remove(
-/*==================*/
-	ulint		space,	/*!< in: space where removed */
-	ulint		zip_size,/*!< in: compressed page size in bytes
-				or 0 for uncompressed pages */
-	page_t*		page,	/*!< in: page to remove */
-	mtr_t*		mtr)	/*!< in: mtr */
+btr_level_list_remove_func(
+/*=======================*/
+	ulint			space,	/*!< in: space where removed */
+	ulint			zip_size,/*!< in: compressed page size in bytes
+					or 0 for uncompressed pages */
+	page_t*			page,	/*!< in/out: page to remove */
+#ifdef UNIV_SYNC_DEBUG
+	const dict_index_t*	index,	/*!< in: index tree */
+#endif /* UNIV_SYNC_DEBUG */
+	mtr_t*			mtr)	/*!< in/out: mini-transaction */
 {
 	ulint	prev_page_no;
 	ulint	next_page_no;
@@ -2836,7 +2864,7 @@ btr_level_list_remove(
 	if (prev_page_no != FIL_NULL) {
 		buf_block_t*	prev_block
 			= btr_block_get(space, zip_size, prev_page_no,
-					RW_X_LATCH, mtr);
+					RW_X_LATCH, index, mtr);
 		page_t*		prev_page
 			= buf_block_get_frame(prev_block);
 #ifdef UNIV_BTR_DEBUG
@@ -2853,7 +2881,7 @@ btr_level_list_remove(
 	if (next_page_no != FIL_NULL) {
 		buf_block_t*	next_block
 			= btr_block_get(space, zip_size, next_page_no,
-					RW_X_LATCH, mtr);
+					RW_X_LATCH, index, mtr);
 		page_t*		next_page
 			= buf_block_get_frame(next_block);
 #ifdef UNIV_BTR_DEBUG
@@ -3179,7 +3207,7 @@ btr_compress(
 	if (is_left) {
 
 		merge_block = btr_block_get(space, zip_size, left_page_no,
-					    RW_X_LATCH, mtr);
+					    RW_X_LATCH, index, mtr);
 		merge_page = buf_block_get_frame(merge_block);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(btr_page_get_next(merge_page, mtr)
@@ -3188,7 +3216,7 @@ btr_compress(
 	} else if (right_page_no != FIL_NULL) {
 
 		merge_block = btr_block_get(space, zip_size, right_page_no,
-					    RW_X_LATCH, mtr);
+					    RW_X_LATCH, index, mtr);
 		merge_page = buf_block_get_frame(merge_block);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(btr_page_get_prev(merge_page, mtr)
@@ -3277,7 +3305,7 @@ err_exit:
 		btr_search_drop_page_hash_index(block);
 
 		/* Remove the page from the level list */
-		btr_level_list_remove(space, zip_size, page, mtr);
+		btr_level_list_remove(space, zip_size, page, index, mtr);
 
 		btr_node_ptr_delete(index, block, mtr);
 		lock_update_merge_left(merge_block, orig_pred, block);
@@ -3334,7 +3362,7 @@ err_exit:
 #endif /* UNIV_BTR_DEBUG */
 
 		/* Remove the page from the level list */
-		btr_level_list_remove(space, zip_size, page, mtr);
+		btr_level_list_remove(space, zip_size, page, index, mtr);
 
 		/* Replace the address of the old child node (= page) with the
 		address of the merge page to the right */
@@ -3526,7 +3554,7 @@ btr_discard_page(
 
 	if (left_page_no != FIL_NULL) {
 		merge_block = btr_block_get(space, zip_size, left_page_no,
-					    RW_X_LATCH, mtr);
+					    RW_X_LATCH, index, mtr);
 		merge_page = buf_block_get_frame(merge_block);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(btr_page_get_next(merge_page, mtr)
@@ -3534,7 +3562,7 @@ btr_discard_page(
 #endif /* UNIV_BTR_DEBUG */
 	} else if (right_page_no != FIL_NULL) {
 		merge_block = btr_block_get(space, zip_size, right_page_no,
-					    RW_X_LATCH, mtr);
+					    RW_X_LATCH, index, mtr);
 		merge_page = buf_block_get_frame(merge_block);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(btr_page_get_prev(merge_page, mtr)
@@ -3569,7 +3597,7 @@ btr_discard_page(
 	btr_node_ptr_delete(index, block, mtr);
 
 	/* Remove the page from the level list */
-	btr_level_list_remove(space, zip_size, page, mtr);
+	btr_level_list_remove(space, zip_size, page, index, mtr);
 #ifdef UNIV_ZIP_DEBUG
 	{
 		page_zip_des_t*	merge_page_zip
@@ -4087,7 +4115,7 @@ loop:
 	if (right_page_no != FIL_NULL) {
 		const rec_t*	right_rec;
 		right_block = btr_block_get(space, zip_size, right_page_no,
-					    RW_X_LATCH, &mtr);
+					    RW_X_LATCH, index, &mtr);
 		right_page = buf_block_get_frame(right_block);
 		if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr)
 				  != page_get_page_no(page))) {
@@ -4313,7 +4341,7 @@ node_ptr_fails:
 		mtr_start(&mtr);
 
 		block = btr_block_get(space, zip_size, right_page_no,
-				      RW_X_LATCH, &mtr);
+				      RW_X_LATCH, index, &mtr);
 		page = buf_block_get_frame(block);
 
 		goto loop;

=== modified file 'storage/innobase/btr/btr0cur.c'
--- a/storage/innobase/btr/btr0cur.c	2011-07-07 11:24:33 +0000
+++ b/storage/innobase/btr/btr0cur.c	2011-08-15 09:34:39 +0000
@@ -249,7 +249,8 @@ btr_cur_latch_leaves(
 	case BTR_SEARCH_LEAF:
 	case BTR_MODIFY_LEAF:
 		mode = latch_mode == BTR_SEARCH_LEAF ? RW_S_LATCH : RW_X_LATCH;
-		get_block = btr_block_get(space, zip_size, page_no, mode, mtr);
+		get_block = btr_block_get(
+			space, zip_size, page_no, mode, cursor->index, mtr);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
 #endif /* UNIV_BTR_DEBUG */
@@ -260,9 +261,9 @@ btr_cur_latch_leaves(
 		left_page_no = btr_page_get_prev(page, mtr);
 
 		if (left_page_no != FIL_NULL) {
-			get_block = btr_block_get(space, zip_size,
-						  left_page_no,
-						  RW_X_LATCH, mtr);
+			get_block = btr_block_get(
+				space, zip_size, left_page_no,
+				RW_X_LATCH, cursor->index, mtr);
 #ifdef UNIV_BTR_DEBUG
 			ut_a(page_is_comp(get_block->frame)
 			     == page_is_comp(page));
@@ -272,8 +273,9 @@ btr_cur_latch_leaves(
 			get_block->check_index_page_at_flush = TRUE;
 		}
 
-		get_block = btr_block_get(space, zip_size, page_no,
-					  RW_X_LATCH, mtr);
+		get_block = btr_block_get(
+			space, zip_size, page_no,
+			RW_X_LATCH, cursor->index, mtr);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
 #endif /* UNIV_BTR_DEBUG */
@@ -282,9 +284,9 @@ btr_cur_latch_leaves(
 		right_page_no = btr_page_get_next(page, mtr);
 
 		if (right_page_no != FIL_NULL) {
-			get_block = btr_block_get(space, zip_size,
-						  right_page_no,
-						  RW_X_LATCH, mtr);
+			get_block = btr_block_get(
+				space, zip_size, right_page_no,
+				RW_X_LATCH, cursor->index, mtr);
 #ifdef UNIV_BTR_DEBUG
 			ut_a(page_is_comp(get_block->frame)
 			     == page_is_comp(page));
@@ -303,8 +305,9 @@ btr_cur_latch_leaves(
 		left_page_no = btr_page_get_prev(page, mtr);
 
 		if (left_page_no != FIL_NULL) {
-			get_block = btr_block_get(space, zip_size,
-						  left_page_no, mode, mtr);
+			get_block = btr_block_get(
+				space, zip_size,
+				left_page_no, mode, cursor->index, mtr);
 			cursor->left_block = get_block;
 #ifdef UNIV_BTR_DEBUG
 			ut_a(page_is_comp(get_block->frame)
@@ -315,7 +318,8 @@ btr_cur_latch_leaves(
 			get_block->check_index_page_at_flush = TRUE;
 		}
 
-		get_block = btr_block_get(space, zip_size, page_no, mode, mtr);
+		get_block = btr_block_get(
+			space, zip_size, page_no, mode, cursor->index, mtr);
 #ifdef UNIV_BTR_DEBUG
 		ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
 #endif /* UNIV_BTR_DEBUG */
@@ -669,7 +673,9 @@ retry_page_get:
 		ut_a(!page_zip || page_zip_validate(page_zip, page));
 #endif /* UNIV_ZIP_DEBUG */
 
-		buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+		buf_block_dbg_add_level(
+			block, dict_index_is_ibuf(index)
+			? SYNC_IBUF_TREE_NODE : SYNC_TREE_NODE);
 	}
 
 	ut_ad(index->id == btr_page_get_index_id(page));
@@ -767,7 +773,7 @@ retry_page_get:
 	if (level != 0) {
 		/* x-latch the page */
 		page = btr_page_get(
-			space, zip_size, page_no, RW_X_LATCH, mtr);
+			space, zip_size, page_no, RW_X_LATCH, index, mtr);
 
 		ut_a((ibool)!!page_is_comp(page)
 		     == dict_table_is_comp(index->table));

=== modified file 'storage/innobase/btr/btr0pcur.c'
--- a/storage/innobase/btr/btr0pcur.c	2010-10-21 22:25:09 +0000
+++ b/storage/innobase/btr/btr0pcur.c	2011-08-15 09:34:39 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 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
@@ -266,8 +266,10 @@ btr_pcur_restore_position_func(
 					file, line, mtr))) {
 			cursor->pos_state = BTR_PCUR_IS_POSITIONED;
 
-			buf_block_dbg_add_level(btr_pcur_get_block(cursor),
-						SYNC_TREE_NODE);
+			buf_block_dbg_add_level(
+				btr_pcur_get_block(cursor),
+				dict_index_is_ibuf(index)
+				? SYNC_IBUF_TREE_NODE : SYNC_TREE_NODE);
 
 			if (cursor->rel_pos == BTR_PCUR_ON) {
 #ifdef UNIV_DEBUG
@@ -417,7 +419,8 @@ btr_pcur_move_to_next_page(
 	ut_ad(next_page_no != FIL_NULL);
 
 	next_block = btr_block_get(space, zip_size, next_page_no,
-				   cursor->latch_mode, mtr);
+				   cursor->latch_mode,
+				   btr_pcur_get_btr_cur(cursor)->index, mtr);
 	next_page = buf_block_get_frame(next_block);
 #ifdef UNIV_BTR_DEBUG
 	ut_a(page_is_comp(next_page) == page_is_comp(page));

=== modified file 'storage/innobase/btr/btr0sea.c'
--- a/storage/innobase/btr/btr0sea.c	2011-08-10 06:26:39 +0000
+++ b/storage/innobase/btr/btr0sea.c	2011-08-15 09:34:39 +0000
@@ -852,6 +852,7 @@ btr_search_guess_on_hash(
 	btr_pcur_t	pcur;
 #endif
 	ut_ad(index && info && tuple && cursor && mtr);
+	ut_ad(!dict_index_is_ibuf(index));
 	ut_ad((latch_mode == BTR_SEARCH_LEAF)
 	      || (latch_mode == BTR_MODIFY_LEAF));
 

=== modified file 'storage/innobase/dict/dict0crea.c'
--- a/storage/innobase/dict/dict0crea.c	2011-07-19 00:25:20 +0000
+++ b/storage/innobase/dict/dict0crea.c	2011-08-15 09:34:39 +0000
@@ -845,7 +845,7 @@ dict_truncate_index_tree(
 	appropriate field in the SYS_INDEXES record: this mini-transaction
 	marks the B-tree totally truncated */
 
-	btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr);
+	btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, NULL, mtr);
 
 	btr_free_root(space, zip_size, root_page_no, mtr);
 create:

=== modified file 'storage/innobase/dict/dict0dict.c'
--- a/storage/innobase/dict/dict0dict.c	2011-05-31 09:30:59 +0000
+++ b/storage/innobase/dict/dict0dict.c	2011-08-15 09:34:39 +0000
@@ -2097,7 +2097,8 @@ undo_size_ok:
 
 	new_index->page = page_no;
 	rw_lock_create(index_tree_rw_lock_key, &new_index->lock,
-		       SYNC_INDEX_TREE);
+		       dict_index_is_ibuf(index)
+		       ? SYNC_IBUF_INDEX_TREE : SYNC_INDEX_TREE);
 
 	if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) {
 

=== modified file 'storage/innobase/ibuf/ibuf0ibuf.c'
--- a/storage/innobase/ibuf/ibuf0ibuf.c	2011-08-10 06:26:39 +0000
+++ b/storage/innobase/ibuf/ibuf0ibuf.c	2011-08-15 09:34:39 +0000
@@ -396,7 +396,7 @@ ibuf_tree_root_get(
 	block = buf_page_get(
 		IBUF_SPACE_ID, 0, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, mtr);
 
-	buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+	buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW);
 
 	root = buf_block_get_frame(block);
 
@@ -544,7 +544,7 @@ ibuf_init_at_db_start(void)
 		block = buf_page_get(
 			IBUF_SPACE_ID, 0, FSP_IBUF_TREE_ROOT_PAGE_NO,
 			RW_X_LATCH, &mtr);
-		buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+		buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
 
 		root = buf_block_get_frame(block);
 	}
@@ -2222,7 +2222,8 @@ ibuf_add_free_page(void)
 	} else {
 		buf_block_t*	block = buf_page_get(
 			IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr);
-		buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
+
+		buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW);
 
 		page = buf_block_get_frame(block);
 	}
@@ -2345,8 +2346,7 @@ ibuf_remove_free_page(void)
 		block = buf_page_get(
 			IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr);
 
-		buf_block_dbg_add_level(block, SYNC_TREE_NODE);
-
+		buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
 
 		page = buf_block_get_frame(block);
 	}
@@ -3055,7 +3055,7 @@ ibuf_get_volume_buffered(
 			IBUF_SPACE_ID, 0, prev_page_no, RW_X_LATCH,
 			mtr);
 
-		buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+		buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
 
 
 		prev_page = buf_block_get_frame(block);
@@ -3128,7 +3128,7 @@ count_later:
 			IBUF_SPACE_ID, 0, next_page_no, RW_X_LATCH,
 			mtr);
 
-		buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+		buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
 
 
 		next_page = buf_block_get_frame(block);
@@ -3366,7 +3366,7 @@ ibuf_set_entry_counter(
 				IBUF_SPACE_ID, 0, prev_page_no,
 				RW_X_LATCH, mtr);
 
-			buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+			buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
 
 			prev_page = buf_block_get_frame(block);
 
@@ -4450,6 +4450,7 @@ ibuf_merge_or_delete_for_page(
 	ut_ad(!block || buf_block_get_space(block) == space);
 	ut_ad(!block || buf_block_get_page_no(block) == page_no);
 	ut_ad(!block || buf_block_get_zip_size(block) == zip_size);
+	ut_ad(!block || buf_block_get_io_fix(block) == BUF_IO_READ);
 
 	if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE
 	    || trx_sys_hdr_page(space, page_no)) {
@@ -4602,7 +4603,13 @@ loop:
 
 		ut_a(success);
 
-		buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+		/* This is a user page (secondary index leaf page),
+		but we pretend that it is a change buffer page in
+		order to obey the latching order. This should be OK,
+		because buffered changes are applied immediately while
+		the block is io-fixed. Other threads must not try to
+		latch an io-fixed block. */
+		buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
 	}
 
 	/* Position pcur in the insert buffer at the first entry for this
@@ -4706,7 +4713,12 @@ loop:
 					__FILE__, __LINE__, &mtr);
 				ut_a(success);
 
-				buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+				/* This is a user page (secondary
+				index leaf page), but it should be OK
+				to use too low latching order for it,
+				as the block is io-fixed. */
+				buf_block_dbg_add_level(
+					block, SYNC_IBUF_TREE_NODE);
 
 				if (!ibuf_restore_pos(space, page_no,
 						      search_tuple,

=== modified file 'storage/innobase/include/btr0btr.h'
--- a/storage/innobase/include/btr0btr.h	2011-06-16 09:26:09 +0000
+++ b/storage/innobase/include/btr0btr.h	2011-08-15 09:34:39 +0000
@@ -199,26 +199,45 @@ btr_block_get_func(
 	ulint		mode,		/*!< in: latch mode */
 	const char*	file,		/*!< in: file name */
 	ulint		line,		/*!< in: line where called */
-	mtr_t*		mtr)		/*!< in/out: mtr */
-	__attribute__((nonnull));
+# ifdef UNIV_SYNC_DEBUG
+	const dict_index_t*	index,	/*!< in: index tree, may be NULL
+					if it is not an insert buffer tree */
+# endif /* UNIV_SYNC_DEBUG */
+	mtr_t*		mtr);		/*!< in/out: mini-transaction */
+# ifdef UNIV_SYNC_DEBUG
 /** Gets a buffer page and declares its latching order level.
 @param space	tablespace identifier
 @param zip_size	compressed page size in bytes or 0 for uncompressed pages
 @param page_no	page number
 @param mode	latch mode
+@param index	index tree, may be NULL if not the insert buffer tree
 @param mtr	mini-transaction handle
 @return the block descriptor */
-# define btr_block_get(space,zip_size,page_no,mode,mtr) \
+#  define btr_block_get(space,zip_size,page_no,mode,index,mtr)	\
+	btr_block_get_func(space,zip_size,page_no,mode,		\
+			   __FILE__,__LINE__,index,mtr)
+# else /* UNIV_SYNC_DEBUG */
+/** Gets a buffer page and declares its latching order level.
+@param space	tablespace identifier
+@param zip_size	compressed page size in bytes or 0 for uncompressed pages
+@param page_no	page number
+@param mode	latch mode
+@param idx	index tree, may be NULL if not the insert buffer tree
+@param mtr	mini-transaction handle
+@return the block descriptor */
+#  define btr_block_get(space,zip_size,page_no,mode,idx,mtr)		\
 	btr_block_get_func(space,zip_size,page_no,mode,__FILE__,__LINE__,mtr)
+# endif /* UNIV_SYNC_DEBUG */
 /** Gets a buffer page and declares its latching order level.
 @param space	tablespace identifier
 @param zip_size	compressed page size in bytes or 0 for uncompressed pages
 @param page_no	page number
 @param mode	latch mode
+@param idx	index tree, may be NULL if not the insert buffer tree
 @param mtr	mini-transaction handle
 @return the uncompressed page frame */
-# define btr_page_get(space,zip_size,page_no,mode,mtr) \
-	buf_block_get_frame(btr_block_get(space,zip_size,page_no,mode,mtr))
+# define btr_page_get(space,zip_size,page_no,mode,idx,mtr)		\
+	buf_block_get_frame(btr_block_get(space,zip_size,page_no,mode,idx,mtr))
 #endif /* !UNIV_HOTBACKUP */
 /**************************************************************//**
 Gets the index id field of a page.
@@ -344,8 +363,7 @@ btr_free_root(
 	ulint	zip_size,	/*!< in: compressed page size in bytes
 				or 0 for uncompressed pages */
 	ulint	root_page_no,	/*!< in: root page number */
-	mtr_t*	mtr);		/*!< in: a mini-transaction which has already
-				been started */
+	mtr_t*	mtr);		/*!< in/out: mini-transaction */
 /*************************************************************//**
 Makes tree one level higher by splitting the root, and inserts
 the tuple. It is assumed that mtr contains an x-latch on the tree.

=== modified file 'storage/innobase/include/btr0btr.ic'
--- a/storage/innobase/include/btr0btr.ic	2010-11-03 09:27:51 +0000
+++ b/storage/innobase/include/btr0btr.ic	2011-08-15 09:34:39 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1994, 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
@@ -48,6 +48,10 @@ btr_block_get_func(
 	ulint		mode,		/*!< in: latch mode */
 	const char*	file,		/*!< in: file name */
 	ulint		line,		/*!< in: line where called */
+#ifdef UNIV_SYNC_DEBUG
+	const dict_index_t*	index,	/*!< in: index tree, may be NULL
+					if it is not an insert buffer tree */
+#endif /* UNIV_SYNC_DEBUG */
 	mtr_t*		mtr)		/*!< in/out: mtr */
 {
 	buf_block_t*	block;
@@ -57,7 +61,9 @@ btr_block_get_func(
 
 	if (mode != RW_NO_LATCH) {
 
-		buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+		buf_block_dbg_add_level(
+			block, index != NULL && dict_index_is_ibuf(index)
+			? SYNC_IBUF_TREE_NODE : SYNC_TREE_NODE);
 	}
 
 	return(block);

=== modified file 'storage/innobase/include/sync0sync.h'
--- a/storage/innobase/include/sync0sync.h	2011-07-26 03:21:33 +0000
+++ b/storage/innobase/include/sync0sync.h	2011-08-15 09:34:39 +0000
@@ -658,10 +658,6 @@ or row lock! */
 #define SYNC_DICT_HEADER	995
 #define SYNC_IBUF_HEADER	914
 #define SYNC_IBUF_PESS_INSERT_MUTEX 912
-#define SYNC_IBUF_MUTEX		910	/* ibuf mutex is really below
-					SYNC_FSP_PAGE: we assign a value this
-					high only to make the program to pass
-					the debug checks */
 /*-------------------------------*/
 #define	SYNC_INDEX_TREE		900
 #define SYNC_TREE_NODE_NEW	892
@@ -677,8 +673,11 @@ or row lock! */
 #define	SYNC_FSP		400
 #define	SYNC_FSP_PAGE		395
 /*------------------------------------- Insert buffer headers */
-/*------------------------------------- ibuf_mutex */
+#define SYNC_IBUF_MUTEX		370	/* ibuf_mutex */
 /*------------------------------------- Insert buffer tree */
+#define SYNC_IBUF_INDEX_TREE	360
+#define SYNC_IBUF_TREE_NODE_NEW	359
+#define SYNC_IBUF_TREE_NODE	358
 #define	SYNC_IBUF_BITMAP_MUTEX	351
 #define	SYNC_IBUF_BITMAP	350
 /*------------------------------------- MySQL query cache mutex */

=== modified file 'storage/innobase/read/read0read.c'
--- a/storage/innobase/read/read0read.c	2011-07-26 03:21:33 +0000
+++ b/storage/innobase/read/read0read.c	2011-08-11 20:23:10 +0000
@@ -519,7 +519,6 @@ read_view_remove(
 /*=============*/
 	read_view_t*	view)	/*!< in: read view */
 {
-	/* We acquire an S lock for the debug validate code. */
 	mutex_enter(&trx_sys->mutex);
 
 	ut_ad(read_view_validate(view));

=== modified file 'storage/innobase/row/row0sel.c'
--- a/storage/innobase/row/row0sel.c	2011-08-10 10:07:49 +0000
+++ b/storage/innobase/row/row0sel.c	2011-08-11 19:59:01 +0000
@@ -3360,16 +3360,16 @@ row_sel_prefetch_cache_init(
 }
 
 /********************************************************************//**
-Pushes a row for MySQL to the fetch cache. */
+Get the last fetch cache buffer from the queue.
+@return pointer to buffer. */
 UNIV_INLINE
-void
-row_sel_enqueue_cache_row_for_mysql(
-/*================================*/
-	byte*		mysql_rec,	/*!< in/out: MySQL record */
+byte*
+row_sel_fetch_last_buf(
+/*===================*/
 	row_prebuilt_t*	prebuilt)	/*!< in/out: prebuilt struct */
 {
-	ut_a(prebuilt->n_fetch_cached < MYSQL_FETCH_CACHE_SIZE);
-	ut_a(!prebuilt->templ_contains_blob);
+	ut_ad(!prebuilt->templ_contains_blob);
+	ut_ad(prebuilt->n_fetch_cached < MYSQL_FETCH_CACHE_SIZE);
 
 	if (prebuilt->fetch_cache[0] == NULL) {
 		/* Allocate memory for the fetch cache */
@@ -3382,8 +3382,26 @@ row_sel_enqueue_cache_row_for_mysql(
 	UNIV_MEM_INVALID(prebuilt->fetch_cache[prebuilt->n_fetch_cached],
 			 prebuilt->mysql_row_len);
 
-	memcpy(prebuilt->fetch_cache[prebuilt->n_fetch_cached],
-	       mysql_rec, prebuilt->mysql_row_len);
+	return(prebuilt->fetch_cache[prebuilt->n_fetch_cached]);
+}
+
+/********************************************************************//**
+Pushes a row for MySQL to the fetch cache. */
+UNIV_INLINE
+void
+row_sel_enqueue_cache_row_for_mysql(
+/*================================*/
+	byte*		mysql_rec,	/*!< in/out: MySQL record */
+	row_prebuilt_t*	prebuilt)	/*!< in/out: prebuilt struct */
+{
+	/* For non ICP code path the row should already exist in the
+	next fetch cache slot. */
+
+	if (prebuilt->idx_cond != NULL) {
+		byte*	dest = row_sel_fetch_last_buf(prebuilt);
+
+		ut_memcpy(dest, mysql_rec, prebuilt->mysql_row_len);
+	}
 
 	++prebuilt->n_fetch_cached;
 }
@@ -4730,7 +4748,8 @@ requires_clust_rec:
 
 		if (!prebuilt->idx_cond
 		    && !row_sel_store_mysql_rec(
-			    buf, prebuilt, result_rec,
+			    row_sel_fetch_last_buf(prebuilt),
+			    prebuilt, result_rec,
 			    result_rec != rec,
 			    result_rec != rec ? clust_index : index,
 			    offsets)) {

=== modified file 'storage/innobase/sync/sync0sync.c'
--- a/storage/innobase/sync/sync0sync.c	2011-07-26 03:21:33 +0000
+++ b/storage/innobase/sync/sync0sync.c	2011-08-15 09:34:39 +0000
@@ -1234,6 +1234,7 @@ sync_thread_add_level(
 	case SYNC_DICT_HEADER:
 	case SYNC_TRX_I_S_RWLOCK:
 	case SYNC_TRX_I_S_LAST_READ:
+	case SYNC_IBUF_MUTEX:
 		if (!sync_thread_levels_g(array, level, TRUE)) {
 			fprintf(stderr,
 				"InnoDB: sync_thread_levels_g(array, %lu)"
@@ -1333,22 +1334,28 @@ sync_thread_add_level(
 		     || sync_thread_levels_g(array, SYNC_TREE_NODE - 1, TRUE));
 		break;
 	case SYNC_TREE_NODE_NEW:
-		ut_a(sync_thread_levels_contain(array, SYNC_FSP_PAGE)
-		     || sync_thread_levels_contain(array, SYNC_IBUF_MUTEX));
+		ut_a(sync_thread_levels_contain(array, SYNC_FSP_PAGE));
 		break;
 	case SYNC_INDEX_TREE:
-		if (sync_thread_levels_contain(array, SYNC_IBUF_MUTEX)
-		    && sync_thread_levels_contain(array, SYNC_FSP)) {
-			ut_a(sync_thread_levels_g(array, SYNC_FSP_PAGE - 1,
-						  TRUE));
+		ut_a(sync_thread_levels_g(array, SYNC_TREE_NODE - 1, TRUE));
+		break;
+	case SYNC_IBUF_TREE_NODE:
+		ut_a(sync_thread_levels_contain(array, SYNC_IBUF_INDEX_TREE)
+		     || sync_thread_levels_g(array, SYNC_IBUF_TREE_NODE - 1,
+					     TRUE));
+		break;
+	case SYNC_IBUF_TREE_NODE_NEW:
+		ut_a(sync_thread_levels_contain(array, SYNC_IBUF_MUTEX));
+		break;
+	case SYNC_IBUF_INDEX_TREE:
+		if (sync_thread_levels_contain(array, SYNC_FSP)) {
+			ut_a(sync_thread_levels_g(
+				     array, SYNC_FSP_PAGE - 1, TRUE));
 		} else {
-			ut_a(sync_thread_levels_g(array, SYNC_TREE_NODE - 1,
-						  TRUE));
+			ut_a(sync_thread_levels_g(
+				     array, SYNC_IBUF_TREE_NODE - 1, TRUE));
 		}
 		break;
-	case SYNC_IBUF_MUTEX:
-		ut_a(sync_thread_levels_g(array, SYNC_FSP_PAGE - 1, TRUE));
-		break;
 	case SYNC_IBUF_PESS_INSERT_MUTEX:
 		ut_a(sync_thread_levels_g(array, SYNC_FSP - 1, TRUE));
 		ut_a(!sync_thread_levels_contain(array, SYNC_IBUF_MUTEX));

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2011-08-08 09:42:09 +0000
+++ b/support-files/mysql.spec.sh	2011-08-11 16:48:00 +0000
@@ -1000,6 +1000,7 @@ echo "====="
 %attr(755, root, root) %{_bindir}/mysql_setpermission
 %attr(755, root, root) %{_bindir}/mysql_tzinfo_to_sql
 %attr(755, root, root) %{_bindir}/mysql_upgrade
+%attr(755, root, root) %{_bindir}/mysql_plugin
 %attr(755, root, root) %{_bindir}/mysql_zap
 %attr(755, root, root) %{_bindir}/mysqlbug
 %attr(755, root, root) %{_bindir}/mysqld_multi
@@ -1017,6 +1018,7 @@ echo "====="
 %attr(755, root, root) %{_sbindir}/rcmysql
 %attr(755, root, root) %{_libdir}/mysql/plugin/adt_null.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/libdaemon_example.so
+%attr(755, root, root) %{_libdir}/mysql/plugin/daemon_example.ini
 %attr(755, root, root) %{_libdir}/mysql/plugin/mypluglib.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so
 %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so
@@ -1131,6 +1133,10 @@ echo "====="
 # merging BK trees)
 ##############################################################################
 %changelog
+* Mon Jul 25 2011 Chuck Bell <chuck.bell@stripped>
+
+- Added the mysql_plugin client - enables or disables plugins.
+
 * Thu Jul 21 2011 Sunanda Menon <sunanda.menon@stripped>
 
 - Fix bug#12561297: Added the MySQL embedded binary

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (chris.powers:3368 to 3369) WL#4896Christopher Powers16 Aug