List:Commits« Previous MessageNext Message »
From:kevin.lewis Date:March 27 2012 12:20pm
Subject:bzr push into mysql-trunk branch (kevin.lewis:3824 to 3826)
View as plain text  
 3826 kevin.lewis@stripped	2012-03-27
      Improve portability code

    modified:
      mysql-test/suite/innodb/r/innodb-restart.result
      mysql-test/suite/innodb/r/innodb-tablespace.result
      mysql-test/suite/innodb/t/innodb-restart.test
      mysql-test/suite/innodb/t/innodb-tablespace.test
      storage/innobase/dict/dict0crea.cc
      storage/innobase/dict/dict0load.cc
      storage/innobase/fil/fil0fil.cc
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/include/dict0crea.h
      storage/innobase/include/dict0load.h
      storage/innobase/include/fil0fil.h
      storage/innobase/row/row0mysql.cc
 3825 kevin.lewis@stripped	2012-03-26 [merge]
      merge

    added:
      BUILD/README
      mysql-test/suite/binlog/r/binlog_row_query_log_events.result
      mysql-test/suite/binlog/t/binlog_row_query_log_events.test
    renamed:
      mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.cnf => mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli-slave.opt
    modified:
      BUILD/compile-pentium
      BUILD/compile-pentium-debug
      BUILD/compile-pentium-debug-max
      BUILD/compile-pentium-debug-max-no-ndb
      BUILD/compile-pentium-gcov
      BUILD/compile-pentium-gprof
      BUILD/compile-pentium-valgrind-max
      BUILD/compile-pentium-valgrind-max-no-ndb
      BUILD/compile-pentium64
      INSTALL-SOURCE
      INSTALL-WIN-SOURCE
      cmake/make_dist.cmake.in
      cmake/mysql_version.cmake
      cmake/package_name.cmake
      cmake/ssl.cmake
      include/my_md5.h
      mysql-test/collections/default.experimental
      mysql-test/collections/default.weekly
      mysql-test/collections/disabled-per-push.list
      mysql-test/include/subquery_mat.inc
      mysql-test/include/subquery_sj.inc
      mysql-test/r/lowercase_table2.result
      mysql-test/r/subquery_mat.result
      mysql-test/r/subquery_mat_all.result
      mysql-test/r/subquery_mat_none.result
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_bka.result
      mysql-test/r/subquery_sj_all_bka_nixbnl.result
      mysql-test/r/subquery_sj_all_bkaunique.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_bka.result
      mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
      mysql-test/r/subquery_sj_dupsweed_bkaunique.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_bka.result
      mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
      mysql-test/r/subquery_sj_firstmatch_bkaunique.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_bka.result
      mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
      mysql-test/r/subquery_sj_loosescan_bkaunique.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_bka.result
      mysql-test/r/subquery_sj_mat_bka_nixbnl.result
      mysql-test/r/subquery_sj_mat_bkaunique.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_bka.result
      mysql-test/r/subquery_sj_none_bka_nixbnl.result
      mysql-test/r/subquery_sj_none_bkaunique.result
      mysql-test/suite/engines/funcs/t/se_string_having.test
      mysql-test/suite/engines/funcs/t/ta_add_column.test
      mysql-test/suite/engines/funcs/t/ta_add_column_first.test
      mysql-test/suite/engines/funcs/t/ta_add_column_middle.test
      mysql-test/suite/engines/funcs/t/tc_multicolumn_different.test
      mysql-test/suite/funcs_2/t/innodb_charset.test
      mysql-test/suite/innodb/include/innodb_stats.inc
      mysql-test/suite/innodb/r/innodb-index-online-purge.result
      mysql-test/suite/innodb/r/innodb-index-online.result
      mysql-test/suite/innodb/r/innodb_stats.result
      mysql-test/suite/innodb/t/disabled.def
      mysql-test/suite/innodb/t/innodb-index-online-purge.test
      mysql-test/suite/innodb/t/innodb-index-online.test
      mysql-test/suite/innodb/t/innodb_bug11766634.test
      mysql-test/suite/innodb/t/innodb_mysql.test
      mysql-test/suite/parts/t/partition_alter1_1_innodb.test
      mysql-test/suite/parts/t/partition_alter2_2_1_innodb.test
      mysql-test/suite/parts/t/partition_basic_innodb.test
      mysql-test/suite/parts/t/partition_decimal_myisam.test
      mysql-test/suite/parts/t/partition_int_myisam.test
      mysql-test/suite/rpl/r/rpl_skip_ddl_errors_cli.result
      mysql-test/suite/rpl/t/rpl_alter_repository.test
      mysql-test/suite/rpl/t/rpl_gtid_parallel.test
      mysql-test/suite/rpl/t/rpl_gtid_stress_failover.test
      mysql-test/suite/rpl/t/rpl_mixed_mixing_engines.test
      mysql-test/suite/rpl/t/rpl_mixed_mts_crash_safe.test
      mysql-test/suite/rpl/t/rpl_mixed_mts_rec_crash_safe.test
      mysql-test/suite/rpl/t/rpl_mixed_mts_rec_crash_safe_checksum.test
      mysql-test/suite/rpl/t/rpl_non_direct_mixed_mixing_engines.test
      mysql-test/suite/rpl/t/rpl_non_direct_row_mixing_engines.test
      mysql-test/suite/rpl/t/rpl_non_direct_stm_mixing_engines.test
      mysql-test/suite/rpl/t/rpl_row_mixing_engines.test
      mysql-test/suite/rpl/t/rpl_row_mts_crash_safe.test
      mysql-test/suite/rpl/t/rpl_row_mts_rec_crash_safe.test
      mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
      mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.test
      mysql-test/suite/rpl/t/rpl_stm_mixed_crash_safe.test
      mysql-test/suite/rpl/t/rpl_stm_mixing_engines.test
      mysql-test/suite/rpl/t/rpl_stm_mts_crash_safe.test
      mysql-test/suite/rpl/t/rpl_stm_mts_rec_crash_safe.test
      mysql-test/t/lowercase_table2.test
      sql/item_subselect.cc
      sql/log_event.cc
      sql/md5.cc
      sql/rpl_slave.cc
      sql/rpl_slave.h
      sql/sql_executor.cc
      sql/sql_table.cc
      sql/sql_view.cc
      storage/innobase/btr/btr0btr.cc
      storage/innobase/btr/btr0cur.cc
      storage/innobase/buf/buf0lru.cc
      storage/innobase/dict/dict0stats.cc
      storage/innobase/fil/fil0fil.cc
      storage/innobase/handler/handler0alter.cc
      storage/innobase/include/btr0btr.h
      storage/innobase/include/buf0lru.h
      storage/innobase/include/buf0types.h
      storage/innobase/include/fil0fil.h
      storage/innobase/row/row0mysql.cc
      support-files/CMakeLists.txt
      support-files/build-tags
      mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli-slave.opt
 3824 kevin.lewis@stripped	2012-03-22
      local commit for 5980

    added:
      mysql-test/r/partition_innodb_tablespace.result
      mysql-test/suite/innodb/r/innodb-tablespace.result
      mysql-test/suite/innodb/t/innodb-tablespace.test
      mysql-test/t/partition_innodb_tablespace.test
    modified:
      storage/innobase/dict/dict0load.cc
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/ha_innodb.h
      storage/innobase/include/dict0load.h
=== added file 'BUILD/README'
--- a/BUILD/README	1970-01-01 00:00:00 +0000
+++ b/BUILD/README	revid:kevin.lewis@stripped
@@ -0,0 +1,38 @@
+This directory used to contain lots of build scripts for building
+MySQL on various platforms. They are mostly gone, use cmake instead.
+
+Some scripts have been kept for backward compatibility (other scripts
+depend on them). Others have been kept to illustrate how to enable
+gcov or gprof, or explicitly selecting 64bit architecture.  If you
+want to use these scripts for building, you may want to speed things
+up a bit by setting environment variable MAKEFLAGS="-j8"
+(or some other number/flag depending on your environment)
+
+The recommended way to build MySQL for developers:
+
+cd <some build directory>
+cmake <path to source directory>
+make
+
+This will give you a release build, with compiler options taken from
+../cmake/build_configurations/compiler_options.cmake
+and "feature set" taken from
+../cmake/build_configurations/feature_set.cmake
+
+Adding -DWITH_DEBUG=1 to the cmake command line gives you a debug build.
+
+
+Building on Windows is slightly different:
+cd <some build directory>
+cmake <path to source directonry>
+
+devenv MySQL.sln /build Debug
+or
+devenv MySQL.sln /build RelWithDebInfo
+
+
+If you have special needs, you can disable the defaults by setting
+these cmake variables off:
+
+WITH_DEFAULT_COMPILER_OPTIONS
+WITH_DEFAULT_FEATURE_SET

=== modified file 'BUILD/compile-pentium'
--- a/BUILD/compile-pentium	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium	revid:kevin.lewis@stripped
@@ -17,4 +17,4 @@
 
 path=`dirname $0`
 cmake $path/.. -DWITH_DEBUG=0
-gmake -j 4
+make

=== modified file 'BUILD/compile-pentium-debug'
--- a/BUILD/compile-pentium-debug	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium-debug	revid:kevin.lewis@stripped
@@ -17,4 +17,4 @@
 
 path=`dirname $0`
 cmake $path/.. -DWITH_DEBUG=1
-gmake -j 4
+make

=== modified file 'BUILD/compile-pentium-debug-max'
--- a/BUILD/compile-pentium-debug-max	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium-debug-max	revid:kevin.lewis@stripped
@@ -17,4 +17,4 @@
 
 path=`dirname $0`
 cmake $path/.. -DWITH_DEBUG=1
-gmake -j 4
+make

=== modified file 'BUILD/compile-pentium-debug-max-no-ndb'
--- a/BUILD/compile-pentium-debug-max-no-ndb	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium-debug-max-no-ndb	revid:kevin.lewis@stripped
@@ -17,4 +17,4 @@
 
 path=`dirname $0`
 cmake $path/.. -DWITH_DEBUG=1 -DWITH_NDBCLUSTER=0
-gmake -j 4
+make

=== modified file 'BUILD/compile-pentium-gcov'
--- a/BUILD/compile-pentium-gcov	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium-gcov	revid:kevin.lewis@stripped
@@ -17,4 +17,4 @@
 
 path=`dirname $0`
 cmake $path/.. -DWITH_DEBUG=1 -DENABLE_GCOV=ON 
-gmake -j 4
+make

=== modified file 'BUILD/compile-pentium-gprof'
--- a/BUILD/compile-pentium-gprof	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium-gprof	revid:kevin.lewis@stripped
@@ -17,4 +17,4 @@
 
 path=`dirname $0`
 cmake $path/.. -DWITH_DEBUG=0 -DENABLE_GPROF=ON 
-gmake -j 4
+make

=== modified file 'BUILD/compile-pentium-valgrind-max'
--- a/BUILD/compile-pentium-valgrind-max	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium-valgrind-max	revid:kevin.lewis@stripped
@@ -19,5 +19,6 @@
 # -DHAVE_purify : activates misc. ifdefs in the source code
 
 path=`dirname $0`
-cmake $path/.. -DWITH_DEBUG=1 -DWITH_VALGRIND=1 -DCMAKE_CXX_FLAGS=-DHAVE_purify
-gmake -j 4
+cmake $path/.. -DWITH_DEBUG=1 -DWITH_VALGRIND=1 \
+    -DCMAKE_C_FLAGS=-DHAVE_purify -DCMAKE_CXX_FLAGS=-DHAVE_purify
+make

=== modified file 'BUILD/compile-pentium-valgrind-max-no-ndb'
--- a/BUILD/compile-pentium-valgrind-max-no-ndb	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium-valgrind-max-no-ndb	revid:kevin.lewis@stripped
@@ -18,7 +18,7 @@
 # MA 02111-1307, USA
 
 path=`dirname $0`
-cmake $path/.. -DWITH_DEBUG=1 \
-     -DWITH_VALGRIND=1 -DCMAKE_CXX_FLAGS=-DHAVE_purify \
-     -DWITH_NDBCLUSTER=0
-gmake -j 4
+cmake $path/.. -DWITH_DEBUG=1 -DWITH_VALGRIND=1 \
+    -DCMAKE_C_FLAGS=-DHAVE_purify -DCMAKE_CXX_FLAGS=-DHAVE_purify \
+    -DWITH_NDBCLUSTER=0
+make

=== modified file 'BUILD/compile-pentium64'
--- a/BUILD/compile-pentium64	revid:kevin.lewis@stripped
+++ b/BUILD/compile-pentium64	revid:kevin.lewis@stripped
@@ -19,4 +19,4 @@
 
 path=`dirname $0`
 cmake $path/.. -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_C_FLAGS=-m64 
-gmake -j 4
+make

=== modified file 'INSTALL-SOURCE'
--- a/INSTALL-SOURCE	revid:kevin.lewis@stripped
+++ b/INSTALL-SOURCE	revid:kevin.lewis@stripped
@@ -1,7 +1,7 @@
 
 You can find information about how to install from a source distributions at
 
-  http://dev.mysql.com/doc/refman/5.1/en/installing-source.html
+  http://dev.mysql.com/doc/refman/5.5/en/source-installation.html
 
 The MySQL Reference Manual is also available in various formats on
 http://dev.mysql.com/doc; if you're interested in the DocBook XML

=== modified file 'INSTALL-WIN-SOURCE'
--- a/INSTALL-WIN-SOURCE	revid:kevin.lewis@stripped
+++ b/INSTALL-WIN-SOURCE	revid:kevin.lewis@stripped
@@ -2,7 +2,7 @@
 You can find information about how to install from a Windows source
 distributions at
 
-  http://dev.mysql.com/doc/refman/5.1/en/windows-source-build.html
+  http://dev.mysql.com/doc/refman/5.5/en/source-installation.html
 
 The MySQL Reference Manual is also available in various formats on
 http://dev.mysql.com/doc; if you're interested in the DocBook XML

=== modified file 'cmake/make_dist.cmake.in'
--- a/cmake/make_dist.cmake.in	revid:kevin.lewis@stripped
+++ b/cmake/make_dist.cmake.in	revid:kevin.lewis@stripped
@@ -120,8 +120,13 @@ CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/s
    ${PACKAGE_DIR}/sql/sql_yacc.cc COPYONLY)
 
 # Copy spec files
-CONFIGURE_FILE(${CMAKE_BINARY_DIR}/support-files/mysql.${VERSION}.spec
-   ${PACKAGE_DIR}/support-files/mysql.${VERSION}.spec COPYONLY)
+SET(SPECFILENAME "mysql.${VERSION}.spec")
+IF("${VERSION}" MATCHES "-ndb-")
+  STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+  SET(SPECFILENAME "mysql-cluster-${NDBVERSION}.spec")
+ENDIF()
+CONFIGURE_FILE(${CMAKE_BINARY_DIR}/support-files/${SPECFILENAME}
+   ${PACKAGE_DIR}/support-files/${SPECFILENAME} COPYONLY)
 
 # Add documentation, if user has specified where to find them
 IF(MYSQL_DOCS_LOCATION)

=== modified file 'cmake/mysql_version.cmake'
--- a/cmake/mysql_version.cmake	revid:kevin.lewis@stripped
+++ b/cmake/mysql_version.cmake	revid:kevin.lewis@stripped
@@ -57,7 +57,10 @@ MACRO(GET_MYSQL_VERSION)
   MESSAGE("-- MySQL ${VERSION}")
   SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
   SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
-  STRING(REPLACE "-" "_" MYSQL_RPM_VERSION "${VERSION}")
+  # Use NDBVERSION irregardless of whether this is Cluster or not, if not
+  # then the regex will be ignored anyway.
+  STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+  STRING(REPLACE "-" "_" MYSQL_RPM_VERSION "${NDBVERSION}")
   MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH_VERSION}")
   MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION)
   SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
@@ -93,6 +96,10 @@ ENDIF()
 
 IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME)
   SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-${VERSION}")
+  IF("${VERSION}" MATCHES "-ndb-")
+    STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+    SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-cluster-gpl-${NDBVERSION}")
+  ENDIF()
 ENDIF()
 SET(CPACK_PACKAGE_CONTACT "MySQL Release Engineering <mysql-build@stripped>")
 SET(CPACK_PACKAGE_VENDOR "Oracle Corporation")

=== modified file 'cmake/package_name.cmake'
--- a/cmake/package_name.cmake	revid:kevin.lewis@stripped
+++ b/cmake/package_name.cmake	revid:kevin.lewis@stripped
@@ -115,8 +115,15 @@ IF(NOT VERSION)
     SET(PRODUCT_TAG)
   ENDIF()
 
-  SET(package_name "mysql${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
-  
+  IF("${VERSION}" MATCHES "-ndb-")
+    STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+    SET(package_name "mysql-cluster${PRODUCT_TAG}-${NDBVERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
+  ELSE()
+    SET(package_name "mysql${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
+  ENDIF()
+
+  MESSAGE("-- Packaging as: ${package_name}")
+
   # Sometimes package suffix is added (something like "-icc-glibc23")
   IF(PACKAGE_SUFFIX)
     SET(package_name "${package_name}${PACKAGE_SUFFIX}")

=== modified file 'cmake/ssl.cmake'
--- a/cmake/ssl.cmake	revid:kevin.lewis@stripped
+++ b/cmake/ssl.cmake	revid:kevin.lewis@stripped
@@ -25,7 +25,7 @@ MACRO (MYSQL_USE_BUNDLED_SSL)
   SET(SSL_LIBRARIES  yassl taocrypt)
   SET(SSL_INCLUDE_DIRS ${INC_DIRS})
   SET(SSL_INTERNAL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
-  SET(SSL_DEFINES "-DHAVE_YASSL -DYASSL_PURE_C -DYASSL_PREFIX -DHAVE_OPENSSL -DYASSL_THREAD_SAFE")
+  SET(SSL_DEFINES "-DHAVE_YASSL -DYASSL_PREFIX -DHAVE_OPENSSL -DYASSL_THREAD_SAFE")
   CHANGE_SSL_SETTINGS("bundled")
   ADD_SUBDIRECTORY(extra/yassl)
   ADD_SUBDIRECTORY(extra/yassl/taocrypt)

=== modified file 'include/my_md5.h'
--- a/include/my_md5.h	revid:kevin.lewis@stripped
+++ b/include/my_md5.h	revid:kevin.lewis@stripped
@@ -29,11 +29,16 @@
 
 #if defined(HAVE_YASSL)
 
-C_MODE_START
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 void my_md5_hash(char *digest, const char *buf, int len);
 
-C_MODE_END
+#ifdef __cplusplus
+}
+#endif
+
 
 #else /* HAVE_YASSL */
 
@@ -65,7 +70,9 @@ typedef struct {
   unsigned char in[64];
 } my_MD5Context;
 
-C_MODE_START
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 void my_MD5Init (my_MD5Context *context);
 void my_MD5Update (my_MD5Context *context,
@@ -73,7 +80,10 @@ void my_MD5Update (my_MD5Context *contex
 void my_MD5Final (unsigned char digest[16],
                   my_MD5Context *context);
 
-C_MODE_END
+#ifdef __cplusplus
+}
+#endif
+
 
 #define MY_MD5_HASH(digest,buf,len) \
 do { \
@@ -85,10 +95,14 @@ do { \
 
 #endif /* defined(HAVE_YASSL) || defined(HAVE_OPENSSL) */
 
-C_MODE_START
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 void compute_md5_hash(char *digest, const char *buf, int len);
 
-C_MODE_END
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* MY_MD5_INCLUDED */

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	revid:kevin.lewis@stripped
+++ b/mysql-test/collections/default.experimental	revid:kevin.lewis@stripped
@@ -24,6 +24,7 @@ rpl.rpl_seconds_behind_master           
 rpl.rpl_show_slave_running               # BUG#12346048 2011-04-11 sven fails sporadically on pb2
 rpl.rpl_parallel_switch_sequential       # BUG#13626976 2012-02-07 dlenev Fails sporadically on pb2
 rpl.rpl_report_port                      # BUG#13812374 2012-03-22 Hemant Fails after the post fix for bug#13812374 
+rpl.rpl_gtid_stress_failover             # BUG#11938382,BUG#13779291 2012-03-26 Nuno Fails sporadically on pb2 (see also BUG#13813811)
 
 sys_vars.max_sp_recursion_depth_func @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
 
@@ -38,3 +39,7 @@ rpl.rpl_mixed_mts_rec_crash_safe @solari
 rpl.rpl_mixed_mts_rec_crash_safe_checksum @solaris # Bug#12902514 2011-08-19 andrei same as rpl_mixed_mts_rec_crash_safe
 rpl.rpl_mixed_mts_crash_safe @solaris              # Bug#12902514 2011-08-19 andrei same as rpl_mixed_mts_rec_crash_safe
 
+
+# All memcached tests are failing. This could be setup issues on PB2
+# Making experimental until the problems are resolved
+memcached.*

=== modified file 'mysql-test/collections/default.weekly'
--- a/mysql-test/collections/default.weekly	revid:kevin.lewis@stripped
+++ b/mysql-test/collections/default.weekly	revid:kevin.lewis@stripped
@@ -28,9 +28,10 @@ perl mysql-test-run.pl --force --timer -
 
 
 # Additional  replication configurations
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=all_binlog_checksum-debug --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum-debug --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay-debug --vardir=var-rpl_crash_safe_relay-debug --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_master-debug --vardir=var-rpl_crash_safe_master-debug --suite=rpl --mysqld=--master-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 --parallel=auto --comment=all_binlog_checksum-debug --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum-debug --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --debug-server --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay-debug --vardir=var-rpl_crash_safe_relay-debug --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --debug-server --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_master-debug --vardir=var-rpl_crash_safe_master-debug --suite=rpl --mysqld=--master-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --debug-server --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog-debug-big --vardir=rpl_binlog-debug-big --suite=rpl --skip-test-list=collections/disabled-daily.list
 
 
 #Engine independent tests
@@ -64,9 +65,9 @@ perl mysql-test-run.pl --force --timer -
 
 
 # Additional  replication configurations
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=all_binlog_checksum --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-weekly.list
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay --vardir=var-rpl_crash_safe_relay --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
-perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_master --vardir=var-rpl_crash_safe_master --suite=rpl --mysqld=--master-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 --parallel=auto --comment=all_binlog_checksum --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-weekly.list
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_relay --vardir=var-rpl_crash_safe_relay --suite=rpl --mysqld=--relay-log-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
+perl mysql-test-run.pl --force --timer --big-test --testcase-timeout=60 --parallel=auto --experimental=collections/default.experimental --comment=rpl_crash_safe_master --vardir=var-rpl_crash_safe_master --suite=rpl --mysqld=--master-info-repository=TABLE --skip-test-list=collections/disabled-daily.list
 
 #Engine independent tests
 perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 --parallel=auto  --comment=eits-tests-myisam-engine-big --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine-big --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam  --skip-test-list=collections/disabled-weekly.list
@@ -77,7 +78,7 @@ perl mysql-test-run.pl --timer --force -
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-mixed-tests-innodb-engine --experimental=collections/default.experimental --vardir=var-binlog-mixed-eits-tests-innodb-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=innodb --mysqld=--innodb --do-test=rpl --mysqld=--binlog-format=mixed --skip-test-list=collections/disabled-weekly.list
 
 # Multi-Thread Slave
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix-MTS --vardir=var-mts-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list --unit-tests --mysqld=--slave-parallel-workers=4 --mysqld=--slave-transaction-retries=0
+perl mysql-test-run.pl --timer --force --big-test --testcase-timeout=60 --debug-server --parallel=auto --comment=n_mix-MTS-debug-big --vardir=var-n_mix-MTS-debug-big --suite=rpl --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list --unit-tests --mysqld=--slave-parallel-workers=4 --mysqld=--slave-transaction-retries=0
 
 # Run with 4K page size
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix_4k_size --vardir=var-n_mix_4k_size --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list --unit-tests --mysqld=--innodb-page-size=4k --skip-test=innodb_ignore_builtin

=== modified file 'mysql-test/collections/disabled-per-push.list'
--- a/mysql-test/collections/disabled-per-push.list	revid:kevin.lewis@stripped
+++ b/mysql-test/collections/disabled-per-push.list	revid:kevin.lewis@stripped
@@ -65,7 +65,6 @@ rpl.rpl_mixed_binlog_max_cache_size : ls
 rpl.rpl_mixed_bit_pk : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_mixed_ddl_dml : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_mixed_implicit_commit_binlog : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
-rpl.rpl_mixed_mixing_engines : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_mixed_row_innodb : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_mix_found_rows : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_multi_delete2 : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
@@ -78,9 +77,6 @@ rpl.rpl_multi_update : lsoares 2010-05-2
 rpl.rpl_mysql_upgrade : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_name_const : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_nondeterministic_functions : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
-rpl.rpl_non_direct_mixed_mixing_engines : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
-rpl.rpl_non_direct_row_mixing_engines : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
-rpl.rpl_non_direct_stm_mixing_engines : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_not_null_myisam : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_optimize : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_ps : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
@@ -106,7 +102,6 @@ rpl.rpl_row_implicit_commit_binlog : lso
 rpl.rpl_row_inexist_tbl : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_row_loaddata_concurrent : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_row_max_relay_size : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
-rpl.rpl_row_mixing_engines : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_row_reset_slave : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_row_show_relaylog_events : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_row_sp001 : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
@@ -160,7 +155,6 @@ rpl.rpl_stm_loaddata_concurrent : lsoare
 rpl.rpl_stm_loadfile : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_stm_log : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_stm_max_relay_size : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
-rpl.rpl_stm_mixing_engines : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_stm_mix_show_relaylog_events : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_stm_multi_query : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.
 rpl.rpl_stm_no_op : lsoares 2010-05-26 WL#5408  Reduce Pushbuild2 turnaround times for rpl suite.

=== modified file 'mysql-test/include/subquery_mat.inc'
--- a/mysql-test/include/subquery_mat.inc	revid:kevin.lewis@stripped
+++ b/mysql-test/include/subquery_mat.inc	revid:kevin.lewis@stripped
@@ -1384,4 +1384,33 @@ eval $query;
 
 DROP TABLE t1, t2;
 
+--echo #
+--echo # Bug#13838501 ASSERTION `TABLE->FILE->INITED' FAILED IN
+--echo # SUBSELECT_HASH_SJ_ENGINE::EXEC
+--echo #
+
+CREATE TABLE t1
+(c1 bigint,c2 char,pk INT,c3 char,c4 int,c5 INT,key (c5))
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (763078661862588416,0,1,'',1,'');
+CREATE TABLE t2 (c4k int,c4 int,cminnuk INT,key (cminnuk)) ENGINE=InnoDB;
+INSERT INTO t2 VALUES(0,'','');
+CREATE TABLE t3
+(c4 int,pk INT,c1 bigint,cyk year,cy year,key (cyk))
+ENGINE=InnoDB;
+INSERT INTO t3 VALUES(0,8,'',0,'');
+let $query=
+SELECT o.c2 AS x FROM t1 AS o
+WHERE o.c1 IN
+       (SELECT innr.c4 AS y
+        FROM t2 AS innr2 JOIN t3 AS innr
+             ON (innr2.c4k=innr.c4)
+        WHERE innr.c1=6 OR NOT innr.c1=innr.pk
+        ORDER BY innr.c4)
+      AND o.c4=7 XOR o.pk=3 ORDER BY o.pk;
+eval EXPLAIN $query;
+eval $query;
+
+DROP TABLE t1,t2,t3;
+
 --echo # End of 5.6 tests

=== modified file 'mysql-test/include/subquery_sj.inc'
--- a/mysql-test/include/subquery_sj.inc	revid:kevin.lewis@stripped
+++ b/mysql-test/include/subquery_sj.inc	revid:kevin.lewis@stripped
@@ -4916,4 +4916,39 @@ eval $query;
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
 
+--echo #
+--echo # BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+--echo #               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+--echo #
+
+CREATE TABLE t1 (
+  col_int_key INT,
+  col_varchar_key VARCHAR(1),
+  KEY col_int_key (col_int_key),
+  KEY col_varchar_key (col_varchar_key)
+);
+
+INSERT INTO t1 VALUES (8,'x');
+
+CREATE TABLE t2 (
+  col_varchar_key VARCHAR(1),
+  KEY col_varchar_key (col_varchar_key)
+);
+
+INSERT INTO t2 VALUES ('x'), ('y');
+
+let $query= SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+  SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+  FROM t1 as t1_inner JOIN t2
+    ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+
+
+--eval explain $query
+--eval $query
+
+DROP TABLE t1,t2;
+
 --echo # End of 5.6 tests

=== modified file 'mysql-test/r/lowercase_table2.result'
--- a/mysql-test/r/lowercase_table2.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/lowercase_table2.result	revid:kevin.lewis@stripped
@@ -277,3 +277,16 @@ ERROR HY000: Can't find file: 't_bug4473
 flush tables;
 create table t_bug44738_UPPERCASE (i int);
 drop table t_bug44738_UPPERCASE;
+# BUG#13702397 - 64211: 'CREATE TABLE ... LIKE ...'
+#                       FAILS TO KEEP CASE
+#
+CREATE TABLE TestTable1 (a int);
+SHOW TABLES;
+Tables_in_test
+TestTable1
+CREATE TABLE TestTable2 LIKE TestTable1;
+SHOW TABLES;
+Tables_in_test
+TestTable1
+TestTable2
+DROP TABLE TestTable1, TestTable2;

=== modified file 'mysql-test/r/subquery_mat.result'
--- a/mysql-test/r/subquery_mat.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_mat.result	revid:kevin.lewis@stripped
@@ -1819,5 +1819,49 @@ HAVING x = '2000-09-09'
 ORDER BY col_time_key;
 x
 DROP TABLE t1, t2;
+#
+# Bug#13838501 ASSERTION `TABLE->FILE->INITED' FAILED IN
+# SUBSELECT_HASH_SJ_ENGINE::EXEC
+#
+CREATE TABLE t1
+(c1 bigint,c2 char,pk INT,c3 char,c4 int,c5 INT,key (c5))
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (763078661862588416,0,1,'',1,'');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c5' at row 1
+CREATE TABLE t2 (c4k int,c4 int,cminnuk INT,key (cminnuk)) ENGINE=InnoDB;
+INSERT INTO t2 VALUES(0,'','');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c4' at row 1
+Warning	1366	Incorrect integer value: '' for column 'cminnuk' at row 1
+CREATE TABLE t3
+(c4 int,pk INT,c1 bigint,cyk year,cy year,key (cyk))
+ENGINE=InnoDB;
+INSERT INTO t3 VALUES(0,8,'',0,'');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c1' at row 1
+Warning	1366	Incorrect integer value: '' for column 'cy' at row 1
+EXPLAIN SELECT o.c2 AS x FROM t1 AS o
+WHERE o.c1 IN
+(SELECT innr.c4 AS y
+FROM t2 AS innr2 JOIN t3 AS innr
+ON (innr2.c4k=innr.c4)
+WHERE innr.c1=6 OR NOT innr.c1=innr.pk
+ORDER BY innr.c4)
+AND o.c4=7 XOR o.pk=3 ORDER BY o.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	o	ALL	NULL	NULL	NULL	NULL	1	Using where; Using filesort
+2	SUBQUERY	innr2	ALL	NULL	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	innr	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
+SELECT o.c2 AS x FROM t1 AS o
+WHERE o.c1 IN
+(SELECT innr.c4 AS y
+FROM t2 AS innr2 JOIN t3 AS innr
+ON (innr2.c4k=innr.c4)
+WHERE innr.c1=6 OR NOT innr.c1=innr.pk
+ORDER BY innr.c4)
+AND o.c4=7 XOR o.pk=3 ORDER BY o.pk;
+x
+DROP TABLE t1,t2,t3;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_mat_all.result'
--- a/mysql-test/r/subquery_mat_all.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_mat_all.result	revid:kevin.lewis@stripped
@@ -1818,5 +1818,49 @@ HAVING x = '2000-09-09'
 ORDER BY col_time_key;
 x
 DROP TABLE t1, t2;
+#
+# Bug#13838501 ASSERTION `TABLE->FILE->INITED' FAILED IN
+# SUBSELECT_HASH_SJ_ENGINE::EXEC
+#
+CREATE TABLE t1
+(c1 bigint,c2 char,pk INT,c3 char,c4 int,c5 INT,key (c5))
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (763078661862588416,0,1,'',1,'');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c5' at row 1
+CREATE TABLE t2 (c4k int,c4 int,cminnuk INT,key (cminnuk)) ENGINE=InnoDB;
+INSERT INTO t2 VALUES(0,'','');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c4' at row 1
+Warning	1366	Incorrect integer value: '' for column 'cminnuk' at row 1
+CREATE TABLE t3
+(c4 int,pk INT,c1 bigint,cyk year,cy year,key (cyk))
+ENGINE=InnoDB;
+INSERT INTO t3 VALUES(0,8,'',0,'');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c1' at row 1
+Warning	1366	Incorrect integer value: '' for column 'cy' at row 1
+EXPLAIN SELECT o.c2 AS x FROM t1 AS o
+WHERE o.c1 IN
+(SELECT innr.c4 AS y
+FROM t2 AS innr2 JOIN t3 AS innr
+ON (innr2.c4k=innr.c4)
+WHERE innr.c1=6 OR NOT innr.c1=innr.pk
+ORDER BY innr.c4)
+AND o.c4=7 XOR o.pk=3 ORDER BY o.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	o	ALL	NULL	NULL	NULL	NULL	1	Using where; Using filesort
+2	SUBQUERY	innr2	ALL	NULL	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	innr	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
+SELECT o.c2 AS x FROM t1 AS o
+WHERE o.c1 IN
+(SELECT innr.c4 AS y
+FROM t2 AS innr2 JOIN t3 AS innr
+ON (innr2.c4k=innr.c4)
+WHERE innr.c1=6 OR NOT innr.c1=innr.pk
+ORDER BY innr.c4)
+AND o.c4=7 XOR o.pk=3 ORDER BY o.pk;
+x
+DROP TABLE t1,t2,t3;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_mat_none.result'
--- a/mysql-test/r/subquery_mat_none.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_mat_none.result	revid:kevin.lewis@stripped
@@ -1816,5 +1816,49 @@ HAVING x = '2000-09-09'
 ORDER BY col_time_key;
 x
 DROP TABLE t1, t2;
+#
+# Bug#13838501 ASSERTION `TABLE->FILE->INITED' FAILED IN
+# SUBSELECT_HASH_SJ_ENGINE::EXEC
+#
+CREATE TABLE t1
+(c1 bigint,c2 char,pk INT,c3 char,c4 int,c5 INT,key (c5))
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (763078661862588416,0,1,'',1,'');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c5' at row 1
+CREATE TABLE t2 (c4k int,c4 int,cminnuk INT,key (cminnuk)) ENGINE=InnoDB;
+INSERT INTO t2 VALUES(0,'','');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c4' at row 1
+Warning	1366	Incorrect integer value: '' for column 'cminnuk' at row 1
+CREATE TABLE t3
+(c4 int,pk INT,c1 bigint,cyk year,cy year,key (cyk))
+ENGINE=InnoDB;
+INSERT INTO t3 VALUES(0,8,'',0,'');
+Warnings:
+Warning	1366	Incorrect integer value: '' for column 'c1' at row 1
+Warning	1366	Incorrect integer value: '' for column 'cy' at row 1
+EXPLAIN SELECT o.c2 AS x FROM t1 AS o
+WHERE o.c1 IN
+(SELECT innr.c4 AS y
+FROM t2 AS innr2 JOIN t3 AS innr
+ON (innr2.c4k=innr.c4)
+WHERE innr.c1=6 OR NOT innr.c1=innr.pk
+ORDER BY innr.c4)
+AND o.c4=7 XOR o.pk=3 ORDER BY o.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	o	ALL	NULL	NULL	NULL	NULL	1	Using where; Using filesort
+2	DEPENDENT SUBQUERY	innr2	ALL	NULL	NULL	NULL	NULL	1	Using where
+2	DEPENDENT SUBQUERY	innr	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
+SELECT o.c2 AS x FROM t1 AS o
+WHERE o.c1 IN
+(SELECT innr.c4 AS y
+FROM t2 AS innr2 JOIN t3 AS innr
+ON (innr2.c4k=innr.c4)
+WHERE innr.c1=6 OR NOT innr.c1=innr.pk
+ORDER BY innr.c4)
+AND o.c4=7 XOR o.pk=3 ORDER BY o.pk;
+x
+DROP TABLE t1,t2,t3;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all.result'
--- a/mysql-test/r/subquery_sj_all.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_all.result	revid:kevin.lewis@stripped
@@ -8060,5 +8060,41 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all_bka.result'
--- a/mysql-test/r/subquery_sj_all_bka.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_all_bka.result	revid:kevin.lewis@stripped
@@ -8065,6 +8065,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_all_bka_nixbnl.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_all_bka_nixbnl.result	revid:kevin.lewis@stripped
@@ -8066,6 +8066,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all_bkaunique.result'
--- a/mysql-test/r/subquery_sj_all_bkaunique.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_all_bkaunique.result	revid:kevin.lewis@stripped
@@ -8066,6 +8066,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed.result'
--- a/mysql-test/r/subquery_sj_dupsweed.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_dupsweed.result	revid:kevin.lewis@stripped
@@ -8044,5 +8044,41 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_bka.result'
--- a/mysql-test/r/subquery_sj_dupsweed_bka.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_dupsweed_bka.result	revid:kevin.lewis@stripped
@@ -8045,6 +8045,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result	revid:kevin.lewis@stripped
@@ -8053,6 +8053,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_bkaunique.result'
--- a/mysql-test/r/subquery_sj_dupsweed_bkaunique.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_dupsweed_bkaunique.result	revid:kevin.lewis@stripped
@@ -8046,6 +8046,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_firstmatch.result'
--- a/mysql-test/r/subquery_sj_firstmatch.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_firstmatch.result	revid:kevin.lewis@stripped
@@ -8043,6 +8043,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 #
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for

=== modified file 'mysql-test/r/subquery_sj_firstmatch_bka.result'
--- a/mysql-test/r/subquery_sj_firstmatch_bka.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_firstmatch_bka.result	revid:kevin.lewis@stripped
@@ -8044,6 +8044,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 #
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for

=== modified file 'mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result	revid:kevin.lewis@stripped
@@ -8052,6 +8052,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 #
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for

=== modified file 'mysql-test/r/subquery_sj_firstmatch_bkaunique.result'
--- a/mysql-test/r/subquery_sj_firstmatch_bkaunique.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_firstmatch_bkaunique.result	revid:kevin.lewis@stripped
@@ -8045,6 +8045,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 #
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for

=== modified file 'mysql-test/r/subquery_sj_loosescan.result'
--- a/mysql-test/r/subquery_sj_loosescan.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_loosescan.result	revid:kevin.lewis@stripped
@@ -8045,5 +8045,41 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_loosescan_bka.result'
--- a/mysql-test/r/subquery_sj_loosescan_bka.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_loosescan_bka.result	revid:kevin.lewis@stripped
@@ -8046,6 +8046,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result	revid:kevin.lewis@stripped
@@ -8054,6 +8054,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_loosescan_bkaunique.result'
--- a/mysql-test/r/subquery_sj_loosescan_bkaunique.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_loosescan_bkaunique.result	revid:kevin.lewis@stripped
@@ -8047,6 +8047,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat.result'
--- a/mysql-test/r/subquery_sj_mat.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_mat.result	revid:kevin.lewis@stripped
@@ -8058,5 +8058,41 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_bka.result'
--- a/mysql-test/r/subquery_sj_mat_bka.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_mat_bka.result	revid:kevin.lewis@stripped
@@ -8059,6 +8059,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_mat_bka_nixbnl.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_mat_bka_nixbnl.result	revid:kevin.lewis@stripped
@@ -8060,6 +8060,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_bkaunique.result'
--- a/mysql-test/r/subquery_sj_mat_bkaunique.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_mat_bkaunique.result	revid:kevin.lewis@stripped
@@ -8060,6 +8060,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_nosj.result'
--- a/mysql-test/r/subquery_sj_mat_nosj.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_mat_nosj.result	revid:kevin.lewis@stripped
@@ -8126,5 +8126,41 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none.result'
--- a/mysql-test/r/subquery_sj_none.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_none.result	revid:kevin.lewis@stripped
@@ -8041,5 +8041,41 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none_bka.result'
--- a/mysql-test/r/subquery_sj_none_bka.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_none_bka.result	revid:kevin.lewis@stripped
@@ -8042,6 +8042,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_none_bka_nixbnl.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_none_bka_nixbnl.result	revid:kevin.lewis@stripped
@@ -8042,6 +8042,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none_bkaunique.result'
--- a/mysql-test/r/subquery_sj_none_bkaunique.result	revid:kevin.lewis@stripped
+++ b/mysql-test/r/subquery_sj_none_bkaunique.result	revid:kevin.lewis@stripped
@@ -8043,6 +8043,42 @@ col_datetime_key
 2008-09-27 00:34:58
 DROP TABLE t1,t2;
 SET @@optimizer_search_depth=@old_depth;
+#
+# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 
+#               SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN
+#
+CREATE TABLE t1 (
+col_int_key INT,
+col_varchar_key VARCHAR(1),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t1 VALUES (8,'x');
+CREATE TABLE t2 (
+col_varchar_key VARCHAR(1),
+KEY col_varchar_key (col_varchar_key)
+);
+INSERT INTO t2 VALUES ('x'), ('y');
+explain SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DEPENDENT SUBQUERY	t1_inner	system	col_varchar_key	NULL	NULL	NULL	1	NULL
+2	DEPENDENT SUBQUERY	t2	ref	col_varchar_key	col_varchar_key	4	const	1	Using index
+SELECT MIN(col_int_key)
+FROM t1 as t1_outer
+HAVING (1, 2) IN (
+SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key)
+FROM t1 as t1_inner JOIN t2
+ON t2.col_varchar_key = t1_inner.col_varchar_key
+);
+MIN(col_int_key)
+DROP TABLE t1,t2;
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== added file 'mysql-test/suite/binlog/r/binlog_row_query_log_events.result'
--- a/mysql-test/suite/binlog/r/binlog_row_query_log_events.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_query_log_events.result	revid:kevin.lewis@stripped
@@ -0,0 +1,5 @@
+SET @@SESSION.BINLOG_ROWS_QUERY_LOG_EVENTS = 1;
+CREATE TABLE t1 (a VARCHAR(256));
+INSERT INTO t1 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+include/assert.inc [Logged query must match the one issued.]
+DROP TABLE t1;

=== added file 'mysql-test/suite/binlog/t/binlog_row_query_log_events.test'
--- a/mysql-test/suite/binlog/t/binlog_row_query_log_events.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_row_query_log_events.test	revid:kevin.lewis@stripped
@@ -0,0 +1,23 @@
+--source include/have_binlog_format_row.inc
+
+#######################################################################
+# BUG#13799489: ROWS_QUERY_LOG_EVENTS CORRUPTED IF QUERY LONGER THAN 255 BYTES
+#
+# Check that queries with more than 255 characters are not truncated
+# when stored on Rows_query_log_events.
+SET @@SESSION.BINLOG_ROWS_QUERY_LOG_EVENTS = 1;
+CREATE TABLE t1 (a VARCHAR(256));
+
+--let $as= `SELECT REPEAT('a', 256)`
+--let $query= INSERT INTO t1 VALUES ('$as')
+
+--let $assert_text= Logged query must match the one issued.
+--let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1)
+--let $binlog_position= query_get_value("SHOW MASTER STATUS", Position, 1)
+--eval $query
+--let $logged_query= query_get_value(SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_position, Info, 2)
+--let $assert_cond= `SELECT "$logged_query" LIKE "%$query"`
+--source include/assert.inc
+
+# Clean up
+DROP TABLE t1;

=== modified file 'mysql-test/suite/engines/funcs/t/se_string_having.test'
--- a/mysql-test/suite/engines/funcs/t/se_string_having.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/engines/funcs/t/se_string_having.test	revid:kevin.lewis@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/ta_add_column.test'
--- a/mysql-test/suite/engines/funcs/t/ta_add_column.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/engines/funcs/t/ta_add_column.test	revid:kevin.lewis@stripped
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
+
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/ta_add_column_first.test'
--- a/mysql-test/suite/engines/funcs/t/ta_add_column_first.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/engines/funcs/t/ta_add_column_first.test	revid:kevin.lewis@stripped
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
+
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/ta_add_column_middle.test'
--- a/mysql-test/suite/engines/funcs/t/ta_add_column_middle.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/engines/funcs/t/ta_add_column_middle.test	revid:kevin.lewis@stripped
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
+
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/tc_multicolumn_different.test'
--- a/mysql-test/suite/engines/funcs/t/tc_multicolumn_different.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/engines/funcs/t/tc_multicolumn_different.test	revid:kevin.lewis@stripped
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
+
 --disable_warnings
 DROP TABLE IF EXISTS m3;
 --enable_warnings

=== modified file 'mysql-test/suite/funcs_2/t/innodb_charset.test'
--- a/mysql-test/suite/funcs_2/t/innodb_charset.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/funcs_2/t/innodb_charset.test	revid:kevin.lewis@stripped
@@ -5,6 +5,8 @@
 #                                                                              #
 # Checking of other prerequisites is in charset_master.test                    #
 ################################################################################
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
 
 --source include/have_innodb.inc
 

=== modified file 'mysql-test/suite/innodb/include/innodb_stats.inc'
--- a/mysql-test/suite/innodb/include/innodb_stats.inc	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/include/innodb_stats.inc	revid:kevin.lewis@stripped
@@ -1,4 +1,4 @@
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 
 -- eval $insert
 

=== modified file 'mysql-test/suite/innodb/r/innodb-index-online-purge.result'
--- a/mysql-test/suite/innodb/r/innodb-index-online-purge.result	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/r/innodb-index-online-purge.result	revid:kevin.lewis@stripped
@@ -1,4 +1,3 @@
-SET DEBUG='+d,debug_sync_abort_on_timeout';
 CREATE TABLE t (a INT PRIMARY KEY, c TEXT) ENGINE=InnoDB;
 CREATE TABLE u (a INT PRIMARY KEY, b INT, c INT NOT NULL) ENGINE=InnoDB;
 INSERT INTO t VALUES (1,'aa');
@@ -16,7 +15,6 @@ INSERT INTO u SELECT a+256,NULL,a+64 FRO
 COMMIT;
 BEGIN;
 DELETE FROM u;
-SET DEBUG='+d,debug_sync_abort_on_timeout';
 SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u';
 ALTER TABLE u ADD INDEX (c);
 COMMIT;
@@ -25,7 +23,6 @@ SELECT state FROM information_schema.pro
 WHERE info='ALTER TABLE u ADD INDEX (c)';
 state
 debug sync point: row_log_apply_before
-SET DEBUG='+d,debug_sync_abort_on_timeout';
 SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t';
 CREATE INDEX c1 ON t (c(1));
 SET DEBUG_SYNC='now WAIT_FOR created_t';
@@ -36,5 +33,4 @@ SLEEP(10)
 SET DEBUG_SYNC='now SIGNAL dml_done_u';
 SET DEBUG_SYNC='now SIGNAL dml_done_t';
 SET DEBUG_SYNC='RESET';
-SET DEBUG='-d,debug_sync_abort_on_timeout';
 DROP TABLE t,u;

=== modified file 'mysql-test/suite/innodb/r/innodb-index-online.result'
--- a/mysql-test/suite/innodb/r/innodb-index-online.result	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/r/innodb-index-online.result	revid:kevin.lewis@stripped
@@ -1,7 +1,8 @@
+SET GLOBAL DEBUG='d,query,debug_sync_exec:i:t:A,ds.trace';
+SET DEBUG='d,query,debug_sync_exec,debug_sync_abort_on_timeout:i:t:A,ds.trace';
 call mtr.add_suppression("InnoDB: Warning: Small buffer pool size");
 call mtr.add_suppression("Cannot find index .*c2 in InnoDB index translation table");
 call mtr.add_suppression("Find index .*c2 in InnoDB index list but not its MySQL index number");
-SET DEBUG='+d,debug_sync_abort_on_timeout';
 CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 INT) ENGINE=InnoDB;
 INSERT INTO t1 VALUES (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
 SET GLOBAL innodb_monitor_enable=module_ddl;
@@ -11,9 +12,10 @@ ddl_background_drop_indexes	0
 ddl_background_drop_tables	0
 ddl_online_create_index	0
 ddl_pending_alter_table	0
+SET DEBUG_SYNC='RESET';
 SET DEBUG_SYNC='write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead';
 INSERT INTO t1 VALUES(1,2,3);
-SET DEBUG='+d,debug_sync_abort_on_timeout';
+SET DEBUG='d,query,debug_sync_exec,debug_sync_abort_on_timeout:i:t:A,ds.trace';
 SET DEBUG_SYNC='now WAIT_FOR have_handle';
 SET lock_wait_timeout=1;
 ALTER TABLE t1 ADD UNIQUE INDEX(c2);
@@ -253,8 +255,9 @@ CHECK TABLE t1;
 Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 SET DEBUG_SYNC='RESET';
-SET DEBUG='-d,debug_sync_abort_on_timeout';
+SET DEBUG='';
 SET GLOBAL innodb_monitor_disable=module_ddl;
 DROP TABLE t1;
+SET GLOBAL DEBUG='';
 SET GLOBAL innodb_monitor_enable=default;
 SET GLOBAL innodb_monitor_disable=default;

=== modified file 'mysql-test/suite/innodb/r/innodb-restart.result'
--- a/mysql-test/suite/innodb/r/innodb-restart.result	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/r/innodb-restart.result	revid:kevin.lewis@stripped
@@ -307,4 +307,26 @@ t55	CREATE TABLE `t55` (
   `c5` text,
   PRIMARY KEY (`c1`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1000000024 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/'
+# Move the remote tablespace to a new location and change the ISL file
+# Restart the server
+SELECT path FROM information_schema.innodb_sys_datafiles;
+path
+MYSQL_TMP_DIR/new_dir/test/t55.ibd
+INSERT INTO t55 (SELECT 0, c2, c3, c4, c5 FROM t55);
+SELECT count(*) FROM t55;
+count(*)
+16
+SHOW CREATE TABLE t55;
+Table	Create Table
+t55	CREATE TABLE `t55` (
+  `c1` double NOT NULL AUTO_INCREMENT,
+  `c2` char(10) DEFAULT NULL,
+  `c3` varchar(100) DEFAULT NULL,
+  `c4` date DEFAULT NULL,
+  `c5` text,
+  PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=1000000024 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/new_dir/'
 DROP TABLE t55;
+#
+# Cleanup
+#

=== modified file 'mysql-test/suite/innodb/r/innodb-tablespace.result'
--- a/mysql-test/suite/innodb/r/innodb-tablespace.result	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/r/innodb-tablespace.result	revid:kevin.lewis@stripped
@@ -63,10 +63,10 @@ SET GLOBAL innodb_file_per_table=ON;
 CREATE TABLE t1 (a int KEY, b text) DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data';
 SHOW WARNINGS;
 Level	Code	Message
-INSERT INTO t1 VALUES (1, "blue");
+INSERT INTO t1 VALUES (1, "Create the tablespace");
 SELECT * FROM t1;
 a	b
-1	blue
+1	Create the tablespace
 # Check if tablespace file exists where we specified in DATA DIRECTORY
 # Check if link file exists  in MYSQLD_DATADIR
 # Check that DATA DIRECTORY shows up in the SHOW CREATE TABLE results.
@@ -101,10 +101,10 @@ SELECT path FROM information_schema.inno
 path
 # Create the same table a second time in the same place
 CREATE TABLE t1 (a int KEY, b text) DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data';
-INSERT INTO t1 VALUES (1, "blue");
+INSERT INTO t1 VALUES (2, "Create the same table a second time in the same place");
 SELECT * FROM t1;
 a	b
-1	blue
+2	Create the same table a second time in the same place
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -125,10 +125,10 @@ path
 MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
 # Truncate the table, then insert and verify
 TRUNCATE TABLE t1;
-INSERT INTO t1 VALUES (2, "red");
+INSERT INTO t1 VALUES (3, "Truncate the table, then insert");
 SELECT * FROM t1;
 a	b
-2	red
+3	Truncate the table, then insert
 SELECT name,n_cols,file_format,row_format
 FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
 name	n_cols	file_format	row_format
@@ -142,11 +142,11 @@ path
 MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
 # Rename the table, then insert and verify
 RENAME TABLE t1 TO t2;
-INSERT INTO t2 VALUES (3, "green");
+INSERT INTO t2 VALUES (4, "Rename the table, then insert");
 SELECT * FROM t2;
 a	b
-2	red
-3	green
+3	Truncate the table, then insert
+4	Rename the table, then insert
 SELECT name,n_cols,file_format,row_format
 FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
 name	n_cols	file_format	row_format
@@ -160,10 +160,10 @@ path
 MYSQL_TMP_DIR/alternate_dir/data/test/t2.ibd
 # CREATE TABLE LIKE does not retain DATA DIRECTORY automatically.
 CREATE TABLE t3 LIKE t2;
-INSERT INTO t3 VALUES (4, "black");
+INSERT INTO t3 VALUES (5, "CREATE TABLE LIKE");
 SELECT * FROM t3;
 a	b
-4	black
+5	CREATE TABLE LIKE
 SELECT name,n_cols,file_format,row_format
 FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
 name	n_cols	file_format	row_format
@@ -200,7 +200,7 @@ Warning	1618	<DATA DIRECTORY> option ign
 SHOW WARNINGS;
 Level	Code	Message
 Warning	1618	<DATA DIRECTORY> option ignored
-INSERT INTO t1 VALUES (1, "blue");
+INSERT INTO t1 VALUES (6, "SQL MODE NO_DIR_IN_CREATE prevents DATA DIRECTORY");
 DROP TABLE t1;
 set @@sql_mode=@org_mode;
 # MySQL engine does not allow DATA DIRECTORY to be
@@ -232,36 +232,16 @@ t1	CREATE TEMPORARY TABLE `t1` (
   PRIMARY KEY (`a`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
 DROP TABLE t1;
-# Test discard/import of InnoDB tables.
-CREATE TABLE t1 (a int KEY, b text) DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data';
-INSERT INTO t1 VALUES (1, "blue");
-SELECT * FROM t1;
-a	b
-1	blue
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) NOT NULL,
-  `b` text,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data/'
-SELECT name,n_cols,file_format,row_format
-FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
-name	n_cols	file_format	row_format
-test/t1	5	Antelope	Compact
-SELECT name,file_format,row_format
-FROM information_schema.innodb_sys_tablespaces;
-name	file_format	row_format
-test/t1	Antelope	Compact or Redundant
-SELECT path FROM information_schema.innodb_sys_datafiles;
-path
-MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
-# Make a backup copy of the tablespace.
-# Discard the tablespace.
-ALTER TABLE t1 DISCARD TABLESPACE;
+# Create the remote table via static DDL statements in a stored procedure
+CREATE PROCEDURE static_proc() BEGIN CREATE TABLE t1 (a int KEY, b text) DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data'; END |
+CALL static_proc;
 SELECT path FROM information_schema.innodb_sys_datafiles;
 path
 MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+INSERT INTO t1 VALUES (7, "Create the remote table via static DDL statements");
+SELECT * FROM t1;
+a	b
+7	Create the remote table via static DDL statements
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -269,17 +249,18 @@ t1	CREATE TABLE `t1` (
   `b` text,
   PRIMARY KEY (`a`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data/'
-# Restore the backup.
-# Import the tablespace.
-ALTER TABLE t1 IMPORT TABLESPACE;
+DROP PROCEDURE static_proc;
+DROP TABLE t1;
+# Create the remote table via dynamic DDL statements in a stored procedure
+CREATE PROCEDURE dynamic_proc() BEGIN PREPARE stmt1 FROM "CREATE TABLE t1 (a int KEY, b text) DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data'"; EXECUTE stmt1; END |
+CALL dynamic_proc;
 SELECT path FROM information_schema.innodb_sys_datafiles;
 path
 MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
-INSERT INTO t1 VALUES (2, "red");
+INSERT INTO t1 VALUES (8, "Create the remote table via dynamic DDL statements");
 SELECT * FROM t1;
 a	b
-1	blue
-2	red
+8	Create the remote table via dynamic DDL statements
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -287,6 +268,7 @@ t1	CREATE TABLE `t1` (
   `b` text,
   PRIMARY KEY (`a`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data/'
+DROP PROCEDURE dynamic_proc;
 DROP TABLE t1;
 #
 # Cleanup

=== modified file 'mysql-test/suite/innodb/r/innodb_stats.result'
--- a/mysql-test/suite/innodb/r/innodb_stats.result	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/r/innodb_stats.result	revid:kevin.lewis@stripped
@@ -1,4 +1,4 @@
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 SELECT 'dummy INSERT, the table should be empty';
 dummy INSERT, the table should be empty
 dummy INSERT, the table should be empty
@@ -52,7 +52,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text
@@ -104,7 +104,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1), (1);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text
@@ -156,7 +156,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1), (1), (1);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text
@@ -208,7 +208,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1), (1);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text
@@ -260,7 +260,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1), (2);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text
@@ -312,7 +312,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1), (1), (2);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text
@@ -364,7 +364,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1), (2), (3);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text
@@ -416,7 +416,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1), (1), (2), (3), (3);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text
@@ -468,7 +468,7 @@ NULLABLE	YES
 INDEX_TYPE	BTREE
 COMMENT	
 INDEX_COMMENT	
-DELETE FROM test_innodb_stats;
+TRUNCATE TABLE test_innodb_stats;
 INSERT INTO test_innodb_stats (a) VALUES (1), (2), (3), (4), (5), (1), (2), (3), (4), (5);
 ANALYZE TABLE test_innodb_stats;
 Table	Op	Msg_type	Msg_text

=== modified file 'mysql-test/suite/innodb/t/disabled.def'
--- a/mysql-test/suite/innodb/t/disabled.def	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/disabled.def	revid:kevin.lewis@stripped
@@ -9,5 +9,3 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-innodb-index-online         : Bug#13875241 2012-03-22 Hemant Test started failing after Marko push on couple of platforms including Valgrind
-innodb-index-online-purge         : Bug#13875241 2012-03-22 Hemant Test started failing after Marko push on couple of platforms including Valgrind

=== modified file 'mysql-test/suite/innodb/t/innodb-index-online-purge.test'
--- a/mysql-test/suite/innodb/t/innodb-index-online-purge.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/innodb-index-online-purge.test	revid:kevin.lewis@stripped
@@ -1,12 +1,9 @@
 --source include/have_innodb.inc
---source include/have_debug.inc
 --source include/have_debug_sync.inc
 
 # Save the initial number of concurrent sessions.
 --source include/count_sessions.inc
 
-SET DEBUG='+d,debug_sync_abort_on_timeout';
-
 connect (con1,localhost,root,,);
 
 connect (con2,localhost,root,,);
@@ -33,7 +30,6 @@ BEGIN;
 DELETE FROM u;
 
 connection con2;
-SET DEBUG='+d,debug_sync_abort_on_timeout';
 SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u';
 --send
 ALTER TABLE u ADD INDEX (c);
@@ -52,7 +48,6 @@ SELECT state FROM information_schema.pro
 WHERE info='ALTER TABLE u ADD INDEX (c)';
 
 connection con1;
-SET DEBUG='+d,debug_sync_abort_on_timeout';
 SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t';
 --send
 CREATE INDEX c1 ON t (c(1));
@@ -62,16 +57,15 @@ UPDATE t SET c='ab';
 # Allow purge to kick in. TODO: Trigger this faster, somehow.
 SELECT SLEEP(10);
 SET DEBUG_SYNC='now SIGNAL dml_done_u';
-SET DEBUG_SYNC='now SIGNAL dml_done_t';
 connection con2;
 reap;
+SET DEBUG_SYNC='now SIGNAL dml_done_t';
 disconnect con2;
 connection con1;
 reap;
 disconnect con1;
 connection default;
 SET DEBUG_SYNC='RESET';
-SET DEBUG='-d,debug_sync_abort_on_timeout';
 DROP TABLE t,u;
 
 # Check that all connections opened by test cases in this file are really

=== modified file 'mysql-test/suite/innodb/t/innodb-index-online.test'
--- a/mysql-test/suite/innodb/t/innodb-index-online.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/innodb-index-online.test	revid:kevin.lewis@stripped
@@ -1,6 +1,10 @@
 --source include/have_innodb.inc
---source include/have_debug.inc
 --source include/have_debug_sync.inc
+# Temporarily prohibit Valgrind runs until Bug#13875241 is resolved
+--source include/not_valgrind.inc
+
+SET GLOBAL DEBUG='d,query,debug_sync_exec:i:t:A,ds.trace';
+SET DEBUG='d,query,debug_sync_exec,debug_sync_abort_on_timeout:i:t:A,ds.trace';
 
 call mtr.add_suppression("InnoDB: Warning: Small buffer pool size");
 # These will be triggered by INSERT INTO t1 VALUES(6,3,1);
@@ -10,21 +14,20 @@ call mtr.add_suppression("Find index .*c
 # Save the initial number of concurrent sessions.
 --source include/count_sessions.inc
 
-SET DEBUG='+d,debug_sync_abort_on_timeout';
-
 CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 INT) ENGINE=InnoDB;
 INSERT INTO t1 VALUES (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
 
 SET GLOBAL innodb_monitor_enable=module_ddl;
 SELECT name,count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem='ddl';
 
+SET DEBUG_SYNC='RESET';
 SET DEBUG_SYNC='write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead';
 -- send
 INSERT INTO t1 VALUES(1,2,3);
 
 connect (con1,localhost,root,,);
 connection con1;
-SET DEBUG='+d,debug_sync_abort_on_timeout';
+SET DEBUG='d,query,debug_sync_exec,debug_sync_abort_on_timeout:i:t:A,ds.trace';
 
 # This should block at the end because of the INSERT in connection default
 # is holding a metadata lock.
@@ -256,7 +259,7 @@ disconnect con1;
 connection default;
 
 SET DEBUG_SYNC='RESET';
-SET DEBUG='-d,debug_sync_abort_on_timeout';
+SET DEBUG='';
 SET GLOBAL innodb_monitor_disable=module_ddl;
 
 DROP TABLE t1;
@@ -265,6 +268,7 @@ DROP TABLE t1;
 # gone so execution of other tests won't be affected by their presence.
 --source include/wait_until_count_sessions.inc
 
+SET GLOBAL DEBUG='';
 -- disable_warnings
 SET GLOBAL innodb_monitor_enable=default;
 SET GLOBAL innodb_monitor_disable=default;

=== modified file 'mysql-test/suite/innodb/t/innodb-restart.test'
--- a/mysql-test/suite/innodb/t/innodb-restart.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/innodb-restart.test	revid:kevin.lewis@stripped
@@ -134,6 +134,9 @@ INSERT INTO t5 (SELECT 0, c2, c3, c4, c5
 SELECT count(*) FROM t5;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SHOW CREATE TABLE t5;
+--file_exists $MYSQLD_DATADIR/test/t5.frm
+--file_exists $MYSQLD_DATADIR/test/t5.isl
+--file_exists $MYSQL_TMP_DIR/alternate_dir/test/t5.ibd
 
 -- echo # Restart the server
 -- source include/restart_mysqld.inc
@@ -145,6 +148,9 @@ INSERT INTO t5 (SELECT 0, c2, c3, c4, c5
 SELECT count(*) FROM t5;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SHOW CREATE TABLE t5;
+--file_exists $MYSQLD_DATADIR/test/t5.frm
+--file_exists $MYSQLD_DATADIR/test/t5.isl
+--file_exists $MYSQL_TMP_DIR/alternate_dir/test/t5.ibd
 
 -- echo # Rename file table and tablespace, then restart
 RENAME TABLE t5 TO t55;
@@ -155,6 +161,9 @@ INSERT INTO t55 (SELECT 0, c2, c3, c4, c
 SELECT count(*) FROM t55;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SHOW CREATE TABLE t55;
+--file_exists $MYSQLD_DATADIR/test/t55.frm
+--file_exists $MYSQLD_DATADIR/test/t55.isl
+--file_exists $MYSQL_TMP_DIR/alternate_dir/test/t55.ibd
 
 -- echo # Restart the server
 -- source include/restart_mysqld.inc
@@ -166,8 +175,39 @@ INSERT INTO t55 (SELECT 0, c2, c3, c4, c
 SELECT count(*) FROM t55;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SHOW CREATE TABLE t55;
+--file_exists $MYSQLD_DATADIR/test/t55.frm
+--file_exists $MYSQLD_DATADIR/test/t55.isl
+--file_exists $MYSQL_TMP_DIR/alternate_dir/test/t55.ibd
+
+-- echo # Move the remote tablespace to a new location and change the ISL file
+--mkdir $MYSQL_TMP_DIR/new_dir
+--mkdir $MYSQL_TMP_DIR/new_dir/test
+--copy_file $MYSQL_TMP_DIR/alternate_dir/test/t55.ibd $MYSQL_TMP_DIR/new_dir/test/t55.ibd
+--remove_file $MYSQLD_DATADIR/test/t55.isl
+--exec echo $MYSQL_TMP_DIR/new_dir/test/t55.ibd > $MYSQLD_DATADIR/test/t55.isl
+
+-- echo # Restart the server
+-- source include/restart_mysqld.inc
+
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles;
+INSERT INTO t55 (SELECT 0, c2, c3, c4, c5 FROM t55);
+SELECT count(*) FROM t55;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t55;
+--file_exists $MYSQLD_DATADIR/test/t55.frm
+--file_exists $MYSQLD_DATADIR/test/t55.isl
+--file_exists $MYSQL_TMP_DIR/new_dir/test/t55.ibd
+--file_exists $MYSQL_TMP_DIR/alternate_dir/test/t55.ibd
+--remove_file $MYSQL_TMP_DIR/alternate_dir/test/t55.ibd
+--error 1
+--file_exists $MYSQL_TMP_DIR/alternate_dir/test/t55.ibd
 DROP TABLE t55;
 
+--echo #
+--echo # Cleanup
+--echo #
+
 --rmdir $MYSQL_TMP_DIR/alternate_dir/test
 --rmdir $MYSQL_TMP_DIR/alternate_dir
 

=== modified file 'mysql-test/suite/innodb/t/innodb-tablespace.test'
--- a/mysql-test/suite/innodb/t/innodb-tablespace.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/innodb-tablespace.test	revid:kevin.lewis@stripped
@@ -61,7 +61,7 @@ SET GLOBAL innodb_file_per_table=ON;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 eval CREATE TABLE t1 (a int KEY, b text) $data_directory;
 SHOW WARNINGS;
-INSERT INTO t1 VALUES (1, "blue");
+INSERT INTO t1 VALUES (1, "Create the tablespace");
 SELECT * FROM t1;
 
 --echo # Check if tablespace file exists where we specified in DATA DIRECTORY
@@ -94,7 +94,7 @@ SELECT path FROM information_schema.inno
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 eval CREATE TABLE t1 (a int KEY, b text) $data_directory;
 
-INSERT INTO t1 VALUES (1, "blue");
+INSERT INTO t1 VALUES (2, "Create the same table a second time in the same place");
 SELECT * FROM t1;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SHOW CREATE TABLE t1;
@@ -111,7 +111,7 @@ SELECT path FROM information_schema.inno
 
 --echo # Truncate the table, then insert and verify
 TRUNCATE TABLE t1;
-INSERT INTO t1 VALUES (2, "red");
+INSERT INTO t1 VALUES (3, "Truncate the table, then insert");
 SELECT * FROM t1;
 SELECT name,n_cols,file_format,row_format
        FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
@@ -124,7 +124,7 @@ SELECT path FROM information_schema.inno
 
 --echo # Rename the table, then insert and verify
 RENAME TABLE t1 TO t2;
-INSERT INTO t2 VALUES (3, "green");
+INSERT INTO t2 VALUES (4, "Rename the table, then insert");
 SELECT * FROM t2;
 SELECT name,n_cols,file_format,row_format
        FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
@@ -139,7 +139,7 @@ SELECT path FROM information_schema.inno
 
 --echo # CREATE TABLE LIKE does not retain DATA DIRECTORY automatically.
 CREATE TABLE t3 LIKE t2;
-INSERT INTO t3 VALUES (4, "black");
+INSERT INTO t3 VALUES (5, "CREATE TABLE LIKE");
 SELECT * FROM t3;
 SELECT name,n_cols,file_format,row_format
        FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
@@ -176,7 +176,7 @@ SELECT @@sql_mode;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 eval CREATE TABLE t1 (a int, b text) $data_directory;
 SHOW WARNINGS;
-INSERT INTO t1 VALUES (1, "blue");
+INSERT INTO t1 VALUES (6, "SQL MODE NO_DIR_IN_CREATE prevents DATA DIRECTORY");
 # Checking if tablespace exists in --datadir since DATA DIRECTORY was ignored.
 --file_exists $MYSQLD_DATADIR/test/t1.ibd
 DROP TABLE t1;
@@ -200,69 +200,56 @@ eval CREATE TEMPORARY TABLE t1 (a int KE
 SHOW WARNINGS;
 SHOW CREATE TABLE t1;
 DROP TABLE t1;
-
---echo # Test discard/import of InnoDB tables.
---replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
-eval CREATE TABLE t1 (a int KEY, b text) $data_directory;
-INSERT INTO t1 VALUES (1, "blue");
-SELECT * FROM t1;
---replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
-SHOW CREATE TABLE t1;
-SELECT name,n_cols,file_format,row_format
-       FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
-SELECT name,file_format,row_format
-       FROM information_schema.innodb_sys_tablespaces;
---replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
-SELECT path FROM information_schema.innodb_sys_datafiles;
+--error 1
 --file_exists $MYSQLD_DATADIR/test/t1.frm
+--error 1
 --file_exists $MYSQLD_DATADIR/test/t1.isl
+--error 1
 --file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
 --error 1
 --file_exists $MYSQLD_DATADIR/test/t1.ibd
 
---echo # Make a backup copy of the tablespace.
-copy_file $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd  $MYSQL_TMP_DIR/alternate_dir/data/test/t1.backup;
 
---echo # Discard the tablespace.
-ALTER TABLE t1 DISCARD TABLESPACE;
+--echo # Create the remote table via static DDL statements in a stored procedure
+DELIMITER |;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval CREATE PROCEDURE static_proc() BEGIN CREATE TABLE t1 (a int KEY, b text) $data_directory; END |
+DELIMITER ;|
+CALL static_proc;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SELECT path FROM information_schema.innodb_sys_datafiles;
+INSERT INTO t1 VALUES (7, "Create the remote table via static DDL statements");
+SELECT * FROM t1;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SHOW CREATE TABLE t1;
 --file_exists $MYSQLD_DATADIR/test/t1.frm
 --file_exists $MYSQLD_DATADIR/test/t1.isl
---error 1
 --file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
---error 1
---file_exists $MYSQLD_DATADIR/test/t1.ibd
-
---echo # Restore the backup.
-copy_file $MYSQL_TMP_DIR/alternate_dir/data/test/t1.backup  $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd;
+DROP PROCEDURE static_proc;
+DROP TABLE t1;
 
---echo # Import the tablespace.
-ALTER TABLE t1 IMPORT TABLESPACE;
+--echo # Create the remote table via dynamic DDL statements in a stored procedure
+DELIMITER |;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval CREATE PROCEDURE dynamic_proc() BEGIN PREPARE stmt1 FROM "CREATE TABLE t1 (a int KEY, b text) $data_directory"; EXECUTE stmt1; END |
+DELIMITER ;|
+CALL dynamic_proc;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SELECT path FROM information_schema.innodb_sys_datafiles;
-INSERT INTO t1 VALUES (2, "red");
+INSERT INTO t1 VALUES (8, "Create the remote table via dynamic DDL statements");
 SELECT * FROM t1;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SHOW CREATE TABLE t1;
 --file_exists $MYSQLD_DATADIR/test/t1.frm
 --file_exists $MYSQLD_DATADIR/test/t1.isl
 --file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+DROP PROCEDURE dynamic_proc;
 DROP TABLE t1;
---error 1
---file_exists $MYSQLD_DATADIR/test/t1.frm
---error 1
---file_exists $MYSQLD_DATADIR/test/t1.isl
---error 1
---file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
 
 --echo #
 --echo # Cleanup
 --echo #
 
---remove_file $MYSQL_TMP_DIR/alternate_dir/data/test/t1.backup
 --rmdir $MYSQL_TMP_DIR/alternate_dir/data/test
 --rmdir $MYSQL_TMP_DIR/alternate_dir/data
 --rmdir $MYSQL_TMP_DIR/alternate_dir

=== modified file 'mysql-test/suite/innodb/t/innodb_bug11766634.test'
--- a/mysql-test/suite/innodb/t/innodb_bug11766634.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/innodb_bug11766634.test	revid:kevin.lewis@stripped
@@ -7,6 +7,9 @@
 # records.  The size of ibdata1 must not increase.
 #
 
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
+
 -- source include/not_embedded.inc
 -- source include/have_innodb.inc
 

=== modified file 'mysql-test/suite/innodb/t/innodb_mysql.test'
--- a/mysql-test/suite/innodb/t/innodb_mysql.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/innodb_mysql.test	revid:kevin.lewis@stripped
@@ -5,6 +5,9 @@
 #               main testing code t/innodb_mysql.test -> include/mix1.inc
 #
 
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
+
 -- source include/have_innodb.inc
 let $engine_type= InnoDB;
 let $other_engine_type= MEMORY;

=== modified file 'mysql-test/suite/parts/t/partition_alter1_1_innodb.test'
--- a/mysql-test/suite/parts/t/partition_alter1_1_innodb.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/parts/t/partition_alter1_1_innodb.test	revid:kevin.lewis@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
 ################################################################################
 # t/partition_alter1_1_innodb.test                                             #
 #                                                                              #

=== modified file 'mysql-test/suite/parts/t/partition_alter2_2_1_innodb.test'
--- a/mysql-test/suite/parts/t/partition_alter2_2_1_innodb.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/parts/t/partition_alter2_2_1_innodb.test	revid:kevin.lewis@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
 ################################################################################
 # t/partition_alter2_2_1_innodb.test                                           #
 #                                                                              #

=== modified file 'mysql-test/suite/parts/t/partition_basic_innodb.test'
--- a/mysql-test/suite/parts/t/partition_basic_innodb.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/parts/t/partition_basic_innodb.test	revid:kevin.lewis@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 ################################################################################
 # t/partition_basic_innodb.test                                                #
 #                                                                              #

=== modified file 'mysql-test/suite/parts/t/partition_decimal_myisam.test'
--- a/mysql-test/suite/parts/t/partition_decimal_myisam.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/parts/t/partition_decimal_myisam.test	revid:kevin.lewis@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
 ################################################################################
 # t/partition_decimal_myisam.test                                              #
 #                                                                              #

=== modified file 'mysql-test/suite/parts/t/partition_int_myisam.test'
--- a/mysql-test/suite/parts/t/partition_int_myisam.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/parts/t/partition_int_myisam.test	revid:kevin.lewis@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution.
+--source include/no_valgrind_without_big.inc
 ################################################################################
 # t/partition_int_myisam.test                                                  #
 #                                                                              #

=== modified file 'mysql-test/suite/rpl/r/rpl_skip_ddl_errors_cli.result'
--- a/mysql-test/suite/rpl/r/rpl_skip_ddl_errors_cli.result	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/r/rpl_skip_ddl_errors_cli.result	revid:kevin.lewis@stripped
@@ -1,5 +1,11 @@
+include/master-slave.inc
+Warnings:
+Note	1756	Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note	1757	Storing MySQL user name or password information in the master.info repository is not secure and is therefore not recommended. Please see the MySQL Manual for more about this issue and possible alternatives.
+[connection master]
 Show the effect of the server command line option slave-skip-errors
 being passed the alias ignore_ddl_errors and a numeric error code
 SHOW VARIABLES LIKE 'slave_skip_errors';
 Variable_name	Value
 slave_skip_errors	1003,1007,1008,1050,1051,1054,1060,1061,1068,1091,1146
+include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_alter_repository.test'
--- a/mysql-test/suite/rpl/t/rpl_alter_repository.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_alter_repository.test	revid:kevin.lewis@stripped
@@ -7,6 +7,8 @@
 --source include/master-slave.inc
 --source include/have_innodb.inc
 --source include/not_mts_slave_parallel_workers.inc
+--source include/not_relay_log_info_table.inc
+--source include/not_master_info_table.inc
 --connection slave
 --source include/stop_slave.inc
 SHOW CREATE TABLE mysql.slave_relay_log_info;

=== modified file 'mysql-test/suite/rpl/t/rpl_gtid_parallel.test'
--- a/mysql-test/suite/rpl/t/rpl_gtid_parallel.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_gtid_parallel.test	revid:kevin.lewis@stripped
@@ -24,6 +24,7 @@
 #
 # Implemented as part of WL#3584: Global Transaction Identifiers
 
+--source include/big_test.inc
 --source include/have_gtid.inc
 --source include/master-slave.inc
 --source include/not_windows.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_gtid_stress_failover.test'
--- a/mysql-test/suite/rpl/t/rpl_gtid_stress_failover.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_gtid_stress_failover.test	revid:kevin.lewis@stripped
@@ -79,6 +79,7 @@
 #
 # Created as part of WL#3584: Global Transaction Identifiers
 
+--source include/big_test.inc
 --source include/have_gtid.inc
 
 # This test case has path issues when executing the 

=== modified file 'mysql-test/suite/rpl/t/rpl_mixed_mixing_engines.test'
--- a/mysql-test/suite/rpl/t/rpl_mixed_mixing_engines.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_mixed_mixing_engines.test	revid:kevin.lewis@stripped
@@ -2,6 +2,7 @@
 # This test cases evaluates the mixture of non-transactional and transcational
 # tables. For further details, please, read WL#2687 and WL#5072.
 ###################################################################################
+--source include/big_test.inc
 --source include/have_binlog_format_mixed.inc
 --source include/master-slave.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_mixed_mts_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_mixed_mts_crash_safe.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_mixed_mts_crash_safe.test	revid:kevin.lewis@stripped
@@ -1,3 +1,4 @@
+--source include/big_test.inc
 --source include/master-slave.inc
 --source include/have_binlog_format_mixed.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_mixed_mts_rec_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_mixed_mts_rec_crash_safe.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_mixed_mts_rec_crash_safe.test	revid:kevin.lewis@stripped
@@ -1,3 +1,4 @@
+--source include/big_test.inc
 --source include/master-slave.inc
 --source include/have_binlog_format_mixed.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_mixed_mts_rec_crash_safe_checksum.test'
--- a/mysql-test/suite/rpl/t/rpl_mixed_mts_rec_crash_safe_checksum.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_mixed_mts_rec_crash_safe_checksum.test	revid:kevin.lewis@stripped
@@ -1 +1,2 @@
+--source include/big_test.inc
 --source rpl_mixed_mts_rec_crash_safe.test

=== modified file 'mysql-test/suite/rpl/t/rpl_non_direct_mixed_mixing_engines.test'
--- a/mysql-test/suite/rpl/t/rpl_non_direct_mixed_mixing_engines.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_non_direct_mixed_mixing_engines.test	revid:kevin.lewis@stripped
@@ -2,6 +2,7 @@
 # This test cases evaluates the mixture of non-transactional and transcational
 # tables. For further details, please, read WL#2687 and WL#5072.
 ###################################################################################
+--source include/big_test.inc
 --source include/have_binlog_format_mixed.inc
 --source include/master-slave.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_non_direct_row_mixing_engines.test'
--- a/mysql-test/suite/rpl/t/rpl_non_direct_row_mixing_engines.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_non_direct_row_mixing_engines.test	revid:kevin.lewis@stripped
@@ -2,6 +2,7 @@
 # This test cases evaluates the mixture of non-transactional and transcational
 # tables. For further details, please, read WL#2687 and WL#5072.
 ###################################################################################
+--source include/big_test.inc
 --source include/have_binlog_format_row.inc
 --source include/master-slave.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_non_direct_stm_mixing_engines.test'
--- a/mysql-test/suite/rpl/t/rpl_non_direct_stm_mixing_engines.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_non_direct_stm_mixing_engines.test	revid:kevin.lewis@stripped
@@ -2,6 +2,7 @@
 # This test cases evaluates the mixture of non-transactional and transcational
 # tables. For further details, please, read WL#2687 and WL#5072.
 ###################################################################################
+--source include/big_test.inc
 --source include/have_binlog_format_statement.inc
 --source include/master-slave.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_row_mixing_engines.test'
--- a/mysql-test/suite/rpl/t/rpl_row_mixing_engines.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_row_mixing_engines.test	revid:kevin.lewis@stripped
@@ -2,6 +2,7 @@
 # This test cases evaluates the mixture of non-transactional and transcational
 # tables. For further details, please, read WL#2687 and WL#5072.
 ###################################################################################
+--source include/big_test.inc
 --source include/have_binlog_format_row.inc
 --source include/master-slave.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_row_mts_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_row_mts_crash_safe.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_row_mts_crash_safe.test	revid:kevin.lewis@stripped
@@ -1,3 +1,4 @@
+--source include/big_test.inc
 --source include/master-slave.inc
 --source include/have_binlog_format_row.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_row_mts_rec_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_row_mts_rec_crash_safe.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_row_mts_rec_crash_safe.test	revid:kevin.lewis@stripped
@@ -1,3 +1,4 @@
+--source include/big_test.inc
 --source include/master-slave.inc
 --source include/have_binlog_format_row.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test'
--- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test	revid:kevin.lewis@stripped
@@ -4,6 +4,7 @@
 # Purpose: To test changes to mysqlbinlog for row based bin logs #
 # We are using .opt file since we need small binlog size         #
 ##################################################################
+--source include/big_test.inc
 # Include Section
 # Make sure that we have row based bin log
 -- source include/have_binlog_format_row.inc

=== renamed file 'mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.cnf' => 'mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.cnf	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli-slave.opt	revid:kevin.lewis@stripped
@@ -1,7 +1 @@
-!include include/default_mysqld.cnf
-
-[mysqld]
-# expect combined error codes
-slave-skip-errors=ddl_exist_errors,1003
-
-[mysqld.1.1]
+--slave-skip-errors=ddl_exist_errors,1003

=== modified file 'mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.test'
--- a/mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_skip_ddl_errors_cli.test	revid:kevin.lewis@stripped
@@ -1,3 +1,9 @@
+--source include/master-slave.inc
+--source include/have_binlog_format_mixed.inc
+
+--connection slave
 --echo Show the effect of the server command line option slave-skip-errors
 --echo being passed the alias ignore_ddl_errors and a numeric error code
 SHOW VARIABLES LIKE 'slave_skip_errors';
+
+--source include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_mixed_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_mixed_crash_safe.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_stm_mixed_crash_safe.test	revid:kevin.lewis@stripped
@@ -1,3 +1,4 @@
+--source include/big_test.inc
 --source include/master-slave.inc
 --source include/not_embedded.inc
 --source include/not_valgrind.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_mixing_engines.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_mixing_engines.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_stm_mixing_engines.test	revid:kevin.lewis@stripped
@@ -2,6 +2,7 @@
 # This test cases evaluates the mixture of non-transactional and transcational
 # tables. For further details, please, read WL#2687 and WL#5072.
 ###################################################################################
+--source include/big_test.inc
 --source include/have_binlog_format_statement.inc
 --source include/master-slave.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_mts_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_mts_crash_safe.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_stm_mts_crash_safe.test	revid:kevin.lewis@stripped
@@ -1,3 +1,4 @@
+--source include/big_test.inc
 --source include/master-slave.inc
 --source include/have_binlog_format_statement.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_mts_rec_crash_safe.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_mts_rec_crash_safe.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/rpl/t/rpl_stm_mts_rec_crash_safe.test	revid:kevin.lewis@stripped
@@ -1,3 +1,4 @@
+--source include/big_test.inc
 --source include/master-slave.inc
 --source include/have_binlog_format_statement.inc
 --source include/have_innodb.inc

=== modified file 'mysql-test/t/lowercase_table2.test'
--- a/mysql-test/t/lowercase_table2.test	revid:kevin.lewis@stripped
+++ b/mysql-test/t/lowercase_table2.test	revid:kevin.lewis@stripped
@@ -257,3 +257,13 @@ create table t_bug44738_UPPERCASE (i int
 flush tables;
 create table t_bug44738_UPPERCASE (i int);
 drop table t_bug44738_UPPERCASE;
+
+--echo # BUG#13702397 - 64211: 'CREATE TABLE ... LIKE ...'
+--echo #                       FAILS TO KEEP CASE
+--echo #
+
+CREATE TABLE TestTable1 (a int);
+SHOW TABLES;
+CREATE TABLE TestTable2 LIKE TestTable1;
+SHOW TABLES;
+DROP TABLE TestTable1, TestTable2;

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	revid:kevin.lewis@stripped
+++ b/sql/item_subselect.cc	revid:kevin.lewis@stripped
@@ -3586,8 +3586,10 @@ err:
     if (mat_table_has_nulls == NEX_UNKNOWN)   // We do not know yet
     {
       // Search for NULL inside tmp table, and remember the outcome.
-      DBUG_ASSERT(table->file->inited);
       *tab->ref.null_ref_key= 1;
+      if (!table->file->inited &&
+          table->file->ha_index_init(tab->ref.key, false /* sorted */))
+        DBUG_RETURN(true);
       if (safe_index_read(tab) == 1)
         DBUG_RETURN(true);
       *tab->ref.null_ref_key= 0; // prepare for next searches of non-NULL

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	revid:kevin.lewis@stripped
+++ b/sql/log_event.cc	revid:kevin.lewis@stripped
@@ -500,10 +500,15 @@ static void cleanup_load_tmpdir()
 
 
 /*
-  write_str()
+  Stores string to IO_CACHE file.
+
+  Writes str to file in the following format:
+   1. Stores length using only one byte (255 maximum value);
+   2. Stores complete str.
 */
 
-static bool write_str(IO_CACHE *file, const char *str, uint length)
+static bool write_str_at_most_255_bytes(IO_CACHE *file, const char *str,
+                                        uint length)
 {
   uchar tmp[1];
   tmp[0]= (uchar) length;
@@ -513,11 +518,20 @@ static bool write_str(IO_CACHE *file, co
 
 
 /*
-  read_str()
+  Reads string from buf.
+
+  Reads str from buf in the following format:
+   1. Read length stored on buf first index, as it only has 1 byte values
+      bigger than 255 where lost.
+   2. Set str pointer to buf second index.
+  Despite str contains the complete stored string, when it is read until
+  len its value will be truncated if original length was bigger than 255.
 */
 
-static inline int read_str(const char **buf, const char *buf_end,
-                           const char **str, uint8 *len)
+static inline int read_str_at_most_255_bytes(const char **buf,
+                                             const char *buf_end,
+                                             const char **str,
+                                             uint8 *len)
 {
   if (*buf + ((uint) (uchar) **buf) >= buf_end)
     return 1;
@@ -8510,11 +8524,11 @@ bool sql_ex_info::write_data(IO_CACHE* f
 {
   if (new_format())
   {
-    return (write_str(file, field_term, (uint) field_term_len) ||
-	    write_str(file, enclosed,   (uint) enclosed_len) ||
-	    write_str(file, line_term,  (uint) line_term_len) ||
-	    write_str(file, line_start, (uint) line_start_len) ||
-	    write_str(file, escaped,    (uint) escaped_len) ||
+    return (write_str_at_most_255_bytes(file, field_term, (uint) field_term_len) ||
+	    write_str_at_most_255_bytes(file, enclosed,   (uint) enclosed_len) ||
+	    write_str_at_most_255_bytes(file, line_term,  (uint) line_term_len) ||
+	    write_str_at_most_255_bytes(file, line_start, (uint) line_start_len) ||
+	    write_str_at_most_255_bytes(file, escaped,    (uint) escaped_len) ||
 	    my_b_safe_write(file,(uchar*) &opt_flags,1));
   }
   else
@@ -8554,11 +8568,11 @@ const char *sql_ex_info::init(const char
       the case when we have old format because we will be reusing net buffer
       to read the actual file before we write out the Create_file event.
     */
-    if (read_str(&buf, buf_end, &field_term, &field_term_len) ||
-        read_str(&buf, buf_end, &enclosed,   &enclosed_len) ||
-        read_str(&buf, buf_end, &line_term,  &line_term_len) ||
-        read_str(&buf, buf_end, &line_start, &line_start_len) ||
-        read_str(&buf, buf_end, &escaped,    &escaped_len))
+    if (read_str_at_most_255_bytes(&buf, buf_end, &field_term, &field_term_len) ||
+        read_str_at_most_255_bytes(&buf, buf_end, &enclosed,   &enclosed_len) ||
+        read_str_at_most_255_bytes(&buf, buf_end, &line_term,  &line_term_len) ||
+        read_str_at_most_255_bytes(&buf, buf_end, &line_start, &line_start_len) ||
+        read_str_at_most_255_bytes(&buf, buf_end, &escaped,    &escaped_len))
       return 0;
     opt_flags = *buf++;
   }
@@ -11580,7 +11594,7 @@ Incident_log_event::Incident_log_event(c
   char const *const str_end= buf + event_len;
   uint8 len= 0;                   // Assignment to keep compiler happy
   const char *str= NULL;          // Assignment to keep compiler happy
-  read_str(&ptr, str_end, &str, &len);
+  read_str_at_most_255_bytes(&ptr, str_end, &str, &len);
   if (!(m_message.str= (char*) my_malloc(len+1, MYF(MY_WME))))
   {
     /* Mark this event invalid */
@@ -11693,7 +11707,7 @@ Incident_log_event::write_data_body(IO_C
     crc= my_checksum(crc, (uchar*) m_message.str, m_message.length);
     // todo: report a bug on write_str accepts uint but treats it as uchar
   }
-  DBUG_RETURN(write_str(file, m_message.str, (uint) m_message.length));
+  DBUG_RETURN(write_str_at_most_255_bytes(file, m_message.str, (uint) m_message.length));
 }
 
 
@@ -11751,14 +11765,15 @@ Rows_query_log_event::Rows_query_log_eve
   DBUG_PRINT("info",("event_len: %u; common_header_len: %d; post_header_len: %d",
                      event_len, common_header_len, post_header_len));
 
-  char const *ptr= buf + common_header_len + post_header_len;
-  char const *const str_end= buf + event_len;
-  uint8 len= 0;                   // Assignment to keep compiler happy
-  const char *str= NULL;          // Assignment to keep compiler happy
-  read_str(&ptr, str_end, &str, &len);
+  /*
+   m_rows_query length is stored using only one byte, but that length is
+   ignored and the complete query is read.
+  */
+  int offset= common_header_len + post_header_len + 1;
+  int len= event_len - offset;
   if (!(m_rows_query= (char*) my_malloc(len+1, MYF(MY_WME))))
     return;
-  strmake(m_rows_query, str, len);
+  strmake(m_rows_query, buf + offset, len);
   DBUG_PRINT("info", ("m_rows_query: %s", m_rows_query));
   DBUG_VOID_RETURN;
 }
@@ -11804,7 +11819,12 @@ bool
 Rows_query_log_event::write_data_body(IO_CACHE *file)
 {
   DBUG_ENTER("Rows_query_log_event::write_data_body");
-  DBUG_RETURN(write_str(file, m_rows_query, (uint) strlen(m_rows_query)));
+  /*
+   m_rows_query length will be stored using only one byte, but on read
+   that length will be ignored and the complete query will be read.
+  */
+  DBUG_RETURN(write_str_at_most_255_bytes(file, m_rows_query,
+              (uint) strlen(m_rows_query)));
 }
 
 #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)

=== modified file 'sql/md5.cc'
--- a/sql/md5.cc	revid:kevin.lewis@stripped
+++ b/sql/md5.cc	revid:kevin.lewis@stripped
@@ -23,7 +23,6 @@
   to make available YaSSL's MD5 implementation.
 */
 
-#include <my_global.h>
 #include <my_md5.h>
 
 #ifdef HAVE_YASSL

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	revid:kevin.lewis@stripped
+++ b/sql/rpl_slave.cc	revid:kevin.lewis@stripped
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/rpl_slave.h'
--- a/sql/rpl_slave.h	revid:kevin.lewis@stripped
+++ b/sql/rpl_slave.h	revid:kevin.lewis@stripped
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

=== modified file 'sql/sql_executor.cc'
--- a/sql/sql_executor.cc	revid:kevin.lewis@stripped
+++ b/sql/sql_executor.cc	revid:kevin.lewis@stripped
@@ -145,15 +145,13 @@ JOIN::exec()
       We have to test for 'conds' here as the WHERE may not be constant
       even if we don't have any tables for prepared statements or if
       conds uses something like 'rand()'.
-      If the HAVING clause is either impossible or always true, then
-      JOIN::having is set to NULL by optimize_cond.
-      In this case JOIN::exec must check for JOIN::having_value, in the
-      same way it checks for JOIN::cond_value.
+
+      Don't evaluate the having clause here. return_zero_rows() should
+      be called only for cases where there are no matching rows after
+      evaluating all conditions except the HAVING clause.
     */
     if (select_lex->cond_value != Item::COND_FALSE &&
-        select_lex->having_value != Item::COND_FALSE &&
-        (!conds || conds->val_int()) &&
-        (!having || having->val_int()))
+        (!conds || conds->val_int()))
     {
       if (result->send_result_set_metadata(*columns_list,
                                            Protocol::SEND_NUM_ROWS |
@@ -161,7 +159,16 @@ JOIN::exec()
       {
         DBUG_VOID_RETURN;
       }
-      if (do_send_rows &&
+
+      /*
+        If the HAVING clause is either impossible or always true, then
+        JOIN::having is set to NULL by optimize_cond.
+        In this case JOIN::exec must check for JOIN::having_value, in the
+        same way it checks for JOIN::cond_value.
+      */
+      if (((select_lex->having_value != Item::COND_FALSE) &&
+           (!having || having->val_int())) 
+          && do_send_rows &&
           (procedure ? (procedure->send_row(procedure_fields_list) ||
            procedure->end_of_records()) : result->send_data(fields_list)))
         error= 1;
@@ -1422,13 +1429,17 @@ static void update_const_equal_items(Ite
 }
 
 /**
-  For some reason (impossible WHERE clause etc), the tables cannot
+  For some reason, e.g. due to an impossible WHERE clause, the tables cannot
   possibly contain any rows that will be in the result. This function
   is used to return with a result based on no matching rows (i.e., an
   empty result or one row with aggregates calculated without using
   rows in the case of implicit grouping) before the execution of
   nested loop join.
 
+  This function may evaluate the HAVING clause and is only meant for
+  result sets that are empty due to an impossible HAVING clause. Do
+  not use it if HAVING has already been evaluated.
+
   @param join    The join that does not produce a row
   @param fields  Fields in result
 */

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	revid:kevin.lewis@stripped
+++ b/sql/sql_table.cc	revid:kevin.lewis@stripped
@@ -4934,6 +4934,7 @@ bool mysql_create_like_table(THD* thd, T
     the original table. This is documented behavior.
   */
   local_create_info.data_file_name= local_create_info.index_file_name= NULL;
+  local_create_info.alias= create_info->alias;
 
   if ((res= mysql_create_table_no_lock(thd, table->db, table->table_name,
                                        &local_create_info, &local_alter_info,

=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc	revid:kevin.lewis@stripped
+++ b/sql/sql_view.cc	revid:kevin.lewis@stripped
@@ -1099,12 +1099,12 @@ err:
 bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
                      uint flags)
 {
-  SELECT_LEX *end, *view_select;
+  SELECT_LEX *end, *view_select= NULL;
   LEX *old_lex, *lex;
   Query_arena *arena, backup;
   TABLE_LIST *top_view= table->top_table();
-  bool parse_status;
-  bool result, view_is_mergeable;
+  bool parse_status= true;
+  bool result= true, view_is_mergeable;
   TABLE_LIST *UNINIT_VAR(view_main_select_tables);
 
   DBUG_ENTER("mysql_make_view");

=== modified file 'storage/innobase/btr/btr0btr.cc'
--- a/storage/innobase/btr/btr0btr.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/btr/btr0btr.cc	revid:kevin.lewis@stripped
@@ -695,13 +695,14 @@ btr_root_fseg_validate(
 #endif /* UNIV_BTR_DEBUG */
 
 /**************************************************************//**
-Gets the root node of a tree and x-latches it.
-@return	root page, x-latched */
+Gets the root node of a tree and x- or s-latches it.
+@return	root page, x- or s-latched */
 static
 buf_block_t*
 btr_root_block_get(
 /*===============*/
 	dict_index_t*	index,	/*!< in: index tree */
+	ulint		mode,	/*!< in: either RW_S_LATCH or RW_X_LATCH */
 	mtr_t*		mtr)	/*!< in: mtr */
 {
 	ulint		space;
@@ -713,8 +714,7 @@ btr_root_block_get(
 	zip_size = dict_table_zip_size(index->table);
 	root_page_no = dict_index_get_page(index);
 
-	block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH,
-			      index, mtr);
+	block = btr_block_get(space, zip_size, root_page_no, mode, index, mtr);
 	btr_assert_not_corrupted(block, index);
 #ifdef UNIV_BTR_DEBUG
 	if (!dict_index_is_ibuf(index)) {
@@ -740,7 +740,42 @@ btr_root_get(
 	dict_index_t*	index,	/*!< in: index tree */
 	mtr_t*		mtr)	/*!< in: mtr */
 {
-	return(buf_block_get_frame(btr_root_block_get(index, mtr)));
+	return(buf_block_get_frame(btr_root_block_get(index, RW_X_LATCH,
+						      mtr)));
+}
+
+/**************************************************************//**
+Gets the height of the B-tree (the level of the root, when the leaf
+level is assumed to be 0). The caller must hold an S or X latch on
+the index.
+@return	tree height (level of the root) */
+UNIV_INTERN
+ulint
+btr_height_get(
+/*===========*/
+	dict_index_t*	index,	/*!< in: index tree */
+	mtr_t*		mtr)	/*!< in/out: mini-transaction */
+{
+	ulint		height;
+	buf_block_t*	root_block;
+
+	ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
+				MTR_MEMO_S_LOCK)
+	      || mtr_memo_contains(mtr, dict_index_get_lock(index),
+				MTR_MEMO_X_LOCK));
+
+        /* S latches the page */
+        root_block = btr_root_block_get(index, RW_S_LATCH, mtr);
+
+        height = btr_page_get_level(buf_block_get_frame(root_block), mtr);
+
+        /* Release the S latch on the root page. */
+        mtr_memo_release(mtr, root_block, MTR_MEMO_PAGE_S_FIX);
+#ifdef UNIV_SYNC_DEBUG
+        sync_thread_reset_level(&root_block->lock);
+#endif /* UNIV_SYNC_DEBUG */
+
+	return(height);
 }
 
 /*************************************************************//**
@@ -3811,7 +3846,7 @@ btr_print_index(
 
 	mtr_start(&mtr);
 
-	root = btr_root_block_get(index, &mtr);
+	root = btr_root_block_get(index, RW_X_LATCH, &mtr);
 
 	btr_print_recursive(index, root, width, &heap, &offsets, &mtr);
 	if (heap) {
@@ -4105,7 +4140,7 @@ btr_validate_level(
 
 	mtr_x_lock(dict_index_get_lock(index), &mtr);
 
-	block = btr_root_block_get(index, &mtr);
+	block = btr_root_block_get(index, RW_X_LATCH, &mtr);
 	page = buf_block_get_frame(block);
 
 	space = dict_index_get_space(index);

=== modified file 'storage/innobase/btr/btr0cur.cc'
--- a/storage/innobase/btr/btr0cur.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/btr/btr0cur.cc	revid:kevin.lewis@stripped
@@ -427,6 +427,14 @@ btr_cur_search_to_nth_level(
 	cursor->low_match = ULINT_UNDEFINED;
 #endif
 
+	ibool	s_latch_by_caller;
+
+	s_latch_by_caller = latch_mode & BTR_ALREADY_S_LATCHED;
+
+	ut_ad(!s_latch_by_caller
+	      || mtr_memo_contains(mtr, dict_index_get_lock(index),
+				   MTR_MEMO_S_LOCK));
+
 	/* These flags are mutually exclusive, they are lumped together
 	with the latch mode for historical reasons. It's possible for
 	none of the flags to be set. */
@@ -466,7 +474,10 @@ btr_cur_search_to_nth_level(
 			| BTR_DELETE_MARK
 			| BTR_DELETE
 			| BTR_ESTIMATE
-			| BTR_IGNORE_SEC_UNIQUE);
+			| BTR_IGNORE_SEC_UNIQUE
+			| BTR_ALREADY_S_LATCHED);
+
+	ut_ad(!s_latch_by_caller || latch_mode == BTR_SEARCH_LEAF);
 
 	cursor->flag = BTR_CUR_BINARY;
 	cursor->index = index;
@@ -551,7 +562,9 @@ no_guess:
 					MTR_MEMO_X_LOCK));
 		break;
 	default:
-		mtr_s_lock(dict_index_get_lock(index), mtr);
+		if (!s_latch_by_caller) {
+			mtr_s_lock(dict_index_get_lock(index), mtr);
+		}
 	}
 
 	page_cursor = btr_cur_get_page_cur(cursor);
@@ -735,10 +748,12 @@ retry_page_get:
 		case BTR_CONT_MODIFY_TREE:
 			break;
 		default:
-			/* Release the tree s-latch */
-
-			mtr_release_s_latch_at_savepoint(
-				mtr, savepoint, dict_index_get_lock(index));
+			if (!s_latch_by_caller) {
+				/* Release the tree s-latch */
+				mtr_release_s_latch_at_savepoint(
+					mtr, savepoint,
+					dict_index_get_lock(index));
+			}
 		}
 
 		page_mode = mode;

=== modified file 'storage/innobase/buf/buf0lru.cc'
--- a/storage/innobase/buf/buf0lru.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/buf/buf0lru.cc	revid:kevin.lewis@stripped
@@ -342,39 +342,276 @@ next_page:
 }
 
 /******************************************************************//**
+While flushing (or removing dirty) pages from a tablespace we don't
+want to hog the CPU and resources. Release the buffer pool and block
+mutex and try to force a context switch. Then reacquire the same mutexes.
+The current page is "fixed" before the release of the mutexes and then
+"unfixed" again once we have reacquired the mutexes. */
+static
+void
+buf_flush_yield(
+/*============*/
+	buf_pool_t*	buf_pool,	/*!< in/out: buffer pool instance */
+	buf_page_t*	bpage)		/*!< in/out: current page */
+{
+	mutex_t*	block_mutex;
+
+	ut_ad(buf_pool_mutex_own(buf_pool));
+	ut_ad(buf_page_in_file(bpage));
+
+	block_mutex = buf_page_get_mutex(bpage);
+
+	mutex_enter(block_mutex);
+	/* "Fix" the block so that the position cannot be
+	changed after we release the buffer pool and
+	block mutexes. */
+	buf_page_set_sticky(bpage);
+
+	/* Now it is safe to release the buf_pool->mutex. */
+	buf_pool_mutex_exit(buf_pool);
+
+	mutex_exit(block_mutex);
+	/* Try and force a context switch. */
+	os_thread_yield();
+
+	buf_pool_mutex_enter(buf_pool);
+
+	mutex_enter(block_mutex);
+	/* "Unfix" the block now that we have both the
+	buffer pool and block mutex again. */
+	buf_page_unset_sticky(bpage);
+	mutex_exit(block_mutex);
+}
+
+/******************************************************************//**
+If we have hogged the resources for too long then release the buffer
+pool and flush list mutex and do a thread yield. Set the current page
+to "sticky" so that it is not relocated during the yield.
+@return TRUE if yielded */
+static
+ibool
+buf_flush_try_yield(
+/*================*/
+	buf_pool_t*	buf_pool,	/*!< in/out: buffer pool instance */
+	buf_page_t*	bpage,		/*!< in/out: bpage to remove */
+	ulint		processed)	/*!< in: number of pages processed */
+{
+	/* Every BUF_LRU_DROP_SEARCH_SIZE iterations in the
+	loop we release buf_pool->mutex to let other threads
+	do their job but only if the block is not IO fixed. This
+	ensures that the block stays in its position in the
+	flush_list. */
+
+	if (bpage != NULL
+	    && processed >= BUF_LRU_DROP_SEARCH_SIZE
+	    && buf_page_get_io_fix(bpage) == BUF_IO_NONE) {
+
+		buf_flush_list_mutex_exit(buf_pool);
+
+		/* Release the buffer pool and block mutex
+		to give the other threads a go. */
+
+		buf_flush_yield(buf_pool, bpage);
+
+		buf_flush_list_mutex_enter(buf_pool);
+
+		/* Should not have been removed from the flush
+		list during the yield. However, this check is
+		not sufficient to catch a remove -> add. */
+
+		ut_ad(bpage->in_flush_list);
+
+		return(TRUE);
+	}
+
+	return(FALSE);
+}
+
+/******************************************************************//**
+Removes a single page from a given tablespace inside a specific
+buffer pool instance.
+@return TRUE if page was removed. */
+static
+ibool
+buf_flush_or_remove_page(
+/*=====================*/
+	buf_pool_t*	buf_pool,	/*!< in/out: buffer pool instance */
+	buf_page_t*	bpage)		/*!< in/out: bpage to remove */
+{
+	mutex_t*	block_mutex;
+	ibool		processed = FALSE;
+
+	ut_ad(buf_pool_mutex_own(buf_pool));
+	ut_ad(buf_flush_list_mutex_own(buf_pool));
+
+	block_mutex = buf_page_get_mutex(bpage);
+
+	/* bpage->space and bpage->io_fix are protected by
+	buf_pool->mutex and block_mutex. It is safe to check
+	them while holding buf_pool->mutex only. */
+
+	if (buf_page_get_io_fix(bpage) != BUF_IO_NONE) {
+
+		/* We cannot remove this page during this scan
+		yet; maybe the system is currently reading it
+		in, or flushing the modifications to the file */
+
+	} else {
+
+		/* We have to release the flush_list_mutex to obey the
+		latching order. We are however guaranteed that the page
+		will stay in the flush_list because buf_flush_remove()
+		needs buf_pool->mutex as well (for the non-flush case). */
+
+		buf_flush_list_mutex_exit(buf_pool);
+
+		mutex_enter(block_mutex);
+
+		ut_ad(bpage->oldest_modification != 0);
+
+		if (bpage->buf_fix_count == 0) {
+
+			buf_flush_remove(bpage);
+
+			processed = TRUE;
+		}
+
+		mutex_exit(block_mutex);
+
+		buf_flush_list_mutex_enter(buf_pool);
+	}
+
+	ut_ad(!mutex_own(block_mutex));
+
+	return(processed);
+}
+
+/******************************************************************//**
 Remove all dirty pages belonging to a given tablespace inside a specific
 buffer pool instance when we are deleting the data file(s) of that
 tablespace. The pages still remain a part of LRU and are evicted from
-the list as they age towards the tail of the LRU. */
+the list as they age towards the tail of the LRU.
+@return TRUE if all freed. */
+static
+ibool
+buf_flush_or_remove_pages(
+/*======================*/
+	buf_pool_t*	buf_pool,	/*!< buffer pool instance */
+	ulint		id)		/*!< in: target space id for which
+					to remove or flush pages */
+{
+	buf_page_t*	prev;
+	buf_page_t*	bpage;
+	ulint		processed = 0;
+	ibool		all_freed = TRUE;
+
+	buf_flush_list_mutex_enter(buf_pool);
+
+	for (bpage = UT_LIST_GET_LAST(buf_pool->flush_list);
+	     bpage != NULL;
+	     bpage = prev) {
+
+		ut_a(buf_page_in_file(bpage));
+		ut_ad(bpage->in_flush_list);
+
+		/* Save the previous link because once we free the
+		page we can't rely on the links. */
+
+		prev = UT_LIST_GET_PREV(list, bpage);
+
+		if (buf_page_get_space(bpage) != id) {
+
+			/* Skip this block, as it does not belong to
+			the target space. */
+
+		} else if (!buf_flush_or_remove_page(buf_pool, bpage)) {
+
+			/* Remove was unsuccessful, we have to try again
+			by scanning the entire list from the end. */
+
+			all_freed = FALSE;
+		}
+
+		++processed;
+
+		/* Yield if we have hogged the CPU and mutexes for too long. */
+		if (buf_flush_try_yield(buf_pool, prev, processed)) {
+
+			/* Reset the batch size counter if we had to yield. */
+
+			processed = 0;
+		}
+
+	}
+
+	buf_flush_list_mutex_exit(buf_pool);
+
+	return(all_freed);
+}
+
+/******************************************************************//**
+Remove or flush all the dirty pages that belong to a given tablespace
+inside a specific buffer pool instance. The pages will remain in the LRU
+list and will be evicted from the LRU list as they age and move towards
+the tail of the LRU list. */
 static
 void
-buf_LRU_remove_dirty_pages_for_tablespace(
-/*======================================*/
+buf_flush_dirty_pages(
+/*==================*/
+	buf_pool_t*	buf_pool,	/*!< buffer pool instance */
+	ulint		id)		/*!< in: space id */
+{
+	ibool	all_freed;
+
+	do {
+		buf_pool_mutex_enter(buf_pool);
+
+		all_freed = buf_flush_or_remove_pages(buf_pool, id);
+
+		buf_pool_mutex_exit(buf_pool);
+
+		ut_ad(buf_flush_validate(buf_pool));
+
+		if (!all_freed) {
+			os_thread_sleep(20000);
+		}
+
+	} while (!all_freed);
+}
+
+/******************************************************************//**
+Remove all pages that belong to a given tablespace inside a specific
+buffer pool instance when we are DISCARDing the tablespace. */
+static
+void
+buf_LRU_remove_all_pages(
+/*=====================*/
 	buf_pool_t*	buf_pool,	/*!< buffer pool instance */
 	ulint		id)		/*!< in: space id */
 {
 	buf_page_t*	bpage;
 	ibool		all_freed;
-	ulint		i;
 
 scan_again:
 	buf_pool_mutex_enter(buf_pool);
-	buf_flush_list_mutex_enter(buf_pool);
 
 	all_freed = TRUE;
 
-	for (bpage = UT_LIST_GET_LAST(buf_pool->flush_list), i = 0;
-	     bpage != NULL; ++i) {
+	for (bpage = UT_LIST_GET_LAST(buf_pool->LRU);
+	     bpage != NULL;
+	     /* No op */) {
 
+		rw_lock_t*      hash_lock;
 		buf_page_t*	prev_bpage;
 		mutex_t*	block_mutex = NULL;
 
 		ut_a(buf_page_in_file(bpage));
+		ut_ad(bpage->in_LRU_list);
 
-		prev_bpage = UT_LIST_GET_PREV(list, bpage);
+		prev_bpage = UT_LIST_GET_PREV(LRU, bpage);
 
 		/* bpage->space and bpage->io_fix are protected by
-		buf_pool->mutex and block_mutex. It is safe to check
+		buf_pool->mutex and the block_mutex. It is safe to check
 		them while holding buf_pool->mutex only. */
 
 		if (buf_page_get_space(bpage) != id) {
@@ -388,83 +625,101 @@ scan_again:
 
 			all_freed = FALSE;
 			goto next_page;
-		}
+		} else {
 
-		/* We have to release the flush_list_mutex to obey the
-		latching order. We are however guaranteed that the page
-		will stay in the flush_list because buf_flush_remove()
-		needs buf_pool->mutex as well. */
-		buf_flush_list_mutex_exit(buf_pool);
-		block_mutex = buf_page_get_mutex(bpage);
-		mutex_enter(block_mutex);
+			ulint	fold = buf_page_address_fold(
+				bpage->space, bpage->offset);
 
-		if (bpage->buf_fix_count > 0) {
-			mutex_exit(block_mutex);
-			buf_flush_list_mutex_enter(buf_pool);
+			hash_lock = buf_page_hash_lock_get(buf_pool, fold);
 
-			/* We cannot remove this page during
-			this scan yet; maybe the system is
-			currently reading it in, or flushing
-			the modifications to the file */
+			rw_lock_x_lock(hash_lock);
 
-			all_freed = FALSE;
-			goto next_page;
-		}
+			block_mutex = buf_page_get_mutex(bpage);
+			mutex_enter(block_mutex);
 
-		ut_ad(bpage->oldest_modification != 0);
+			if (bpage->buf_fix_count > 0) {
 
-		buf_flush_remove(bpage);
+				mutex_exit(block_mutex);
 
-		mutex_exit(block_mutex);
-		buf_flush_list_mutex_enter(buf_pool);
-next_page:
-		bpage = prev_bpage;
+				/* We cannot remove this page during
+				this scan yet; maybe the system is
+				currently reading it in, or flushing
+				the modifications to the file */
 
-		if (!bpage) {
-			break;
+				all_freed = FALSE;
+
+				goto next_page;
+			}
 		}
 
-		/* Every BUF_LRU_DROP_SEARCH_SIZE iterations in the
-		loop we release buf_pool->mutex to let other threads
-		do their job. */
-		if (i < BUF_LRU_DROP_SEARCH_SIZE) {
-			continue;
+		ut_ad(mutex_own(block_mutex));
+
+#ifdef UNIV_DEBUG
+		if (buf_debug_prints) {
+			fprintf(stderr,
+				"Dropping space %lu page %lu\n",
+				(ulong) buf_page_get_space(bpage),
+				(ulong) buf_page_get_page_no(bpage));
 		}
+#endif
+		if (buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE) {
+			/* Do nothing, because the adaptive hash index
+			covers uncompressed pages only. */
+		} else if (((buf_block_t*) bpage)->index) {
+			ulint	page_no;
+			ulint	zip_size;
+
+			buf_pool_mutex_exit(buf_pool);
+
+			zip_size = buf_page_get_zip_size(bpage);
+			page_no = buf_page_get_page_no(bpage);
 
-		/* We IO-fix the block to make sure that the block
-		stays in its position in the flush_list. */
-		if (buf_page_get_io_fix(bpage) != BUF_IO_NONE) {
-			/* Block is already IO-fixed. We don't
-			want to change the value. Lets leave
-			this block alone. */
-			continue;
+			rw_lock_x_unlock(hash_lock);
+
+			mutex_exit(block_mutex);
+
+			/* Note that the following call will acquire
+			and release block->lock X-latch. */
+
+			btr_search_drop_page_hash_when_freed(
+				id, zip_size, page_no);
+
+			goto scan_again;
 		}
 
-		buf_flush_list_mutex_exit(buf_pool);
-		block_mutex = buf_page_get_mutex(bpage);
-		mutex_enter(block_mutex);
-		buf_page_set_sticky(bpage);
-		mutex_exit(block_mutex);
+		if (bpage->oldest_modification != 0) {
+			buf_flush_remove(bpage);
+		}
 
-		/* Now it is safe to release the buf_pool->mutex. */
-		buf_pool_mutex_exit(buf_pool);
-		os_thread_yield();
-		buf_pool_mutex_enter(buf_pool);
+		ut_ad(!bpage->in_flush_list);
 
-		mutex_enter(block_mutex);
-		buf_page_unset_sticky(bpage);
-		mutex_exit(block_mutex);
+		/* Remove from the LRU list. */
 
-		buf_flush_list_mutex_enter(buf_pool);
-		ut_ad(bpage->in_flush_list);
+		if (buf_LRU_block_remove_hashed_page(bpage, TRUE)
+		    != BUF_BLOCK_ZIP_FREE) {
+
+			buf_LRU_block_free_hashed_page((buf_block_t*) bpage);
+
+		} else {
+			/* The block_mutex should have been released
+			by buf_LRU_block_remove_hashed_page() when it
+			returns BUF_BLOCK_ZIP_FREE. */
+			ut_ad(block_mutex == &buf_pool->zip_mutex);
+		}
+
+		ut_ad(!mutex_own(block_mutex));
+
+#ifdef UNIV_SYNC_DEBUG
+                /* buf_LRU_block_remove_hashed_page() releases the hash_lock */
+                ut_ad(!rw_lock_own(hash_lock, RW_LOCK_EX));
+                ut_ad(!rw_lock_own(hash_lock, RW_LOCK_SHARED));
+#endif /* UNIV_SYNC_DEBUG */
 
-		i = 0;
+next_page:
+		bpage = prev_bpage;
 	}
 
 	buf_pool_mutex_exit(buf_pool);
-	buf_flush_list_mutex_exit(buf_pool);
-
-	ut_ad(buf_flush_validate(buf_pool));
 
 	if (!all_freed) {
 		os_thread_sleep(20000);
@@ -474,28 +729,46 @@ next_page:
 }
 
 /******************************************************************//**
-Invalidates all pages belonging to a given tablespace when we are deleting
-the data file(s) of that tablespace. */
+Removes all pages belonging to a given tablespace. */
 UNIV_INTERN
 void
-buf_LRU_invalidate_tablespace(
+buf_LRU_flush_or_remove_pages(
 /*==========================*/
-	ulint	id)	/*!< in: space id */
+	ulint			id,	/*!< in: space id */
+	enum buf_remove_t	buf_remove)/*!< in: remove or flush
+					strategy */
 {
-	ulint	i;
+	ulint		i;
 
-	/* Before we attempt to drop pages one by one we first
-	attempt to drop page hash index entries in batches to make
-	it more efficient. The batching attempt is a best effort
-	attempt and does not guarantee that all pages hash entries
-	will be dropped. We get rid of remaining page hash entries
-	one by one below. */
 	for (i = 0; i < srv_buf_pool_instances; i++) {
 		buf_pool_t*	buf_pool;
 
 		buf_pool = buf_pool_from_array(i);
-		buf_LRU_drop_page_hash_for_tablespace(buf_pool, id);
-		buf_LRU_remove_dirty_pages_for_tablespace(buf_pool, id);
+
+		switch (buf_remove) {
+		case BUF_REMOVE_ALL_NO_WRITE:
+			/* A DISCARD tablespace case. Remove AHI entries
+			and evict all pages from LRU. */
+
+			/* Before we attempt to drop pages hash entries
+			one by one we first attempt to drop page hash
+			index entries in batches to make it more
+			efficient. The batching attempt is a best effort
+			attempt and does not guarantee that all pages
+			hash entries will be dropped. We get rid of
+			remaining page hash entries one by one below. */
+			buf_LRU_drop_page_hash_for_tablespace(buf_pool, id);
+			buf_LRU_remove_all_pages(buf_pool, id);
+			break;
+
+		case BUF_REMOVE_FLUSH_NO_WRITE:
+			/* A DROP table case. AHI entries are already
+			removed. No need to evict all pages from LRU
+			list. Just evict pages from flush list without
+			writing. */
+			buf_flush_dirty_pages(buf_pool, id);
+			break;
+		}
 	}
 }
 

=== modified file 'storage/innobase/dict/dict0crea.cc'
--- a/storage/innobase/dict/dict0crea.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/dict/dict0crea.cc	revid:kevin.lewis@stripped
@@ -1741,7 +1741,7 @@ db_err
 dict_create_add_tablespace_to_dictionary(
 /*=====================================*/
 	ulint		space,		/*!< in: tablespace id */
-	char*		name,		/*!< in: tablespace name */
+	const char*	name,		/*!< in: tablespace name */
 	ulint		flags,		/*!< in: tablespace flags */
 	trx_t*		trx)		/*!< in: transaction */
 {
@@ -1787,7 +1787,7 @@ db_err
 dict_create_add_datafile_to_dictionary(
 /*===================================*/
 	ulint		space,		/*!< in: tablespace id */
-	char*		path,		/*!< in: tablespace path */
+	const char*	path,		/*!< in: tablespace path */
 	trx_t*		trx)		/*!< in: transaction */
 {
 	db_err		error;

=== modified file 'storage/innobase/dict/dict0load.cc'
--- a/storage/innobase/dict/dict0load.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/dict/dict0load.cc	revid:kevin.lewis@stripped
@@ -41,6 +41,7 @@ Created 4/24/1996 Heikki Tuuri
 #include "rem0cmp.h"
 #include "srv0start.h"
 #include "srv0srv.h"
+#include "dict0crea.h"
 #include "dict0priv.h"
 #include "ha_prototypes.h" /* innobase_casedn_str() */
 #include "fts0priv.h"
@@ -677,8 +678,8 @@ err_len:
 }
 
 /********************************************************************//**
-This function parses a SYS_DATAFILES record and extract necessary
-information from the record and return to caller.
+This function parses a SYS_DATAFILES record, extracts necessary
+information from the record and returns it to the caller.
 @return error message, or NULL on success */
 UNIV_INTERN
 const char*
@@ -773,29 +774,109 @@ dict_sys_tables_get_flags(
 }
 
 /********************************************************************//**
-Gets the filepath for a spaceid from SYS_DATAFILES. This function provides
-a temporary heap which is used for the table lookup, but not for the path.
-The caller must free the memory for the path returned. This function can
-return NULL if the space ID is not found in SYS_DATAFILES, then the caller
-will assume that the ibd file is in the normal datadir. */
+Look up a tablename in SYS_TABLES and return the space ID.
+@return TRUE if tablename was found and space ID is set, FALSE if not. */
 UNIV_INTERN
-void
+bool
+dict_get_space_from_sys_tables(
+/*===========================*/
+	const char*	name,		/*!< in: table name */
+	ulint*		space)		/*!< out: space ID */
+{
+	bool		found;
+	mem_heap_t*	heap;
+	mtr_t		mtr;
+	dict_table_t*	sys_tables;
+	dict_index_t*	sys_index;
+	dtuple_t*	tuple;
+	dfield_t*	dfield;
+	btr_pcur_t	pcur;
+	const rec_t*	rec;
+	const byte*	field;
+	ulint		len;
+
+	ut_ad(mutex_own(&(dict_sys->mutex)));
+
+	heap = mem_heap_create(1024);
+
+	mtr_start(&mtr);
+
+	ut_ad(mutex_own(&(dict_sys->mutex)));
+
+	mtr_start(&mtr);
+
+	sys_tables = dict_table_get_low("SYS_TABLES");
+	sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
+
+	ut_ad(!dict_table_is_comp(sys_tables));
+	ut_ad(name_of_col_is(sys_tables, sys_index,
+			     DICT_FLD__SYS_TABLES__TYPE, "TYPE"));
+	ut_ad(name_of_col_is(sys_tables, sys_index,
+			     DICT_FLD__SYS_TABLES__SPACE, "SPACE"));
+
+	tuple = dtuple_create(heap, 1);
+	dfield = dtuple_get_nth_field(tuple, 0);
+
+	dfield_set_data(dfield, name, ut_strlen(name));
+	dict_index_copy_types(tuple, sys_index, 1);
+
+	btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
+				  BTR_SEARCH_LEAF, &pcur, &mtr);
+	rec = btr_pcur_get_rec(&pcur);
+
+	if (!btr_pcur_is_on_user_rec(&pcur)
+	    || rec_get_deleted_flag(rec, 0)) {
+		found = false;
+		goto exit_func;
+	}
+
+	field = rec_get_nth_field_old(
+		rec, DICT_FLD__SYS_TABLES__SPACE, &len);
+	ut_a(len == 4);
+
+	*space = mach_read_from_4(field);
+	found = true;
+
+exit_func:
+	btr_pcur_close(&pcur);
+	mtr_commit(&mtr);
+	mem_heap_free(heap);
+
+	return(found);
+}
+
+/********************************************************************//**
+Gets the filepath for a spaceid from SYS_DATAFILES and checks it against
+the contents of a link file. This function is called when there is no
+fil_node_t entry for this space ID so both durable locations on  disk
+must be checked and compared.
+We use a temporary heap here for the table lookup, but not for the path
+returned which the caller must free.
+This function can return NULL if the space ID is not found in SYS_DATAFILES,
+then the caller will assume that the ibd file is in the normal datadir.
+@return	own: A copy of the first datafile found in SYS_DATAFILES.PATH for
+the given space ID. NULL if space ID is zero or not found. */
+UNIV_INTERN
+char*
 dict_get_first_path(
 /*================*/
 	ulint		space,	/*!< in: space id */
-	char**		path)	/*!< out: datafile path for this tablespace */
+	const char*	name)	/*!< in: tablespace name */
 {
+	mtr_t		mtr;
 	dict_table_t*	sys_datafiles;
 	dict_index_t*	sys_index;
-	btr_pcur_t	pcur;
 	dtuple_t*	tuple;
 	dfield_t*	dfield;
+	byte*		buf;
+	btr_pcur_t	pcur;
 	const rec_t*	rec;
 	const byte*	field;
 	ulint		len;
-	byte*		buf;
-	mtr_t		mtr;
+	char*		dict_filepath = NULL;
+	char*		remote_filepath = NULL;
 	mem_heap_t*	heap = mem_heap_create(1024);
+	trx_t*		trx;
 
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
@@ -823,27 +904,82 @@ dict_get_first_path(
 
 	rec = btr_pcur_get_rec(&pcur);
 
-	if (!btr_pcur_is_on_user_rec(&pcur)) {
-		/* If the file-per-table tablespace was created with
-		an earlier version of InnoDB, then this record is not
-		in SYS_DATAFILES and the filepath can be created
-		from the databasename/tablename. */
+	/* If the file-per-table tablespace was created with
+	an earlier version of InnoDB, then this record is not
+	in SYS_DATAFILES.  But a link file still might exist. */
 
-		*path = NULL;
-		goto exit_func;
+	if (btr_pcur_is_on_user_rec(&pcur)) {
+		/* A record for this space ID was found. */
+		field = rec_get_nth_field_old(
+			rec, DICT_FLD__SYS_DATAFILES__PATH, &len);
+		ut_a(len > 0 || len == UNIV_SQL_NULL);
+		ut_a(len < OS_FILE_MAX_PATH);
+		dict_filepath = mem_strdupl((char*) field, len);
+		ut_a(dict_filepath);
 	}
 
-	field = rec_get_nth_field_old(
-		rec, DICT_FLD__SYS_DATAFILES__PATH, &len);
-	ut_a(len > 0 || len == UNIV_SQL_NULL);
-	ut_a(len < OS_FILE_MAX_PATH);
-	*path = mem_strdupl((char*) field, len);
-	ut_a(*path);
-
-exit_func:
 	btr_pcur_close(&pcur);
 	mtr_commit(&mtr);
 	mem_heap_free(heap);
+
+	/* Compare this path with the path found in a link file if it
+	exists. The .isl file is in the 'normal' tablespace location. */
+	remote_filepath = fil_read_link_file(name);
+	if (!remote_filepath) {
+		return(dict_filepath);
+	}
+
+	/* A link file existed, make sure it is the same file we found
+	in SYS_DATAFILES. */
+	if (strcmp(dict_filepath, remote_filepath) == 0) {
+		mem_free(remote_filepath);
+		return (dict_filepath);
+	}
+
+	/* The two filepaths are different. Since the link file may be
+	updated in order to migrate tablespaces, always use the
+	linked_filepath. Write the linked_filepath into the system tables. */
+	trx = trx_allocate_for_background();
+	trx_start_if_not_started(trx);
+
+	if (dict_filepath) {
+		db_err		error;
+		pars_info_t*	info = pars_info_create();
+
+		pars_info_add_int4_literal(info, "space", space);
+		pars_info_add_str_literal(info, "remote_path",
+					  remote_filepath);
+
+		error = que_eval_sql(info,
+				   "PROCEDURE UPDATE_FILEPATH () IS\n"
+				   "BEGIN\n"
+				   "UPDATE SYS_DATAFILES"
+				   " SET PATH = :remote_path\n"
+				   " WHERE SPACE = :space;\n"
+				   "END;\n", FALSE, trx);
+	} else {
+		/* A record for this space ID was not found in
+		SYS_DATAFILES. Assume the record is also missing in
+		SYS_TABLESPACES.  Insert records onto them both.
+		Note, we do not know the value of flags. */
+		dict_create_add_tablespace_to_dictionary(
+			space, name, 0, trx);
+
+		dict_create_add_datafile_to_dictionary(
+			space, remote_filepath, trx);
+	}
+	trx_commit_for_mysql(trx);
+
+	/* We just updated SYS_DATAFILES due to the contents in a link
+	file.  Make a note that we did this. */
+	ut_print_timestamp(stderr);
+	fputs("  InnoDB: Note: The InnoDB data dictionary for table ",
+	      stderr);
+	ut_print_filename(stderr, name);
+	fprintf(stderr, "\n  InnoDB: was updated to use tablespace %s.\n",
+		remote_filepath);
+
+	return remote_filepath;
 }
 
 /********************************************************************//**
@@ -992,7 +1128,8 @@ loop:
 			/* Use the remote filepath if needed. */
 			char*	filepath = NULL;
 			if (DICT_TF_HAS_DATA_DIR(flags)) {
-				dict_get_first_path(space_id, &filepath);
+				filepath = dict_get_first_path(
+					space_id, name);
 			}
 
 			/* filepath can be NULL in this call. */
@@ -2109,7 +2246,8 @@ err_exit:
 
 			/* Use the remote filepath if needed. */
 			if (DICT_TF_HAS_DATA_DIR(table->flags)) {
-				dict_get_first_path(table->space, &filepath);
+				filepath = dict_get_first_path(
+					table->space, name);
 				if (filepath) {
 					dict_save_data_dir_path(
 						table, filepath);

=== modified file 'storage/innobase/dict/dict0stats.cc'
--- a/storage/innobase/dict/dict0stats.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/dict/dict0stats.cc	revid:kevin.lewis@stripped
@@ -408,14 +408,14 @@ dict_stats_analyze_index_level(
 					distinct keys for all prefixes */
 	ib_uint64_t*	total_recs,	/*!< out: total number of records */
 	ib_uint64_t*	total_pages,	/*!< out: total number of pages */
-	dyn_array_t*	n_diff_boundaries)/*!< out: boundaries of the groups
+	dyn_array_t*	n_diff_boundaries,/*!< out: boundaries of the groups
 					of distinct keys */
+	mtr_t*		mtr)		/*!< in/out: mini-transaction */
 {
 	ulint		n_uniq;
 	mem_heap_t*	heap;
 	dtuple_t*	dtuple;
 	btr_pcur_t	pcur;
-	mtr_t		mtr;
 	const page_t*	page;
 	const rec_t*	rec;
 	const rec_t*	prev_rec;
@@ -426,6 +426,9 @@ dict_stats_analyze_index_level(
 	DEBUG_PRINTF("    %s(table=%s, index=%s, level=%lu)\n", __func__,
 		     index->table->name, index->name, level);
 
+	ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
+				MTR_MEMO_S_LOCK));
+
 	n_uniq = dict_index_get_n_unique(index);
 
 	/* elements in the n_diff array are 1..n_uniq (inclusive) */
@@ -451,18 +454,17 @@ dict_stats_analyze_index_level(
 	dict_table_copy_types(dtuple, index->table);
 	dtuple_set_info_bits(dtuple, REC_INFO_MIN_REC_FLAG);
 
-	mtr_start(&mtr);
-
-	btr_pcur_open_low(index, level, dtuple, PAGE_CUR_LE, BTR_SEARCH_LEAF,
-			  &pcur, __FILE__, __LINE__, &mtr);
+	btr_pcur_open_low(index, level, dtuple, PAGE_CUR_LE,
+			  BTR_SEARCH_LEAF | BTR_ALREADY_S_LATCHED,
+			  &pcur, __FILE__, __LINE__, mtr);
 
 	page = btr_pcur_get_page(&pcur);
 
 	/* check that we are indeed on the desired level */
-	ut_a(btr_page_get_level(page, &mtr) == level);
+	ut_a(btr_page_get_level(page, mtr) == level);
 
 	/* there should not be any pages on the left */
-	ut_a(btr_page_get_prev(page, &mtr) == FIL_NULL);
+	ut_a(btr_page_get_prev(page, mtr) == FIL_NULL);
 
 	/* check whether the first record on the leftmost page is marked
 	as such, if we are on a non-leaf level */
@@ -491,7 +493,7 @@ dict_stats_analyze_index_level(
 	X and the fist on page X+1 */
 	for (;
 	     btr_pcur_is_on_user_rec(&pcur);
-	     btr_pcur_move_to_next_user_rec(&pcur, &mtr)) {
+	     btr_pcur_move_to_next_user_rec(&pcur, mtr)) {
 
 		ulint	matched_fields = 0;
 		ulint	matched_bytes = 0;
@@ -508,13 +510,6 @@ dict_stats_analyze_index_level(
 			(*total_pages)++;
 		}
 
-		/* skip delete-marked records */
-		if (rec_get_deleted_flag(rec, page_is_comp(
-				btr_pcur_get_page(&pcur)))) {
-
-			continue;
-		}
-
 		offsets_rec = rec_get_offsets(rec, index, offsets_rec_onstack,
 					      n_uniq, &heap);
 
@@ -572,7 +567,7 @@ dict_stats_analyze_index_level(
 				n_diff[i]++;
 			}
 		} else {
-			/* this is the first non-delete marked record */
+			/* this is the first record */
 			for (i = 1; i <= n_uniq; i++) {
 				n_diff[i] = 1;
 			}
@@ -671,8 +666,6 @@ dict_stats_analyze_index_level(
 
 	btr_pcur_close(&pcur);
 
-	mtr_commit(&mtr);
-
 	if (prev_rec_buf != NULL) {
 
 		mem_free(prev_rec_buf);
@@ -965,7 +958,7 @@ dict_stats_analyze_index_for_n_prefix(
 						records on the given level,
 						when looking at the first
 						n_prefix columns */
-	dyn_array_t*	boundaries)		/*!< in: array that contains
+	dyn_array_t*	boundaries,		/*!< in: array that contains
 						n_diff_for_this_prefix
 						integers each of which
 						represents the index (on the
@@ -974,11 +967,11 @@ dict_stats_analyze_index_for_n_prefix(
 						from 0) of the last record
 						from each group of distinct
 						keys */
+	mtr_t*		mtr)			/*!< in/out: mini-transaction */
 {
 	mem_heap_t*	heap;
 	dtuple_t*	dtuple;
 	btr_pcur_t	pcur;
-	mtr_t		mtr;
 	const page_t*	page;
 	ib_uint64_t	rec_idx;
 	ib_uint64_t	last_idx_on_level;
@@ -993,6 +986,9 @@ dict_stats_analyze_index_for_n_prefix(
 		     n_prefix, n_diff_for_this_prefix);
 #endif
 
+	ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
+				MTR_MEMO_S_LOCK));
+
 	/* if some of those is 0 then this means that there is exactly one
 	page in the B-tree and it is empty and we should have done full scan
 	and should not be here */
@@ -1011,18 +1007,17 @@ dict_stats_analyze_index_for_n_prefix(
 	dict_table_copy_types(dtuple, index->table);
 	dtuple_set_info_bits(dtuple, REC_INFO_MIN_REC_FLAG);
 
-	mtr_start(&mtr);
-
-	btr_pcur_open_low(index, level, dtuple, PAGE_CUR_LE, BTR_SEARCH_LEAF,
-			  &pcur, __FILE__, __LINE__, &mtr);
+	btr_pcur_open_low(index, level, dtuple, PAGE_CUR_LE,
+			  BTR_SEARCH_LEAF | BTR_ALREADY_S_LATCHED,
+			  &pcur, __FILE__, __LINE__, mtr);
 
 	page = btr_pcur_get_page(&pcur);
 
 	/* check that we are indeed on the desired level */
-	ut_a(btr_page_get_level(page, &mtr) == level);
+	ut_a(btr_page_get_level(page, mtr) == level);
 
 	/* there should not be any pages on the left */
-	ut_a(btr_page_get_prev(page, &mtr) == FIL_NULL);
+	ut_a(btr_page_get_prev(page, mtr) == FIL_NULL);
 
 	/* check whether the first record on the leftmost page is marked
 	as such, if we are on a non-leaf level */
@@ -1108,7 +1103,7 @@ dict_stats_analyze_index_for_n_prefix(
 		while (rec_idx < dive_below_idx
 		       && btr_pcur_is_on_user_rec(&pcur)) {
 
-			btr_pcur_move_to_next_user_rec(&pcur, &mtr);
+			btr_pcur_move_to_next_user_rec(&pcur, mtr);
 			rec_idx++;
 		}
 
@@ -1127,7 +1122,7 @@ dict_stats_analyze_index_for_n_prefix(
 		ib_uint64_t	n_diff_on_leaf_page;
 
 		n_diff_on_leaf_page = dict_stats_analyze_index_below_cur(
-			btr_pcur_get_btr_cur(&pcur), n_prefix, &mtr);
+			btr_pcur_get_btr_cur(&pcur), n_prefix, mtr);
 
 		/* We adjust n_diff_on_leaf_page here to avoid counting
 		one record twice - once as the last on some page and once
@@ -1178,8 +1173,6 @@ dict_stats_analyze_index_for_n_prefix(
 
 	btr_pcur_close(&pcur);
 
-	mtr_commit(&mtr);
-
 	mem_heap_free(heap);
 }
 /* @} */
@@ -1221,9 +1214,11 @@ dict_stats_analyze_index(
 		size = btr_get_size(index, BTR_N_LEAF_PAGES, &mtr);
 	}
 
+	/* Release the X locks on the root page taken by btr_get_size() */
+	mtr_commit(&mtr);
+
 	switch (size) {
 	case ULINT_UNDEFINED:
-		mtr_commit(&mtr);
 		/* Fake some statistics. */
 		index->stat_index_size = index->stat_n_leaf_pages = 1;
 
@@ -1242,9 +1237,11 @@ dict_stats_analyze_index(
 
 	index->stat_n_leaf_pages = size;
 
-	root_level = btr_page_get_level(btr_root_get(index, &mtr), &mtr);
+	mtr_start(&mtr);
 
-	mtr_commit(&mtr);
+	mtr_s_lock(dict_index_get_lock(index), &mtr);
+
+	root_level = btr_height_get(index, &mtr);
 
 	n_uniq = dict_index_get_n_unique(index);
 
@@ -1276,12 +1273,15 @@ dict_stats_analyze_index(
 					       index->stat_n_diff_key_vals,
 					       &total_recs,
 					       &total_pages,
-					       NULL /*boundaries not needed*/);
+					       NULL /*boundaries not needed*/,
+					       &mtr);
 
 		for (i = 1; i <= n_uniq; i++) {
 			index->stat_n_sample_sizes[i] = total_pages;
 		}
 
+		mtr_commit(&mtr);
+
 		return;
 	}
 	/* else */
@@ -1322,6 +1322,23 @@ dict_stats_analyze_index(
 			     "distinct records, n_prefix=%lu\n",
 			     __func__, N_DIFF_REQUIRED, n_prefix);
 
+		/* Commit the mtr to release the tree S lock to allow
+		other threads to do some work too. */
+		mtr_commit(&mtr);
+		mtr_start(&mtr);
+		mtr_s_lock(dict_index_get_lock(index), &mtr);
+		if (root_level != btr_height_get(index, &mtr)) {
+			/* Just quit if the tree has changed beyond
+			recognition here. The old stats from previous
+			runs will remain in the values that we have
+			not calculated yet. Initially when the index
+			object is created the stats members are given
+			some sensible values so leaving them untouched
+			here even the first time will not cause us to
+			read uninitialized memory later. */
+			break;
+		}
+
 		/* check whether we should pick the current level;
 		we pick level 1 even if it does not have enough
 		distinct records because we do not want to scan the
@@ -1346,6 +1363,7 @@ dict_stats_analyze_index(
 			level_is_analyzed = FALSE;
 		}
 
+		/* descend into the tree, searching for "good enough" level */
 		for (;;) {
 
 			/* make sure we do not scan the leaf level
@@ -1385,7 +1403,8 @@ dict_stats_analyze_index(
 						       n_diff_on_level,
 						       &total_recs,
 						       &total_pages,
-						       n_diff_boundaries);
+						       n_diff_boundaries,
+						       &mtr);
 
 			level_is_analyzed = TRUE;
 
@@ -1422,9 +1441,11 @@ found_level:
 		dict_stats_analyze_index_for_n_prefix(
 			index, level, total_recs, n_prefix,
 			n_diff_on_level[n_prefix],
-			&n_diff_boundaries[n_prefix]);
+			&n_diff_boundaries[n_prefix], &mtr);
 	}
 
+	mtr_commit(&mtr);
+
 	for (i = 1; i <= n_uniq; i++) {
 		dyn_array_free(&n_diff_boundaries[i]);
 	}

=== modified file 'storage/innobase/fil/fil0fil.cc'
--- a/storage/innobase/fil/fil0fil.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/fil/fil0fil.cc	revid:kevin.lewis@stripped
@@ -2241,7 +2241,7 @@ fil_op_log_parse_or_replay(
 	switch (type) {
 	case MLOG_FILE_DELETE:
 		if (fil_tablespace_exists_in_mem(space_id)) {
-			ut_a(fil_delete_tablespace(space_id));
+			ut_a(fil_delete_tablespace(space_id, TRUE));
 		}
 
 		break;
@@ -2320,7 +2320,9 @@ UNIV_INTERN
 ibool
 fil_delete_tablespace(
 /*==================*/
-	ulint	id)	/*!< in: space id */
+	ulint	id,		/*!< in: space id */
+	ibool	evict_all)	/*!< in: TRUE if we want all pages
+				evicted from LRU. */
 {
 	ibool		success;
 	fil_space_t*	space;
@@ -2447,7 +2449,10 @@ try_again:
 	completely and permanently. The flag is_being_deleted also prevents
 	fil_flush() from being applied to this tablespace. */
 
-	buf_LRU_invalidate_tablespace(id);
+	buf_LRU_flush_or_remove_pages(
+		id, evict_all
+		? BUF_REMOVE_ALL_NO_WRITE
+		: BUF_REMOVE_FLUSH_NO_WRITE);
 #endif
 	/* printf("Deleting tablespace %s id %lu\n", space->name, id); */
 
@@ -2535,7 +2540,7 @@ fil_discard_tablespace(
 {
 	ibool	success;
 
-	success = fil_delete_tablespace(id);
+	success = fil_delete_tablespace(id, TRUE);
 
 	if (!success) {
 		fprintf(stderr,
@@ -2897,42 +2902,48 @@ fil_delete_link_file(
 }
 
 /*******************************************************************//**
-Reads an InnoDB Symbolic Link (ISL) file.  It is always created
-under the 'datadir' of MySQL.  The caller must free the memory of the
-null-terminated path returned if it is not null.
-@return	own: true if link file is found and read into *filepath. */
+Reads an InnoDB Symbolic Link (ISL) file.
+It is always created under the 'datadir' of MySQL.  The name is of the
+form {databasename}/{tablename}. and the isl file is expected to be in a
+'{databasename}' directory called '{tablename}.isl'. The caller must free
+the memory of the null-terminated path returned if it is not null.
+@return	own: filepath found in link file, NULL if not found. */
 UNIV_INTERN
-bool
+char*
 fil_read_link_file(
 /*===============*/
-	const char*	link_filepath,	/*!< in: pathname of link file */
-	char**		filepath)	/*!< out: pathname of tablespace */
+	const char*	name)		/*!< in: tablespace name */
 {
+	char*		filepath = NULL;
+	char*		link_filepath;
 	FILE*		file = NULL;
-	char*		buf;
+
+	/* The .isl file is in the 'normal' tablespace location. */
+	link_filepath = fil_make_isl_name(name);
 
 	file = fopen(link_filepath, "r+b");
 
-	if (file == NULL) {
-		/* file is not found. */
-		*filepath = NULL;
-		return(false);
-	}
+	mem_free(link_filepath);
 
-	buf = static_cast<char*>(mem_alloc(OS_FILE_MAX_PATH));
-
-	os_file_read_string(file, buf, OS_FILE_MAX_PATH);
-	if (strlen(buf)) {
-		*filepath = buf;
-		srv_normalize_path_for_win(*filepath);
-	} else {
-		mem_free(buf);
-		*filepath = NULL;
-	}
+	if (file) {
+		filepath = static_cast<char*>(mem_alloc(OS_FILE_MAX_PATH));
+
+		os_file_read_string(file, filepath, OS_FILE_MAX_PATH);
+		fclose(file);
 
-	fclose(file);
+		if (strlen(filepath)) {
+			/* Trim whitespace from end of filepath */
+			ulint lastch = strlen(filepath) - 1;
+			while (lastch > 4 && filepath[lastch] <= 0x20) {
+				filepath[lastch--] = 0x00;
+			}
+			srv_normalize_path_for_win(filepath);
+		} else {
+			mem_free(filepath);
+		}
+	}
 
-	return(NULL != *filepath);
+	return(filepath);
 }
 
 /*******************************************************************//**
@@ -2950,20 +2961,15 @@ fil_open_linked_file(
 {
 	ibool		success;
 	ulint		err;
-	char*		link_filepath;
-
-	/* The .isl file is in the 'normal' tablespace location. */
-	link_filepath = fil_make_isl_name(tablename);
 
-	if (!fil_read_link_file(link_filepath, remote_filepath)) {
-		mem_free(link_filepath);
+	*remote_filepath = fil_read_link_file(tablename);
+	if (*remote_filepath == NULL) {
 		return(FALSE);
 	}
 
 	/* A link file existed, make sure it is not the file we are
 	already using. */
 	if (strcmp(filepath, *remote_filepath) == 0) {
-		mem_free(link_filepath);
 		mem_free(*remote_filepath);
 		*remote_filepath = NULL;
 		return (FALSE);
@@ -2977,6 +2983,8 @@ fil_open_linked_file(
 		&success);
 
 	if (!success) {
+		char*	link_filepath = fil_make_isl_name(tablename);
+
 		/* The following call prints an error message */
 		err = os_file_get_last_error(TRUE);
 
@@ -2991,12 +2999,11 @@ fil_open_linked_file(
 		ut_print_filename(stderr, *remote_filepath);
 		fputs(" could not be opened.\n", stderr);
 
+		mem_free(link_filepath);
 		mem_free(*remote_filepath);
 		*remote_filepath = NULL;
 	}
 
-	mem_free(link_filepath);
-
 	return(success);
 }
 

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/handler/ha_innodb.cc	revid:kevin.lewis@stripped
@@ -8632,8 +8632,9 @@ ha_innobase::update_create_info(
 
 			if (prebuilt->table->tablespace_discarded) {
 				mutex_enter(&(dict_sys->mutex));
-				dict_get_first_path(
-					prebuilt->table->space, &path);
+				path = dict_get_first_path(
+					prebuilt->table->space,
+					prebuilt->table->name);
 				mutex_exit(&dict_sys->mutex);
 			} else {
 				path = fil_space_get_first_path(

=== modified file 'storage/innobase/handler/handler0alter.cc'
--- a/storage/innobase/handler/handler0alter.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/handler/handler0alter.cc	revid:kevin.lewis@stripped
@@ -677,7 +677,9 @@ innobase_create_index_def(
 		index->ind_type |= DICT_CLUSTERED;
 	} else if (key->flags & HA_FULLTEXT) {
 		DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK
-			      & ~(HA_FULLTEXT | HA_BINARY_PACK_KEY)));
+			      & ~(HA_FULLTEXT
+				  | HA_PACK_KEY
+				  | HA_BINARY_PACK_KEY)));
 		DBUG_ASSERT(!(key->flags & HA_NOSAME));
 		DBUG_ASSERT(!index->ind_type);
 		index->ind_type |= DICT_FTS;
@@ -1878,7 +1880,9 @@ err_exit_no_heap:
 			fulltext indexes are not supported. */
 			DBUG_ASSERT(!(key->flags & HA_NOSAME));
 			DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK
-				      & ~(HA_FULLTEXT | HA_BINARY_PACK_KEY)));
+				      & ~(HA_FULLTEXT
+					  | HA_PACK_KEY
+					  | HA_BINARY_PACK_KEY)));
 			continue;
 		}
 
@@ -2019,7 +2023,9 @@ func_exit:
 
 		if (key->flags & HA_FULLTEXT) {
 			DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK
-				      & ~(HA_FULLTEXT | HA_BINARY_PACK_KEY)));
+				      & ~(HA_FULLTEXT
+					  | HA_PACK_KEY
+					  | HA_BINARY_PACK_KEY)));
 			num_fts_index++;
 		}
 	}

=== modified file 'storage/innobase/include/btr0btr.h'
--- a/storage/innobase/include/btr0btr.h	revid:kevin.lewis@stripped
+++ b/storage/innobase/include/btr0btr.h	revid:kevin.lewis@stripped
@@ -96,6 +96,10 @@ insert/delete buffer when the record is 
 buffer when the record is not in the buffer pool. */
 #define BTR_DELETE		8192
 
+/** In the case of BTR_SEARCH_LEAF, the caller is already holding an S latch
+on the index tree */
+#define BTR_ALREADY_S_LATCHED	16384
+
 /**************************************************************//**
 Report that an index page is corrupted. */
 UNIV_INTERN
@@ -211,6 +215,18 @@ btr_root_get(
 	dict_index_t*	index,	/*!< in: index tree */
 	mtr_t*		mtr);	/*!< in: mtr */
 /**************************************************************//**
+Gets the height of the B-tree (the level of the root, when the leaf
+level is assumed to be 0). The caller must hold an S or X latch on
+the index.
+@return	tree height (level of the root) */
+UNIV_INTERN
+ulint
+btr_height_get(
+/*===========*/
+	dict_index_t*	index,	/*!< in: index tree */
+	mtr_t*		mtr)	/*!< in/out: mini-transaction */
+	__attribute__((nonnull, warn_unused_result));
+/**************************************************************//**
 Gets a buffer page and declares its latching order level. */
 UNIV_INLINE
 buf_block_t*

=== modified file 'storage/innobase/include/buf0lru.h'
--- a/storage/innobase/include/buf0lru.h	revid:kevin.lewis@stripped
+++ b/storage/innobase/include/buf0lru.h	revid:kevin.lewis@stripped
@@ -49,15 +49,14 @@ These are low-level functions
 #define BUF_LRU_OLD_MIN_LEN	512	/* 8 megabytes of 16k pages */
 
 /******************************************************************//**
-Invalidates all pages belonging to a given tablespace when we are deleting
-the data file(s) of that tablespace. A PROBLEM: if readahead is being started,
-what guarantees that it will not try to read in pages after this operation has
-completed? */
+Removes all pages belonging to a given tablespace. */
 UNIV_INTERN
 void
-buf_LRU_invalidate_tablespace(
+buf_LRU_flush_or_remove_pages(
 /*==========================*/
-	ulint	id);	/*!< in: space id */
+	ulint			id,	/*!< in: space id */
+	enum buf_remove_t	buf_remove);/*!< in: remove or flush
+					strategy */
 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 /********************************************************************//**
 Insert a compressed block into buf_pool->zip_clean in the LRU order. */

=== modified file 'storage/innobase/include/buf0types.h'
--- a/storage/innobase/include/buf0types.h	revid:kevin.lewis@stripped
+++ b/storage/innobase/include/buf0types.h	revid:kevin.lewis@stripped
@@ -80,9 +80,17 @@ enum srv_checksum_algorithm_enum {
 	SRV_CHECKSUM_ALGORITHM_STRICT_NONE	/*!< Write none, allow none
 						when reading */
 };
-
 typedef enum srv_checksum_algorithm_enum	srv_checksum_algorithm_t;
 
+/** Algorithm to remove the pages for a tablespace from the buffer pool.
+@See buf_LRU_flush_or_remove_pages(). */
+enum buf_remove_t {
+	BUF_REMOVE_ALL_NO_WRITE,	/*!< Remove all pages from the buffer
+					pool, don't write or sync to disk */
+	BUF_REMOVE_FLUSH_NO_WRITE,	/*!< Remove only, from the flush list,
+					don't write or sync to disk */
+};
+
 /** Parameters of binary buddy system for compressed pages (buf0buddy.h) */
 /* @{ */
 /** Zip shift value for the smallest page size */

=== modified file 'storage/innobase/include/dict0crea.h'
--- a/storage/innobase/include/dict0crea.h	revid:kevin.lewis@stripped
+++ b/storage/innobase/include/dict0crea.h	revid:kevin.lewis@stripped
@@ -146,7 +146,7 @@ db_err
 dict_create_add_tablespace_to_dictionary(
 /*=====================================*/
 	ulint		space,		/*!< in: tablespace id */
-	char*		name,		/*!< in: tablespace name */
+	const char*	name,		/*!< in: tablespace name */
 	ulint		flags,		/*!< in: tablespace flags */
 	trx_t*		trx);		/*!< in: transaction */
 /********************************************************************//**
@@ -158,7 +158,7 @@ db_err
 dict_create_add_datafile_to_dictionary(
 /*===================================*/
 	ulint		space,		/*!< in: tablespace id */
-	char*		path,		/*!< in: tablespace path */
+	const char*	path,		/*!< in: tablespace path */
 	trx_t*		trx);		/*!< in: transaction */
 
 /********************************************************************//**

=== modified file 'storage/innobase/include/dict0load.h'
--- a/storage/innobase/include/dict0load.h	revid:kevin.lewis@stripped
+++ b/storage/innobase/include/dict0load.h	revid:kevin.lewis@stripped
@@ -29,6 +29,7 @@ Created 4/24/1996 Heikki Tuuri
 
 #include "univ.i"
 #include "dict0types.h"
+#include "trx0types.h"
 #include "ut0byte.h"
 #include "mem0mem.h"
 #include "btr0types.h"
@@ -363,17 +364,28 @@ dict_process_sys_datafiles(
 	ulint*		space,		/*!< out: pace id */
 	const char**	path);		/*!< out: datafile path */
 /********************************************************************//**
+Look up a tablename in SYS_TABLES and return the space ID.
+@return TRUE if tablename was found and space is set, FALSE if not */
+UNIV_INTERN
+bool
+dict_get_space_from_sys_tables(
+/*===========================*/
+	const char*	name,		/*!< in: table name */
+	ulint*		space);		/*!< out: space ID */
+/********************************************************************//**
 Get the filepath for a spaceid from SYS_DATAFILES. This function provides
 a temporary heap which is used for the table lookup, but not for the path.
 The caller must free the memory for the path returned. This function can
 return NULL if the space ID is not found in SYS_DATAFILES, then the caller
-will assume that the ibd file is in the normal datadir. */
+will assume that the ibd file is in the normal datadir.
+@return	own: A copy of the first datafile found in SYS_DATAFILES.PATH for
+the given space ID. NULL if space ID is zero or not found. */
 UNIV_INTERN
-void
+char*
 dict_get_first_path(
 /*================*/
 	ulint		space,	/*!< in: space id */
-	char**		path);	/*!< out: datafile path for this tablespace */
+	const char*	name);	/*!< in: tablespace name */
 
 #ifndef UNIV_NONINL
 #include "dict0load.ic"

=== modified file 'storage/innobase/include/fil0fil.h'
--- a/storage/innobase/include/fil0fil.h	revid:kevin.lewis@stripped
+++ b/storage/innobase/include/fil0fil.h	revid:kevin.lewis@stripped
@@ -419,7 +419,9 @@ UNIV_INTERN
 ibool
 fil_delete_tablespace(
 /*==================*/
-	ulint	id);	/*!< in: space id */
+	ulint	id,		/*!< in: space id */
+	ibool	evict_all);	/*!< in: TRUE if we want all pages
+				evicted from LRU. */
 #ifndef UNIV_HOTBACKUP
 /*******************************************************************//**
 Discards a single-table tablespace. The tablespace must be cached in the
@@ -496,6 +498,18 @@ fil_delete_link_file(
 /*==================*/
 	const char*	tablename);	/*!< in: name of table */
 /*******************************************************************//**
+Reads an InnoDB Symbolic Link (ISL) file.
+It is always created under the 'datadir' of MySQL.  The name is of the
+form {databasename}/{tablename}. and the isl file is expected to be in a
+'{databasename}' directory called '{tablename}.isl'. The caller must free
+the memory of the null-terminated path returned if it is not null.
+@return	own: filepath found in link file, NULL if not found. */
+UNIV_INTERN
+char*
+fil_read_link_file(
+/*===============*/
+	const char*	name);		/*!< in: tablespace name */
+/*******************************************************************//**
 Creates a new single-table tablespace to a database directory of MySQL.
 Database directories are under the 'datadir' of MySQL. The datadir is the
 directory of a running mysqld program. We can refer to it by simply the

=== modified file 'storage/innobase/row/row0mysql.cc'
--- a/storage/innobase/row/row0mysql.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/row/row0mysql.cc	revid:kevin.lewis@stripped
@@ -2236,7 +2236,8 @@ err_exit:
 	case DB_TOO_MANY_CONCURRENT_TRXS:
 		/* We already have .ibd file here. it should be deleted. */
 
-		if (table->space && !fil_delete_tablespace(table->space)) {
+		if (table->space && !fil_delete_tablespace(table->space,
+							   FALSE)) {
 			ut_print_timestamp(stderr);
 			fprintf(stderr,
 				"  InnoDB: Error: not able to"
@@ -2853,7 +2854,8 @@ row_import_tablespace_for_mysql(
 	const char*	name,	/*!< in: table name */
 	trx_t*		trx)	/*!< in: transaction handle */
 {
-	dict_table_t*	table;
+	dict_table_t*	table = NULL;
+	ulint		space;
 	char*		filepath	= NULL;
 	ibool		success;
 	lsn_t		current_lsn;
@@ -2870,13 +2872,15 @@ row_import_tablespace_for_mysql(
 
 	row_mysql_lock_data_dictionary(trx);
 
-	table = dict_table_open_on_name_no_stats(name, TRUE, FALSE,
-						 DICT_ERR_IGNORE_NONE);
+	/* If the table is stored in a remote tablespace, we need to
+	determine that filepath from the link file and system tables.
+	Find the space ID in SYS_TABLES since this is an ALTER TABLE. */
+	if (!dict_get_space_from_sys_tables(name, &space)) {
+		goto table_not_found;
+	}
+	filepath = dict_get_first_path(space, name);
 
-	/* Use the remote filepath if needed. */
-	if (DICT_TF_HAS_DATA_DIR(table->flags)) {
-		dict_get_first_path(table->space, &filepath);
-	} else {
+	if (!filepath) {
 		filepath = fil_make_ibd_name(name, FALSE);
 	}
 	ut_a(filepath);
@@ -2905,13 +2909,14 @@ row_import_tablespace_for_mysql(
 
 		err = DB_ERROR;
 
-		row_mysql_lock_data_dictionary(trx);
-		table = NULL;
-
 		goto funct_exit;
 	}
 
+	table = dict_table_open_on_name_no_stats(name, TRUE, FALSE,
+						 DICT_ERR_IGNORE_NONE);
+
 	if (!table) {
+table_not_found:
 		ut_print_timestamp(stderr);
 		fputs("  InnoDB: table ", stderr);
 		ut_print_name(stderr, trx, TRUE, name);
@@ -3934,7 +3939,7 @@ check_next_foreign:
 					"InnoDB: of table ");
 				ut_print_name(stderr, trx, TRUE, name);
 				fprintf(stderr, ".\n");
-			} else if (!fil_delete_tablespace(space_id)) {
+			} else if (!fil_delete_tablespace(space_id, FALSE)) {
 				fprintf(stderr,
 					"InnoDB: We removed now the InnoDB"
 					" internal data dictionary entry\n"

=== modified file 'support-files/CMakeLists.txt'
--- a/support-files/CMakeLists.txt	revid:kevin.lewis@stripped
+++ b/support-files/CMakeLists.txt	revid:kevin.lewis@stripped
@@ -69,7 +69,14 @@ IF(UNIX)
   INSTALL(FILES mysql.m4 DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development)
   CONFIGURE_FILE(MySQL-shared-compat.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/MySQL-shared-compat.spec @ONLY)
   CONFIGURE_FILE(mysql.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/mysql.spec @ONLY)
-  CONFIGURE_FILE(mysql.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/mysql.${VERSION}.spec @ONLY)
+  
+  SET(SPECFILENAME "mysql.${VERSION}.spec")
+  IF("${VERSION}" MATCHES "-ndb-")
+    STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}")
+    SET(SPECFILENAME "mysql-cluster-${NDBVERSION}.spec")
+  ENDIF()
+  CONFIGURE_FILE(mysql.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/${SPECFILENAME} @ONLY)
+  
   CONFIGURE_FILE(MySQL-shared-compat.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/MySQL-shared-compat.spec @ONLY)
 
   SET(bindir ${prefix}/${INSTALL_BINDIR})

=== modified file 'support-files/build-tags'
--- a/support-files/build-tags	revid:kevin.lewis@stripped
+++ b/support-files/build-tags	revid:kevin.lewis@stripped
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 rm -f TAGS
-filter='\.cpp$\|\.cc$\|\.c$\|\.h$\|\.yy$'
+filter='\.cpp$\|\.cc$\|\.c$\|\.h$\|\.yy$\|\.hpp$'
 
 list="find . -type f"
 bzr root >/dev/null 2>/dev/null && list="bzr ls --from-root -R --kind=file --versioned"

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (kevin.lewis:3824 to 3826) kevin.lewis28 Mar