List:Commits« Previous MessageNext Message »
From:vasil.dimov Date:November 8 2010 2:42pm
Subject:bzr commit into mysql-trunk-innodb branch (vasil.dimov:3314)
View as plain text  
#At file:///usr/local/devel/bzrroot/server/t/mysql-trunk-innodb/ based on revid:jimmy.yang@stripped17-dvev6424yzogf4gq

 3314 Vasil Dimov	2010-11-08 [merge]
      Merge mysql-trunk-bugfixing -> mysql-trunk-innodb

    removed:
      win/build-nmake-x64.bat
      win/build-nmake.bat
      win/build-vs71.bat
      win/build-vs8.bat
      win/build-vs8_x64.bat
      win/build-vs9.bat
      win/build-vs9_x64.bat
    added:
      mysql-test/std_data/bug57108.cnf
      mysql-test/suite/bugs/r/bug57108.result
      mysql-test/suite/bugs/t/bug57108-master.opt
      mysql-test/suite/bugs/t/bug57108.test
      mysql-test/suite/parts/inc/part_exch_drop_tabs.inc
      mysql-test/suite/parts/inc/part_exch_qa.inc
      mysql-test/suite/parts/inc/part_exch_qa_1.inc
      mysql-test/suite/parts/inc/part_exch_qa_13.inc
      mysql-test/suite/parts/inc/part_exch_qa_4.inc
      mysql-test/suite/parts/inc/part_exch_qa_5.inc
      mysql-test/suite/parts/inc/part_exch_qa_7.inc
      mysql-test/suite/parts/inc/part_exch_qa_8.inc
      mysql-test/suite/parts/inc/part_exch_tabs.inc
      mysql-test/suite/parts/r/partition_exch_innodb.result
      mysql-test/suite/parts/r/partition_exch_myisam.result
      mysql-test/suite/parts/r/partition_exch_myisam_innodb.result
      mysql-test/suite/parts/r/partition_exch_qa.result
      mysql-test/suite/parts/r/partition_exch_qa_10.result
      mysql-test/suite/parts/r/partition_exch_qa_11.result
      mysql-test/suite/parts/r/partition_exch_qa_12.result
      mysql-test/suite/parts/r/partition_exch_qa_13.result
      mysql-test/suite/parts/r/partition_exch_qa_14.result
      mysql-test/suite/parts/r/partition_exch_qa_15.result
      mysql-test/suite/parts/r/partition_exch_qa_1_innodb.result
      mysql-test/suite/parts/r/partition_exch_qa_1_myisam.result
      mysql-test/suite/parts/r/partition_exch_qa_2.result
      mysql-test/suite/parts/r/partition_exch_qa_3.result
      mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result
      mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result
      mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result
      mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result
      mysql-test/suite/parts/r/partition_exch_qa_6.result
      mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result
      mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result
      mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result
      mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result
      mysql-test/suite/parts/t/partition_exch_innodb.test
      mysql-test/suite/parts/t/partition_exch_myisam.test
      mysql-test/suite/parts/t/partition_exch_myisam_innodb.test
      mysql-test/suite/parts/t/partition_exch_qa.test
      mysql-test/suite/parts/t/partition_exch_qa_10.test
      mysql-test/suite/parts/t/partition_exch_qa_11.test
      mysql-test/suite/parts/t/partition_exch_qa_12.test
      mysql-test/suite/parts/t/partition_exch_qa_13.test
      mysql-test/suite/parts/t/partition_exch_qa_14.test
      mysql-test/suite/parts/t/partition_exch_qa_15.test
      mysql-test/suite/parts/t/partition_exch_qa_1_innodb.test
      mysql-test/suite/parts/t/partition_exch_qa_1_myisam.test
      mysql-test/suite/parts/t/partition_exch_qa_2.test
      mysql-test/suite/parts/t/partition_exch_qa_3.test
      mysql-test/suite/parts/t/partition_exch_qa_4_innodb.test
      mysql-test/suite/parts/t/partition_exch_qa_4_myisam.test
      mysql-test/suite/parts/t/partition_exch_qa_5_innodb.test
      mysql-test/suite/parts/t/partition_exch_qa_5_myisam.test
      mysql-test/suite/parts/t/partition_exch_qa_6.test
      mysql-test/suite/parts/t/partition_exch_qa_7_innodb.test
      mysql-test/suite/parts/t/partition_exch_qa_7_myisam.test
      mysql-test/suite/parts/t/partition_exch_qa_8_innodb.test
      mysql-test/suite/parts/t/partition_exch_qa_8_myisam.test
      mysql-test/suite/sys_vars/inc/autocommit_func2.inc
      mysql-test/suite/sys_vars/r/autocommit_func2.result
      mysql-test/suite/sys_vars/r/autocommit_func3.result
      mysql-test/suite/sys_vars/t/autocommit_func2-master.opt
      mysql-test/suite/sys_vars/t/autocommit_func2.test
      mysql-test/suite/sys_vars/t/autocommit_func3-master.opt
      mysql-test/suite/sys_vars/t/autocommit_func3.test
    modified:
      .bzrignore
      CMakeLists.txt
      client/mysqlbinlog.cc
      cmake/mysql_version.cmake
      config/ac-macros/maintainer.m4
      include/my_sys.h
      include/mysql/plugin_auth.h
      libmysqld/lib_sql.cc
      mysql-test/collections/default.experimental
      mysql-test/mysql-test-run.pl
      mysql-test/r/1st.result
      mysql-test/r/connect.result
      mysql-test/r/ctype_binary.result
      mysql-test/r/ctype_cp1251.result
      mysql-test/r/ctype_latin1.result
      mysql-test/r/ctype_uca.result
      mysql-test/r/ctype_ucs.result
      mysql-test/r/ctype_utf16_uca.result
      mysql-test/r/ctype_utf32_uca.result
      mysql-test/r/ctype_utf8.result
      mysql-test/r/errors.result
      mysql-test/r/func_time.result
      mysql-test/r/information_schema.result
      mysql-test/r/keywords.result
      mysql-test/r/log_tables.result
      mysql-test/r/log_tables_upgrade.result
      mysql-test/r/mysql_upgrade.result
      mysql-test/r/mysql_upgrade_ssl.result
      mysql-test/r/mysqlbinlog.result
      mysql-test/r/mysqlcheck.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/plugin_auth.result
      mysql-test/r/system_mysql_db.result
      mysql-test/r/type_blob.result
      mysql-test/suite/funcs_1/r/is_columns_mysql.result
      mysql-test/suite/funcs_1/r/is_key_column_usage.result
      mysql-test/suite/funcs_1/r/is_statistics.result
      mysql-test/suite/funcs_1/r/is_statistics_mysql.result
      mysql-test/suite/funcs_1/r/is_table_constraints.result
      mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result
      mysql-test/suite/funcs_1/r/is_tables_mysql.result
      mysql-test/suite/perfschema/r/privilege_table_io.result
      mysql-test/t/ctype_uca.test
      mysql-test/t/ctype_utf16_uca.test
      mysql-test/t/ctype_utf32_uca.test
      mysql-test/t/errors.test
      mysql-test/t/func_time.test
      mysql-test/t/keywords.test
      mysql-test/t/log_tables.test
      mysql-test/t/mysqlbinlog.test
      mysql-test/t/plugin_auth.test
      mysql-test/t/system_mysql_db_fix40123.test
      mysql-test/t/system_mysql_db_fix50030.test
      mysql-test/t/system_mysql_db_fix50117.test
      mysql-test/t/type_blob.test
      mysys/charset-def.c
      mysys/default.c
      mysys/stacktrace.c
      plugin/auth/dialog.c
      plugin/auth/test_plugin.c
      scripts/mysql_system_tables.sql
      scripts/mysql_system_tables_data.sql
      scripts/mysql_system_tables_fix.sql
      sql/field.cc
      sql/field.h
      sql/ha_partition.h
      sql/item.cc
      sql/item_timefunc.h
      sql/log_event.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/rpl_handler.cc
      sql/rpl_record.cc
      sql/sql_acl.cc
      sql/sql_partition.cc
      sql/sql_partition_admin.cc
      sql/sql_plugin.cc
      sql/sql_rename.cc
      sql/sql_select.cc
      sql/sql_show.cc
      sql/sql_yacc.yy
      storage/innobase/os/os0sync.c
      storage/ndb/src/mgmsrv/InitConfigFileParser.cpp
      strings/ctype-uca.c
      support-files/mysql.spec.sh
      win/README
=== modified file '.bzrignore'
--- a/.bzrignore	revid:jimmy.yang@strippedm-20101105133317-dvev6424yzogf4gq
+++ b/.bzrignore	revid:vasil.dimov@stripped
@@ -10,15 +10,19 @@
 *.core
 *.d
 *.da
+*.dll
 *.exe
+*.exp
 *.gcda
 *.gcno
 *.gcov
 *.idb
+*.ilk
 *.la
 *.lai
 *.lib
 *.lo
+*.manifest
 *.map
 *.o
 *.obj
@@ -149,6 +153,7 @@ Makefile
 Makefile.in
 Makefile.in'
 PENDING/*
+scripts/scripts
 TAGS
 VC++Files/client/mysql_amd64.dsp
 ac_available_languages_fragment
@@ -1983,6 +1988,7 @@ sql-bench/test-transactions
 sql-bench/test-wisconsin
 sql/*.cpp
 sql/*.ds?
+sql/*.def
 sql/*.vcproj
 sql/.deps/client.Po
 sql/.deps/derror.Po
@@ -2118,6 +2124,7 @@ sql/.libs/udf_example.lai
 sql/.libs/udf_example.so.0
 sql/.libs/udf_example.so.0.0.0
 sql/client.c
+sql/cmake_dummy.cc
 sql/Doxyfile
 sql/f.c
 sql/gen_lex_hash
@@ -3048,6 +3055,7 @@ vio/viotest.cpp
 win/configure.data
 win/vs71cache.txt
 win/vs8cache.txt
+win/nmake_cache.txt
 ylwrap
 zlib/*.ds?
 zlib/*.vcproj

=== modified file 'CMakeLists.txt'
--- a/CMakeLists.txt	revid:jimmy.yang@strippedv6424yzogf4gq
+++ b/CMakeLists.txt	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -115,18 +115,27 @@ ENDIF()
 # Control aspects of the development environment which are
 # specific to MySQL maintainers and developers.
 #
+INCLUDE (CheckCCompilerFlag)
 OPTION(MYSQL_MAINTAINER_MODE "MySQL maintainer-specific development environment" OFF)
 # Whether the maintainer mode should be enabled.
 IF(MYSQL_MAINTAINER_MODE)
   IF(CMAKE_COMPILER_IS_GNUCC)
+    CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement" HAVE_DECLARATION_AFTER_STATEMENT)
+    IF(HAVE_DECLARATION_AFTER_STATEMENT)
+      SET(MY_MAINTAINER_DECLARATION_AFTER_STATEMENT "-Wdeclaration-after-statement")
+    ENDIF()
     SET(MY_MAINTAINER_C_WARNINGS
-        "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror"
-        CACHE STRING "C warning options used in maintainer builds.")
+        "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror")
   ENDIF()
   IF(CMAKE_COMPILER_IS_GNUCXX)
     SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_C_WARNINGS} -Wno-unused-parameter"
         CACHE STRING "C++ warning options used in maintainer builds.")
   ENDIF()
+  IF(CMAKE_COMPILER_IS_GNUCC)
+    SET(MY_MAINTAINER_C_WARNINGS
+        "${MY_MAINTAINER_C_WARNINGS} ${MY_MAINTAINER_DECLARATION_AFTER_STATEMENT}"
+        CACHE STRING "C warning options used in maintainer builds.")
+  ENDIF()
   # Do not make warnings in checks into errors.
   IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
     SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error")

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	revid:jimmy.yang@strippedq
+++ b/client/mysqlbinlog.cc	revid:vasil.dimov@strippedm-20101108144220-zlcp5sg51xgg75x0
@@ -67,7 +67,7 @@ static void warning(const char *format, 
 static my_bool one_database=0, disable_log_bin= 0;
 static my_bool opt_hexdump= 0;
 const char *base64_output_mode_names[]=
-{"NEVER", "AUTO", "ALWAYS", "UNSPEC", "DECODE-ROWS", NullS};
+{"NEVER", "AUTO", "UNSPEC", "DECODE-ROWS", NullS};
 TYPELIB base64_output_mode_typelib=
   { array_elements(base64_output_mode_names) - 1, "",
     base64_output_mode_names, NULL };
@@ -632,45 +632,6 @@ static bool shall_skip_database(const ch
 
 
 /**
-  Prints the given event in base64 format.
-
-  The header is printed to the head cache and the body is printed to
-  the body cache of the print_event_info structure.  This allows all
-  base64 events corresponding to the same statement to be joined into
-  one BINLOG statement.
-
-  @param[in] ev Log_event to print.
-  @param[in,out] result_file FILE to which the output will be written.
-  @param[in,out] print_event_info Parameters and context state
-  determining how to print.
-
-  @retval ERROR_STOP An error occurred - the program should terminate.
-  @retval OK_CONTINUE No error, the program should continue.
-*/
-static Exit_status
-write_event_header_and_base64(Log_event *ev, FILE *result_file,
-                              PRINT_EVENT_INFO *print_event_info)
-{
-  IO_CACHE *head= &print_event_info->head_cache;
-  IO_CACHE *body= &print_event_info->body_cache;
-  DBUG_ENTER("write_event_header_and_base64");
-
-  /* Write header and base64 output to cache */
-  ev->print_header(head, print_event_info, FALSE);
-  ev->print_base64(body, print_event_info, FALSE);
-
-  /* Read data from cache and write to result file */
-  if (copy_event_cache_to_file_and_reinit(head, result_file) ||
-      copy_event_cache_to_file_and_reinit(body, result_file))
-  {
-    error("Error writing event to file.");
-    DBUG_RETURN(ERROR_STOP);
-  }
-  DBUG_RETURN(OK_CONTINUE);
-}
-
-
-/**
   Print the given event, and either delete it or delegate the deletion
   to someone else.
 
@@ -745,15 +706,7 @@ Exit_status process_event(PRINT_EVENT_IN
       if (!((Query_log_event*)ev)->is_trans_keyword() &&
           shall_skip_database(((Query_log_event*)ev)->db))
         goto end;
-      if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
-      {
-        if ((retval= write_event_header_and_base64(ev, result_file,
-                                                   print_event_info)) !=
-            OK_CONTINUE)
-          goto end;
-      }
-      else
-        ev->print(result_file, print_event_info);
+      ev->print(result_file, print_event_info);
       break;
 
     case CREATE_FILE_EVENT:
@@ -774,15 +727,7 @@ Exit_status process_event(PRINT_EVENT_IN
 	filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' 
 	below.
       */
-      if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
-      {
-        if ((retval= write_event_header_and_base64(ce, result_file,
-                                                   print_event_info)) !=
-            OK_CONTINUE)
-          goto end;
-      }
-      else
-        ce->print(result_file, print_event_info, TRUE);
+      ce->print(result_file, print_event_info, TRUE);
 
       // If this binlog is not 3.23 ; why this test??
       if (glob_description_event->binlog_version >= 3)
@@ -1015,12 +960,10 @@ static struct my_option my_long_options[
    "row-based events; 'decode-rows' decodes row events into commented SQL "
    "statements if the --verbose option is also given; 'auto' prints base64 "
    "only when necessary (i.e., for row-based events and format description "
-   "events); 'always' prints base64 whenever possible. 'always' is for "
-   "debugging only and should not be used in a production system. If this "
-   "argument is not given, the default is 'auto'; if it is given with no "
-   "argument, 'always' is used.",
+   "events).  If no --base64-output[=name] option is given at all, the "
+   "default is 'auto'.",
    &opt_base64_output_mode_str, &opt_base64_output_mode_str,
-   0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   /*
     mysqlbinlog needs charsets knowledge, to be able to convert a charset
     number found in binlog to a charset name (to be able to print things
@@ -1347,13 +1290,8 @@ get_one_option(int optid, const struct m
     stop_datetime= convert_str_to_timestamp(stop_datetime_str);
     break;
   case OPT_BASE64_OUTPUT_MODE:
-    if (argument == NULL)
-      opt_base64_output_mode= BASE64_OUTPUT_ALWAYS;
-    else
-    {
-      opt_base64_output_mode= (enum_base64_output_mode)
-        (find_type_or_exit(argument, &base64_output_mode_typelib, opt->name)-1);
-    }
+    opt_base64_output_mode= (enum_base64_output_mode)
+      (find_type_or_exit(argument, &base64_output_mode_typelib, opt->name)-1);
     break;
   case 'v':
     if (argument == disabled_my_option)
@@ -1928,8 +1866,7 @@ static Exit_status check_header(IO_CACHE
                 (ulonglong)tmp_pos);
           return ERROR_STOP;
         }
-        if (opt_base64_output_mode == BASE64_OUTPUT_AUTO
-            || opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
+        if (opt_base64_output_mode == BASE64_OUTPUT_AUTO)
         {
           /*
             process_event will delete *description_event and set it to

=== modified file 'cmake/mysql_version.cmake'
--- a/cmake/mysql_version.cmake	revid:jimmy.yang@stripped105133317-dvev6424yzogf4gq
+++ b/cmake/mysql_version.cmake	revid:vasil.dimov@strippedg75x0
@@ -42,6 +42,9 @@ MACRO(GET_MYSQL_VERSION)
         IF(NOT VERSION_STRING)
           FILE(STRINGS  configure.in  str REGEX "AC_INIT\\(")
           STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][a-zAZ0-9]+" VERSION_STRING "${str}")
+          IF(NOT VERSION_STRING)
+            STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}")
+          ENDIF()
         ENDIF()
       ENDIF()
     ENDIF()

=== modified file 'config/ac-macros/maintainer.m4'
--- a/config/ac-macros/maintainer.m4	revid:jimmy.yang@stripped
+++ b/config/ac-macros/maintainer.m4	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -19,6 +19,7 @@ AC_DEFUN([MY_MAINTAINER_MODE_WARNINGS], 
   AS_IF([test "$GCC" = "yes"], [
     C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror"
     CXX_WARNINGS="${C_WARNINGS} -Wno-unused-parameter"
+    C_WARNINGS="${C_WARNINGS} -Wdeclaration-after-statement"
   ])
 
   # Test whether the warning options work.

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	revid:jimmy.yang@stripped
+++ b/include/my_sys.h	revid:vasil.dimov@stripped08144220-zlcp5sg51xgg75x0
@@ -256,7 +256,7 @@ extern my_bool  my_disable_locking, my_d
 extern char	wild_many,wild_one,wild_prefix;
 extern const char *charsets_dir;
 /* from default.c */
-extern char *my_defaults_extra_file;
+extern const char *my_defaults_extra_file;
 extern const char *my_defaults_group_suffix;
 extern const char *my_defaults_file;
 

=== modified file 'include/mysql/plugin_auth.h'
--- a/include/mysql/plugin_auth.h	revid:jimmy.yang@oracle.com-20101105133317-dvev6424yzogf4gq
+++ b/include/mysql/plugin_auth.h	revid:vasil.dimov@stripped144220-zlcp5sg51xgg75x0
@@ -90,8 +90,8 @@ typedef struct st_mysql_server_auth_info
   int  password_used;
 
   /**
-    Set to the name of the connected client if it can be resolved, or to 
-    the address otherwise
+    Set to the name of the connected client host, if it can be resolved, 
+    or to its IP address otherwise.
   */
   const char *host_or_ip;
 
@@ -107,7 +107,7 @@ typedef struct st_mysql_server_auth_info
 */
 struct st_mysql_auth
 {
-  int interface_version;                        /**< version plugin uses */
+  int interface_version;                        /** version plugin uses */
   /**
     A plugin that a client must use for authentication with this server
     plugin. Can be NULL to mean "any plugin".

=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc	revid:jimmy.yang@strippedzogf4gq
+++ b/libmysqld/lib_sql.cc	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -506,7 +506,8 @@ int init_embedded_server(int argc, char 
 
   orig_argc= *argcp;
   orig_argv= *argvp;
-  load_defaults("my", (const char **)groups, argcp, argvp);
+  if (load_defaults("my", (const char **)groups, argcp, argvp))
+    return 1;
   defaults_argc= *argcp;
   defaults_argv= *argvp;
   remaining_argc= argc;

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	revid:jimmy.yang@stripped05133317-dvev6424yzogf4gq
+++ b/mysql-test/collections/default.experimental	revid:vasil.dimov@stripped44220-zlcp5sg51xgg75x0
@@ -17,6 +17,7 @@ main.log_tables                         
 main.lowercase_table2 @darwin            # Bug#55509 2010-07-26 alik main.lowercase_table2 fails on Mac OSX (again)
 main.mysqlslap @windows                  # Bug#54024 2010-08-10 alik mysqlslap fails sporadically starting from Dahlia
 main.outfile_loaddata @solaris           # Bug#46895 2010-01-20 alik Test "outfile_loaddata" fails (reproducible)
+main.server_uuid                         # Bug#57482 2010-11-02 alik server_uuid fails on PB2
 main.signal_demo3 @solaris               # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 main.sp @solaris                         # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 main.type_float @freebsd                 # Bug#38965 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	revid:jimmy.yang@strippedyzogf4gq
+++ b/mysql-test/mysql-test-run.pl	revid:vasil.dimov@stripped
@@ -4463,7 +4463,13 @@ sub mysqld_arguments ($$$) {
   my $mysqld=            shift;
   my $extra_opts=        shift;
 
-  mtr_add_arg($args, "--defaults-file=%s",  $path_config_file);
+  my @defaults = grep(/^--defaults-file=/, @$extra_opts);
+  if (@defaults > 0) {
+    mtr_add_arg($args, pop(@defaults))
+  }
+  else {
+    mtr_add_arg($args, "--defaults-file=%s",  $path_config_file);
+  }
 
   # When mysqld is run by a root user(euid is 0), it will fail
   # to start unless we specify what user to run as, see BUG#30630
@@ -4499,6 +4505,9 @@ sub mysqld_arguments ($$$) {
   my $found_skip_core= 0;
   foreach my $arg ( @$extra_opts )
   {
+    # Skip --defaults-file option since it's handled above.
+    next if $arg =~ /^--defaults-file/;
+
     # Allow --skip-core-file to be set in <testname>-[master|slave].opt file
     if ($arg eq "--skip-core-file")
     {
@@ -5323,8 +5332,7 @@ sub gdb_arguments {
 	       "break mysql_parse\n" .
 	       "commands 1\n" .
 	       "disable 1\n" .
-	       "end\n" .
-	       "run");
+	       "end\n");
   }
 
   if ( $opt_manual_gdb )

=== modified file 'mysql-test/r/1st.result'
--- a/mysql-test/r/1st.result	revid:jimmy.yang@strippedvev6424yzogf4gq
+++ b/mysql-test/r/1st.result	revid:vasil.dimov@stripped
@@ -21,7 +21,7 @@ ndb_binlog_index
 plugin
 proc
 procs_priv
-proxy_priv
+proxies_priv
 servers
 slow_log
 tables_priv

=== modified file 'mysql-test/r/connect.result'
--- a/mysql-test/r/connect.result	revid:jimmy.yang@stripped105133317-dvev6424yzogf4gq
+++ b/mysql-test/r/connect.result	revid:vasil.dimov@strippedxgg75x0
@@ -15,7 +15,7 @@ ndb_binlog_index
 plugin
 proc
 procs_priv
-proxy_priv
+proxies_priv
 servers
 slow_log
 tables_priv
@@ -49,7 +49,7 @@ ndb_binlog_index
 plugin
 proc
 procs_priv
-proxy_priv
+proxies_priv
 servers
 slow_log
 tables_priv
@@ -91,7 +91,7 @@ ndb_binlog_index
 plugin
 proc
 procs_priv
-proxy_priv
+proxies_priv
 servers
 slow_log
 tables_priv

=== modified file 'mysql-test/r/ctype_binary.result'
--- a/mysql-test/r/ctype_binary.result	revid:jimmy.yang@strippedf4gq
+++ b/mysql-test/r/ctype_binary.result	revid:vasil.dimov@stripped
@@ -1425,7 +1425,7 @@ create table t1 as select concat(time_to
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `c1` varbinary(10) NOT NULL DEFAULT ''
+  `c1` varbinary(10) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 select hex(concat(extract(year from 20090702)));

=== modified file 'mysql-test/r/ctype_cp1251.result'
--- a/mysql-test/r/ctype_cp1251.result	revid:jimmy.yang@stripped
+++ b/mysql-test/r/ctype_cp1251.result	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -1507,7 +1507,7 @@ create table t1 as select concat(time_to
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT ''
+  `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 select hex(concat(extract(year from 20090702)));

=== modified file 'mysql-test/r/ctype_latin1.result'
--- a/mysql-test/r/ctype_latin1.result	revid:jimmy.yang@strippedom-20101105133317-dvev6424yzogf4gq
+++ b/mysql-test/r/ctype_latin1.result	revid:vasil.dimov@stripped220-zlcp5sg51xgg75x0
@@ -1835,7 +1835,7 @@ create table t1 as select concat(time_to
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `c1` varchar(10) NOT NULL DEFAULT ''
+  `c1` varchar(10) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 select hex(concat(extract(year from 20090702)));

=== modified file 'mysql-test/r/ctype_uca.result'
--- a/mysql-test/r/ctype_uca.result	revid:jimmy.yang@stripped317-dvev6424yzogf4gq
+++ b/mysql-test/r/ctype_uca.result	revid:vasil.dimov@stripped5x0
@@ -2476,111 +2476,6 @@ Z,z,��,��,��,�ncat(c1 order by c1) from t1 group by c1 collate utf8_vietnamese_520_ci;
-group_concat(c1 order by c1)
-��
-,��,��,��,��,��,��,��,��e,��,��,��,��,��,��
-��,�,��,��,��,��,��,��
-CH,Ch,cH,ch
-��,��
-D,d,��,��,��,��
-DZ,Dz,dZ,dz,��,��,��,��,��,��
-��,����,���,���,���
-��,��,,���,���,���,���
-��,��
-��
-��
-F,f
-��,��
-G,g,��,��,��,��,��,��,��,��,��,��,�H,h,��,��,��,��
-��,��
-I,i,�,��,��,��,��,��,��,��,��,��,��,���,���,���,���
-IJ,Ij,iJ,ij,��,��
-��
-��
-��
-J,j,�,��
-L,l,��,��,��,��,��,��,J,Nj,nJ,nj,��,��,��
-��
-��
-��,,��,���,���,���,���
-OE,Oe,oE,oe,��,��
-��,��,���,���,���,���,���,���,���,���,���,���
-��
-��
-P,p
-��,��
-Q,q
-��
-R,r,��,��,��,��,��,��,��,��,��,��,��,��,��,�,���,���,���,���,���,���,���
-��
-��
-V,v
-��
-W,w,��,-��,��
-Z,z,��,��,��,��,��,,��
-��
-��,��
-��,��
-��
-
-��
-��
-��
 ALTER TABLE t1 CONVERT TO CHARACTER SET ucs2 COLLATE ucs2_bin;
 SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_unicode_ci;
 GROUP_CONCAT(c1 ORDER BY c1)
@@ -4870,111 +4765,6 @@ Z,z,��,��,��,��,��,��
 ��
 �OUP BY c1 COLLATE ucs2_vietnamese_520_ci;
-GROUP_CONCAT(c1 ORDER BY c1)
-��
-��
-A,a,��,��,��,��,��,��,��,��,��,��,��,,���,���,���,���,���,���,���
-��,��,���,���,����,��
-��,��
-��
-��
-��,���,��,��,��,��,��,��,��,��,���,���,���,���,���,���
-��,��
-��
-��
-F,f
-��,��
-G,g,��,��,��,��,��,��,��,��,��,��,��,��
-��,��
-�
-��,��
-I,i,��,��,��,��,��,
-��
-��
-J,j,��,��,��
-K,k,��,j,lJ,lj,��,��,��
-LL,Ll,lL,ll
-��
-��
-M,m
-N,n,��,��,��,��,��,��,�
-��
-��
-��,��
-O,o,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,���
-OE,Oe,oE,oe,��,��
-��,���,��,��,��
-RR,Rr,rR,rr
-��
-S,s,��,��,��,��,��,��,��,��,�,��,��
-��
-��,��
-��
-��,��
-��
-U,u,��,��,��,��,��,�,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,��,���,���,���,���,���,���,���,���,���
-��
-��
-V,v
-��
-W,w,��,��
-X,x
-Y,y,��,��,-��,��
-��
-��,��
-��,��
-��,��
-��
-��
-��
-��
-��
 drop table t1;
 SET NAMES utf8;
 CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE utf8_general_ci, INDEX (c));

=== modified file 'mysql-test/r/ctype_ucs.result'
--- a/mysql-test/r/ctype_ucs.result	revid:jimmy.yang@stripped5133317-dvev6424yzogf4gq
+++ b/mysql-test/r/ctype_ucs.result	revid:vasil.dimov@strippedxgg75x0
@@ -2733,7 +2733,7 @@ create table t1 as select concat(time_to
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT ''
+  `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 select hex(concat(extract(year from 20090702)));

=== modified file 'mysql-test/r/ctype_utf16_uca.result'
--- a/mysql-test/r/ctype_utf16_uca.result	revid:jimmy.yang@stripped
+++ b/mysql-test/r/ctype_utf16_uca.result	revid:vasil.dimov@stripped
@@ -2485,111 +2485,6 @@ Zz������������
 ��
 ��
 ��
-select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_vietnamese_520_ci;
-group_concat(c1 order by binary c1 separator '')
-��
-��
-Aa�����������������
-�������������������������
-CHChcHch
-����
-Dd��������
-DZDzdZdz��-�������������������
-��
-��
-Ff
-����
-Gg�����-����
-��
-��
-����
-Hh���
-Jj������
-Kk��������
-��
-��
-Mm
-Nn��������������������������������������������������������������
-OEOeoEoe�������������������
-��p
-����
-Qq
-��
-Rr������������������������������
-��
-��
-Vv
-��
-Ww����
-Xx
-Yy������������
-����
-Zz������������
-��
-���ble t1;
 SET NAMES utf8;
 CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL, INDEX (c));

=== modified file 'mysql-test/r/ctype_utf32_uca.result'
--- a/mysql-test/r/ctype_utf32_uca.result	revid:jimmy.yang@stripped
+++ b/mysql-test/r/ctype_utf32_uca.result	revid:vasil.dimov@stripped
@@ -2485,111 +2485,6 @@ Zz������������
 � c1 separator '') from t1 group by c1 collate utf32_vietnamese_520_ci;
-group_concat(c1 order by binary c1 separator '')
-��
-��
-Aa���������������������������������
-�����������������������
-����
-��
-��
-����
-Ee��������������������������������������������������
-������������������
-����
-����
-Ii��������������������������������������������������
-IJIjiJij����
-��
-��
-��
-Jj������
-Kk��������
-������
-LJLjlJlj������
-LLLllLll
-�-��
-����
-Oo����������-�������������������������������������������������
-��
-��
-Pp
-����
-Qq
-��
-Rr������������������
-SSSssSss��
-��
-��
-����
-��
-Uu���������Yy������������
-����
-Zz
-������
-����
-��
-����
-����
-��
-����
-����
-����
-��
-��
-��
-��
-��
 drop table t1;
 SET NAMES utf8;
 CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL, INDEX (c));

=== modified file 'mysql-test/r/ctype_utf8.result'
--- a/mysql-test/r/ctype_utf8.result	revid:jimmy.yang@oracle.com-20101105133317-dvev6424yzogf4gq
+++ b/mysql-test/r/ctype_utf8.result	revid:vasil.dimov@stripped1108144220-zlcp5sg51xgg75x0
@@ -3602,7 +3602,7 @@ create table t1 as select concat(time_to
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `c1` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT ''
+  `c1` varchar(10) CHARACTER SET utf8 DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 select hex(concat(extract(year from 20090702)));

=== modified file 'mysql-test/r/errors.result'
--- a/mysql-test/r/errors.result	revid:jimmy.yang@strippedgq
+++ b/mysql-test/r/errors.result	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -134,3 +134,15 @@ INSERT INTO t1 VALUES ('abc\0\0');
 INSERT INTO t1 VALUES ('abc\0\0');
 ERROR 23000: Duplicate entry 'abc\x00\x00' for key 'PRIMARY'
 DROP TABLE t1;
+#
+# Bug#57882: Item_func_conv_charset::val_str(String*): 
+#            Assertion `fixed == 1' failed
+#
+SELECT (CONVERT('0' USING latin1) IN (CHAR(COT('v') USING utf8),''));
+ERROR 22003: DOUBLE value is out of range in 'cot('v')'
+SET NAMES utf8 COLLATE utf8_latvian_ci ;
+SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null);
+ERROR 22003: BIGINT value is out of range in '(-(73) * -(2465717823867977728))'
+#
+# End Bug#57882
+#

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	revid:jimmy.yang@stripped05133317-dvev6424yzogf4gq
+++ b/mysql-test/r/func_time.result	revid:vasil.dimov@stripped1xgg75x0
@@ -1315,6 +1315,20 @@ SELECT 1 FROM t1 ORDER BY @x:=makedate(a
 1
 1
 DROP TABLE t1;
+#
+# Bug #52160: crash and inconsistent results when grouping
+#             by a function and column
+#
+CREATE TABLE t1(a CHAR(10) NOT NULL);
+INSERT INTO t1 VALUES (''),('');
+SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
+COUNT(*)
+2
+Warnings:
+Warning	1292	Truncated incorrect time value: ''
+Warning	1292	Truncated incorrect time value: ''
+Warning	1292	Truncated incorrect time value: ''
+DROP TABLE t1;
 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	revid:jimmy.yang@stripped133317-dvev6424yzogf4gq
+++ b/mysql-test/r/information_schema.result	revid:vasil.dimov@strippedlcp5sg51xgg75x0
@@ -88,7 +88,7 @@ host
 plugin
 proc
 procs_priv
-proxy_priv
+proxies_priv
 servers
 slow_log
 tables_priv

=== modified file 'mysql-test/r/keywords.result'
--- a/mysql-test/r/keywords.result	revid:jimmy.yang@oracle.com-20101105133317-dvev6424yzogf4gq
+++ b/mysql-test/r/keywords.result	revid:vasil.dimov@stripped4220-zlcp5sg51xgg75x0
@@ -45,3 +45,227 @@ p1
 max=1
 drop procedure p1;
 drop table t1;
+CREATE TABLE slow (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO slow(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO slow(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO slow(slow, general) VALUES (1,2), (5,6);
+INSERT INTO slow(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM slow ORDER BY slow;
+slow	general	master_heartbeat_period	ignore_server_ids
+1	2	3	4
+1	2	3	NULL
+1	2	NULL	NULL
+1	NULL	NULL	NULL
+5	6	7	8
+5	6	7	NULL
+5	6	NULL	NULL
+5	NULL	NULL	NULL
+SELECT slow, general, master_heartbeat_period FROM slow ORDER BY slow;
+slow	general	master_heartbeat_period
+1	2	3
+1	2	3
+1	2	NULL
+1	NULL	NULL
+5	6	7
+5	6	7
+5	6	NULL
+5	NULL	NULL
+SELECT slow, master_heartbeat_period FROM slow ORDER BY slow;
+slow	master_heartbeat_period
+1	3
+1	3
+1	NULL
+1	NULL
+5	7
+5	7
+5	NULL
+5	NULL
+SELECT slow FROM slow ORDER BY slow;
+slow
+1
+1
+1
+1
+5
+5
+5
+5
+DROP TABLE slow;
+CREATE TABLE general (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO general(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO general(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO general(slow, general) VALUES (1,2), (5,6);
+INSERT INTO general(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM general ORDER BY slow;
+slow	general	master_heartbeat_period	ignore_server_ids
+1	2	3	4
+1	2	3	NULL
+1	2	NULL	NULL
+1	NULL	NULL	NULL
+5	6	7	8
+5	6	7	NULL
+5	6	NULL	NULL
+5	NULL	NULL	NULL
+SELECT slow, general, master_heartbeat_period FROM general ORDER BY slow;
+slow	general	master_heartbeat_period
+1	2	3
+1	2	3
+1	2	NULL
+1	NULL	NULL
+5	6	7
+5	6	7
+5	6	NULL
+5	NULL	NULL
+SELECT slow, master_heartbeat_period FROM general ORDER BY slow;
+slow	master_heartbeat_period
+1	3
+1	3
+1	NULL
+1	NULL
+5	7
+5	7
+5	NULL
+5	NULL
+SELECT slow FROM general ORDER BY slow;
+slow
+1
+1
+1
+1
+5
+5
+5
+5
+DROP TABLE general;
+CREATE TABLE master_heartbeat_period (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO master_heartbeat_period(slow, general) VALUES (1,2), (5,6);
+INSERT INTO master_heartbeat_period(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM master_heartbeat_period ORDER BY slow;
+slow	general	master_heartbeat_period	ignore_server_ids
+1	2	3	4
+1	2	3	NULL
+1	2	NULL	NULL
+1	NULL	NULL	NULL
+5	6	7	8
+5	6	7	NULL
+5	6	NULL	NULL
+5	NULL	NULL	NULL
+SELECT slow, general, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow;
+slow	general	master_heartbeat_period
+1	2	3
+1	2	3
+1	2	NULL
+1	NULL	NULL
+5	6	7
+5	6	7
+5	6	NULL
+5	NULL	NULL
+SELECT slow, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow;
+slow	master_heartbeat_period
+1	3
+1	3
+1	NULL
+1	NULL
+5	7
+5	7
+5	NULL
+5	NULL
+SELECT slow FROM master_heartbeat_period ORDER BY slow;
+slow
+1
+1
+1
+1
+5
+5
+5
+5
+DROP TABLE master_heartbeat_period;
+CREATE TABLE ignore_server_ids (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO ignore_server_ids(slow, general) VALUES (1,2), (5,6);
+INSERT INTO ignore_server_ids(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM ignore_server_ids ORDER BY slow;
+slow	general	master_heartbeat_period	ignore_server_ids
+1	2	3	4
+1	2	3	NULL
+1	2	NULL	NULL
+1	NULL	NULL	NULL
+5	6	7	8
+5	6	7	NULL
+5	6	NULL	NULL
+5	NULL	NULL	NULL
+SELECT slow, general, master_heartbeat_period FROM ignore_server_ids ORDER BY slow;
+slow	general	master_heartbeat_period
+1	2	3
+1	2	3
+1	2	NULL
+1	NULL	NULL
+5	6	7
+5	6	7
+5	6	NULL
+5	NULL	NULL
+SELECT slow, master_heartbeat_period FROM ignore_server_ids ORDER BY slow;
+slow	master_heartbeat_period
+1	3
+1	3
+1	NULL
+1	NULL
+5	7
+5	7
+5	NULL
+5	NULL
+SELECT slow FROM ignore_server_ids ORDER BY slow;
+slow
+1
+1
+1
+1
+5
+5
+5
+5
+DROP TABLE ignore_server_ids;
+CREATE TABLE t1 (slow INT, general INT, ignore_server_ids INT, master_heartbeat_period INT);
+INSERT INTO t1 VALUES (1,2,3,4);
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE slow INT;
+DECLARE general INT;
+DECLARE ignore_server_ids INT;
+DECLARE master_heartbeat_period INT;
+SELECT max(t1.slow) INTO slow FROM t1;
+SELECT max(t1.general) INTO general FROM t1;
+SELECT max(t1.ignore_server_ids) INTO ignore_server_ids FROM t1;
+SELECT max(t1.master_heartbeat_period) INTO master_heartbeat_period FROM t1;
+SELECT slow, general, ignore_server_ids, master_heartbeat_period;
+END|
+CREATE PROCEDURE p2()
+BEGIN
+DECLARE n INT DEFAULT 2;
+general: WHILE n > 0 DO 
+SET n = n -1;
+END WHILE general;
+SET n = 2;
+slow: WHILE n > 0 DO 
+SET n = n -1;
+END WHILE slow;
+SET n = 2;
+ignore_server_ids: WHILE n > 0 DO 
+SET n = n -1;
+END WHILE ignore_server_ids;
+SET n = 2;
+master_heartbeat_period: WHILE n > 0 DO 
+SET n = n -1;
+END WHILE master_heartbeat_period;
+END|
+CALL p1();
+slow	general	ignore_server_ids	master_heartbeat_period
+1	2	3	4
+call p2();
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP TABLE t1;

=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	revid:jimmy.yang@stripped317-dvev6424yzogf4gq
+++ b/mysql-test/r/log_tables.result	revid:vasil.dimov@stripped75x0
@@ -896,6 +896,16 @@ TIMESTAMP	1	1	SELECT SQL_NO_CACHE 'Bug#3
 TIMESTAMP	1	1	SELECT SQL_NO_CACHE 'Bug#31700 - PK',  f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2
 DROP TABLE t1;
 TRUNCATE TABLE mysql.slow_log;
+use mysql;
+drop table if exists renamed_general_log;
+drop table if exists renamed_slow_log;
+RENAME TABLE general_log TO renamed_general_log;
+ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log'
+RENAME TABLE slow_log TO renamed_slow_log;
+ERROR HY000: Cannot rename 'slow_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'slow_log'
+use test;
+flush tables with read lock;
+unlock tables;
 SET @@session.long_query_time= @old_long_query_time;
 SET @@global.log_output=       @old_log_output;
 SET @@global.slow_query_log=   @old_slow_query_log;

=== modified file 'mysql-test/r/log_tables_upgrade.result'
--- a/mysql-test/r/log_tables_upgrade.result	revid:jimmy.yang@strippedf4gq
+++ b/mysql-test/r/log_tables_upgrade.result	revid:vasil.dimov@stripped
@@ -27,7 +27,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.renamed_general_log                          OK
 mysql.servers                                      OK
 mysql.slow_log                                     OK

=== modified file 'mysql-test/r/mysql_upgrade.result'
--- a/mysql-test/r/mysql_upgrade.result	revid:jimmy.yang@stripped133317-dvev6424yzogf4gq
+++ b/mysql-test/r/mysql_upgrade.result	revid:vasil.dimov@strippedg51xgg75x0
@@ -15,7 +15,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
@@ -44,7 +44,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
@@ -73,7 +73,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
@@ -104,7 +104,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
@@ -139,7 +139,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK
@@ -177,7 +177,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK

=== modified file 'mysql-test/r/mysql_upgrade_ssl.result'
--- a/mysql-test/r/mysql_upgrade_ssl.result	revid:jimmy.yang@oracle.com-20101105133317-dvev6424yzogf4gq
+++ b/mysql-test/r/mysql_upgrade_ssl.result	revid:vasil.dimov@stripped101108144220-zlcp5sg51xgg75x0
@@ -17,7 +17,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log                                     OK
 mysql.tables_priv                                  OK

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	revid:jimmy.yang@stripped
+++ b/mysql-test/r/mysqlbinlog.result	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -879,3 +879,9 @@ ROLLBACK /* added by mysqlbinlog */;
 /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
 End of 5.0 tests
 End of 5.1 tests
+# Expect error for unknown argument.
+Unknown option to base64-output: always
+Alternatives are: 'NEVER','AUTO','UNSPEC','DECODE-ROWS'
+# Expect error for unknown argument again.
+Unknown option to base64-output: std_data/master-bin.000001
+Alternatives are: 'NEVER','AUTO','UNSPEC','DECODE-ROWS'

=== modified file 'mysql-test/r/mysqlcheck.result'
--- a/mysql-test/r/mysqlcheck.result	revid:jimmy.yang@strippedf4gq
+++ b/mysql-test/r/mysqlcheck.result	revid:vasil.dimov@stripped
@@ -18,7 +18,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log
 note     : The storage engine for the table doesn't support analyze
@@ -46,7 +46,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log
 note     : The storage engine for the table doesn't support optimize
@@ -72,7 +72,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       OK
 mysql.proc                                         OK
 mysql.procs_priv                                   OK
-mysql.proxy_priv                                   OK
+mysql.proxies_priv                                 OK
 mysql.servers                                      OK
 mysql.slow_log
 note     : The storage engine for the table doesn't support analyze
@@ -98,7 +98,7 @@ mysql.ndb_binlog_index                  
 mysql.plugin                                       Table is already up to date
 mysql.proc                                         Table is already up to date
 mysql.procs_priv                                   Table is already up to date
-mysql.proxy_priv                                   Table is already up to date
+mysql.proxies_priv                                 Table is already up to date
 mysql.servers                                      Table is already up to date
 mysql.slow_log
 note     : The storage engine for the table doesn't support optimize

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	revid:jimmy.yang@oracle.com-20101105133317-dvev6424yzogf4gq
+++ b/mysql-test/r/mysqld--help-notwin.result	revid:vasil.dimov@stripped0101108144220-zlcp5sg51xgg75x0
@@ -19,6 +19,7 @@ The following options may be given as th
  --auto-increment-offset[=#] 
  Offset added to Auto-increment columns. Used when
  auto-increment-increment != 1
+ --autocommit        Set default value for autocommit (0 or 1)
  --automatic-sp-privileges 
  Creating and dropping stored procedures alters ACLs
  (Defaults to on; use --skip-automatic-sp-privileges to disable.)

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	revid:jimmy.yang@stripped4yzogf4gq
+++ b/mysql-test/r/mysqld--help-win.result	revid:vasil.dimov@stripped
@@ -19,6 +19,7 @@ The following options may be given as th
  --auto-increment-offset[=#] 
  Offset added to Auto-increment columns. Used when
  auto-increment-increment != 1
+ --autocommit        Set default value for autocommit (0 or 1)
  --automatic-sp-privileges 
  Creating and dropping stored procedures alters ACLs
  (Defaults to on; use --skip-automatic-sp-privileges to disable.)

=== modified file 'mysql-test/r/plugin_auth.result'
--- a/mysql-test/r/plugin_auth.result	revid:jimmy.yang@stripped05133317-dvev6424yzogf4gq
+++ b/mysql-test/r/plugin_auth.result	revid:vasil.dimov@strippedg51xgg75x0
@@ -11,6 +11,26 @@ test_plugin_server	plug_dest
 ## test plugin auth
 ERROR 28000: Access denied for user 'plug'@'localhost' (using password: YES)
 GRANT PROXY ON plug_dest TO plug;
+test proxies_priv columns
+SELECT * FROM mysql.proxies_priv;
+Host	User	Proxied_host	Proxied_user	With_grant	Grantor	Timestamp
+xx	root			1		xx
+xx	root			1		xx
+xx	plug	%	plug_dest	0	root@localhost	xx
+test mysql.proxies_priv;
+SHOW CREATE TABLE mysql.proxies_priv;
+Table	Create Table
+proxies_priv	CREATE TABLE `proxies_priv` (
+  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
+  `User` char(16) COLLATE utf8_bin NOT NULL DEFAULT '',
+  `Proxied_host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
+  `Proxied_user` char(16) COLLATE utf8_bin NOT NULL DEFAULT '',
+  `With_grant` tinyint(1) NOT NULL DEFAULT '0',
+  `Grantor` char(77) COLLATE utf8_bin NOT NULL DEFAULT '',
+  `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  PRIMARY KEY (`Host`,`User`,`Proxied_host`,`Proxied_user`),
+  KEY `Grantor` (`Grantor`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User proxy privileges'
 select USER(),CURRENT_USER();
 USER()	CURRENT_USER()
 plug@localhost	plug_dest@%
@@ -146,8 +166,8 @@ Grants for test_drop@localhost
 GRANT USAGE ON *.* TO 'test_drop'@'localhost'
 GRANT PROXY ON 'future_user'@'%' TO 'test_drop'@'localhost'
 DROP USER test_drop@localhost;
-SELECT * FROM mysql.proxy_priv WHERE Host = 'test_drop' AND User = 'localhost';
-Host	User	Proxied_Host	Proxied_User	With_Grant
+SELECT * FROM mysql.proxies_priv WHERE Host = 'test_drop' AND User = 'localhost';
+Host	User	Proxied_host	Proxied_user	With_grant	Grantor	Timestamp
 DROP USER proxy_admin;
 DROP USER grant_plug,grant_plug_dest,grant_plug_dest2;
 ## END GRANT PROXY tests

=== modified file 'mysql-test/r/system_mysql_db.result'
--- a/mysql-test/r/system_mysql_db.result	revid:jimmy.yang@stripped33317-dvev6424yzogf4gq
+++ b/mysql-test/r/system_mysql_db.result	revid:vasil.dimov@strippedsg51xgg75x0
@@ -14,7 +14,7 @@ ndb_binlog_index
 plugin
 proc
 procs_priv
-proxy_priv
+proxies_priv
 servers
 slow_log
 tables_priv

=== modified file 'mysql-test/r/type_blob.result'
--- a/mysql-test/r/type_blob.result	revid:jimmy.yang@stripped
+++ b/mysql-test/r/type_blob.result	revid:vasil.dimov@stripped-20101108144220-zlcp5sg51xgg75x0
@@ -975,4 +975,14 @@ SELECT LENGTH(c) FROM t2;
 LENGTH(c)
 65535
 DROP TABLE t1, t2;
+# Bug #52160: crash and inconsistent results when grouping
+#             by a function and column
+CREATE FUNCTION f1() RETURNS TINYBLOB RETURN 1;
+CREATE TABLE t1(a CHAR(1));
+INSERT INTO t1 VALUES ('0'), ('0');
+SELECT COUNT(*) FROM t1 GROUP BY f1(), a;
+COUNT(*)
+2
+DROP FUNCTION f1;
+DROP TABLE t1;
 End of 5.1 tests

=== added file 'mysql-test/std_data/bug57108.cnf'
--- a/mysql-test/std_data/bug57108.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/std_data/bug57108.cnf	revid:vasil.dimov@stripped0101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,95 @@
+[mysqld]
+open-files-limit=1024
+character-set-server=latin1
+connect-timeout=4711
+log-bin-trust-function-creators=1
+key_buffer_size=1M
+sort_buffer=256K
+max_heap_table_size=1M
+loose-innodb_data_file_path=ibdata1:10M:autoextend
+loose-innodb_buffer_pool_size=8M
+loose-innodb_write_io_threads=2
+loose-innodb_read_io_threads=2
+loose-innodb_log_buffer_size=1M
+loose-innodb_log_file_size=5M
+loose-innodb_additional_mem_pool_size=1M
+loose-innodb_log_files_in_group=2
+slave-net-timeout=120
+log-bin=mysqld-bin
+loose-enable-performance-schema
+loose-performance-schema-max-mutex-instances=10000
+loose-performance-schema-max-rwlock-instances=10000
+loose-performance-schema-max-table-instances=500
+loose-performance-schema-max-table-handles=1000
+binlog-direct-non-transactional-updates
+
+[mysql]
+default-character-set=latin1
+
+[mysqlshow]
+default-character-set=latin1
+
+[mysqlimport]
+default-character-set=latin1
+
+[mysqlcheck]
+default-character-set=latin1
+
+[mysql_upgrade]
+default-character-set=latin1
+tmpdir=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp
+
+[mysqld.1]
+#!run-master-sh
+log-bin=master-bin
+loose-enable-performance-schema
+basedir=/home/bzr/bugs/b57108-5.5-bugteam
+tmpdir=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1
+character-sets-dir=/home/bzr/bugs/b57108-5.5-bugteam/sql/share/charsets
+lc-messages-dir=/home/bzr/bugs/b57108-5.5-bugteam/sql/share/
+datadir=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/mysqld.1/data
+pid-file=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/run/mysqld.1.pid
+#host=localhost
+port=13000
+socket=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1.sock
+#log-error=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/log/mysqld.1.err
+general_log=1
+general_log_file=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/mysqld.1/mysqld.log
+slow_query_log=1
+slow_query_log_file=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/mysqld.1/mysqld-slow.log
+#user=root
+#password=
+server-id=1
+secure-file-priv=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var
+ssl-ca=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/cacert.pem
+ssl-cert=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/server-cert.pem
+ssl-key=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/server-key.pem
+
+[mysqlbinlog]
+disable-force-if-open
+character-sets-dir=/home/bzr/bugs/b57108-5.5-bugteam/sql/share/charsets
+
+[ENV]
+MASTER_MYPORT=13000
+MASTER_MYSOCK=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1.sock
+
+[client]
+password=
+user=root
+port=13000
+host=localhost
+socket=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1.sock
+
+[mysqltest]
+ssl-ca=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/cacert.pem
+ssl-cert=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/client-cert.pem
+ssl-key=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/client-key.pem
+skip-ssl=1
+
+[client.1]
+password=
+user=root
+port=13000
+host=localhost
+socket=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1.sock
+

=== added file 'mysql-test/suite/bugs/r/bug57108.result'
--- a/mysql-test/suite/bugs/r/bug57108.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/bugs/r/bug57108.result	revid:vasil.dimov@strippedom-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,5 @@
+INSTALL PLUGIN example SONAME 'ha_example.so';
+SELECT @@global.connect_timeout AS connect_timeout, @@global.local_infile AS local_infile;
+connect_timeout	4711
+local_infile	1
+UNINSTALL PLUGIN example;

=== added file 'mysql-test/suite/bugs/t/bug57108-master.opt'
--- a/mysql-test/suite/bugs/t/bug57108-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/bugs/t/bug57108-master.opt	revid:vasil.dimov@stripped
@@ -0,0 +1,2 @@
+--defaults-file=std_data/bug57108.cnf
+$EXAMPLE_PLUGIN_OPT

=== added file 'mysql-test/suite/bugs/t/bug57108.test'
--- a/mysql-test/suite/bugs/t/bug57108.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/bugs/t/bug57108.test	revid:vasil.dimov@strippedp5sg51xgg75x0
@@ -0,0 +1,12 @@
+--source include/not_windows_embedded.inc
+--source include/have_example_plugin.inc
+
+# Test that we can install a plugin despite the fact that we have
+# switched directory after starting the server and am using a relative
+# --defaults-file.
+--replace_regex /\.dll/.so/
+eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+
+--query_vertical SELECT @@global.connect_timeout AS connect_timeout, @@global.local_infile AS local_infile
+
+UNINSTALL PLUGIN example;

=== modified file 'mysql-test/suite/funcs_1/r/is_columns_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result	revid:jimmy.yang@strippedq
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result	revid:vasil.dimov@strippedg75x0
@@ -134,11 +134,13 @@ def	mysql	procs_priv	Routine_name	4		NO	
 def	mysql	procs_priv	Routine_type	5	NULL	NO	enum	9	27	NULL	NULL	utf8	utf8_bin	enum('FUNCTION','PROCEDURE')	PRI		select,insert,update,references	
 def	mysql	procs_priv	Timestamp	8	CURRENT_TIMESTAMP	NO	timestamp	NULL	NULL	NULL	NULL	NULL	NULL	timestamp		on update CURRENT_TIMESTAMP	select,insert,update,references	
 def	mysql	procs_priv	User	3		NO	char	16	48	NULL	NULL	utf8	utf8_bin	char(16)	PRI		select,insert,update,references	
-def	mysql	proxy_priv	Host	1		NO	char	60	180	NULL	NULL	utf8	utf8_bin	char(60)	PRI		select,insert,update,references	
-def	mysql	proxy_priv	Proxied_Host	3		NO	char	16	48	NULL	NULL	utf8	utf8_bin	char(16)	PRI		select,insert,update,references	
-def	mysql	proxy_priv	Proxied_User	4		NO	char	60	180	NULL	NULL	utf8	utf8_bin	char(60)	PRI		select,insert,update,references	
-def	mysql	proxy_priv	User	2		NO	char	16	48	NULL	NULL	utf8	utf8_bin	char(16)	PRI		select,insert,update,references	
-def	mysql	proxy_priv	With_Grant	5	0	NO	tinyint	NULL	NULL	3	0	NULL	NULL	tinyint(1)			select,insert,update,references	
+def	mysql	proxies_priv	Grantor	6		NO	char	77	231	NULL	NULL	utf8	utf8_bin	char(77)	MUL		select,insert,update,references	
+def	mysql	proxies_priv	Host	1		NO	char	60	180	NULL	NULL	utf8	utf8_bin	char(60)	PRI		select,insert,update,references	
+def	mysql	proxies_priv	Proxied_host	3		NO	char	60	180	NULL	NULL	utf8	utf8_bin	char(60)	PRI		select,insert,update,references	
+def	mysql	proxies_priv	Proxied_user	4		NO	char	16	48	NULL	NULL	utf8	utf8_bin	char(16)	PRI		select,insert,update,references	
+def	mysql	proxies_priv	Timestamp	7	CURRENT_TIMESTAMP	NO	timestamp	NULL	NULL	NULL	NULL	NULL	NULL	timestamp		on update CURRENT_TIMESTAMP	select,insert,update,references	
+def	mysql	proxies_priv	User	2		NO	char	16	48	NULL	NULL	utf8	utf8_bin	char(16)	PRI		select,insert,update,references	
+def	mysql	proxies_priv	With_grant	5	0	NO	tinyint	NULL	NULL	3	0	NULL	NULL	tinyint(1)			select,insert,update,references	
 def	mysql	servers	Db	3		NO	char	64	192	NULL	NULL	utf8	utf8_general_ci	char(64)			select,insert,update,references	
 def	mysql	servers	Host	2		NO	char	64	192	NULL	NULL	utf8	utf8_general_ci	char(64)			select,insert,update,references	
 def	mysql	servers	Owner	9		NO	char	64	192	NULL	NULL	utf8	utf8_general_ci	char(64)			select,insert,update,references	
@@ -425,11 +427,13 @@ NULL	mysql	proc	modified	timestamp	NULL	
 3.0000	mysql	procs_priv	Grantor	char	77	231	utf8	utf8_bin	char(77)
 3.0000	mysql	procs_priv	Proc_priv	set	27	81	utf8	utf8_general_ci	set('Execute','Alter Routine','Grant')
 NULL	mysql	procs_priv	Timestamp	timestamp	NULL	NULL	NULL	NULL	timestamp
-3.0000	mysql	proxy_priv	Host	char	60	180	utf8	utf8_bin	char(60)
-3.0000	mysql	proxy_priv	User	char	16	48	utf8	utf8_bin	char(16)
-3.0000	mysql	proxy_priv	Proxied_Host	char	16	48	utf8	utf8_bin	char(16)
-3.0000	mysql	proxy_priv	Proxied_User	char	60	180	utf8	utf8_bin	char(60)
-NULL	mysql	proxy_priv	With_Grant	tinyint	NULL	NULL	NULL	NULL	tinyint(1)
+3.0000	mysql	proxies_priv	Host	char	60	180	utf8	utf8_bin	char(60)
+3.0000	mysql	proxies_priv	User	char	16	48	utf8	utf8_bin	char(16)
+3.0000	mysql	proxies_priv	Proxied_host	char	60	180	utf8	utf8_bin	char(60)
+3.0000	mysql	proxies_priv	Proxied_user	char	16	48	utf8	utf8_bin	char(16)
+NULL	mysql	proxies_priv	With_grant	tinyint	NULL	NULL	NULL	NULL	tinyint(1)
+3.0000	mysql	proxies_priv	Grantor	char	77	231	utf8	utf8_bin	char(77)
+NULL	mysql	proxies_priv	Timestamp	timestamp	NULL	NULL	NULL	NULL	timestamp
 3.0000	mysql	servers	Server_name	char	64	192	utf8	utf8_general_ci	char(64)
 3.0000	mysql	servers	Host	char	64	192	utf8	utf8_general_ci	char(64)
 3.0000	mysql	servers	Db	char	64	192	utf8	utf8_general_ci	char(64)

=== modified file 'mysql-test/suite/funcs_1/r/is_key_column_usage.result'
--- a/mysql-test/suite/funcs_1/r/is_key_column_usage.result	revid:jimmy.yang@stripped1105133317-dvev6424yzogf4gq
+++ b/mysql-test/suite/funcs_1/r/is_key_column_usage.result	revid:vasil.dimov@strippedom-20101108144220-zlcp5sg51xgg75x0
@@ -106,10 +106,10 @@ def	mysql	PRIMARY	def	mysql	procs_priv	D
 def	mysql	PRIMARY	def	mysql	procs_priv	User
 def	mysql	PRIMARY	def	mysql	procs_priv	Routine_name
 def	mysql	PRIMARY	def	mysql	procs_priv	Routine_type
-def	mysql	PRIMARY	def	mysql	proxy_priv	Host
-def	mysql	PRIMARY	def	mysql	proxy_priv	User
-def	mysql	PRIMARY	def	mysql	proxy_priv	Proxied_Host
-def	mysql	PRIMARY	def	mysql	proxy_priv	Proxied_User
+def	mysql	PRIMARY	def	mysql	proxies_priv	Host
+def	mysql	PRIMARY	def	mysql	proxies_priv	User
+def	mysql	PRIMARY	def	mysql	proxies_priv	Proxied_host
+def	mysql	PRIMARY	def	mysql	proxies_priv	Proxied_user
 def	mysql	PRIMARY	def	mysql	servers	Server_name
 def	mysql	PRIMARY	def	mysql	tables_priv	Host
 def	mysql	PRIMARY	def	mysql	tables_priv	Db

=== modified file 'mysql-test/suite/funcs_1/r/is_statistics.result'
--- a/mysql-test/suite/funcs_1/r/is_statistics.result	revid:jimmy.yang@strippedq
+++ b/mysql-test/suite/funcs_1/r/is_statistics.result	revid:vasil.dimov@strippedx0
@@ -118,10 +118,11 @@ def	mysql	procs_priv	mysql	PRIMARY
 def	mysql	procs_priv	mysql	PRIMARY
 def	mysql	procs_priv	mysql	PRIMARY
 def	mysql	procs_priv	mysql	Grantor
-def	mysql	proxy_priv	mysql	PRIMARY
-def	mysql	proxy_priv	mysql	PRIMARY
-def	mysql	proxy_priv	mysql	PRIMARY
-def	mysql	proxy_priv	mysql	PRIMARY
+def	mysql	proxies_priv	mysql	PRIMARY
+def	mysql	proxies_priv	mysql	PRIMARY
+def	mysql	proxies_priv	mysql	PRIMARY
+def	mysql	proxies_priv	mysql	PRIMARY
+def	mysql	proxies_priv	mysql	Grantor
 def	mysql	servers	mysql	PRIMARY
 def	mysql	tables_priv	mysql	PRIMARY
 def	mysql	tables_priv	mysql	PRIMARY

=== modified file 'mysql-test/suite/funcs_1/r/is_statistics_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_statistics_mysql.result	revid:jimmy.yang@strippedgf4gq
+++ b/mysql-test/suite/funcs_1/r/is_statistics_mysql.result	revid:vasil.dimov@stripped5sg51xgg75x0
@@ -40,10 +40,11 @@ def	mysql	procs_priv	0	mysql	PRIMARY	2	D
 def	mysql	procs_priv	0	mysql	PRIMARY	3	User	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	procs_priv	0	mysql	PRIMARY	4	Routine_name	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	procs_priv	0	mysql	PRIMARY	5	Routine_type	A	#CARD#	NULL	NULL		BTREE		
-def	mysql	proxy_priv	0	mysql	PRIMARY	1	Host	A	#CARD#	NULL	NULL		BTREE		
-def	mysql	proxy_priv	0	mysql	PRIMARY	2	User	A	#CARD#	NULL	NULL		BTREE		
-def	mysql	proxy_priv	0	mysql	PRIMARY	3	Proxied_Host	A	#CARD#	NULL	NULL		BTREE		
-def	mysql	proxy_priv	0	mysql	PRIMARY	4	Proxied_User	A	#CARD#	NULL	NULL		BTREE		
+def	mysql	proxies_priv	1	mysql	Grantor	1	Grantor	A	#CARD#	NULL	NULL		BTREE		
+def	mysql	proxies_priv	0	mysql	PRIMARY	1	Host	A	#CARD#	NULL	NULL		BTREE		
+def	mysql	proxies_priv	0	mysql	PRIMARY	2	User	A	#CARD#	NULL	NULL		BTREE		
+def	mysql	proxies_priv	0	mysql	PRIMARY	3	Proxied_host	A	#CARD#	NULL	NULL		BTREE		
+def	mysql	proxies_priv	0	mysql	PRIMARY	4	Proxied_user	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	servers	0	mysql	PRIMARY	1	Server_name	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	tables_priv	1	mysql	Grantor	1	Grantor	A	#CARD#	NULL	NULL		BTREE		
 def	mysql	tables_priv	0	mysql	PRIMARY	1	Host	A	#CARD#	NULL	NULL		BTREE		

=== modified file 'mysql-test/suite/funcs_1/r/is_table_constraints.result'
--- a/mysql-test/suite/funcs_1/r/is_table_constraints.result	revid:jimmy.yang@stripped24yzogf4gq
+++ b/mysql-test/suite/funcs_1/r/is_table_constraints.result	revid:vasil.dimov@stripped0-zlcp5sg51xgg75x0
@@ -73,7 +73,7 @@ def	mysql	PRIMARY	mysql	ndb_binlog_index
 def	mysql	PRIMARY	mysql	plugin
 def	mysql	PRIMARY	mysql	proc
 def	mysql	PRIMARY	mysql	procs_priv
-def	mysql	PRIMARY	mysql	proxy_priv
+def	mysql	PRIMARY	mysql	proxies_priv
 def	mysql	PRIMARY	mysql	servers
 def	mysql	PRIMARY	mysql	tables_priv
 def	mysql	PRIMARY	mysql	time_zone

=== modified file 'mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result	revid:jimmy.yang@stripped
+++ b/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result	revid:vasil.dimov@strippedxgg75x0
@@ -23,7 +23,7 @@ def	mysql	PRIMARY	mysql	ndb_binlog_index
 def	mysql	PRIMARY	mysql	plugin	PRIMARY KEY
 def	mysql	PRIMARY	mysql	proc	PRIMARY KEY
 def	mysql	PRIMARY	mysql	procs_priv	PRIMARY KEY
-def	mysql	PRIMARY	mysql	proxy_priv	PRIMARY KEY
+def	mysql	PRIMARY	mysql	proxies_priv	PRIMARY KEY
 def	mysql	PRIMARY	mysql	servers	PRIMARY KEY
 def	mysql	PRIMARY	mysql	tables_priv	PRIMARY KEY
 def	mysql	PRIMARY	mysql	time_zone	PRIMARY KEY

=== modified file 'mysql-test/suite/funcs_1/r/is_tables_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_tables_mysql.result	revid:jimmy.yang@stripped
+++ b/mysql-test/suite/funcs_1/r/is_tables_mysql.result	revid:vasil.dimov@strippedx0
@@ -336,7 +336,7 @@ user_comment	Procedure privileges
 Separator	-----------------------------------------------------
 TABLE_CATALOG	def
 TABLE_SCHEMA	mysql
-TABLE_NAME	proxy_priv
+TABLE_NAME	proxies_priv
 TABLE_TYPE	BASE TABLE
 ENGINE	MyISAM
 VERSION	10

=== added file 'mysql-test/suite/parts/inc/part_exch_drop_tabs.inc'
--- a/mysql-test/suite/parts/inc/part_exch_drop_tabs.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_drop_tabs.inc	revid:vasil.dimov@strippedlcp5sg51xgg75x0
@@ -0,0 +1,15 @@
+--disable_warnings
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+--enable_warnings
+

=== added file 'mysql-test/suite/parts/inc/part_exch_qa.inc'
--- a/mysql-test/suite/parts/inc/part_exch_qa.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_qa.inc	revid:vasil.dimov@stripped
@@ -0,0 +1,148 @@
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 1) Valid exchange with partitions.
+# exchange of values < 10 of tp to t and complete contents of t to p0 and back.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+# Exchange with empty table.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+--sorted_result
+SELECT * FROM t_empty;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+--sorted_result
+SELECT * FROM t_empty;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+# Exchange with null table.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+--sorted_result
+SELECT * FROM t_null;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+--sorted_result
+SELECT * FROM t_null;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+# exchange of values < 100 of tp to t and complete contents of t to p1 and back.
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+
+# exchange of values < 1000 of tp to t and complete contents of t to p2 and back.
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+# Back to the former contents.
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+
+# 2) Valid exchange of subpartitions.
+# exchange of values < 10 of tsp to t and complete contents of t to p0 and back.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+
+# Exchange with null table.
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+--sorted_result
+SELECT * FROM t_null;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to the former contents.
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+--sorted_result
+SELECT * FROM t_null;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/inc/part_exch_qa_1.inc'
--- a/mysql-test/suite/parts/inc/part_exch_qa_1.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_qa_1.inc	revid:vasil.dimov@stripped
@@ -0,0 +1,61 @@
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 13) Exchanges with indexes.
+CREATE INDEX id_t_10_b USING BTREE ON t_10 (b);
+--error ER_TABLES_DIFFERENT_METADATA 
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--error ER_TABLES_DIFFERENT_METADATA 
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+CREATE INDEX id_tp_b USING BTREE ON tp (b);
+--error ER_TABLES_DIFFERENT_METADATA 
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--error ER_TABLES_DIFFERENT_METADATA 
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+DROP INDEX id_t_10_b ON t_10;
+DROP INDEX id_tp_b ON tp;
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+--error ER_TABLES_DIFFERENT_METADATA 
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--error ER_TABLES_DIFFERENT_METADATA 
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ALTER TABLE tp   ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+show create table tp  ;
+ALTER TABLE tp   DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+ALTER TABLE tp   ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+show create table tp  ;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/inc/part_exch_qa_13.inc'
--- a/mysql-test/suite/parts/inc/part_exch_qa_13.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_qa_13.inc	revid:vasil.dimov@strippedgg75x0
@@ -0,0 +1,201 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--disable_warnings
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+--enable_warnings
+
+eval CREATE TABLE t_10 (a INT, b VARCHAR(55), PRIMARY KEY (a))
+CHECKSUM= 1,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_100 (a INT, b VARCHAR(55), PRIMARY KEY (a))
+COMMENT= 'comment',
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_1000 (a INT, b VARCHAR(55), PRIMARY KEY (a))
+MIN_ROWS= 1,
+MAX_ROWS= 2000,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_empty (a INT, b VARCHAR(55), PRIMARY KEY (a))
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_null (a INT, b VARCHAR(55), PRIMARY KEY (a))
+ENGINE = $engine_table;
+
+eval CREATE TABLE tp (a INT, b VARCHAR(55), PRIMARY KEY (a))
+CHECKSUM= 1,
+ENGINE = $engine_part
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10),
+ PARTITION p1 VALUES LESS THAN (100),
+ PARTITION p2 VALUES LESS THAN (1000));
+
+eval CREATE TABLE tp1 (a INT, b VARCHAR(55), PRIMARY KEY (a))
+ENGINE = $engine_part
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10)   MAX_ROWS=2000 MIN_ROWS=1,
+ PARTITION p1 VALUES LESS THAN (100)  MAX_ROWS=2000 MIN_ROWS=1,
+ PARTITION p2 VALUES LESS THAN (1000) MAX_ROWS=2000 MIN_ROWS=1
+);
+
+eval CREATE TABLE tsp (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a))
+COMMENT= 'comment',
+ENGINE = $engine_subpart
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (10)
+ (SUBPARTITION sp00  MAX_ROWS=2000 MIN_ROWS=1,
+  SUBPARTITION sp01  MAX_ROWS=2000 MIN_ROWS=1,
+  SUBPARTITION sp02  MAX_ROWS=2000 MIN_ROWS=1,
+  SUBPARTITION sp03  MAX_ROWS=2000 MIN_ROWS=1,
+  SUBPARTITION sp04  MAX_ROWS=2000 MIN_ROWS=1),
+ PARTITION p1 VALUES LESS THAN (100)
+ (SUBPARTITION sp10,
+  SUBPARTITION sp11,
+  SUBPARTITION sp12,
+  SUBPARTITION sp13,
+  SUBPARTITION sp14),
+ PARTITION p2 VALUES LESS THAN (1000)
+ (SUBPARTITION sp20,
+  SUBPARTITION sp21,
+  SUBPARTITION sp22,
+  SUBPARTITION sp23,
+  SUBPARTITION sp24));
+
+# Values t_10 (not partitioned)
+INSERT INTO t_10 VALUES (1, "One"), (3, "Three"), (5, "Five"), (9, "Nine");
+
+# Values t_100 (not partitioned)
+INSERT INTO t_100 VALUES (11, "Eleven"), (13, "Thirdteen"), (15, "Fifeteen"), (19, "Nineteen");
+INSERT INTO t_100 VALUES (91, "Ninety-one"), (93, "Ninety-three"), (95, "Ninety-five"), (99, "Ninety-nine");
+
+# Values t_1000 (not partitioned)
+INSERT INTO t_1000 VALUES (111, "Hundred elven"), (113, "Hundred thirdteen"), (115, "Hundred fiveteen"), (119, "Hundred nineteen");
+INSERT INTO t_1000 VALUES (131, "Hundred thirty-one"), (133, "Hundred thirty-three"), (135, "Hundred thirty-five"), (139, "Hundred thirty-nine");
+INSERT INTO t_1000 VALUES (151, "Hundred fifty-one"), (153, "Hundred fifty-three"), (155, "Hundred fity-five"), (159, "Hundred fifty-nine");
+INSERT INTO t_1000 VALUES (191, "Hundred ninety-one"), (193, "Hundred ninety-three"), (195, "Hundred ninety-five"), (199, "Hundred ninety-nine");
+
+# Values t_null (not partitioned)
+INSERT INTO t_null VALUES (1, "NULL");
+
+# Values tp (partitions)
+INSERT INTO tp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tp VALUES (182, "Hundred eighty-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+# Values tp1 (partitions)
+INSERT INTO tp1 VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tp1 VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tp1 VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tp1 VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tp1 VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tp1 VALUES (182, "Hundred eighty-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+# Values tps (subpartitions)
+INSERT INTO tsp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tsp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tsp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tsp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tsp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tsp VALUES (182, "Hundred eight-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+eval CREATE TABLE tsp_01(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 1;
+eval CREATE TABLE tsp_02(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 2;
+eval CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table,
+             MAX_ROWS=2000, MIN_ROWS=1
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 3;
+eval CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4;
+eval CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0;
+
+SHOW CREATE TABLE t_100;
+SHOW CREATE TABLE t_1000;
+SHOW CREATE TABLE tp;
+SHOW CREATE TABLE tsp;
+
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 13) Exchanges with different table options.
+# See bug#55944 to change the IGNORE
+INSERT INTO t_10 VALUES (10, "TEN");
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM tp WHERE a < 11;
+--sorted_result
+SELECT * FROM t_10 WHERE a < 11;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+--sorted_result
+SELECT * FROM tp WHERE a < 11;
+--sorted_result
+SELECT * FROM t_10 WHERE a < 11;
+INSERT INTO t_1000 VALUES (99, "Ninetynine");
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tp1 EXCHANGE PARTITION p2 WITH TABLE t_1000;
+--sorted_result
+SELECT * FROM tp1 WHERE a < 1000 AND a > 98;
+--sorted_result
+SELECT * FROM t_1000 WHERE a < 1000 AND a > 98;
+ALTER TABLE tp1 EXCHANGE PARTITION p2 WITH TABLE t_1000 IGNORE;
+--sorted_result
+SELECT * FROM tp1 WHERE a < 1000 AND a > 98;
+--sorted_result
+SELECT * FROM t_1000 WHERE a < 1000 AND a > 98;
+INSERT INTO tsp_03 VALUES (20, "Twenty");
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03 IGNORE;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_03;
+
+DROP TABLE tp1;
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/inc/part_exch_qa_4.inc'
--- a/mysql-test/suite/parts/inc/part_exch_qa_4.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_qa_4.inc	revid:vasil.dimov@stripped
@@ -0,0 +1,45 @@
+CREATE DATABASE test_2;
+
+USE test;
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+
+USE test_2;
+--source suite/parts/inc/part_exch_tabs.inc
+
+--enable_result_log
+--enable_query_log
+
+USE test;
+# 10) Exchanges with different databases.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+--sorted_result
+SELECT * FROM test_2.t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+--sorted_result
+SELECT * FROM test_2.t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+--sorted_result
+SELECT * FROM test_2.tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+--sorted_result
+SELECT * FROM test_2.tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+USE test_2;
+--source suite/parts/inc/part_exch_drop_tabs.inc
+USE test;
+
+DROP DATABASE test_2;
+

=== added file 'mysql-test/suite/parts/inc/part_exch_qa_5.inc'
--- a/mysql-test/suite/parts/inc/part_exch_qa_5.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_qa_5.inc	revid:vasil.dimov@stripped220-zlcp5sg51xgg75x0
@@ -0,0 +1,89 @@
+--source include/not_embedded.inc
+
+CREATE USER test1@localhost;
+CREATE USER test2@localhost;
+GRANT USAGE ON *.* TO test1@localhost;
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, INSERT, SELECT ON test.* TO test1@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+
+--echo connect (test1,localhost,test1,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test1,localhost,test1,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+SELECT current_user();
+SHOW GRANTS FOR CURRENT_USER;
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--echo disconnect test1;
+disconnect test1;
+
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+SHOW GRANTS FOR CURRENT_USER;
+
+# 9) Exchanges with different owner.
+# Privilege for ALTER and SELECT
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+REVOKE ALTER ON test.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+SHOW GRANTS FOR CURRENT_USER;
+# Privilege for ALTER and SELECT
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+# Back to former values.
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+
+--echo connection default;
+connection default;
+--echo disconnect test2;
+disconnect test2;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
+DROP USER test1@localhost;
+DROP USER test2@localhost;
+

=== added file 'mysql-test/suite/parts/inc/part_exch_qa_7.inc'
--- a/mysql-test/suite/parts/inc/part_exch_qa_7.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_qa_7.inc	revid:vasil.dimov@stripped
@@ -0,0 +1,63 @@
+CREATE USER test_2@localhost;
+
+--source include/not_embedded.inc
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+# 8) Exchanges partition and table and back in 2 sessions with an insert.
+# Parallel INSERT and SELECT
+# LOCK behaviour when exchanging different partitons.
+--echo send
+--send
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--echo connect (test_2,localhost,test_2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test_2,localhost,test_2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+# Wait until exchange has been done.
+let $wait_condition= SELECT count(a)>0 FROM tp WHERE a=1;
+--source include/wait_condition.inc
+# Expect 1,3,5,9 in tp and 2,4,6,8 in t_10
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Exchange back.
+INSERT INTO tp VALUES (7,"Seven");
+# Expect 2,4,6,8 in tp
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--echo connection default;
+connection default;
+--echo reap;
+reap;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+--echo connection test_2;
+connection test_2;
+let $wait_condition= SELECT count(a)>0 FROM tp WHERE a=2;
+--source include/wait_condition.inc
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+--echo disconnect test_2;
+disconnect test_2;
+
+--echo connection default;
+connection default;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
+DROP USER test_2@localhost;
+

=== added file 'mysql-test/suite/parts/inc/part_exch_qa_8.inc'
--- a/mysql-test/suite/parts/inc/part_exch_qa_8.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_qa_8.inc	revid:vasil.dimov@stripped44220-zlcp5sg51xgg75x0
@@ -0,0 +1,71 @@
+CREATE USER test2@localhost;
+
+--source include/not_embedded.inc
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+CREATE DATABASE testdb;
+USE testdb;
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+USE test;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on test.* TO test2@localhost;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on testdb.* TO test2@localhost;
+
+# 8) Exchanges partition and table and back in 2 sessions with 2 databases.
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+# Privileges on both DB's
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+--sorted_result
+SELECT * FROM testdb.t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Exchange back.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+--sorted_result
+SELECT * FROM testdb.t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+# Exchange back.
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+REVOKE INSERT ON testdb.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
+DROP USER test2@localhost;
+DROP DATABASE testdb;
+

=== added file 'mysql-test/suite/parts/inc/part_exch_tabs.inc'
--- a/mysql-test/suite/parts/inc/part_exch_tabs.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/inc/part_exch_tabs.inc	revid:vasil.dimov@stripped4220-zlcp5sg51xgg75x0
@@ -0,0 +1,139 @@
+--disable_warnings
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+--enable_warnings
+
+eval CREATE TABLE t_10 (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_100 (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_1000 (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_empty (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_null (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_table;
+
+eval CREATE TABLE tp (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_part
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) $p_data_directory $p_index_directory,
+ PARTITION p1 VALUES LESS THAN (100) $p_data_directory $p_index_directory,
+ PARTITION p2 VALUES LESS THAN (1000) $p_data_directory $p_index_directory);
+
+eval CREATE TABLE tsp (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a)) $data_directory $index_directory
+ENGINE = $engine_subpart
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (10) $p_data_directory $p_index_directory
+ (SUBPARTITION sp00,
+  SUBPARTITION sp01,
+  SUBPARTITION sp02,
+  SUBPARTITION sp03,
+  SUBPARTITION sp04),
+ PARTITION p1 VALUES LESS THAN (100)
+ (SUBPARTITION sp10 $p_data_directory $p_index_directory,
+  SUBPARTITION sp11 $p_data_directory $p_index_directory,
+  SUBPARTITION sp12 $p_data_directory $p_index_directory,
+  SUBPARTITION sp13 $p_data_directory $p_index_directory,
+  SUBPARTITION sp14 $p_data_directory $p_index_directory),
+ PARTITION p2 VALUES LESS THAN (1000) $p_data_directory $p_index_directory
+ (SUBPARTITION sp20,
+  SUBPARTITION sp21,
+  SUBPARTITION sp22,
+  SUBPARTITION sp23,
+  SUBPARTITION sp24));
+
+# Values t_10 (not partitioned)
+INSERT INTO t_10 VALUES (1, "One"), (3, "Three"), (5, "Five"), (9, "Nine");
+
+# Values t_100 (not partitioned)
+INSERT INTO t_100 VALUES (11, "Eleven"), (13, "Thirdteen"), (15, "Fifeteen"), (19, "Nineteen");
+INSERT INTO t_100 VALUES (91, "Ninety-one"), (93, "Ninety-three"), (95, "Ninety-five"), (99, "Ninety-nine");
+
+# Values t_1000 (not partitioned)
+INSERT INTO t_1000 VALUES (111, "Hundred elven"), (113, "Hundred thirdteen"), (115, "Hundred fiveteen"), (119, "Hundred nineteen");
+INSERT INTO t_1000 VALUES (131, "Hundred thirty-one"), (133, "Hundred thirty-three"), (135, "Hundred thirty-five"), (139, "Hundred thirty-nine");
+INSERT INTO t_1000 VALUES (151, "Hundred fifty-one"), (153, "Hundred fifty-three"), (155, "Hundred fity-five"), (159, "Hundred fifty-nine");
+INSERT INTO t_1000 VALUES (191, "Hundred ninety-one"), (193, "Hundred ninety-three"), (195, "Hundred ninety-five"), (199, "Hundred ninety-nine");
+
+# Values t_null (not partitioned)
+INSERT INTO t_null VALUES (1, "NULL");
+
+# Values tp (partitions)
+INSERT INTO tp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tp VALUES (182, "Hundred eighty-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+# Values tps (subpartitions)
+INSERT INTO tsp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tsp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tsp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tsp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tsp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tsp VALUES (182, "Hundred eight-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+eval CREATE TABLE tsp_01(a INT,b VARCHAR(55),PRIMARY KEY (a))
+             ENGINE = $engine_table $data_directory $index_directory
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 1;
+eval CREATE TABLE tsp_02(a INT,b VARCHAR(55),PRIMARY KEY (a)) 
+             ENGINE = $engine_table $data_directory $index_directory
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 2;
+eval CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) 
+             ENGINE = $engine_table $data_directory $index_directory
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 3;
+eval CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) 
+             ENGINE = $engine_table $data_directory $index_directory
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4;
+eval CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) 
+             ENGINE = $engine_table $data_directory $index_directory
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0;
+ 
+SHOW CREATE TABLE t_10;
+SHOW CREATE TABLE t_100;
+SHOW CREATE TABLE t_1000;
+SHOW CREATE TABLE tp;
+SHOW CREATE TABLE tsp;
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tp WHERE a< 10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 11 AND 100;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 101 AND 200;
+--sorted_result
+SELECT * FROM tsp;

=== added file 'mysql-test/suite/parts/r/partition_exch_innodb.result'
--- a/mysql-test/suite/parts/r/partition_exch_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_innodb.result	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,355 @@
+use test;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a	b
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	NULL
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+1	NULL
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a	b
+12	twelve
+14	Fourteen
+16	Sixteen
+18	Eightteen
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a	b
+12	twelve
+14	Fourteen
+16	Sixteen
+18	Eightteen
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a	b
+SELECT * FROM tsp_01;
+a	b
+6	Six
+SELECT * FROM tsp_02;
+a	b
+2	Two
+SELECT * FROM tsp_03;
+a	b
+8	Eight
+SELECT * FROM tsp_04;
+a	b
+4	Four
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+6	Six
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+1	NULL
+2	Two
+4	Four
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+1	NULL
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_myisam.result'
--- a/mysql-test/suite/parts/r/partition_exch_myisam.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_myisam.result	revid:vasil.dimov@strippedg51xgg75x0
@@ -0,0 +1,355 @@
+use test;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a	b
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	NULL
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+1	NULL
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a	b
+12	twelve
+14	Fourteen
+16	Sixteen
+18	Eightteen
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a	b
+12	twelve
+14	Fourteen
+16	Sixteen
+18	Eightteen
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a	b
+SELECT * FROM tsp_01;
+a	b
+6	Six
+SELECT * FROM tsp_02;
+a	b
+2	Two
+SELECT * FROM tsp_03;
+a	b
+8	Eight
+SELECT * FROM tsp_04;
+a	b
+4	Four
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+6	Six
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+1	NULL
+2	Two
+4	Four
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+1	NULL
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_myisam_innodb.result'
--- a/mysql-test/suite/parts/r/partition_exch_myisam_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_myisam_innodb.result	revid:vasil.dimov@strippedgg75x0
@@ -0,0 +1,14 @@
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MySQL
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa.result	revid:vasil.dimov@stripped
@@ -0,0 +1,355 @@
+use test;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_empty;
+SELECT * FROM t_empty;
+a	b
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	NULL
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+1	NULL
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a	b
+12	twelve
+14	Fourteen
+16	Sixteen
+18	Eightteen
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 10 AND 100;
+a	b
+12	twelve
+14	Fourteen
+16	Sixteen
+18	Eightteen
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_1000;
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp WHERE a BETWEEN 100 AND 1000;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a	b
+SELECT * FROM tsp_01;
+a	b
+6	Six
+SELECT * FROM tsp_02;
+a	b
+2	Two
+SELECT * FROM tsp_03;
+a	b
+8	Eight
+SELECT * FROM tsp_04;
+a	b
+4	Four
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE tsp_01;
+ALTER TABLE tsp EXCHANGE PARTITION sp02 WITH TABLE tsp_02;
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ALTER TABLE tsp EXCHANGE PARTITION sp04 WITH TABLE tsp_04;
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+6	Six
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+1	NULL
+2	Two
+4	Four
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp01 WITH TABLE t_null;
+SELECT * FROM t_null;
+a	b
+1	NULL
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_10.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_10.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_10.result	revid:vasil.dimov@stripped20-zlcp5sg51xgg75x0
@@ -0,0 +1,70 @@
+use test;
+CREATE PROCEDURE test_p1 ()
+BEGIN
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp   ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ALTER TABLE tp   DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+END|
+CALL test_p1;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 9;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+DROP PROCEDURE test_p1;
+SET @save_autocommit= @@autocommit;
+SET @@autocommit= OFF;
+SHOW VARIABLES LIKE '%autocommit%';
+Variable_name	Value
+autocommit	OFF
+CREATE TRIGGER test_trg_1 BEFORE UPDATE ON tp FOR EACH ROW
+BEGIN
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+END|
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+CREATE FUNCTION test_f_1() RETURNS int
+BEGIN
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+END|
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+SET @@autocommit= @save_autocommit;
+SET @save_event_scheduler= @@global.event_scheduler;
+SET @@global.event_scheduler= ON;
+CREATE EVENT test_ev_1
+ON SCHEDULE AT CURRENT_TIMESTAMP
+DO
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 9;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SET @@global.event_scheduler= @save_event_scheduler;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_11.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_11.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_11.result	revid:vasil.dimov@stripped
@@ -0,0 +1,56 @@
+use test;
+SET @part= 'p0';
+SET @part_tab= 'tp';
+SET @table= 't_10';
+SET @s= CONCAT('ALTER TABLE ',@part_tab,' EXCHANGE PARTITION ',@part,' WITH TABLE ',@table);
+PREPARE test_stmt1 FROM @s;
+EXECUTE test_stmt1;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp;
+a	b
+1	One
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+3	Three
+5	Five
+9	Nine
+DEALLOCATE PREPARE test_stmt1;
+SET @part_tab= 'tp';
+SET @s= CONCAT('ALTER TABLE ',@part_tab,' EXCHANGE PARTITION ? WITH TABLE ?');
+PREPARE test_stmt2 FROM @s;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? WITH TABLE ?' at line 1
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_12.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_12.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_12.result	revid:vasil.dimov@stripped0-zlcp5sg51xgg75x0
@@ -0,0 +1,125 @@
+use test;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100 IGNORE;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_1000;
+ERROR HY000: Non matching attribute 'MAX_ROWS' between partition and table
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_1000 IGNORE;
+ERROR HY000: Non matching attribute 'MAX_ROWS' between partition and table
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_13.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_13.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_13.result	revid:vasil.dimov@stripped
@@ -0,0 +1,286 @@
+use test;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+INSERT INTO t_10 VALUES (10, "TEN");
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Found row that does not match the partition
+SELECT * FROM tp WHERE a < 11;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM t_10 WHERE a < 11;
+a	b
+1	One
+10	TEN
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+SELECT * FROM tp WHERE a < 11;
+a	b
+1	One
+10	TEN
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_10 WHERE a < 11;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+INSERT INTO t_1000 VALUES (99, "Ninetynine");
+ALTER TABLE tp1 EXCHANGE PARTITION p2 WITH TABLE t_1000;
+ERROR HY000: Found row that does not match the partition
+SELECT * FROM tp1 WHERE a < 1000 AND a > 98;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+SELECT * FROM t_1000 WHERE a < 1000 AND a > 98;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+99	Ninetynine
+ALTER TABLE tp1 EXCHANGE PARTITION p2 WITH TABLE t_1000 IGNORE;
+SELECT * FROM tp1 WHERE a < 1000 AND a > 98;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+99	Ninetynine
+SELECT * FROM t_1000 WHERE a < 1000 AND a > 98;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+INSERT INTO tsp_03 VALUES (20, "Twenty");
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03;
+ERROR HY000: Found row that does not match the partition
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_03;
+a	b
+20	Twenty
+3	Three
+ALTER TABLE tsp EXCHANGE PARTITION sp03 WITH TABLE tsp_03 IGNORE;
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+20	Twenty
+3	Three
+4	Four
+6	Six
+SELECT * FROM tsp_03;
+a	b
+8	Eight
+DROP TABLE tp1;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_14.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_14.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_14.result	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,45 @@
+use test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+use test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+use test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_15.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_15.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_15.result	revid:vasil.dimov@stripped220-zlcp5sg51xgg75x0
@@ -0,0 +1,19 @@
+use test;
+CREATE TABLE t_11 (a INT, b VARCHAR(55), 
+FOREIGN KEY (a) REFERENCES t_10 (a) ON DELETE CASCADE)
+ENGINE= InnoDB;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: Table to exchange with partition has foreign key references: 't_11'
+DROP TABLE IF EXISTS t_11;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_1_innodb.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_1_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_1_innodb.result	revid:vasil.dimov@strippedg75x0
@@ -0,0 +1,177 @@
+use test;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+CREATE INDEX id_t_10_b USING BTREE ON t_10 (b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ERROR HY000: Tables have different definitions
+CREATE INDEX id_tp_b USING BTREE ON tp (b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ERROR HY000: Tables have different definitions
+DROP INDEX id_t_10_b ON t_10;
+DROP INDEX id_tp_b ON tp;
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp   ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+Table	Create Table
+t_10	CREATE TABLE `t_10` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` varchar(55) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `a` (`a`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table tp  ;
+Table	Create Table
+tp	CREATE TABLE `tp` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` varchar(55) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `a` (`a`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN (100) ENGINE = InnoDB,
+ PARTITION p2 VALUES LESS THAN (1000) ENGINE = InnoDB) */
+ALTER TABLE tp   DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+ALTER TABLE tp   ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+Table	Create Table
+t_10	CREATE TABLE `t_10` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` varchar(55) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `a` (`a`,`b`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table tp  ;
+Table	Create Table
+tp	CREATE TABLE `tp` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` varchar(55) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `a` (`a`,`b`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN (100) ENGINE = InnoDB,
+ PARTITION p2 VALUES LESS THAN (1000) ENGINE = InnoDB) */
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_1_myisam.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_1_myisam.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_1_myisam.result	revid:vasil.dimov@stripped5sg51xgg75x0
@@ -0,0 +1,177 @@
+use test;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+CREATE INDEX id_t_10_b USING BTREE ON t_10 (b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ERROR HY000: Tables have different definitions
+CREATE INDEX id_tp_b USING BTREE ON tp (b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ERROR HY000: Tables have different definitions
+DROP INDEX id_t_10_b ON t_10;
+DROP INDEX id_tp_b ON tp;
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+ERROR HY000: Tables have different definitions
+ALTER TABLE tp   ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+Table	Create Table
+t_10	CREATE TABLE `t_10` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` varchar(55) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `a` (`a`) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table tp  ;
+Table	Create Table
+tp	CREATE TABLE `tp` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` varchar(55) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `a` (`a`) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p2 VALUES LESS THAN (1000) ENGINE = MyISAM) */
+ALTER TABLE tp   DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+ALTER TABLE tp   ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a,b);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+show create table t_10;
+Table	Create Table
+t_10	CREATE TABLE `t_10` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` varchar(55) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `a` (`a`,`b`) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table tp  ;
+Table	Create Table
+tp	CREATE TABLE `tp` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` varchar(55) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `a` (`a`,`b`) USING BTREE
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p2 VALUES LESS THAN (1000) ENGINE = MyISAM) */
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_2.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_2.result	revid:vasil.dimov@stripped
@@ -0,0 +1,144 @@
+use test;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM t_100;
+a	b
+11	Eleven
+13	Thirdteen
+15	Fifeteen
+19	Nineteen
+91	Ninety-one
+93	Ninety-three
+95	Ninety-five
+99	Ninety-nine
+SELECT * FROM t_1000;
+a	b
+111	Hundred elven
+113	Hundred thirdteen
+115	Hundred fiveteen
+119	Hundred nineteen
+131	Hundred thirty-one
+133	Hundred thirty-three
+135	Hundred thirty-five
+139	Hundred thirty-nine
+151	Hundred fifty-one
+153	Hundred fifty-three
+155	Hundred fity-five
+159	Hundred fifty-nine
+191	Hundred ninety-one
+193	Hundred ninety-three
+195	Hundred ninety-five
+199	Hundred ninety-nine
+SELECT * FROM tp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eighty-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp;
+a	b
+112	Hundred twelve
+114	Hundred fourteen
+116	Hundred sixteen
+118	Hundred eightteen
+12	twelve
+122	Hundred twenty-two
+124	Hundred twenty-four
+126	Hundred twenty-six
+128	Hundred twenty-eight
+14	Fourteen
+16	Sixteen
+162	Hundred sixty-two
+164	Hundred sixty-four
+166	Hundred sixty-six
+168	Hundred sixty-eight
+18	Eightteen
+182	Hundred eight-two
+184	Hundred eighty-four
+186	Hundred eighty-six
+188	Hundred eighty-eight
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp_01;
+a	b
+1	One
+SELECT * FROM tsp_02;
+a	b
+SELECT * FROM tsp_03;
+a	b
+3	Three
+SELECT * FROM tsp_04;
+a	b
+9	Nine
+CREATE TABLE t_11(a INT,b VARCHAR(55)) SELECT * FROM t_10;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_11;
+CREATE TABLE t_11(a INT,b CHAR(55),PRIMARY KEY(a)) ENGINE= $engine_table SELECT * FROM t_10;
+Warnings:
+Warning	1286	Unknown storage engine '$engine_table'
+Warning	1266	Using storage engine MyISAM for table 't_11'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: Tables have different definitions
+DROP TABLE IF EXISTS t_11;
+CREATE TABLE t_11(a INT,b VARCHAR(55),PRIMARY KEY(a)) ENGINE= MEMORY SELECT * FROM t_10;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MySQL
+DROP TABLE IF EXISTS t_11;
+CREATE TABLE t_11(a INT,b CHAR(55),PRIMARY KEY(a)) ENGINE= $engine_table 
+PARTITION BY KEY() AS SELECT * FROM t_10;
+Warnings:
+Warning	1286	Unknown storage engine '$engine_table'
+Warning	1266	Using storage engine MyISAM for table 't_11'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+ERROR HY000: Table to exchange with partition is partitioned: 't_11'
+DROP TABLE IF EXISTS t_11;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE tsp;
+ERROR HY000: Table to exchange with partition is partitioned: 'tsp'
+ALTER TABLE tsp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: Subpartitioned table, use subpartition instead of partition
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_100;
+ERROR HY000: Found row that does not match the partition
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_10;
+ERROR HY000: Found row that does not match the partition
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_3.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_3.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_3.result	revid:vasil.dimov@stripped20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,17 @@
+use test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MySQL
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MySQL
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result	revid:vasil.dimov@strippedom-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,76 @@
+CREATE DATABASE test_2;
+USE test;
+USE test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+SELECT * FROM test_2.t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+SELECT * FROM test_2.t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+SELECT * FROM test_2.tsp_00;
+a	b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+5	Five
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+SELECT * FROM test_2.tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+USE test_2;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+USE test;
+DROP DATABASE test_2;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result	revid:vasil.dimov@stripped
@@ -0,0 +1,76 @@
+CREATE DATABASE test_2;
+USE test;
+USE test;
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+SELECT * FROM test_2.t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE test_2.t_10;
+SELECT * FROM test_2.t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+SELECT * FROM test_2.tsp_00;
+a	b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+5	Five
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE test_2.tsp_00;
+SELECT * FROM test_2.tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+USE test_2;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+USE test;
+DROP DATABASE test_2;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result	revid:vasil.dimov@stripped4220-zlcp5sg51xgg75x0
@@ -0,0 +1,114 @@
+CREATE USER test1@localhost;
+CREATE USER test2@localhost;
+GRANT USAGE ON *.* TO test1@localhost;
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, INSERT, SELECT ON test.* TO test1@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+connect (test1,localhost,test1,,test,MASTER_MYPORT,MASTER_MYSOCK);
+SELECT current_user();
+current_user()
+test1@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test1@localhost
+GRANT USAGE ON *.* TO 'test1'@'localhost'
+GRANT SELECT, INSERT, CREATE, DROP ON `test`.* TO 'test1'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test1'@'localhost' for table 'tp'
+disconnect test1;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+current_user()
+test2@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a	b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+5	Five
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+disconnect test2;
+connection default;
+REVOKE ALTER ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+current_user()
+test2@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp'
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp'
+connection default;
+disconnect test2;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test1@localhost;
+DROP USER test2@localhost;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result	revid:vasil.dimov@stripped-zlcp5sg51xgg75x0
@@ -0,0 +1,114 @@
+CREATE USER test1@localhost;
+CREATE USER test2@localhost;
+GRANT USAGE ON *.* TO test1@localhost;
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, INSERT, SELECT ON test.* TO test1@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+connect (test1,localhost,test1,,test,MASTER_MYPORT,MASTER_MYSOCK);
+SELECT current_user();
+current_user()
+test1@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test1@localhost
+GRANT USAGE ON *.* TO 'test1'@'localhost'
+GRANT SELECT, INSERT, CREATE, DROP ON `test`.* TO 'test1'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test1'@'localhost' for table 'tp'
+disconnect test1;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+current_user()
+test2@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a	b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+5	Five
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+disconnect test2;
+connection default;
+REVOKE ALTER ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SELECT current_user();
+current_user()
+test2@localhost
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp'
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp'
+connection default;
+disconnect test2;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test1@localhost;
+DROP USER test2@localhost;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_6.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_6.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_6.result	revid:vasil.dimov@stripped
@@ -0,0 +1,105 @@
+CREATE USER test2@localhost;
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a	b
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+5	Five
+6	Six
+8	Eight
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+SELECT * FROM tsp_00;
+a	b
+5	Five
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+disconnect test2;
+connection default;
+REVOKE INSERT ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, UPDATE, CREATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 'tp'
+disconnect test2;
+connection default;
+GRANT INSERT ON test.* TO test2@localhost;
+REVOKE CREATE ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, DROP, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+ERROR 42000: CREATE command denied to user 'test2'@'localhost' for table 'tsp'
+disconnect test2;
+connection default;
+GRANT CREATE ON test.* TO test2@localhost;
+REVOKE DROP ON test.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+Grants for test2@localhost
+GRANT USAGE ON *.* TO 'test2'@'localhost'
+GRANT SELECT, INSERT, UPDATE, CREATE, ALTER ON `test`.* TO 'test2'@'localhost'
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: DROP command denied to user 'test2'@'localhost' for table 'tp'
+disconnect test2;
+connection default;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test2@localhost;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result	revid:vasil.dimov@stripped
@@ -0,0 +1,82 @@
+CREATE USER test_2@localhost;
+send
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+connect (test_2,localhost,test_2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+INSERT INTO tp VALUES (7,"Seven");
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+7	Seven
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+connection default;
+reap;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+7	Seven
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+connection test_2;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+7	Seven
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+disconnect test_2;
+connection default;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+7	Seven
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test_2@localhost;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,82 @@
+CREATE USER test_2@localhost;
+send
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+connect (test_2,localhost,test_2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+INSERT INTO tp VALUES (7,"Seven");
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+7	Seven
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+connection default;
+reap;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+7	Seven
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+connection test_2;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+7	Seven
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+disconnect test_2;
+connection default;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+7	Seven
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test_2@localhost;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result	revid:vasil.dimov@strippedom-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,83 @@
+CREATE USER test2@localhost;
+CREATE DATABASE testdb;
+USE testdb;
+USE test;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on test.* TO test2@localhost;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on testdb.* TO test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+SELECT * FROM testdb.t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+SELECT * FROM testdb.t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+disconnect test2;
+connection default;
+REVOKE INSERT ON testdb.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 't_10'
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 'tp'
+disconnect test2;
+connection default;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test2@localhost;
+DROP DATABASE testdb;

=== added file 'mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result	revid:vasil.dimov@strippedcp5sg51xgg75x0
@@ -0,0 +1,83 @@
+CREATE USER test2@localhost;
+CREATE DATABASE testdb;
+USE testdb;
+USE test;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on test.* TO test2@localhost;
+GRANT CREATE, ALTER, DROP, INSERT, SELECT on testdb.* TO test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+SELECT * FROM testdb.t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+SELECT * FROM testdb.t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+SELECT * FROM t_10;
+a	b
+1	One
+3	Three
+5	Five
+9	Nine
+SELECT * FROM testdb.tp WHERE a BETWEEN 0 AND 10;
+a	b
+2	Two
+4	Four
+6	Six
+8	Eight
+disconnect test2;
+connection default;
+REVOKE INSERT ON testdb.* FROM test2@localhost;
+connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 't_10'
+ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 'tp'
+disconnect test2;
+connection default;
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS tsp_00;
+DROP TABLE IF EXISTS tsp_01;
+DROP TABLE IF EXISTS tsp_02;
+DROP TABLE IF EXISTS tsp_03;
+DROP TABLE IF EXISTS tsp_04;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+DROP USER test2@localhost;
+DROP DATABASE testdb;

=== added file 'mysql-test/suite/parts/t/partition_exch_innodb.test'
--- a/mysql-test/suite/parts/t/partition_exch_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_innodb.test	revid:vasil.dimov@stripped0101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_innodb.inc
+--source include/have_partition.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_myisam.test'
--- a/mysql-test/suite/parts/t/partition_exch_myisam.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_myisam.test	revid:vasil.dimov@stripped75x0
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_myisam_innodb.test'
--- a/mysql-test/suite/parts/t/partition_exch_myisam_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_myisam_innodb.test	revid:vasil.dimov@stripped44220-zlcp5sg51xgg75x0
@@ -0,0 +1,21 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_innodb.inc
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--error 1497
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa.test	revid:vasil.dimov@stripped44220-zlcp5sg51xgg75x0
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_10.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_10.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_10.test	revid:vasil.dimov@strippedzlcp5sg51xgg75x0
@@ -0,0 +1,69 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/not_embedded.inc
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+# 17) Exchanges in Procedure, triggers and events.
+DELIMITER |;
+CREATE PROCEDURE test_p1 ()
+BEGIN
+ALTER TABLE t_10 ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp   ADD UNIQUE INDEX USING BTREE (a);
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+ALTER TABLE tp   DROP INDEX a;
+ALTER TABLE t_10 DROP INDEX a;
+END|
+DELIMITER ;|
+CALL test_p1;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 9;
+DROP PROCEDURE test_p1;
+
+SET @save_autocommit= @@autocommit;
+SET @@autocommit= OFF;
+SHOW VARIABLES LIKE '%autocommit%';
+DELIMITER |;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+CREATE TRIGGER test_trg_1 BEFORE UPDATE ON tp FOR EACH ROW
+BEGIN
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+END|
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+CREATE FUNCTION test_f_1() RETURNS int
+BEGIN
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+END|
+DELIMITER ;|
+SET @@autocommit= @save_autocommit;
+
+SET @save_event_scheduler= @@global.event_scheduler;
+SET @@global.event_scheduler= ON;
+CREATE EVENT test_ev_1
+    ON SCHEDULE AT CURRENT_TIMESTAMP
+    DO
+       ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+sleep 1;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 9;
+SET @@global.event_scheduler= @save_event_scheduler;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_11.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_11.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_11.test	revid:vasil.dimov@stripped
@@ -0,0 +1,37 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+# 13) Exchange with dynamic variables.
+SET @part= 'p0';
+SET @part_tab= 'tp';
+SET @table= 't_10';
+SET @s= CONCAT('ALTER TABLE ',@part_tab,' EXCHANGE PARTITION ',@part,' WITH TABLE ',@table);
+PREPARE test_stmt1 FROM @s;
+EXECUTE test_stmt1;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp;
+DEALLOCATE PREPARE test_stmt1;
+
+SET @part_tab= 'tp';
+SET @s= CONCAT('ALTER TABLE ',@part_tab,' EXCHANGE PARTITION ? WITH TABLE ?');
+--error ER_PARSE_ERROR
+PREPARE test_stmt2 FROM @s;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_12.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_12.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_12.test	revid:vasil.dimov@stripped4220-zlcp5sg51xgg75x0
@@ -0,0 +1,176 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--disable_warnings
+DROP TABLE IF EXISTS t_10;
+DROP TABLE IF EXISTS t_100;
+DROP TABLE IF EXISTS t_1000;
+DROP TABLE IF EXISTS tp;
+DROP TABLE IF EXISTS tsp;
+DROP TABLE IF EXISTS t_empty;
+DROP TABLE IF EXISTS t_null;
+--enable_warnings
+
+eval CREATE TABLE t_10 (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a))
+CHECKSUM= 1,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_100 (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a))
+COMMENT= 'comment',
+ROW_FORMAT= COMPRESSED,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_1000 (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a))
+MIN_ROWS= 1,
+MAX_ROWS= 200,
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_empty (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a))
+ENGINE = $engine_table;
+
+eval CREATE TABLE t_null (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a))
+ENGINE = $engine_table;
+
+eval CREATE TABLE tp (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a))
+ENGINE = $engine_part
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (10),
+ PARTITION p1 VALUES LESS THAN (100),
+ PARTITION p2 VALUES LESS THAN (1000));
+
+eval CREATE TABLE tsp (a INT,
+  b VARCHAR(55),
+  PRIMARY KEY (a))
+ENGINE = $engine_subpart
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH(a)
+(PARTITION p0 VALUES LESS THAN (10)
+ (SUBPARTITION sp00,
+  SUBPARTITION sp01,
+  SUBPARTITION sp02,
+  SUBPARTITION sp03,
+  SUBPARTITION sp04),
+ PARTITION p1 VALUES LESS THAN (100)
+ (SUBPARTITION sp10,
+  SUBPARTITION sp11,
+  SUBPARTITION sp12,
+  SUBPARTITION sp13,
+  SUBPARTITION sp14),
+ PARTITION p2 VALUES LESS THAN (1000)
+ (SUBPARTITION sp20,
+  SUBPARTITION sp21,
+  SUBPARTITION sp22,
+  SUBPARTITION sp23,
+  SUBPARTITION sp24));
+
+# Values t_10 (not partitioned)
+INSERT INTO t_10 VALUES (1, "One"), (3, "Three"), (5, "Five"), (9, "Nine");
+
+# Values t_100 (not partitioned)
+INSERT INTO t_100 VALUES (11, "Eleven"), (13, "Thirdteen"), (15, "Fifeteen"), (19, "Nineteen");
+INSERT INTO t_100 VALUES (91, "Ninety-one"), (93, "Ninety-three"), (95, "Ninety-five"), (99, "Ninety-nine");
+
+# Values t_1000 (not partitioned)
+INSERT INTO t_1000 VALUES (111, "Hundred elven"), (113, "Hundred thirdteen"), (115, "Hundred fiveteen"), (119, "Hundred nineteen");
+INSERT INTO t_1000 VALUES (131, "Hundred thirty-one"), (133, "Hundred thirty-three"), (135, "Hundred thirty-five"), (139, "Hundred thirty-nine");
+INSERT INTO t_1000 VALUES (151, "Hundred fifty-one"), (153, "Hundred fifty-three"), (155, "Hundred fity-five"), (159, "Hundred fifty-nine");
+INSERT INTO t_1000 VALUES (191, "Hundred ninety-one"), (193, "Hundred ninety-three"), (195, "Hundred ninety-five"), (199, "Hundred ninety-nine");
+
+# Values t_null (not partitioned)
+INSERT INTO t_null VALUES (1, "NULL");
+
+# Values tp (partitions)
+INSERT INTO tp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tp VALUES (182, "Hundred eighty-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+# Values tps (subpartitions)
+INSERT INTO tsp VALUES (2, "Two"), (4, "Four"), (6, "Six"), (8, "Eight");
+INSERT INTO tsp VALUES (12, "twelve"), (14, "Fourteen"), (16, "Sixteen"), (18, "Eightteen");
+INSERT INTO tsp VALUES (112, "Hundred twelve"), (114, "Hundred fourteen"), (116, "Hundred sixteen"), (118, "Hundred eightteen");
+INSERT INTO tsp VALUES (122, "Hundred twenty-two"), (124, "Hundred twenty-four"), (126, "Hundred twenty-six"), (128, "Hundred twenty-eight");
+INSERT INTO tsp VALUES (162, "Hundred sixty-two"), (164, "Hundred sixty-four"), (166, "Hundred sixty-six"), (168, "Hundred sixty-eight");
+INSERT INTO tsp VALUES (182, "Hundred eight-two"), (184, "Hundred eighty-four"), (186, "Hundred eighty-six"), (188, "Hundred eighty-eight");
+
+eval CREATE TABLE tsp_01(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 1;
+eval CREATE TABLE tsp_02(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 2;
+eval CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 3;
+eval CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4;
+eval CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = $engine_table
+             AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0;
+
+SHOW CREATE TABLE t_10;
+SHOW CREATE TABLE t_100;
+SHOW CREATE TABLE t_1000;
+SHOW CREATE TABLE tp;
+SHOW CREATE TABLE tsp;
+
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 13) Exchanges with different table options.
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100 IGNORE;
+--error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_1000;
+--error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION
+ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_1000 IGNORE;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_13.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_13.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_13.test	revid:vasil.dimov@stripped
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_13.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_14.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_14.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_14.test	revid:vasil.dimov@stripped
@@ -0,0 +1,92 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+# DATA DIRECTORY
+# Make directory for partition data
+let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir;
+--mkdir $data_dir_path
+let $p_data_directory= DATA DIRECTORY = '$data_dir_path';
+let $data_directory= DATA DIRECTORY = '$data_dir_path';
+
+# INDEX DIRECTORY
+# Make directory for partition index
+let $idx_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir;
+--mkdir $idx_dir_path
+let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
+let $index_directory= INDEX DIRECTORY = '$idx_dir_path';
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+--rmdir $data_dir_path
+--rmdir $idx_dir_path
+
+# DATA DIRECTORY
+# Make directory for partition data
+let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir;
+--mkdir $data_dir_path
+let $p_data_directory= DATA DIRECTORY = '$data_dir_path';
+
+# INDEX DIRECTORY
+# Make directory for partition index
+let $idx_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir;
+--mkdir $idx_dir_path
+let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+--rmdir $data_dir_path
+--rmdir $idx_dir_path
+
+# DATA DIRECTORY
+# Make directory for partition data
+let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir;
+--mkdir $data_dir_path
+let $data_directory= DATA DIRECTORY = '$data_dir_path';
+
+# INDEX DIRECTORY
+# Make directory for partition index
+let $idx_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir;
+--mkdir $idx_dir_path
+let $index_directory= INDEX DIRECTORY = '$idx_dir_path';
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+--rmdir $data_dir_path
+--rmdir $idx_dir_path
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_15.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_15.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_15.test	revid:vasil.dimov@stripped
@@ -0,0 +1,30 @@
+# Author: Horst Hunger
+# Created: 2010-07-15
+
+--source include/have_innodb.inc
+--source include/have_partition.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+# 21) Foreign Key.
+# Exchange of partition with table differing in structure.
+CREATE TABLE t_11 (a INT, b VARCHAR(55), 
+             FOREIGN KEY (a) REFERENCES t_10 (a) ON DELETE CASCADE)
+             ENGINE= InnoDB;
+--error ER_PARTITION_EXCHANGE_FOREIGN_KEY
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+--enable_warnings
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_1_innodb.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_1_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_1_innodb.test	revid:vasil.dimov@strippedx0
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_1.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_1_myisam.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_1_myisam.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_1_myisam.test	revid:vasil.dimov@stripped
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-13
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_1.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_2.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_2.test	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,80 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+
+# 3) Invalid exchanges.
+# Exchange of partition with table differing in structure.
+CREATE TABLE t_11(a INT,b VARCHAR(55)) SELECT * FROM t_10;
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+--enable_warnings
+CREATE TABLE t_11(a INT,b CHAR(55),PRIMARY KEY(a)) ENGINE= $engine_table SELECT * FROM t_10;
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+CREATE TABLE t_11(a INT,b VARCHAR(55),PRIMARY KEY(a)) ENGINE= MEMORY SELECT * FROM t_10;
+--error ER_MIX_HANDLER_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+--enable_warnings
+# Exchange of partition with partitioned table.
+CREATE TABLE t_11(a INT,b CHAR(55),PRIMARY KEY(a)) ENGINE= $engine_table 
+             PARTITION BY KEY() AS SELECT * FROM t_10;
+--error ER_PARTITION_EXCHANGE_PART_TABLE
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_11;
+--disable_warnings
+DROP TABLE IF EXISTS t_11;
+--enable_warnings
+# Exchange of subpartition with partitioned table.
+--error ER_PARTITION_EXCHANGE_PART_TABLE
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE tsp;
+# Exchange of subpartitioned partition with table.
+--error ER_PARTITION_INSTEAD_OF_SUBPARTITION
+ALTER TABLE tsp EXCHANGE PARTITION p0 WITH TABLE t_10;
+# Exchange of values in partition not fitting the hash.
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_100;
+# Exchange of values in subpartition not fitting the hash.
+--error ER_ROW_DOES_NOT_MATCH_PARTITION
+ALTER TABLE tp EXCHANGE PARTITION p2 WITH TABLE t_10;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_3.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_3.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_3.test	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,46 @@
+# Author: Horst Hunger
+# Created: 2010-07-05
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+use test;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM t_100;
+--sorted_result
+SELECT * FROM t_1000;
+--sorted_result
+SELECT * FROM tp;
+--sorted_result
+SELECT * FROM tsp;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp_01;
+--sorted_result
+SELECT * FROM tsp_02;
+--sorted_result
+SELECT * FROM tsp_03;
+--sorted_result
+SELECT * FROM tsp_04;
+--enable_result_log
+--enable_query_log
+
+# 5) Exchanges with different engines.
+--error ER_MIX_HANDLER_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--error ER_MIX_HANDLER_ERROR
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_4_innodb.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_4_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_4_innodb.test	revid:vasil.dimov@strippedsg51xgg75x0
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_4.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_4_myisam.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_4_myisam.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_4_myisam.test	revid:vasil.dimov@strippedx0
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_4.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_5_innodb.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_5_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_5_innodb.test	revid:vasil.dimov@strippedzlcp5sg51xgg75x0
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_5.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_5_myisam.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_5_myisam.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_5_myisam.test	revid:vasil.dimov@strippedxgg75x0
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_5.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_6.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_6.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_6.test	revid:vasil.dimov@stripped
@@ -0,0 +1,102 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/not_embedded.inc
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+CREATE USER test2@localhost;
+
+--disable_result_log
+--disable_query_log
+--source suite/parts/inc/part_exch_tabs.inc
+--enable_result_log
+--enable_query_log
+
+GRANT USAGE ON *.* TO test2@localhost;
+GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+# 9) Exchanges with different owner.
+# Privilege for ALTER and SELECT
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--sorted_result
+SELECT * FROM t_10;
+--sorted_result
+SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+# Back to former values.
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--sorted_result
+SELECT * FROM tsp_00;
+--sorted_result
+SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+REVOKE INSERT ON test.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+# Privilege for ALTER and SELECT
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--echo disconnect test2;
+disconnect test2;
+ 
+--echo connection default;
+connection default;
+GRANT INSERT ON test.* TO test2@localhost;
+REVOKE CREATE ON test.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
+--echo disconnect test2;
+disconnect test2;
+
+--echo connection default;
+connection default;
+GRANT CREATE ON test.* TO test2@localhost;
+REVOKE DROP ON test.* FROM test2@localhost;
+
+--echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
+connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+USE test;
+SHOW GRANTS FOR CURRENT_USER;
+# Privilege for ALTER and SELECT
+--error ER_TABLEACCESS_DENIED_ERROR
+ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
+--echo disconnect test2;
+disconnect test2;
+ 
+--echo connection default;
+connection default;
+
+--source suite/parts/inc/part_exch_drop_tabs.inc
+
+DROP USER test2@localhost;
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_7_innodb.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_7_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_7_innodb.test	revid:vasil.dimov@stripped
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_7.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_7_myisam.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_7_myisam.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_7_myisam.test	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-06
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_7.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_8_innodb.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_8_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_8_innodb.test	revid:vasil.dimov@stripped
@@ -0,0 +1,12 @@
+# Author: Horst Hunger
+# Created: 2010-07-07
+
+--source include/have_partition.inc
+--source include/have_innodb.inc
+
+let $engine_table= InnoDB;
+let $engine_part= InnoDB;
+let $engine_subpart= InnoDB;
+
+--source suite/parts/inc/part_exch_qa_8.inc
+

=== added file 'mysql-test/suite/parts/t/partition_exch_qa_8_myisam.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_8_myisam.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_exch_qa_8_myisam.test	revid:vasil.dimov@stripped
@@ -0,0 +1,11 @@
+# Author: Horst Hunger
+# Created: 2010-07-07
+
+--source include/have_partition.inc
+
+let $engine_table= MYISAM;
+let $engine_part= MYISAM;
+let $engine_subpart= MYISAM;
+
+--source suite/parts/inc/part_exch_qa_8.inc
+

=== modified file 'mysql-test/suite/perfschema/r/privilege_table_io.result'
--- a/mysql-test/suite/perfschema/r/privilege_table_io.result	revid:jimmy.yang@stripped0101105133317-dvev6424yzogf4gq
+++ b/mysql-test/suite/perfschema/r/privilege_table_io.result	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -34,9 +34,9 @@ wait/io/table/sql/handler	handler.cc:	TA
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	db	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	db	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	db	fetch	NULL
-wait/io/table/sql/handler	handler.cc:	TABLE	mysql	proxy_priv	fetch	NULL
-wait/io/table/sql/handler	handler.cc:	TABLE	mysql	proxy_priv	fetch	NULL
-wait/io/table/sql/handler	handler.cc:	TABLE	mysql	proxy_priv	fetch	NULL
+wait/io/table/sql/handler	handler.cc:	TABLE	mysql	proxies_priv	fetch	NULL
+wait/io/table/sql/handler	handler.cc:	TABLE	mysql	proxies_priv	fetch	NULL
+wait/io/table/sql/handler	handler.cc:	TABLE	mysql	proxies_priv	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	tables_priv	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	procs_priv	fetch	NULL
 wait/io/table/sql/handler	handler.cc:	TABLE	mysql	servers	fetch	NULL

=== added file 'mysql-test/suite/sys_vars/inc/autocommit_func2.inc'
--- a/mysql-test/suite/sys_vars/inc/autocommit_func2.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/inc/autocommit_func2.inc	revid:vasil.dimov@stripped1108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,29 @@
+--source include/have_innodb.inc
+
+CREATE TABLE t1
+(
+id INT NOT NULL auto_increment,
+PRIMARY KEY (id),
+name varchar(30)
+) ENGINE = INNODB;
+
+SELECT @@global.autocommit;
+SELECT @@autocommit;
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+ROLLBACK;
+SELECT * from t1;
+
+set @@global.autocommit = 1-@@global.autocommit;
+set @@autocommit = 1-@@autocommit;
+SELECT @@global.autocommit;
+SELECT @@autocommit;
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+ROLLBACK;
+SELECT * from t1;
+
+DROP TABLE t1;
+set @@global.autocommit = 1-@@global.autocommit;

=== added file 'mysql-test/suite/sys_vars/r/autocommit_func2.result'
--- a/mysql-test/suite/sys_vars/r/autocommit_func2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/autocommit_func2.result	revid:vasil.dimov@stripped220-zlcp5sg51xgg75x0
@@ -0,0 +1,46 @@
+CREATE TABLE t1
+(
+id INT NOT NULL auto_increment,
+PRIMARY KEY (id),
+name varchar(30)
+) ENGINE = INNODB;
+SELECT @@global.autocommit;
+@@global.autocommit
+1
+SELECT @@autocommit;
+@@autocommit
+1
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+set @@global.autocommit = 1-@@global.autocommit;
+set @@autocommit = 1-@@autocommit;
+SELECT @@global.autocommit;
+@@global.autocommit
+0
+SELECT @@autocommit;
+@@autocommit
+0
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+3	Record_1
+4	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+DROP TABLE t1;
+set @@global.autocommit = 1-@@global.autocommit;

=== added file 'mysql-test/suite/sys_vars/r/autocommit_func3.result'
--- a/mysql-test/suite/sys_vars/r/autocommit_func3.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/autocommit_func3.result	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1,42 @@
+CREATE TABLE t1
+(
+id INT NOT NULL auto_increment,
+PRIMARY KEY (id),
+name varchar(30)
+) ENGINE = INNODB;
+SELECT @@global.autocommit;
+@@global.autocommit
+0
+SELECT @@autocommit;
+@@autocommit
+0
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+set @@global.autocommit = 1-@@global.autocommit;
+set @@autocommit = 1-@@autocommit;
+SELECT @@global.autocommit;
+@@global.autocommit
+1
+SELECT @@autocommit;
+@@autocommit
+1
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+3	Record_1
+4	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+3	Record_1
+4	Record_2
+DROP TABLE t1;
+set @@global.autocommit = 1-@@global.autocommit;

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func2-master.opt'
--- a/mysql-test/suite/sys_vars/t/autocommit_func2-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func2-master.opt	revid:vasil.dimov@stripped220-zlcp5sg51xgg75x0
@@ -0,0 +1 @@
+--autocommit=1

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func2.test'
--- a/mysql-test/suite/sys_vars/t/autocommit_func2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func2.test	revid:vasil.dimov@stripped-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1 @@
+--source suite/sys_vars/inc/autocommit_func2.inc

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func3-master.opt'
--- a/mysql-test/suite/sys_vars/t/autocommit_func3-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func3-master.opt	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -0,0 +1 @@
+--autocommit=0

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func3.test'
--- a/mysql-test/suite/sys_vars/t/autocommit_func3.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func3.test	revid:vasil.dimov@stripped
@@ -0,0 +1 @@
+--source suite/sys_vars/inc/autocommit_func2.inc

=== modified file 'mysql-test/t/ctype_uca.test'
--- a/mysql-test/t/ctype_uca.test	revid:jimmy.yang@stripped0101105133317-dvev6424yzogf4gq
+++ b/mysql-test/t/ctype_uca.test	revid:vasil.dimov@strippedsg51xgg75x0
@@ -68,7 +68,6 @@ select group_concat(c1 order by c1) from
 select group_concat(c1 order by c1) from t1 group by c1 collate utf8_german2_ci;
 select group_concat(c1 order by c1) from t1 group by c1 collate utf8_unicode_520_ci;
 select group_concat(c1 order by c1) from t1 group by c1 collate utf8_vietnamese_ci;
-select group_concat(c1 order by c1) from t1 group by c1 collate utf8_vietnamese_520_ci;
 
 ALTER TABLE t1 CONVERT TO CHARACTER SET ucs2 COLLATE ucs2_bin;
 SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_unicode_ci;
@@ -92,7 +91,6 @@ SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM
 SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_german2_ci;
 SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_unicode_520_ci;
 SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_vietnamese_ci;
-SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_vietnamese_520_ci;
 
 drop table t1;
 

=== modified file 'mysql-test/t/ctype_utf16_uca.test'
--- a/mysql-test/t/ctype_utf16_uca.test	revid:jimmy.yang@stripped
+++ b/mysql-test/t/ctype_utf16_uca.test	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -55,7 +55,6 @@ select group_concat(c1 order by binary c
 select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_german2_ci;
 select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_unicode_520_ci;
 select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_vietnamese_ci;
-select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_vietnamese_520_ci;
 
 drop table t1;
 

=== modified file 'mysql-test/t/ctype_utf32_uca.test'
--- a/mysql-test/t/ctype_utf32_uca.test	revid:jimmy.yang@strippeddvev6424yzogf4gq
+++ b/mysql-test/t/ctype_utf32_uca.test	revid:vasil.dimov@stripped5x0
@@ -56,7 +56,6 @@ select group_concat(c1 order by binary c
 select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_german2_ci;
 select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_unicode_520_ci;
 select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_vietnamese_ci;
-select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_vietnamese_520_ci;
 
 drop table t1;
 

=== modified file 'mysql-test/t/errors.test'
--- a/mysql-test/t/errors.test	revid:jimmy.yang@stripped7-dvev6424yzogf4gq
+++ b/mysql-test/t/errors.test	revid:vasil.dimov@stripped
@@ -155,3 +155,19 @@ INSERT INTO t1 VALUES ('abc\0\0');
 --error ER_DUP_ENTRY
 INSERT INTO t1 VALUES ('abc\0\0');
 DROP TABLE t1;
+
+--echo #
+--echo # Bug#57882: Item_func_conv_charset::val_str(String*): 
+--echo #            Assertion `fixed == 1' failed
+--echo #
+
+--error ER_DATA_OUT_OF_RANGE
+SELECT (CONVERT('0' USING latin1) IN (CHAR(COT('v') USING utf8),''));
+
+SET NAMES utf8 COLLATE utf8_latvian_ci ;
+--error ER_DATA_OUT_OF_RANGE
+SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null);
+
+--echo #
+--echo # End Bug#57882
+--echo #

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	revid:jimmy.yang@stripped20101105133317-dvev6424yzogf4gq
+++ b/mysql-test/t/func_time.test	revid:vasil.dimov@stripped5sg51xgg75x0
@@ -832,6 +832,16 @@ INSERT INTO t1 VALUES (0),(9.216e-096);
 SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a);
 DROP TABLE t1;
 
+--echo #
+--echo # Bug #52160: crash and inconsistent results when grouping
+--echo #             by a function and column
+--echo #
+
+CREATE TABLE t1(a CHAR(10) NOT NULL);
+INSERT INTO t1 VALUES (''),('');
+SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/keywords.test'
--- a/mysql-test/t/keywords.test	revid:jimmy.yang@stripped33317-dvev6424yzogf4gq
+++ b/mysql-test/t/keywords.test	revid:vasil.dimov@strippedx0
@@ -62,5 +62,103 @@ call p1();
 drop procedure p1;
 drop table t1;
 
-
 # End of 5.0 tests
+
+#
+# BUG#57899: Certain reserved words should not be reserved
+#
+
+#
+# We are looking for SYNTAX ERRORS here, so no need to 
+# log the queries
+#
+
+CREATE TABLE slow (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO slow(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO slow(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO slow(slow, general) VALUES (1,2), (5,6);
+INSERT INTO slow(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM slow ORDER BY slow;
+SELECT slow, general, master_heartbeat_period FROM slow ORDER BY slow;
+SELECT slow, master_heartbeat_period FROM slow ORDER BY slow;
+SELECT slow FROM slow ORDER BY slow;
+DROP TABLE slow;
+CREATE TABLE general (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO general(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO general(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO general(slow, general) VALUES (1,2), (5,6);
+INSERT INTO general(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM general ORDER BY slow;
+SELECT slow, general, master_heartbeat_period FROM general ORDER BY slow;
+SELECT slow, master_heartbeat_period FROM general ORDER BY slow;
+SELECT slow FROM general ORDER BY slow;
+DROP TABLE general;
+CREATE TABLE master_heartbeat_period (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO master_heartbeat_period(slow, general) VALUES (1,2), (5,6);
+INSERT INTO master_heartbeat_period(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM master_heartbeat_period ORDER BY slow;
+SELECT slow, general, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow;
+SELECT slow, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow;
+SELECT slow FROM master_heartbeat_period ORDER BY slow;
+DROP TABLE master_heartbeat_period;
+CREATE TABLE ignore_server_ids (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO ignore_server_ids(slow, general) VALUES (1,2), (5,6);
+INSERT INTO ignore_server_ids(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM ignore_server_ids ORDER BY slow;
+SELECT slow, general, master_heartbeat_period FROM ignore_server_ids ORDER BY slow;
+SELECT slow, master_heartbeat_period FROM ignore_server_ids ORDER BY slow;
+SELECT slow FROM ignore_server_ids ORDER BY slow;
+DROP TABLE ignore_server_ids;
+
+CREATE TABLE t1 (slow INT, general INT, ignore_server_ids INT, master_heartbeat_period INT);
+INSERT INTO t1 VALUES (1,2,3,4);
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+  DECLARE slow INT;
+  DECLARE general INT;
+  DECLARE ignore_server_ids INT;
+  DECLARE master_heartbeat_period INT;
+
+  SELECT max(t1.slow) INTO slow FROM t1;
+  SELECT max(t1.general) INTO general FROM t1;
+  SELECT max(t1.ignore_server_ids) INTO ignore_server_ids FROM t1;
+  SELECT max(t1.master_heartbeat_period) INTO master_heartbeat_period FROM t1;
+
+  SELECT slow, general, ignore_server_ids, master_heartbeat_period;
+END|
+
+CREATE PROCEDURE p2()
+BEGIN
+
+   DECLARE n INT DEFAULT 2;
+   general: WHILE n > 0 DO 
+     SET n = n -1;
+   END WHILE general;
+
+   SET n = 2;
+   slow: WHILE n > 0 DO 
+     SET n = n -1;
+   END WHILE slow;
+
+   SET n = 2;
+   ignore_server_ids: WHILE n > 0 DO 
+     SET n = n -1;
+   END WHILE ignore_server_ids;
+
+   SET n = 2;
+   master_heartbeat_period: WHILE n > 0 DO 
+     SET n = n -1;
+   END WHILE master_heartbeat_period;
+
+END|
+DELIMITER ;|
+CALL p1();
+call p2();
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP TABLE t1;

=== modified file 'mysql-test/t/log_tables.test'
--- a/mysql-test/t/log_tables.test	revid:jimmy.yang@stripped
+++ b/mysql-test/t/log_tables.test	revid:vasil.dimov@stripped101108144220-zlcp5sg51xgg75x0
@@ -1034,6 +1034,25 @@ DROP TABLE t1;
 
 TRUNCATE TABLE mysql.slow_log;
 
+#
+# Bug #47924 main.log_tables times out sporadically
+#
+
+use mysql;
+# Should result in error
+--disable_warnings
+drop table if exists renamed_general_log;
+drop table if exists renamed_slow_log;
+--enable_warnings
+--error ER_CANT_RENAME_LOG_TABLE
+RENAME TABLE general_log TO renamed_general_log;
+--error ER_CANT_RENAME_LOG_TABLE
+RENAME TABLE slow_log TO renamed_slow_log;
+
+use test;
+flush tables with read lock;
+unlock tables;
+
 SET @@session.long_query_time= @old_long_query_time;
 
 SET @@global.log_output=       @old_log_output;

=== modified file 'mysql-test/t/mysqlbinlog.test'
--- a/mysql-test/t/mysqlbinlog.test	revid:jimmy.yang@strippedq
+++ b/mysql-test/t/mysqlbinlog.test	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -487,3 +487,20 @@ diff_files $MYSQLTEST_VARDIR/tmp/mysqlbi
 # Cleanup for this part of test
 remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
 remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn;
+
+#
+# WL#5625: Deprecate mysqlbinlog options --base64-output=always and --base64-output
+#
+
+--echo # Expect error for unknown argument.
+--error 1
+--exec $MYSQL_BINLOG --base64-output=always std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+--cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+
+--echo # Expect error for unknown argument again.
+--error 1
+--exec $MYSQL_BINLOG --base64-output std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+--cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+
+# Clean up this part of the test.
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn

=== modified file 'mysql-test/t/plugin_auth.test'
--- a/mysql-test/t/plugin_auth.test	revid:jimmy.yang@stripped33317-dvev6424yzogf4gq
+++ b/mysql-test/t/plugin_auth.test	revid:vasil.dimov@strippedg75x0
@@ -16,6 +16,11 @@ connect(plug_con,localhost,plug,plug_des
 --enable_query_log
 
 GRANT PROXY ON plug_dest TO plug;
+--echo test proxies_priv columns
+--replace_column 1 xx 7 xx
+SELECT * FROM mysql.proxies_priv;
+--echo test mysql.proxies_priv;
+SHOW CREATE TABLE mysql.proxies_priv;
 
 connect(plug_con,localhost,plug,plug_dest);
 
@@ -226,7 +231,7 @@ CREATE USER test_drop@localhost;
 GRANT PROXY ON future_user TO test_drop@localhost;
 SHOW GRANTS FOR test_drop@localhost;
 DROP USER test_drop@localhost;
-SELECT * FROM mysql.proxy_priv WHERE Host = 'test_drop' AND User = 'localhost';
+SELECT * FROM mysql.proxies_priv WHERE Host = 'test_drop' AND User = 'localhost';
 
 DROP USER proxy_admin;
 

=== modified file 'mysql-test/t/system_mysql_db_fix40123.test'
--- a/mysql-test/t/system_mysql_db_fix40123.test	revid:jimmy.yang@stripped05133317-dvev6424yzogf4gq
+++ b/mysql-test/t/system_mysql_db_fix40123.test	revid:vasil.dimov@stripped4220-zlcp5sg51xgg75x0
@@ -72,7 +72,7 @@ CREATE TABLE time_zone_leap_second (   T
 -- disable_query_log
 
 # Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
 
 -- enable_query_log
 

=== modified file 'mysql-test/t/system_mysql_db_fix50030.test'
--- a/mysql-test/t/system_mysql_db_fix50030.test	revid:jimmy.yang@stripped
+++ b/mysql-test/t/system_mysql_db_fix50030.test	revid:vasil.dimov@stripped
@@ -78,7 +78,7 @@ INSERT INTO servers VALUES ('test','loca
 -- disable_query_log
 
 # Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
 
 -- enable_query_log
 

=== modified file 'mysql-test/t/system_mysql_db_fix50117.test'
--- a/mysql-test/t/system_mysql_db_fix50117.test	revid:jimmy.yang@stripped105133317-dvev6424yzogf4gq
+++ b/mysql-test/t/system_mysql_db_fix50117.test	revid:vasil.dimov@stripped44220-zlcp5sg51xgg75x0
@@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS ndb_binlog_in
 -- disable_query_log
 
 # Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
 
 -- enable_query_log
 

=== modified file 'mysql-test/t/type_blob.test'
--- a/mysql-test/t/type_blob.test	revid:jimmy.yang@stripped05133317-dvev6424yzogf4gq
+++ b/mysql-test/t/type_blob.test	revid:vasil.dimov@strippedgg75x0
@@ -617,4 +617,17 @@ SELECT LENGTH(c) FROM t2;
 
 DROP TABLE t1, t2;
 
+--echo # Bug #52160: crash and inconsistent results when grouping
+--echo #             by a function and column
+
+CREATE FUNCTION f1() RETURNS TINYBLOB RETURN 1;
+
+CREATE TABLE t1(a CHAR(1));
+INSERT INTO t1 VALUES ('0'), ('0');
+
+SELECT COUNT(*) FROM t1 GROUP BY f1(), a;
+
+DROP FUNCTION f1;
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== modified file 'mysys/charset-def.c'
--- a/mysys/charset-def.c	revid:jimmy.yang@strippedm-20101105133317-dvev6424yzogf4gq
+++ b/mysys/charset-def.c	revid:vasil.dimov@strippedgg75x0
@@ -46,7 +46,6 @@ extern CHARSET_INFO my_charset_ucs2_hung
 extern CHARSET_INFO my_charset_ucs2_sinhala_uca_ci;
 extern CHARSET_INFO my_charset_ucs2_unicode_520_ci;
 extern CHARSET_INFO my_charset_ucs2_vietnamese_ci;
-extern CHARSET_INFO my_charset_ucs2_vietnamese_520_ci;
 #endif /* HAVE_CHARSET_ucs2 */
 
 
@@ -73,7 +72,6 @@ extern CHARSET_INFO my_charset_utf32_hun
 extern CHARSET_INFO my_charset_utf32_sinhala_uca_ci;
 extern CHARSET_INFO my_charset_utf32_unicode_520_ci;
 extern CHARSET_INFO my_charset_utf32_vietnamese_ci;
-extern CHARSET_INFO my_charset_utf32_vietnamese_520_ci;
 #endif /* HAVE_CHARSET_utf32 */
 
 
@@ -100,7 +98,6 @@ extern CHARSET_INFO my_charset_utf16_hun
 extern CHARSET_INFO my_charset_utf16_sinhala_uca_ci;
 extern CHARSET_INFO my_charset_utf16_unicode_520_ci;
 extern CHARSET_INFO my_charset_utf16_vietnamese_ci;
-extern CHARSET_INFO my_charset_utf16_vietnamese_520_ci;
 #endif  /* HAVE_CHARSET_utf16 */
 
 
@@ -127,7 +124,6 @@ extern CHARSET_INFO my_charset_utf8_hung
 extern CHARSET_INFO my_charset_utf8_sinhala_uca_ci;
 extern CHARSET_INFO my_charset_utf8_unicode_520_ci;
 extern CHARSET_INFO my_charset_utf8_vietnamese_ci;
-extern CHARSET_INFO my_charset_utf8_vietnamese_520_ci;
 #ifdef HAVE_UTF8_GENERAL_CS
 extern CHARSET_INFO my_charset_utf8_general_cs;
 #endif
@@ -156,7 +152,6 @@ extern CHARSET_INFO my_charset_utf8mb4_h
 extern CHARSET_INFO my_charset_utf8mb4_sinhala_uca_ci;
 extern CHARSET_INFO my_charset_utf8mb4_unicode_520_ci;
 extern CHARSET_INFO my_charset_utf8mb4_vietnamese_ci;
-extern CHARSET_INFO my_charset_utf8mb4_vietnamese_520_ci;
 #endif /* HAVE_CHARSET_utf8mb4 */
 
 #endif /* HAVE_UCA_COLLATIONS */
@@ -247,7 +242,6 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_ucs2_sinhala_uca_ci);
   add_compiled_collation(&my_charset_ucs2_unicode_520_ci);
   add_compiled_collation(&my_charset_ucs2_vietnamese_ci);
-  add_compiled_collation(&my_charset_ucs2_vietnamese_520_ci);
 #endif
 #endif
 
@@ -286,7 +280,6 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_utf8_sinhala_uca_ci);
   add_compiled_collation(&my_charset_utf8_unicode_520_ci);
   add_compiled_collation(&my_charset_utf8_vietnamese_ci);
-  add_compiled_collation(&my_charset_utf8_vietnamese_520_ci);
 #endif
 #endif /* HAVE_CHARSET_utf8 */
 
@@ -318,7 +311,6 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_utf8mb4_sinhala_uca_ci);
   add_compiled_collation(&my_charset_utf8mb4_unicode_520_ci);
   add_compiled_collation(&my_charset_utf8mb4_vietnamese_ci);
-  add_compiled_collation(&my_charset_utf8mb4_vietnamese_520_ci);
 #endif /* HAVE_UCA_COLLATIONS  */
 #endif /* HAVE_CHARSET_utf8mb4 */
 
@@ -350,7 +342,6 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_utf16_sinhala_uca_ci);
   add_compiled_collation(&my_charset_utf16_unicode_520_ci);
   add_compiled_collation(&my_charset_utf16_vietnamese_ci);
-  add_compiled_collation(&my_charset_utf16_vietnamese_520_ci);
 #endif /* HAVE_UCA_COLLATIOINS */
 #endif /* HAVE_CHARSET_utf16 */
 
@@ -382,7 +373,6 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_utf32_sinhala_uca_ci);
   add_compiled_collation(&my_charset_utf32_unicode_520_ci);
   add_compiled_collation(&my_charset_utf32_vietnamese_ci);
-  add_compiled_collation(&my_charset_utf32_vietnamese_520_ci);
 #endif /* HAVE_UCA_COLLATIONS */
 #endif /* HAVE_CHARSET_utf32 */
 

=== modified file 'mysys/default.c'
--- a/mysys/default.c	revid:jimmy.yang@stripped
+++ b/mysys/default.c	revid:vasil.dimov@stripped8144220-zlcp5sg51xgg75x0
@@ -66,7 +66,9 @@
 const char *args_separator= "----args-separator----";
 const char *my_defaults_file=0;
 const char *my_defaults_group_suffix=0;
-char *my_defaults_extra_file=0;
+const char *my_defaults_extra_file=0;
+
+static my_bool defaults_already_read= FALSE;
 
 /* Which directories are searched for options (and in which order) */
 
@@ -140,6 +142,36 @@ static char *remove_end_comment(char *pt
 
 
 /*
+  Expand a file name so that the current working directory is added if
+  the name is relative.
+
+  RETURNS
+   0   All OK
+   2   Out of memory or path to long
+   3   Not able to get working directory
+ */
+
+static int
+fn_expand(const char *filename, const char **filename_var)
+{
+  char dir[FN_REFLEN], buf[FN_REFLEN];
+  const int flags= MY_UNPACK_FILENAME | MY_SAFE_PATH | MY_RELATIVE_PATH;
+  const char *result_path= NULL;
+  DBUG_ENTER("fn_expand");
+  DBUG_PRINT("enter", ("filename: %s, buf: 0x%lx", filename, (unsigned long) buf));
+  if (my_getwd(dir, sizeof(dir), MYF(0)))
+    DBUG_RETURN(3);
+  DBUG_PRINT("debug", ("dir: %s", dir));
+  if (fn_format(buf, filename, dir, NULL, flags) == NULL ||
+      (result_path= my_strdup(buf, MYF(0))) == NULL)
+    DBUG_RETURN(2);
+  DBUG_PRINT("return", ("result: %s", result_path));
+  DBUG_ASSERT(result_path != NULL);
+  *filename_var= result_path;
+  DBUG_RETURN(0);
+}
+
+/*
   Process config files in default directories.
 
   SYNOPSIS
@@ -167,6 +199,7 @@ static char *remove_end_comment(char *pt
     0  ok
     1  given cinf_file doesn't exist
     2  out of memory
+    3  Can't get current working directory
 
     The global variable 'my_defaults_group_suffix' is updated with value for
     --defaults_group_suffix
@@ -189,11 +222,21 @@ int my_search_option_files(const char *c
   if (! my_defaults_group_suffix)
     my_defaults_group_suffix= getenv(STRINGIFY_ARG(DEFAULT_GROUP_SUFFIX_ENV));
 
-  if (forced_extra_defaults)
-    my_defaults_extra_file= (char *) forced_extra_defaults;
-  
-  if (forced_default_file)
-    my_defaults_file= forced_default_file;
+  if (forced_extra_defaults && !defaults_already_read)
+  {
+    int error= fn_expand(forced_extra_defaults, &my_defaults_extra_file);
+    if (error)
+      DBUG_RETURN(error);
+  }
+
+  if (forced_default_file && !defaults_already_read)
+  {
+    int error= fn_expand(forced_default_file, &my_defaults_file);
+    if (error)
+      DBUG_RETURN(error);
+  }
+
+  defaults_already_read= TRUE;
 
   /*
     We can only handle 'defaults-group-suffix' if we are called from
@@ -236,15 +279,15 @@ int my_search_option_files(const char *c
     group->type_names[group->count]= 0;
   }
   
-  if (forced_default_file)
+  if (my_defaults_file)
   {
     if ((error= search_default_file_with_ext(func, func_ctx, "", "",
-                                             forced_default_file, 0)) < 0)
+                                             my_defaults_file, 0)) < 0)
       goto err;
     if (error > 0)
     {
       fprintf(stderr, "Could not open required defaults file: %s\n",
-              forced_default_file);
+              my_defaults_file);
       goto err;
     }
   }

=== modified file 'mysys/stacktrace.c'
--- a/mysys/stacktrace.c	revid:jimmy.yang@stripped33317-dvev6424yzogf4gq
+++ b/mysys/stacktrace.c	revid:vasil.dimov@stripped
@@ -315,6 +315,9 @@ end:
 /* Produce a core for the thread */
 void my_write_core(int sig)
 {
+#ifdef HAVE_gcov
+  extern void __gcov_flush(void);
+#endif
   signal(sig, SIG_DFL);
 #ifdef HAVE_gcov
   /*
@@ -322,7 +325,6 @@ void my_write_core(int sig)
     information from this process, causing gcov output to be incomplete.
     So we force the writing of coverage information here before terminating.
   */
-  extern void __gcov_flush(void);
   __gcov_flush();
 #endif
   pthread_kill(pthread_self(), sig);

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

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

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	revid:jimmy.yang@stripped3317-dvev6424yzogf4gq
+++ b/scripts/mysql_system_tables.sql	revid:vasil.dimov@strippedgg75x0
@@ -474,7 +474,7 @@ PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;
 
-CREATE TABLE IF NOT EXISTS proxy_priv (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Proxied_Host char(16) binary DEFAULT '' NOT NULL, Proxied_User char(60) binary DEFAULT '' NOT NULL, With_Grant BOOL DEFAULT 0 NOT NULL, PRIMARY KEY Host (Host,User,Proxied_Host,Proxied_User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges';
+CREATE TABLE IF NOT EXISTS proxies_priv (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Proxied_host char(60) binary DEFAULT '' NOT NULL, Proxied_user char(16) binary DEFAULT '' NOT NULL, With_grant BOOL DEFAULT 0 NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY Host (Host,User,Proxied_host,Proxied_user), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges';
 
--- Remember for later if proxy_priv table already existed
-set @had_proxy_priv_table= @@warning_count != 0;
+-- Remember for later if proxies_priv table already existed
+set @had_proxies_priv_table= @@warning_count != 0;

=== modified file 'scripts/mysql_system_tables_data.sql'
--- a/scripts/mysql_system_tables_data.sql	revid:jimmy.yang@stripped
+++ b/scripts/mysql_system_tables_data.sql	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -30,8 +30,8 @@ INSERT INTO tmp_user (host,user) SELECT 
 INSERT INTO user SELECT * FROM tmp_user WHERE @had_user_table=0;
 DROP TABLE tmp_user;
 
-CREATE TEMPORARY TABLE tmp_proxy_priv LIKE proxy_priv;
-INSERT INTO tmp_proxy_priv VALUES ('localhost', 'root', '', '', TRUE);
-REPLACE INTO tmp_proxy_priv SELECT @current_hostname, 'root', '', '', TRUE FROM DUAL WHERE LOWER (@current_hostname) != 'localhost';
-INSERT INTO  proxy_priv SELECT * FROM tmp_proxy_priv WHERE @had_proxy_priv_table=0;
-DROP TABLE tmp_proxy_priv;
+CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv;
+INSERT INTO tmp_proxies_priv VALUES ('localhost', 'root', '', '', TRUE, '', now());
+REPLACE INTO tmp_proxies_priv SELECT @current_hostname, 'root', '', '', TRUE, '', now() FROM DUAL WHERE LOWER (@current_hostname) != 'localhost';
+INSERT INTO  proxies_priv SELECT * FROM tmp_proxies_priv WHERE @had_proxies_priv_table=0;
+DROP TABLE tmp_proxies_priv;

=== modified file 'scripts/mysql_system_tables_fix.sql'
--- a/scripts/mysql_system_tables_fix.sql	revid:jimmy.yang@stripped
+++ b/scripts/mysql_system_tables_fix.sql	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -643,7 +643,7 @@ drop procedure mysql.die;
 ALTER TABLE user ADD plugin char(60) DEFAULT '' NOT NULL,  ADD authentication_string TEXT NOT NULL;
 ALTER TABLE user MODIFY plugin char(60) DEFAULT '' NOT NULL;
 
-CREATE TABLE IF NOT EXISTS proxy_priv (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Proxied_User char(60) binary DEFAULT '' NOT NULL, Proxied_Host char(16) binary DEFAULT '' NOT NULL, With_Grant BOOL DEFAULT 0 NOT NULL, PRIMARY KEY Host (Host,User,Proxied_Host,Proxied_User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges';
+CREATE TABLE IF NOT EXISTS proxies_priv (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Proxied_host char(60) binary DEFAULT '' NOT NULL, Proxied_user char(16) binary DEFAULT '' NOT NULL, With_grant BOOL DEFAULT 0 NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY Host (Host,User,Proxied_host,Proxied_user), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges';
 
 # Activate the new, possible modified privilege tables
 # This should not be needed, but gives us some extra testing that the above

=== modified file 'sql/field.cc'
--- a/sql/field.cc	revid:jimmy.yang@stripped7-dvev6424yzogf4gq
+++ b/sql/field.cc	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -7748,12 +7748,6 @@ void Field_blob::sql_type(String &res) c
 uchar *Field_blob::pack(uchar *to, const uchar *from,
                         uint max_length, bool low_byte_first)
 {
-  DBUG_ENTER("Field_blob::pack");
-  DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx;"
-                       " max_length: %u; low_byte_first: %d",
-                       (ulong) to, (ulong) from,
-                       max_length, low_byte_first));
-  DBUG_DUMP("record", from, table->s->reclength);
   uchar *save= ptr;
   ptr= (uchar*) from;
   uint32 length=get_length();			// Length of from string
@@ -7774,8 +7768,7 @@ uchar *Field_blob::pack(uchar *to, const
     memcpy(to+packlength, from,length);
   }
   ptr=save;					// Restore org row pointer
-  DBUG_DUMP("packed", to, packlength + length);
-  DBUG_RETURN(to+packlength+length);
+  return to+packlength+length;
 }
 
 
@@ -8419,6 +8412,54 @@ uint Field_enum::is_equal(Create_field *
 }
 
 
+uchar *Field_enum::pack(uchar *to, const uchar *from,
+                        uint max_length, bool low_byte_first)
+{
+  DBUG_ENTER("Field_enum::pack");
+  DBUG_PRINT("debug", ("packlength: %d", packlength));
+  DBUG_DUMP("from", from, packlength);
+
+  switch (packlength)
+  {
+  case 1:
+    *to = *from;
+    DBUG_RETURN(to + 1);
+  case 2: DBUG_RETURN(pack_int16(to, from, low_byte_first));
+  case 3: DBUG_RETURN(pack_int24(to, from, low_byte_first));
+  case 4: DBUG_RETURN(pack_int32(to, from, low_byte_first));
+  case 8: DBUG_RETURN(pack_int64(to, from, low_byte_first));
+  default:
+    DBUG_ASSERT(0);
+  }
+  MY_ASSERT_UNREACHABLE();
+  DBUG_RETURN(NULL);
+}
+
+const uchar *Field_enum::unpack(uchar *to, const uchar *from,
+                                uint param_data, bool low_byte_first)
+{
+  DBUG_ENTER("Field_enum::unpack");
+  DBUG_PRINT("debug", ("packlength: %d", packlength));
+  DBUG_DUMP("from", from, packlength);
+
+  switch (packlength)
+  {
+  case 1:
+    *to = *from;
+    DBUG_RETURN(from + 1);
+
+  case 2: DBUG_RETURN(unpack_int16(to, from, low_byte_first));
+  case 3: DBUG_RETURN(unpack_int24(to, from, low_byte_first));
+  case 4: DBUG_RETURN(unpack_int32(to, from, low_byte_first));
+  case 8: DBUG_RETURN(unpack_int64(to, from, low_byte_first));
+  default:
+    DBUG_ASSERT(0);
+  }
+  MY_ASSERT_UNREACHABLE();
+  DBUG_RETURN(NULL);
+}
+
+
 /**
   @return
   returns 1 if the fields are equally defined

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

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	revid:jimmy.yang@stripped05133317-dvev6424yzogf4gq
+++ b/sql/ha_partition.h	revid:vasil.dimov@stripped
@@ -935,22 +935,16 @@ private:
     /* lock already taken */
     if (auto_increment_safe_stmt_log_lock)
       return;
-#ifdef WITH_PARTITION_STORAGE_ENGINE
     DBUG_ASSERT(table_share->ha_part_data && !auto_increment_lock);
-#endif
     if(table_share->tmp_table == NO_TMP_TABLE)
     {
       auto_increment_lock= TRUE;
-#ifdef WITH_PARTITION_STORAGE_ENGINE
       mysql_mutex_lock(&table_share->ha_part_data->LOCK_auto_inc);
-#endif
     }
   }
   virtual void unlock_auto_increment()
   {
-#ifdef WITH_PARTITION_STORAGE_ENGINE
     DBUG_ASSERT(table_share->ha_part_data);
-#endif
     /*
       If auto_increment_safe_stmt_log_lock is true, we have to keep the lock.
       It will be set to false and thus unlocked at the end of the statement by
@@ -958,25 +952,19 @@ private:
     */
     if(auto_increment_lock && !auto_increment_safe_stmt_log_lock)
     {
-#ifdef WITH_PARTITION_STORAGE_ENGINE
       mysql_mutex_unlock(&table_share->ha_part_data->LOCK_auto_inc);
-#endif
       auto_increment_lock= FALSE;
     }
   }
   virtual void set_auto_increment_if_higher(Field *field)
   {
-#ifdef WITH_PARTITION_STORAGE_ENGINE
     ulonglong nr= (((Field_num*) field)->unsigned_flag ||
                    field->val_int() > 0) ? field->val_int() : 0;
-#endif
     lock_auto_increment();
-#ifdef WITH_PARTITION_STORAGE_ENGINE
     DBUG_ASSERT(table_share->ha_part_data->auto_inc_initialized == TRUE);
     /* must check when the mutex is taken */
     if (nr >= table_share->ha_part_data->next_auto_inc_val)
       table_share->ha_part_data->next_auto_inc_val= nr + 1;
-#endif
     unlock_auto_increment();
   }
 

=== modified file 'sql/item.cc'
--- a/sql/item.cc	revid:jimmy.yang@strippeddvev6424yzogf4gq
+++ b/sql/item.cc	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -1853,11 +1853,12 @@ bool agg_item_set_converter(DTCollation 
       *arg= conv;
     else
       thd->change_item_tree(arg, conv);
-    /*
-      We do not check conv->fixed, because Item_func_conv_charset which can
-      be return by safe_charset_converter can't be fixed at creation
-    */
-    conv->fix_fields(thd, arg);
+
+    if (conv->fix_fields(thd, arg))
+    {
+      res= TRUE;
+      break; // we cannot return here, we need to restore "arena".
+    }
   }
   if (arena)
     thd->restore_active_arena(arena, &backup);

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	revid:jimmy.yang@stripped7-dvev6424yzogf4gq
+++ b/sql/item_timefunc.h	revid:vasil.dimov@stripped
@@ -361,6 +361,7 @@ public:
   const char *func_name() const { return "time_to_sec"; }
   void fix_length_and_dec()
   {
+    maybe_null= TRUE;
     decimals=0;
     max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
   }

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	revid:jimmy.yang@oracle.com-20101105133317-dvev6424yzogf4gq
+++ b/sql/log_event.h	revid:vasil.dimov@strippedg75x0
@@ -628,9 +628,8 @@ class Relay_log_info;
 enum enum_base64_output_mode {
   BASE64_OUTPUT_NEVER= 0,
   BASE64_OUTPUT_AUTO= 1,
-  BASE64_OUTPUT_ALWAYS= 2,
-  BASE64_OUTPUT_UNSPEC= 3,
-  BASE64_OUTPUT_DECODE_ROWS= 4,
+  BASE64_OUTPUT_UNSPEC= 2,
+  BASE64_OUTPUT_DECODE_ROWS= 3,
   /* insert new output modes here */
   BASE64_OUTPUT_MODE_COUNT
 };

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	revid:jimmy.yang@stripped424yzogf4gq
+++ b/sql/mysqld.cc	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -3926,12 +3926,12 @@ static int init_server_components()
     unireg_abort(1);
   }
 
-  /* initialize delegates for extension observers */
+  /*
+    initialize delegates for extension observers, errors have already
+    been reported in the function
+  */
   if (delegates_init())
-  {
-    sql_print_error("Initialize extension delegates failed");
     unireg_abort(1);
-  }
 
   /* need to configure logging before initializing storage engines */
   if (opt_log_slave_updates && !opt_bin_log)
@@ -5823,6 +5823,12 @@ struct my_option my_long_options[]=
   {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode "
    "will also set transaction isolation level 'serializable'.", 0, 0, 0,
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+  /*
+    Because Sys_var_bit does not support command-line options, we need to
+    explicitely add one for --autocommit
+  */
+  {"autocommit", OPT_AUTOCOMMIT, "Set default value for autocommit (0 or 1)",
+   NULL, NULL, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, NULL},
   {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.",
    &my_bind_addr_str, &my_bind_addr_str, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -7263,6 +7269,13 @@ mysqld_get_one_option(int optid,
     if (argument == NULL) /* no argument */
       log_error_file_ptr= const_cast<char*>("");
     break;
+  case OPT_AUTOCOMMIT:
+    const ulonglong turn_bit_on= (argument && (atoi(argument) == 0)) ?
+      OPTION_NOT_AUTOCOMMIT : OPTION_AUTOCOMMIT;
+    global_system_variables.option_bits=
+      (global_system_variables.option_bits &
+       ~(OPTION_NOT_AUTOCOMMIT | OPTION_AUTOCOMMIT)) | turn_bit_on;
+    break;
   }
   return 0;
 }

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	revid:jimmy.yang@stripped
+++ b/sql/mysqld.h	revid:vasil.dimov@stripped220-zlcp5sg51xgg75x0
@@ -395,7 +395,8 @@ enum options_mysqld
   OPT_UPDATE_LOG,
   OPT_WANT_CORE,
   OPT_ENGINE_CONDITION_PUSHDOWN,
-  OPT_LOG_ERROR
+  OPT_LOG_ERROR,
+  OPT_AUTOCOMMIT
 };
 
 

=== modified file 'sql/rpl_handler.cc'
--- a/sql/rpl_handler.cc	revid:jimmy.yang@stripped-20101105133317-dvev6424yzogf4gq
+++ b/sql/rpl_handler.cc	revid:vasil.dimov@stripped75x0
@@ -104,12 +104,20 @@ int delegates_init()
   transaction_delegate= new (place_trans_mem) Trans_delegate;
 
   if (!transaction_delegate->is_inited())
+  {
+    sql_print_error("Initialization of transaction delegates failed. "
+                    "Please report a bug.");
     return 1;
+  }
 
   binlog_storage_delegate= new (place_storage_mem) Binlog_storage_delegate;
 
   if (!binlog_storage_delegate->is_inited())
+  {
+    sql_print_error("Initialization binlog storage delegates failed. "
+                    "Please report a bug.");
     return 1;
+  }
 
 #ifdef HAVE_REPLICATION
   void *place_transmit_mem= transmit_mem.data;
@@ -118,16 +126,29 @@ int delegates_init()
   binlog_transmit_delegate= new (place_transmit_mem) Binlog_transmit_delegate;
 
   if (!binlog_transmit_delegate->is_inited())
+  {
+    sql_print_error("Initialization of binlog transmit delegates failed. "
+                    "Please report a bug.");
     return 1;
+  }
 
   binlog_relay_io_delegate= new (place_relay_io_mem) Binlog_relay_IO_delegate;
 
   if (!binlog_relay_io_delegate->is_inited())
+  {
+    sql_print_error("Initialization binlog relay IO delegates failed. "
+                    "Please report a bug.");
     return 1;
+  }
 #endif
 
   if (pthread_key_create(&RPL_TRANS_BINLOG_INFO, NULL))
+  {
+    sql_print_error("Error while creating pthread specific data key for replication. "
+                    "Please report a bug.");
     return 1;
+  }
+
   return 0;
 }
 

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

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	revid:jimmy.yang@stripped0101105133317-dvev6424yzogf4gq
+++ b/sql/sql_acl.cc	revid:vasil.dimov@stripped
@@ -268,11 +268,13 @@ class ACL_PROXY_USER :public ACL_ACCESS
   bool with_grant;
 
   typedef enum { 
-    MYSQL_PROXY_PRIV_HOST, 
-    MYSQL_PROXY_PRIV_USER, 
-    MYSQL_PROXY_PRIV_PROXIED_HOST,
-    MYSQL_PROXY_PRIV_PROXIED_USER, 
-    MYSQL_PROXY_PRIV_WITH_GRANT } old_acl_proxy_users;
+    MYSQL_PROXIES_PRIV_HOST, 
+    MYSQL_PROXIES_PRIV_USER, 
+    MYSQL_PROXIES_PRIV_PROXIED_HOST,
+    MYSQL_PROXIES_PRIV_PROXIED_USER, 
+    MYSQL_PROXIES_PRIV_WITH_GRANT,
+    MYSQL_PROXIES_PRIV_GRANTOR,
+    MYSQL_PROXIES_PRIV_TIMESTAMP } old_acl_proxy_users;
 public:
   ACL_PROXY_USER () {};
 
@@ -308,11 +310,11 @@ public:
 
   void init(TABLE *table, MEM_ROOT *mem)
   {
-    init (get_field(mem, table->field[MYSQL_PROXY_PRIV_HOST]),
-          get_field(mem, table->field[MYSQL_PROXY_PRIV_USER]),
-          get_field(mem, table->field[MYSQL_PROXY_PRIV_PROXIED_HOST]),
-          get_field(mem, table->field[MYSQL_PROXY_PRIV_PROXIED_USER]),
-          table->field[MYSQL_PROXY_PRIV_WITH_GRANT]->val_int() != 0);
+    init (get_field(mem, table->field[MYSQL_PROXIES_PRIV_HOST]),
+          get_field(mem, table->field[MYSQL_PROXIES_PRIV_USER]),
+          get_field(mem, table->field[MYSQL_PROXIES_PRIV_PROXIED_HOST]),
+          get_field(mem, table->field[MYSQL_PROXIES_PRIV_PROXIED_USER]),
+          table->field[MYSQL_PROXIES_PRIV_WITH_GRANT]->val_int() != 0);
   }
 
   bool get_with_grant() { return with_grant; }
@@ -337,7 +339,7 @@ public:
         (hostname_requires_resolving(host.hostname) ||
          hostname_requires_resolving(proxied_host.hostname)))
     {
-      sql_print_warning("'proxy_priv' entry '%s@%s %s@%s' "
+      sql_print_warning("'proxes_priv' entry '%s@%s %s@%s' "
                         "ignored in --skip-name-resolve mode.",
                         proxied_user ? proxied_user : "",
                         proxied_host.hostname ? proxied_host.hostname : "",
@@ -452,19 +454,19 @@ public:
                         user->str ? user->str : "<NULL>",
                         proxied_host->str ? proxied_host->str : "<NULL>",
                         proxied_user->str ? proxied_user->str : "<NULL>"));
-    if (table->field[MYSQL_PROXY_PRIV_HOST]->store(host->str, 
+    if (table->field[MYSQL_PROXIES_PRIV_HOST]->store(host->str, 
                                                    host->length,
                                                    system_charset_info))
       DBUG_RETURN(TRUE);
-    if (table->field[MYSQL_PROXY_PRIV_USER]->store(user->str, 
+    if (table->field[MYSQL_PROXIES_PRIV_USER]->store(user->str, 
                                                    user->length,
                                                    system_charset_info))
       DBUG_RETURN(TRUE);
-    if (table->field[MYSQL_PROXY_PRIV_PROXIED_HOST]->store(proxied_host->str,
+    if (table->field[MYSQL_PROXIES_PRIV_PROXIED_HOST]->store(proxied_host->str,
                                                            proxied_host->length,
                                                            system_charset_info))
       DBUG_RETURN(TRUE);
-    if (table->field[MYSQL_PROXY_PRIV_PROXIED_USER]->store(proxied_user->str,
+    if (table->field[MYSQL_PROXIES_PRIV_PROXIED_USER]->store(proxied_user->str,
                                                            proxied_user->length,
                                                            system_charset_info))
       DBUG_RETURN(TRUE);
@@ -472,20 +474,25 @@ public:
     DBUG_RETURN(FALSE);
   }
 
-  static int store_data_record(TABLE *table, 
-                               const LEX_STRING *host, 
+  static int store_data_record(TABLE *table,
+                               const LEX_STRING *host,
                                const LEX_STRING *user,
-                               const LEX_STRING *proxied_host, 
+                               const LEX_STRING *proxied_host,
                                const LEX_STRING *proxied_user,
-                               bool with_grant)
+                               bool with_grant,
+                               const char *grantor)
   {
-    DBUG_ENTER ("ACL_PROXY_USER::store_pk");
-    if (store_pk (table,  host, user, proxied_host, proxied_user))
+    DBUG_ENTER("ACL_PROXY_USER::store_pk");
+    if (store_pk(table,  host, user, proxied_host, proxied_user))
       DBUG_RETURN(TRUE);
-    DBUG_PRINT ("info", ("with_grant=%s", with_grant ? "TRUE" : "FALSE"));
-    if (table->field[MYSQL_PROXY_PRIV_WITH_GRANT]->store(with_grant ? 1 : 0, 
+    DBUG_PRINT("info", ("with_grant=%s", with_grant ? "TRUE" : "FALSE"));
+    if (table->field[MYSQL_PROXIES_PRIV_WITH_GRANT]->store(with_grant ? 1 : 0, 
                                                          TRUE))
       DBUG_RETURN(TRUE);
+    if (table->field[MYSQL_PROXIES_PRIV_GRANTOR]->store(grantor, 
+                                                        strlen(grantor),
+                                                        system_charset_info))
+      DBUG_RETURN(TRUE);
 
     DBUG_RETURN(FALSE);
   }
@@ -1113,8 +1120,8 @@ my_bool acl_reload(THD *thd)
   tables[2].init_one_table(C_STRING_WITH_LEN("mysql"),
                            C_STRING_WITH_LEN("db"), "db", TL_READ);
   tables[3].init_one_table(C_STRING_WITH_LEN("mysql"),
-                           C_STRING_WITH_LEN("proxy_priv"), 
-                           "proxy_priv", TL_READ);
+                           C_STRING_WITH_LEN("proxies_priv"), 
+                           "proxies_priv", TL_READ);
   tables[0].next_local= tables[0].next_global= tables + 1;
   tables[1].next_local= tables[1].next_global= tables + 2;
   tables[2].next_local= tables[2].next_global= tables + 3;
@@ -2608,7 +2615,7 @@ acl_insert_proxy_user(ACL_PROXY_USER *ne
 
 
 static int 
-replace_proxy_priv_table(THD *thd, TABLE *table, const LEX_USER *user,
+replace_proxies_priv_table(THD *thd, TABLE *table, const LEX_USER *user,
                          const LEX_USER *proxied_user, bool with_grant_arg, 
                          bool revoke_grant)
 {
@@ -2616,8 +2623,9 @@ replace_proxy_priv_table(THD *thd, TABLE
   int error;
   uchar user_key[MAX_KEY_LENGTH];
   ACL_PROXY_USER new_grant;
+  char grantor[USER_HOST_BUFF_SIZE];
 
-  DBUG_ENTER("replace_proxy_priv_table");
+  DBUG_ENTER("replace_proxies_priv_table");
 
   if (!initialized)
   {
@@ -2639,6 +2647,8 @@ replace_proxy_priv_table(THD *thd, TABLE
   key_copy(user_key, table->record[0], table->key_info,
            table->key_info->key_length);
 
+  get_grantor(thd, grantor);
+
   table->file->ha_index_init(0, 1);
   if (table->file->ha_index_read_map(table->record[0], user_key,
                                      HA_WHOLE_KEY,
@@ -2655,7 +2665,8 @@ replace_proxy_priv_table(THD *thd, TABLE
     ACL_PROXY_USER::store_data_record(table, &user->host, &user->user,
                                       &proxied_user->host,
                                       &proxied_user->user,
-                                      with_grant_arg);
+                                      with_grant_arg,
+                                      grantor);
   }
   else
   {
@@ -2712,7 +2723,7 @@ table_error:
   table->file->print_error(error, MYF(0));	/* purecov: inspected */
 
 abort:
-  DBUG_PRINT("info", ("aborting replace_proxy_priv_table"));
+  DBUG_PRINT("info", ("aborting replace_proxies_priv_table"));
   table->file->ha_index_end();
   DBUG_RETURN(-1);
 }
@@ -3977,14 +3988,14 @@ bool mysql_grant(THD *thd, const char *d
     proxied_user= str_list++;
   }
 
-  /* open the mysql.user and mysql.db or mysql.proxy_priv tables */
+  /* open the mysql.user and mysql.db or mysql.proxies_priv tables */
   tables[0].init_one_table(C_STRING_WITH_LEN("mysql"),
                            C_STRING_WITH_LEN("user"), "user", TL_WRITE);
   if (is_proxy)
 
     tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
-                             C_STRING_WITH_LEN("proxy_priv"),
-                             "proxy_priv", 
+                             C_STRING_WITH_LEN("proxies_priv"),
+                             "proxies_priv", 
                              TL_WRITE);
   else
     tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
@@ -4078,7 +4089,7 @@ bool mysql_grant(THD *thd, const char *d
     }
     else if (is_proxy)
     {
-      if (replace_proxy_priv_table (thd, tables[1].table, Str, proxied_user,
+      if (replace_proxies_priv_table (thd, tables[1].table, Str, proxied_user,
                                     rights & GRANT_ACL ? TRUE : FALSE, 
                                     revoke_grant))
         result= -1;
@@ -5711,8 +5722,8 @@ int open_grant_tables(THD *thd, TABLE_LI
                              C_STRING_WITH_LEN("procs_priv"),
                              "procs_priv", TL_WRITE);
   (tables+5)->init_one_table(C_STRING_WITH_LEN("mysql"),
-                             C_STRING_WITH_LEN("proxy_priv"),
-                             "proxy_priv", TL_WRITE);
+                             C_STRING_WITH_LEN("proxies_priv"),
+                             "proxies_priv", TL_WRITE);
   tables->next_local= tables->next_global= tables + 1;
   (tables+1)->next_local= (tables+1)->next_global= tables + 2;
   (tables+2)->next_local= (tables+2)->next_global= tables + 3;
@@ -6304,7 +6315,7 @@ static int handle_grant_data(TABLE_LIST 
     }
   }
 
-  /* Handle proxy_priv table. */
+  /* Handle proxies_priv table. */
   if ((found= handle_grant_table(tables, 5, drop, user_from, user_to)) < 0)
   {
     /* Handle of table failed, don't touch the in-memory array. */
@@ -6312,7 +6323,7 @@ static int handle_grant_data(TABLE_LIST 
   }
   else
   {
-    /* Handle proxy_priv array. */
+    /* Handle proxies_priv array. */
     if ((handle_grant_struct(5, drop, user_from, user_to) && !result) ||
         found)
       result= 1; /* At least one record/element found. */

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	revid:jimmy.yang@strippedzogf4gq
+++ b/sql/sql_partition.cc	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -2004,7 +2004,7 @@ static int add_part_field_list(File fptr
     String field_string("", 0, system_charset_info);
     THD *thd= current_thd;
     ulonglong save_options= thd->variables.option_bits;
-    thd->variables.option_bits= 0;
+    thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE;
     append_identifier(thd, &field_string, field_str,
                       strlen(field_str));
     thd->variables.option_bits= save_options;
@@ -2023,8 +2023,7 @@ static int add_name_string(File fptr, co
   String name_string("", 0, system_charset_info);
   THD *thd= current_thd;
   ulonglong save_options= thd->variables.option_bits;
-
-  thd->variables.option_bits= 0;
+  thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE;
   append_identifier(thd, &name_string, name,
                     strlen(name));
   thd->variables.option_bits= save_options;

=== modified file 'sql/sql_partition_admin.cc'
--- a/sql/sql_partition_admin.cc	revid:jimmy.yang@strippedv6424yzogf4gq
+++ b/sql/sql_partition_admin.cc	revid:vasil.dimov@stripped
@@ -25,7 +25,9 @@
 #include "debug_sync.h"                     // DEBUG_SYNC
 #include "sql_admin.h"                      // Analyze/Check/.._table_statement
 #include "sql_partition_admin.h"            // Alter_table_*_partition
+#ifdef WITH_PARTITION_STORAGE_ENGINE
 #include "ha_partition.h"                   // ha_partition
+#endif
 #include "sql_base.h"                       // open_and_lock_tables
 
 #ifndef WITH_PARTITION_STORAGE_ENGINE

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	revid:jimmy.yang@stripped
+++ b/sql/sql_plugin.cc	revid:vasil.dimov@stripped4220-zlcp5sg51xgg75x0
@@ -1738,7 +1738,11 @@ bool mysql_install_plugin(THD *thd, cons
   mysql_mutex_lock(&LOCK_plugin);
   mysql_rwlock_wrlock(&LOCK_system_variables_hash);
 
-  my_load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, NULL);
+  if (my_load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, NULL))
+  {
+    report_error(REPORT_TO_USER, ER_PLUGIN_IS_NOT_LOADED, name->str);
+    goto err;
+  }
   error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER);
   if (argv)
     free_defaults(argv);

=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc	revid:jimmy.yang@stripped
+++ b/sql/sql_rename.cc	revid:vasil.dimov@stripped20-zlcp5sg51xgg75x0
@@ -108,7 +108,7 @@ bool mysql_rename_tables(THD *thd, TABLE
             */
             my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), ren_table->table_name,
                      ren_table->table_name);
-            DBUG_RETURN(1);
+            goto err;
           }
         }
         else
@@ -121,7 +121,7 @@ bool mysql_rename_tables(THD *thd, TABLE
             */
             my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), ren_table->table_name,
                      ren_table->table_name);
-            DBUG_RETURN(1);
+            goto err;
           }
           else
           {
@@ -139,7 +139,7 @@ bool mysql_rename_tables(THD *thd, TABLE
       else
         my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), rename_log_table[1],
                  rename_log_table[1]);
-      DBUG_RETURN(1);
+      goto err;
     }
   }
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	revid:jimmy.yang@strippedq
+++ b/sql/sql_select.cc	revid:vasil.dimov@stripped101108144220-zlcp5sg51xgg75x0
@@ -15164,6 +15164,8 @@ calc_group_buffer(JOIN *join,ORDER *grou
         {
           key_length+= 8;
         }
+        else if (type == MYSQL_TYPE_BLOB)
+          key_length+= MAX_BLOB_WIDTH;		// Can't be used as a key
         else
         {
           /*

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	revid:jimmy.yang@stripped6424yzogf4gq
+++ b/sql/sql_show.cc	revid:vasil.dimov@oracle.com-20101108144220-zlcp5sg51xgg75x0
@@ -480,12 +480,6 @@ find_files(THD *thd, List<LEX_STRING> *f
 	else if (wild_compare(uname, wild, 0))
 	  continue;
       }
-      if (!(file_name= 
-            thd->make_lex_string(file_name, uname, file_name_len, TRUE)))
-      {
-        my_dirend(dirp);
-        DBUG_RETURN(FIND_FILES_OOM);
-      }
     }
     else
     {

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	revid:jimmy.yang@strippedm-20101105133317-dvev6424yzogf4gq
+++ b/sql/sql_yacc.yy	revid:vasil.dimov@strippedx0
@@ -12662,6 +12662,7 @@ keyword_sp:
         | FILE_SYM                 {}
         | FIRST_SYM                {}
         | FIXED_SYM                {}
+        | GENERAL                  {}
         | GEOMETRY_SYM             {}
         | GEOMETRYCOLLECTION       {}
         | GET_FORMAT               {}
@@ -12671,6 +12672,7 @@ keyword_sp:
         | HOSTS_SYM                {}
         | HOUR_SYM                 {}
         | IDENTIFIED_SYM           {}
+        | IGNORE_SERVER_IDS_SYM    {}
         | INVOKER_SYM              {}
         | IMPORT                   {}
         | INDEXES                  {}
@@ -12693,6 +12695,7 @@ keyword_sp:
         | LOGS_SYM                 {}
         | MAX_ROWS                 {}
         | MASTER_SYM               {}
+        | MASTER_HEARTBEAT_PERIOD_SYM {}
         | MASTER_HOST_SYM          {}
         | MASTER_PORT_SYM          {}
         | MASTER_LOG_FILE_SYM      {}
@@ -12800,6 +12803,7 @@ keyword_sp:
         | SIMPLE_SYM               {}
         | SHARE_SYM                {}
         | SHUTDOWN                 {}
+        | SLOW                     {}
         | SNAPSHOT_SYM             {}
         | SOUNDS_SYM               {}
         | SOURCE_SYM               {}

=== modified file 'storage/innobase/os/os0sync.c'
--- a/storage/innobase/os/os0sync.c	revid:jimmy.yang@stripped317-dvev6424yzogf4gq
+++ b/storage/innobase/os/os0sync.c	revid:vasil.dimov@stripped5x0
@@ -656,7 +656,7 @@ os_event_wait_time_low(
 						os_event_reset(). */
 
 {
-	ibool		timed_out;
+	ibool		timed_out = FALSE;
 	ib_int64_t	old_signal_count;
 
 #ifdef __WIN__

=== modified file 'storage/ndb/src/mgmsrv/InitConfigFileParser.cpp'
--- a/storage/ndb/src/mgmsrv/InitConfigFileParser.cpp	revid:jimmy.yang@stripped7-dvev6424yzogf4gq
+++ b/storage/ndb/src/mgmsrv/InitConfigFileParser.cpp	revid:vasil.dimov@stripped20-zlcp5sg51xgg75x0
@@ -702,7 +702,7 @@ load_defaults(Vector<struct my_option>& 
   BaseString group_suffix;
 
   const char *save_file = my_defaults_file;
-  char *save_extra_file = my_defaults_extra_file;
+  const char *save_extra_file = my_defaults_extra_file;
   const char *save_group_suffix = my_defaults_group_suffix;
 
   if (my_defaults_file)

=== modified file 'strings/ctype-uca.c'
--- a/strings/ctype-uca.c	revid:jimmy.yang@stripped33317-dvev6424yzogf4gq
+++ b/strings/ctype-uca.c	revid:vasil.dimov@stripped
@@ -21889,40 +21889,6 @@ CHARSET_INFO my_charset_ucs2_vietnamese_
 };
 
 
-CHARSET_INFO my_charset_ucs2_vietnamese_520_ci=
-{
-    152,0,0,             /* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
-    "ucs2",              /* csname       */
-    "ucs2_vietnamese_520_ci",/* name     */
-    "",                  /* comment      */
-    vietnamese,          /* tailoring    */
-    NULL,                /* ctype        */
-    NULL,                /* to_lower     */
-    NULL,                /* to_upper     */
-    NULL,                /* sort_order   */
-    &my_uca_v520,        /* uca          */
-    NULL,                /* tab_to_uni   */
-    NULL,                /* tab_from_uni */
-    &my_unicase_unicode520, /* caseinfo  */
-    NULL,                /* state_map    */
-    NULL,                /* ident_map    */
-    8,                   /* strxfrm_multiply */
-    1,                   /* caseup_multiply  */
-    1,                   /* casedn_multiply  */
-    2,                   /* mbminlen     */
-    2,                   /* mbmaxlen     */
-    9,                   /* min_sort_char */
-    0x10FFFF,            /* max_sort_char */
-    ' ',                 /* pad char      */
-    0,                   /* escape_with_backslash_is_dangerous */
-    1,                   /* levels_for_compare */
-    1,                   /* levels_for_order   */
-    &my_charset_ucs2_handler,
-    &my_collation_ucs2_uca_handler
-};
-
-
 #endif
 
 
@@ -22737,40 +22703,6 @@ CHARSET_INFO my_charset_utf8_vietnamese_
 };
 
 
-CHARSET_INFO my_charset_utf8_vietnamese_520_ci=
-{
-    216,0,0,             /* number       */
-    MY_CS_UTF8MB3_UCA_FLAGS,/* flags     */
-    MY_UTF8MB3,          /* cs name      */
-    MY_UTF8MB3 "_vietnamese_520_ci",/* name  */
-    "",                  /* comment      */
-    vietnamese,          /* tailoring    */
-    ctype_utf8,          /* ctype        */
-    NULL,                /* to_lower     */
-    NULL,                /* to_upper     */
-    NULL,                /* sort_order   */
-    &my_uca_v520,        /* uca          */
-    NULL,                /* tab_to_uni   */
-    NULL,                /* tab_from_uni */
-    &my_unicase_unicode520, /* caseinfo  */
-    NULL,                /* state_map    */
-    NULL,                /* ident_map    */
-    8,                   /* strxfrm_multiply */
-    1,                   /* caseup_multiply  */
-    1,                   /* casedn_multiply  */
-    1,                   /* mbminlen     */
-    3,                   /* mbmaxlen     */
-    9,                   /* min_sort_char */
-    0x10FFFF,            /* max_sort_char */
-    ' ',                 /* pad char      */
-    0,                   /* escape_with_backslash_is_dangerous */
-    1,                   /* levels_for_compare */
-    1,                   /* levels_for_order   */
-    &my_charset_utf8_handler,
-    &my_collation_any_uca_handler
-};
-
-
 #endif /* HAVE_CHARSET_utf8 */
 
 
@@ -23543,40 +23475,6 @@ CHARSET_INFO my_charset_utf8mb4_vietname
 };
 
 
-CHARSET_INFO my_charset_utf8mb4_vietnamese_520_ci=
-{
-    248,0,0,            /* number       */
-    MY_CS_UTF8MB4_UCA_FLAGS,/* state    */
-    MY_UTF8MB4,         /* csname       */
-    MY_UTF8MB4 "_vietnamese_520_ci",/* name */
-    "",                 /* comment      */
-    vietnamese,         /* tailoring    */
-    ctype_utf8,         /* ctype        */
-    NULL,               /* to_lower     */
-    NULL,               /* to_upper     */
-    NULL,               /* sort_order   */
-    &my_uca_v520,       /* uca          */
-    NULL,               /* tab_to_uni   */
-    NULL,               /* tab_from_uni */
-    &my_unicase_unicode520,/* caseinfo  */
-    NULL,               /* state_map    */
-    NULL,               /* ident_map    */
-    8,                  /* strxfrm_multiply */
-    1,                  /* caseup_multiply  */
-    1,                  /* casedn_multiply  */
-    1,                  /* mbminlen      */
-    4,                  /* mbmaxlen      */
-    9,                  /* min_sort_char */
-    0x10FFFF,           /* max_sort_char */
-    ' ',                /* pad char      */
-    0,                  /* escape_with_backslash_is_dangerous */
-    1,                  /* levels_for_compare */
-    1,                  /* levels_for_order   */
-    &my_charset_utf8mb4_handler,
-    &my_collation_any_uca_handler
-};
-
-
 #endif /* HAVE_CHARSET_utf8mb4 */
 
 
@@ -24364,40 +24262,6 @@ CHARSET_INFO my_charset_utf32_vietnamese
 };
 
 
-CHARSET_INFO my_charset_utf32_vietnamese_520_ci=
-{
-    184,0,0,            /* number       */
-    MY_CS_UTF32_UCA_FLAGS,/* state      */
-    "utf32",            /* csname       */
-    "utf32_vietnamese_520_ci",/* name   */
-    "",                 /* comment      */
-    vietnamese,         /* tailoring    */
-    NULL,               /* ctype        */
-    NULL,               /* to_lower     */
-    NULL,               /* to_upper     */
-    NULL,               /* sort_order   */
-    &my_uca_v520,       /* uca          */
-    NULL,               /* tab_to_uni   */
-    NULL,               /* tab_from_uni */
-    &my_unicase_unicode520,/* caseinfo  */
-    NULL,               /* state_map    */
-    NULL,               /* ident_map    */
-    8,                  /* strxfrm_multiply */
-    1,                  /* caseup_multiply  */
-    1,                  /* casedn_multiply  */
-    4,                  /* mbminlen     */
-    4,                  /* mbmaxlen     */
-    9,                  /* min_sort_char */
-    0x10FFFF,           /* max_sort_char */
-    ' ',                /* pad char      */
-    0,                  /* escape_with_backslash_is_dangerous */
-    1,                  /* levels_for_compare */
-    1,                  /* levels_for_order   */
-    &my_charset_utf32_handler,
-    &my_collation_utf32_uca_handler
-};
-
-
 #endif /* HAVE_CHARSET_utf32 */
 
 
@@ -25187,40 +25051,6 @@ CHARSET_INFO my_charset_utf16_vietnamese
 };
 
 
-CHARSET_INFO my_charset_utf16_vietnamese_520_ci=
-{
-    125,0,0,           /* number       */
-    MY_CS_UTF16_UCA_FLAGS,/* state     */
-    "utf16",           /* cs name      */
-    "utf16_vietnamese_520_ci",/* name  */
-    "",                /* comment      */
-    vietnamese,        /* tailoring    */
-    NULL,              /* ctype        */
-    NULL,              /* to_lower     */
-    NULL,              /* to_upper     */
-    NULL,              /* sort_order   */
-    &my_uca_v520,      /* uca          */
-    NULL,              /* tab_to_uni   */
-    NULL,              /* tab_from_uni */
-    &my_unicase_unicode520,/* caseinfo */
-    NULL,              /* state_map    */
-    NULL,              /* ident_map    */
-    8,                 /* strxfrm_multiply */
-    1,                 /* caseup_multiply  */
-    1,                 /* casedn_multiply  */
-    2,                 /* mbminlen     */
-    4,                 /* mbmaxlen     */
-    9,                 /* min_sort_char */
-    0x10FFFF,          /* max_sort_char */
-    ' ',               /* pad char      */
-    0,                 /* escape_with_backslash_is_dangerous */
-    1,                 /* levels_for_compare */
-    1,                 /* levels_for_order   */
-    &my_charset_utf16_handler,
-    &my_collation_utf16_uca_handler
-};
-
-
 #endif /* HAVE_CHARSET_utf16 */
 
 

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	revid:jimmy.yang@stripped-20101105133317-dvev6424yzogf4gq
+++ b/support-files/mysql.spec.sh	revid:vasil.dimov@strippedp5sg51xgg75x0
@@ -977,6 +977,9 @@ echo "====="                            
 %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
@@ -985,6 +988,9 @@ echo "====="                            
 %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
 
 %if %{WITH_TCMALLOC}
 %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target}

=== modified file 'win/README'
--- a/win/README	revid:jimmy.yang@oracle.com-20101105133317-dvev6424yzogf4gq
+++ b/win/README	revid:vasil.dimov@stripped5x0
@@ -10,7 +10,8 @@ or ealier.
 
 The Windows build system uses a tool named CMake to generate build files for
 a variety of project systems.  This tool is combined with a set of jscript
-files to enable building of MySQL for Windows directly out of a bk clone.
+files to enable building of MySQL for Windows directly out of a bzr clone.
+For relevant information, please refer to http://forge.mysql.com/wiki/CMake
 The steps required are below.
 
 Step 1:
@@ -41,56 +42,67 @@ before you start the build)
 
 Step 4
 ------
-Clone your bk tree to any location you like.
+One of the nice CMake features is "out-of-source" build support, which 
+means not building in the source directory, but in dedicated build 
+directory. This keeps the source directory clean and allows for more than 
+single build tree for the same source tree (e.g debug and release, 32 and 
+64 bit etc). We'll create subdirectory "bld" in the source directory for 
+this purpose. Clone your bzr tree to any location you like.
 
 Step 5
 ------
-From the root of your installation directory, execute the command:
+From the root of your installation directory use cmake . -L to see the 
+various configuration parameters.
 
-win\configure <options>
-
-The options right now are:
-
-    WITH_INNOBASE_STORAGE_ENGINE         Enable particular storage engines
-    WITH_PARTITION_STORAGE_ENGINE
-    WITH_ARCHIVE_STORAGE_ENGINE
-    WITH_BLACKHOLE_STORAGE_ENGINE
-    WITH_EXAMPLE_STORAGE_ENGINE
-    WITH_FEDERATED_STORAGE_ENGINE
-    __NT__                               Enable named pipe support
-    WITHOUT_ATOMICS                      Do not use atomic instructions
-    MYSQL_SERVER_SUFFIX=<suffix>         Server suffix, default none
-    COMPILATION_COMMENT=<comment>        Server comment, default "Source distribution"
-    MYSQL_TCP_PORT=<port>                Server port, default 3306
-    CYBOZU                               Default character set is UTF8
-    EMBED_MANIFESTS                      Embed custom manifests into final exes, otherwise VS
-                                         default will be used. (Note - This option should only be
-                                         used by MySQL AB.)
-    WITH_EMBEDDED_SERVER                 Configure solution to produce libmysqld.dll
-                                         and the static mysqlserver.lib 
-                                
 So the command line could look like:
 
-win\configure WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro
+cmake .. -G "target" -DWITH_INNOBASE_STORAGE_ENGINE=1
+
+The recommended way of configuring would be to use -DBUILD_CONFIG=mysql_release
+to build binaries exactly the same as the official MySQL releases. 
 
 Step 6
 ------
 
-From the root of your installation directory/bk clone, execute one of
-the batch files to generate the type of project files you desire.
-
-For Visual Studio 8 (or Visual C++ 2005 express edition), do win\build-vs8.
-For Visual Studio 7.1, do win\build-vs71.
-
-We will support building with nmake in the near future.
-
+From the root of your installation directory/bzr clone, you can
+use cmake to compile the sources.  Use cmake --help when necessary.
+Before you start building the sources, please remove the old build area
+created from an earlier run and start afresh.
+
+C:\> del bld 
+C:\> md bld 
+C:\> cd  bld 
+C:\> cmake .. -G "target name" -DBUILD_CONFIG=mysql_release
+
+
+For Example:
+To generate the Win64 project files using Visual Studio 9, you would run
+cmake .. -G "Visual Studio 9 2008 Win64" 
+
+Other target names supported using CMake 2.6 patch 4 are:
+
+  Visual Studio 7              "Visual Studio 7 .NET 2003"
+  Visual Studio 8              "Visual Studio 8 2005"
+  Visual Studio 8 (64 bit)     "Visual Studio 8 2005 Win64"
+  Visual Studio 9              "Visual Studio 9 2008"
+  Visual Studio 9 (64 bit)     "Visual Studio 9 2008 Win64"
+
+For generating project files using Visual Studio 10, you need CMake 2.8
+or higher and corresponding target names are
+  Visual Studio 10              "Visual Studio 10" 
+  Visual Studio 10 (64 bit)     "Visual Studio 10 Win64" 
+ 
 Step 7
 ------
-From the root of your bk clone, start your build.
+From the root of your bzr clone, start your build.
 
 For Visual Studio, execute mysql.sln.  This will start the IDE
 and you can click the build solution menu option.
 
+Alternatively, you could start the build from command line as follows
+
+devenv mysql.sln /build relwithdebinfo
+ 
 Current issues
 --------------
 1. After changing configuration (eg. adding or removing a storage engine), it

=== removed file 'win/build-nmake-x64.bat'
--- a/win/build-nmake-x64.bat	revid:jimmy.yang@stripped0101105133317-dvev6424yzogf4gq
+++ b/win/build-nmake-x64.bat	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-@echo off
-
-REM Copyright (C) 2006 MySQL AB
-REM 
-REM This program is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; version 2 of the License.
-REM 
-REM This program is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-REM GNU General Public License for more details.
-REM 
-REM You should have received a copy of the GNU General Public License
-REM along with this program; if not, write to the Free Software
-REM Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-if exist cmakecache.txt del cmakecache.txt
-copy win\nmake_x64_cache.txt cmakecache.txt
-cmake -G "NMake Makefiles"
-copy cmakecache.txt win\nmake_x64_cache.txt

=== removed file 'win/build-nmake.bat'
--- a/win/build-nmake.bat	revid:jimmy.yang@stripped
+++ b/win/build-nmake.bat	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-@echo off
-
-REM Copyright (C) 2006 MySQL AB
-REM 
-REM This program is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; version 2 of the License.
-REM 
-REM This program is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-REM GNU General Public License for more details.
-REM 
-REM You should have received a copy of the GNU General Public License
-REM along with this program; if not, write to the Free Software
-REM Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-if exist cmakecache.txt del cmakecache.txt
-copy win\nmake_cache.txt cmakecache.txt
-cmake -G "NMake Makefiles"
-copy cmakecache.txt win\nmake_cache.txt

=== removed file 'win/build-vs71.bat'
--- a/win/build-vs71.bat	revid:jimmy.yang@strippedgf4gq
+++ b/win/build-vs71.bat	1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
-@echo off
-
-REM Copyright (C) 2006 MySQL AB
-REM 
-REM This program is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; version 2 of the License.
-REM 
-REM This program is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-REM GNU General Public License for more details.
-REM 
-REM You should have received a copy of the GNU General Public License
-REM along with this program; if not, write to the Free Software
-REM Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-if exist cmakecache.txt del cmakecache.txt
-copy win\vs71cache.txt cmakecache.txt
-cmake -G "Visual Studio 7 .NET 2003"
-copy cmakecache.txt win\vs71cache.txt
-

=== removed file 'win/build-vs8.bat'
--- a/win/build-vs8.bat	revid:jimmy.yang@stripped17-dvev6424yzogf4gq
+++ b/win/build-vs8.bat	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-@echo off
-
-REM Copyright (C) 2006 MySQL AB
-REM 
-REM This program is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; version 2 of the License.
-REM 
-REM This program is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-REM GNU General Public License for more details.
-REM 
-REM You should have received a copy of the GNU General Public License
-REM along with this program; if not, write to the Free Software
-REM Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-if exist cmakecache.txt del cmakecache.txt
-copy win\vs8cache.txt cmakecache.txt
-cmake -G "Visual Studio 8 2005"
-copy cmakecache.txt win\vs8cache.txt

=== removed file 'win/build-vs8_x64.bat'
--- a/win/build-vs8_x64.bat	revid:jimmy.yang@stripped20101105133317-dvev6424yzogf4gq
+++ b/win/build-vs8_x64.bat	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-@echo off
-
-REM Copyright (C) 2006 MySQL AB
-REM 
-REM This program is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; version 2 of the License.
-REM 
-REM This program is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-REM GNU General Public License for more details.
-REM 
-REM You should have received a copy of the GNU General Public License
-REM along with this program; if not, write to the Free Software
-REM Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-if exist cmakecache.txt del cmakecache.txt
-copy win\vs8cache.txt cmakecache.txt
-cmake -G "Visual Studio 8 2005 Win64"
-copy cmakecache.txt win\vs8cache.txt

=== removed file 'win/build-vs9.bat'
--- a/win/build-vs9.bat	revid:jimmy.yang@stripped
+++ b/win/build-vs9.bat	1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
-@echo off
-
-REM Copyright (C) 2006 MySQL AB
-REM 
-REM This program is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; version 2 of the License.
-REM 
-REM This program is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-REM GNU General Public License for more details.
-REM 
-REM You should have received a copy of the GNU General Public License
-REM along with this program; if not, write to the Free Software
-REM Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-cmake -G "Visual Studio 9 2008"
-

=== removed file 'win/build-vs9_x64.bat'
--- a/win/build-vs9_x64.bat	revid:jimmy.yang@stripped
+++ b/win/build-vs9_x64.bat	1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
-@echo off
-
-REM Copyright (C) 2006 MySQL AB
-REM 
-REM This program is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; version 2 of the License.
-REM 
-REM This program is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-REM GNU General Public License for more details.
-REM 
-REM You should have received a copy of the GNU General Public License
-REM along with this program; if not, write to the Free Software
-REM Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-cmake -G "Visual Studio 9 2008 Win64"
-

No bundle (reason: revision is a merge).
Thread
bzr commit into mysql-trunk-innodb branch (vasil.dimov:3314) vasil.dimov8 Nov