List:Commits« Previous MessageNext Message »
From:magnus.blaudd Date:October 5 2011 9:01am
Subject:bzr push into mysql-5.5-cluster branch (magnus.blaudd:3569 to 3570)
View as plain text  
 3570 magnus.blaudd@stripped	2011-10-05 [merge]
      Merge 5.5.16 into 5.5-cluster

    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/rpl/r/rpl_row_corruption.result
      mysql-test/suite/rpl/t/rpl_row_corruption-slave.opt
      mysql-test/suite/rpl/t/rpl_row_corruption.test
      mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result
      mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result
      mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result
      mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result
      mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test
      mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test
      mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test
      mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test
      mysql-test/t/mysql_plugin-master.opt
      mysql-test/t/mysql_plugin.test
      plugin/daemon_example/daemon_example.ini
    modified:
      VERSION
      client/CMakeLists.txt
      client/mysql.cc
      client/mysql_upgrade.c
      client/mysqladmin.cc
      client/mysqlcheck.c
      client/mysqldump.c
      client/mysqlimport.c
      client/mysqlshow.c
      client/mysqltest.cc
      cmake/plugin.cmake
      config.h.cmake
      configure.cmake
      dbug/dbug_analyze.c
      dbug/my_main.c
      dbug/tests.c
      include/my_global.h
      include/mysql/plugin.h
      include/mysql/plugin_audit.h.pp
      include/mysql/plugin_auth.h.pp
      include/mysql/plugin_ftparser.h.pp
      libmysql/authentication_win/common.cc
      libmysql/authentication_win/common.h
      libmysql/authentication_win/handshake_client.cc
      libmysql/authentication_win/log_client.cc
      libmysqld/examples/CMakeLists.txt
      mysql-test/collections/default.experimental
      mysql-test/extra/rpl_tests/rpl_reset_slave.test
      mysql-test/include/plugin.defs
      mysql-test/lib/mtr_cases.pm
      mysql-test/mysql-test-run.pl
      mysql-test/r/ctype_errors.result
      mysql-test/r/ctype_utf32_uca.result
      mysql-test/r/func_math.result
      mysql-test/r/func_time.result
      mysql-test/r/information_schema.result
      mysql-test/r/merge.result
      mysql-test/r/order_by.result
      mysql-test/r/plugin_auth.result
      mysql-test/r/sp-error.result
      mysql-test/r/sp.result
      mysql-test/r/type_float.result
      mysql-test/r/union.result
      mysql-test/suite/innodb/r/innodb-zip.result
      mysql-test/suite/innodb/t/innodb-zip.test
      mysql-test/suite/rpl/r/rpl_row_reset_slave.result
      mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
      mysql-test/suite/sys_vars/r/all_vars.result
      mysql-test/suite/sys_vars/r/innodb_file_format_check_basic.result
      mysql-test/suite/sys_vars/t/innodb_file_format_check_basic.test
      mysql-test/t/ctype_errors.test
      mysql-test/t/ctype_utf32_uca.test
      mysql-test/t/disabled.def
      mysql-test/t/func_math.test
      mysql-test/t/func_time.test
      mysql-test/t/implicit_commit.test
      mysql-test/t/information_schema.test
      mysql-test/t/merge.test
      mysql-test/t/order_by.test
      mysql-test/t/plugin_auth.test
      mysql-test/t/sp-error.test
      mysql-test/t/sp.test
      mysql-test/t/type_float.test
      mysql-test/t/union.test
      mysys/my_init.c
      plugin/audit_null/audit_null.c
      plugin/auth/auth_socket.c
      plugin/auth/dialog.c
      plugin/auth/qa_auth_interface.c
      plugin/auth/qa_auth_server.c
      plugin/auth/test_plugin.c
      plugin/daemon_example/CMakeLists.txt
      plugin/daemon_example/daemon_example.cc
      plugin/fulltext/plugin_example.c
      plugin/semisync/semisync_master_plugin.cc
      plugin/semisync/semisync_slave_plugin.cc
      sql/CMakeLists.txt
      sql/gen_lex_hash.cc
      sql/ha_partition.cc
      sql/item_func.cc
      sql/item_strfunc.cc
      sql/item_timefunc.cc
      sql/log.cc
      sql/log_event.cc
      sql/mysqld.cc
      sql/protocol.cc
      sql/rpl_mi.cc
      sql/rpl_mi.h
      sql/share/errmsg-utf8.txt
      sql/sql_acl.cc
      sql/sql_base.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_error.cc
      sql/sql_insert.cc
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_plugin.cc
      sql/sql_prepare.cc
      sql/sql_profile.cc
      sql/sql_repl.cc
      sql/sql_select.cc
      sql/sql_show.cc
      sql/sql_union.cc
      sql/sql_yacc.yy
      storage/archive/ha_archive.cc
      storage/blackhole/ha_blackhole.cc
      storage/csv/ha_tina.cc
      storage/example/ha_example.cc
      storage/federated/ha_federated.cc
      storage/heap/ha_heap.cc
      storage/innobase/btr/btr0pcur.c
      storage/innobase/buf/buf0buf.c
      storage/innobase/buf/buf0rea.c
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/i_s.cc
      storage/innobase/include/btr0pcur.h
      storage/innobase/include/btr0pcur.ic
      storage/innobase/include/buf0buf.h
      storage/innobase/include/buf0buf.ic
      storage/innobase/include/buf0lru.h
      storage/innobase/include/buf0rea.h
      storage/innobase/include/mtr0mtr.h
      storage/innobase/include/srv0srv.h
      storage/innobase/include/ut0mem.h
      storage/innobase/include/ut0mem.ic
      storage/innobase/mtr/mtr0mtr.c
      storage/innobase/row/row0sel.c
      storage/innobase/srv/srv0srv.c
      storage/innobase/ut/ut0mem.c
      storage/myisam/ha_myisam.cc
      storage/myisammrg/ha_myisammrg.cc
      storage/myisammrg/myrg_open.c
      storage/perfschema/ha_perfschema.cc
      strings/ctype-uca.c
      strings/decimal.c
      support-files/compiler_warnings.supp
      support-files/mysql.spec.sh
      tests/mysql_client_test.c
 3569 magnus.blaudd@stripped	2011-10-05 [merge]
      Merge

    modified:
      sql/ha_ndbcluster_glue.h
=== modified file 'VERSION'
--- a/VERSION	2011-09-22 17:08:54 +0000
+++ b/VERSION	2011-10-05 08:56:12 +0000
@@ -1,4 +1,4 @@
 MYSQL_VERSION_MAJOR=5
 MYSQL_VERSION_MINOR=5
-MYSQL_VERSION_PATCH=15
+MYSQL_VERSION_PATCH=16
 MYSQL_VERSION_EXTRA=-ndb-7.2.2

=== modified file 'client/CMakeLists.txt'
--- a/client/CMakeLists.txt	2011-08-31 10:39:08 +0000
+++ b/client/CMakeLists.txt	2011-10-05 08:56:12 +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)

=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2011-08-31 10:39:08 +0000
+++ b/client/mysql.cc	2011-10-05 08:56:12 +0000
@@ -1178,7 +1178,7 @@ int main(int argc,char *argv[])
 	  mysql_thread_id(&mysql), server_version_string(&mysql));
   put_info((char*) glob_buffer.ptr(),INFO_INFO);
 
-  put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"), INFO_INFO);
+  put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"), INFO_INFO);
 
 #ifdef HAVE_READLINE
   initialize_readline((char*) my_progname);
@@ -1601,7 +1601,7 @@ static void usage(int version)
 
   if (version)
     return;
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   printf("Usage: %s [OPTIONS] [database]\n", my_progname);
   my_print_help(my_long_options);
   print_defaults("my", load_default_groups);

=== added file 'client/mysql_plugin.c'
--- a/client/mysql_plugin.c	1970-01-01 00:00:00 +0000
+++ b/client/mysql_plugin.c	2011-09-09 14:39:44 +0000
@@ -0,0 +1,1202 @@
+/*
+   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;
+
+  bzero(tool_path, 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)
+    {
+      char buff[FN_REFLEN];
+      
+      strncpy(buff, opt_basedir, sizeof(buff) - 1);
+#ifdef __WIN__
+      strncat(buff, "/", sizeof(buff) - strlen(buff) - 1);
+#else
+      strncat(buff, FN_DIRSEP, sizeof(buff) - strlen(buff) - 1);
+#endif
+      buff[sizeof(buff) - 1]= 0;
+      my_delete(opt_basedir, MYF(0));
+      opt_basedir= my_strdup(buff, MYF(MY_FAE));
+    }
+  }
+  
+  /*
+    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;
+  const char *verbose_str= NULL;
+   
+  
+  if (opt_verbose)
+    verbose_str= "--console";
+  else
+    verbose_str= "";
+  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 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2011-08-31 10:39:08 +0000
+++ b/client/mysql_upgrade.c	2011-10-05 08:56:12 +0000
@@ -242,6 +242,7 @@ get_one_option(int optid, const struct m
   switch (optid) {
 
   case '?':
+    puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
     printf("%s  Ver %s Distrib %s, for %s (%s)\n",
            my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
     puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));

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

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

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2011-08-31 10:39:08 +0000
+++ b/client/mysqldump.c	2011-10-05 08:56:12 +0000
@@ -55,6 +55,8 @@
 
 #include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
 
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
 /* Exit codes */
 
 #define EX_USAGE 1
@@ -611,7 +613,7 @@ static void short_usage_sub(void)
 static void usage(void)
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   puts("Dumping structure and contents of MySQL databases and tables.");
   short_usage_sub();
   print_defaults("my",load_default_groups);

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

=== modified file 'client/mysqlshow.c'
--- a/client/mysqlshow.c	2011-08-31 10:39:08 +0000
+++ b/client/mysqlshow.c	2011-10-05 08:56:12 +0000
@@ -275,7 +275,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010)"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011)"));
   puts("Shows the structure of a MySQL database (databases, tables, and columns).\n");
   printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname);
   puts("\n\

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2011-08-31 10:39:08 +0000
+++ b/client/mysqltest.cc	2011-10-05 08:56:12 +0000
@@ -22,13 +22,6 @@
   http://dev.mysql.com/doc/mysqltest/en/index.html
 
   Please keep the test framework tools identical in all versions!
-
-  Written by:
-  Sasha Pachev <sasha@stripped>
-  Matt Wagner  <matt@stripped>
-  Monty
-  Jani
-  Holyfoot
 */
 
 #define MTEST_VERSION "3.3"
@@ -6398,7 +6391,7 @@ void print_version(void)
 void usage()
 {
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   printf("Runs a test against the mysql server and compares output with a results file.\n\n");
   printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname);
   my_print_help(my_long_options);

=== modified file 'cmake/plugin.cmake'
--- a/cmake/plugin.cmake	2011-06-10 12:57:42 +0000
+++ b/cmake/plugin.cmake	2011-08-15 10:10:08 +0000
@@ -196,6 +196,10 @@ MACRO(MYSQL_ADD_PLUGIN)
     # Install dynamic library
     MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT Server)
     INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug)
+    # Add installed files to list for RPMs
+    FILE(APPEND ${CMAKE_BINARY_DIR}/support-files/plugins.files
+            "%attr(755, root, root) %{_prefix}/${INSTALL_PLUGINDIR}/${ARG_MODULE_OUTPUT_NAME}.so\n"
+            "%attr(755, root, root) %{_prefix}/${INSTALL_PLUGINDIR}/debug/${ARG_MODULE_OUTPUT_NAME}.so\n")
     # For internal testing in PB2, append collections files
     IF(DEFINED ENV{PB2WORKDIR})
       PLUGIN_APPEND_COLLECTIONS(${plugin})

=== modified file 'config.h.cmake'
--- a/config.h.cmake	2011-09-22 00:51:13 +0000
+++ b/config.h.cmake	2011-10-05 08:56:12 +0000
@@ -219,7 +219,6 @@
 #cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
 #cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
 #cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1
-#cmakedefine HAVE_PTHREAD_INIT 1
 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1
 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1
 #cmakedefine HAVE_PTHREAD_KILL 1

=== modified file 'configure.cmake'
--- a/configure.cmake	2011-08-31 10:39:08 +0000
+++ b/configure.cmake	2011-10-05 08:56:12 +0000
@@ -393,7 +393,6 @@ CHECK_FUNCTION_EXISTS (pthread_attr_sets
 CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
 CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
 CHECK_FUNCTION_EXISTS (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK)
-CHECK_FUNCTION_EXISTS (pthread_init HAVE_PTHREAD_INIT)
 CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE)
 CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK)
 CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK)

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

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

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

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2011-08-31 10:39:08 +0000
+++ b/include/my_global.h	2011-10-05 08:56:12 +0000
@@ -603,6 +603,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 */
@@ -611,6 +613,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
 

=== modified file 'include/mysql/plugin.h'
--- a/include/mysql/plugin.h	2011-08-31 10:39:08 +0000
+++ b/include/mysql/plugin.h	2011-10-05 08:56:12 +0000
@@ -71,7 +71,7 @@ typedef struct st_mysql_xid MYSQL_XID;
   Plugin API. Common for all plugin types.
 */
 
-#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0102
+#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103
 
 /*
   The allowable types of plugins
@@ -120,7 +120,7 @@ __MYSQL_DECLARE_PLUGIN(NAME, \
                  builtin_ ## NAME ## _sizeof_struct_st_plugin, \
                  builtin_ ## NAME ## _plugin)
 
-#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0}}
+#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}}
 
 /*
   declarations for SHOW STATUS support in plugins
@@ -144,6 +144,14 @@ typedef int (*mysql_show_var_func)(MYSQL
 
 
 /*
+  Constants for plugin flags.
+ */
+
+#define PLUGIN_OPT_NO_INSTALL   1UL   /* Not dynamically loadable */
+#define PLUGIN_OPT_NO_UNINSTALL 2UL   /* Not dynamically unloadable */
+
+
+/*
   declarations for server variables and command line options
 */
 
@@ -415,6 +423,7 @@ struct st_mysql_plugin
   struct st_mysql_show_var *status_vars;
   struct st_mysql_sys_var **system_vars;
   void * __reserved1;   /* reserved for dependency checking             */
+  unsigned long flags;  /* flags for plugin */
 };
 
 /*************************************************************************

=== modified file 'include/mysql/plugin_audit.h.pp'
--- a/include/mysql/plugin_audit.h.pp	2011-06-03 07:27:11 +0000
+++ b/include/mysql/plugin_audit.h.pp	2011-08-15 18:12:11 +0000
@@ -101,6 +101,7 @@ struct st_mysql_plugin
   struct st_mysql_show_var *status_vars;
   struct st_mysql_sys_var **system_vars;
   void * __reserved1;
+  unsigned long flags;
 };
 #include "plugin_ftparser.h"
 #include "plugin.h"

=== modified file 'include/mysql/plugin_auth.h.pp'
--- a/include/mysql/plugin_auth.h.pp	2011-03-04 12:12:31 +0000
+++ b/include/mysql/plugin_auth.h.pp	2011-08-15 18:12:11 +0000
@@ -101,6 +101,7 @@ struct st_mysql_plugin
   struct st_mysql_show_var *status_vars;
   struct st_mysql_sys_var **system_vars;
   void * __reserved1;
+  unsigned long flags;
 };
 #include "plugin_ftparser.h"
 #include "plugin.h"

=== modified file 'include/mysql/plugin_ftparser.h.pp'
--- a/include/mysql/plugin_ftparser.h.pp	2011-03-04 12:12:31 +0000
+++ b/include/mysql/plugin_ftparser.h.pp	2011-08-15 18:12:11 +0000
@@ -43,7 +43,7 @@ typedef enum _thd_wait_type_e {
   THD_WAIT_BINLOG= 8,
   THD_WAIT_GROUP_COMMIT= 9,
   THD_WAIT_SYNC= 10,
-  THD_WAIT_LAST= 11 
+  THD_WAIT_LAST= 11
 } thd_wait_type;
 extern struct thd_wait_service_st {
   void (*thd_wait_begin_func)(void*, int);
@@ -101,6 +101,7 @@ struct st_mysql_plugin
   struct st_mysql_show_var *status_vars;
   struct st_mysql_sys_var **system_vars;
   void * __reserved1;
+  unsigned long flags;
 };
 #include "plugin_ftparser.h"
 struct st_mysql_daemon

=== modified file 'libmysql/authentication_win/common.cc'
--- a/libmysql/authentication_win/common.cc	2011-04-28 19:17:29 +0000
+++ b/libmysql/authentication_win/common.cc	2011-09-07 18:02:35 +0000
@@ -22,6 +22,24 @@ template <> void error_log_print<error_l
 template <> void error_log_print<error_log_level::WARNING>(const char *fmt, ...);
 template <> void error_log_print<error_log_level::ERROR>(const char *fmt, ...);
 
+/**
+  Option indicating desired level of logging. Values:
+
+  0 - no logging
+  1 - log only error messages
+  2 - additionally log warnings
+  3 - additionally log info notes
+  4 - also log debug messages
+
+  Value of this option should be taken into account in the 
+  implementation of  error_log_vprint() function (see 
+  log_client.cc).
+
+  Note: No error or debug messages are logged in production code
+  (see logging macros in common.h).
+*/
+int opt_auth_win_log_level= 2;
+
 
 /** Connection class **************************************************/
 

=== modified file 'libmysql/authentication_win/common.h'
--- a/libmysql/authentication_win/common.h	2011-04-28 19:39:42 +0000
+++ b/libmysql/authentication_win/common.h	2011-09-07 18:02:35 +0000
@@ -41,13 +41,15 @@ struct error_log_level
   typedef enum {INFO, WARNING, ERROR}  type;
 };
 
+extern "C" int opt_auth_win_log_level;
+unsigned int  get_log_level(void);
+void          set_log_level(unsigned int);
+
 
 /*
   If DEBUG_ERROR_LOG is defined then error logging happens only
   in debug-copiled code. Otherwise ERROR_LOG() expands to 
-  error_log_print() even in production code. Note that in client
-  plugin, error_log_print() will print nothing if opt_auth_win_clinet_log
-  is 0.
+  error_log_print() even in production code.
 
   Note: Macro ERROR_LOG() can use printf-like format string like this:
 
@@ -57,8 +59,6 @@ struct error_log_level
   to fprintf() (see error_log_vprint() function).
 */
 
-extern "C" int opt_auth_win_client_log;
-
 #if defined(DEBUG_ERROR_LOG) && defined(DBUG_OFF)
 #define ERROR_LOG(Level, Msg)     do {} while (0)
 #else
@@ -67,7 +67,7 @@ extern "C" int opt_auth_win_client_log;
 
 
 void error_log_vprint(error_log_level::type level,
-                        const char *fmt, va_list args);
+                      const char *fmt, va_list args);
 
 template <error_log_level::type Level>
 void error_log_print(const char *fmt, ...)
@@ -96,7 +96,7 @@ const char* get_last_error_message(Error
 
 #define DBUG_PRINT_DO(Keyword, Msg) \
   do { \
-    if (2 > opt_auth_win_client_log) break; \
+    if (4 > get_log_level()) break; \
     fprintf(stderr, "winauth: %s: ", Keyword); \
     debug_msg Msg; \
   } while (0)

=== modified file 'libmysql/authentication_win/handshake_client.cc'
--- a/libmysql/authentication_win/handshake_client.cc	2011-04-28 19:39:42 +0000
+++ b/libmysql/authentication_win/handshake_client.cc	2011-09-07 18:02:35 +0000
@@ -323,13 +323,13 @@ int win_auth_handshake_client(MYSQL_PLUG
     int opt_val= opt ? atoi(opt) : 0;
     if (opt && !opt_val)
     {
-      if (!strncasecmp("on", opt, 2))    opt_val= 1;
-      if (!strncasecmp("yes", opt, 3))   opt_val= 1;
-      if (!strncasecmp("true", opt, 4))  opt_val= 1;
-      if (!strncasecmp("debug", opt, 5)) opt_val= 2;
-      if (!strncasecmp("dbug", opt, 4))  opt_val= 2;
+      if (!strncasecmp("on", opt, 2))    opt_val= 2;
+      if (!strncasecmp("yes", opt, 3))   opt_val= 2;
+      if (!strncasecmp("true", opt, 4))  opt_val= 2;
+      if (!strncasecmp("debug", opt, 5)) opt_val= 4;
+      if (!strncasecmp("dbug", opt, 4))  opt_val= 4;
     }
-    opt_auth_win_client_log= opt_val;
+    set_log_level(opt_val);
   }
 
   ERROR_LOG(INFO, ("Authentication handshake for account %s", mysql->user));

=== modified file 'libmysql/authentication_win/log_client.cc'
--- a/libmysql/authentication_win/log_client.cc	2011-04-28 19:17:29 +0000
+++ b/libmysql/authentication_win/log_client.cc	2011-09-07 18:02:35 +0000
@@ -16,36 +16,32 @@
 #include <my_global.h>
 #include "common.h"
 
-/**
-  This option is set in win_auth_handshake_client() function 
-  in handshake_client.cc.
-
-  Values:
-  0 - no logging
-  1 - log error/warning/info messages
-  2 - also log debug messages
-
-  Note: No error or debug messages are logged in production code
-  (see logging macros in common.h).
-*/
-int opt_auth_win_client_log= 0;
-
 
 // Client-side logging function
 
 void error_log_vprint(error_log_level::type level,
                         const char *fmt, va_list args)
 {
-  if (0 == opt_auth_win_client_log)
-    return;
-
   const char *level_string= "";
+  int   log_level= get_log_level();
 
   switch (level)
   {
-  case error_log_level::INFO:    level_string= "Note"; break;
-  case error_log_level::WARNING: level_string= "Warning"; break;
-  case error_log_level::ERROR:   level_string= "ERROR"; break;
+  case error_log_level::INFO:    
+    if (3 > log_level)
+      return;
+    level_string= "Note"; 
+    break;
+  case error_log_level::WARNING: 
+    if (2 > log_level)
+      return;
+    level_string= "Warning"; 
+    break;
+  case error_log_level::ERROR:   
+    if (1 > log_level)
+      return;
+    level_string= "ERROR";
+    break;
   }
 
   fprintf(stderr, "Windows Authentication Plugin %s: ", level_string);
@@ -53,3 +49,17 @@ void error_log_vprint(error_log_level::t
   fputc('\n', stderr);
   fflush(stderr);
 }
+
+
+// Trivial implementation of log-level setting storage.
+
+void set_log_level(unsigned int level)
+{
+  opt_auth_win_log_level= level;
+}
+
+
+unsigned int  get_log_level(void)
+{
+  return opt_auth_win_log_level;
+}

=== modified file 'libmysqld/examples/CMakeLists.txt'
--- a/libmysqld/examples/CMakeLists.txt	2011-08-31 10:39:08 +0000
+++ b/libmysqld/examples/CMakeLists.txt	2011-10-05 08:56:12 +0000
@@ -23,9 +23,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/
 ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT)
 
 
-# We never use "mysql_embedded", is more of a linktest, so we don't
-# use MYSQL_ADD_EXECUTABLE as that would install it and package it
-ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
+MYSQL_ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
                ../../client/mysql.cc ../../client/readline.cc)
 TARGET_LINK_LIBRARIES(mysql_embedded mysqlserver)
 IF(UNIX)

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2011-10-02 17:10:27 +0000
+++ b/mysql-test/collections/default.experimental	2011-10-05 08:56:12 +0000
@@ -8,16 +8,15 @@ funcs_1.charset_collation_1             
 main.func_math @freebsd                  # Bug#11751977 2010-05-04 alik main.func_math fails on FreeBSD in PB2
 main.lock_multi_bug38499                 # Bug#11755645 2009-09-19 alik main.lock_multi_bug38499 times out sporadically
 main.outfile_loaddata @solaris           # Bug#11755168 2010-01-20 alik Test "outfile_loaddata" fails (reproducible)
-main.signal_demo3 @solaris               # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
-main.sp @solaris                         # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
+main.signal_demo3 @solaris               # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
+main.sp @solaris                         # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 main.wait_timeout @solaris               # Bug#11758972 2010-04-26 alik wait_timeout fails on OpenSolaris
 
-rpl.rpl_innodb_bug28430                  # Bug#11754425
-rpl.rpl_bug37426                         # WL#5867: skozlov: test case moved from unused bugs suite
 rpl.rpl_heartbeat_basic                  # BUG#12403008 2011-04-27 sven fails sporadically
-rpl.rpl_show_slave_hosts                 # BUG#12416700 2011-05-02 sven fails sporadically
+rpl.rpl_innodb_bug28430                  # Bug#11754425
+rpl.rpl_row_sp011  @solaris              # Bug#11753919 2011-07-25 sven Several test cases fail on Solaris with error Thread stack overrun
 
-sys_vars.max_sp_recursion_depth_func @solaris # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
+sys_vars.max_sp_recursion_depth_func @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 sys_vars.wait_timeout_func                    # Bug#11750645 2010-04-26 alik wait_timeout_func fails
 
 sys_vars.rpl_init_slave_func		 # Bug#12535301 2011-05-09 andrei sys_vars.rpl_init_slave_func mismatches in daily-5.5

=== modified file 'mysql-test/extra/rpl_tests/rpl_reset_slave.test'
--- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test	2010-12-19 17:15:12 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test	2011-07-18 17:18:03 +0000
@@ -77,5 +77,31 @@ reset slave;
 source include/check_slave_no_error.inc;
 change master to master_user='root';
 
---let $rpl_only_running_threads= 1
+
+#
+# BUG#11809016 - NO WAY TO DISCOVER AN INSTANCE IS NO LONGER A SLAVE FOLLOWING MYSQL BUG#28796
+#
+
+reset slave;
+--source include/start_slave.inc
+
+--source include/stop_slave.inc
+--let $_slave_master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1)
+--let $_slave_master_user= query_get_value(SHOW SLAVE STATUS, Master_User, 1)
+--let $_slave_master_port= query_get_value(SHOW SLAVE STATUS, Master_Port, 1)
+
+reset slave all;
+--error ER_BAD_SLAVE
+start slave;
+
+--let $_show_master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1)
+if ($_show_master_host != No such row)
+{
+  die;
+}
+
+--replace_result $_slave_master_host MASTER_HOST $_slave_master_user MASTER_USER $_slave_master_port MASTER_PORT
+--eval CHANGE MASTER TO MASTER_HOST= '$_slave_master_host', MASTER_USER= '$_slave_master_user', MASTER_PORT= $_slave_master_port
+--source include/start_slave.inc
+
 --source include/rpl_end.inc

=== 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-08-15 14:29:38 +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-08-15 14:29:38 +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/plugin.defs'
--- a/mysql-test/include/plugin.defs	2011-05-30 13:55:44 +0000
+++ b/mysql-test/include/plugin.defs	2011-08-15 14:29:38 +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/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm	2011-08-29 13:37:39 +0000
+++ b/mysql-test/lib/mtr_cases.pm	2011-10-05 08:56:12 +0000
@@ -111,6 +111,9 @@ sub collect_test_cases ($$$$) {
   my $opt_skip_test_list= shift;
   my $cases= []; # Array of hash(one hash for each testcase)
 
+  # Unit tests off by default also if using --do-test or --start-from
+  $::opt_ctest= 0 if $::opt_ctest == -1 && ($do_test || $start_from);
+
   $do_test_reg= init_pattern($do_test, "--do-test");
   $skip_test_reg= init_pattern($skip_test, "--skip-test");
 

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2011-09-30 05:24:01 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-10-05 08:56:12 +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;
@@ -197,7 +198,7 @@ our $opt_debug_server;
 our @opt_cases;                  # The test cases names in argv
 our $opt_embedded_server;
 # -1 indicates use default, override with env.var.
-my $opt_ctest= env_or_val(MTR_UNIT_TESTS => -1);
+our $opt_ctest= env_or_val(MTR_UNIT_TESTS => -1);
 # Unit test report stored here for delayed printing
 my $ctest_report;
 
@@ -451,8 +452,9 @@ sub main {
   #
   read_plugin_defs("include/plugin.defs");
 
-  # Also read from any plugin local plugin.defs
-  for (glob "$basedir/plugin/*/tests/mtr/plugin.defs") {
+  # Also read from any plugin local or suite specific plugin.defs
+  for (glob "$basedir/plugin/*/tests/mtr/plugin.defs".
+            " suite/*/plugin.defs") {
     read_plugin_defs($_);
   }
 
@@ -1953,6 +1955,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");
 
@@ -2133,8 +2136,10 @@ sub find_plugin($$)
   my $lib_plugin=
     mtr_file_exists(vs_config_dirs($location,$plugin_filename),
                     "$basedir/lib/plugin/".$plugin_filename,
+                    "$basedir/lib64/plugin/".$plugin_filename,
                     "$basedir/$location/.libs/".$plugin_filename,
                     "$basedir/lib/mysql/plugin/".$plugin_filename,
+                    "$basedir/lib64/mysql/plugin/".$plugin_filename,
                     );
   return $lib_plugin;
 }
@@ -2390,6 +2395,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/ctype_errors.result'
--- a/mysql-test/r/ctype_errors.result	2009-10-15 12:23:43 +0000
+++ b/mysql-test/r/ctype_errors.result	2011-07-15 11:05:30 +0000
@@ -29,4 +29,14 @@ SET lc_messages=cs_CZ;
 SET NAMES UTF8;
 USE nonexistant;
 ERROR 42000: Nezn-Bámá databáze 'nonexistant'
-End of 5.4 tests
+#
+# Bug#12736295: Buffer overflow for variable converted_err
+#               with non-latin1 server error message
+#
+# Connection con1
+SET lc_messages=ru_RU;
+SET NAMES latin1;
+SELECT '01234567890123456789012345678901234\';
+ERROR 42000: \0423 \0432\0430\0441 \043E\0448\0438\0431\043A\0430 \0432 \0437\0430\043F\0440\043E\0441\0435. \0418\0437\0443\0447\0438\0442\0435 \0434\043E\043A\0443\043C\0435\043D\0442\0430\0446\0438\044E \043F\043E \0438\0441\043F\043E\043B\044C\0437\0443\0435\043C\043E\0439 \0432\0435\0440\0441\0438\0438 MySQL \043D\0430 \043F\0440\0435\0434\043C\0435\0442 \043A\043E\0440\0440\0435\043A\0442\043D\043E\0433\043E \0441\0438\043D\0442\0430\043A\0441\0438\0441\0430 \043E\043A\043E\043B\043E ''012345678901234567890123456
+# Connection default
+End of 5.5 tests

=== modified file 'mysql-test/r/ctype_utf32_uca.result'
--- a/mysql-test/r/ctype_utf32_uca.result	2010-11-26 10:44:39 +0000
+++ b/mysql-test/r/ctype_utf32_uca.result	2011-07-22 12:54:47 +0000
@@ -2415,5 +2415,25 @@ HEX(s1)
 00000061
 DROP TABLE t1;
 #
+# Bug #12319710 : INVALID MEMORY READ AND/OR CRASH IN 
+#   MY_UCA_CHARCMP WITH UTF32
+#
+SET collation_connection=utf32_unicode_ci;
+CREATE TABLE t1 (a TEXT CHARACTER SET utf32 COLLATE utf32_turkish_ci NOT NULL);
+INSERT INTO t1 VALUES ('a'), ('b');
+CREATE TABLE t2 (b VARBINARY(5) NOT NULL);
+#insert chars outside of BMP
+INSERT INTO t2 VALUEs (0x082837),(0x082837);
+#test for read-out-of-bounds with non-BMP chars as a LIKE pattern
+SELECT * FROM t1,t2 WHERE a LIKE b;
+a	b
+#test the original statement
+SELECT 1 FROM t1 AS t1_0 NATURAL LEFT OUTER JOIN t2 AS t2_0
+RIGHT JOIN t1 AS t1_1 ON t1_0.a LIKE t2_0.b;
+1
+1
+1
+DROP TABLE t1,t2;
+#
 # End of 5.5 tests
 #

=== modified file 'mysql-test/r/func_math.result'
--- a/mysql-test/r/func_math.result	2011-05-26 10:09:25 +0000
+++ b/mysql-test/r/func_math.result	2011-07-18 09:21:14 +0000
@@ -699,3 +699,32 @@ select (1.175494351E-37 div 1.7976931348
 0
 Warnings:
 Warning	1292	Truncated incorrect DECIMAL value: ''
+#
+# Bug#12537160 ASSERTION FAILED:
+# STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER.
+#
+select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.1 as foo;
+foo
+0.0
+select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.0 as foo;
+foo
+NULL
+#
+# Bug#12711164 - 61676:
+# RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE 
+#
+select 5 div 2;
+5 div 2
+2
+select 5.0 div 2.0;
+5.0 div 2.0
+2
+select 5.0 div 2;
+5.0 div 2
+2
+select 5 div 2.0;
+5 div 2.0
+2
+select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2;
+5.9 div 2	1.23456789e3 DIV 2	1.23456789e9 DIV 2	1.23456789e19 DIV 2
+2	617	617283945	6172839450000000000

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2011-05-18 06:59:04 +0000
+++ b/mysql-test/r/func_time.result	2011-07-27 08:51:55 +0000
@@ -1398,6 +1398,12 @@ NULL
 SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
 WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1)
 NULL
+#
+# Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0,
+#
+DO WEEK((DATE_ADD((CAST(0 AS DATE)), INTERVAL 1 YEAR_MONTH)), 5);
+Warnings:
+Warning	1292	Incorrect datetime value: '0'
 End of 5.1 tests
 #
 # Bug#57039: constant subtime expression returns incorrect result.

=== modified file 'mysql-test/r/information_schema.result'
--- a/mysql-test/r/information_schema.result	2011-04-14 15:40:04 +0000
+++ b/mysql-test/r/information_schema.result	2011-10-05 08:56:12 +0000
@@ -1849,5 +1849,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/merge.result'
--- a/mysql-test/r/merge.result	2010-11-30 17:53:11 +0000
+++ b/mysql-test/r/merge.result	2011-07-22 12:31:10 +0000
@@ -904,7 +904,8 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table 'test.t1' doesn't exist
+test.tm1	check	Error	Table 'test.t1' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 CREATE TABLE t1(a INT);
@@ -912,7 +913,7 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Error	Table 'test.t2' doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 CREATE TABLE t2(a BLOB);
@@ -920,7 +921,7 @@ SELECT * FROM tm1;
 ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 CHECK TABLE tm1;
 Table	Op	Msg_type	Msg_text
-test.tm1	check	Warning	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.tm1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.tm1	check	error	Corrupt
 ALTER TABLE t2 MODIFY a INT;
@@ -3634,7 +3635,7 @@ test.t1	analyze	Error	Unable to open und
 test.t1	analyze	error	Corrupt
 CHECK TABLE t1;
 Table	Op	Msg_type	Msg_text
-test.t1	check	Error	Table 'test.t_not_exists' doesn't exist
+test.t1	check	Error	Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist
 test.t1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.t1	check	error	Corrupt
 CHECKSUM TABLE t1;
@@ -3650,7 +3651,7 @@ test.t1	optimize	Error	Unable to open un
 test.t1	optimize	error	Corrupt
 REPAIR TABLE t1;
 Table	Op	Msg_type	Msg_text
-test.t1	repair	Error	Table 'test.t_not_exists' doesn't exist
+test.t1	repair	Error	Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist
 test.t1	repair	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 test.t1	repair	error	Corrupt
 REPAIR TABLE t1 USE_FRM;
@@ -3676,4 +3677,37 @@ ALTER TABLE t1 engine=myisam;
 ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
 UNLOCK TABLES;
 DROP TABLE m1, t1;
-End of 6.0 tests
+#
+# Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL
+#                           PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1"
+#
+drop tables if exists t1, t2, t3, t4, m1;
+create table t1(id int) engine=myisam;
+create view t3 as select 1 as id;
+create table t4(id int) engine=memory;
+create table m1(id int) engine=merge union=(t1,t2,t3,t4);
+select * from m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+# The below CHECK and REPAIR TABLE statements should
+# report all problems with underlying tables: 
+# - absence of 't2',
+# - missing base table for 't3',
+# - wrong engine of 't4'.
+check table m1;
+Table	Op	Msg_type	Msg_text
+test.m1	check	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+test.m1	check	error	Corrupt
+repair table m1;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	Error	Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	Error	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+test.m1	repair	error	Corrupt
+# Clean-up.
+drop tables m1, t1, t4;
+drop view t3;
+End of 5.5 tests

=== 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-15 14:29:38 +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/order_by.result'
--- a/mysql-test/r/order_by.result	2011-03-30 12:55:53 +0000
+++ b/mysql-test/r/order_by.result	2011-07-11 09:27:52 +0000
@@ -1665,6 +1665,13 @@ a	1
 3	1
 2	1
 DROP TABLE t1;
+#
+# Bug#11765255 58201:
+# VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS
+#
+select 1 order by max(1) + min(1);
+1
+1
 End of 5.1 tests
 #
 # Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY

=== modified file 'mysql-test/r/plugin_auth.result'
--- a/mysql-test/r/plugin_auth.result	2011-07-05 23:13:50 +0000
+++ b/mysql-test/r/plugin_auth.result	2011-08-12 12:55:04 +0000
@@ -44,7 +44,7 @@ ERROR 28000: Access denied for user 'plu
 ## test correct default plugin
 select USER(),CURRENT_USER();
 USER()	CURRENT_USER()
-plug@localhost	plug@%
+plug@localhost	plug_dest@%
 ## test no_auto_create_user sql mode with plugin users
 SET @@sql_mode=no_auto_create_user;
 GRANT INSERT ON TEST.* TO grant_user IDENTIFIED WITH 'test_plugin_server';
@@ -462,4 +462,24 @@ CREATE USER bug12610784@localhost;
 SET PASSWORD FOR bug12610784@localhost = PASSWORD('secret');
 ERROR 28000: Access denied for user 'bug12610784'@'localhost' (using password: NO)
 DROP USER bug12610784@localhost;
+#
+# Bug #12818542: PAM: ADDING PASSWORD FOR AN ACCOUNT DISABLES PAM 
+#   AUTHENTICATION SETTINGS
+#
+CREATE USER bug12818542@localhost 
+IDENTIFIED WITH 'test_plugin_server' AS 'bug12818542_dest';
+CREATE USER bug12818542_dest@localhost 
+IDENTIFIED BY 'bug12818542_dest_passwd';
+GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost;
+SELECT USER(),CURRENT_USER();
+USER()	CURRENT_USER()
+bug12818542@localhost	bug12818542_dest@localhost
+SET PASSWORD = PASSWORD('bruhaha');
+Warnings:
+Note	1699	SET PASSWORD has no significance for users authenticating via plugins
+SELECT USER(),CURRENT_USER();
+USER()	CURRENT_USER()
+bug12818542@localhost	bug12818542_dest@localhost
+DROP USER bug12818542@localhost;
+DROP USER bug12818542_dest@localhost;
 End of 5.5 tests

=== modified file 'mysql-test/r/sp-error.result'
--- a/mysql-test/r/sp-error.result	2010-10-26 11:48:08 +0000
+++ b/mysql-test/r/sp-error.result	2011-06-16 10:54:16 +0000
@@ -1717,6 +1717,22 @@ ERROR HY000: View 'test.v1' references i
 DROP PROCEDURE p1;
 DROP VIEW v1;
 DROP TABLE t1;
+#
+# Bug#12428824 - PARSER STACK OVERFLOW AND CRASH IN SP_ADD_USED_ROUTINE
+#                WITH OBSCURE QUERY
+#
+SELECT very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999();
+ERROR 42000: Identifier name 'very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long
+CALL very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999();
+ERROR 42000: Identifier name 'very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long
+SELECT very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_func();
+ERROR 42000: Incorrect database name 'very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222'
+CALL very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_proc();
+ERROR 42000: Incorrect database name 'very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222'
+SELECT db_name.very_long_fn_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999();
+ERROR 42000: Identifier name 'very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long
+CALL db_name.very_long_pr_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999();
+ERROR 42000: Identifier name 'very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long
 End of 5.1 tests
 #
 # Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP

=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2011-08-29 13:37:39 +0000
+++ b/mysql-test/r/sp.result	2011-10-05 08:56:12 +0000
@@ -7161,6 +7161,40 @@ init_connect
 SET @@GLOBAL.init_connect= @old_init_connect;
 DROP PROCEDURE p2;
 DROP PROCEDURE p5;
+#
+# Bug#11840395 (formerly known as bug#60347):
+# The string "versiondata" seems
+# to be 'leaking' into the schema name space
+#
+DROP DATABASE IF EXISTS mixedCaseDbName;
+CREATE DATABASE mixedCaseDbName;
+CREATE PROCEDURE mixedCaseDbName.tryMyProc() begin end|
+CREATE FUNCTION mixedCaseDbName.tryMyFunc() returns text begin return 'IT WORKS'; end
+|
+call mixedCaseDbName.tryMyProc();
+select mixedCaseDbName.tryMyFunc();
+mixedCaseDbName.tryMyFunc()
+IT WORKS
+DROP DATABASE mixedCaseDbName;
+#
+# Bug#11766594  59736: SELECT DISTINCT.. INCORRECT RESULT WITH DETERMINISTIC FUNCTION IN WHERE C
+#
+CREATE TABLE t1 (a INT, b INT, KEY(b));
+CREATE TABLE t2 (c INT, d INT, KEY(c));
+INSERT INTO t1 VALUES (1,1),(1,1),(1,2);
+INSERT INTO t2 VALUES (1,1),(1,2);
+CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
+BEGIN
+DECLARE a int;
+-- SQL statement inside
+SELECT 1 INTO a;
+RETURN a;
+END $
+SELECT COUNT(DISTINCT d) FROM t1, t2  WHERE a = c AND b = f1();
+COUNT(DISTINCT d)
+2
+DROP FUNCTION f1;
+DROP TABLE t1, t2;
 # ------------------------------------------------------------------
 # -- End of 5.1 tests
 # ------------------------------------------------------------------

=== modified file 'mysql-test/r/type_float.result'
--- a/mysql-test/r/type_float.result	2010-04-11 06:52:42 +0000
+++ b/mysql-test/r/type_float.result	2011-07-18 08:27:05 +0000
@@ -431,4 +431,19 @@ SELECT f1 FROM t1;
 f1
 -1.79769313486231e308
 DROP TABLE t1;
+#
+# Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REAL
+# 
+# Ignoring output from misc. float operations
+select format(-1.7976931348623157E+307,256) as foo;
+select least(-1.1111111111111111111111111,
+- group_concat(1.7976931348623157E+308)) as foo;
+select concat((truncate((-1.7976931348623157E+307),(0x1e))),
+(99999999999999999999999999999999999999999999999999999999999999999)) into @a;
 End of 5.0 tests
+#
+# Bug#12368853 FORMAT() CRASHES WITH LARGE NUMBERS AFTER TRUNCATE...
+#
+select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;
+foo
+0

=== modified file 'mysql-test/r/union.result'
--- a/mysql-test/r/union.result	2011-01-10 12:43:12 +0000
+++ b/mysql-test/r/union.result	2011-07-11 09:27:52 +0000
@@ -1643,6 +1643,63 @@ b
 1
 2
 DROP TABLE t1,t2;
+#
+# Bug#11765255 58201:
+# VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS
+#
+select 1 as foo
+union
+select 2
+union
+select 3
+union
+select 4
+order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
+;
+foo
+1
+prepare stmt1 from 'select 1 as foo
+union
+select 2
+union
+select 3
+union
+select 4
+order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
+';
+execute stmt1;
+foo
+1
+execute stmt1;
+foo
+1
+select 1 as foo
+union
+select 2
+union
+select 3
+union
+(select 4)
+order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
+;
+foo
+1
+prepare stmt1 from 'select 1 as foo
+union
+select 2
+union
+select 3
+union
+(select 4)
+order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
+';
+execute stmt1;
+foo
+1
+execute stmt1;
+foo
+1
+deallocate prepare stmt1;
 End of 5.1 tests
 #
 # Bug#57986 ORDER BY clause is not used after a UNION, 

=== modified file 'mysql-test/suite/innodb/r/innodb-zip.result'
--- a/mysql-test/suite/innodb/r/innodb-zip.result	2010-11-02 23:19:29 +0000
+++ b/mysql-test/suite/innodb/r/innodb-zip.result	2011-08-08 09:16:15 +0000
@@ -63,42 +63,42 @@ row_format=compressed;
 create table t14(a int primary key) engine=innodb key_block_size=9;
 Warnings:
 Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=9.
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t0	Compact
-test	t00	Compact
-test	t1	Compact
-test	t10	Dynamic
-test	t11	Compressed
-test	t12	Compressed
-test	t13	Compressed
-test	t14	Compact
-test	t2	Redundant
-test	t3	Compact
-test	t4	Compact
-test	t5	Redundant
-test	t6	Redundant
-test	t7	Redundant
-test	t8	Compact
-test	t9	Compact
+table_schema	table_name	row_format	data_length	index_length
+test	t0	Compact	16384	0
+test	t00	Compact	16384	0
+test	t1	Compact	16384	0
+test	t10	Dynamic	16384	0
+test	t11	Compressed	1024	0
+test	t12	Compressed	1024	0
+test	t13	Compressed	8192	0
+test	t14	Compact	16384	0
+test	t2	Redundant	16384	0
+test	t3	Compact	16384	0
+test	t4	Compact	16384	0
+test	t5	Redundant	16384	0
+test	t6	Redundant	16384	0
+test	t7	Redundant	16384	0
+test	t8	Compact	16384	0
+test	t9	Compact	16384	0
 drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
 alter table t1 key_block_size=0;
 alter table t1 row_format=dynamic;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t1	Dynamic
+table_schema	table_name	row_format	data_length	index_length
+test	t1	Dynamic	16384	0
 alter table t1 row_format=compact;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t1	Compact
+table_schema	table_name	row_format	data_length	index_length
+test	t1	Compact	16384	0
 alter table t1 row_format=redundant;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t1	Redundant
+table_schema	table_name	row_format	data_length	index_length
+test	t1	Redundant	16384	0
 drop table t1;
 create table t1(a int not null, b text, index(b(10))) engine=innodb
 key_block_size=1;
@@ -115,11 +115,11 @@ rollback;
 select a,left(b,40) from t1 natural join t2;
 a	left(b,40)
 1	1abcdefghijklmnopqrstuvwxyzAAAAAAAAAAAAA
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t1	Compressed
-test	t2	Compact
+table_schema	table_name	row_format	data_length	index_length
+test	t1	Compressed	2048	1024
+test	t2	Compact	16384	0
 drop table t1,t2;
 SET SESSION innodb_strict_mode = off;
 CREATE TABLE t1(
@@ -207,19 +207,19 @@ create table t8 (id int primary key) eng
 create table t9 (id int primary key) engine = innodb row_format = dynamic;
 create table t10(id int primary key) engine = innodb row_format = compact;
 create table t11(id int primary key) engine = innodb row_format = redundant;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t1	Compact
-test	t10	Compact
-test	t11	Redundant
-test	t3	Compressed
-test	t4	Compressed
-test	t5	Compressed
-test	t6	Compressed
-test	t7	Compressed
-test	t8	Compressed
-test	t9	Dynamic
+table_schema	table_name	row_format	data_length	index_length
+test	t1	Compact	16384	0
+test	t10	Compact	16384	0
+test	t11	Redundant	16384	0
+test	t3	Compressed	1024	0
+test	t4	Compressed	2048	0
+test	t5	Compressed	4096	0
+test	t6	Compressed	8192	0
+test	t7	Compressed	16384	0
+test	t8	Compressed	8192	0
+test	t9	Dynamic	16384	0
 drop table t1, t3, t4, t5, t6, t7, t8, t9, t10, t11;
 create table t1 (id int primary key) engine = innodb
 key_block_size = 8 row_format = compressed;
@@ -246,11 +246,11 @@ Warning	1478	InnoDB: cannot specify ROW_
 Error	1005	Can't create table 'test.t4' (errno: 1478)
 create table t5 (id int primary key) engine = innodb
 key_block_size = 8 row_format = default;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t1	Compressed
-test	t5	Compressed
+table_schema	table_name	row_format	data_length	index_length
+test	t1	Compressed	8192	0
+test	t5	Compressed	8192	0
 drop table t1, t5;
 create table t1 (id int primary key) engine = innodb
 key_block_size = 9 row_format = redundant;
@@ -276,9 +276,9 @@ Level	Code	Message
 Warning	1478	InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
 Warning	1478	InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
 Error	1005	Can't create table 'test.t2' (errno: 1478)
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
+table_schema	table_name	row_format	data_length	index_length
 set global innodb_file_per_table = off;
 create table t1 (id int primary key) engine = innodb key_block_size = 1;
 ERROR HY000: Can't create table 'test.t1' (errno: 1478)
@@ -324,11 +324,11 @@ Warning	1478	InnoDB: ROW_FORMAT=DYNAMIC 
 Error	1005	Can't create table 'test.t7' (errno: 1478)
 create table t8 (id int primary key) engine = innodb row_format = compact;
 create table t9 (id int primary key) engine = innodb row_format = redundant;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t8	Compact
-test	t9	Redundant
+table_schema	table_name	row_format	data_length	index_length
+test	t8	Compact	16384	0
+test	t9	Redundant	16384	0
 drop table t8, t9;
 set global innodb_file_per_table = on;
 set global innodb_file_format = `0`;
@@ -376,11 +376,11 @@ Warning	1478	InnoDB: ROW_FORMAT=DYNAMIC 
 Error	1005	Can't create table 'test.t7' (errno: 1478)
 create table t8 (id int primary key) engine = innodb row_format = compact;
 create table t9 (id int primary key) engine = innodb row_format = redundant;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
-table_schema	table_name	row_format
-test	t8	Compact
-test	t9	Redundant
+table_schema	table_name	row_format	data_length	index_length
+test	t8	Compact	16384	0
+test	t9	Redundant	16384	0
 drop table t8, t9;
 set global innodb_file_per_table=0;
 set global innodb_file_format=Antelope;

=== modified file 'mysql-test/suite/innodb/t/innodb-zip.test'
--- a/mysql-test/suite/innodb/t/innodb-zip.test	2010-11-02 23:19:29 +0000
+++ b/mysql-test/suite/innodb/t/innodb-zip.test	2011-08-08 09:16:15 +0000
@@ -39,19 +39,19 @@ create table t13(a int primary key) engi
 row_format=compressed;
 create table t14(a int primary key) engine=innodb key_block_size=9;
 
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 
 drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
 alter table t1 key_block_size=0;
 alter table t1 row_format=dynamic;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 alter table t1 row_format=compact;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 alter table t1 row_format=redundant;
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 drop table t1;
 
@@ -84,7 +84,7 @@ connection default;
 disconnect a;
 disconnect b;
 
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 drop table t1,t2;
 
@@ -195,7 +195,7 @@ create table t9 (id int primary key) eng
 create table t10(id int primary key) engine = innodb row_format = compact;
 create table t11(id int primary key) engine = innodb row_format = redundant;
 
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 drop table t1, t3, t4, t5, t6, t7, t8, t9, t10, t11;
 
@@ -221,7 +221,7 @@ show warnings;
 create table t5 (id int primary key) engine = innodb
 key_block_size = 8 row_format = default;
 
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 drop table t1, t5;
 
@@ -241,7 +241,7 @@ create table t2 (id int primary key) eng
 key_block_size = 9 row_format = dynamic;
 show warnings;
 
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 
 #test valid values with innodb_file_per_table unset
@@ -271,7 +271,7 @@ show warnings;
 create table t8 (id int primary key) engine = innodb row_format = compact;
 create table t9 (id int primary key) engine = innodb row_format = redundant;
 
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 drop table t8, t9;
 
@@ -303,7 +303,7 @@ show warnings;
 create table t8 (id int primary key) engine = innodb row_format = compact;
 create table t9 (id int primary key) engine = innodb row_format = redundant;
 
-SELECT table_schema, table_name, row_format
+SELECT table_schema, table_name, row_format, data_length, index_length
 FROM information_schema.tables WHERE engine='innodb';
 drop table t8, t9;
 

=== added file 'mysql-test/suite/rpl/r/rpl_row_corruption.result'
--- a/mysql-test/suite/rpl/r/rpl_row_corruption.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_corruption.result	2011-07-14 11:15:24 +0000
@@ -0,0 +1,49 @@
+include/master-slave.inc
+[connection master]
+CREATE TABLE t1_11753004 (c1 INT);
+CREATE TABLE t2_11753004 (c1 INT);
+INSERT INTO t1_11753004 VALUES (1);
+INSERT INTO t2_11753004 VALUES (2);
+call mtr.add_suppression(".*Found table map event mapping table id 0 which was already mapped but with different settings.*");
+include/stop_slave.inc
+SET @save_debug= @@global.debug;
+SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table";
+include/start_slave.inc
+UPDATE t1_11753004, t2_11753004 SET t1_11753004.c1=3, t2_11753004.c1=4 WHERE t1_11753004.c1=1 OR t2_11753004.c1=2;
+include/wait_for_slave_sql_error.inc [errno=1593 ]
+include/stop_slave.inc
+SET GLOBAL debug="-d,inject_tblmap_same_id_maps_diff_table";
+include/start_slave.inc
+include/rpl_reset.inc
+DROP TABLE t1_11753004, t2_11753004;
+include/stop_slave.inc
+SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table";
+include/start_slave.inc
+include/rpl_reset.inc
+CREATE TABLE t1_11753004 (c1 INT);
+CREATE TABLE t2_11753004_ign (c1 INT);
+INSERT INTO t1_11753004 VALUES (1);
+INSERT INTO t2_11753004_ign VALUES (2);
+UPDATE t1_11753004, t2_11753004_ign SET t1_11753004.c1=3, t2_11753004_ign.c1=4 WHERE t1_11753004.c1=1 OR t2_11753004_ign.c1=2;
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+BINLOG '
+SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=
+'/*!*/;
+SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table";
+BINLOG '
+SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+SOgWThMBAAAAKQAAAC8DAAAAAEMAAAAAAAEABHRlc3QAAnQyAAEDAAE=
+SOgWThgBAAAAKAAAAFcDAAAAAEIAAAAAAAAAAf///gEAAAD+AwAAAA==
+SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA==
+'/*!*/;
+ERROR HY000: Fatal error: Found table map event mapping table id 0 which was already mapped but with different settings.
+DROP TABLE t1,t2;
+SET GLOBAL debug="-d,inject_tblmap_same_id_maps_diff_table";
+DROP TABLE t1_11753004;
+DROP TABLE t2_11753004_ign;
+SET GLOBAL debug= @save_debug;
+include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_row_reset_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result	2011-04-14 15:40:04 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result	2011-10-05 08:56:12 +0000
@@ -41,4 +41,12 @@ include/stop_slave_sql.inc
 reset slave;
 include/check_slave_no_error.inc
 change master to master_user='root';
+reset slave;
+include/start_slave.inc
+include/stop_slave.inc
+reset slave all;
+start slave;
+ERROR HY000: The server is not configured as slave; fix in config file or with CHANGE MASTER TO
+CHANGE MASTER TO MASTER_HOST= 'MASTER_HOST', MASTER_USER= 'MASTER_USER', MASTER_PORT= MASTER_PORT;
+include/start_slave.inc
 include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_reset_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result	2011-04-14 15:40:04 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result	2011-10-05 08:56:12 +0000
@@ -41,4 +41,12 @@ include/stop_slave_sql.inc
 reset slave;
 include/check_slave_no_error.inc
 change master to master_user='root';
+reset slave;
+include/start_slave.inc
+include/stop_slave.inc
+reset slave all;
+start slave;
+ERROR HY000: The server is not configured as slave; fix in config file or with CHANGE MASTER TO
+CHANGE MASTER TO MASTER_HOST= 'MASTER_HOST', MASTER_USER= 'MASTER_USER', MASTER_PORT= MASTER_PORT;
+include/start_slave.inc
 include/rpl_end.inc

=== added file 'mysql-test/suite/rpl/t/rpl_row_corruption-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_corruption-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_corruption-slave.opt	2011-07-14 11:15:24 +0000
@@ -0,0 +1 @@
+--replicate-ignore-table=test.t2_11753004_ign

=== added file 'mysql-test/suite/rpl/t/rpl_row_corruption.test'
--- a/mysql-test/suite/rpl/t/rpl_row_corruption.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_corruption.test	2011-07-14 11:15:24 +0000
@@ -0,0 +1,115 @@
+#
+--source include/master-slave.inc
+--source include/have_debug.inc
+--source include/have_binlog_format_row.inc
+
+# BUG#11753004: 44360: REPLICATION FAILED 
+
+## assert that we get an error when checking the
+## identifiers at the slave (instead of a crash or
+## different table being updated)
+
+--let $t1= t1_11753004
+--let $t2= t2_11753004
+--let $t2_ign= t2_11753004_ign
+
+## test #1: assert that we get an error raised when multiple
+##          tables in the same RBR statement are mapped with the
+##          same identifier
+
+--eval CREATE TABLE $t1 (c1 INT)
+--eval CREATE TABLE $t2 (c1 INT)
+--eval INSERT INTO $t1 VALUES (1)
+--eval INSERT INTO $t2 VALUES (2)
+
+--sync_slave_with_master
+call mtr.add_suppression(".*Found table map event mapping table id 0 which was already mapped but with different settings.*");
+
+# stop the slave and inject corruption
+--source include/stop_slave.inc
+SET @save_debug= @@global.debug;
+SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table";
+--source include/start_slave.inc
+--connection master
+# both tables get mapped to 0 (in a way, simulating scenario 
+# originated by BUG#56226)
+--eval UPDATE $t1, $t2 SET $t1.c1=3, $t2.c1=4 WHERE $t1.c1=1 OR $t2.c1=2
+--connection slave
+
+# wait for error 1593 (ER_SLAVE_FATAL_ERROR)
+--let $slave_sql_errno=1593 
+--source include/wait_for_slave_sql_error.inc
+--source include/stop_slave.inc
+
+# clean up
+SET GLOBAL debug="-d,inject_tblmap_same_id_maps_diff_table";
+--source include/start_slave.inc
+--connection master
+--source include/rpl_reset.inc
+--eval DROP TABLE $t1, $t2
+--sync_slave_with_master
+
+## test #2: assert that ignored tables that may have been mapped
+##          with the same identifier are skipped, thus no error
+##          is raised.
+
+--connection slave
+--source include/stop_slave.inc
+SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table";
+--source include/start_slave.inc
+--source include/rpl_reset.inc
+--connection master
+--eval CREATE TABLE $t1 (c1 INT)
+--eval CREATE TABLE $t2_ign (c1 INT)
+--eval INSERT INTO $t1 VALUES (1)
+--eval INSERT INTO $t2_ign VALUES (2)
+--eval UPDATE $t1, $t2_ign SET $t1.c1=3, $t2_ign.c1=4 WHERE $t1.c1=1 OR $t2_ign.c1=2
+
+# must not raise error as second table is filtered
+--sync_slave_with_master
+
+
+## test #3: check that BINLOG statements will also raise an
+##          error if containing table map events mapping different
+##          tables to same table identifier.
+
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+
+# FD event
+BINLOG '
+SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8=
+'/*!*/;
+
+#110708 12:21:44 server id 1  end_log_pos 774   Table_map: `test`.`t1` mapped to number 66
+# at 774
+#110708 12:21:44 server id 1  end_log_pos 815   Table_map: `test`.`t2` mapped to number 67
+# at 815
+#110708 12:21:44 server id 1  end_log_pos 855   Update_rows: table id 66
+# at 855
+#110708 12:21:44 server id 1  end_log_pos 895   Update_rows: table id 67 flags: STMT_END_F
+SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table";
+--error ER_SLAVE_FATAL_ERROR
+BINLOG '
+SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+SOgWThMBAAAAKQAAAC8DAAAAAEMAAAAAAAEABHRlc3QAAnQyAAEDAAE=
+SOgWThgBAAAAKAAAAFcDAAAAAEIAAAAAAAAAAf///gEAAAD+AwAAAA==
+SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA==
+'/*!*/;
+
+
+# clean up
+DROP TABLE t1,t2;
+--connection slave
+SET GLOBAL debug="-d,inject_tblmap_same_id_maps_diff_table";
+--connection master
+--eval DROP TABLE $t1
+--eval DROP TABLE $t2_ign
+--sync_slave_with_master
+SET GLOBAL debug= @save_debug;
+
+--source include/rpl_end.inc

=== modified file 'mysql-test/suite/sys_vars/r/all_vars.result'
--- a/mysql-test/suite/sys_vars/r/all_vars.result	2011-09-21 12:03:03 +0000
+++ b/mysql-test/suite/sys_vars/r/all_vars.result	2011-10-05 08:56:12 +0000
@@ -11,15 +11,9 @@ There should be *no* long test name list
 select variable_name as `There should be *no* variables listed below:` from t2
 left join t1 on variable_name=test_name where test_name is null;
 There should be *no* variables listed below:
-INNODB_ROLLBACK_SEGMENTS
 LOG_BIN_USE_V1_ROW_EVENTS
-INNODB_STATS_METHOD
-INNODB_FILE_FORMAT_MAX
 INNODB_LARGE_PREFIX
-INNODB_ROLLBACK_SEGMENTS
 LOG_BIN_USE_V1_ROW_EVENTS
-INNODB_STATS_METHOD
-INNODB_FILE_FORMAT_MAX
 INNODB_LARGE_PREFIX
 drop table t1;
 drop table t2;

=== modified file 'mysql-test/suite/sys_vars/r/innodb_file_format_check_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_file_format_check_basic.result	2010-06-17 09:13:53 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_file_format_check_basic.result	2011-08-15 14:29:38 +0000
@@ -1,59 +1,80 @@
-SET @start_global_value = @@global.innodb_file_format_max;
+SET @start_global_value = @@global.innodb_file_format_check;
 SELECT @start_global_value;
 @start_global_value
-Antelope
-Valid values are 'Antelope' and 'Barracuda' 
-select @@global.innodb_file_format_max in ('Antelope', 'Barracuda');
-@@global.innodb_file_format_max in ('Antelope', 'Barracuda')
-1
-select @@global.innodb_file_format_max;
-@@global.innodb_file_format_max
-Antelope
-select @@session.innodb_file_format_max;
-ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable
-show global variables like 'innodb_file_format_max';
+1
+Valid values are 'ON' and 'OFF'
+SELECT @@global.innodb_file_format_check in (0, 1);
+@@global.innodb_file_format_check in (0, 1)
+1
+SELECT @@global.innodb_file_format_check;
+@@global.innodb_file_format_check
+1
+SELECT @@session.innodb_file_format_check;
+ERROR HY000: Variable 'innodb_file_format_check' is a GLOBAL variable
+SHOW global variables LIKE 'innodb_file_format_check';
 Variable_name	Value
-innodb_file_format_max	Antelope
-show session variables like 'innodb_file_format_max';
+innodb_file_format_check	ON
+SHOW session variables LIKE 'innodb_file_format_check';
 Variable_name	Value
-innodb_file_format_max	Antelope
-select * from information_schema.global_variables where variable_name='innodb_file_format_max';
-VARIABLE_NAME	VARIABLE_VALUE
-INNODB_FILE_FORMAT_MAX	Antelope
-select * from information_schema.session_variables where variable_name='innodb_file_format_max';
-VARIABLE_NAME	VARIABLE_VALUE
-INNODB_FILE_FORMAT_MAX	Antelope
-set global innodb_file_format_max='Antelope';
-select @@global.innodb_file_format_max;
-@@global.innodb_file_format_max
-Antelope
-select * from information_schema.global_variables where variable_name='innodb_file_format_max';
-VARIABLE_NAME	VARIABLE_VALUE
-INNODB_FILE_FORMAT_MAX	Antelope
-select * from information_schema.session_variables where variable_name='innodb_file_format_max';
-VARIABLE_NAME	VARIABLE_VALUE
-INNODB_FILE_FORMAT_MAX	Antelope
-set @@global.innodb_file_format_max='Barracuda';
-select @@global.innodb_file_format_max;
-@@global.innodb_file_format_max
-Barracuda
-select * from information_schema.global_variables where variable_name='innodb_file_format_max';
-VARIABLE_NAME	VARIABLE_VALUE
-INNODB_FILE_FORMAT_MAX	Barracuda
-select * from information_schema.session_variables where variable_name='innodb_file_format_max';
-VARIABLE_NAME	VARIABLE_VALUE
-INNODB_FILE_FORMAT_MAX	Barracuda
-set session innodb_file_format_max='Salmon';
-ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable and should be set with SET GLOBAL
-set @@session.innodb_file_format_max='Salmon';
-ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable and should be set with SET GLOBAL
-set global innodb_file_format_max=1.1;
-ERROR 42000: Incorrect argument type to variable 'innodb_file_format_max'
-set global innodb_file_format_max=1e1;
-ERROR 42000: Incorrect argument type to variable 'innodb_file_format_max'
-set global innodb_file_format_max='Salmon';
-ERROR 42000: Variable 'innodb_file_format_max' can't be set to the value of 'Salmon'
-SET @@global.innodb_file_format_max = @start_global_value;
-SELECT @@global.innodb_file_format_max;
-@@global.innodb_file_format_max
-Antelope
+innodb_file_format_check	ON
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_file_format_check';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_FILE_FORMAT_CHECK	ON
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_file_format_check';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_FILE_FORMAT_CHECK	ON
+SET @@global.innodb_file_format_check='Off';
+ERROR HY000: Variable 'innodb_file_format_check' is a read only variable
+Expected error 'Read only variable'
+SET @@global.innodb_file_format_check=1;
+ERROR HY000: Variable 'innodb_file_format_check' is a read only variable
+Expected error 'Read only variable'
+SET @@global.innodb_file_format_check=0;
+ERROR HY000: Variable 'innodb_file_format_check' is a read only variable
+Expected error 'Read only variable'
+SET @@global.innodb_file_format_check='On';
+ERROR HY000: Variable 'innodb_file_format_check' is a read only variable
+Expected error 'Read only variable'
+SET session innodb_large_prefix='OFF';
+ERROR HY000: Variable 'innodb_large_prefix' is a GLOBAL variable and should be set with SET GLOBAL
+SET @@session.innodb_stats_on_metadata='ON';
+ERROR HY000: Variable 'innodb_stats_on_metadata' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT IF(@@GLOBAL.innodb_file_format_check, "ON", "OFF") = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='innodb_file_format_check';
+IF(@@GLOBAL.innodb_file_format_check, "ON", "OFF") = VARIABLE_VALUE
+1
+1 Expected
+SELECT COUNT(@@GLOBAL.innodb_file_format_check);
+COUNT(@@GLOBAL.innodb_file_format_check)
+1
+1 Expected
+SELECT COUNT(VARIABLE_VALUE)
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='innodb_file_format_check';
+COUNT(VARIABLE_VALUE)
+1
+1 Expected
+SELECT @@innodb_file_format_check = @@GLOBAL.innodb_file_format_check;
+@@innodb_file_format_check = @@GLOBAL.innodb_file_format_check
+1
+1 Expected
+SELECT COUNT(@@innodb_file_format_check);
+COUNT(@@innodb_file_format_check)
+1
+1 Expected
+SELECT COUNT(@@local.innodb_file_format_check);
+ERROR HY000: Variable 'innodb_file_format_check' is a GLOBAL variable
+Expected error 'Variable is a GLOBAL variable'
+SELECT COUNT(@@SESSION.innodb_file_format_check);
+ERROR HY000: Variable 'innodb_file_format_check' is a GLOBAL variable
+Expected error 'Variable is a GLOBAL variable'
+SELECT COUNT(@@GLOBAL.innodb_file_format_check);
+COUNT(@@GLOBAL.innodb_file_format_check)
+1
+1 Expected
+SELECT innodb_file_format_check = @@SESSION.innodb_file_format_check;
+ERROR 42S22: Unknown column 'innodb_file_format_check' in 'field list'
+Expected error 'Readonly variable'

=== added file 'mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result	2011-08-15 14:29:38 +0000
@@ -0,0 +1,65 @@
+SET @start_global_value = @@global.innodb_file_format_max;
+SELECT @start_global_value;
+@start_global_value
+Antelope
+Valid values are 'Antelope' and 'Barracuda' 
+SELECT @@global.innodb_file_format_max in ('Antelope', 'Barracuda');
+@@global.innodb_file_format_max in ('Antelope', 'Barracuda')
+1
+SELECT @@global.innodb_file_format_max;
+@@global.innodb_file_format_max
+Antelope
+SELECT @@session.innodb_file_format_max;
+ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable
+SHOW global variables LIKE 'innodb_file_format_max';
+Variable_name	Value
+innodb_file_format_max	Antelope
+SHOW session variables LIKE 'innodb_file_format_max';
+Variable_name	Value
+innodb_file_format_max	Antelope
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_file_format_max';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_FILE_FORMAT_MAX	Antelope
+SELECT * FROM information_schema.session_variables
+WHERE variable_name='innodb_file_format_max';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_FILE_FORMAT_MAX	Antelope
+SET global innodb_file_format_max='Antelope';
+SELECT @@global.innodb_file_format_max;
+@@global.innodb_file_format_max
+Antelope
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_file_format_max';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_FILE_FORMAT_MAX	Antelope
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_file_format_max';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_FILE_FORMAT_MAX	Antelope
+SET @@global.innodb_file_format_max='Barracuda';
+SELECT @@global.innodb_file_format_max;
+@@global.innodb_file_format_max
+Barracuda
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_file_format_max';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_FILE_FORMAT_MAX	Barracuda
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_file_format_max';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_FILE_FORMAT_MAX	Barracuda
+SET session innodb_file_format_max='Salmon';
+ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable and should be set with SET GLOBAL
+SET @@session.innodb_file_format_max='Salmon';
+ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable and should be set with SET GLOBAL
+SET global innodb_file_format_max=1.1;
+ERROR 42000: Incorrect argument type to variable 'innodb_file_format_max'
+SET global innodb_file_format_max=1e1;
+ERROR 42000: Incorrect argument type to variable 'innodb_file_format_max'
+SET global innodb_file_format_max='Salmon';
+ERROR 42000: Variable 'innodb_file_format_max' can't be set to the value of 'Salmon'
+SET @@global.innodb_file_format_max = @start_global_value;
+SELECT @@global.innodb_file_format_max;
+@@global.innodb_file_format_max
+Antelope

=== added file 'mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result	2011-07-19 14:54:59 +0000
@@ -0,0 +1,92 @@
+SET @start_global_value = @@global.innodb_random_read_ahead;
+SELECT @start_global_value;
+@start_global_value
+0
+Valid values are 'ON' and 'OFF' 
+select @@global.innodb_random_read_ahead in (0, 1);
+@@global.innodb_random_read_ahead in (0, 1)
+1
+select @@global.innodb_random_read_ahead;
+@@global.innodb_random_read_ahead
+0
+select @@session.innodb_random_read_ahead;
+ERROR HY000: Variable 'innodb_random_read_ahead' is a GLOBAL variable
+show global variables like 'innodb_random_read_ahead';
+Variable_name	Value
+innodb_random_read_ahead	OFF
+show session variables like 'innodb_random_read_ahead';
+Variable_name	Value
+innodb_random_read_ahead	OFF
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	OFF
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	OFF
+set global innodb_random_read_ahead='ON';
+select @@global.innodb_random_read_ahead;
+@@global.innodb_random_read_ahead
+1
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	ON
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	ON
+set @@global.innodb_random_read_ahead=0;
+select @@global.innodb_random_read_ahead;
+@@global.innodb_random_read_ahead
+0
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	OFF
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	OFF
+set global innodb_random_read_ahead=1;
+select @@global.innodb_random_read_ahead;
+@@global.innodb_random_read_ahead
+1
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	ON
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	ON
+set @@global.innodb_random_read_ahead='OFF';
+select @@global.innodb_random_read_ahead;
+@@global.innodb_random_read_ahead
+0
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	OFF
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	OFF
+set session innodb_random_read_ahead='OFF';
+ERROR HY000: Variable 'innodb_random_read_ahead' is a GLOBAL variable and should be set with SET GLOBAL
+set @@session.innodb_random_read_ahead='ON';
+ERROR HY000: Variable 'innodb_random_read_ahead' is a GLOBAL variable and should be set with SET GLOBAL
+set global innodb_random_read_ahead=1.1;
+ERROR 42000: Incorrect argument type to variable 'innodb_random_read_ahead'
+set global innodb_random_read_ahead=1e1;
+ERROR 42000: Incorrect argument type to variable 'innodb_random_read_ahead'
+set global innodb_random_read_ahead=2;
+ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of '2'
+NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
+set global innodb_random_read_ahead=-3;
+select @@global.innodb_random_read_ahead;
+@@global.innodb_random_read_ahead
+1
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	ON
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_RANDOM_READ_AHEAD	ON
+set global innodb_random_read_ahead='AUTO';
+ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of 'AUTO'
+SET @@global.innodb_random_read_ahead = @start_global_value;
+SELECT @@global.innodb_random_read_ahead;
+@@global.innodb_random_read_ahead
+0

=== added file 'mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result	2011-08-15 14:29:38 +0000
@@ -0,0 +1,64 @@
+SET @start_global_value = @@global.innodb_rollback_segments;
+SELECT @start_global_value;
+@start_global_value
+128
+Valid values are zero or above
+SELECT @@global.innodb_rollback_segments >=0;
+@@global.innodb_rollback_segments >=0
+1
+SELECT @@global.innodb_rollback_segments <=128;
+@@global.innodb_rollback_segments <=128
+1
+SELECT @@global.innodb_rollback_segments;
+@@global.innodb_rollback_segments
+128
+SELECT @@session.innodb_rollback_segments;
+ERROR HY000: Variable 'innodb_rollback_segments' is a GLOBAL variable
+SHOW global variables LIKE 'innodb_rollback_segments';
+Variable_name	Value
+innodb_rollback_segments	128
+SHOW session variables LIKE 'innodb_rollback_segments';
+Variable_name	Value
+innodb_rollback_segments	128
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_rollback_segments';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_ROLLBACK_SEGMENTS	128
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_rollback_segments';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_ROLLBACK_SEGMENTS	128
+SET global innodb_rollback_segments=100;
+SELECT @@global.innodb_rollback_segments;
+@@global.innodb_rollback_segments
+100
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_rollback_segments';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_ROLLBACK_SEGMENTS	100
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_rollback_segments';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_ROLLBACK_SEGMENTS	100
+SET session innodb_rollback_segments=1;
+ERROR HY000: Variable 'innodb_rollback_segments' is a GLOBAL variable and should be set with SET GLOBAL
+SET global innodb_rollback_segments=1.1;
+ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments'
+SET global innodb_rollback_segments=1e1;
+ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments'
+SET global innodb_rollback_segments="foo";
+ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments'
+SET global innodb_rollback_segments=-7;
+Warnings:
+Warning	1292	Truncated incorrect innodb_rollback_segments value: '-7'
+SELECT @@global.innodb_rollback_segments;
+@@global.innodb_rollback_segments
+1
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_rollback_segments';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_ROLLBACK_SEGMENTS	1
+SET @@global.innodb_rollback_segments = @start_global_value;
+SELECT @@global.innodb_rollback_segments;
+@@global.innodb_rollback_segments
+128

=== added file 'mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result'
--- a/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result	2011-08-15 14:29:38 +0000
@@ -0,0 +1,83 @@
+SET @start_global_value = @@global.innodb_stats_method;
+SELECT @start_global_value;
+@start_global_value
+nulls_equal
+Valid values are 'nulls_equal', 'nulls_unequal', 'nulls_ignored'
+SELECT @@global.innodb_stats_method in ('nulls_equal', 'nulls_unequal', 
+'nulls_ignored');
+@@global.innodb_stats_method in ('nulls_equal', 'nulls_unequal', 
+'nulls_ignored')
+1
+SELECT @@global.innodb_stats_method;
+@@global.innodb_stats_method
+nulls_equal
+SELECT @@session.innodb_stats_method;
+ERROR HY000: Variable 'innodb_stats_method' is a GLOBAL variable
+SHOW global variables LIKE 'innodb_stats_method';
+Variable_name	Value
+innodb_stats_method	nulls_equal
+SHOW session variables LIKE 'innodb_stats_method';
+Variable_name	Value
+innodb_stats_method	nulls_equal
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_stats_method';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_STATS_METHOD	nulls_equal
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_stats_method';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_STATS_METHOD	nulls_equal
+SET global innodb_stats_method='nulls_equal';
+SELECT @@global.innodb_stats_method;
+@@global.innodb_stats_method
+nulls_equal
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_stats_method';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_STATS_METHOD	nulls_equal
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_stats_method';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_STATS_METHOD	nulls_equal
+SET @@global.innodb_stats_method='nulls_unequal';
+SELECT @@global.innodb_stats_method;
+@@global.innodb_stats_method
+nulls_unequal
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_stats_method';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_STATS_METHOD	nulls_unequal
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_stats_method';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_STATS_METHOD	nulls_unequal
+SET global innodb_stats_method=2;
+SELECT @@global.innodb_stats_method;
+@@global.innodb_stats_method
+nulls_ignored
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_stats_method';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_STATS_METHOD	nulls_ignored
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_stats_method';
+VARIABLE_NAME	VARIABLE_VALUE
+INNODB_STATS_METHOD	nulls_ignored
+SET session innodb_stats_method='nulls_equal';
+ERROR HY000: Variable 'innodb_stats_method' is a GLOBAL variable and should be set with SET GLOBAL
+SET @@session.innodb_stats_method='nulls_ignored';
+ERROR HY000: Variable 'innodb_stats_method' is a GLOBAL variable and should be set with SET GLOBAL
+SET global innodb_stats_method=1.1;
+ERROR 42000: Incorrect argument type to variable 'innodb_stats_method'
+SET global innodb_stats_method=4;
+ERROR 42000: Variable 'innodb_stats_method' can't be set to the value of '4'
+SET global innodb_stats_method=-2;
+ERROR 42000: Variable 'innodb_stats_method' can't be set to the value of '-2'
+SET global innodb_stats_method=1e1;
+ERROR 42000: Incorrect argument type to variable 'innodb_stats_method'
+SET global innodb_stats_method='some';
+ERROR 42000: Variable 'innodb_stats_method' can't be set to the value of 'some'
+SET @@global.innodb_stats_method = @start_global_value;
+SELECT @@global.innodb_stats_method;
+@@global.innodb_stats_method
+nulls_equal

=== modified file 'mysql-test/suite/sys_vars/t/innodb_file_format_check_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_file_format_check_basic.test	2010-06-17 20:51:35 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_file_format_check_basic.test	2011-08-15 14:29:38 +0000
@@ -1,55 +1,95 @@
-
-
-# 2010-01-25 - Added
 #
+# 2011-08-02 - Added
+#
+
 --source include/not_embedded.inc
 --source include/have_innodb.inc
 
-SET @start_global_value = @@global.innodb_file_format_max;
+SET @start_global_value = @@global.innodb_file_format_check;
 SELECT @start_global_value;
 
 #
 # exists as global only
 #
---echo Valid values are 'Antelope' and 'Barracuda' 
-select @@global.innodb_file_format_max in ('Antelope', 'Barracuda');
-select @@global.innodb_file_format_max;
+--echo  Valid values are 'ON' and 'OFF'
+SELECT @@global.innodb_file_format_check in (0, 1);
+SELECT @@global.innodb_file_format_check;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.innodb_file_format_check;
+SHOW global variables LIKE 'innodb_file_format_check';
+SHOW session variables LIKE 'innodb_file_format_check';
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_file_format_check';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_file_format_check';
+
+#
+# show that it's read only
+#
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@global.innodb_file_format_check='Off';
+--echo Expected error 'Read only variable'
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@global.innodb_file_format_check=1; 
+--echo Expected error 'Read only variable'
+
 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
-select @@session.innodb_file_format_max;
-show global variables like 'innodb_file_format_max';
-show session variables like 'innodb_file_format_max';
-select * from information_schema.global_variables where variable_name='innodb_file_format_max';
-select * from information_schema.session_variables where variable_name='innodb_file_format_max';
-
-#
-# show that it's writable
-#
-set global innodb_file_format_max='Antelope';
-select @@global.innodb_file_format_max;
-select * from information_schema.global_variables where variable_name='innodb_file_format_max';
-select * from information_schema.session_variables where variable_name='innodb_file_format_max';
-set @@global.innodb_file_format_max='Barracuda';
-select @@global.innodb_file_format_max;
-select * from information_schema.global_variables where variable_name='innodb_file_format_max';
-select * from information_schema.session_variables where variable_name='innodb_file_format_max';
+SET @@global.innodb_file_format_check=0;
+--echo Expected error 'Read only variable'
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@global.innodb_file_format_check='On';
+--echo Expected error 'Read only variable'
+
 --error ER_GLOBAL_VARIABLE
-set session innodb_file_format_max='Salmon';
+SET session innodb_large_prefix='OFF';
 --error ER_GLOBAL_VARIABLE
-set @@session.innodb_file_format_max='Salmon';
+SET @@session.innodb_stats_on_metadata='ON';
 
 #
-# incorrect types
+# Check if the value in GLOBAL Table matches value in variable 
 #
---error ER_WRONG_TYPE_FOR_VAR
-set global innodb_file_format_max=1.1;
---error ER_WRONG_TYPE_FOR_VAR
-set global innodb_file_format_max=1e1;
---error ER_WRONG_VALUE_FOR_VAR
-set global innodb_file_format_max='Salmon';
+
+SELECT IF(@@GLOBAL.innodb_file_format_check, "ON", "OFF") = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='innodb_file_format_check';
+--echo 1 Expected
+
+SELECT COUNT(@@GLOBAL.innodb_file_format_check);
+--echo 1 Expected
+
+SELECT COUNT(VARIABLE_VALUE)
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='innodb_file_format_check';
+--echo 1 Expected
 
 #
-# Cleanup
+# Check if accessing variable with and without GLOBAL point to same variable
 #
+SELECT @@innodb_file_format_check = @@GLOBAL.innodb_file_format_check;
+--echo 1 Expected
+
+#
+# Check if innodb_doublewrite can be accessed with and without @@ sign 
+#
+
+SELECT COUNT(@@innodb_file_format_check);
+--echo 1 Expected
+
+--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT COUNT(@@local.innodb_file_format_check);
+--echo Expected error 'Variable is a GLOBAL variable'
+
+--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT COUNT(@@SESSION.innodb_file_format_check);
+--echo Expected error 'Variable is a GLOBAL variable'
+
+SELECT COUNT(@@GLOBAL.innodb_file_format_check);
+--echo 1 Expected
 
-SET @@global.innodb_file_format_max = @start_global_value;
-SELECT @@global.innodb_file_format_max;
+--Error ER_BAD_FIELD_ERROR
+SELECT innodb_file_format_check = @@SESSION.innodb_file_format_check;
+--echo Expected error 'Readonly variable'

=== added file 'mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test	2011-08-15 14:29:38 +0000
@@ -0,0 +1,60 @@
+#
+# 2011-08-02 - Added
+#
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+
+SET @start_global_value = @@global.innodb_file_format_max;
+SELECT @start_global_value;
+
+#
+# exists as global only
+#
+--echo Valid values are 'Antelope' and 'Barracuda' 
+SELECT @@global.innodb_file_format_max in ('Antelope', 'Barracuda');
+SELECT @@global.innodb_file_format_max;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.innodb_file_format_max;
+SHOW global variables LIKE 'innodb_file_format_max';
+SHOW session variables LIKE 'innodb_file_format_max';
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_file_format_max';
+SELECT * FROM information_schema.session_variables
+WHERE variable_name='innodb_file_format_max';
+
+#
+# show that it's writable
+#
+SET global innodb_file_format_max='Antelope';
+SELECT @@global.innodb_file_format_max;
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_file_format_max';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_file_format_max';
+SET @@global.innodb_file_format_max='Barracuda';
+SELECT @@global.innodb_file_format_max;
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_file_format_max';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_file_format_max';
+--error ER_GLOBAL_VARIABLE
+SET session innodb_file_format_max='Salmon';
+--error ER_GLOBAL_VARIABLE
+SET @@session.innodb_file_format_max='Salmon';
+
+#
+# incorrect types
+#
+--error ER_WRONG_TYPE_FOR_VAR
+SET global innodb_file_format_max=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET global innodb_file_format_max=1e1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET global innodb_file_format_max='Salmon';
+
+#
+# Cleanup
+#
+
+SET @@global.innodb_file_format_max = @start_global_value;
+SELECT @@global.innodb_file_format_max;

=== added file 'mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test	2011-07-19 14:54:59 +0000
@@ -0,0 +1,70 @@
+
+
+# 2010-01-25 - Added
+#
+
+--source include/have_innodb.inc
+
+SET @start_global_value = @@global.innodb_random_read_ahead;
+SELECT @start_global_value;
+
+#
+# exists as global only
+#
+--echo Valid values are 'ON' and 'OFF' 
+select @@global.innodb_random_read_ahead in (0, 1);
+select @@global.innodb_random_read_ahead;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.innodb_random_read_ahead;
+show global variables like 'innodb_random_read_ahead';
+show session variables like 'innodb_random_read_ahead';
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+
+#
+# show that it's writable
+#
+set global innodb_random_read_ahead='ON';
+select @@global.innodb_random_read_ahead;
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+set @@global.innodb_random_read_ahead=0;
+select @@global.innodb_random_read_ahead;
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+set global innodb_random_read_ahead=1;
+select @@global.innodb_random_read_ahead;
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+set @@global.innodb_random_read_ahead='OFF';
+select @@global.innodb_random_read_ahead;
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+--error ER_GLOBAL_VARIABLE
+set session innodb_random_read_ahead='OFF';
+--error ER_GLOBAL_VARIABLE
+set @@session.innodb_random_read_ahead='ON';
+
+#
+# incorrect types
+#
+--error ER_WRONG_TYPE_FOR_VAR
+set global innodb_random_read_ahead=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+set global innodb_random_read_ahead=1e1;
+--error ER_WRONG_VALUE_FOR_VAR
+set global innodb_random_read_ahead=2;
+--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643)
+set global innodb_random_read_ahead=-3;
+select @@global.innodb_random_read_ahead;
+select * from information_schema.global_variables where variable_name='innodb_random_read_ahead';
+select * from information_schema.session_variables where variable_name='innodb_random_read_ahead';
+--error ER_WRONG_VALUE_FOR_VAR
+set global innodb_random_read_ahead='AUTO';
+
+#
+# Cleanup
+#
+
+SET @@global.innodb_random_read_ahead = @start_global_value;
+SELECT @@global.innodb_random_read_ahead;

=== added file 'mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test	2011-08-15 14:29:38 +0000
@@ -0,0 +1,58 @@
+#
+#  2011-08-01  Added
+#
+
+--source include/have_innodb.inc
+
+SET @start_global_value = @@global.innodb_rollback_segments;
+SELECT @start_global_value;
+
+#
+# exists as global only
+#
+--echo Valid values are zero or above
+SELECT @@global.innodb_rollback_segments >=0;
+SELECT @@global.innodb_rollback_segments <=128;
+SELECT @@global.innodb_rollback_segments;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.innodb_rollback_segments;
+SHOW global variables LIKE 'innodb_rollback_segments';
+SHOW session variables LIKE 'innodb_rollback_segments';
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_rollback_segments';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_rollback_segments';
+
+#
+# show that it's writable
+#
+SET global innodb_rollback_segments=100;
+SELECT @@global.innodb_rollback_segments;
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_rollback_segments';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_rollback_segments';
+--error ER_GLOBAL_VARIABLE
+SET session innodb_rollback_segments=1;
+
+#
+# incorrect types
+#
+--error ER_WRONG_TYPE_FOR_VAR
+SET global innodb_rollback_segments=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET global innodb_rollback_segments=1e1;
+--error ER_WRONG_TYPE_FOR_VAR
+SET global innodb_rollback_segments="foo";
+SET global innodb_rollback_segments=-7;
+SELECT @@global.innodb_rollback_segments;
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_rollback_segments';
+
+#
+# cleanup
+#
+
+SET @@global.innodb_rollback_segments = @start_global_value;
+SELECT @@global.innodb_rollback_segments;

=== added file 'mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test'
--- a/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test	2011-08-15 14:29:38 +0000
@@ -0,0 +1,72 @@
+#
+# 2011-08-05 - Added
+#
+
+--source include/have_innodb.inc
+
+SET @start_global_value = @@global.innodb_stats_method;
+SELECT @start_global_value;
+
+#
+# exists as global only 
+#
+--echo Valid values are 'nulls_equal', 'nulls_unequal', 'nulls_ignored'
+SELECT @@global.innodb_stats_method in ('nulls_equal', 'nulls_unequal', 
+'nulls_ignored');
+SELECT @@global.innodb_stats_method;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.innodb_stats_method;
+SHOW global variables LIKE 'innodb_stats_method';
+SHOW session variables LIKE 'innodb_stats_method';
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_stats_method';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_stats_method';
+
+#
+# show that it's writable
+#
+SET global innodb_stats_method='nulls_equal';
+SELECT @@global.innodb_stats_method;
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_stats_method';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_stats_method';
+SET @@global.innodb_stats_method='nulls_unequal';
+SELECT @@global.innodb_stats_method;
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_stats_method';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_stats_method';
+SET global innodb_stats_method=2;
+SELECT @@global.innodb_stats_method;
+SELECT * FROM information_schema.global_variables 
+WHERE variable_name='innodb_stats_method';
+SELECT * FROM information_schema.session_variables 
+WHERE variable_name='innodb_stats_method';
+
+--error ER_GLOBAL_VARIABLE
+SET session innodb_stats_method='nulls_equal';
+--error ER_GLOBAL_VARIABLE
+SET @@session.innodb_stats_method='nulls_ignored';
+
+#
+# incorrect types
+#
+--error ER_WRONG_TYPE_FOR_VAR
+SET global innodb_stats_method=1.1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET global innodb_stats_method=4;
+--error ER_WRONG_VALUE_FOR_VAR
+SET global innodb_stats_method=-2;
+--error ER_WRONG_TYPE_FOR_VAR
+SET global innodb_stats_method=1e1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET global innodb_stats_method='some';
+
+#
+# Cleanup
+#
+
+SET @@global.innodb_stats_method = @start_global_value;
+SELECT @@global.innodb_stats_method;

=== modified file 'mysql-test/t/ctype_errors.test'
--- a/mysql-test/t/ctype_errors.test	2009-10-15 12:23:43 +0000
+++ b/mysql-test/t/ctype_errors.test	2011-07-15 11:05:30 +0000
@@ -44,4 +44,19 @@ USE nonexistant;
 disconnect con1;
 connection default;
 
---echo End of 5.4 tests
+--echo #
+--echo # Bug#12736295: Buffer overflow for variable converted_err
+--echo #               with non-latin1 server error message
+--echo #
+
+connect (con1,localhost,root,,test);
+--echo # Connection con1
+SET lc_messages=ru_RU;
+SET NAMES latin1;
+--error ER_PARSE_ERROR
+--query SELECT '01234567890123456789012345678901234\'
+disconnect con1;
+--echo # Connection default
+connection default;
+
+--echo End of 5.5 tests

=== modified file 'mysql-test/t/ctype_utf32_uca.test'
--- a/mysql-test/t/ctype_utf32_uca.test	2010-11-26 10:44:39 +0000
+++ b/mysql-test/t/ctype_utf32_uca.test	2011-07-22 12:54:47 +0000
@@ -293,6 +293,27 @@ SET collation_connection=utf32_czech_ci;
 --source include/ctype_czech.inc
 --source include/ctype_like_ignorable.inc
 
+--echo #
+--echo # Bug #12319710 : INVALID MEMORY READ AND/OR CRASH IN 
+--echo #   MY_UCA_CHARCMP WITH UTF32
+--echo #
+
+SET collation_connection=utf32_unicode_ci;
+CREATE TABLE t1 (a TEXT CHARACTER SET utf32 COLLATE utf32_turkish_ci NOT NULL);
+INSERT INTO t1 VALUES ('a'), ('b');
+CREATE TABLE t2 (b VARBINARY(5) NOT NULL);
+
+--echo #insert chars outside of BMP
+INSERT INTO t2 VALUEs (0x082837),(0x082837);
+
+--echo #test for read-out-of-bounds with non-BMP chars as a LIKE pattern
+SELECT * FROM t1,t2 WHERE a LIKE b;
+
+--echo #test the original statement
+SELECT 1 FROM t1 AS t1_0 NATURAL LEFT OUTER JOIN t2 AS t2_0
+RIGHT JOIN t1 AS t1_1 ON t1_0.a LIKE t2_0.b;
+
+DROP TABLE t1,t2;
 
 --echo #
 --echo # End of 5.5 tests

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2011-09-09 12:41:37 +0000
+++ b/mysql-test/t/disabled.def	2011-10-05 08:56:12 +0000
@@ -1,4 +1,4 @@
-##############################################################################
+201##############################################################################
 #
 #  List the test cases that are to be disabled temporarily.
 #
@@ -17,5 +17,8 @@ create-big               : Bug#11748731 
 archive-big              : Bug#11817185 2011-03-10 Anitha Disabled since this leads to timeout on Solaris Sparc
 file_contents            : Bug#12585902 file_contents.test fails when building from "bzr export"
 log_tables-big           : Bug#11756699 2010-11-15 mattiasj report already exists
-mysql_embedded           : Bug#12561297 seems to be fixed in 5.5.16 (I verified that it fails also in tag:mysql-5.5.15)
+mysql_embedded           : Bug#12561297 2011-05-14 Anitha Dependent on PB2 changes - eventum#41836
 
+### MCP_DISABLE_FAILING_TESTS start ###
+file_contents            : Bug#12585902 2011-09-27 magnus file_contents.test fails when building from "bzr export"
+### MCP_DISABLE_FAILING_TESTS end ###

=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test	2011-05-26 10:09:25 +0000
+++ b/mysql-test/t/func_math.test	2011-07-18 09:21:14 +0000
@@ -536,3 +536,25 @@ SELECT 1 div null;
 --echo # Bug #11792200 - DIVIDING LARGE NUMBERS CAUSES STACK CORRUPTIONS
 --echo #
 select (1.175494351E-37 div 1.7976931348623157E+308);
+
+--echo #
+--echo # Bug#12537160 ASSERTION FAILED:
+--echo # STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER.
+--echo #
+
+let $nine_81=
+999999999999999999999999999999999999999999999999999999999999999999999999999999999;
+
+eval select $nine_81 % 0.1 as foo;
+eval select $nine_81 % 0.0 as foo;
+
+--echo #
+--echo # Bug#12711164 - 61676:
+--echo # RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE 
+--echo #
+
+select 5 div 2;
+select 5.0 div 2.0;
+select 5.0 div 2;
+select 5 div 2.0;
+select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2;

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2011-05-18 06:59:04 +0000
+++ b/mysql-test/t/func_time.test	2011-07-27 08:51:55 +0000
@@ -909,6 +909,12 @@ SELECT DATE_FORMAT('0000-00-11', '%w');
 SELECT MAKEDATE(11111111,1);
 SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
 
+--echo #
+--echo # Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0,
+--echo #
+
+DO WEEK((DATE_ADD((CAST(0 AS DATE)), INTERVAL 1 YEAR_MONTH)), 5);
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/implicit_commit.test'
--- a/mysql-test/t/implicit_commit.test	2010-02-26 09:58:33 +0000
+++ b/mysql-test/t/implicit_commit.test	2011-07-20 06:50:47 +0000
@@ -1,5 +1,6 @@
 source include/have_innodb.inc;
 source include/not_embedded.inc;
+source include/have_profiling.inc;
 
 SET GLOBAL EVENT_SCHEDULER = OFF;
 SET BINLOG_FORMAT = STATEMENT;

=== modified file 'mysql-test/t/information_schema.test'
--- a/mysql-test/t/information_schema.test	2011-01-04 17:46:01 +0000
+++ b/mysql-test/t/information_schema.test	2011-08-15 14:31:45 +0000
@@ -1543,8 +1543,6 @@ DROP TABLE t1, information_schema.tables
 LOCK TABLES t1 READ, information_schema.tables READ;
 DROP TABLE t1;
 
-# 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
@@ -1609,5 +1607,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

=== modified file 'mysql-test/t/merge.test'
--- a/mysql-test/t/merge.test	2010-10-06 07:56:29 +0000
+++ b/mysql-test/t/merge.test	2011-07-22 12:31:10 +0000
@@ -2798,7 +2798,32 @@ UNLOCK TABLES;
 DROP TABLE m1, t1;
 
 
---echo End of 6.0 tests
+--echo #
+--echo # Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL
+--echo #                           PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1"
+--echo #
+--disable_warnings
+drop tables if exists t1, t2, t3, t4, m1;
+--enable_warnings
+create table t1(id int) engine=myisam;
+create view t3 as select 1 as id;
+create table t4(id int) engine=memory;
+create table m1(id int) engine=merge union=(t1,t2,t3,t4);
+--error ER_WRONG_MRG_TABLE
+select * from m1;
+--echo # The below CHECK and REPAIR TABLE statements should
+--echo # report all problems with underlying tables: 
+--echo # - absence of 't2',
+--echo # - missing base table for 't3',
+--echo # - wrong engine of 't4'.
+check table m1;
+repair table m1;
+--echo # Clean-up.
+drop tables m1, t1, t4;
+drop view t3;
+
+
+--echo End of 5.5 tests
 
 --disable_result_log
 --disable_query_log

=== 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-08-15 14:29:38 +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-09-09 14:39:44 +0000
@@ -0,0 +1,319 @@
+#
+# 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;
+replace_result "/basedir_not_there//" "/basedir_not_there/";
+--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/order_by.test'
--- a/mysql-test/t/order_by.test	2011-03-30 12:55:53 +0000
+++ b/mysql-test/t/order_by.test	2011-07-11 09:27:52 +0000
@@ -1509,6 +1509,13 @@ SELECT DISTINCT a,1 FROM t1 WHERE a <> 1
 
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#11765255 58201:
+--echo # VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS
+--echo #
+
+select 1 order by max(1) + min(1);
+
 --echo End of 5.1 tests
 
 

=== modified file 'mysql-test/t/plugin_auth.test'
--- a/mysql-test/t/plugin_auth.test	2011-07-05 23:13:50 +0000
+++ b/mysql-test/t/plugin_auth.test	2011-08-12 12:55:04 +0000
@@ -540,4 +540,35 @@ connection default;
 disconnect b12610784;
 DROP USER bug12610784@localhost;
 
+
+--echo #
+--echo # Bug #12818542: PAM: ADDING PASSWORD FOR AN ACCOUNT DISABLES PAM 
+--echo #   AUTHENTICATION SETTINGS
+--echo #
+
+CREATE USER bug12818542@localhost 
+  IDENTIFIED WITH 'test_plugin_server' AS 'bug12818542_dest';
+CREATE USER bug12818542_dest@localhost 
+  IDENTIFIED BY 'bug12818542_dest_passwd';
+GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost;
+
+connect(bug12818542_con,localhost,bug12818542,bug12818542_dest);
+connection bug12818542_con;
+SELECT USER(),CURRENT_USER();
+
+SET PASSWORD = PASSWORD('bruhaha');
+
+connection default;
+disconnect bug12818542_con;
+
+connect(bug12818542_con2,localhost,bug12818542,bug12818542_dest);
+connection bug12818542_con2;
+SELECT USER(),CURRENT_USER();
+
+connection default;
+disconnect bug12818542_con2;
+
+DROP USER bug12818542@localhost;
+DROP USER bug12818542_dest@localhost;
+
 --echo End of 5.5 tests

=== modified file 'mysql-test/t/sp-error.test'
--- a/mysql-test/t/sp-error.test	2010-10-26 11:48:08 +0000
+++ b/mysql-test/t/sp-error.test	2011-06-16 10:54:16 +0000
@@ -2541,6 +2541,28 @@ DROP PROCEDURE p1;
 DROP VIEW v1;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#12428824 - PARSER STACK OVERFLOW AND CRASH IN SP_ADD_USED_ROUTINE
+--echo #                WITH OBSCURE QUERY
+--echo #
+
+--error ER_TOO_LONG_IDENT
+SELECT very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999();
+
+--error ER_TOO_LONG_IDENT
+CALL very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999();
+
+--error ER_WRONG_DB_NAME
+SELECT very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_func();
+
+--error ER_WRONG_DB_NAME
+CALL very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_proc();
+
+--error ER_TOO_LONG_IDENT
+SELECT db_name.very_long_fn_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999();
+
+--error ER_TOO_LONG_IDENT
+CALL db_name.very_long_pr_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999();
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test	2011-06-21 15:24:44 +0000
+++ b/mysql-test/t/sp.test	2011-08-09 08:50:55 +0000
@@ -8376,6 +8376,53 @@ SET @@GLOBAL.init_connect= @old_init_con
 DROP PROCEDURE p2;
 DROP PROCEDURE p5;
 
+
+--echo #
+--echo # Bug#11840395 (formerly known as bug#60347):
+--echo # The string "versiondata" seems
+--echo # to be 'leaking' into the schema name space
+--echo #
+--disable_warnings
+DROP DATABASE IF EXISTS mixedCaseDbName;
+--enable_warnings
+CREATE DATABASE mixedCaseDbName;
+DELIMITER |;
+CREATE PROCEDURE mixedCaseDbName.tryMyProc() begin end|
+CREATE FUNCTION mixedCaseDbName.tryMyFunc() returns text begin return 'IT WORKS'; end
+|
+DELIMITER ;|
+call mixedCaseDbName.tryMyProc();
+select mixedCaseDbName.tryMyFunc();
+DROP DATABASE mixedCaseDbName;
+
+
+--echo #
+--echo # Bug#11766594  59736: SELECT DISTINCT.. INCORRECT RESULT WITH DETERMINISTIC FUNCTION IN WHERE C
+--echo #
+
+CREATE TABLE t1 (a INT, b INT, KEY(b));
+CREATE TABLE t2 (c INT, d INT, KEY(c));
+INSERT INTO t1 VALUES (1,1),(1,1),(1,2);
+INSERT INTO t2 VALUES (1,1),(1,2);
+
+DELIMITER $;
+
+CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
+BEGIN
+  DECLARE a int;
+  -- SQL statement inside
+  SELECT 1 INTO a;
+  RETURN a;
+END $
+
+DELIMITER ;$
+
+SELECT COUNT(DISTINCT d) FROM t1, t2  WHERE a = c AND b = f1();
+
+DROP FUNCTION f1;
+DROP TABLE t1, t2;
+
+
 --echo # ------------------------------------------------------------------
 --echo # -- End of 5.1 tests
 --echo # ------------------------------------------------------------------

=== modified file 'mysql-test/t/type_float.test'
--- a/mysql-test/t/type_float.test	2010-04-11 06:52:42 +0000
+++ b/mysql-test/t/type_float.test	2011-07-18 08:27:05 +0000
@@ -307,4 +307,27 @@ INSERT INTO t1 VALUES(-1.79769313486231e
 SELECT f1 FROM t1;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REAL
+--echo # 
+
+--echo # Ignoring output from misc. float operations
+--disable_result_log
+
+let $nine_65=
+99999999999999999999999999999999999999999999999999999999999999999;
+
+select format(-1.7976931348623157E+307,256) as foo;
+select least(-1.1111111111111111111111111,
+             - group_concat(1.7976931348623157E+308)) as foo;
+eval select concat((truncate((-1.7976931348623157E+307),(0x1e))),
+                   ($nine_65)) into @a;
+--enable_result_log
+
 --echo End of 5.0 tests
+
+--echo #
+--echo # Bug#12368853 FORMAT() CRASHES WITH LARGE NUMBERS AFTER TRUNCATE...
+--echo #
+
+select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;

=== modified file 'mysql-test/t/union.test'
--- a/mysql-test/t/union.test	2011-01-10 12:43:12 +0000
+++ b/mysql-test/t/union.test	2011-07-11 09:27:52 +0000
@@ -1116,6 +1116,47 @@ SELECT * FROM t2 UNION SELECT * FROM t2
 DROP TABLE t1,t2;
 
 
+--echo #
+--echo # Bug#11765255 58201:
+--echo # VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS
+--echo #
+
+let $my_stmt=
+select 1 as foo
+union
+select 2
+union
+select 3
+union
+select 4
+order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
+;
+
+eval $my_stmt;
+
+eval prepare stmt1 from '$my_stmt';
+execute stmt1;
+execute stmt1;
+
+let $my_stmt=
+select 1 as foo
+union
+select 2
+union
+select 3
+union
+(select 4)
+order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
+;
+
+eval $my_stmt;
+
+eval prepare stmt1 from '$my_stmt';
+execute stmt1;
+execute stmt1;
+
+deallocate prepare stmt1;
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2011-08-31 10:39:08 +0000
+++ b/mysys/my_init.c	2011-10-05 08:56:12 +0000
@@ -99,10 +99,6 @@ my_bool my_init(void)
   fastmutex_global_init();              /* Must be called early */
 #endif
 
-#if defined(HAVE_PTHREAD_INIT)
-  pthread_init();			/* Must be called before DBUG_ENTER */
-#endif
-
   /* $HOME is needed early to parse configuration files located in ~/ */
   if ((home_dir= getenv("HOME")) != 0)
     home_dir= intern_filename(home_dir_buff, home_dir);

=== modified file 'plugin/audit_null/audit_null.c'
--- a/plugin/audit_null/audit_null.c	2011-07-05 23:13:50 +0000
+++ b/plugin/audit_null/audit_null.c	2011-08-15 18:12:11 +0000
@@ -154,7 +154,8 @@ mysql_declare_plugin(audit_null)
   0x0002,                     /* version                         */
   simple_status,              /* status variables                */
   NULL,                       /* system variables                */
-  NULL
+  NULL,
+  0,
 }
 mysql_declare_plugin_end;
 

=== modified file 'plugin/auth/auth_socket.c'
--- a/plugin/auth/auth_socket.c	2011-06-30 15:46:53 +0000
+++ b/plugin/auth/auth_socket.c	2011-08-15 18:12:11 +0000
@@ -88,7 +88,8 @@ mysql_declare_plugin(socket_auth)
   0x0100,
   NULL,
   NULL,
-  NULL
+  NULL,
+  0,
 }
 mysql_declare_plugin_end;
 

=== modified file 'plugin/auth/dialog.c'
--- a/plugin/auth/dialog.c	2010-10-27 15:12:17 +0000
+++ b/plugin/auth/dialog.c	2011-08-15 18:12:11 +0000
@@ -153,7 +153,8 @@ mysql_declare_plugin(dialog)
   0x0100,
   NULL,
   NULL,
-  NULL
+  NULL,
+  0,
 },
 {
   MYSQL_AUTHENTICATION_PLUGIN,
@@ -167,7 +168,8 @@ mysql_declare_plugin(dialog)
   0x0100,
   NULL,
   NULL,
-  NULL
+  NULL,
+  0,
 }
 mysql_declare_plugin_end;
 

=== modified file 'plugin/auth/qa_auth_interface.c'
--- a/plugin/auth/qa_auth_interface.c	2011-06-30 17:50:10 +0000
+++ b/plugin/auth/qa_auth_interface.c	2011-10-05 08:56:12 +0000
@@ -182,7 +182,8 @@ mysql_declare_plugin(test_plugin)
   0x0100,
   NULL,
   NULL,
-  NULL
+  NULL,
+  0,
 }
 mysql_declare_plugin_end;
 

=== modified file 'plugin/auth/qa_auth_server.c'
--- a/plugin/auth/qa_auth_server.c	2010-10-20 14:56:09 +0000
+++ b/plugin/auth/qa_auth_server.c	2011-08-15 18:12:11 +0000
@@ -82,6 +82,7 @@ mysql_declare_plugin(test_plugin)
   0x0100,
   NULL,
   NULL,
-  NULL
+  NULL,
+  0,
 }
 mysql_declare_plugin_end;

=== modified file 'plugin/auth/test_plugin.c'
--- a/plugin/auth/test_plugin.c	2011-06-30 15:46:53 +0000
+++ b/plugin/auth/test_plugin.c	2011-08-15 18:12:11 +0000
@@ -125,7 +125,8 @@ mysql_declare_plugin(test_plugin)
   0x0100,
   NULL,
   NULL,
-  NULL
+  NULL,
+  0,
 },
 {
   MYSQL_AUTHENTICATION_PLUGIN,
@@ -139,7 +140,8 @@ mysql_declare_plugin(test_plugin)
   0x0100,
   NULL,
   NULL,
-  NULL
+  NULL,
+  0,
 }
 mysql_declare_plugin_end;
 

=== 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-08-15 14:29:38 +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})

=== modified file 'plugin/daemon_example/daemon_example.cc'
--- a/plugin/daemon_example/daemon_example.cc	2011-08-31 10:39:08 +0000
+++ b/plugin/daemon_example/daemon_example.cc	2011-10-05 08:56:12 +0000
@@ -201,6 +201,7 @@ mysql_declare_plugin(daemon_example)
   0x0100 /* 1.0 */,
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;

=== 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-08-15 14:29:38 +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 'plugin/fulltext/plugin_example.c'
--- a/plugin/fulltext/plugin_example.c	2011-08-31 10:39:08 +0000
+++ b/plugin/fulltext/plugin_example.c	2011-10-05 08:56:12 +0000
@@ -267,7 +267,8 @@ mysql_declare_plugin(ftexample)
   0x0001,                     /* version                         */
   simple_status,              /* status variables                */
   simple_system_variables,    /* system variables                */
-  NULL
+  NULL,
+  0,
 }
 mysql_declare_plugin_end;
 

=== modified file 'plugin/semisync/semisync_master_plugin.cc'
--- a/plugin/semisync/semisync_master_plugin.cc	2011-06-30 15:46:53 +0000
+++ b/plugin/semisync/semisync_master_plugin.cc	2011-08-15 18:12:11 +0000
@@ -429,6 +429,7 @@ mysql_declare_plugin(semi_sync_master)
   0x0100 /* 1.0 */,
   semi_sync_master_status_vars,	/* status variables */
   semi_sync_master_system_vars,	/* system variables */
-  NULL                        /* config options                  */
+  NULL,                         /* config options */
+  0,                            /* flags */
 }
 mysql_declare_plugin_end;

=== modified file 'plugin/semisync/semisync_slave_plugin.cc'
--- a/plugin/semisync/semisync_slave_plugin.cc	2011-05-04 13:07:59 +0000
+++ b/plugin/semisync/semisync_slave_plugin.cc	2011-08-15 18:12:11 +0000
@@ -225,6 +225,7 @@ mysql_declare_plugin(semi_sync_slave)
   0x0100 /* 1.0 */,
   semi_sync_slave_status_vars,	/* status variables */
   semi_sync_slave_system_vars,	/* system variables */
-  NULL                        /* config options                  */
+  NULL,                         /* config options */
+  0,                            /* flags */
 }
 mysql_declare_plugin_end;

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2011-09-02 09:16:56 +0000
+++ b/sql/CMakeLists.txt	2011-10-05 08:56:12 +0000
@@ -101,6 +101,14 @@ ENDIF()
 
 MYSQL_ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE} DESTINATION ${INSTALL_SBINDIR} COMPONENT Server)
 
+IF(APPLE) 
+  # Add CoreServices framework since some dloadable plugins may need it 
+  FIND_LIBRARY(CORESERVICES NAMES CoreServices) 
+  IF(CORESERVICES) 
+    TARGET_LINK_LIBRARIES(mysqld ${CORESERVICES}) 
+  ENDIF() 
+ENDIF() 
+
 IF(NOT WITHOUT_DYNAMIC_PLUGINS)
   SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
   GET_TARGET_PROPERTY(mysqld_link_flags mysqld LINK_FLAGS)

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

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2011-09-02 09:16:56 +0000
+++ b/sql/ha_partition.cc	2011-10-05 08:56:12 +0000
@@ -7209,7 +7209,8 @@ mysql_declare_plugin(partition)
   0x0100, /* 1.0 */
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;
 

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-08-31 10:39:08 +0000
+++ b/sql/item_func.cc	2011-10-05 08:56:12 +0000
@@ -1605,8 +1605,13 @@ longlong Item_func_int_div::val_int()
       return 0;
     }
 
+    my_decimal truncated;
+    const bool do_truncate= true;
+    if (my_decimal_round(E_DEC_FATAL_ERROR, &tmp, 0, do_truncate, &truncated))
+      DBUG_ASSERT(false);
+
     longlong res;
-    if (my_decimal2int(E_DEC_FATAL_ERROR, &tmp, unsigned_flag, &res) &
+    if (my_decimal2int(E_DEC_FATAL_ERROR, &truncated, unsigned_flag, &res) &
         E_DEC_OVERFLOW)
       raise_integer_overflow();
     return res;

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2011-08-31 10:39:08 +0000
+++ b/sql/item_strfunc.cc	2011-10-05 08:56:12 +0000
@@ -2316,7 +2316,7 @@ String *Item_func_format::val_str_ascii(
       return 0; /* purecov: inspected */
     nr= my_double_round(nr, (longlong) dec, FALSE, FALSE);
     str->set_real(nr, dec, &my_charset_numeric);
-    if (isnan(nr))
+    if (isnan(nr) || my_isinf(nr))
       return str;
     str_length=str->length();
   }
@@ -2372,6 +2372,7 @@ String *Item_func_format::val_str_ascii(
       For short values without thousands (<1000)
       replace decimal point to localized value.
     */
+    DBUG_ASSERT(dec_length <= str_length);
     ((char*) str->ptr())[str_length - dec_length]= lc->decimal_point;
   }
   return str;

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2011-08-31 10:39:08 +0000
+++ b/sql/item_timefunc.cc	2011-10-05 08:56:12 +0000
@@ -2747,7 +2747,7 @@ String *Item_time_typecast::val_str(Stri
 
 bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
 {
-  bool res= get_arg0_date(ltime, TIME_FUZZY_DATE);
+  bool res= get_arg0_date(ltime, fuzzy_date);
   ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
   ltime->time_type= MYSQL_TIMESTAMP_DATE;
   return res;

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2011-08-31 10:39:08 +0000
+++ b/sql/log.cc	2011-10-05 08:56:12 +0000
@@ -6616,6 +6616,7 @@ mysql_declare_plugin(binlog)
   0x0100 /* 1.0 */,
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2011-09-21 10:57:59 +0000
+++ b/sql/log_event.cc	2011-10-05 08:56:12 +0000
@@ -70,6 +70,11 @@ static int rows_event_stmt_cleanup(Relay
 
 static const char *HA_ERR(int i)
 {
+  /* 
+    This function should only be called in case of an error
+    was detected 
+   */
+  DBUG_ASSERT(i != 0);
   switch (i) {
   case HA_ERR_KEY_NOT_FOUND: return "HA_ERR_KEY_NOT_FOUND";
   case HA_ERR_FOUND_DUPP_KEY: return "HA_ERR_FOUND_DUPP_KEY";
@@ -122,7 +127,7 @@ static const char *HA_ERR(int i)
   case HA_ERR_CORRUPT_EVENT: return "HA_ERR_CORRUPT_EVENT";
   case HA_ERR_ROWS_EVENT_APPLY : return "HA_ERR_ROWS_EVENT_APPLY";
   }
-  return 0;
+  return "No Error!";
 }
 
 /**
@@ -143,7 +148,7 @@ static void inline slave_rows_error_repo
                                            TABLE *table, const char * type,
                                            const char *log_name, ulong pos)
 {
-  const char *handler_error= HA_ERR(ha_error);
+  const char *handler_error= (ha_error ? HA_ERR(ha_error) : NULL);
   char buff[MAX_SLAVE_ERRMSG], *slider;
   const char *buff_end= buff + sizeof(buff);
   uint len;
@@ -8134,7 +8139,8 @@ int Rows_log_event::do_apply_event(Relay
 
       error= do_exec_row(rli);
 
-      DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
+      if (error)
+        DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
       DBUG_ASSERT(error != HA_ERR_RECORD_DELETED);
 
       table->in_use = old_thd;
@@ -8813,6 +8819,97 @@ Table_map_log_event::~Table_map_log_even
  */
 
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+
+enum enum_tbl_map_status
+{
+  /* no duplicate identifier found */
+  OK_TO_PROCESS= 0,
+
+  /* this table map must be filtered out */
+  FILTERED_OUT= 1,
+
+  /* identifier mapping table with different properties */
+  SAME_ID_MAPPING_DIFFERENT_TABLE= 2,
+  
+  /* a duplicate identifier was found mapping the same table */
+  SAME_ID_MAPPING_SAME_TABLE= 3
+};
+
+/*
+  Checks if this table map event should be processed or not. First
+  it checks the filtering rules, and then looks for duplicate identifiers
+  in the existing list of rli->tables_to_lock.
+
+  It checks that there hasn't been any corruption by verifying that there
+  are no duplicate entries with different properties.
+
+  In some cases, some binary logs could get corrupted, showing several
+  tables mapped to the same table_id, 0 (see: BUG#56226). Thus we do this
+  early sanity check for such cases and avoid that the server crashes 
+  later.
+
+  In some corner cases, the master logs duplicate table map events, i.e.,
+  same id, same database name, same table name (see: BUG#37137). This is
+  different from the above as it's the same table that is mapped again 
+  to the same identifier. Thus we cannot just check for same ids and 
+  assume that the event is corrupted we need to check every property. 
+
+  NOTE: in the event that BUG#37137 ever gets fixed, this extra check 
+        will still be valid because we would need to support old binary 
+        logs anyway.
+
+  @param rli The relay log info reference.
+  @param table_list A list element containing the table to check against.
+  @return OK_TO_PROCESS 
+            if there was no identifier already in rli->tables_to_lock 
+            
+          FILTERED_OUT
+            if the event is filtered according to the filtering rules
+
+          SAME_ID_MAPPING_DIFFERENT_TABLE 
+            if the same identifier already maps a different table in 
+            rli->tables_to_lock
+
+          SAME_ID_MAPPING_SAME_TABLE 
+            if the same identifier already maps the same table in 
+            rli->tables_to_lock.
+*/
+static enum_tbl_map_status
+check_table_map(Relay_log_info const *rli, RPL_TABLE_LIST *table_list)
+{
+  DBUG_ENTER("check_table_map");
+  enum_tbl_map_status res= OK_TO_PROCESS;
+
+  if (rli->sql_thd->slave_thread /* filtering is for slave only */ &&
+      (!rpl_filter->db_ok(table_list->db) ||
+       (rpl_filter->is_on() && !rpl_filter->tables_ok("", table_list))))
+    res= FILTERED_OUT;
+  else
+  {
+    for(RPL_TABLE_LIST *ptr= static_cast<RPL_TABLE_LIST*>(rli->tables_to_lock);
+        ptr; 
+        ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_local))
+    {
+      if (ptr->table_id == table_list->table_id)
+      {
+
+        if (strcmp(ptr->db, table_list->db) || 
+            strcmp(ptr->alias, table_list->table_name) || 
+            ptr->lock_type != TL_WRITE) // the ::do_apply_event always sets TL_WRITE
+          res= SAME_ID_MAPPING_DIFFERENT_TABLE;
+        else
+          res= SAME_ID_MAPPING_SAME_TABLE;
+
+        break;
+      }
+    }
+  }
+
+  DBUG_PRINT("debug", ("check of table map ended up with: %u", res));
+
+  DBUG_RETURN(res);
+}
+
 int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
 {
   RPL_TABLE_LIST *table_list;
@@ -8839,18 +8936,11 @@ int Table_map_log_event::do_apply_event(
                              tname_mem, strlen(tname_mem),
                              tname_mem, TL_WRITE);
 
-  table_list->table_id= m_table_id;
+  table_list->table_id= DBUG_EVALUATE_IF("inject_tblmap_same_id_maps_diff_table", 0, m_table_id);
   table_list->updating= 1;
-
-  int error= 0;
-
-  if (rli->sql_thd->slave_thread /* filtering is for slave only */ &&
-      (!rpl_filter->db_ok(table_list->db) ||
-       (rpl_filter->is_on() && !rpl_filter->tables_ok("", table_list))))
-  {
-    my_free(memory);
-  }
-  else
+  DBUG_PRINT("debug", ("table: %s is mapped to %u", table_list->table_name, table_list->table_id));
+  enum_tbl_map_status tblmap_status= check_table_map(rli, table_list);
+  if (tblmap_status == OK_TO_PROCESS)
   {
     DBUG_ASSERT(thd->lex->query_tables != table_list);
 
@@ -8880,8 +8970,48 @@ int Table_map_log_event::do_apply_event(
     const_cast<Relay_log_info*>(rli)->tables_to_lock_count++;
     /* 'memory' is freed in clear_tables_to_lock */
   }
+  else  // FILTERED_OUT, SAME_ID_MAPPING_*
+  {
+    /*
+      If mapped already but with different properties, we raise an
+      error.
+      If mapped already but with same properties we skip the event.
+      If filtered out we skip the event.
+
+      In all three cases, we need to free the memory previously 
+      allocated.
+     */
+    if (tblmap_status == SAME_ID_MAPPING_DIFFERENT_TABLE)
+    {
+      /*
+        Something bad has happened. We need to stop the slave as strange things
+        could happen if we proceed: slave crash, wrong table being updated, ...
+        As a consequence we push an error in this case.
+       */
+
+      char buf[256];
+
+      my_snprintf(buf, sizeof(buf), 
+                  "Found table map event mapping table id %u which "
+                  "was already mapped but with different settings.",
+                  table_list->table_id);
+
+      if (thd->slave_thread)
+        rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, 
+                    ER(ER_SLAVE_FATAL_ERROR), buf);
+      else
+        /* 
+          For the cases in which a 'BINLOG' statement is set to 
+          execute in a user session 
+         */
+        my_printf_error(ER_SLAVE_FATAL_ERROR, ER(ER_SLAVE_FATAL_ERROR), 
+                        MYF(0), buf);
+    } 
+    
+    my_free(memory);
+  }
 
-  DBUG_RETURN(error);
+  DBUG_RETURN(tblmap_status == SAME_ID_MAPPING_DIFFERENT_TABLE);
 }
 
 Log_event::enum_skip_reason
@@ -9849,7 +9979,8 @@ int Rows_log_event::find_row(const Relay
   restart_rnd_next:
       error= table->file->rnd_next(table->record[0]);
 
-      DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
+      if (error)
+        DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
       switch (error) {
 
       case 0:

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-09-28 10:55:58 +0000
+++ b/sql/mysqld.cc	2011-10-05 08:56:12 +0000
@@ -6754,7 +6754,7 @@ static void usage(void)
   if (!default_collation_name)
     default_collation_name= (char*) default_charset_info->name;
   print_version();
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"));
   puts("Starts the MySQL database server.\n");
   printf("Usage: %s [OPTIONS]\n", my_progname);
   if (!opt_verbose)

=== modified file 'sql/protocol.cc'
--- a/sql/protocol.cc	2011-08-31 10:39:08 +0000
+++ b/sql/protocol.cc	2011-10-05 08:56:12 +0000
@@ -980,8 +980,8 @@ bool Protocol_text::store(const char *fr
 {
   CHARSET_INFO *tocs= this->thd->variables.character_set_results;
 #ifndef DBUG_OFF
-  DBUG_PRINT("info", ("Protocol_text::store field %u (%u): %s", field_pos,
-                      field_count, (length == 0? "" : from)));
+  DBUG_PRINT("info", ("Protocol_text::store field %u (%u): %.*s", field_pos,
+                      field_count, (int) length, (length == 0 ? "" : from)));
   DBUG_ASSERT(field_pos < field_count);
   DBUG_ASSERT(field_types == 0 ||
 	      field_types[field_pos] == MYSQL_TYPE_DECIMAL ||

=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc	2011-09-28 10:20:42 +0000
+++ b/sql/rpl_mi.cc	2011-10-05 08:56:12 +0000
@@ -31,6 +31,8 @@ int init_strvar_from_file(char *var, int
 int init_floatvar_from_file(float* var, IO_CACHE* f, float default_val);
 int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f);
 
+static void init_master_log_pos(Master_info* mi);
+
 Master_info::Master_info(bool is_slave_recovery)
   :Slave_reporting_capability("I/O"),
    ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0), 
@@ -104,6 +106,16 @@ bool Master_info::shall_ignore_server_id
       != NULL;
 }
 
+void Master_info::clear_in_memory_info(bool all)
+{
+  init_master_log_pos(this);
+  if (all)
+  {
+    port= MYSQL_PORT;
+    host[0] = 0; user[0] = 0; password[0] = 0;
+  }
+}
+
 void init_master_log_pos(Master_info* mi)
 {
   DBUG_ENTER("init_master_log_pos");
@@ -238,7 +250,7 @@ file '%s')", fname);
     }
 
     mi->fd = fd;
-    init_master_log_pos(mi);
+    mi->clear_in_memory_info(false);
 
   }
   else // file exists

=== modified file 'sql/rpl_mi.h'
--- a/sql/rpl_mi.h	2011-09-28 10:20:42 +0000
+++ b/sql/rpl_mi.h	2011-10-05 08:56:12 +0000
@@ -62,6 +62,7 @@ class Master_info : public Slave_reporti
   Master_info(bool is_slave_recovery);
   ~Master_info();
   bool shall_ignore_server_id(ulong s_id);
+  void clear_in_memory_info(bool all);
 
   /* the variables below are needed because we can change masters on the fly */
   char master_log_name[FN_REFLEN];
@@ -117,7 +118,6 @@ class Master_info : public Slave_reporti
   char bind_addr[HOSTNAME_LENGTH+1];
 #endif
 };
-void init_master_log_pos(Master_info* mi);
 int init_master_info(Master_info* mi, const char* master_info_fname,
 		     const char* slave_info_fname,
 		     bool abort_if_no_master_info_file,

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2011-09-27 11:50:55 +0000
+++ b/sql/share/errmsg-utf8.txt	2011-10-05 08:56:12 +0000
@@ -6414,3 +6414,9 @@ ER_ERROR_IN_TRIGGER_BODY
 
 ER_ERROR_IN_UNKNOWN_TRIGGER_BODY
   eng "Unknown trigger has an error in its body: '%-.256s'"
+
+ER_PLUGIN_NO_UNINSTALL
+  eng "Plugin '%s' is marked as not dynamically uninstallable. You have to stop the server to uninstall it."
+
+ER_PLUGIN_NO_INSTALL
+  eng "Plugin '%s' is marked as not dynamically installable. You have to stop the server to install it."

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2011-09-21 14:06:04 +0000
+++ b/sql/sql_acl.cc	2011-10-05 08:56:12 +0000
@@ -1896,17 +1896,17 @@ bool change_password(THD *thd, const cha
     goto end;
   }
 
+  /* update loaded acl entry: */
+  set_user_salt(acl_user, new_password, new_password_len);
+
   if (my_strcasecmp(system_charset_info, acl_user->plugin.str,
                     native_password_plugin_name.str) &&
       my_strcasecmp(system_charset_info, acl_user->plugin.str,
                     old_password_plugin_name.str))
-  {
     push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
                  ER_SET_PASSWORD_AUTH_PLUGIN, ER(ER_SET_PASSWORD_AUTH_PLUGIN));
-  }
-  /* update loaded acl entry: */
-  set_user_salt(acl_user, new_password, new_password_len);
-  set_user_plugin(acl_user, new_password_len);
+  else
+    set_user_plugin(acl_user, new_password_len);
 
   if (update_user_table(thd, table,
 			acl_user->host.hostname ? acl_user->host.hostname : "",
@@ -9157,24 +9157,18 @@ static ulong parse_client_handshake_pack
 
 
 /**
-  Make sure that when sending plugin supplued data to the client they
+  Make sure that when sending plugin supplied data to the client they
   are not considered a special out-of-band command, like e.g. 
-  \255 (error) or \254 (change user request packet).
-  To avoid this we send plugin data packets starting with one of these
-  2 bytes "wrapped" in a command \1. 
-  For the above reason we have to wrap plugin data packets starting with
-  \1 as well.
+  \255 (error) or \254 (change user request packet) or \0 (OK).
+  To avoid this the server will send all plugin data packets "wrapped" 
+  in a command \1.
+  Note that the client will continue sending its replies unrwapped.
 */
 
-#define IS_OUT_OF_BAND_PACKET(packet,packet_len) \
-  ((packet_len) > 0 && \
-   (*(packet) == 1 || *(packet) == 255 || *(packet) == 254))
-
 static inline int 
 wrap_plguin_data_into_proper_command(NET *net, 
                                      const uchar *packet, int packet_len)
 {
-  DBUG_ASSERT(IS_OUT_OF_BAND_PACKET(packet, packet_len));
   return net_write_command(net, 1, (uchar *) "", 0, packet, packet_len);
 }
 
@@ -9211,13 +9205,8 @@ static int server_mpvio_write_packet(MYS
     res= send_server_handshake_packet(mpvio, (char*) packet, packet_len);
   else if (mpvio->status == MPVIO_EXT::RESTART)
     res= send_plugin_request_packet(mpvio, packet, packet_len);
-  else if (IS_OUT_OF_BAND_PACKET(packet, packet_len))
-    res= wrap_plguin_data_into_proper_command(mpvio->net, packet, packet_len);
   else
-  {
-    res= my_net_write(mpvio->net, packet, packet_len) ||
-         net_flush(mpvio->net);
-  }
+    res= wrap_plguin_data_into_proper_command(mpvio->net, packet, packet_len);
   mpvio->packets_written++;
   DBUG_RETURN(res);
 }
@@ -9988,7 +9977,8 @@ mysql_declare_plugin(mysql_password)
   0x0100,                                       /* Version (1.0)    */
   NULL,                                         /* status variables */
   NULL,                                         /* system variables */
-  NULL                                          /* config options   */
+  NULL,                                         /* config options   */
+  0,                                            /* flags            */
 },
 {
   MYSQL_AUTHENTICATION_PLUGIN,                  /* type constant    */
@@ -10002,7 +9992,8 @@ mysql_declare_plugin(mysql_password)
   0x0100,                                       /* Version (1.0)    */
   NULL,                                         /* status variables */
   NULL,                                         /* system variables */
-  NULL                                          /* config options   */
+  NULL,                                         /* config options   */
+  0,                                            /* flags            */
 }
 mysql_declare_plugin_end;
 

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_base.cc	2011-10-05 08:56:12 +0000
@@ -89,6 +89,69 @@ bool No_such_table_error_handler::safely
   return ((m_handled_errors > 0) && (m_unhandled_errors == 0));
 }
 
+
+/**
+  This internal handler is used to trap ER_NO_SUCH_TABLE and
+  ER_WRONG_MRG_TABLE errors during CHECK/REPAIR TABLE for MERGE
+  tables.
+*/
+
+class Repair_mrg_table_error_handler : public Internal_error_handler
+{
+public:
+  Repair_mrg_table_error_handler()
+    : m_handled_errors(false), m_unhandled_errors(false)
+  {}
+
+  bool handle_condition(THD *thd,
+                        uint sql_errno,
+                        const char* sqlstate,
+                        MYSQL_ERROR::enum_warning_level level,
+                        const char* msg,
+                        MYSQL_ERROR ** cond_hdl);
+
+  /**
+    Returns TRUE if there were ER_NO_SUCH_/WRONG_MRG_TABLE and there
+    were no unhandled errors. FALSE otherwise.
+  */
+  bool safely_trapped_errors()
+  {
+    /*
+      Check for m_handled_errors is here for extra safety.
+      It can be useful in situation when call to open_table()
+      fails because some error which was suppressed by another
+      error handler (e.g. in case of MDL deadlock which we
+      decided to solve by back-off and retry).
+    */
+    return (m_handled_errors && (! m_unhandled_errors));
+  }
+
+private:
+  bool m_handled_errors;
+  bool m_unhandled_errors;
+};
+
+
+bool
+Repair_mrg_table_error_handler::handle_condition(THD *,
+                                                 uint sql_errno,
+                                                 const char*,
+                                                 MYSQL_ERROR::enum_warning_level level,
+                                                 const char*,
+                                                 MYSQL_ERROR ** cond_hdl)
+{
+  *cond_hdl= NULL;
+  if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_WRONG_MRG_TABLE)
+  {
+    m_handled_errors= true;
+    return TRUE;
+  }
+
+  m_unhandled_errors= true;
+  return FALSE;
+}
+
+
 /**
   @defgroup Data_Dictionary Data Dictionary
   @{
@@ -4395,6 +4458,20 @@ open_and_process_table(THD *thd, LEX *le
     thd->pop_internal_handler();
     safe_to_ignore_table= no_such_table_handler.safely_trapped_errors();
   }
+  else if (tables->parent_l && (thd->open_options & HA_OPEN_FOR_REPAIR))
+  {
+    /*
+      Also fail silently for underlying tables of a MERGE table if this
+      table is opened for CHECK/REPAIR TABLE statement. This is needed
+      to provide complete list of problematic underlying tables in
+      CHECK/REPAIR TABLE output.
+    */
+    Repair_mrg_table_error_handler repair_mrg_table_handler;
+    thd->push_internal_handler(&repair_mrg_table_handler);
+    error= open_table(thd, tables, new_frm_mem, ot_ctx);
+    thd->pop_internal_handler();
+    safe_to_ignore_table= repair_mrg_table_handler.safely_trapped_errors();
+  }
   else
     error= open_table(thd, tables, new_frm_mem, ot_ctx);
 
@@ -7874,7 +7951,7 @@ bool setup_fields(THD *thd, Item **ref_p
     if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM &&
 	sum_func_list)
       item->split_sum_func(thd, ref_pointer_array, *sum_func_list);
-    thd->used_tables|= item->used_tables();
+    thd->lex->used_tables|= item->used_tables();
     thd->lex->current_select->cur_pos_in_select_list++;
   }
   thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
@@ -8221,7 +8298,7 @@ insert_fields(THD *thd, Name_resolution_
       views and natural joins this update is performed inside the loop below.
     */
     if (table)
-      thd->used_tables|= table->map;
+      thd->lex->used_tables|= table->map;
 
     /*
       Initialize a generic field iterator for the current table reference.
@@ -8306,7 +8383,7 @@ insert_fields(THD *thd, Name_resolution_
           field_table= nj_col->table_ref->table;
           if (field_table)
           {
-            thd->used_tables|= field_table->map;
+            thd->lex->used_tables|= field_table->map;
             field_table->covering_keys.intersect(field->part_of_key);
             field_table->merge_keys.merge(field->part_of_key);
             field_table->used_fields++;
@@ -8314,7 +8391,7 @@ insert_fields(THD *thd, Name_resolution_
         }
       }
       else
-        thd->used_tables|= item->used_tables();
+        thd->lex->used_tables|= item->used_tables();
       thd->lex->current_select->cur_pos_in_select_list++;
     }
     /*

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-09-21 10:57:59 +0000
+++ b/sql/sql_class.cc	2011-10-05 08:56:12 +0000
@@ -520,11 +520,11 @@ const char *set_thd_proc_info(void *thd_
     thd= current_thd;
 
   const char *old_info= thd->proc_info;
-  const char *basename= calling_file ? base_name(calling_file) : NULL;
-  DBUG_PRINT("proc_info", ("%s:%d  %s", basename, calling_line, info));
+  DBUG_PRINT("proc_info", ("%s:%d  %s", calling_file, calling_line, info));
 
 #if defined(ENABLED_PROFILING)
-  thd->profiling.status_change(info, calling_function, basename, calling_line);
+  thd->profiling.status_change(info,
+                               calling_function, calling_file, calling_line);
 #endif
   thd->proc_info= info;
   return old_info;
@@ -641,7 +641,7 @@ char *thd_security_context(THD *thd, cha
 {
   String str(buffer, length, &my_charset_latin1);
   const Security_context *sctx= &thd->main_security_ctx;
-  char header[64];
+  char header[256];
   int len;
   /*
     The pointers thd->query and thd->proc_info might change since they are
@@ -655,8 +655,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);
 
@@ -798,7 +798,6 @@ THD::THD()
   is_slave_error= thread_specific_used= FALSE;
   my_hash_clear(&handler_tables_hash);
   tmp_table=0;
-  used_tables=0;
   cuted_fields= 0L;
   sent_row_count= 0L;
   limit_found_rows= 0;

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-09-28 10:55:58 +0000
+++ b/sql/sql_class.h	2011-10-05 08:56:12 +0000
@@ -1990,13 +1990,6 @@ public:
   */
   ha_rows    examined_row_count;
 
-  /*
-    The set of those tables whose fields are referenced in all subqueries
-    of the query.
-    TODO: possibly this it is incorrect to have used tables in THD because
-    with more than one subquery, it is not clear what does the field mean.
-  */
-  table_map  used_tables;
   USER_CONN *user_connect;
   CHARSET_INFO *db_charset;
   Warning_info *warning_info;

=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_error.cc	2011-10-05 08:56:12 +0000
@@ -803,14 +803,16 @@ uint32 convert_error_message(char *to, u
   my_wc_t     wc;
   const uchar *from_end= (const uchar*) from+from_length;
   char *to_start= to;
-  uchar *to_end= (uchar*) to+to_length;
+  uchar *to_end;
   my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc;
   my_charset_conv_wc_mb wc_mb;
   uint error_count= 0;
   uint length;
 
   DBUG_ASSERT(to_length > 0);
+  /* Make room for the null terminator. */
   to_length--;
+  to_end= (uchar*) (to + to_length);
 
   if (!to_cs || from_cs == to_cs || to_cs == &my_charset_bin)
   {

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_insert.cc	2011-10-05 08:56:12 +0000
@@ -717,7 +717,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   lock_type= table_list->lock_type;
 
   thd_proc_info(thd, "init");
-  thd->used_tables=0;
+  thd->lex->used_tables=0;
   values= its++;
   value_count= values->elements;
 
@@ -872,7 +872,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
     }
     else
     {
-      if (thd->used_tables)			// Column used in values()
+      if (thd->lex->used_tables)		      // Column used in values()
 	restore_record(table,s->default_values);	// Get empty record
       else
       {
@@ -1610,9 +1610,6 @@ int write_record(THD *thd, TABLE *table,
           goto before_trg_err;
 
         table->file->restore_auto_increment(prev_insert_id);
-        if (table->next_number_field)
-          table->file->adjust_next_insert_id_after_explicit_value(
-            table->next_number_field->val_int());
         info->touched++;
         if (!records_are_comparable(table) || compare_records(table))
         {
@@ -1649,8 +1646,6 @@ int write_record(THD *thd, TABLE *table,
         if (table->next_number_field)
           table->file->adjust_next_insert_id_after_explicit_value(
             table->next_number_field->val_int());
-        info->touched++;
-
         goto ok_or_after_trg_err;
       }
       else /* DUP_REPLACE */

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_lex.cc	2011-10-05 08:56:12 +0000
@@ -434,6 +434,7 @@ void lex_start(THD *thd)
   lex->server_options.port= -1;
 
   lex->is_lex_started= TRUE;
+  lex->used_tables= 0;
   DBUG_VOID_RETURN;
 }
 
@@ -2123,6 +2124,9 @@ bool st_select_lex::setup_ref_array(THD 
   if (ref_pointer_array)
     return 0;
 
+  // find_order_in_list() may need some extra space, so multiply by two.
+  order_group_num*= 2;
+
   /*
     We have to create array in prepared statement memory if it is
     prepared statement

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2011-08-31 10:39:08 +0000
+++ b/sql/sql_lex.h	2011-10-05 08:56:12 +0000
@@ -297,6 +297,10 @@ typedef struct st_lex_master_info
 #endif
 } LEX_MASTER_INFO;
 
+typedef struct st_lex_reset_slave
+{
+  bool all;
+} LEX_RESET_SLAVE;
 
 enum sub_select_type
 {
@@ -2278,6 +2282,7 @@ struct LEX: public Query_tables_list
   LEX_MASTER_INFO mi;				// used by CHANGE MASTER
   LEX_SERVER_OPTIONS server_options;
   USER_RESOURCES mqh;
+  LEX_RESET_SLAVE reset_slave_info;
   ulong type;
   /*
     This variable is used in post-parse stage to declare that sum-functions,
@@ -2437,6 +2442,16 @@ struct LEX: public Query_tables_list
   bool escape_used;
   bool is_lex_started; /* If lex_start() did run. For debugging. */
 
+  /*
+    The set of those tables whose fields are referenced in all subqueries
+    of the query.
+    TODO: possibly this it is incorrect to have used tables in LEX because
+    with subquery, it is not clear what does the field mean. To fix this
+    we should aggregate used tables information for selected expressions
+    into the select_lex.
+  */
+  table_map  used_tables;
+
   LEX();
 
   virtual ~LEX()

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_plugin.cc	2011-10-05 08:56:12 +0000
@@ -539,6 +539,11 @@ static st_plugin_dl *plugin_dl_add(const
 #endif
     }
 
+    /*
+      What's the purpose of this loop? If the goal is to catch a
+      missing 0 record at the end of a list, it will fail miserably
+      since the compiler is likely to optimize this away. /Matz
+     */
     for (i= 0;
          ((struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
          i++)
@@ -567,6 +572,23 @@ static st_plugin_dl *plugin_dl_add(const
   }
   plugin_dl.plugins= (struct st_mysql_plugin *)sym;
 
+  /*
+    If report is REPORT_TO_USER, we were called from
+    mysql_install_plugin. Otherwise, we are called directly or
+    indirectly from plugin_init.
+   */
+  if (report == REPORT_TO_USER)
+  {
+    st_mysql_plugin *plugin= plugin_dl.plugins;
+    for ( ; plugin->info ; ++plugin)
+      if (plugin->flags & PLUGIN_OPT_NO_INSTALL)
+      {
+        report_error(report, ER_PLUGIN_NO_INSTALL, plugin->name);
+        free_plugin_mem(&plugin_dl);
+        DBUG_RETURN(0);
+   }
+  }
+
   /* Duplicate and convert dll name */
   plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1;
   if (! (plugin_dl.dl.str= (char*) my_malloc(plugin_dl.dl.length, MYF(0))))
@@ -1884,6 +1906,16 @@ bool mysql_uninstall_plugin(THD *thd, co
     my_error(ER_PLUGIN_IS_PERMANENT, MYF(0), name->str);
     goto err;
   }
+  /*
+    Error message for ER_PLUGIN_IS_PERMANENT is not suitable for
+    plugins marked as not dynamically uninstallable, so we have a
+    separate one instead of changing the old one.
+   */
+  if (plugin->plugin->flags & PLUGIN_OPT_NO_UNINSTALL)
+  {
+    my_error(ER_PLUGIN_NO_UNINSTALL, MYF(0), plugin->plugin->name);
+    goto err;
+  }
 
   plugin->state= PLUGIN_IS_DELETED;
   if (plugin->ref_count)

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_prepare.cc	2011-10-05 08:56:12 +0000
@@ -1474,7 +1474,7 @@ static int mysql_test_select(Prepared_st
   if (open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL))
     goto error;
 
-  thd->used_tables= 0;                        // Updated by setup_fields
+  thd->lex->used_tables= 0;                        // Updated by setup_fields
 
   /*
     JOIN::prepare calls
@@ -1646,7 +1646,7 @@ static bool select_like_stmt_test(Prepar
   if (specific_prepare && (*specific_prepare)(thd))
     DBUG_RETURN(TRUE);
 
-  thd->used_tables= 0;                        // Updated by setup_fields
+  thd->lex->used_tables= 0;                        // Updated by setup_fields
 
   /* Calls JOIN::prepare */
   DBUG_RETURN(lex->unit.prepare(thd, 0, setup_tables_done_option));

=== modified file 'sql/sql_profile.cc'
--- a/sql/sql_profile.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_profile.cc	2011-10-05 08:56:12 +0000
@@ -294,7 +294,7 @@ void QUERY_PROFILE::new_status(const cha
   DBUG_ASSERT(status_arg != NULL);
 
   if ((function_arg != NULL) && (file_arg != NULL))
-    prof= new PROF_MEASUREMENT(this, status_arg, function_arg, file_arg, line_arg);
+    prof= new PROF_MEASUREMENT(this, status_arg, function_arg, base_name(file_arg), line_arg);
   else
     prof= new PROF_MEASUREMENT(this, status_arg);
 

=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_repl.cc	2011-10-05 08:56:12 +0000
@@ -1285,8 +1285,9 @@ int reset_slave(THD *thd, Master_info* m
     goto err;
   }
 
-  /* Clear master's log coordinates */
-  init_master_log_pos(mi);
+  /* Clear master's log coordinates and associated information */
+  mi->clear_in_memory_info(thd->lex->reset_slave_info.all);
+
   /*
      Reset errors (the idea is that we forget about the
      old master).

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-09-14 13:56:17 +0000
+++ b/sql/sql_select.cc	2011-10-05 08:56:12 +0000
@@ -450,7 +450,7 @@ fix_inner_refs(THD *thd, List<Item> &all
 
     if (!ref->fixed && ref->fix_fields(thd, 0))
       return TRUE;
-    thd->used_tables|= item->used_tables();
+    thd->lex->used_tables|= item->used_tables();
   }
   return false;
 }
@@ -1695,7 +1695,7 @@ JOIN::optimize()
 
     if (exec_tmp_table1->distinct)
     {
-      table_map used_tables= thd->used_tables;
+      table_map used_tables= thd->lex->used_tables;
       JOIN_TAB *last_join_tab= join_tab+tables-1;
       do
       {
@@ -2661,7 +2661,7 @@ mysql_select(THD *thd, Item ***rref_poin
     if (!(join= new JOIN(thd, fields, select_options, result)))
 	DBUG_RETURN(TRUE);
     thd_proc_info(thd, "init");
-    thd->used_tables=0;                         // Updated by setup_fields
+    thd->lex->used_tables=0;                         // Updated by setup_fields
     err= join->prepare(rref_pointer_array, tables, wild_num,
                        conds, og_num, order, group, having, proc_param,
                        select_lex, unit);
@@ -17439,7 +17439,7 @@ static void select_describe(JOIN *join, 
 	  need_order=0;
 	  extra.append(STRING_WITH_LEN("; Using filesort"));
 	}
-	if (distinct & test_all_bits(used_tables,thd->used_tables))
+	if (distinct & test_all_bits(used_tables, thd->lex->used_tables))
 	  extra.append(STRING_WITH_LEN("; Distinct"));
 
         for (uint part= 0; part < tab->ref.key_parts; part++)

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_show.cc	2011-10-05 08:56:12 +0000
@@ -3181,6 +3181,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;
@@ -3363,6 +3367,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
@@ -3380,6 +3387,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;
@@ -3529,13 +3537,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;
 }
@@ -3786,6 +3808,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_union.cc'
--- a/sql/sql_union.cc	2011-08-31 10:39:08 +0000
+++ b/sql/sql_union.cc	2011-10-05 08:56:12 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -404,15 +404,27 @@ bool st_select_lex_unit::prepare(THD *th
 	  fake_select_lex->table_list.empty();
 	  DBUG_RETURN(TRUE);
 	}
+
+        /*
+          Fake st_select_lex should have item list for correct ref_array
+          allocation.
+        */
 	fake_select_lex->item_list= item_list;
 
 	thd_arg->lex->current_select= fake_select_lex;
+
+        /*
+          We need to add up n_sum_items in order to make the correct
+          allocation in setup_ref_array().
+        */
+        fake_select_lex->n_child_sum_items+= global_parameters->n_sum_items;
+
 	saved_error= fake_select_lex->join->
 	  prepare(&fake_select_lex->ref_pointer_array,
 		  fake_select_lex->table_list.first,
 		  0, 0,
-		  fake_select_lex->order_list.elements,
-		  fake_select_lex->order_list.first,
+                  global_parameters->order_list.elements, // og_num
+                  global_parameters->order_list.first,    // order
 		  NULL, NULL, NULL,
 		  fake_select_lex, this);
 	fake_select_lex->table_list.empty();
@@ -581,11 +593,21 @@ bool st_select_lex_unit::exec()
 	}
         fake_select_lex->join->no_const_tables= TRUE;
 
-	/*
-	  Fake st_select_lex should have item list for correctref_array
-	  allocation.
-	*/
-	fake_select_lex->item_list= item_list;
+        /*
+          Fake st_select_lex should have item list for correct ref_array
+          allocation.
+        */
+        fake_select_lex->item_list= item_list;
+
+        /*
+          We need to add up n_sum_items in order to make the correct
+          allocation in setup_ref_array().
+          Don't add more sum_items if we have already done JOIN::prepare
+          for this (with a different join object)
+        */
+        if (!fake_select_lex->ref_pointer_array)
+          fake_select_lex->n_child_sum_items+= global_parameters->n_sum_items;
+
         saved_error= mysql_select(thd, &fake_select_lex->ref_pointer_array,
                               &result_table_list,
                               0, item_list, NULL,

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-08-31 10:39:08 +0000
+++ b/sql/sql_yacc.yy	2011-10-05 08:56:12 +0000
@@ -8806,6 +8806,11 @@ function_call_generic:
             Create_func *builder;
             Item *item= NULL;
 
+            if (check_routine_name(&$1))
+            {
+              MYSQL_YYABORT;
+            }
+
             /*
               Implementation note:
               names are resolved with the following order:
@@ -8869,6 +8874,16 @@ function_call_generic:
               version() (a vendor can specify any schema).
             */
 
+            if (!$1.str || check_db_name(&$1))
+            {
+              my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
+              MYSQL_YYABORT;
+            }
+            if (check_routine_name(&$3))
+            {
+              MYSQL_YYABORT;
+            }
+
             builder= find_qualified_function_builder(thd);
             DBUG_ASSERT(builder);
             item= builder->create(thd, $1, $3, true, $5);
@@ -11490,7 +11505,10 @@ flush_option:
         | STATUS_SYM
           { Lex->type|= REFRESH_STATUS; }
         | SLAVE
-          { Lex->type|= REFRESH_SLAVE; }
+          { 
+            Lex->type|= REFRESH_SLAVE;
+            Lex->reset_slave_info.all= false;
+          }
         | MASTER_SYM
           { Lex->type|= REFRESH_MASTER; }
         | DES_KEY_FILE
@@ -11521,10 +11539,16 @@ reset_options:
 
 reset_option:
           SLAVE               { Lex->type|= REFRESH_SLAVE; }
+          slave_reset_options { }
         | MASTER_SYM          { Lex->type|= REFRESH_MASTER; }
         | QUERY_SYM CACHE_SYM { Lex->type|= REFRESH_QUERY_CACHE;}
         ;
 
+slave_reset_options:
+          /* empty */ { Lex->reset_slave_info.all= false; }
+        | ALL         { Lex->reset_slave_info.all= true; }
+        ;
+
 purge:
           PURGE
           {

=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc	2011-08-31 10:39:08 +0000
+++ b/storage/archive/ha_archive.cc	2011-10-05 08:56:12 +0000
@@ -1766,7 +1766,8 @@ mysql_declare_plugin(archive)
   0x0300 /* 3.0 */,
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;
 

=== modified file 'storage/blackhole/ha_blackhole.cc'
--- a/storage/blackhole/ha_blackhole.cc	2011-08-31 10:39:08 +0000
+++ b/storage/blackhole/ha_blackhole.cc	2011-10-05 08:56:12 +0000
@@ -448,6 +448,7 @@ mysql_declare_plugin(blackhole)
   0x0100 /* 1.0 */,
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;

=== modified file 'storage/csv/ha_tina.cc'
--- a/storage/csv/ha_tina.cc	2011-08-31 10:39:08 +0000
+++ b/storage/csv/ha_tina.cc	2011-10-05 08:56:12 +0000
@@ -1766,7 +1766,8 @@ mysql_declare_plugin(csv)
   0x0100 /* 1.0 */,
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;
 

=== modified file 'storage/example/ha_example.cc'
--- a/storage/example/ha_example.cc	2011-08-31 10:39:08 +0000
+++ b/storage/example/ha_example.cc	2011-10-05 08:56:12 +0000
@@ -1008,6 +1008,7 @@ mysql_declare_plugin(example)
   0x0001 /* 0.1 */,
   func_status,                                  /* status variables */
   example_system_variables,                     /* system variables */
-  NULL                                          /* config options */
+  NULL,                                         /* config options */
+  0,                                            /* flags */
 }
 mysql_declare_plugin_end;

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2011-08-31 10:39:08 +0000
+++ b/storage/federated/ha_federated.cc	2011-10-05 08:56:12 +0000
@@ -3481,6 +3481,7 @@ mysql_declare_plugin(federated)
   0x0100 /* 1.0 */,
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;

=== modified file 'storage/heap/ha_heap.cc'
--- a/storage/heap/ha_heap.cc	2011-08-31 10:39:08 +0000
+++ b/storage/heap/ha_heap.cc	2011-10-05 08:56:12 +0000
@@ -825,6 +825,7 @@ mysql_declare_plugin(heap)
   0x0100, /* 1.0 */
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;

=== modified file 'storage/innobase/btr/btr0pcur.c'
--- a/storage/innobase/btr/btr0pcur.c	2010-10-01 13:36:35 +0000
+++ b/storage/innobase/btr/btr0pcur.c	2011-08-10 12:03:33 +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
@@ -356,33 +356,6 @@ btr_pcur_restore_position_func(
 	return(FALSE);
 }
 
-/**************************************************************//**
-If the latch mode of the cursor is BTR_LEAF_SEARCH or BTR_LEAF_MODIFY,
-releases the page latch and bufferfix reserved by the cursor.
-NOTE! In the case of BTR_LEAF_MODIFY, there should not exist changes
-made by the current mini-transaction to the data protected by the
-cursor latch, as then the latch must not be released until mtr_commit. */
-UNIV_INTERN
-void
-btr_pcur_release_leaf(
-/*==================*/
-	btr_pcur_t*	cursor, /*!< in: persistent cursor */
-	mtr_t*		mtr)	/*!< in: mtr */
-{
-	buf_block_t*	block;
-
-	ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
-	ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
-
-	block = btr_pcur_get_block(cursor);
-
-	btr_leaf_page_release(block, cursor->latch_mode, mtr);
-
-	cursor->latch_mode = BTR_NO_LATCHES;
-
-	cursor->pos_state = BTR_PCUR_WAS_POSITIONED;
-}
-
 /*********************************************************//**
 Moves the persistent cursor to the first record on the next page. Releases the
 latch on the current page, and bufferunfixes it. Note that there must not be

=== modified file 'storage/innobase/buf/buf0buf.c'
--- a/storage/innobase/buf/buf0buf.c	2011-06-23 12:57:25 +0000
+++ b/storage/innobase/buf/buf0buf.c	2011-07-19 14:54:59 +0000
@@ -400,6 +400,7 @@ buf_get_total_stat(
 		tot_stat->n_pages_read += buf_stat->n_pages_read;
 		tot_stat->n_pages_written += buf_stat->n_pages_written;
 		tot_stat->n_pages_created += buf_stat->n_pages_created;
+		tot_stat->n_ra_pages_read_rnd += buf_stat->n_ra_pages_read_rnd;
 		tot_stat->n_ra_pages_read += buf_stat->n_ra_pages_read;
 		tot_stat->n_ra_pages_evicted += buf_stat->n_ra_pages_evicted;
 		tot_stat->n_pages_made_young += buf_stat->n_pages_made_young;
@@ -2358,6 +2359,9 @@ loop2:
 		}
 
 		if (buf_read_page(space, zip_size, offset)) {
+			buf_read_ahead_random(space, zip_size, offset,
+					      ibuf_inside(mtr));
+
 			retries = 0;
 		} else if (retries < BUF_PAGE_READ_MAX_RETRIES) {
 			++retries;
@@ -4381,6 +4385,7 @@ buf_stats_aggregate_pool_info(
 	total_info->n_pages_created += pool_info->n_pages_created;
 	total_info->n_pages_written += pool_info->n_pages_written;
 	total_info->n_page_gets += pool_info->n_page_gets;
+	total_info->n_ra_pages_read_rnd += pool_info->n_ra_pages_read_rnd;
 	total_info->n_ra_pages_read += pool_info->n_ra_pages_read;
 	total_info->n_ra_pages_evicted += pool_info->n_ra_pages_evicted;
 	total_info->page_made_young_rate += pool_info->page_made_young_rate;
@@ -4393,6 +4398,7 @@ buf_stats_aggregate_pool_info(
 	total_info->page_read_delta += pool_info->page_read_delta;
 	total_info->young_making_delta += pool_info->young_making_delta;
 	total_info->not_young_making_delta += pool_info->not_young_making_delta;
+	total_info->pages_readahead_rnd_rate += pool_info->pages_readahead_rnd_rate;
 	total_info->pages_readahead_rate += pool_info->pages_readahead_rate;
 	total_info->pages_evicted_rate += pool_info->pages_evicted_rate;
 	total_info->unzip_lru_len += pool_info->unzip_lru_len;
@@ -4470,6 +4476,7 @@ buf_stats_get_pool_info(
 
 	pool_info->n_page_gets = buf_pool->stat.n_page_gets;
 
+	pool_info->n_ra_pages_read_rnd = buf_pool->stat.n_ra_pages_read_rnd;
 	pool_info->n_ra_pages_read = buf_pool->stat.n_ra_pages_read;
 
 	pool_info->n_ra_pages_evicted = buf_pool->stat.n_ra_pages_evicted;
@@ -4509,6 +4516,10 @@ buf_stats_get_pool_info(
 			buf_pool->stat.n_pages_not_made_young
 			- buf_pool->old_stat.n_pages_not_made_young;
 	}
+	pool_info->pages_readahead_rnd_rate =
+		 (buf_pool->stat.n_ra_pages_read_rnd
+		  - buf_pool->old_stat.n_ra_pages_read_rnd) / time_elapsed;
+
 
 	pool_info->pages_readahead_rate =
 		 (buf_pool->stat.n_ra_pages_read
@@ -4594,9 +4605,12 @@ buf_print_io_instance(
 
 	/* Statistics about read ahead algorithm */
 	fprintf(file, "Pages read ahead %.2f/s,"
-		" evicted without access %.2f/s\n",
+		" evicted without access %.2f/s,"
+		" Random read ahead %.2f/s\n",
+
 		pool_info->pages_readahead_rate,
-		pool_info->pages_evicted_rate);
+		pool_info->pages_evicted_rate,
+		pool_info->pages_readahead_rnd_rate);
 
 	/* Print some values to help us with visualizing what is
 	happening with LRU eviction. */

=== modified file 'storage/innobase/buf/buf0rea.c'
--- a/storage/innobase/buf/buf0rea.c	2011-04-15 13:46:11 +0000
+++ b/storage/innobase/buf/buf0rea.c	2011-07-19 14:54:59 +0000
@@ -40,8 +40,10 @@ Created 11/5/1995 Heikki Tuuri
 #include "mysql/plugin.h"
 #include "mysql/service_thd_wait.h"
 
-/** The linear read-ahead area size */
-#define	BUF_READ_AHEAD_LINEAR_AREA	BUF_READ_AHEAD_AREA
+/** There must be at least this many pages in buf_pool in the area to start
+a random read-ahead */
+#define BUF_READ_AHEAD_RANDOM_THRESHOLD(b)	\
+				(5 + BUF_READ_AHEAD_AREA(b) / 8)
 
 /** If there are buf_pool->curr_size per the number below pending reads, then
 read-ahead is not done: this is to prevent flooding the buffer pool with
@@ -162,6 +164,171 @@ buf_read_page_low(
 }
 
 /********************************************************************//**
+Applies a random read-ahead in buf_pool if there are at least a threshold
+value of accessed pages from the random read-ahead area. Does not read any
+page, not even the one at the position (space, offset), if the read-ahead
+mechanism is not activated. NOTE 1: the calling thread may own latches on
+pages: to avoid deadlocks this function must be written such that it cannot
+end up waiting for these latches! NOTE 2: the calling thread must want
+access to the page given: this rule is set to prevent unintended read-aheads
+performed by ibuf routines, a situation which could result in a deadlock if
+the OS does not support asynchronous i/o.
+@return number of page read requests issued; NOTE that if we read ibuf
+pages, it may happen that the page at the given page number does not
+get read even if we return a positive value!
+@return	number of page read requests issued */
+UNIV_INTERN
+ulint
+buf_read_ahead_random(
+/*==================*/
+	ulint	space,		/*!< in: space id */
+	ulint	zip_size,	/*!< in: compressed page size in bytes,
+				or 0 */
+	ulint	offset,		/*!< in: page number of a page which
+				the current thread wants to access */
+	ibool	inside_ibuf)	/*!< in: TRUE if we are inside ibuf
+				routine */
+{
+	buf_pool_t*	buf_pool = buf_pool_get(space, offset);
+	ib_int64_t	tablespace_version;
+	ulint		recent_blocks	= 0;
+	ulint		ibuf_mode;
+	ulint		count;
+	ulint		low, high;
+	ulint		err;
+	ulint		i;
+	const ulint	buf_read_ahead_random_area
+				= BUF_READ_AHEAD_AREA(buf_pool);
+
+	if (!srv_random_read_ahead) {
+		/* Disabled by user */
+		return(0);
+	}
+
+	if (srv_startup_is_before_trx_rollback_phase) {
+		/* No read-ahead to avoid thread deadlocks */
+		return(0);
+	}
+
+	if (ibuf_bitmap_page(zip_size, offset)
+	    || trx_sys_hdr_page(space, offset)) {
+
+		/* If it is an ibuf bitmap page or trx sys hdr, we do
+		no read-ahead, as that could break the ibuf page access
+		order */
+
+		return(0);
+	}
+
+	/* Remember the tablespace version before we ask te tablespace size
+	below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we
+	do not try to read outside the bounds of the tablespace! */
+
+	tablespace_version = fil_space_get_version(space);
+
+	low  = (offset / buf_read_ahead_random_area)
+		* buf_read_ahead_random_area;
+	high = (offset / buf_read_ahead_random_area + 1)
+		* buf_read_ahead_random_area;
+	if (high > fil_space_get_size(space)) {
+
+		high = fil_space_get_size(space);
+	}
+
+	buf_pool_mutex_enter(buf_pool);
+
+	if (buf_pool->n_pend_reads
+	    > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
+		buf_pool_mutex_exit(buf_pool);
+
+		return(0);
+	}
+
+	/* Count how many blocks in the area have been recently accessed,
+	that is, reside near the start of the LRU list. */
+
+	for (i = low; i < high; i++) {
+		const buf_page_t* bpage =
+			buf_page_hash_get(buf_pool, space, i);
+
+		if (bpage
+		    && buf_page_is_accessed(bpage)
+		    && buf_page_peek_if_young(bpage)) {
+
+			recent_blocks++;
+
+			if (recent_blocks
+			    >= BUF_READ_AHEAD_RANDOM_THRESHOLD(buf_pool)) {
+
+				buf_pool_mutex_exit(buf_pool);
+				goto read_ahead;
+			}
+		}
+	}
+
+	buf_pool_mutex_exit(buf_pool);
+	/* Do nothing */
+	return(0);
+
+read_ahead:
+	/* Read all the suitable blocks within the area */
+
+	if (inside_ibuf) {
+		ibuf_mode = BUF_READ_IBUF_PAGES_ONLY;
+	} else {
+		ibuf_mode = BUF_READ_ANY_PAGE;
+	}
+
+	count = 0;
+
+	for (i = low; i < high; i++) {
+		/* It is only sensible to do read-ahead in the non-sync aio
+		mode: hence FALSE as the first parameter */
+
+		if (!ibuf_bitmap_page(zip_size, i)) {
+			count += buf_read_page_low(
+				&err, FALSE,
+				ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER,
+				space, zip_size, FALSE,
+				tablespace_version, i);
+			if (err == DB_TABLESPACE_DELETED) {
+				ut_print_timestamp(stderr);
+				fprintf(stderr,
+					"  InnoDB: Warning: in random"
+					" readahead trying to access\n"
+					"InnoDB: tablespace %lu page %lu,\n"
+					"InnoDB: but the tablespace does not"
+					" exist or is just being dropped.\n",
+					(ulong) space, (ulong) i);
+			}
+		}
+	}
+
+	/* In simulated aio we wake the aio handler threads only after
+	queuing all aio requests, in native aio the following call does
+	nothing: */
+
+	os_aio_simulated_wake_handler_threads();
+
+#ifdef UNIV_DEBUG
+	if (buf_debug_prints && (count > 0)) {
+		fprintf(stderr,
+			"Random read-ahead space %lu offset %lu pages %lu\n",
+			(ulong) space, (ulong) offset,
+			(ulong) count);
+	}
+#endif /* UNIV_DEBUG */
+
+	/* Read ahead is considered one I/O operation for the purpose of
+	LRU policy decision. */
+	buf_LRU_stat_inc_io();
+
+	buf_pool->stat.n_ra_pages_read_rnd += count;
+	srv_buf_pool_reads += count;
+	return(count);
+}
+
+/********************************************************************//**
 High-level function which reads a page asynchronously from a file to the
 buffer buf_pool if it is not already there. Sets the io_fix flag and sets
 an exclusive lock on the buffer frame. The flag is cleared and the x-lock
@@ -257,7 +424,7 @@ buf_read_ahead_linear(
 	ulint		err;
 	ulint		i;
 	const ulint	buf_read_ahead_linear_area
-		= BUF_READ_AHEAD_LINEAR_AREA(buf_pool);
+		= BUF_READ_AHEAD_AREA(buf_pool);
 	ulint		threshold;
 
 	if (UNIV_UNLIKELY(srv_startup_is_before_trx_rollback_phase)) {

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2011-08-31 10:39:08 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2011-10-05 08:56:12 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2000, 2011, MySQL AB & Innobase Oy. All Rights Reserved.
+Copyright (c) 2000, 2011, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, 2009 Google Inc.
 Copyright (c) 2009, Percona Inc.
 
@@ -614,6 +614,8 @@ static SHOW_VAR innodb_status_variables[
   (char*) &export_vars.innodb_buffer_pool_pages_misc,	  SHOW_LONG},
   {"buffer_pool_pages_total",
   (char*) &export_vars.innodb_buffer_pool_pages_total,	  SHOW_LONG},
+  {"buffer_pool_read_ahead_rnd",
+  (char*) &export_vars.innodb_buffer_pool_read_ahead_rnd, SHOW_LONG},
   {"buffer_pool_read_ahead",
   (char*) &export_vars.innodb_buffer_pool_read_ahead,	  SHOW_LONG},
   {"buffer_pool_read_ahead_evicted",
@@ -4035,25 +4037,6 @@ field_in_record_is_null(
 	return(0);
 }
 
-/**************************************************************//**
-Sets a field in a record to SQL NULL. Uses the record format
-information in table to track the null bit in record. */
-static inline
-void
-set_field_in_record_to_null(
-/*========================*/
-	TABLE*	table,	/*!< in: MySQL table object */
-	Field*	field,	/*!< in: MySQL field object */
-	char*	record)	/*!< in: a row in MySQL format */
-{
-	int	null_offset;
-
-	null_offset = (uint) ((char*) field->null_ptr
-					- (char*) table->record[0]);
-
-	record[null_offset] = record[null_offset] | field->null_bit;
-}
-
 /*************************************************************//**
 InnoDB uses this function to compare two data fields for which the data type
 is such that we must use MySQL code to compare them. NOTE that the prototype
@@ -7896,6 +7879,8 @@ ha_innobase::info_low(
 
 	if (flag & HA_STATUS_VARIABLE) {
 
+		ulint	page_size;
+
 		dict_table_stats_lock(ib_table, RW_S_LATCH);
 
 		n_rows = ib_table->stat_n_rows;
@@ -7938,14 +7923,19 @@ ha_innobase::info_low(
 			prebuilt->autoinc_last_value = 0;
 		}
 
+		page_size = dict_table_zip_size(ib_table);
+		if (page_size == 0) {
+			page_size = UNIV_PAGE_SIZE;
+		}
+
 		stats.records = (ha_rows)n_rows;
 		stats.deleted = 0;
-		stats.data_file_length = ((ulonglong)
-				ib_table->stat_clustered_index_size)
-					* UNIV_PAGE_SIZE;
-		stats.index_file_length = ((ulonglong)
-				ib_table->stat_sum_of_other_index_sizes)
-					* UNIV_PAGE_SIZE;
+		stats.data_file_length
+			= ((ulonglong) ib_table->stat_clustered_index_size)
+			* page_size;
+		stats.index_file_length =
+			((ulonglong) ib_table->stat_sum_of_other_index_sizes)
+			* page_size;
 
 		dict_table_stats_unlock(ib_table, RW_S_LATCH);
 
@@ -11317,6 +11307,11 @@ static MYSQL_SYSVAR_UINT(change_bufferin
   NULL, NULL, 0, 0, 1, 0);
 #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
 
+static MYSQL_SYSVAR_BOOL(random_read_ahead, srv_random_read_ahead,
+  PLUGIN_VAR_NOCMDARG,
+  "Whether to use read ahead for random access within an extent.",
+  NULL, NULL, FALSE);
+
 static MYSQL_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
   PLUGIN_VAR_RQCMDARG,
   "Number of pages that must be accessed sequentially for InnoDB to "
@@ -11385,6 +11380,7 @@ static struct st_mysql_sys_var* innobase
 #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
   MYSQL_SYSVAR(change_buffering_debug),
 #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
+  MYSQL_SYSVAR(random_read_ahead),
   MYSQL_SYSVAR(read_ahead_threshold),
   MYSQL_SYSVAR(io_capacity),
   MYSQL_SYSVAR(purge_threads),
@@ -11406,7 +11402,8 @@ mysql_declare_plugin(innobase)
   INNODB_VERSION_SHORT,
   innodb_status_variables_export,/* status variables             */
   innobase_system_variables, /* system variables */
-  NULL /* reserved */
+  NULL, /* reserved */
+  0,    /* flags */
 },
 i_s_innodb_trx,
 i_s_innodb_locks,

=== modified file 'storage/innobase/handler/i_s.cc'
--- a/storage/innobase/handler/i_s.cc	2011-03-02 09:00:48 +0000
+++ b/storage/innobase/handler/i_s.cc	2011-08-15 18:12:11 +0000
@@ -638,7 +638,11 @@ UNIV_INTERN struct st_mysql_plugin	i_s_i
 
 	/* reserved for dependency checking */
 	/* void* */
-	STRUCT_FLD(__reserved1, NULL)
+	STRUCT_FLD(__reserved1, NULL),
+
+	/* Plugin flags */
+	/* unsigned long */
+	STRUCT_FLD(flags, 0UL),
 };
 
 /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */
@@ -904,7 +908,11 @@ UNIV_INTERN struct st_mysql_plugin	i_s_i
 
 	/* reserved for dependency checking */
 	/* void* */
-	STRUCT_FLD(__reserved1, NULL)
+	STRUCT_FLD(__reserved1, NULL),
+
+	/* Plugin flags */
+	/* unsigned long */
+	STRUCT_FLD(flags, 0UL),
 };
 
 /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */
@@ -1087,7 +1095,11 @@ UNIV_INTERN struct st_mysql_plugin	i_s_i
 
 	/* reserved for dependency checking */
 	/* void* */
-	STRUCT_FLD(__reserved1, NULL)
+	STRUCT_FLD(__reserved1, NULL),
+
+	/* Plugin flags */
+	/* unsigned long */
+	STRUCT_FLD(flags, 0UL),
 };
 
 /*******************************************************************//**
@@ -1420,7 +1432,11 @@ UNIV_INTERN struct st_mysql_plugin	i_s_i
 
 	/* reserved for dependency checking */
 	/* void* */
-	STRUCT_FLD(__reserved1, NULL)
+	STRUCT_FLD(__reserved1, NULL),
+
+	/* Plugin flags */
+	/* unsigned long */
+	STRUCT_FLD(flags, 0UL),
 };
 
 UNIV_INTERN struct st_mysql_plugin	i_s_innodb_cmp_reset =
@@ -1470,7 +1486,11 @@ UNIV_INTERN struct st_mysql_plugin	i_s_i
 
 	/* reserved for dependency checking */
 	/* void* */
-	STRUCT_FLD(__reserved1, NULL)
+	STRUCT_FLD(__reserved1, NULL),
+
+	/* Plugin flags */
+	/* unsigned long */
+	STRUCT_FLD(flags, 0UL),
 };
 
 /* Fields of the dynamic table information_schema.innodb_cmpmem. */
@@ -1711,7 +1731,11 @@ UNIV_INTERN struct st_mysql_plugin	i_s_i
 
 	/* reserved for dependency checking */
 	/* void* */
-	STRUCT_FLD(__reserved1, NULL)
+	STRUCT_FLD(__reserved1, NULL),
+
+	/* Plugin flags */
+	/* unsigned long */
+	STRUCT_FLD(flags, 0UL),
 };
 
 UNIV_INTERN struct st_mysql_plugin	i_s_innodb_cmpmem_reset =
@@ -1761,7 +1785,11 @@ UNIV_INTERN struct st_mysql_plugin	i_s_i
 
 	/* reserved for dependency checking */
 	/* void* */
-	STRUCT_FLD(__reserved1, NULL)
+	STRUCT_FLD(__reserved1, NULL),
+
+	/* Plugin flags */
+	/* unsigned long */
+	STRUCT_FLD(flags, 0UL),
 };
 
 /*******************************************************************//**

=== modified file 'storage/innobase/include/btr0pcur.h'
--- a/storage/innobase/include/btr0pcur.h	2011-03-21 07:56:38 +0000
+++ b/storage/innobase/include/btr0pcur.h	2011-08-10 12:03:33 +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
@@ -244,18 +244,6 @@ btr_pcur_restore_position_func(
 	mtr_t*		mtr);		/*!< in: mtr */
 #define btr_pcur_restore_position(l,cur,mtr)				\
 	btr_pcur_restore_position_func(l,cur,__FILE__,__LINE__,mtr)
-/**************************************************************//**
-If the latch mode of the cursor is BTR_LEAF_SEARCH or BTR_LEAF_MODIFY,
-releases the page latch and bufferfix reserved by the cursor.
-NOTE! In the case of BTR_LEAF_MODIFY, there should not exist changes
-made by the current mini-transaction to the data protected by the
-cursor latch, as then the latch must not be released until mtr_commit. */
-UNIV_INTERN
-void
-btr_pcur_release_leaf(
-/*==================*/
-	btr_pcur_t*	cursor, /*!< in: persistent cursor */
-	mtr_t*		mtr);	/*!< in: mtr */
 /*********************************************************//**
 Gets the rel_pos field for a cursor whose position has been stored.
 @return	BTR_PCUR_ON, ... */
@@ -266,10 +254,9 @@ btr_pcur_get_rel_pos(
 	const btr_pcur_t*	cursor);/*!< in: persistent cursor */
 /**************************************************************//**
 Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES,
-that is, the cursor becomes detached. If there have been modifications
-to the page where pcur is positioned, this can be used instead of
-btr_pcur_release_leaf. Function btr_pcur_store_position should be used
-before calling this, if restoration of cursor is wanted later. */
+that is, the cursor becomes detached.
+Function btr_pcur_store_position should be used before calling this,
+if restoration of cursor is wanted later. */
 UNIV_INLINE
 void
 btr_pcur_commit_specify_mtr(

=== modified file 'storage/innobase/include/btr0pcur.ic'
--- a/storage/innobase/include/btr0pcur.ic	2011-03-21 07:56:38 +0000
+++ b/storage/innobase/include/btr0pcur.ic	2011-08-10 12:03:33 +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
@@ -369,10 +369,9 @@ btr_pcur_move_to_next(
 
 /**************************************************************//**
 Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES,
-that is, the cursor becomes detached. If there have been modifications
-to the page where pcur is positioned, this can be used instead of
-btr_pcur_release_leaf. Function btr_pcur_store_position should be used
-before calling this, if restoration of cursor is wanted later. */
+that is, the cursor becomes detached.
+Function btr_pcur_store_position should be used before calling this,
+if restoration of cursor is wanted later. */
 UNIV_INLINE
 void
 btr_pcur_commit_specify_mtr(

=== modified file 'storage/innobase/include/buf0buf.h'
--- a/storage/innobase/include/buf0buf.h	2011-06-23 12:57:25 +0000
+++ b/storage/innobase/include/buf0buf.h	2011-07-19 14:54:59 +0000
@@ -147,6 +147,8 @@ struct buf_pool_info_struct{
 	ulint	n_pages_created;	/*!< buf_pool->n_pages_created */
 	ulint	n_pages_written;	/*!< buf_pool->n_pages_written */
 	ulint	n_page_gets;		/*!< buf_pool->n_page_gets */
+	ulint	n_ra_pages_read_rnd;	/*!< buf_pool->n_ra_pages_read_rnd,
+					number of pages readahead */
 	ulint	n_ra_pages_read;	/*!< buf_pool->n_ra_pages_read, number
 					of pages readahead */
 	ulint	n_ra_pages_evicted;	/*!< buf_pool->n_ra_pages_evicted,
@@ -171,6 +173,8 @@ struct buf_pool_info_struct{
 					last printout */
 
 	/* Statistics about read ahead algorithm.  */
+	double	pages_readahead_rnd_rate;/*!< random readahead rate in pages per
+					second */
 	double	pages_readahead_rate;	/*!< readahead rate in pages per
 					second */
 	double	pages_evicted_rate;	/*!< rate of readahead page evicted
@@ -542,6 +546,18 @@ buf_block_get_freed_page_clock(
 	__attribute__((pure));
 
 /********************************************************************//**
+Tells if a block is still close enough to the MRU end of the LRU list
+meaning that it is not in danger of getting evicted and also implying
+that it has been accessed recently.
+Note that this is for heuristics only and does not reserve buffer pool
+mutex.
+@return	TRUE if block is close to MRU end of LRU */
+UNIV_INLINE
+ibool
+buf_page_peek_if_young(
+/*===================*/
+	const buf_page_t*	bpage);	/*!< in: block */
+/********************************************************************//**
 Recommends a move of a block to the start of the LRU list if there is danger
 of dropping from the buffer pool. NOTE: does not reserve the buffer pool
 mutex.
@@ -1605,6 +1621,8 @@ struct buf_pool_stat_struct{
 	ulint	n_pages_written;/*!< number write operations */
 	ulint	n_pages_created;/*!< number of pages created
 				in the pool with no read */
+	ulint	n_ra_pages_read_rnd;/*!< number of pages read in
+				as part of random read ahead */
 	ulint	n_ra_pages_read;/*!< number of pages read in
 				as part of read ahead */
 	ulint	n_ra_pages_evicted;/*!< number of read ahead
@@ -1744,7 +1762,7 @@ struct buf_pool_struct{
 	UT_LIST_BASE_NODE_T(buf_page_t) LRU;
 					/*!< base node of the LRU list */
 	buf_page_t*	LRU_old;	/*!< pointer to the about
-					buf_LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV
+					LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV
 					oldest blocks in the LRU list;
 					NULL if LRU length less than
 					BUF_LRU_OLD_MIN_LEN;

=== modified file 'storage/innobase/include/buf0buf.ic'
--- a/storage/innobase/include/buf0buf.ic	2011-06-23 12:57:25 +0000
+++ b/storage/innobase/include/buf0buf.ic	2011-07-19 14:54:59 +0000
@@ -125,6 +125,29 @@ buf_block_get_freed_page_clock(
 }
 
 /********************************************************************//**
+Tells if a block is still close enough to the MRU end of the LRU list
+meaning that it is not in danger of getting evicted and also implying
+that it has been accessed recently.
+Note that this is for heuristics only and does not reserve buffer pool
+mutex.
+@return	TRUE if block is close to MRU end of LRU */
+UNIV_INLINE
+ibool
+buf_page_peek_if_young(
+/*===================*/
+	const buf_page_t*	bpage)	/*!< in: block */
+{
+	buf_pool_t*	buf_pool = buf_pool_from_bpage(bpage);
+
+	/* FIXME: bpage->freed_page_clock is 31 bits */
+	return((buf_pool->freed_page_clock & ((1UL << 31) - 1))
+	       < ((ulint) bpage->freed_page_clock
+		  + (buf_pool->curr_size
+		     * (BUF_LRU_OLD_RATIO_DIV - buf_pool->LRU_old_ratio)
+		     / (BUF_LRU_OLD_RATIO_DIV * 4))));
+}
+
+/********************************************************************//**
 Recommends a move of a block to the start of the LRU list if there is danger
 of dropping from the buffer pool. NOTE: does not reserve the buffer pool
 mutex.
@@ -154,12 +177,7 @@ buf_page_peek_if_too_old(
 		buf_pool->stat.n_pages_not_made_young++;
 		return(FALSE);
 	} else {
-		/* FIXME: bpage->freed_page_clock is 31 bits */
-		return((buf_pool->freed_page_clock & ((1UL << 31) - 1))
-		       > ((ulint) bpage->freed_page_clock
-			  + (buf_pool->curr_size
-			     * (BUF_LRU_OLD_RATIO_DIV - buf_pool->LRU_old_ratio)
-			     / (BUF_LRU_OLD_RATIO_DIV * 4))));
+		return(!buf_page_peek_if_young(bpage));
 	}
 }
 

=== modified file 'storage/innobase/include/buf0lru.h'
--- a/storage/innobase/include/buf0lru.h	2011-06-23 12:57:25 +0000
+++ b/storage/innobase/include/buf0lru.h	2011-07-19 14:54:59 +0000
@@ -184,7 +184,7 @@ buf_LRU_make_block_old(
 /*===================*/
 	buf_page_t*	bpage);	/*!< in: control block */
 /**********************************************************************//**
-Updates buf_LRU_old_ratio.
+Updates buf_pool->LRU_old_ratio.
 @return	updated old_pct */
 UNIV_INTERN
 ulint
@@ -193,7 +193,7 @@ buf_LRU_old_ratio_update(
 	uint	old_pct,/*!< in: Reserve this percentage of
 			the buffer pool for "old" blocks. */
 	ibool	adjust);/*!< in: TRUE=adjust the LRU list;
-			FALSE=just assign buf_LRU_old_ratio
+			FALSE=just assign buf_pool->LRU_old_ratio
 			during the initialization of InnoDB */
 /********************************************************************//**
 Update the historical stats that we are collecting for LRU eviction
@@ -222,18 +222,15 @@ buf_LRU_print(void);
 #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
 
 /** @name Heuristics for detecting index scan @{ */
-/** Reserve this much/BUF_LRU_OLD_RATIO_DIV of the buffer pool for
-"old" blocks.  Protected by buf_pool->mutex. */
-extern uint	buf_LRU_old_ratio;
-/** The denominator of buf_LRU_old_ratio. */
+/** The denominator of buf_pool->LRU_old_ratio. */
 #define BUF_LRU_OLD_RATIO_DIV	1024
-/** Maximum value of buf_LRU_old_ratio.
+/** Maximum value of buf_pool->LRU_old_ratio.
 @see buf_LRU_old_adjust_len
-@see buf_LRU_old_ratio_update */
+@see buf_pool->LRU_old_ratio_update */
 #define BUF_LRU_OLD_RATIO_MAX	BUF_LRU_OLD_RATIO_DIV
-/** Minimum value of buf_LRU_old_ratio.
+/** Minimum value of buf_pool->LRU_old_ratio.
 @see buf_LRU_old_adjust_len
-@see buf_LRU_old_ratio_update
+@see buf_pool->LRU_old_ratio_update
 The minimum must exceed
 (BUF_LRU_OLD_TOLERANCE + 5) * BUF_LRU_OLD_RATIO_DIV / BUF_LRU_OLD_MIN_LEN. */
 #define BUF_LRU_OLD_RATIO_MIN	51

=== modified file 'storage/innobase/include/buf0rea.h'
--- a/storage/innobase/include/buf0rea.h	2011-04-15 13:58:30 +0000
+++ b/storage/innobase/include/buf0rea.h	2011-07-19 14:54:59 +0000
@@ -43,6 +43,31 @@ buf_read_page(
 	ulint	zip_size,/*!< in: compressed page size in bytes, or 0 */
 	ulint	offset);/*!< in: page number */
 /********************************************************************//**
+Applies a random read-ahead in buf_pool if there are at least a threshold
+value of accessed pages from the random read-ahead area. Does not read any
+page, not even the one at the position (space, offset), if the read-ahead
+mechanism is not activated. NOTE 1: the calling thread may own latches on
+pages: to avoid deadlocks this function must be written such that it cannot
+end up waiting for these latches! NOTE 2: the calling thread must want
+access to the page given: this rule is set to prevent unintended read-aheads
+performed by ibuf routines, a situation which could result in a deadlock if
+the OS does not support asynchronous i/o.
+@return number of page read requests issued; NOTE that if we read ibuf
+pages, it may happen that the page at the given page number does not
+get read even if we return a positive value!
+@return	number of page read requests issued */
+UNIV_INTERN
+ulint
+buf_read_ahead_random(
+/*==================*/
+	ulint	space,		/*!< in: space id */
+	ulint	zip_size,	/*!< in: compressed page size in bytes,
+				or 0 */
+	ulint	offset,		/*!< in: page number of a page which
+				the current thread wants to access */
+	ibool	inside_ibuf);	/*!< in: TRUE if we are inside ibuf
+				routine */
+/********************************************************************//**
 Applies linear read-ahead if in the buf_pool the page is a border page of
 a linear read-ahead area and all the pages in the area have been accessed.
 Does not read any page if the read-ahead mechanism is not activated. Note

=== modified file 'storage/innobase/include/mtr0mtr.h'
--- a/storage/innobase/include/mtr0mtr.h	2011-04-15 13:46:11 +0000
+++ b/storage/innobase/include/mtr0mtr.h	2011-08-10 12:03:33 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 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
@@ -213,16 +213,6 @@ ulint
 mtr_set_savepoint(
 /*==============*/
 	mtr_t*	mtr);	/*!< in: mtr */
-/**********************************************************//**
-Releases the latches stored in an mtr memo down to a savepoint.
-NOTE! The mtr must not have made changes to buffer pages after the
-savepoint, as these can be handled only by mtr_commit. */
-UNIV_INTERN
-void
-mtr_rollback_to_savepoint(
-/*======================*/
-	mtr_t*	mtr,		/*!< in: mtr */
-	ulint	savepoint);	/*!< in: savepoint */
 #ifndef UNIV_HOTBACKUP
 /**********************************************************//**
 Releases the (index tree) s-latch stored in an mtr memo after a

=== modified file 'storage/innobase/include/srv0srv.h'
--- a/storage/innobase/include/srv0srv.h	2011-04-26 17:55:52 +0000
+++ b/storage/innobase/include/srv0srv.h	2011-07-19 14:54:59 +0000
@@ -158,6 +158,7 @@ extern ulint	srv_mem_pool_size;
 extern ulint	srv_lock_table_size;
 
 extern ulint	srv_n_file_io_threads;
+extern my_bool	srv_random_read_ahead;
 extern ulong	srv_read_ahead_threshold;
 extern ulint	srv_n_read_io_threads;
 extern ulint	srv_n_write_io_threads;
@@ -703,6 +704,7 @@ struct export_var_struct{
 	ulint innodb_buffer_pool_wait_free;	/*!< srv_buf_pool_wait_free */
 	ulint innodb_buffer_pool_pages_flushed;	/*!< srv_buf_pool_flushed */
 	ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */
+	ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */
 	ulint innodb_buffer_pool_read_ahead;	/*!< srv_read_ahead */
 	ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
 	ulint innodb_dblwr_pages_written;	/*!< srv_dblwr_pages_written */

=== modified file 'storage/innobase/include/ut0mem.h'
--- a/storage/innobase/include/ut0mem.h	2010-09-29 14:26:32 +0000
+++ b/storage/innobase/include/ut0mem.h	2011-08-10 12:03:33 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2009, 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
@@ -210,43 +210,6 @@ ut_strlcpy_rev(
 	ulint		size);	/*!< in: size of destination buffer */
 
 /**********************************************************************//**
-Compute strlen(ut_strcpyq(str, q)).
-@return	length of the string when quoted */
-UNIV_INLINE
-ulint
-ut_strlenq(
-/*=======*/
-	const char*	str,	/*!< in: null-terminated string */
-	char		q);	/*!< in: the quote character */
-
-/**********************************************************************//**
-Make a quoted copy of a NUL-terminated string.	Leading and trailing
-quotes will not be included; only embedded quotes will be escaped.
-See also ut_strlenq() and ut_memcpyq().
-@return	pointer to end of dest */
-UNIV_INTERN
-char*
-ut_strcpyq(
-/*=======*/
-	char*		dest,	/*!< in: output buffer */
-	char		q,	/*!< in: the quote character */
-	const char*	src);	/*!< in: null-terminated string */
-
-/**********************************************************************//**
-Make a quoted copy of a fixed-length string.  Leading and trailing
-quotes will not be included; only embedded quotes will be escaped.
-See also ut_strlenq() and ut_strcpyq().
-@return	pointer to end of dest */
-UNIV_INTERN
-char*
-ut_memcpyq(
-/*=======*/
-	char*		dest,	/*!< in: output buffer */
-	char		q,	/*!< in: the quote character */
-	const char*	src,	/*!< in: string to be quoted */
-	ulint		len);	/*!< in: length of src */
-
-/**********************************************************************//**
 Return the number of times s2 occurs in s1. Overlapping instances of s2
 are only counted once.
 @return	the number of times s2 occurs in s1 */

=== modified file 'storage/innobase/include/ut0mem.ic'
--- a/storage/innobase/include/ut0mem.ic	2010-06-22 15:58:28 +0000
+++ b/storage/innobase/include/ut0mem.ic	2011-08-10 12:03:33 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2009, 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
@@ -99,27 +99,6 @@ ut_strcmp(const char* str1, const char* 
 }
 
 /**********************************************************************//**
-Compute strlen(ut_strcpyq(str, q)).
-@return	length of the string when quoted */
-UNIV_INLINE
-ulint
-ut_strlenq(
-/*=======*/
-	const char*	str,	/*!< in: null-terminated string */
-	char		q)	/*!< in: the quote character */
-{
-	ulint len;
-
-	for (len = 0; *str; len++, str++) {
-		if (*str == q) {
-			len++;
-		}
-	}
-
-	return(len);
-}
-
-/**********************************************************************//**
 Converts a raw binary data to a NUL-terminated hex string. The output is
 truncated if there is not enough space in "hex", make sure "hex_size" is at
 least (2 * raw_size + 1) if you do not want this to happen. Returns the

=== modified file 'storage/innobase/mtr/mtr0mtr.c'
--- a/storage/innobase/mtr/mtr0mtr.c	2011-05-31 07:55:29 +0000
+++ b/storage/innobase/mtr/mtr0mtr.c	2011-08-10 12:03:33 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 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
@@ -282,44 +282,6 @@ mtr_commit(
 }
 
 #ifndef UNIV_HOTBACKUP
-/**********************************************************//**
-Releases the latches stored in an mtr memo down to a savepoint.
-NOTE! The mtr must not have made changes to buffer pages after the
-savepoint, as these can be handled only by mtr_commit. */
-UNIV_INTERN
-void
-mtr_rollback_to_savepoint(
-/*======================*/
-	mtr_t*	mtr,		/*!< in: mtr */
-	ulint	savepoint)	/*!< in: savepoint */
-{
-	mtr_memo_slot_t* slot;
-	dyn_array_t*	memo;
-	ulint		offset;
-
-	ut_ad(mtr);
-	ut_ad(mtr->magic_n == MTR_MAGIC_N);
-	ut_ad(mtr->state == MTR_ACTIVE);
-
-	memo = &(mtr->memo);
-
-	offset = dyn_array_get_data_size(memo);
-	ut_ad(offset >= savepoint);
-
-	while (offset > savepoint) {
-		offset -= sizeof(mtr_memo_slot_t);
-
-		slot = dyn_array_get_element(memo, offset);
-
-		ut_ad(slot->type != MTR_MEMO_MODIFY);
-
-		/* We do not call mtr_memo_slot_note_modification()
-		because there MUST be no changes made to the buffer
-		pages after the savepoint */
-		mtr_memo_slot_release(mtr, slot);
-	}
-}
-
 /***************************************************//**
 Releases an object in the memo stack. */
 UNIV_INTERN

=== modified file 'storage/innobase/row/row0sel.c'
--- a/storage/innobase/row/row0sel.c	2011-05-31 09:12:32 +0000
+++ b/storage/innobase/row/row0sel.c	2011-08-10 12:03:33 +0000
@@ -2541,6 +2541,8 @@ row_sel_field_store_in_mysql_format(
 
 	ut_ad(len != UNIV_SQL_NULL);
 	UNIV_MEM_ASSERT_RW(data, len);
+	UNIV_MEM_ASSERT_W(dest, templ->mysql_col_len);
+	UNIV_MEM_INVALID(dest, templ->mysql_col_len);
 
 	switch (templ->type) {
 		const byte*	field_end;
@@ -2579,14 +2581,16 @@ row_sel_field_store_in_mysql_format(
 
 			dest = row_mysql_store_true_var_len(
 				dest, len, templ->mysql_length_bytes);
+			/* Copy the actual data. Leave the rest of the
+			buffer uninitialized. */
+			memcpy(dest, data, len);
+			break;
 		}
 
 		/* Copy the actual data */
 		ut_memcpy(dest, data, len);
 
-		/* Pad with trailing spaces. We pad with spaces also the
-		unused end of a >= 5.0.3 true VARCHAR column, just in case
-		MySQL expects its contents to be deterministic. */
+		/* Pad with trailing spaces. */
 
 		pad = dest + len;
 
@@ -3113,6 +3117,39 @@ sel_restore_position_for_mysql(
 }
 
 /********************************************************************//**
+Copies a cached field for MySQL from the fetch cache. */
+static
+void
+row_sel_copy_cached_field_for_mysql(
+/*================================*/
+	byte*			buf,	/*!< in/out: row buffer */
+	const byte*		cache,	/*!< in: cached row */
+	const mysql_row_templ_t*templ)	/*!< in: column template */
+{
+	ulint	len;
+
+	buf += templ->mysql_col_offset;
+	cache += templ->mysql_col_offset;
+
+	UNIV_MEM_ASSERT_W(buf, templ->mysql_col_len);
+
+	if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR
+	    && templ->type != DATA_INT) {
+		/* Check for != DATA_INT to make sure we do
+		not treat MySQL ENUM or SET as a true VARCHAR!
+		Find the actual length of the true VARCHAR field. */
+		row_mysql_read_true_varchar(
+			&len, cache, templ->mysql_length_bytes);
+		len += templ->mysql_length_bytes;
+		UNIV_MEM_INVALID(buf, templ->mysql_col_len);
+	} else {
+		len = templ->mysql_col_len;
+	}
+
+	ut_memcpy(buf, cache, len);
+}
+
+/********************************************************************//**
 Pops a cached row for MySQL from the fetch cache. */
 UNIV_INLINE
 void
@@ -3124,26 +3161,22 @@ row_sel_pop_cached_row_for_mysql(
 {
 	ulint			i;
 	const mysql_row_templ_t*templ;
-	byte*			cached_rec;
+	const byte*		cached_rec;
 	ut_ad(prebuilt->n_fetch_cached > 0);
 	ut_ad(prebuilt->mysql_prefix_len <= prebuilt->mysql_row_len);
 
+	UNIV_MEM_ASSERT_W(buf, prebuilt->mysql_row_len);
+
+	cached_rec = prebuilt->fetch_cache[prebuilt->fetch_cache_first];
+
 	if (UNIV_UNLIKELY(prebuilt->keep_other_fields_on_keyread)) {
 		/* Copy cache record field by field, don't touch fields that
 		are not covered by current key */
-		cached_rec = prebuilt->fetch_cache[
-			prebuilt->fetch_cache_first];
 
 		for (i = 0; i < prebuilt->n_template; i++) {
 			templ = prebuilt->mysql_template + i;
-#if 0 /* Some of the cached_rec may legitimately be uninitialized. */
-			UNIV_MEM_ASSERT_RW(cached_rec
-					   + templ->mysql_col_offset,
-					   templ->mysql_col_len);
-#endif
-			ut_memcpy(buf + templ->mysql_col_offset,
-				  cached_rec + templ->mysql_col_offset,
-				  templ->mysql_col_len);
+			row_sel_copy_cached_field_for_mysql(
+				buf, cached_rec, templ);
 			/* Copy NULL bit of the current field from cached_rec
 			to buf */
 			if (templ->mysql_null_bit_mask) {
@@ -3153,17 +3186,24 @@ row_sel_pop_cached_row_for_mysql(
 					& (byte)templ->mysql_null_bit_mask;
 			}
 		}
+	} else if (prebuilt->mysql_prefix_len > 63) {
+		/* The record is long. Copy it field by field, in case
+		there are some long VARCHAR column of which only a
+		small length is being used. */
+		UNIV_MEM_INVALID(buf, prebuilt->mysql_prefix_len);
+
+		/* First copy the NULL bits. */
+		ut_memcpy(buf, cached_rec, prebuilt->null_bitmap_len);
+		/* Then copy the requested fields. */
+
+		for (i = 0; i < prebuilt->n_template; i++) {
+			row_sel_copy_cached_field_for_mysql(
+				buf, cached_rec, prebuilt->mysql_template + i);
+		}
+	} else {
+		ut_memcpy(buf, cached_rec, prebuilt->mysql_prefix_len);
 	}
-	else {
-#if 0 /* Some of the cached_rec may legitimately be uninitialized. */
-		UNIV_MEM_ASSERT_RW(prebuilt->fetch_cache
-				   [prebuilt->fetch_cache_first],
-				   prebuilt->mysql_prefix_len);
-#endif
-		ut_memcpy(buf,
-			  prebuilt->fetch_cache[prebuilt->fetch_cache_first],
-			  prebuilt->mysql_prefix_len);
-	}
+
 	prebuilt->n_fetch_cached--;
 	prebuilt->fetch_cache_first++;
 

=== modified file 'storage/innobase/srv/srv0srv.c'
--- a/storage/innobase/srv/srv0srv.c	2011-05-04 09:08:07 +0000
+++ b/storage/innobase/srv/srv0srv.c	2011-07-19 14:54:59 +0000
@@ -222,6 +222,8 @@ UNIV_INTERN ulint	srv_n_file_io_threads	
 UNIV_INTERN ulint	srv_n_read_io_threads	= ULINT_MAX;
 UNIV_INTERN ulint	srv_n_write_io_threads	= ULINT_MAX;
 
+/* Switch to enable random read ahead. */
+UNIV_INTERN my_bool	srv_random_read_ahead	= FALSE;
 /* User settable value of the number of pages that must be present
 in the buffer cache and accessed sequentially for InnoDB to trigger a
 readahead request. */
@@ -2032,6 +2034,8 @@ srv_export_innodb_status(void)
 	export_vars.innodb_buffer_pool_wait_free = srv_buf_pool_wait_free;
 	export_vars.innodb_buffer_pool_pages_flushed = srv_buf_pool_flushed;
 	export_vars.innodb_buffer_pool_reads = srv_buf_pool_reads;
+	export_vars.innodb_buffer_pool_read_ahead_rnd
+		= stat.n_ra_pages_read_rnd;
 	export_vars.innodb_buffer_pool_read_ahead
 		= stat.n_ra_pages_read;
 	export_vars.innodb_buffer_pool_read_ahead_evicted

=== modified file 'storage/innobase/ut/ut0mem.c'
--- a/storage/innobase/ut/ut0mem.c	2010-09-29 14:26:32 +0000
+++ b/storage/innobase/ut/ut0mem.c	2011-08-10 12:03:33 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2009, 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
@@ -483,53 +483,6 @@ ut_strlcpy_rev(
 	return(src_size);
 }
 
-/**********************************************************************//**
-Make a quoted copy of a NUL-terminated string.	Leading and trailing
-quotes will not be included; only embedded quotes will be escaped.
-See also ut_strlenq() and ut_memcpyq().
-@return	pointer to end of dest */
-UNIV_INTERN
-char*
-ut_strcpyq(
-/*=======*/
-	char*		dest,	/*!< in: output buffer */
-	char		q,	/*!< in: the quote character */
-	const char*	src)	/*!< in: null-terminated string */
-{
-	while (*src) {
-		if ((*dest++ = *src++) == q) {
-			*dest++ = q;
-		}
-	}
-
-	return(dest);
-}
-
-/**********************************************************************//**
-Make a quoted copy of a fixed-length string.  Leading and trailing
-quotes will not be included; only embedded quotes will be escaped.
-See also ut_strlenq() and ut_strcpyq().
-@return	pointer to end of dest */
-UNIV_INTERN
-char*
-ut_memcpyq(
-/*=======*/
-	char*		dest,	/*!< in: output buffer */
-	char		q,	/*!< in: the quote character */
-	const char*	src,	/*!< in: string to be quoted */
-	ulint		len)	/*!< in: length of src */
-{
-	const char*	srcend = src + len;
-
-	while (src < srcend) {
-		if ((*dest++ = *src++) == q) {
-			*dest++ = q;
-		}
-	}
-
-	return(dest);
-}
-
 #ifndef UNIV_HOTBACKUP
 /**********************************************************************//**
 Return the number of times s2 occurs in s1. Overlapping instances of s2

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2011-08-31 10:39:08 +0000
+++ b/storage/myisam/ha_myisam.cc	2011-10-05 08:56:12 +0000
@@ -2086,7 +2086,8 @@ mysql_declare_plugin(myisam)
   0x0100, /* 1.0 */
   NULL,                       /* status variables                */
   myisam_sysvars,             /* system variables                */
-  NULL
+  NULL,
+  0,
 }
 mysql_declare_plugin_end;
 

=== modified file 'storage/myisammrg/ha_myisammrg.cc'
--- a/storage/myisammrg/ha_myisammrg.cc	2011-08-31 10:39:08 +0000
+++ b/storage/myisammrg/ha_myisammrg.cc	2011-10-05 08:56:12 +0000
@@ -159,9 +159,14 @@ extern "C" void myrg_print_wrong_table(c
   buf[db.length]= '.';
   memcpy(buf + db.length + 1, name.str, name.length);
   buf[db.length + name.length + 1]= 0;
-  push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                      ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE),
-                      buf);
+  /*
+    Push an error to be reported as part of CHECK/REPAIR result-set.
+    Note that calling my_error() from handler is a hack which is kept
+    here to avoid refactoring. Normally engines should report errors
+    through return value which will be interpreted by caller using
+    handler::print_error() call.
+  */
+  my_error(ER_ADMIN_WRONG_MRG_TABLE, MYF(0), buf);
 }
 
 
@@ -593,8 +598,7 @@ public:
 
   @return       pointer to open MyISAM table structure
     @retval     !=NULL                  OK, returning pointer
-    @retval     NULL, my_errno == 0     Ok, no more child tables
-    @retval     NULL, my_errno != 0     error
+    @retval     NULL,                   Error.
 
   @detail
     This function retrieves the MyISAM table handle from the
@@ -614,17 +618,33 @@ extern "C" MI_INFO *myisammrg_attach_chi
   MI_INFO       *myisam= NULL;
   DBUG_ENTER("myisammrg_attach_children_callback");
 
-  if (!child_l)
-  {
-    DBUG_PRINT("myrg", ("No more children to attach"));
-    my_errno= 0; /* Ok, no more child tables. */
-    goto end;
-  }
+  /*
+    Number of children in the list and MYRG_INFO::tables_count,
+    which is used by caller of this function, should always match.
+  */
+  DBUG_ASSERT(child_l);
+
   child= child_l->table;
   /* Prepare for next child. */
   param->next();
 
   /*
+    When MERGE table is opened for CHECK or REPAIR TABLE statements,
+    failure to open any of underlying tables is ignored until this moment
+    (this is needed to provide complete list of the problematic underlying
+    tables in CHECK/REPAIR TABLE output).
+    Here we detect such a situation and report an appropriate error.
+  */
+  if (! child)
+  {
+    DBUG_PRINT("error", ("failed to open underlying table '%s'.'%s'",
+                         child_l->db, child_l->table_name));
+    /* This should only happen inside of CHECK/REPAIR TABLE. */
+    DBUG_ASSERT(current_thd->open_options & HA_OPEN_FOR_REPAIR);
+    goto end;
+  }
+
+  /*
     Do a quick compatibility check. The table def version is set when
     the table share is created. The child def version is copied
     from the table def version after a successful compatibility check.
@@ -653,7 +673,6 @@ extern "C" MI_INFO *myisammrg_attach_chi
   {
     DBUG_PRINT("error", ("temporary table mismatch parent: %d  child: %d",
                          parent->s->tmp_table, child->s->tmp_table));
-    my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
     goto end;
   }
 
@@ -664,12 +683,27 @@ extern "C" MI_INFO *myisammrg_attach_chi
     DBUG_PRINT("error", ("no MyISAM handle for child table: '%s'.'%s' 0x%lx",
                          child->s->db.str, child->s->table_name.str,
                          (long) child));
-    my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
   }
-  DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx  my_errno: %d",
-                      my_errno ? 0L : (long) myisam, my_errno));
+
+  DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx", (long) myisam));
 
  end:
+
+  if (!myisam &&
+      (current_thd->open_options & HA_OPEN_FOR_REPAIR))
+  {
+    char buf[2*NAME_LEN + 1 + 1];
+    strxnmov(buf, sizeof(buf) - 1, child_l->db, ".", child_l->table_name, NULL);
+    /*
+      Push an error to be reported as part of CHECK/REPAIR result-set.
+      Note that calling my_error() from handler is a hack which is kept
+      here to avoid refactoring. Normally engines should report errors
+      through return value which will be interpreted by caller using
+      handler::print_error() call.
+    */
+    my_error(ER_ADMIN_WRONG_MRG_TABLE, MYF(0), buf);
+  }
+
   DBUG_RETURN(myisam);
 }
 
@@ -783,12 +817,6 @@ int ha_myisammrg::attach_children(void)
   /* Must call this with children list in place. */
   DBUG_ASSERT(this->table->pos_in_table_list->next_global == this->children_l);
 
-  /*
-    'my_errno' is set by myisammrg_attach_children_callback() in
-    case of an error.
-  */
-  my_errno= 0;
-
   if (myrg_attach_children(this->file, this->test_if_locked |
                            current_thd->open_options,
                            myisammrg_attach_children_callback, &param,
@@ -1659,6 +1687,7 @@ mysql_declare_plugin(myisammrg)
   0x0100, /* 1.0 */
   NULL,                       /* status variables                */
   NULL,                       /* system variables                */
-  NULL                        /* config options                  */
+  NULL,                       /* config options                  */
+  0,                          /* flags                           */
 }
 mysql_declare_plugin_end;

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

=== modified file 'storage/perfschema/ha_perfschema.cc'
--- a/storage/perfschema/ha_perfschema.cc	2010-12-01 12:06:41 +0000
+++ b/storage/perfschema/ha_perfschema.cc	2011-08-15 18:12:11 +0000
@@ -166,7 +166,8 @@ mysql_declare_plugin(perfschema)
   0x0001 /* 0.1 */,
   pfs_status_vars,                              /* status variables */
   NULL,                                         /* system variables */
-  NULL                                          /* config options */
+  NULL,                                         /* config options */
+  0,                                            /* flags */
 }
 mysql_declare_plugin_end;
 

=== modified file 'strings/ctype-uca.c'
--- a/strings/ctype-uca.c	2011-08-31 10:39:08 +0000
+++ b/strings/ctype-uca.c	2011-10-05 08:56:12 +0000
@@ -42,6 +42,7 @@
 #define MY_UCA_NCHARS 256
 #define MY_UCA_CMASK  255
 #define MY_UCA_PSHIFT 8
+#define MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT 0xFFFF
 
 uint16 page000data[]= { /* 0000 (4 weights per char) */
 0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,
@@ -6984,7 +6985,7 @@ static int my_uca_scanner_next_any(my_uc
       return -1;
     
     scanner->sbeg+= mb_len;
-    if (wc > 0xFFFF)
+    if (wc > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT)
     {
       /* Return 0xFFFD as weight for all characters outside BMP */
       scanner->wbeg= nochar;
@@ -7322,6 +7323,33 @@ static size_t my_strnxfrm_uca(CHARSET_IN
 
 
 
+/**
+  Helper function:
+  Find address of weights of the given character.
+  
+  @param weights  UCA weight array
+  @param lengths  UCA length array
+  @param ch       character Unicode code point
+  
+  @return Weight array
+    @retval  pointer to weight array for the given character,
+             or NULL if this page does not have implicit weights.
+*/
+
+static inline uint16 *
+my_char_weight_addr(CHARSET_INFO *cs, uint wc)
+{
+  uint page, ofst;
+  uchar *ucal= cs->sort_order;
+  uint16 **ucaw= cs->sort_order_big;
+
+  return wc > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT ? NULL :
+         (ucaw[page= (wc >> 8)] ?
+          ucaw[page] + (ofst= (wc & 0xFF)) * ucal[page] :
+          NULL);
+}
+
+
 /*
   This function compares if two characters are the same.
   The sign +1 or -1 does not matter. The only
@@ -7332,17 +7360,20 @@ static size_t my_strnxfrm_uca(CHARSET_IN
 
 static int my_uca_charcmp(CHARSET_INFO *cs, my_wc_t wc1, my_wc_t wc2)
 {
-  size_t page1= wc1 >> MY_UCA_PSHIFT;
-  size_t page2= wc2 >> MY_UCA_PSHIFT;
-  uchar *ucal= cs->sort_order;
-  uint16 **ucaw= cs->sort_order_big;
-  size_t length1= ucal[page1];
-  size_t length2= ucal[page2];
-  uint16 *weight1= ucaw[page1] + (wc1 & MY_UCA_CMASK) * ucal[page1];
-  uint16 *weight2= ucaw[page2] + (wc2 & MY_UCA_CMASK) * ucal[page2];
+  size_t length1, length2;
+  uint16 *weight1= my_char_weight_addr(cs, wc1);
+  uint16 *weight2= my_char_weight_addr(cs, wc2);
   
   if (!weight1 || !weight2)
     return wc1 != wc2;
+
+  /* Quickly compare first weights */
+  if (weight1[0] != weight2[0])
+    return 1;
+
+  /* Thoroughly compare all weights */
+  length1= cs->sort_order[wc1 >> MY_UCA_PSHIFT];
+  length2= cs->sort_order[wc2 >> MY_UCA_PSHIFT];
   
   if (length1 > length2)
     return memcmp((const void*)weight1, (const void*)weight2, length2*2) ?
@@ -7924,6 +7955,11 @@ static my_bool create_tailoring(CHARSET_
   */
   for (i=0; i < rc; i++)
   {
+    /* check if the shift or the reset characters are out of range */
+    if (rule[i].curr[0] > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT ||
+        rule[i].base > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT)
+      return 1;
+
     if (!rule[i].curr[1]) /* If not a contraction */
     {
       uint pageb= (rule[i].base >> 8) & 0xFF;

=== modified file 'strings/decimal.c'
--- a/strings/decimal.c	2011-08-31 10:39:08 +0000
+++ b/strings/decimal.c	2011-10-05 08:56:12 +0000
@@ -2182,7 +2182,6 @@ static int do_div_mod(const decimal_t *f
   }
   buf0=to->buf;
   stop0=buf0+intg0+frac0;
-  DBUG_ASSERT(stop0 <= &to->buf[to->len]);
   if (likely(div_mod))
     while (dintg++ < 0 && buf0 < &to->buf[to->len])
     {
@@ -2277,7 +2276,10 @@ static int do_div_mod(const decimal_t *f
       }
     }
     if (likely(div_mod))
+    {
+      DBUG_ASSERT(buf0 < to->buf + to->len);
       *buf0=(dec1)guess;
+    }
     dcarry= *start1;
     start1++;
   }

=== modified file 'support-files/compiler_warnings.supp'
--- a/support-files/compiler_warnings.supp	2011-09-29 17:47:44 +0000
+++ b/support-files/compiler_warnings.supp	2011-10-05 08:56:12 +0000
@@ -99,27 +99,21 @@ mi_packrec.c : .*result of 32-bit shift 
 .* : .*no matching operator delete found; memory will not be freed if initialization throws an exception.*
 ctype-simple.c : .*unary minus operator applied to unsigned type, result still unsigned.*
 
+### MCP_COMPILER_WARN_SUPPRESSIONS start ###
+# warnings ingnored by Cluster team
 #
-# Below is suppressions added by Cluster Team
-#
-
-#
-# 5.5-mainline
-# 
 extra/perror.c : .*strerror.*
 plugin/semisync/semisync_master.cc : .*may be used uninitialized in this function.*
 .*/innobase/.* : .*
 client/mysqldump.c : .*may be used uninitialized in this function.*
 
-# 5.5-mainline windows
+# windows
 mysqlslap/mysqlslap.c : .*
 yassl/.* : C4005: 'WIN32_LEAN_AND_MEAN' : macro redefinition
 mytap/tap.c : C4028: formal parameter .* different from declaration
 .*/readline.cc : C4101: 'input_file_stat' : unreferenced local variable
 
 #
-# 
-#
 .*/sys_vars.h             : .*C4244.* conversion .* possible loss of data
 .*/mi_dynrec.c            : .*C4244.* conversion .* possible loss of data
 .*/mi_check.c             : .*C4244.* conversion .* possible loss of data
@@ -165,3 +159,4 @@ my_print_defaults/my_print_defaults.c : 
 myisamchk/myisamchk.c                 : .*C4090.*
 mysqlimport/mysqlimport.c             : .*C4090.*
 mysqlcheck/mysqlcheck.c               : .*C4090.*
+### MCP_COMPILE_WARN_SUPPRESSIONS end ###

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2011-08-31 10:39:08 +0000
+++ b/support-files/mysql.spec.sh	2011-10-05 08:56:12 +0000
@@ -127,13 +127,13 @@
       %define distro_description        Oracle Enterprise Linux 4
       %define distro_releasetag         oel4
       %define distro_buildreq           gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel
-      %define distro_requires           chkconfig coreutils grep procps shadow-utils
+      %define distro_requires           chkconfig coreutils grep procps shadow-utils net-tools
     %else
       %if "%oelver" == "5"
         %define distro_description      Oracle Enterprise Linux 5
         %define distro_releasetag       oel5
         %define distro_buildreq         gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel
-        %define distro_requires         chkconfig coreutils grep procps shadow-utils
+        %define distro_requires         chkconfig coreutils grep procps shadow-utils net-tools
       %else
         %{error:Oracle Enterprise Linux %{oelver} is unsupported}
       %endif
@@ -145,13 +145,13 @@
         %define distro_description      Red Hat Enterprise Linux 4
         %define distro_releasetag       rhel4
         %define distro_buildreq         gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel
-        %define distro_requires         chkconfig coreutils grep procps shadow-utils
+        %define distro_requires         chkconfig coreutils grep procps shadow-utils net-tools
       %else
         %if "%rhelver" == "5"
           %define distro_description    Red Hat Enterprise Linux 5
           %define distro_releasetag     rhel5
           %define distro_buildreq       gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel
-          %define distro_requires       chkconfig coreutils grep procps shadow-utils
+          %define distro_requires       chkconfig coreutils grep procps shadow-utils net-tools
         %else
           %{error:Red Hat Enterprise Linux %{rhelver} is unsupported}
         %endif
@@ -944,7 +944,7 @@ echo "====="                            
 #  Files section
 ##############################################################################
 
-%files -n MySQL-server%{product_suffix}
+%files -n MySQL-server%{product_suffix} -f release/support-files/plugins.files
 %defattr(-,root,root,0755)
 
 %if %{defined license_files_server}
@@ -984,6 +984,7 @@ echo "====="                            
 %doc %attr(644, root, man) %{_mandir}/man1/replace.1*
 %doc %attr(644, root, man) %{_mandir}/man1/resolve_stack_dump.1*
 %doc %attr(644, root, man) %{_mandir}/man1/resolveip.1*
+%doc %attr(644, root, man) %{_mandir}/man1/mysql_plugin.1*
 
 %ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf
 
@@ -1000,6 +1001,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
@@ -1015,28 +1017,7 @@ echo "====="                            
 %attr(755, root, root) %{_sbindir}/mysqld
 %attr(755, root, root) %{_sbindir}/mysqld-debug
 %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/mypluglib.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/auth.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/auth_socket.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/auth_test_plugin.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_client.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_interface.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_server.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/adt_null.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/libdaemon_example.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/mypluglib.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_master.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_slave.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_socket.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_test_plugin.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_client.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_interface.so
-%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_server.so
+%attr(755, root, root) %{_libdir}/mysql/plugin/daemon_example.ini
 
 %if %{WITH_TCMALLOC}
 %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target}
@@ -1121,6 +1102,7 @@ echo "====="                            
 # ----------------------------------------------------------------------------
 %files -n MySQL-embedded%{product_suffix}
 %defattr(-, root, root, 0755)
+%attr(755, root, root) %{_bindir}/mysql_embedded
 %attr(644, root, root) %{_libdir}/mysql/libmysqld.a
 %attr(644, root, root) %{_libdir}/mysql/libmysqld-debug.a
 
@@ -1130,6 +1112,22 @@ echo "====="                            
 # merging BK trees)
 ##############################################################################
 %changelog
+* Thu Sep 08 2011 Daniel Fischer <daniel.fischer@stripped>
+
+- Add mysql_plugin man page.
+
+* Fri Aug 12 2011 Daniel Fischer <daniel.fischer@oracle.com>
+
+- Source plugin library files list from cmake-generated file.
+
+* 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
+
 * Thu Jul 07 2011 Joerg Bruehe <joerg.bruehe@stripped>
 
 - Fix bug#45415: "rpm upgrade recreates test database"

=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c	2011-08-31 10:39:08 +0000
+++ b/tests/mysql_client_test.c	2011-10-05 08:56:12 +0000
@@ -19662,6 +19662,34 @@ static void test_bug12337762()
   DBUG_VOID_RETURN;
 }
 
+
+/*
+  BUG 11754979 - 46675: ON DUPLICATE KEY UPDATE AND UPDATECOUNT() POSSIBLY WRONG
+*/
+
+static void test_bug11754979()
+{
+  MYSQL* conn;
+  DBUG_ENTER("test_bug11754979");
+
+  myheader("test_bug11754979");
+  DIE_UNLESS((conn= mysql_client_init(NULL)));
+  DIE_UNLESS(mysql_real_connect(conn, opt_host, opt_user,
+             opt_password, opt_db ? opt_db:"test", opt_port,
+             opt_unix_socket,  CLIENT_FOUND_ROWS));
+  myquery(mysql_query(conn, "DROP TABLE IF EXISTS t1"));
+  myquery(mysql_query(conn, "CREATE TABLE t1(id INT, label CHAR(1), PRIMARY KEY(id))"));
+  myquery(mysql_query(conn, "INSERT INTO t1(id, label) VALUES (1, 'a')"));
+  myquery(mysql_query(conn, "INSERT INTO t1(id, label) VALUES (1, 'a') "
+                            "ON DUPLICATE KEY UPDATE id = 4"));
+  DIE_UNLESS(mysql_affected_rows(conn) == 2);
+  myquery(mysql_query(conn, "DROP TABLE t1"));
+  mysql_close(conn);
+
+  DBUG_VOID_RETURN;
+}
+
+
 /*
   Read and parse arguments and MySQL options from my.cnf
 */
@@ -20007,6 +20035,7 @@ static struct my_tests_st my_tests[]= {
   { "test_bug56976", test_bug56976 },
   { "test_bug11766854", test_bug11766854 },
   { "test_bug12337762", test_bug12337762 },
+  { "test_bug11754979", test_bug11754979 },
   { 0, 0 }
 };
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster branch (magnus.blaudd:3569 to 3570) magnus.blaudd5 Oct