List:Commits« Previous MessageNext Message »
From:MySQL Build Team Date:November 1 2010 6:59pm
Subject:bzr push into mysql-5.1 branch (build:3472 to 3473)
View as plain text  
 3473 karen.langford@stripped	2010-11-01 [merge]
      Merge from mysql-5.1.52-release

    added:
      mysql-test/r/partition_binlog_stmt.result
      mysql-test/suite/innodb/r/innodb_bug56716.result
      mysql-test/suite/innodb/r/innodb_bug57255.result
      mysql-test/suite/innodb/t/innodb_bug56716.test
      mysql-test/suite/innodb/t/innodb_bug57255.test
      mysql-test/suite/innodb_plugin/r/innodb_bug53756.result
      mysql-test/suite/innodb_plugin/r/innodb_bug56716.result
      mysql-test/suite/innodb_plugin/r/innodb_bug57255.result
      mysql-test/suite/innodb_plugin/t/innodb_bug53756-master.opt
      mysql-test/suite/innodb_plugin/t/innodb_bug53756.test
      mysql-test/suite/innodb_plugin/t/innodb_bug56716.test
      mysql-test/suite/innodb_plugin/t/innodb_bug57255.test
      mysql-test/t/partition_binlog_stmt.test
    modified:
      BUILD/build_mccge.sh
      BUILD/check-cpu
      client/mysqltest.cc
      config/ac-macros/maintainer.m4
      dbug/dbug.c
      include/mysql.h
      include/mysql.h.pp
      include/sha1.h
      libmysql/libmysql.c
      mysql-test/collections/default.daily
      mysql-test/include/index_merge_ror_cpk.inc
      mysql-test/include/setup_fake_relay_log.inc
      mysql-test/lib/mtr_cases.pm
      mysql-test/mysql-test-run.pl
      mysql-test/r/index_merge_innodb.result
      mysql-test/r/index_merge_myisam.result
      mysql-test/r/merge.result
      mysql-test/r/multi_update.result
      mysql-test/r/mysqltest.result
      mysql-test/r/order_by.result
      mysql-test/r/partition.result
      mysql-test/r/partition_error.result
      mysql-test/r/partition_hash.result
      mysql-test/r/partition_innodb.result
      mysql-test/r/partition_pruning.result
      mysql-test/r/partition_range.result
      mysql-test/r/ps.result
      mysql-test/r/ps_2myisam.result
      mysql-test/r/ps_3innodb.result
      mysql-test/r/ps_4heap.result
      mysql-test/r/ps_5merge.result
      mysql-test/r/row.result
      mysql-test/r/subselect.result
      mysql-test/r/subselect4.result
      mysql-test/r/trigger_notembedded.result
      mysql-test/r/type_timestamp.result
      mysql-test/r/variables_debug.result
      mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
      mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
      mysql-test/suite/innodb/r/innodb_mysql.result
      mysql-test/suite/innodb/t/innodb_bug53756.test
      mysql-test/suite/innodb/t/innodb_mysql.test
      mysql-test/suite/innodb_plugin/r/innodb_mysql.result
      mysql-test/suite/innodb_plugin/t/innodb_mysql.test
      mysql-test/suite/ndb/r/ps_7ndb.result
      mysql-test/suite/parts/r/partition_alter3_innodb.result
      mysql-test/suite/parts/r/partition_alter3_myisam.result
      mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result
      mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
      mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test
      mysql-test/suite/sys_vars/t/secure_file_priv.test
      mysql-test/t/merge.test
      mysql-test/t/multi_update.test
      mysql-test/t/mysqltest.test
      mysql-test/t/order_by.test
      mysql-test/t/partition.test
      mysql-test/t/partition_error.test
      mysql-test/t/partition_pruning.test
      mysql-test/t/ps.test
      mysql-test/t/row.test
      mysql-test/t/subselect4.test
      mysql-test/t/trigger_notembedded.test
      mysql-test/t/type_timestamp.test
      mysql-test/t/variables_debug.test
      mysys/my_getopt.c
      mysys/sha1.c
      sql/ha_partition.cc
      sql/ha_partition.h
      sql/item.cc
      sql/item_cmpfunc.cc
      sql/item_func.cc
      sql/item_subselect.cc
      sql/item_timefunc.cc
      sql/item_timefunc.h
      sql/log.cc
      sql/net_serv.cc
      sql/opt_range.cc
      sql/sql_cache.cc
      sql/sql_class.cc
      sql/sql_load.cc
      sql/sql_prepare.cc
      sql/sql_select.cc
      sql/sql_table.cc
      sql/sql_trigger.cc
      sql/table.cc
      sql/table.h
      storage/innobase/btr/btr0btr.c
      storage/innobase/btr/btr0cur.c
      storage/innobase/btr/btr0pcur.c
      storage/innobase/btr/btr0sea.c
      storage/innobase/buf/buf0flu.c
      storage/innobase/eval/eval0eval.c
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/include/ut0rnd.ic
      storage/innobase/lock/lock0lock.c
      storage/innobase/log/log0recv.c
      storage/innobase/os/os0file.c
      storage/innobase/que/que0que.c
      storage/innobase/row/row0mysql.c
      storage/innobase/row/row0purge.c
      storage/innobase/row/row0sel.c
      storage/innobase/row/row0umod.c
      storage/innobase/row/row0upd.c
      storage/innobase/row/row0vers.c
      storage/innobase/trx/trx0purge.c
      storage/innobase/trx/trx0roll.c
      storage/innobase/trx/trx0sys.c
      storage/innobase/trx/trx0trx.c
      storage/innobase/trx/trx0undo.c
      storage/innodb_plugin/ChangeLog
      storage/innodb_plugin/btr/btr0btr.c
      storage/innodb_plugin/btr/btr0cur.c
      storage/innodb_plugin/btr/btr0pcur.c
      storage/innodb_plugin/btr/btr0sea.c
      storage/innodb_plugin/buf/buf0flu.c
      storage/innodb_plugin/dict/dict0crea.c
      storage/innodb_plugin/dict/dict0dict.c
      storage/innodb_plugin/dict/dict0load.c
      storage/innodb_plugin/eval/eval0eval.c
      storage/innodb_plugin/handler/ha_innodb.cc
      storage/innodb_plugin/handler/i_s.cc
      storage/innodb_plugin/include/os0sync.h
      storage/innodb_plugin/include/univ.i
      storage/innodb_plugin/include/ut0rnd.ic
      storage/innodb_plugin/log/log0recv.c
      storage/innodb_plugin/os/os0file.c
      storage/innodb_plugin/que/que0que.c
      storage/innodb_plugin/row/row0mysql.c
      storage/innodb_plugin/row/row0purge.c
      storage/innodb_plugin/row/row0sel.c
      storage/innodb_plugin/row/row0umod.c
      storage/innodb_plugin/row/row0vers.c
      storage/innodb_plugin/trx/trx0purge.c
      storage/innodb_plugin/trx/trx0roll.c
      storage/innodb_plugin/trx/trx0sys.c
      storage/innodb_plugin/trx/trx0trx.c
      storage/innodb_plugin/trx/trx0undo.c
      storage/myisam/mi_range.c
      storage/myisam/mi_search.c
      storage/myisam/rt_index.c
      storage/myisam/rt_split.c
      tests/mysql_client_test.c
 3472 hery.ramilison@stripped	2010-10-07 [merge]
      Null-merge from mysql-5.1.49sp1-release

=== modified file 'BUILD/build_mccge.sh'
--- a/BUILD/build_mccge.sh	2010-06-03 12:54:37 +0000
+++ b/BUILD/build_mccge.sh	2010-09-16 06:53:58 +0000
@@ -63,41 +63,50 @@ sysadmin_usage()
 cat <<EOF
 
   This script can be used to build MySQL Cluster Carrier Grade Edition
-  based on a source code release you received from MySQL.
+  based on a source code release you received from MySQL. It can also
+  be used to build many variants other variants of MySQL, in particular
+  various performance-optimised versions of MySQL.
 
   It is assumed that you are building on a computer which is of the 
-  same type as that on which you intend to run MySQL Cluster.
+  same type as that on which you intend to run MySQL/MySQL Cluster.
 
   The simplest possible way to run this script is to allow it to use the 
-  built-in defaults everywhere, invoking it simply as:
+  built-in defaults everywhere, invoking it simply as (from top-level
+  MySQL directory):
 
-  shell> ./build_mccge.sh
+  shell> BUILD/build_mccge.sh
 
   This performs the following operations:
     1) Detects the operating system. Currently, Linux, FreeBSD, Solaris 
-      10/11, and Mac OS X are supported by this script.
+      8/9/10/11, and Mac OS X are supported by this script.
     2) Detect the type of CPU being used. Currently supported processors 
       are: x86 for all supported operating systems, Itanium for Linux 
-      with GCC, and SPARC for Solaris using the Forte compiler.
+      with GCC, and x86 + SPARC for Solaris using the Forte compiler and
+      finally x86 on Linux using the Intel compiler.
     3) Invokes the GCC compiler.
-    4) Builds a set of MySQL Cluster Carrier Grade Edition binaries; for
+    4) Builds a set of MySQL/MySQL Cluster binaries; for
       more information about these, see --extended-help.
+    5) Default compiler is always gcc.
   
   The default version assumes that you have a source code tarball from 
   which you are building, and thus autoconf and automake do not need to 
   be run. If you have downloaded a BitKeeper tree then you should read 
   --developer-help.
 
-  If you are building MySQL Cluster Carrier Grade Edition for commercial 
+  If you are building MySQL/MySQL Cluster for commercial 
   use then you need to set the --commercial flag to ensure that the 
   commercial libraries are compiled in, rather than the GPL-only 
   libraries. The default is to build a GPL version of MySQL Cluster 
   Carrier Grade Edition.
 
-  If your building on a Solaris SPARC machine you must set 
+  If your building on a Solaris SPARC machine and you want to compile
+  using SunStudio you must set 
   --compiler=forte; if you want to build using the Intel compiler on 
   Linux, you need to set --compiler=icc.
 
+  A synonym for forte is SunStudio, so one can also use
+  --compiler=SunStudio.
+
   If you want to make sure that a 64-bit version is built then you 
   should add the flag --64. This is always set on Solaris machines and 
   when check-cpu is able to discover that a 64-bit CPU is being used. If 
@@ -120,7 +129,7 @@ cat <<EOF
   information in the binary then use --debug.
 
   If your aim is not to build MySQL Cluster Carrier Grade Edition, you 
-  can also use this script to build MySQL Classic and MySQL Pro 
+  can also use this script to build MySQL Classic and MySQL Enterprise Pro 
   versions; see the --extended-help for descriptions of these packages.
 EOF
 }
@@ -133,13 +142,20 @@ Usage: $0 [options]
   --help                  Show this help message.
   --sysadmin-help         Show help for system administrators wishing 
                           to build MySQL Cluster Carrier Grade Edition
+                          or other MySQL versions.
   --developer-help        Show help for developers trying to build MySQL
   --with-help             Show extended help on --with-xxx options to 
                           configure
   --extended-help         Show extended help message
   --without-debug         Build non-debug version
+  --use-comment           Set the comment in the build
+  --with-fast-mutexes     Use try/retry method of acquiring mutex
   --with-debug            Build debug version
   --with-debug=full       Build with full debug.
+  --with-link-time-optimizer
+                          Link time optimizations enabled (Requires GCC 4.5
+                          if GCC used), available for icc as well. This flag
+                          is only considered if also fast is set.
   --configure-only        Stop after running configure.
   --use-autotools         Start by running autoconf, automake,.. tools
   --no-autotools          Start from configure
@@ -155,10 +171,10 @@ Usage: $0 [options]
                           MySQL use
   --commercial            Use commercial libraries
   --gpl                   Use gpl libraries
-  --compiler=[gcc|icc|forte]                  Select compiler
-  --cpu=[x86|x86_64|sparc]                    Select CPU type
-                          x86 => 32-bit binary
-                          x86_64 => 64 bit binary unless Mac OS X
+  --compiler=[gcc|icc|forte|SunStudio]        Select compiler
+  --cpu=[x86|x86_64|sparc|itanium]            Select CPU type
+                          x86 => x86 and 32-bit binary
+                          x86_64 => x86 and 64 bit binary
   --warning-mode=[extra|pedantic|normal|no]   Set warning mode level
   --warnings              Set warning mode to normal
   --32                    Build a 32-bit binary even if CPU is 64-bit
@@ -170,8 +186,9 @@ Usage: $0 [options]
   --error-inject          Enable error injection into MySQL Server and 
                           data nodes
   --valgrind              Build with valgrind
-  --fast                  Optimise for CPU architecture buildt on
+  --fast                  Optimise for CPU architecture built on
   --static-linking        Statically link system libraries into binaries
+  --use-tcmalloc          Link with tcmalloc instead of standard malloc (Linux only)
   --with-flags *          Pass extra --with-xxx options to configure
 EOF
   if test "x$1" != "x" ; then
@@ -186,13 +203,14 @@ extended_usage()
   Extended help text for this script:
   -----------------------------------
   This script is intended to make it easier for customers using MySQL
-  Cluster Carrier Grade Edition to build the product from source on 
-  these platforms/compilers: Linux/x86 (32-bit and 64-bit),
-  Solaris 10 and 11/x86/gcc, Solaris 9/Sparc/Forte, and MacOSX/x86/gcc. 
-  The script automatically detects CPU type and operating system; in 
-  most cases this also determines which compiler to use, the exception 
-  being Linux/x86 where you can choose between gcc and icc (gcc is the
-  default).
+  Cluster Carrier Grade Edition, customers using performance-optimised
+  MySQL versions and developers to build the product from source on 
+  these platforms/compilers: Linux/x86 (32-bit and 64-bit) (either using
+  gcc or icc), Linux Itanium, Solaris 8,9,10 and 11 x86 and SPARC using
+  gcc or SunStudio and MacOSX/x86/gcc.
+
+  The script automatically detects CPU type and operating system; The
+  default compiler is always gcc.
 
   To build on other platforms you can use the --print-only option on a
   supported platform and edit the output for a proper set of commands on
@@ -213,7 +231,7 @@ extended_usage()
 
   --package=cge
     storage engines:
-      ARCHIVE, BLACKHOLE, CSV, EXAMPLE, FEDERATED, MYISAM, NDB
+      ARCHIVE, BLACKHOLE, CSV, FEDERATED, MYISAM, NDB
       (All storage engines except InnoDB)
     comment: MySQL Cluster Carrier Grade Edition GPL/Commercial version 
              built from source
@@ -221,7 +239,7 @@ extended_usage()
 
   --package=extended
     storage engines:
-      ARCHIVE, BLACKHOLE, CSV, EXAMPLE, FEDERATED, MYISAM, INNODB, NDB
+      ARCHIVE, BLACKHOLE, CSV, FEDERATED, MYISAM, INNODB, NDB
       (All storage engines)
     comment: MySQL Cluster Carrier Grade Extended Edition GPL/Commercial 
              version built from source
@@ -229,7 +247,7 @@ extended_usage()
 
   --package=pro
     storage engines:
-      ARCHIVE, BLACKHOLE, CSV, EXAMPLE, FEDERATED, INNODB, MYISAM
+      ARCHIVE, BLACKHOLE, CSV, FEDERATED, INNODB, MYISAM
       (All storage engines except NDB)
     comment: MySQL Pro GPL/Commercial version built from 
              source
@@ -291,11 +309,16 @@ extended_usage()
     by MySQL (cannot be overridden).
 
   --with-ssl: Enable use of yaSSL library included in the MySQL source
+    if possible (GCC and same CC and CXX).
     (cannot be overridden).
 
   --with-pic: Build all binaries using position independent assembler
     to avoid problems with dynamic linkers (cannot be overridden).
 
+  --without-example-engine: Ensure that the example engine isn't built,
+    it cannot do any useful things, it's merely intended as documentation.
+    (cannot be overridden)
+
   --with-csv-storage-engine: Ensure that the CSV storage engine is
     included in all builds. Since CSV is required for log tables in
     MySQL 5.1, this option cannot be overridden.
@@ -314,10 +337,6 @@ extended_usage()
   In addition there are some configure options that are specific to
   Linux operating systems:
 
-  --with-fast-mutexes
-    Include an alternative implementation of mutexes that is faster on
-    Linux systems
-
   --enable-assembler
     Include assembler code optimisations for a number of mostly string
     methods. Used for x86 processors only.
@@ -364,17 +383,24 @@ extended_usage()
 
   --with-mysqld-libs=-lmtmalloc
     Used on Solaris to ensure that the proper malloc library is used.
+    Investigations have shown mtmalloc to be the best choice on Solaris,
+    also umem has good performance on Solaris but better debugging
+    capabilities.
 
   Compiler options:
   -----------------
 
-  This section describes the compiler options for each of the different
-  platforms supported by thisscript.
+    This section describes the compiler options for each of the different
+    platforms supported by this script.
+
+    The --fast option adds -mtune=cpu_arg to the C/C++ flags (provides
+    support for Nocona, K8, and other processors).
 
-  The --fast option adds -mtune=cpu_arg to the C/C++ flags (provides
-  support for Nocona, K8, and other processors).
+    Use of the --debug option adds -g to the C/C++ flags.
 
-  Use of the --debug option adds -g to the C/C++ flags.
+    In all cases it is possible to override the definition of CC and CXX
+    by calling the script as follows:
+    CC="/usr/local/bin/gcc" CXX="/usr/local/bin/gcc" BUILD/build_mccge.sh
 
   FreeBSD/x86/gcc
   ---------------
@@ -383,8 +409,7 @@ extended_usage()
 
   Linux/x86+Itanium/gcc
   -------------
-    No flags are used. Instead the configure script determines the
-    proper flags to use for both normal and debug builds. Discovery of a
+    For debug builds -O is used and otherwise -O3 is used.Discovery of a
     Nocona or Core 2 Duo CPU causes a 64-bit binary to be built;
     otherwise, the binary is 32-bit. To build a 64-bit binary, -m64 is
     added to the C/C++ flags. (To build a 32-bit binary on a 64-bit CPU,
@@ -393,48 +418,105 @@ extended_usage()
   Linux/x86+Itanium/icc
   -------------
     Flags used:
-    CC  = icc -static-libgcc -static-libcxa -i-static
-    C++ = icpc -static-libgcc -static-libcxa -i-static
+    CC  = icc -static-libgcc -static-intel
+    C++ = icpc -static-libgcc -static-intel
     C/C++ flags = -mp -restrict
 
-    On Itanium we also add -no-ftz and -no-prefetch to CC and C++ flags.
+    On Itanium we also add -no-ftz and to CC and C++ flags.
 
-  The non-debug versions also add the following:
-    C/C++ flags += -O3 unroll2 -ip
+    Note that if the user of this script sets CC or CXX explicitly then
+    also -static-libgcc and -static-intel needs to be set in the CC and
+    CXX.
 
-  The fast version adds:
-    C/C++ flags += -ipo
+    The non-debug versions also add the following:
+      C/C++ flags += -O3 unroll2 -ip
 
-  On discovery of a Core 2 Duo architecture while using icc, -xT is also 
-  added to the C/C++ flags; this provides optimisations specific to Core 
-  2 Duo. This is added only when the --fast flag is set.
+    The fast version adds (if --with-link-time-optimizer is used):
+      C/C++ flags += -ipo
+
+    On discovery of a Core 2 Duo architecture while using icc, -xT is also 
+    added to the C/C++ flags; this provides optimisations specific to Core 
+    2 Duo. This is added only when the --fast flag is set.
 
   Solaris/x86/gcc
   ---------------
-    All builds on Solaris are 64-bit, so -m64 is always used in the
-    C/C++ flags. LDFLAGS is set to -m64 -static-libgcc -O/-O2.
+    All builds on Solaris are by default 64-bit, so -m64 is always used in
+    the C/C++ flags. LDFLAGS is set to -m64 -O/-O2/-O3. If for
+    some reason a 32-bit Solaris is used it is necessary to add the flag
+    --32 to the script invocation. Due to bugs in compiling with -O3 on
+    Solaris only -O2 is used by default, when --fast flag is used -O3 will
+    be used instead.
+
+    Sets -m64 (default) or -m32 (if specifically set) in LDFLAGS and
+    C/C++ flags.
 
   Solaris/Sparc/Forte
   -------------------
-    Uses cc-5.0 as CC
-    Sets ASFLAGS=LDFLAGS=xarch=v9, so that we compile Sparc v9 binaries
-    C flags   = -Xa -strconst -xc99=none
-    C++ flags = -noex
-    C/C++ flags = -mt -D_FORTEC -xarch=v9
+    Uses cc as CC and CC as CXX
+    Note that SunStudio uses different binaries for C and C++ compilers.
 
-    For non-debug builds, the following flags are also used:
+    Set -m64 (default) or -m32 (if specifically set) in ASFLAGS,
+    LDFLAGS and C/C++ flags.
 
-    C/C++ flags = -xO3
+    Sets ASFLAGS=LDFLAGS=compiler flags=xarch=sparc, so that we compile
+    Sparc v9 binaries, also -mt is set in all those since we're always
+    building a multithreaded program.
+
+    C flags   = -xstrconst    This flag is set only on SPARC
+    C++ flags = -noex
+
+    Set the following C/C++ flags:
+    -fsimple=1
+    -ftrap=%none
+    -nofstore          This flag is set only on x86
+    -xbuiltin=%all
+    -xlibmil
+    -xlibmopt
+
+    Set the C++ flag:
+    -noex
+    -features=no%except    This flag is set only on x86
+
+    When compiling with fast we set (-ipo only used if we have
+    set --with-link-time-optimizer):
+    C/C++ flags: -xtarget=native -xunroll=3 -xipo
+    LDFLAGS: -xipo
+
+    When not compiling with fast we always set -xtarget=generic
+
+    When compiling with fast on SPARC we also set:
+    C/C++ flags: -xbinopt=prepare
+    LDFLAGS: -xbinopt=prepare
+
+    When compiling with fast on x86 we also set:
+    C/C++ flags: -xregs=frameptr
+    When not compiling with fast we set on x86
+    C/C++ flags: -xregs=no%frameptr
+
+    On SPARC we set
+    ASFLAGS = LDFLAGS = C/C++ flags = -xarch=sparc
+
+    The optimisation level is
+    -xO         Debug builds
+    -xO2        Production build on SPARC
+    -xO3        Production build on x86
+    -xO4        Fast builds on SPARC/x86
 
   MacOSX/x86/gcc
   --------------
-  C/C++ flags include -fno-common -arch i386.
+    C/C++ flags include -fno-common -arch i386.
+    When 64-bits builds then i386 is replaced by x86_64.
 
-  Non-debug versions also add -Os -felide-constructors, where "-Os"
-  means the build is space-optimised as long as the space optimisations
-  do not negatively affect performance. Debug versions use -O.
+    Non-debug versions also add -Os -felide-constructors, where "-Os"
+    means the build is space-optimised as long as the space optimisations
+    do not negatively affect performance. Debug versions use -O.
+  
+    Mac OS X builds will always be 32-bit by default, when --64 is added
+    the build will be 64 bit instead. Thus the flag --m64 is added only
+    when specifically given as an option.
 EOF
 }
+
 with_usage()
 {
   cat <<EOF
@@ -495,7 +577,7 @@ parse_package()
       package="pro"
       ;;
     extended )
-      package=""
+      package="extended"
       ;;
     cge )
       package="cge"
@@ -537,11 +619,15 @@ parse_cpu_type()
   case "$cpu_type" in
     x86 )
       cpu_type="x86"
-      m32="yes"
+      if test "x$m64" = "x" ; then
+        m64="no"
+      fi
       ;;
     x86_64 )
       cpu_type="x86"
-      m64="yes"
+      if test "x$m64" = "x" ; then
+        m64="yes"
+      fi
       ;;
     itanium )
       cpu_type="itanium"
@@ -569,7 +655,7 @@ parse_compiler()
     icc )
       compiler="icc"
       ;;
-    forte )
+    forte | SunStudio | sunstudio )
       compiler="forte"
       ;;
     *)
@@ -590,6 +676,9 @@ parse_options()
     --datadir=*)
       datadir=`get_key_value "$1"`
       ;;
+    --with-link-time-optimizer)
+      with_link_time_optimizer="yes"
+      ;;
     --with-debug=full)
       full_debug="=full"
       with_debug_flag="yes"
@@ -601,6 +690,15 @@ parse_options()
         fast_flag="generic"
       fi
       ;;
+    --use-comment)
+      without_comment="no"
+      ;;
+    --with-fast-mutexes)
+      with_fast_mutexes="yes"
+      ;;
+    --use-tcmalloc)
+      use_tcmalloc="yes"
+      ;;
     --with-debug)
       with_debug_flag="yes"
       fast_flag="no"
@@ -636,17 +734,19 @@ parse_options()
       warning_mode="normal"
       ;;
     --32)
-      if test "x$m64" != "x" ; then
+      if test "x$explicit_size_set" != "x" ; then
         echo "Cannot set both --32 and --64"
         exit 1
       fi
-      m32="yes"
+      explicit_size_set="yes"
+      m64="no"
       ;;
     --64)
-      if test "x$m32" != "x" ; then
+      if test "x$explicit_size_set" != "x" ; then
         echo "Cannot set both --32 and --64"
         exit 1
       fi
+      explicit_size_set="yes"
       m64="yes"
       ;;
     --package=*)
@@ -750,13 +850,15 @@ set_cpu_base()
   if test "x$cpu_type" = "x" ; then
     if test "x$cpu_arg" = "x" ; then
       usage "CPU type not discovered, cannot proceed"
-      return 1
+      exit 1
     fi
     case "$cpu_arg" in
       core2 | nocona | prescott | pentium* | i*86 )
+        # Intel CPU
         cpu_base_type="x86"
         ;;
-      athlon* | opteron* )
+      athlon* | opteron* | k6 | k8 )
+        # AMD CPU
         cpu_base_type="x86"
         ;;
       sparc )
@@ -775,18 +877,20 @@ set_cpu_base()
     check_cpu_cflags=""
   fi
   if test "x$os" = "xMacOSX" ; then
-    m64="no"
+    if test "x$m64" = "x" ; then
+      m64="no"
+    fi
   elif test "x$os" = "xSolaris" ; then
-    m64="yes"
-  elif test "x$m32" = "x" ; then
+    if test "x$m64" = "x" ; then
+      m64="yes"
+    fi
+  elif test "x$m64" = "x" ; then
     if test "x$cpu_arg" = "xnocona" || test "x$cpu_arg" = "xcore2" || \
        test "x$cpu_arg" = "xathlon64" || test "x$cpu_arg" = "xopteron" ; then
       m64="yes"
-    elif test "x$m64" != "xyes" ; then
+    else
       m64="no"
     fi
-  else
-    m64="no"
   fi
   echo "Discovered CPU of type $cpu_base_type ($cpu_arg) on $os"
   if test "x$m64" = "xyes" ; then
@@ -806,18 +910,15 @@ init_configure_commands()
   cxxflags="$cxx_warnings $base_cxxflags $compiler_flags"
   configure="./configure $base_configs $with_flags"
 
-  commands="$commands
-    CC=\"$CC\" CFLAGS=\"$cflags\" CXX=\"$CXX\" CXXFLAGS=\"$cxxflags\""
+  env_flags="CC=\"$CC\" CFLAGS=\"$cflags\" CXX=\"$CXX\" CXXFLAGS=\"$cxxflags\""
   if test "x$LDFLAGS" != "x" ; then
-    commands="$commands
-      LDFLAGS=\"$LDFLAGS\""
+    env_flags="$env_flags LDFLAGS=\"$LDFLAGS\""
   fi
   if test "x$ASFLAGS" != "x" ; then
-    commands="$commands
-      ASFLAGS=\"$ASFLAGS\""
+    env_flags="$env_flags ASFLAGS=\"$ASFLAGS\""
   fi
   commands="$commands
-    $configure"
+    $env_flags $configure"
 } 
 
 #
@@ -920,7 +1021,7 @@ set_libtoolize_version()
 # We do not use ccache when gcov is used. Also only when
 # gcc is used.
 #
-set_up_ccache()
+set_ccache_usage()
 {
   if test "x$compiler" = "xgcc" ; then
     if ccache -V > /dev/null 2>&1 && test "$USING_GCOV" != "1"
@@ -994,7 +1095,7 @@ set_with_debug_flags()
   if test "x$with_debug_flag" = "xyes" ; then
     if test "x$developer_flag" = "xyes" ; then
       loc_debug_flags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
-      loc_debug_flags="$loc_debug_cflags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC"
+      loc_debug_flags="$loc_debug_flags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC"
       compiler_flags="$compiler_flags $loc_debug_flags"
     fi
   fi
@@ -1024,6 +1125,18 @@ set_debug_flag()
 }
 
 #
+# We compile in SSL support if we can, this isn't possible if CXX
+# and CC aren't the same and we're not using GCC.
+# 
+set_ssl()
+{
+  if test "x$compiler" = "xgcc" && \
+     test "x$CC" = "x$CXX" ; then
+    base_configs="$base_configs --with-ssl"
+  fi
+}
+
+#
 # Base options used by all packages
 #
 # SSL library to use. --with-ssl selects the bundled yaSSL
@@ -1048,9 +1161,12 @@ set_base_configs()
   base_configs="$base_configs --enable-thread-safe-client"
   base_configs="$base_configs --with-big-tables"
   base_configs="$base_configs --with-extra-charsets=all"
-  base_configs="$base_configs --with-ssl"
+  if test "x$with_fast_mutexes" = "xyes" ; then
+    base_configs="$base_configs --with-fast-mutexes"
+  fi
   base_configs="$base_configs --with-pic"
   base_configs="$base_configs --with-csv-storage-engine"
+  base_configs="$base_configs --with-perfschema"
 }
 
 #
@@ -1060,18 +1176,30 @@ set_base_configs()
 #
 set_base_engines()
 {
-  engine_configs="$engine_configs --with-archive-storage-engine"
+  engine_configs="--with-archive-storage-engine"
   engine_configs="$engine_configs --with-blackhole-storage-engine"
-  engine_configs="$engine_configs --with-example-storage-engine"
+  engine_configs="$engine_configs --without-example-storage-engine"
   engine_configs="$engine_configs --with-federated-storage-engine"
   engine_configs="$engine_configs --with-partition"
+  base_configs="$base_configs $engine_configs"
 }
 
-set_pro_package()
+set_innodb_engine()
 {
-  base_configs="$base_configs $engine_configs"
   base_configs="$base_configs --with-innodb"
-  base_configs="$base_configs --with-comment=\"MySQL Pro $version_text built from source\""
+}
+
+set_ndb_engine()
+{
+  base_configs="$base_configs --with-ndbcluster"
+  base_configs="$base_configs --without-ndb-debug"
+}
+
+set_pro_package()
+{
+  if test "x$without_comment" != "xyes" ; then
+    base_configs="$base_configs --with-comment=\"MySQL Enterprise Pro $version_text built from source\""
+  fi
   if test "x$with_debug_flag" = "xyes" ; then
     base_configs="$base_configs --with-server-suffix=\"-debug\""
   fi
@@ -1079,40 +1207,37 @@ set_pro_package()
 
 set_cge_extended_package()
 {
-  if test "x$gpl" = "xno" ; then
-    echo "Cannot build Extended Carrier Grade Edition as Commercial version"
+  if test "x$without_comment" != "xyes" ; then
+    base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Extended Edition $version_text built from source\""
   fi
-  base_configs="$base_configs --with-ndbcluster"
-  base_configs="$base_configs --without-ndb-debug"
-  base_configs="$base_configs $engine_configs"
-  base_configs="$base_configs --with-innodb"
-  base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Extended Edition $version_text built from source\""
   if test "x$with_debug_flag" = "xyes" ; then
     base_configs="$base_configs --with-server-suffix=\"-cge-extended-debug\""
   else
-    base_configs="$base_configs --with-server-suffix=\"-cge-extended"\"
+    base_configs="$base_configs --with-server-suffix=\"-cge-extended\""
   fi
 }
 
 set_cge_package()
 {
-  base_configs="$base_configs --with-ndbcluster"
-  base_configs="$base_configs --without-ndb-debug"
-  base_configs="$base_configs $engine_configs"
-  base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Edition $version_text built from source\""
+  if test "x$without_comment" != "xyes" ; then
+    base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Edition $version_text built from source\""
+  fi
   if test "x$with_debug_flag" = "xyes" ; then
     base_configs="$base_configs --with-server-suffix=\"-cge-debug\""
   else
-    base_configs="$base_configs --with-server-suffix=\"-cge"\"
+    base_configs="$base_configs --with-server-suffix=\"-cge\""
   fi
 }
 
 set_classic_package()
 {
-  base_configs="$base_configs --with-comment=\"MySQL Classic $version_text built from source\""
+  if test "x$without_comment" != "xyes" ; then
+    base_configs="$base_configs --with-comment=\"MySQL Classic $version_text built from source\""
+  fi
   if test "x$with_debug_flag" = "xyes" ; then
     base_configs="$base_configs --with-server-suffix=\"-debug\""
   fi
+  base_configs="$base_configs --without-example-storage-engine"
 }
 
 #
@@ -1140,6 +1265,36 @@ set_gcc_special_options()
   fi
 }
 
+set_cc_and_cxx_for_gcc()
+{
+  if test "x$CC" = "x" ; then
+    CC="gcc -static-libgcc -fno-exceptions"
+  fi
+  if test "x$CXX" = "x" ; then
+    CXX="gcc -static-libgcc -fno-exceptions"
+  fi
+}
+
+set_cc_and_cxx_for_icc()
+{
+  if test "x$CC" = "x" ; then
+    CC="icc -static-intel -static-libgcc"
+  fi
+  if test "x$CXX" = "x" ; then
+    CXX="icpc -static-intel -static-libgcc"
+  fi
+}
+
+set_cc_and_cxx_for_forte()
+{
+  if test "x$CC" = "x" ; then
+    CC="cc"
+  fi
+  if test "x$CXX" = "x" ; then
+    CXX="CC"
+  fi
+}
+
 #
 # If we discover a Core 2 Duo architecture and we have enabled the fast
 # flag, we enable a compile especially optimised for Core 2 Duo. This
@@ -1167,42 +1322,116 @@ set_bsd_configs()
     exit 1
   fi
   base_configs="$base_configs --enable-assembler"
-  CC="gcc"
-  CXX="gcc"
+  if test "x$fast_flag" != "xno" ; then
+    compiler_flags="$compiler_flags -O3"
+  else
+    compiler_flags="$compiler_flags -O0"
+  fi
+  set_cc_and_cxx_for_gcc
+}
+
+check_64_bits()
+{
+  echo "Checking for 32/64-bits compilation"
+  echo "int main() { return 0; }" > temp_test.c
+  if test "x$m64" = "xyes" ; then
+    cmd="$CC $compile_flags -m64 temp_test.c"
+    if ! $cmd 2>1 ; then
+      m64="no"
+      echo "Changing to 32-bits since 64-bits didn't work"
+    else
+      echo "Will use 64-bits"
+    fi
+  else
+    cmd="$CC $compile_flags -m32 temp_test.c"
+    if ! $cmd 2>1 ; then
+      m64="yes"
+      echo "Changing to 64-bits since 32-bits didn't work"
+    else
+      echo "Will use 32-bits"
+    fi
+  fi
+  rm temp_test.c
 }
 
 #
+# Get GCC version
+#
+get_gcc_version()
+{
+  # check if compiler is gcc and dump its version
+  cc_verno=`$cc -dumpversion 2>/dev/null`
+  if test "x$?" = "x0" ; then
+    set -- `echo $cc_verno | tr '.' ' '`
+    cc_ver="GCC"
+    cc_major=$1
+    cc_minor=$2
+    cc_patch=$3
+    gcc_version=`expr $cc_major '*' 100 '+' $cc_minor`
+  fi
+}
+
+#
+# Link Time Optimizer in GCC (LTO) uses a parameter -flto
+# which was added to GCC 4.5, if --with-link-time-optimizer
+# is set then use this feature
+#
+check_for_link_time_optimizer()
+{
+  get_gcc_version
+  if test "$gcc_version" -ge 405 && \
+     test "x$with_link_time_optimizer" = "xyes" ; then
+    compiler_flags="$compiler_flags -flto"
+    LDFLAGS="$LDFLAGS -flto"
+  fi
+}
+#
 # Linux Section
 #
 set_linux_configs()
 {
   if test "x$cpu_base_type" != "xx86" && \
      test "x$cpu_base_type" != "xitanium" ; then
-    usage "Only x86 and Itanium CPUs supported for 32-bit Linux"
+    usage "Only x86 and Itanium CPUs supported for Linux"
     exit 1
   fi
-  base_configs="$base_configs --with-fast-mutexes"
+  if test "x$use_tcmalloc" = "xyes" ; then
+    base_configs="$base_configs --with-mysqld-libs=-ltcmalloc_minimal"
+  fi
   if test "x$cpu_base_type" = "xx86" ; then
     base_configs="$base_configs --enable-assembler"
   fi
   if test "x$compiler" = "xgcc" ; then
-    CC="gcc"
-    CXX="gcc"
+    set_cc_and_cxx_for_gcc
+    if test "x$fast_flag" != "xno" ; then
+      if test "x$fast_flag" = "xyes" ; then
+        compiler_flags="$compiler_flags -O3"
+        check_for_link_time_optimizer
+      else
+        compiler_flags="$compiler_flags -O2"
+      fi
+    else
+      compiler_flags="$compiler_flags -O0"
+    fi
+    check_64_bits
     if test "x$m64" = "xyes" ; then
       compiler_flags="$compiler_flags -m64"
+    else
+      compiler_flags="$compiler_flags -m32"
     fi
 # configure will set proper compiler flags for gcc on Linux
   elif test "x$compiler" = "xicc" ; then
     compiler_flags="$compiler_flags -mp -restrict"
-    CC="icc -static-intel"
-    CXX="icpc -static-intel"
+    set_cc_and_cxx_for_icc
     if test "x$cpu_base_type" = "xitanium" ; then
       compiler_flags="$compiler_flags -no-ftz"
     fi
     if test "x$fast_flag" != "xno" ; then
       compiler_flags="$compiler_flags -O3 -unroll2 -ip"
-      if test "x$fast_flag" = "xyes" ; then
+      if test "x$fast_flag" = "xyes" && \
+         test "x$with_link_time_optimizer" = "xyes" ; then
         compiler_flags="$compiler_flags -ipo"
+        LDFLAGS="$LDFLAGS -ipo"
       fi
     fi
   else
@@ -1216,53 +1445,111 @@ set_linux_configs()
 #
 set_solaris_configs()
 {
-  base_configs="$base_configs --with-mysqld-libs=-lmtmalloc"
+# Use mtmalloc as malloc, see Tim Cook blog
+# For information on optimal compiler settings, see article at
+# http://developers.sun.com/solaris/articles/mysql_perf_tune.html
+# by Luojia Chen at Sun.
+  base_configs="$base_configs --with-named-curses=-lcurses"
   case "`uname -a`" in
-    *5.10*|*5.11*)
+    *5.8* | *5.9* )
+      ;;
+
+    *5.10* | *5.11*)
+      base_configs="$base_configs --with-mysqld-libs=-lmtmalloc"
       ;;
     *)
-      die "Only versions 10 and 11 supported for Solaris"
+      usage "Only versions 8,9, 10 and 11 supported for Solaris"
+      exit 1
   esac
   if test "x$cpu_base_type" != "xx86" && \
      test "x$cpu_base_type" != "xsparc" ; then
     usage "Only x86 and Sparc CPUs supported for Solaris"
     exit 1
   fi
+  if test "x$compiler" != "xgcc" && \
+     test "x$compiler" != "xforte" ; then
+    usage "Only gcc and Forte compilers supported for Solaris"
+    exit 1
+  fi
+  if test "x$m64" = "xyes" ; then
+    compiler_flags="$compiler_flags -m64"
+    LDFLAGS="-m64"
+    ASFLAGS="$ASFLAGS -m64"
+  else
+    compiler_flags="$compiler_flags -m32"
+    LDFLAGS="-m32"
+    ASFLAGS="$ASFLAGS -m32"
+  fi
   if test "x$compiler" = "xgcc" ; then
-    CC="gcc"
-    CXX="gcc"
+    set_cc_and_cxx_for_gcc
     if test "x$cpu_base_type" != "xx86" ; then
-      usage "Only gcc supported for Solaris 10/11 on SPARC"
+      usage "gcc currently not supported for Solaris on SPARC"
+      exit 1
     fi
-    compiler_flags="$compiler_flags -m64 -DMY_ATOMIC_MODE_RWLOCKS"
-    LDFLAGS="-m64 -static-libgcc"
-    if test "x$fast_flag" != "xno" ; then
-      LDFLAGS="$LDFLAGS -O2"
-      compiler_flags="$compiler_flags -O2"
+    if test "x$fast_flag" = "xyes" ; then
+      LDFLAGS="$LDFLAGS -O3"
+      compiler_flags="$compiler_flags -O3"
+      check_for_link_time_optimizer
     else
-      LDFLAGS="$LDFLAGS -O"
-      compiler_flags="$compiler_flags -O"
-    fi
-  elif test "x$compiler" = "xforte" ; then
-    if test "x$cpu_base_type" = "xx86" ; then
-      usage "Only gcc supported for Solaris/x86"
+      if test "x$fast_flag" = "xgeneric" ; then
+        LDFLAGS="$LDFLAGS -O2"
+        compiler_flags="$compiler_flags -O2"
+      else
+        LDFLAGS="$LDFLAGS -O0"
+        compiler_flags="$compiler_flags -O0"
+      fi
     fi
-    if test "x$cpu_base_type" != "xsparc" ; then
-      usage "Forte compiler supported for Solaris 9/SPARC only"
+  else
+#Using Forte compiler (SunStudio)
+    set_cc_and_cxx_for_forte
+    compiler_flags="$compiler_flags -mt"
+    LDFLAGS="$LDFLAGS -mt"
+    compiler_flags="$compiler_flags -fsimple=1"
+    compiler_flags="$compiler_flags -ftrap=%none"
+    compiler_flags="$compiler_flags -xbuiltin=%all"
+    compiler_flags="$compiler_flags -xlibmil"
+    compiler_flags="$compiler_flags -xlibmopt"
+    if test "x$fast_flag" = "xyes" ; then
+      compiler_flags="$compiler_flags -xtarget=native"
+      compiler_flags="$compiler_flags -xunroll=3"
+      if test "x$with_link_time_optimizer" = "xyes" ; then
+        compiler_flags="$compiler_flags -xipo"
+        LDFLAGS="$LDFLAGS -xipo"
+      fi
+    else
+      compiler_flags="$compiler_flags -xtarget=generic"
     fi
-    CC="cc-5.0"
-    CXX=CC
-    ASFLAGS="xarch=v9"
-    LDFLAGS="xarch=v9"
-    base_cflags="$base_cflags -Xa -xstrconst -xc99=none"
-    base_cxxflags="$base_cxxflags -noex"
-    compiler_flags="$compiler_flags -mt -D_FORTEC -xarch=v9"
-    if test "x$fast_flag" != "xno" ; then
-      compiler_flags="$compiler_flags -xO3"
+    if test "x$cpu_base_type" = "xx86" ; then
+      compiler_flags="$compiler_flags -nofstore"
+      base_cxx_flags="$base_cxx_flags -features=no%except"
+      if test "x$fast_flag" = "xyes" ; then
+        compiler_flags="$compiler_flags -xregs=frameptr"
+        compiler_flags="$compiler_flags -xO4"
+      else
+        compiler_flags="$compiler_flags -xregs=no%frameptr"
+        if test "x$fast_flag" = "xgeneric" ; then
+          compiler_flags="$compiler_flags -xO2"
+        else
+          compiler_flags="$compiler_flags -xO0"
+        fi
+      fi
+    else
+#Using SPARC cpu with SunStudio (Forte) compiler
+      ASFLAGS="$ASFLAGS -xarch=sparc"
+      LDFLAGS="$LDFLAGS -xarch=sparc"
+      base_cxxflags="$base_cxxflags -noex"
+      base_cflags="$base_cflags -xstrconst"
+      compiler_flags="$compiler_flags -xarch=sparc"
+      if test "x$fast_flag" = "xyes" ; then
+        compiler_flags="$compiler_flags -xbinopt=prepare"
+        LDFLAGS="$LDFLAGS -xbinopt=prepare"
+        compiler_flags="$compiler_flags -xO4"
+      elif test "x$fast_flag" = "xgeneric" ; then
+        compiler_flags="$compiler_flags -xO3"
+      else
+        compiler_flags="$compiler_flags -xO0"
+      fi
     fi
-  else
-    usage "Only gcc and Forte compilers supported for Solaris"
-    exit 1
   fi
 }
 
@@ -1271,10 +1558,7 @@ set_solaris_configs()
 #
 set_macosx_configs()
 {
-  base_cxxflags="$base_cxxflags -fno-common"
-  if test "x$cpu_base_type" = "xx86" && test "x$compiler" = "xgcc" ; then
-    compiler_flags="$compiler_flags -arch i386"
-  else
+  if test "x$cpu_base_type" != "xx86" || test "x$compiler" != "xgcc" ; then
     usage "Only gcc/x86 supported for Mac OS X"
     exit 1
   fi
@@ -1282,14 +1566,21 @@ set_macosx_configs()
 # Optimize for space as long as it doesn't affect performance, use some
 # optimisations also when not in fast mode.
 #
+  base_cxxflags="$base_cxxflags -felide-constructors"
+  compiler_flags="$compiler_flags -fno-common"
+  if test "x$m64" = "xyes" ; then
+    compiler_flags="$compiler_flags -m64"
+    compiler_flags="$compiler_flags -arch x86_64"
+  else
+    compiler_flags="$compiler_flags -m32"
+    compiler_flags="$compiler_flags -arch i386"
+  fi
   if test "x$fast_flag" != "xno" ; then
     compiler_flags="$compiler_flags -Os"
-    base_cxxflags="$base_cxxflags -felide-constructors"
   else
-    compiler_flags="$compiler_flags -O"
+    compiler_flags="$compiler_flags -O0"
   fi
-  CC="gcc"
-  CXX="gcc"
+  set_cc_and_cxx_for_gcc
 }
 
 #
@@ -1370,7 +1661,7 @@ fi
 cpu_type=
 package=
 prefix="/usr/local/mysql"
-parallelism="4"
+parallelism="8"
 fast_flag="generic"
 compiler="gcc"
 gpl="yes"
@@ -1398,11 +1689,19 @@ base_cxxflags=
 base_configs=
 debug_flags=
 cxxflags=
-m32=
 m64=
+explicit_size_set=
 datadir=
 commands=
 use_autotools=
+engine_configs=
+ASFLAGS=
+LDFLAGS=
+use_tcmalloc=
+without_comment="yes"
+with_fast_mutexes=
+with_link_time_optimizer=
+gcc_version="0"
 
 set_defaults_based_on_environment
 
@@ -1419,7 +1718,14 @@ set -e
 # This call sets the cpu_arg and check_cpu_args parameters
 #
 path=`dirname $0`
+if test "x$compiler" = "xgcc" ; then
+  compiler=
+fi
 . "$path/check-cpu"
+if test "x$compiler" = "x" ; then
+  compiler="gcc"
+fi
+check_os
 set_cpu_base
 if test "x$?" = "x1" ; then
   exit 1
@@ -1447,17 +1753,23 @@ set_icc_special_options
 # including all storage engines except InnoDB, and to use GPL libraries.
 #
 set_base_configs
-set_base_engines
 if test "x$gpl" = "xyes" ; then
   version_text="GPL version"
 else
   version_text="Commercial version"
 fi
 if test "x$package" = "xpro" ; then
+  set_base_engines
+  set_innodb_engine
   set_pro_package
 elif test "x$package" = "xextended" ; then
+  set_base_engines
+  set_ndb_engine
+  set_innodb_engine
   set_cge_extended_package
 elif test "x$package" = "xcge" ; then
+  set_base_engines
+  set_ndb_engine
   set_cge_package
 elif test "x$package" = "xclassic" ; then
   set_classic_package
@@ -1473,7 +1785,6 @@ set_error_inject_configs
 # operating systems, and processors.
 #
 
-check_os
 if test "x$os" = "xlinux" ; then
   set_linux_configs
 elif test "x$os" = "xSolaris" ; then
@@ -1485,13 +1796,13 @@ elif test "x$os" = "xbsd" ; then
 else
   die "Operating system not supported by this script"
 fi
-
+set_ssl
 #
 # Final step before setting up commands is to set up proper make and
 # proper libtoolize versions, and to determine whether to use ccache.
 #
 set_make_version
-set_up_ccache
+set_ccache_usage
 
 #
 # Set up commands variable from variables prepared for base 

=== modified file 'BUILD/check-cpu'
--- a/BUILD/check-cpu	2010-07-02 18:30:47 +0000
+++ b/BUILD/check-cpu	2010-09-16 06:53:58 +0000
@@ -16,12 +16,14 @@ check_cpu () {
     # on Linux (and others?) we can get detailed CPU information out of /proc
     cpuinfo="cat $CPUINFO"
 
+    # detect CPU architecture
+    cpu_arch=`$cpuinfo | grep 'arch' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
+
     # detect CPU family
     cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
     if test -z "$cpu_family" ; then
       cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
     fi
-
     # detect CPU vendor and model
     cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
     model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
@@ -56,8 +58,8 @@ check_cpu () {
         fi  
         ;;
       *)
-        cpu_family=`uname -m`;
-        model_name=`uname -p`;
+        cpu_family=`uname -p`;
+        model_name=`uname -m`;
         ;;
     esac
   fi
@@ -65,9 +67,10 @@ check_cpu () {
   # detect CPU shortname as used by gcc options 
   # this list is not complete, feel free to add further entries
   cpu_arg=""
-  case "$cpu_family--$model_name" in
+  low_cpu_arg=""
+  case "$cpu_vendor--$cpu_family--$model_name--$cpu_arch" in
     # DEC Alpha
-    Alpha*EV6*)
+    *Alpha*EV6*)
       cpu_arg="ev6";
       ;;
     #Core 2 Duo  
@@ -96,6 +99,13 @@ check_cpu () {
     *Pentium*4*Mobile*)
       cpu_arg="pentium4m"
       ;;
+    *Pentium\(R\)*\ M*)
+      cpu_arg="pentium-m"
+      low_cpu_arg="pentium3"
+      ;;
+    *Pentium\(R\)*\ D*)
+      cpu_arg="prescott"
+      ;;
     *Pentium*4*)
       cpu_arg="pentium4"
       ;;
@@ -120,6 +130,12 @@ check_cpu () {
     *Celeron*)
       cpu_arg="pentium2"
       ;;
+    *Atom*)
+      cpu_arg="prescott"
+      ;;
+    *GenuineIntel*)
+      cpu_arg="pentium"
+      ;;
     *Turion*)
       cpu_arg="athlon64"
       ;;
@@ -129,9 +145,30 @@ check_cpu () {
     *Athlon*)
       cpu_arg="athlon"
       ;;
+    *AMD-K7*)
+      cpu_arg="athlon"
+      ;;
+    *Athlon*XP\ *)
+      cpu_arg="athlon-xp"
+      ;;
+    *AMD*Sempron\(tm\)*)
+      cpu_arg="athlon-mp"
+      ;;
+    *AMD*Athlon\(tm\)\ 64*)
+      cpu_arg="k8"
+      ;;
     *Opteron*)
       cpu_arg="opteron"
       ;;
+    *Phenom*)
+      cpu_arg="k8"
+      ;;
+    *AuthenticAMD*)
+      cpu_arg="k6"
+      ;;
+    *VIA\ *)
+      cpu_arg="i686"
+      ;;
     # MacOSX / Intel  
     *i386*i486*)
       cpu_arg="pentium-m"
@@ -143,8 +180,11 @@ check_cpu () {
     *Itanium*)
       cpu_arg="itanium"
       ;;
+    *IA-64*)
+      cpu_arg="itanium"
+      ;;
     # Solaris Sparc
-    *sparc*sun4u*)
+    *sparc*sun4[uv]*)
       cpu_arg="sparc"
       ;;
     # Power PC
@@ -160,6 +200,10 @@ check_cpu () {
       ;;
   esac
 
+  if test "x$low_cpu_arg" = "x" ; then
+    low_cpu_arg="$cpu_arg"
+  fi
+
   if test -z "$cpu_arg" ; then
     if test "$CPUINFO" != " " ; then
       # fallback to uname if necessary
@@ -198,7 +242,7 @@ check_cpu () {
         case `gcc -dumpmachine` in
           i?86-* | x86_64-*)
 	    if test "$cc_comp" -lt 304 ; then
-              check_cpu_cflags="-mcpu=${cpu_arg}"
+              check_cpu_cflags="-mcpu=${low_cpu_arg}"
             elif test "$cc_comp" -ge 402 ; then
               check_cpu_cflags="-mtune=native"
             else

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-08-26 13:14:50 +0000
+++ b/client/mysqltest.cc	2010-10-03 17:37:58 +0000
@@ -103,6 +103,7 @@ static my_bool parsing_disabled= 0;
 static my_bool display_result_vertically= FALSE, display_result_lower= FALSE,
   display_metadata= FALSE, display_result_sorted= FALSE;
 static my_bool disable_query_log= 0, disable_result_log= 0;
+static my_bool disable_connect_log= 1;
 static my_bool disable_warnings= 0;
 static my_bool disable_info= 1;
 static my_bool abort_on_error= 1;
@@ -242,7 +243,9 @@ struct st_connection
   int cur_query_len;
   pthread_mutex_t mutex;
   pthread_cond_t cond;
+  pthread_t tid;
   int query_done;
+  my_bool has_thread;
 #endif /*EMBEDDED_LIBRARY*/
 };
 
@@ -273,6 +276,7 @@ enum enum_commands {
   Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
   Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
   Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
+  Q_ENABLE_CONNECT_LOG, Q_DISABLE_CONNECT_LOG,
   Q_WAIT_FOR_SLAVE_TO_STOP,
   Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
   Q_ENABLE_INFO, Q_DISABLE_INFO,
@@ -340,6 +344,8 @@ const char *command_names[]=
   /* Enable/disable that the _result_ from a query is logged to result file */
   "enable_result_log",
   "disable_result_log",
+  "enable_connect_log",
+  "disable_connect_log",
   "wait_for_slave_to_stop",
   "enable_warnings",
   "disable_warnings",
@@ -733,8 +739,6 @@ pthread_handler_t send_one_query(void *a
 static int do_send_query(struct st_connection *cn, const char *q, int q_len,
                          int flags)
 {
-  pthread_t tid;
-
   if (flags & QUERY_REAP_FLAG)
     return mysql_send_query(&cn->mysql, q, q_len);
 
@@ -745,9 +749,10 @@ static int do_send_query(struct st_conne
   cn->cur_query= q;
   cn->cur_query_len= q_len;
   cn->query_done= 0;
-  if (pthread_create(&tid, &cn_thd_attrib, send_one_query, (void*)cn))
+  if (pthread_create(&cn->tid, &cn_thd_attrib, send_one_query, (void*)cn))
     die("Cannot start new thread for query");
 
+  cn->has_thread= TRUE;
   return 0;
 }
 
@@ -760,6 +765,14 @@ static void wait_query_thread_end(struct
       pthread_cond_wait(&con->cond, &con->mutex);
     pthread_mutex_unlock(&con->mutex);
   }
+  if (con->has_thread)
+  {
+#ifndef __WIN__
+    /* May hang on Windows, but the problem it solves is not seen there */
+    pthread_join(con->tid, NULL);
+#endif
+    con->has_thread= FALSE;
+  }
 }
 
 #else /*EMBEDDED_LIBRARY*/
@@ -2175,8 +2188,14 @@ void var_query_set(VAR *var, const char
   DBUG_ENTER("var_query_set");
   LINT_INIT(res);
 
+  /* Only white space or ) allowed past ending ` */
   while (end > query && *end != '`')
+  {
+    if (*end && (*end != ' ' && *end != '\t' && *end != '\n' && *end != ')'))
+      die("Spurious text after `query` expression");
     --end;
+  }
+
   if (query == end)
     die("Syntax error in query, missing '`'");
   ++query;
@@ -3834,7 +3853,18 @@ void do_perl(struct st_command *command)
     if (!error)
       my_delete(temp_file_path, MYF(0));
 
-    handle_command_error(command, WEXITSTATUS(error));
+    /* Check for error code that indicates perl could not be started */
+    int exstat= WEXITSTATUS(error);
+#ifdef __WIN__
+    if (exstat == 1)
+      /* Text must begin 'perl not found' as mtr looks for it */
+      abort_not_supported_test("perl not found in path or did not start");
+#else
+    if (exstat == 127)
+      abort_not_supported_test("perl not found in path");
+#endif
+    else
+      handle_command_error(command, exstat);
   }
   dynstr_free(&ds_delimiter);
   DBUG_VOID_RETURN;
@@ -4778,6 +4808,16 @@ void select_connection_name(const char *
 
   set_current_connection(con);
 
+  /* Connection logging if enabled */
+  if (!disable_connect_log && !disable_query_log)
+  {
+    DYNAMIC_STRING *ds= &ds_res;
+
+    dynstr_append_mem(ds, "connection ", 11);
+    replace_dynstr_append(ds, name);
+    dynstr_append_mem(ds, ";\n", 2);
+  }
+
   DBUG_VOID_RETURN;
 }
 
@@ -4865,6 +4905,16 @@ void do_close_connection(struct st_comma
     var_set_string("$CURRENT_CONNECTION", con->name);
   }
 
+  /* Connection logging if enabled */
+  if (!disable_connect_log && !disable_query_log)
+  {
+    DYNAMIC_STRING *ds= &ds_res;
+
+    dynstr_append_mem(ds, "disconnect ", 11);
+    replace_dynstr_append(ds, ds_connection.str);
+    dynstr_append_mem(ds, ";\n", 2);
+  }
+
   DBUG_VOID_RETURN;
 }
 
@@ -4999,6 +5049,13 @@ int connect_n_handle_errors(struct st_co
     dynstr_append_mem(ds, delimiter, delimiter_length);
     dynstr_append_mem(ds, "\n", 1);
   }
+  /* Simlified logging if enabled */
+  if (!disable_connect_log && !disable_query_log)
+  {
+    replace_dynstr_append(ds, command->query);
+    dynstr_append_mem(ds, ";\n", 2);
+  }
+  
   while (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
                           CLIENT_MULTI_STATEMENTS))
   {
@@ -5187,6 +5244,7 @@ void do_connect(struct st_command *comma
 
 #ifdef EMBEDDED_LIBRARY
   con_slot->query_done= 1;
+  con_slot->has_thread= FALSE;
 #endif
   if (!mysql_init(&con_slot->mysql))
     die("Failed on mysql_init()");
@@ -5507,6 +5565,8 @@ int read_line(char *buf, int size)
   char c, UNINIT_VAR(last_quote);
   char *p= buf, *buf_end= buf + size - 1;
   int skip_char= 0;
+  my_bool have_slash= FALSE;
+  
   enum {R_NORMAL, R_Q, R_SLASH_IN_Q,
         R_COMMENT, R_LINE_START} state= R_LINE_START;
   DBUG_ENTER("read_line");
@@ -5578,9 +5638,13 @@ int read_line(char *buf, int size)
       }
       else if (c == '\'' || c == '"' || c == '`')
       {
-        last_quote= c;
-	state= R_Q;
+        if (! have_slash) 
+        {
+	  last_quote= c;
+	  state= R_Q;
+	}
       }
+      have_slash= (c == '\\');
       break;
 
     case R_COMMENT:
@@ -7301,11 +7365,13 @@ void run_query(struct st_connection *cn,
                            (flags & QUERY_REAP_FLAG));
   DBUG_ENTER("run_query");
 
-  init_dynamic_string(&ds_warnings, NULL, 0, 256);
-
   if (cn->pending && (flags & QUERY_SEND_FLAG))
     die ("Cannot run query on connection between send and reap");
 
+  if (!(flags & QUERY_SEND_FLAG) && !cn->pending)
+    die ("Cannot reap on a connection without pending send");
+  
+  init_dynamic_string(&ds_warnings, NULL, 0, 256);
   /*
     Evaluate query if this is an eval command
   */
@@ -8046,6 +8112,8 @@ int main(int argc, char **argv)
       case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break;
       case Q_ENABLE_RESULT_LOG:  disable_result_log=0; break;
       case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
+      case Q_ENABLE_CONNECT_LOG:   disable_connect_log=0; break;
+      case Q_DISABLE_CONNECT_LOG:  disable_connect_log=1; break;
       case Q_ENABLE_WARNINGS:    disable_warnings=0; break;
       case Q_DISABLE_WARNINGS:   disable_warnings=1; break;
       case Q_ENABLE_INFO:        disable_info=0; break;

=== modified file 'config/ac-macros/maintainer.m4'
--- a/config/ac-macros/maintainer.m4	2010-07-09 12:51:21 +0000
+++ b/config/ac-macros/maintainer.m4	2010-09-24 12:36:31 +0000
@@ -16,7 +16,7 @@ AC_DEFUN([MY_MAINTAINER_MODE], [
 AC_DEFUN([MY_MAINTAINER_MODE_WARNINGS], [
   # Setup GCC warning options.
   AS_IF([test "$GCC" = "yes"], [
-    C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Werror"
+    C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror"
     CXX_WARNINGS="${C_WARNINGS} -Wno-unused-parameter"
   ])
 

=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c	2010-05-20 06:31:03 +0000
+++ b/dbug/dbug.c	2010-09-22 19:33:18 +0000
@@ -455,13 +455,8 @@ static void DbugParse(CODE_STATE *cs, co
   rel= control[0] == '+' || control[0] == '-';
   if ((!rel || (!stack->out_file && !stack->next)))
   {
-    /*
-      We need to free what's already in init_settings, because unlike
-      the thread related stack frames there's a chance that something
-      is in these variables already.
-    */
-    if (stack == &init_settings)
-      FreeState(cs, stack, 0);
+    /* Free memory associated with the state before resetting its members */
+    FreeState(cs, stack, 0);
     stack->flags= 0;
     stack->delay= 0;
     stack->maxdepth= 0;
@@ -1447,8 +1442,8 @@ static void PushState(CODE_STATE *cs)
   struct settings *new_malloc;
 
   new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings));
+  bzero(new_malloc, sizeof(struct settings));
   new_malloc->next= cs->stack;
-  new_malloc->out_file= NULL;
   cs->stack= new_malloc;
 }
 
@@ -1957,7 +1952,7 @@ static FILE *OpenProfile(CODE_STATE *cs,
 
 static void DBUGCloseFile(CODE_STATE *cs, FILE *fp)
 {
-  if (fp != stderr && fp != stdout && fclose(fp) == EOF)
+  if (fp != NULL && fp != stderr && fp != stdout && fclose(fp) == EOF)
   {
     pthread_mutex_lock(&THR_LOCK_dbug);
     (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process);

=== modified file 'include/mysql.h'
--- a/include/mysql.h	2010-07-20 17:44:29 +0000
+++ b/include/mysql.h	2010-09-07 07:18:01 +0000
@@ -224,7 +224,8 @@ struct st_mysql_options {
 
 enum mysql_status 
 {
-  MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT
+  MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT,
+  MYSQL_STATUS_STATEMENT_GET_RESULT
 };
 
 enum mysql_protocol_type 

=== modified file 'include/mysql.h.pp'
--- a/include/mysql.h.pp	2010-07-20 17:44:29 +0000
+++ b/include/mysql.h.pp	2010-09-07 07:18:01 +0000
@@ -293,7 +293,8 @@ struct st_mysql_options {
 };
 enum mysql_status
 {
-  MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT
+  MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT,
+  MYSQL_STATUS_STATEMENT_GET_RESULT
 };
 enum mysql_protocol_type
 {

=== modified file 'include/sha1.h'
--- a/include/sha1.h	2006-12-31 00:02:27 +0000
+++ b/include/sha1.h	2010-10-05 14:05:37 +0000
@@ -6,12 +6,13 @@
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
 
 /*
  This is the header file for code which implements the Secure
@@ -25,6 +26,38 @@
  Please read the file sha1.c for more information.
 
  Modified 2002 by Peter Zaitsev to better follow MySQL standards
+
+  Original Source from: http://www.faqs.org/rfcs/rfc3174.html
+
+  Copyright (C) The Internet Society (2001).  All Rights Reserved.
+
+  This document and translations of it may be copied and furnished to
+  others, and derivative works that comment on or otherwise explain it
+  or assist in its implementation may be prepared, copied, published
+  and distributed, in whole or in part, without restriction of any
+  kind, provided that the above copyright notice and this paragraph are
+  included on all such copies and derivative works.  However, this
+  document itself may not be modified in any way, such as by removing
+  the copyright notice or references to the Internet Society or other
+  Internet organizations, except as needed for the purpose of
+  developing Internet standards in which case the procedures for
+  copyrights defined in the Internet Standards process must be
+  followed, or as required to translate it into languages other than
+  English.
+
+  The limited permissions granted above are perpetual and will not be
+  revoked by the Internet Society or its successors or assigns.
+
+  This document and the information contained herein is provided on an
+  "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
+  TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+  BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+  HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+
+  Acknowledgement 
+  Funding for the RFC Editor function is currently provided by the 
+  Internet Society. 
 */
 
 

=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c	2010-07-06 22:31:54 +0000
+++ b/libmysql/libmysql.c	2010-09-07 07:18:01 +0000
@@ -2503,6 +2503,8 @@ static my_bool execute(MYSQL_STMT *stmt,
       set_stmt_errmsg(stmt, net);
     DBUG_RETURN(1);
   }
+  else if (mysql->status == MYSQL_STATUS_GET_RESULT)
+    stmt->mysql->status= MYSQL_STATUS_STATEMENT_GET_RESULT;
   DBUG_RETURN(0);
 }
 
@@ -2641,7 +2643,7 @@ static int stmt_read_row_unbuffered(MYSQ
     set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate, NULL);
     return 1;
   }
-  if (mysql->status != MYSQL_STATUS_GET_RESULT)
+  if (mysql->status != MYSQL_STATUS_STATEMENT_GET_RESULT)
   {
     set_stmt_error(stmt, stmt->unbuffered_fetch_cancelled ?
                    CR_FETCH_CANCELED : CR_COMMANDS_OUT_OF_SYNC,
@@ -4847,7 +4849,7 @@ int STDCALL mysql_stmt_store_result(MYSQ
       DBUG_RETURN(1);
     }
   }
-  else if (mysql->status != MYSQL_STATUS_GET_RESULT)
+  else if (mysql->status != MYSQL_STATUS_STATEMENT_GET_RESULT)
   {
     set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate, NULL);
     DBUG_RETURN(1);

=== modified file 'mysql-test/collections/default.daily'
--- a/mysql-test/collections/default.daily	2010-03-02 12:43:21 +0000
+++ b/mysql-test/collections/default.daily	2010-10-05 08:47:03 +0000
@@ -1,5 +1,3 @@
-perl mysql-test-run.pl --timer --force --comment=rpl_ndb_row --vardir=var-rpl_ndb_row --suite=rpl_ndb,ndb --mysqld=--binlog-format=row --experimental=collections/default.experimental
-
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental
 perl mysql-test-run.pl --timer --force --parallel=auto --comment=embedded --vardir=var-emebbed  --embedded --experimental=collections/default.experimental

=== modified file 'mysql-test/include/index_merge_ror_cpk.inc'
--- a/mysql-test/include/index_merge_ror_cpk.inc	2006-08-16 12:58:49 +0000
+++ b/mysql-test/include/index_merge_ror_cpk.inc	2010-09-16 12:13:53 +0000
@@ -126,3 +126,19 @@ WHERE
 
 drop table t1;
 
+--echo #
+--echo # Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB
+--echo #
+CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (2);
+CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1),
+                 PRIMARY KEY (f1), KEY (f2), KEY (f3) );
+INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, '');
+
+SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+
+EXPLAIN SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+
+DROP TABLE t1,t2;

=== modified file 'mysql-test/include/setup_fake_relay_log.inc'
--- a/mysql-test/include/setup_fake_relay_log.inc	2010-02-02 15:16:47 +0000
+++ b/mysql-test/include/setup_fake_relay_log.inc	2010-09-15 12:56:22 +0000
@@ -72,7 +72,7 @@ copy_file $fake_relay_log $_fake_relay_l
 
 if (`SELECT LENGTH(@@secure_file_priv) > 0`)
 {
-  -- let $_file_priv_dir= `SELECT @@secure_file_priv`;
+  -- let $_file_priv_dir= `SELECT @@secure_file_priv`
   -- let $_suffix= `SELECT UUID()`
   -- let $_tmp_file= $_file_priv_dir/fake-index.$_suffix
 

=== modified file 'mysql-test/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm	2010-08-04 10:19:51 +0000
+++ b/mysql-test/lib/mtr_cases.pm	2010-10-05 08:24:45 +0000
@@ -684,6 +684,13 @@ sub process_opts_file {
 	next;
       }
 
+      $value= mtr_match_prefix($opt, "--testcase-timeout=");
+      if ( defined $value ) {
+	# Overrides test case timeout for this test
+	$tinfo->{'case-timeout'}= $value;
+	next;
+      }
+
       # Ok, this was a real option, add it
       push(@{$tinfo->{$opt_name}}, $opt);
     }
@@ -902,7 +909,7 @@ sub collect_one_test_case {
     {
       # Ndb is not supported, skip it
       $tinfo->{'skip'}= 1;
-      $tinfo->{'comment'}= "No ndbcluster support";
+      $tinfo->{'comment'}= "No ndbcluster support or ndb tests not enabled";
       return $tinfo;
     }
     elsif ( $::opt_skip_ndbcluster )

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2010-08-04 10:19:51 +0000
+++ b/mysql-test/mysql-test-run.pl	2010-10-05 08:24:45 +0000
@@ -110,12 +110,24 @@ my $path_vardir_trace;          # unix f
 my $opt_tmpdir;                 # Path to use for tmp/ dir
 my $opt_tmpdir_pid;
 
+my $opt_start;
+my $opt_start_dirty;
+my $opt_start_exit;
+my $start_only;
+
 END {
   if ( defined $opt_tmpdir_pid and $opt_tmpdir_pid == $$ )
   {
-    # Remove the tempdir this process has created
-    mtr_verbose("Removing tmpdir '$opt_tmpdir");
-    rmtree($opt_tmpdir);
+    if (!$opt_start_exit)
+    {
+      # Remove the tempdir this process has created
+      mtr_verbose("Removing tmpdir $opt_tmpdir");
+      rmtree($opt_tmpdir);
+    }
+    else
+    {
+      mtr_warning("tmpdir $opt_tmpdir should be removed after the server has finished");
+    }
   }
 }
 
@@ -212,20 +224,16 @@ my $opt_suite_timeout   = $ENV{MTR_SUITE
 my $opt_shutdown_timeout= $ENV{MTR_SHUTDOWN_TIMEOUT} ||  10; # seconds
 my $opt_start_timeout   = $ENV{MTR_START_TIMEOUT}    || 180; # seconds
 
-sub testcase_timeout { return $opt_testcase_timeout * 60; };
 sub suite_timeout { return $opt_suite_timeout * 60; };
 sub check_timeout { return $opt_testcase_timeout * 6; };
 
-my $opt_start;
-my $opt_start_dirty;
-my $opt_start_exit;
-my $start_only;
 my $opt_wait_all;
 my $opt_user_args;
 my $opt_repeat= 1;
 my $opt_retry= 3;
 my $opt_retry_failure= env_or_val(MTR_RETRY_FAILURE => 2);
 my $opt_reorder= 1;
+my $opt_force_restart= 0;
 
 my $opt_strace_client;
 
@@ -241,9 +249,21 @@ my $opt_callgrind;
 my %mysqld_logs;
 my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions.
 
+sub testcase_timeout ($) {
+  my ($tinfo)= @_;
+  if (exists $tinfo->{'case-timeout'}) {
+    # Return test specific timeout if *longer* that the general timeout
+    my $test_to= $tinfo->{'case-timeout'};
+    $test_to*= 10 if $opt_valgrind;
+    return $test_to * 60 if $test_to > $opt_testcase_timeout;
+  }
+  return $opt_testcase_timeout * 60;
+}
+
 our $opt_warnings= 1;
 
-our $opt_skip_ndbcluster= 0;
+our $opt_include_ndbcluster= 0;
+our $opt_skip_ndbcluster= 1;
 
 my $exe_ndbd;
 my $exe_ndb_mgmd;
@@ -838,6 +858,7 @@ sub command_line_setup {
              # Control what test suites or cases to run
              'force'                    => \$opt_force,
              'with-ndbcluster-only'     => \&collect_option,
+             'include-ndbcluster'       => \$opt_include_ndbcluster,
              'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
              'suite|suites=s'           => \$opt_suites,
              'skip-rpl'                 => \&collect_option,
@@ -914,6 +935,7 @@ sub command_line_setup {
              'report-features'          => \$opt_report_features,
              'comment=s'                => \$opt_comment,
              'fast'                     => \$opt_fast,
+	     'force-restart'            => \$opt_force_restart,
              'reorder!'                 => \$opt_reorder,
              'enable-disabled'          => \&collect_option,
              'verbose+'                 => \$opt_verbose,
@@ -2087,6 +2109,11 @@ sub environment_setup {
   # to detect that valgrind is being used from test cases
   $ENV{'VALGRIND_TEST'}= $opt_valgrind;
 
+  # Add dir of this perl to aid mysqltest in finding perl
+  my $perldir= dirname($^X);
+  my $pathsep= ":";
+  $pathsep= ";" if IS_WINDOWS && ! IS_CYGWIN;
+  $ENV{'PATH'}= "$ENV{'PATH'}".$pathsep.$perldir;
 }
 
 
@@ -2362,6 +2389,11 @@ sub vs_config_dirs ($$) {
 sub check_ndbcluster_support ($) {
   my $mysqld_variables= shift;
 
+  if ($opt_include_ndbcluster)
+  {
+    $opt_skip_ndbcluster= 0;
+  }
+
   if ($opt_skip_ndbcluster)
   {
     mtr_report(" - skipping ndbcluster");
@@ -3469,7 +3501,7 @@ sub run_testcase ($) {
     }
   }
 
-  my $test_timeout= start_timer(testcase_timeout());
+  my $test_timeout= start_timer(testcase_timeout($tinfo));
 
   do_before_run_mysqltest($tinfo);
 
@@ -3563,6 +3595,9 @@ sub run_testcase ($) {
 	# Try to get reason from test log file
 	find_testcase_skipped_reason($tinfo);
 	mtr_report_test_skipped($tinfo);
+	# Restart if skipped due to missing perl, it may have had side effects
+	stop_all_servers($opt_shutdown_timeout)
+	  if ($tinfo->{'comment'} =~ /^perl not found/);
       }
       elsif ( $res == 65 )
       {
@@ -3669,7 +3704,7 @@ sub run_testcase ($) {
     {
       my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log";
       $tinfo->{comment}=
-        "Test case timeout after ".testcase_timeout().
+        "Test case timeout after ".testcase_timeout($tinfo).
 	  " seconds\n\n";
       # Add 20 last executed commands from test case log file
       if  (-e $log_file_name)
@@ -3678,7 +3713,7 @@ sub run_testcase ($) {
 	   "== $log_file_name == \n".
 	     mtr_lastlinesfromfile($log_file_name, 20)."\n";
       }
-      $tinfo->{'timeout'}= testcase_timeout(); # Mark as timeout
+      $tinfo->{'timeout'}= testcase_timeout($tinfo); # Mark as timeout
       run_on_all($tinfo, 'analyze-timeout');
 
       report_failure_and_restart($tinfo);
@@ -4502,6 +4537,11 @@ sub server_need_restart {
     return 1;
   }
 
+  if ( $opt_force_restart ) {
+    mtr_verbose_restart($server, "forced restart turned on");
+    return 1;
+  }
+
   if ( $tinfo->{template_path} ne $current_config_name)
   {
     mtr_verbose_restart($server, "using different config file");
@@ -5416,7 +5456,8 @@ Options to control what test suites or c
 
   force                 Continue to run the suite after failure
   with-ndbcluster-only  Run only tests that include "ndb" in the filename
-  skip-ndb[cluster]     Skip all tests that need cluster
+  skip-ndb[cluster]     Skip all tests that need cluster. Default.
+  include-ndb[cluster]  Enable all tests that need cluster
   do-test=PREFIX or REGEX
                         Run test cases which name are prefixed with PREFIX
                         or fulfills REGEX
@@ -5531,6 +5572,7 @@ Misc options
                         servers to exit before finishing the process
   fast                  Run as fast as possible, dont't wait for servers
                         to shutdown etc.
+  force-restart         Always restart servers between tests
   parallel=N            Run tests in N parallel threads (default=1)
                         Use parallel=auto for auto-setting of N
   repeat=N              Run each test N number of times

=== modified file 'mysql-test/r/index_merge_innodb.result'
--- a/mysql-test/r/index_merge_innodb.result	2006-09-18 14:55:56 +0000
+++ b/mysql-test/r/index_merge_innodb.result	2010-09-16 12:13:53 +0000
@@ -581,3 +581,21 @@ WHERE
 `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
 `TESTID`='' AND `UCCHECK`='';
 drop table t1;
+#
+# Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB
+#
+CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (2);
+CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1),
+PRIMARY KEY (f1), KEY (f2), KEY (f3) );
+INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, '');
+SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+f1
+2
+EXPLAIN SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	const	PRIMARY	PRIMARY	4	const	1	Using index
+2	DEPENDENT SUBQUERY	t2	index_merge	f2,f3	f3,f2	2,5	NULL	1	Using intersect(f3,f2); Using where; Using index
+DROP TABLE t1,t2;

=== modified file 'mysql-test/r/index_merge_myisam.result'
--- a/mysql-test/r/index_merge_myisam.result	2009-06-15 14:36:51 +0000
+++ b/mysql-test/r/index_merge_myisam.result	2010-09-16 12:13:53 +0000
@@ -1416,6 +1416,24 @@ WHERE
 `TESTID`='' AND `UCCHECK`='';
 drop table t1;
 #
+# Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB
+#
+CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (2);
+CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1),
+PRIMARY KEY (f1), KEY (f2), KEY (f3) );
+INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, '');
+SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+f1
+2
+EXPLAIN SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	system	PRIMARY	NULL	NULL	NULL	1	
+2	DEPENDENT SUBQUERY	t2	ref	f2,f3	f2	5		1	Using where
+DROP TABLE t1,t2;
+#
 # Generic @@optimizer_switch tests (move those into a separate file if
 #  we get another @@optimizer_switch user)
 #

=== modified file 'mysql-test/r/merge.result'
--- a/mysql-test/r/merge.result	2010-03-19 06:01:02 +0000
+++ b/mysql-test/r/merge.result	2010-04-26 13:44:10 +0000
@@ -2298,4 +2298,45 @@ t2 WHERE b SOUNDS LIKE e AND d = 1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 DROP TABLE t2, t1;
+#
+# Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
+#
+DROP TABLE IF EXISTS m1, t1;
+CREATE TABLE t1 (c1 INT) ENGINE=MYISAM;
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST;
+LOCK TABLE m1 READ;
+REPAIR TABLE m1 USE_FRM;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	note	The storage engine for the table doesn't support repair
+UNLOCK TABLES;
+REPAIR TABLE m1 USE_FRM;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	note	The storage engine for the table doesn't support repair
+DROP TABLE m1,t1;
+CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
+REPAIR TABLE m1 USE_FRM;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	Error	Can't open table
+test.m1	repair	error	Corrupt
+CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM;
+REPAIR TABLE m1 USE_FRM;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	note	The storage engine for the table doesn't support repair
+REPAIR TABLE m1;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	note	The storage engine for the table doesn't support repair
+DROP TABLE m1, t1;
+CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
+REPAIR TABLE m1 USE_FRM;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	Error	Table 'test.m1' doesn't exist
+test.m1	repair	error	Corrupt
+CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM;
+REPAIR TABLE m1 USE_FRM;
+Table	Op	Msg_type	Msg_text
+m1	repair	error	Cannot repair temporary table from .frm file
+REPAIR TABLE m1;
+Table	Op	Msg_type	Msg_text
+test.m1	repair	note	The storage engine for the table doesn't support repair
+DROP TABLE m1, t1;
 End of 5.1 tests

=== modified file 'mysql-test/r/multi_update.result'
--- a/mysql-test/r/multi_update.result	2010-05-24 13:54:08 +0000
+++ b/mysql-test/r/multi_update.result	2010-09-07 07:58:05 +0000
@@ -639,4 +639,24 @@ SET SESSION sql_safe_updates = 1;
 UPDATE IGNORE t1, t1 t1a SET t1.a = 1 WHERE t1a.a = 1;
 ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
 DROP TABLE t1;
+#
+# Bug#54543: update ignore with incorrect subquery leads to assertion
+# failure: inited==INDEX
+#
+SET SESSION sql_safe_updates = 0;
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (1), (2);
+CREATE TABLE t2 ( a INT );
+INSERT INTO t2 VALUES (1), (2);
+CREATE TABLE t3 ( a INT );
+INSERT INTO t3 VALUES (1), (2);
+# Should not crash
+UPDATE IGNORE
+( SELECT ( SELECT COUNT(*) FROM t1 GROUP BY a, @v ) a FROM t2 ) x, t3
+SET t3.a = 0;
+Warnings:
+Error	1242	Subquery returns more than 1 row
+Error	1242	Subquery returns more than 1 row
+DROP TABLE t1, t2, t3;
+SET SESSION sql_safe_updates = DEFAULT;
 end of tests

=== modified file 'mysql-test/r/mysqltest.result'
--- a/mysql-test/r/mysqltest.result	2010-08-04 08:52:45 +0000
+++ b/mysql-test/r/mysqltest.result	2010-09-22 08:57:10 +0000
@@ -177,6 +177,9 @@ mysqltest: At line 1: End of line junk d
 "
 mysqltest: At line 1: Extra delimiter ";" found
 mysqltest: At line 1: Extra delimiter ";" found
+mysqltest: At line 1: Spurious text after `query` expression
+mysqltest: At line 1: Spurious text after `query` expression
+mysqltest: At line 2: Spurious text after `query` expression
 mysqltest: At line 1: Missing argument(s) to 'error'
 mysqltest: At line 1: Missing argument(s) to 'error'
 mysqltest: At line 1: The sqlstate definition must start with an uppercase S
@@ -262,6 +265,9 @@ a long \$where variable content
 
 banana = banana
 Not a banana: ba\$cat\$cat
+with\`some"escaped\'quotes
+with\`some"escaped\'quotes
+single'tick`backtick
 mysqltest: At line 1: Missing arguments to let
 mysqltest: At line 1: Missing variable name in let
 mysqltest: At line 1: Missing assignment operator in let
@@ -446,12 +452,16 @@ mysqltest: At line 1: Missing required a
 mysqltest: At line 1: query 'connect  con2,localhost,root,,illegal_db' failed: 1049: Unknown database 'illegal_db'
 mysqltest: At line 1: Illegal argument for port: 'illegal_port'
 mysqltest: At line 1: Illegal option to connect: SMTP
-OK
-mysqltest: The test didn't produce any output
+200 connects succeeded
 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 3: connection 'test_con1' not found in connection pool
 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 2: Connection test_con1 already exists
 show tables;
 ERROR 3D000: No database selected
+connect  con1,localhost,root,,;
+connection default;
+connection con1;
+disconnect con1;
+connection default;
 Output from mysqltest-x.inc
 Output from mysqltest-x.inc
 Output from mysqltest-x.inc

=== modified file 'mysql-test/r/order_by.result'
--- a/mysql-test/r/order_by.result	2009-12-10 15:38:01 +0000
+++ b/mysql-test/r/order_by.result	2010-09-13 11:33:19 +0000
@@ -1617,4 +1617,25 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t1	range	a	a	5	NULL	2	Using where; Using temporary; Using filesort
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	10	Using join buffer
 DROP TABLE t1, t2;
+#
+# Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and
+# ORDER BY computed col
+#
+CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, KEY( a, b ) );
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+INSERT INTO t1 SELECT a + 5, b + 5 FROM t1;
+CREATE TABLE t2( a INT PRIMARY KEY, b INT );
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+INSERT INTO t2 SELECT a + 5, b + 5 FROM t2;
+EXPLAIN
+SELECT count(*) AS c, t1.a
+FROM t1 JOIN t2 ON t1.b = t2.a
+WHERE t2.b = 1
+GROUP BY t1.a
+ORDER by c
+LIMIT 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	a	8	NULL	10	Using index; Using temporary; Using filesort
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.b	1	Using where
+DROP TABLE t1, t2;
 End of 5.1 tests

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2010-03-22 12:30:27 +0000
+++ b/mysql-test/r/partition.result	2010-10-01 13:41:27 +0000
@@ -1,4 +1,44 @@
 drop table if exists t1, t2;
+#
+# Bug#57113: ha_partition::extra(ha_extra_function):
+#            Assertion `m_extra_cache' failed
+CREATE TABLE t1
+(id INT NOT NULL PRIMARY KEY,
+name VARCHAR(16) NOT NULL,
+year YEAR,
+INDEX name (name(8))
+)
+PARTITION BY HASH(id) PARTITIONS 2;
+INSERT INTO t1 VALUES ( 1, 'FooBar', '1924' );
+CREATE TABLE t2 (id INT);
+INSERT INTO t2 VALUES (1),(2);
+UPDATE t1, t2 SET t1.year = '1955' WHERE t1.name = 'FooBar';
+DROP TABLE t1, t2;
+#
+# Bug#55458: Partitioned MyISAM table gets crashed by multi-table update 
+#
+CREATE TABLE t1 (
+`id` int NOT NULL,
+`user_num` int DEFAULT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1,8601);
+INSERT INTO t1 VALUES (2,8601);
+INSERT INTO t1 VALUES (3,8601);
+INSERT INTO t1 VALUES (4,8601);
+CREATE TABLE t2 (
+`id` int(11) NOT NULL,
+`user_num` int DEFAULT NULL,
+`name` varchar(64) NOT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM CHARSET=latin1
+PARTITION BY HASH (id)
+PARTITIONS 2;
+INSERT INTO t2 VALUES (1,8601,'John');
+INSERT INTO t2 VALUES (2,8601,'JS');
+INSERT INTO t2 VALUES (3,8601,'John S');
+UPDATE t1, t2 SET t2.name = 'John Smith' WHERE t1.user_num = t2.user_num;
+DROP TABLE t1, t2;
 CREATE TABLE t1 (a INT, b INT)
 PARTITION BY LIST (a)
 SUBPARTITION BY HASH (b)
@@ -1382,7 +1422,7 @@ NULL
 2
 explain partitions select * from t1 where a is null or a < 0 or a > 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pn,p2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t1	pn,p2	ALL	NULL	NULL	NULL	NULL	2	Using where
 drop table t1;
 CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(20)) 
 ENGINE=MyISAM DEFAULT CHARSET=latin1

=== added file 'mysql-test/r/partition_binlog_stmt.result'
--- a/mysql-test/r/partition_binlog_stmt.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/partition_binlog_stmt.result	2010-10-01 11:39:04 +0000
@@ -0,0 +1,13 @@
+DROP TABLE IF EXISTS t1;
+#
+# Bug#51851: Server with SBR locks mutex twice on LOAD DATA into
+#            partitioned MyISAM table
+CREATE TABLE t1
+(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+name TINYBLOB NOT NULL,
+modified TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+INDEX namelocs (name(255))) ENGINE = MyISAM
+PARTITION BY HASH(id) PARTITIONS 2;
+LOAD DATA LOCAL INFILE 'init_file.txt'
+INTO TABLE t1 (name);
+DROP TABLE t1;

=== modified file 'mysql-test/r/partition_error.result'
--- a/mysql-test/r/partition_error.result	2010-05-25 13:41:00 +0000
+++ b/mysql-test/r/partition_error.result	2010-09-22 19:33:18 +0000
@@ -1008,4 +1008,14 @@ PARTITION p VALUES LESS THAN (1219089600
 PARTITION pmax VALUES LESS THAN MAXVALUE);
 ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
 DROP TABLE old;
+#
+# Bug #56709: Memory leaks at running the 5.1 test suite
+# 
+CREATE TABLE t1 (a TIMESTAMP NOT NULL PRIMARY KEY);
+ALTER TABLE t1
+PARTITION BY RANGE (EXTRACT(DAY FROM a)) (
+PARTITION p VALUES LESS THAN (18),
+PARTITION pmax VALUES LESS THAN MAXVALUE);
+ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
+DROP TABLE t1;
 End of 5.1 tests

=== modified file 'mysql-test/r/partition_hash.result'
--- a/mysql-test/r/partition_hash.result	2008-07-07 20:42:19 +0000
+++ b/mysql-test/r/partition_hash.result	2010-08-27 08:43:51 +0000
@@ -69,25 +69,25 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	p0,p1,p2,p3	ALL	NULL	NULL	NULL	NULL	9	Using where
 explain partitions select * from t1 where a is null or (a >= 5 and a <= 7);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p2,p3	ALL	NULL	NULL	NULL	NULL	9	Using where
+1	SIMPLE	t1	p0,p2,p3	ALL	NULL	NULL	NULL	NULL	7	Using where
 explain partitions select * from t1 where a is null;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	9	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	3	Using where
 explain partitions select * from t1 where a is not null;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p0,p1,p2,p3	ALL	NULL	NULL	NULL	NULL	9	Using where
 explain partitions select * from t1 where a >= 1 and a < 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1	ALL	NULL	NULL	NULL	NULL	9	Using where
+1	SIMPLE	t1	p0,p1	ALL	NULL	NULL	NULL	NULL	5	Using where
 explain partitions select * from t1 where a >= 3 and a <= 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p1,p2	ALL	NULL	NULL	NULL	NULL	9	Using where
+1	SIMPLE	t1	p1,p2	ALL	NULL	NULL	NULL	NULL	4	Using where
 explain partitions select * from t1 where a > 2 and a < 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p1	ALL	NULL	NULL	NULL	NULL	9	Using where
+1	SIMPLE	t1	p1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a > 3 and a <= 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2,p3	ALL	NULL	NULL	NULL	NULL	9	Using where
+1	SIMPLE	t1	p2,p3	ALL	NULL	NULL	NULL	NULL	4	Using where
 explain partitions select * from t1 where a > 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p0,p1,p2,p3	ALL	NULL	NULL	NULL	NULL	9	Using where

=== modified file 'mysql-test/r/partition_innodb.result'
--- a/mysql-test/r/partition_innodb.result	2010-04-12 10:12:20 +0000
+++ b/mysql-test/r/partition_innodb.result	2010-08-27 08:43:51 +0000
@@ -22,31 +22,31 @@ insert INTO t1 VALUES (110);
 ERROR HY000: Table has no partition for value 110
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	5	Using where
+1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	5	Using where
+1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	5	Using where
+1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 89;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p90	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p90	ALL	NULL	NULL	NULL	NULL	3	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 89;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p90	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p90	ALL	NULL	NULL	NULL	NULL	3	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 89;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 100;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 100;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 100;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1		ALL	NULL	NULL	NULL	NULL	0	Using where
 DROP TABLE t1;
 #
 # Bug#50104: Partitioned table with just 1 partion works with fk

=== modified file 'mysql-test/r/partition_pruning.result'
--- a/mysql-test/r/partition_pruning.result	2010-03-12 10:52:38 +0000
+++ b/mysql-test/r/partition_pruning.result	2010-08-26 15:14:18 +0000
@@ -1,5 +1,29 @@
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 #
+# Bug#53806: Wrong estimates for range query in partitioned MyISAM table
+# Bug#46754: 'rows' field doesn't reflect partition pruning
+#
+CREATE TABLE t1 (a INT PRIMARY KEY)
+PARTITION BY RANGE (a) (
+PARTITION p0 VALUES LESS THAN (1),
+PARTITION p1 VALUES LESS THAN (2),
+PARTITION p2 VALUES LESS THAN (3),
+PARTITION p3 VALUES LESS THAN (4),
+PARTITION p4 VALUES LESS THAN (5),
+PARTITION p5 VALUES LESS THAN (6),
+PARTITION max VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8);
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
+id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
+#	#	#	#	#	#	#	#	#	3	#
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
+id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
+#	#	#	#	#	#	#	#	#	9	#
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
+id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
+#	#	#	#	#	#	#	#	#	3	#
+DROP TABLE t1;
+#
 # Bug#49742: Partition Pruning not working correctly for RANGE
 #
 CREATE TABLE t1 (a INT PRIMARY KEY)
@@ -89,7 +113,7 @@ a
 1
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p0,p1	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a <= 2;
 a
 -1
@@ -98,7 +122,7 @@ a
 2
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2	index	PRIMARY	PRIMARY	4	NULL	4	Using where; Using index
 SELECT * FROM t1 WHERE a <= 3;
 a
 -1
@@ -108,7 +132,7 @@ a
 3
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3	index	PRIMARY	PRIMARY	4	NULL	5	Using where; Using index
 SELECT * FROM t1 WHERE a <= 4;
 a
 -1
@@ -119,7 +143,7 @@ a
 4
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4	index	PRIMARY	PRIMARY	4	NULL	6	Using where; Using index
 SELECT * FROM t1 WHERE a <= 5;
 a
 -1
@@ -131,7 +155,7 @@ a
 5
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4,p5	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4,p5	index	PRIMARY	PRIMARY	4	NULL	7	Using where; Using index
 SELECT * FROM t1 WHERE a <= 6;
 a
 -1
@@ -213,7 +237,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p1,p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p1,p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	8	Using where; Using index
 SELECT * FROM t1 WHERE a >= 2;
 a
 2
@@ -225,7 +249,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	7	Using where; Using index
 SELECT * FROM t1 WHERE a >= 3;
 a
 3
@@ -236,7 +260,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	6	Using where; Using index
 SELECT * FROM t1 WHERE a >= 4;
 a
 4
@@ -246,7 +270,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	5	Using where; Using index
 SELECT * FROM t1 WHERE a >= 5;
 a
 5
@@ -255,7 +279,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p5,max	index	PRIMARY	PRIMARY	4	NULL	4	Using where; Using index
 SELECT * FROM t1 WHERE a >= 6;
 a
 6
@@ -263,14 +287,14 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a >= 7;
 a
 7
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 7;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a > 1;
 a
 2
@@ -282,7 +306,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p2,p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	7	Using where; Using index
 SELECT * FROM t1 WHERE a > 2;
 a
 3
@@ -293,7 +317,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p3,p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	6	Using where; Using index
 SELECT * FROM t1 WHERE a > 3;
 a
 4
@@ -303,7 +327,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p4,p5,max	index	PRIMARY	PRIMARY	4	NULL	5	Using where; Using index
 SELECT * FROM t1 WHERE a > 4;
 a
 5
@@ -312,7 +336,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p5,max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	p5,max	index	PRIMARY	PRIMARY	4	NULL	4	Using where; Using index
 SELECT * FROM t1 WHERE a > 5;
 a
 6
@@ -320,20 +344,20 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a > 6;
 a
 7
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a > 7;
 a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 7;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	10	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 DROP TABLE t1;
 CREATE TABLE t1 (a INT PRIMARY KEY)
 PARTITION BY RANGE (a) (
@@ -408,7 +432,7 @@ a
 1
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p0,p1	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a <= 2;
 a
 -1
@@ -417,7 +441,7 @@ a
 2
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2	index	PRIMARY	PRIMARY	4	NULL	4	Using where; Using index
 SELECT * FROM t1 WHERE a <= 3;
 a
 -1
@@ -427,7 +451,7 @@ a
 3
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3	index	PRIMARY	PRIMARY	4	NULL	5	Using where; Using index
 SELECT * FROM t1 WHERE a <= 4;
 a
 -1
@@ -438,7 +462,7 @@ a
 4
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1,p2,p3,p4	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p0,p1,p2,p3,p4	index	PRIMARY	PRIMARY	4	NULL	6	Using where; Using index
 SELECT * FROM t1 WHERE a <= 5;
 a
 -1
@@ -511,7 +535,7 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p1,p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p1,p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	7	Using where; Using index
 SELECT * FROM t1 WHERE a >= 2;
 a
 2
@@ -522,7 +546,7 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	6	Using where; Using index
 SELECT * FROM t1 WHERE a >= 3;
 a
 3
@@ -532,7 +556,7 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	5	Using where; Using index
 SELECT * FROM t1 WHERE a >= 4;
 a
 4
@@ -541,7 +565,7 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p4,max	index	PRIMARY	PRIMARY	4	NULL	4	Using where; Using index
 SELECT * FROM t1 WHERE a >= 5;
 a
 5
@@ -549,14 +573,14 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a >= 6;
 a
 6
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a > 1;
 a
 2
@@ -567,7 +591,7 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p2,p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	6	Using where; Using index
 SELECT * FROM t1 WHERE a > 2;
 a
 3
@@ -577,7 +601,7 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p3,p4,max	index	PRIMARY	PRIMARY	4	NULL	5	Using where; Using index
 SELECT * FROM t1 WHERE a > 3;
 a
 4
@@ -586,7 +610,7 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4,max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	p4,max	index	PRIMARY	PRIMARY	4	NULL	4	Using where; Using index
 SELECT * FROM t1 WHERE a > 4;
 a
 5
@@ -594,20 +618,20 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a > 5;
 a
 6
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 SELECT * FROM t1 WHERE a > 6;
 a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	9	Using where; Using index
+1	SIMPLE	t1	max	index	PRIMARY	PRIMARY	4	NULL	3	Using where; Using index
 DROP TABLE t1;
 # test of RANGE and index
 CREATE TABLE t1 (a DATE, KEY(a))
@@ -757,10 +781,10 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	range	a	a	4	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p2001-01-01	index	a	a	4	NULL	7	Using where; Using index
+1	SIMPLE	t1	pNULL,p2001-01-01	index	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p2001-01-01	index	a	a	4	NULL	7	Using where; Using index
+1	SIMPLE	t1	pNULL,p2001-01-01	index	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	pNULL	ref	a	a	4	const	1	Using where; Using index
@@ -880,34 +904,34 @@ a
 1001-01-01
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p2001-01-01	ALL	NULL	NULL	NULL	NULL	4	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p1001-01-01	system	NULL	NULL	NULL	NULL	1	
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL	ALL	NULL	NULL	NULL	NULL	3	Using where
 # Disabling warnings for the invalid date
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -917,25 +941,25 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p2001-01-01	ALL	NULL	NULL	NULL	NULL	4	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p2001-01-01	ALL	NULL	NULL	NULL	NULL	4	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL	ALL	NULL	NULL	NULL	NULL	3	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p1001-01-01,p2001-01-01	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p0001-01-01,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 DROP TABLE t1;
 # test of LIST and index
 CREATE TABLE t1 (a DATE, KEY(a))
@@ -1086,10 +1110,10 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2001-01-01,pNULL	index	a	a	4	NULL	7	Using where; Using index
+1	SIMPLE	t1	p2001-01-01,pNULL	index	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2001-01-01,pNULL	index	a	a	4	NULL	7	Using where; Using index
+1	SIMPLE	t1	p2001-01-01,pNULL	index	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	pNULL	ref	a	a	4	const	1	Using where; Using index
@@ -1101,7 +1125,7 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	range	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01	index	a	a	4	NULL	7	Using where; Using index
+1	SIMPLE	t1	pNULL,p1001-01-01	index	a	a	4	NULL	4	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p0001-01-01,pNULL,p1001-01-01	range	a	a	4	NULL	3	Using where; Using index
@@ -1209,62 +1233,62 @@ a
 1001-01-01
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2001-01-01,pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p2001-01-01,pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2001-01-01,pNULL	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p2001-01-01,pNULL	ALL	NULL	NULL	NULL	NULL	4	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p1001-01-01	system	NULL	NULL	NULL	NULL	1	
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2001-01-01,pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p2001-01-01,pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2001-01-01,pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p2001-01-01,pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL	ALL	NULL	NULL	NULL	NULL	3	Using where
 # Disabling warnings for the invalid date
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2001-01-01,pNULL	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p2001-01-01,pNULL	ALL	NULL	NULL	NULL	NULL	4	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2001-01-01,pNULL	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p2001-01-01,pNULL	ALL	NULL	NULL	NULL	NULL	4	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL	ALL	NULL	NULL	NULL	NULL	3	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p0000-01-02,p1001-01-01	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	4	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0001-01-01,pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p0001-01-01,pNULL,p1001-01-01	ALL	NULL	NULL	NULL	NULL	5	Using where
 DROP TABLE t1;
 # Test with DATETIME column NOT NULL
 CREATE TABLE t1 (
@@ -1289,25 +1313,25 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	8	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090402	index	NULL	PRIMARY	12	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1315,99 +1339,99 @@ id	select_type	table	partitions	type	pos
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090402	index	NULL	PRIMARY	12	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p20090401,p20090402,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	12	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	12	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	12	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	12	NULL	6	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090402	index	NULL	PRIMARY	12	NULL	13	Using where; Using index
+1	SIMPLE	t1	p20090402	index	NULL	PRIMARY	12	NULL	3	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1440,21 +1464,21 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	7	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	7	NULL	7	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	7	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1462,79 +1486,79 @@ id	select_type	table	partitions	type	pos
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	7	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	7	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	7	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	7	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	7	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090403	index	NULL	PRIMARY	7	NULL	2	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	7	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402,p20090403	index	NULL	PRIMARY	7	NULL	7	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1542,19 +1566,19 @@ id	select_type	table	partitions	type	pos
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	8	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090402	index	NULL	PRIMARY	7	NULL	5	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1562,11 +1586,11 @@ id	select_type	table	partitions	type	pos
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	12	Using where; Using index
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	index	NULL	PRIMARY	7	NULL	10	Using where; Using index
 DROP TABLE t1;
 # Test with DATETIME column NULL
 CREATE TABLE t1 (
@@ -1590,25 +1614,25 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	8	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090402	ALL	NULL	NULL	NULL	NULL	3	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1616,99 +1640,99 @@ id	select_type	table	partitions	type	pos
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090402	ALL	NULL	NULL	NULL	NULL	3	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p20090401,p20090402,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	6	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090402	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p20090402	ALL	NULL	NULL	NULL	NULL	3	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1740,21 +1764,21 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	7	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	7	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1762,79 +1786,79 @@ id	select_type	table	partitions	type	pos
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	7	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	7	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	7	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090403	ALL	NULL	NULL	NULL	NULL	2	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	7	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402,p20090403	ALL	NULL	NULL	NULL	NULL	7	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1842,19 +1866,19 @@ id	select_type	table	partitions	type	pos
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	8	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090402	ALL	NULL	NULL	NULL	NULL	5	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -1862,11 +1886,11 @@ id	select_type	table	partitions	type	pos
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 EXPLAIN PARTITIONS SELECT * FROM t1
 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	12	Using where
+1	SIMPLE	t1	p20090401,p20090403,p20090404,p20090405	ALL	NULL	NULL	NULL	NULL	10	Using where
 DROP TABLE t1;
 # For better code coverage of the patch
 CREATE TABLE t1 (
@@ -1930,7 +1954,7 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t2	p0,p1	ALL	NULL	NULL	NULL	NULL	3	Using where
 explain partitions select * from t2 where a=1 and b=1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t2	p0	ALL	NULL	NULL	NULL	NULL	2	Using where
 create table t3 (
 a int
 )
@@ -1988,25 +2012,25 @@ id	select_type	table	partitions	type	pos
 explain partitions select * from t5
 where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_p0sp0,p0_p0sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_p0sp0,p0_p0sp1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t5 where (a=10 and b=2) or (a=10 and b=3)
 or (a=10 and b = 4);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t5	p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
 explain partitions select * from t5 where (c=1 and d=1);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_p0sp0,p1_p1sp0	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_p0sp0,p1_p1sp0	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t5 where (c=2 and d=1);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_p0sp1,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_p0sp1,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or 
 (c=2 and d=1);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_p0sp0,p0_p0sp1,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_p0sp0,p0_p0sp1,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	3	Using where
 explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or 
 (b=2 and c=2 and d=1);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t5	p0_p0sp0,p0_p0sp1,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t5	p0_p0sp0,p0_p0sp1,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	3	Using where
 create table t6 (a int not null) partition by LIST(a) (
 partition p1 values in (1),
 partition p3 values in (3),
@@ -2044,7 +2068,7 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t6	p5,p7,p9	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t6 where a >= 3 and a <= 8;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p3,p5,p7	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t6	p3,p5,p7	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t6 where a > 3 and a < 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
@@ -2086,7 +2110,7 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t6	p5,p7,p9	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t6 where a >= 3 and a <= 8;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t6	p3,p5,p7	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t6	p3,p5,p7	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t6 where a > 3 and a < 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
@@ -2325,7 +2349,7 @@ id	select_type	table	partitions	type	pos
 explain partitions
 select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	X	p1,p2	ALL	a	NULL	NULL	NULL	4	Using where
+1	SIMPLE	X	p1,p2	ALL	a	NULL	NULL	NULL	2	Using where
 1	SIMPLE	Y	p1,p2	ref	a	a	4	test.X.a	2	
 drop table t1;
 create table t1 (a int) partition by hash(a) partitions 20;
@@ -2338,7 +2362,7 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	p1,p2	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a >  1 and a <= 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2,p3	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t1	p2,p3	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a >= 1 and a <= 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	p1,p2,p3	ALL	NULL	NULL	NULL	NULL	3	Using where
@@ -2428,22 +2452,22 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ALL	NULL	NULL	NULL	NULL	1010	
 explain partitions select * from t2 where a < 801 and a > 200;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p1,p2,p3,p4	ALL	NULL	NULL	NULL	NULL	1010	Using where
+1	SIMPLE	t2	p1,p2,p3,p4	ALL	NULL	NULL	NULL	NULL	800	Using where
 explain partitions select * from t2 where a < 801 and a > 800;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p4	ALL	NULL	NULL	NULL	NULL	1010	Using where
+1	SIMPLE	t2	p4	ALL	NULL	NULL	NULL	NULL	200	Using where
 explain partitions select * from t2 where a > 600;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p3,p4	ALL	NULL	NULL	NULL	NULL	1010	Using where
+1	SIMPLE	t2	p3,p4	ALL	NULL	NULL	NULL	NULL	400	Using where
 explain partitions select * from t2 where a > 600 and b = 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p3,p4	ALL	NULL	NULL	NULL	NULL	1010	Using where
+1	SIMPLE	t2	p3,p4	ALL	NULL	NULL	NULL	NULL	400	Using where
 explain partitions select * from t2 where a > 600 and b = 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p3,p4	ALL	NULL	NULL	NULL	NULL	1010	Using where
+1	SIMPLE	t2	p3,p4	ALL	NULL	NULL	NULL	NULL	400	Using where
 explain partitions select * from t2 where a > 600 and b = 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p3,p4	ALL	NULL	NULL	NULL	NULL	1010	Using where
+1	SIMPLE	t2	p3,p4	ALL	NULL	NULL	NULL	NULL	400	Using where
 explain partitions select * from t2 where b = 5;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ALL	NULL	NULL	NULL	NULL	1010	Using where
@@ -2498,19 +2522,19 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ALL	NULL	NULL	NULL	NULL	910	
 explain partitions select * from t2 where a = 101;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0	ALL	NULL	NULL	NULL	NULL	910	Using where
+1	SIMPLE	t2	p0	ALL	NULL	NULL	NULL	NULL	110	Using where
 explain partitions select * from t2 where a = 550;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p2	ALL	NULL	NULL	NULL	NULL	910	Using where
+1	SIMPLE	t2	p2	ALL	NULL	NULL	NULL	NULL	200	Using where
 explain partitions select * from t2 where a = 833;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p4	ALL	NULL	NULL	NULL	NULL	910	Using where
+1	SIMPLE	t2	p4	ALL	NULL	NULL	NULL	NULL	200	Using where
 explain partitions select * from t2 where (a = 100 OR a = 900);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0,p4	ALL	NULL	NULL	NULL	NULL	910	Using where
+1	SIMPLE	t2	p0,p4	ALL	NULL	NULL	NULL	NULL	310	Using where
 explain partitions select * from t2 where (a > 100 AND a < 600);
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0,p1,p2	ALL	NULL	NULL	NULL	NULL	910	Using where
+1	SIMPLE	t2	p0,p1,p2	ALL	NULL	NULL	NULL	NULL	510	Using where
 explain partitions select * from t2 where b = 4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	p0,p1,p2,p3,p4	ref	b	b	5	const	76	Using where
@@ -2796,17 +2820,17 @@ id	select_type	table	partitions	type	pos
 explain partitions select * from t1 
 where a >= 18446744073709551000-1 and a <= 18446744073709551000+1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p3,p4	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t1	p3,p4	ALL	NULL	NULL	NULL	NULL	3	Using where
 explain partitions select * from t1 
 where a between 18446744073709551001 and 18446744073709551002;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a = 18446744073709551000;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a = 18446744073709551613;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a = 18446744073709551614;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
@@ -2833,10 +2857,10 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t2	p0	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a=0xFE;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t1	p2	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t2 where a=0xFE;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t2	p2	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a > 0xFE AND a <= 0xFF;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
@@ -2845,22 +2869,22 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t1 where a >= 0xFE AND a <= 0xFF;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t1	p2	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t2 where a >= 0xFE AND a <= 0xFF;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t2	p2	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a < 64 AND a >= 63;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t2 where a < 64 AND a >= 63;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	t2	p0	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a <= 64 AND a >= 63;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t1	p0,p1	ALL	NULL	NULL	NULL	NULL	4	Using where
 explain partitions select * from t2 where a <= 64 AND a >= 63;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	p0,p1	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t2	p0,p1	ALL	NULL	NULL	NULL	NULL	4	Using where
 drop table t1;
 drop table t2;
 create table t1(a bigint unsigned not null) partition by range(a+0) (

=== modified file 'mysql-test/r/partition_range.result'
--- a/mysql-test/r/partition_range.result	2010-08-11 12:13:59 +0000
+++ b/mysql-test/r/partition_range.result	2010-08-27 08:43:51 +0000
@@ -73,13 +73,13 @@ id	select_type	table	partitions	type	pos
 1	SIMPLE	t1	pnull	system	NULL	NULL	NULL	NULL	1	
 explain partitions select * from t1 where a >= 0;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0,p1	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t1	p0,p1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a < 0;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 explain partitions select * from t1 where a <= 0;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pnull,p0	ALL	NULL	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t1	pnull,p0	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a > 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
@@ -112,16 +112,16 @@ select * from t1 where a > 1;
 a	b
 explain partitions select * from t1 where a is null;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pnull_pnullsp0,pnull_pnullsp1	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t1	pnull_pnullsp0,pnull_pnullsp1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a >= 0;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t1	p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
 explain partitions select * from t1 where a < 0;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pnull_pnullsp0,pnull_pnullsp1	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t1	pnull_pnullsp0,pnull_pnullsp1	ALL	NULL	NULL	NULL	NULL	2	Using where
 explain partitions select * from t1 where a <= 0;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t1	pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1	ALL	NULL	NULL	NULL	NULL	4	Using where
 explain partitions select * from t1 where a > 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables

=== modified file 'mysql-test/r/ps.result'
--- a/mysql-test/r/ps.result	2010-07-08 18:46:26 +0000
+++ b/mysql-test/r/ps.result	2010-10-04 08:51:26 +0000
@@ -3001,4 +3001,42 @@ EXECUTE stmt;
 1
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
+#
+# Bug#54494 crash with explain extended and prepared statements
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1),(2);
+PREPARE stmt FROM 'EXPLAIN EXTENDED SELECT 1 FROM t1 RIGHT JOIN t1 t2 ON 1';
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
+Warnings:
+Note	1003	select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
+Warnings:
+Note	1003	select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+#
+# Bug#54488 crash when using explain and prepared statements with subqueries
+#
+CREATE TABLE t1(f1 INT);
+INSERT INTO t1 VALUES (1),(1);
+PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))';
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
+2	SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+3	SUBQUERY	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesort
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
+2	SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+3	SUBQUERY	t1	ALL	NULL	NULL	NULL	NULL	2	Using temporary; Using filesort
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
 End of 5.1 tests.

=== modified file 'mysql-test/r/ps_2myisam.result'
--- a/mysql-test/r/ps_2myisam.result	2009-02-05 09:49:32 +0000
+++ b/mysql-test/r/ps_2myisam.result	2010-08-16 13:43:21 +0000
@@ -1929,26 +1929,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select @arg01:=  c1, @arg02:=  c2, @arg03:=  c3, @arg04:=  c4,
@@ -1976,26 +1976,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select 
@@ -2026,26 +2026,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2066,26 +2066,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select ? := c1 from t9 where c1= 1" ;
@@ -2114,26 +2114,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2158,26 +2158,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2204,26 +2204,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2242,26 +2242,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1 into ? from t9 where c1= 1" ;

=== modified file 'mysql-test/r/ps_3innodb.result'
--- a/mysql-test/r/ps_3innodb.result	2009-02-05 09:49:32 +0000
+++ b/mysql-test/r/ps_3innodb.result	2010-08-16 13:43:21 +0000
@@ -1912,26 +1912,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select @arg01:=  c1, @arg02:=  c2, @arg03:=  c3, @arg04:=  c4,
@@ -1959,26 +1959,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select 
@@ -2009,26 +2009,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2049,26 +2049,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select ? := c1 from t9 where c1= 1" ;
@@ -2097,26 +2097,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2141,26 +2141,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2187,26 +2187,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2225,26 +2225,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1 into ? from t9 where c1= 1" ;

=== modified file 'mysql-test/r/ps_4heap.result'
--- a/mysql-test/r/ps_4heap.result	2009-02-05 09:49:32 +0000
+++ b/mysql-test/r/ps_4heap.result	2010-08-16 13:43:21 +0000
@@ -1913,26 +1913,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	0	31	8
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	0	31	8
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	0	31	8
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	0	31	8
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	0	31	8
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	0	31	8
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	0	31	8
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	0	31	8
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select @arg01:=  c1, @arg02:=  c2, @arg03:=  c3, @arg04:=  c4,
@@ -1960,26 +1960,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	0	31	8
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	0	31	8
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	0	31	8
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	0	31	8
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	0	31	8
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	0	31	8
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	0	31	8
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	0	31	8
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select 
@@ -2010,26 +2010,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	0	31	8
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	0	31	8
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	0	31	8
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	0	31	8
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	0	31	8
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	0	31	8
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	0	31	8
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	0	31	8
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2050,26 +2050,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	0	31	8
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	0	31	8
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	0	31	8
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	0	31	8
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	0	31	8
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	0	31	8
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	0	31	8
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	0	31	8
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select ? := c1 from t9 where c1= 1" ;
@@ -2098,26 +2098,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	0	31	8
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	0	31	8
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	0	31	8
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	0	31	8
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	0	31	8
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	0	31	8
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	0	31	8
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	0	31	8
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2142,26 +2142,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	0	31	8
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	0	31	8
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	0	31	8
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	0	31	8
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	0	31	8
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	0	31	8
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	0	31	8
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	0	31	8
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2188,26 +2188,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	0	31	8
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	0	31	8
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	0	31	8
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	0	31	8
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	0	31	8
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	0	31	8
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	0	31	8
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	0	31	8
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2226,26 +2226,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	0	31	8
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	0	31	8
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	0	31	8
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	0	31	8
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	0	31	8
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	0	31	8
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	0	31	8
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	0	31	8
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1 into ? from t9 where c1= 1" ;

=== modified file 'mysql-test/r/ps_5merge.result'
--- a/mysql-test/r/ps_5merge.result	2009-02-05 09:49:32 +0000
+++ b/mysql-test/r/ps_5merge.result	2010-08-16 13:43:21 +0000
@@ -1849,26 +1849,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select @arg01:=  c1, @arg02:=  c2, @arg03:=  c3, @arg04:=  c4,
@@ -1896,26 +1896,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select 
@@ -1946,26 +1946,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -1986,26 +1986,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select ? := c1 from t9 where c1= 1" ;
@@ -2034,26 +2034,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2078,26 +2078,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2124,26 +2124,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2162,26 +2162,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1 into ? from t9 where c1= 1" ;
@@ -4871,26 +4871,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select @arg01:=  c1, @arg02:=  c2, @arg03:=  c3, @arg04:=  c4,
@@ -4918,26 +4918,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select 
@@ -4968,26 +4968,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -5008,26 +5008,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select ? := c1 from t9 where c1= 1" ;
@@ -5056,26 +5056,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -5100,26 +5100,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -5146,26 +5146,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -5184,26 +5184,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1 into ? from t9 where c1= 1" ;

=== modified file 'mysql-test/r/row.result'
--- a/mysql-test/r/row.result	2010-04-16 11:42:34 +0000
+++ b/mysql-test/r/row.result	2010-09-09 12:46:13 +0000
@@ -466,3 +466,26 @@ SELECT 1 FROM t1 WHERE ROW(a, b) >=
 ROW('1', (SELECT 1 FROM t1 WHERE a > 1234));
 1
 DROP TABLE t1;
+#
+# Bug #54190: Comparison to row subquery produces incorrect result
+# 
+SELECT ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0);
+ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0)
+NULL
+SELECT ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0);
+ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0)
+NULL
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 () VALUES (1), (2), (3);
+SELECT ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0);
+ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0)
+NULL
+SELECT ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0);
+ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0)
+NULL
+SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0);
+i
+SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0);
+i
+DROP TABLE t1;
+End of 5.1 tests

=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2010-04-15 14:04:24 +0000
+++ b/mysql-test/r/subselect.result	2010-09-09 12:46:13 +0000
@@ -922,7 +922,7 @@ select a, (select a,b,c from t1 where t1
 a	(select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a')	(select c from t1 where a=t2.a)
 1	1	a
 2	0	b
-NULL	0	NULL
+NULL	NULL	NULL
 select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b'),(select c from t1 where a=t2.a) from t2;
 a	(select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b')	(select c from t1 where a=t2.a)
 1	0	a
@@ -932,7 +932,7 @@ select a, (select a,b,c from t1 where t1
 a	(select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c')	(select c from t1 where a=t2.a)
 1	0	a
 2	0	b
-NULL	0	NULL
+NULL	NULL	NULL
 drop table t1,t2;
 create table t1 (a int, b real, c varchar(10));
 insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b');

=== modified file 'mysql-test/r/subselect4.result'
--- a/mysql-test/r/subselect4.result	2010-08-05 10:42:14 +0000
+++ b/mysql-test/r/subselect4.result	2010-09-07 09:21:09 +0000
@@ -77,6 +77,92 @@ Note	1249	Select 2 was reduced during op
 CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
 CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) );
 DROP VIEW v1, v2;
+# 
+# Bug#51070: Query with a NOT IN subquery predicate returns a wrong
+# result set
+# 
+CREATE TABLE t1 ( a INT, b INT );
+INSERT INTO t1 VALUES ( 1, NULL ), ( 2, NULL );
+CREATE TABLE t2 ( c INT, d INT );
+INSERT INTO t2 VALUES ( NULL, 3 ), ( NULL, 4 );
+CREATE TABLE t3 ( e INT, f INT );
+INSERT INTO t3 VALUES ( NULL, NULL ), ( NULL, NULL );
+CREATE TABLE t4 ( a INT );
+INSERT INTO t4 VALUES (1), (2), (3);
+CREATE TABLE t5 ( a INT );
+INSERT INTO t5 VALUES (NULL), (2);
+EXPLAIN
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+x	PRIMARY	x	x	x	x	x	x	x	x
+x	DEPENDENT SUBQUERY	x	x	x	x	x	x	x	x
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
+a	b
+EXPLAIN
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+2	DEPENDENT SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
+a	b
+1	NULL
+2	NULL
+SELECT * FROM t1 WHERE ( a, b ) IN ( SELECT c, d FROM t2 ) IS NULL;
+a	b
+1	NULL
+2	NULL
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS UNKNOWN;
+a	b
+1	NULL
+2	NULL
+SELECT * FROM t1 WHERE (( a, b ) NOT IN ( SELECT c, d FROM t2 )) IS UNKNOWN;
+a	b
+1	NULL
+2	NULL
+SELECT * FROM t1 WHERE 1 = 1 AND ( a, b ) NOT IN ( SELECT c, d FROM t2 );
+a	b
+EXPLAIN
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+x	PRIMARY	x	x	x	x	x	x	x	x
+x	DEPENDENT SUBQUERY	x	x	x	x	x	x	x	x
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
+a	b
+EXPLAIN
+SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+x	PRIMARY	x	x	x	x	x	x	x	x
+x	DEPENDENT SUBQUERY	x	x	x	x	x	x	x	x
+SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
+c	d
+EXPLAIN
+SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+x	PRIMARY	x	x	x	x	x	x	x	x
+x	DEPENDENT SUBQUERY	x	x	x	x	x	x	x	x
+SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
+e	f
+EXPLAIN
+SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+x	PRIMARY	x	x	x	x	x	x	x	x
+x	DEPENDENT SUBQUERY	x	x	x	x	x	x	x	x
+SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
+c	d
+SELECT * FROM t1 WHERE ( a, b ) NOT IN 
+( SELECT c, d FROM t2 WHERE c = 1 AND c <> 1 );
+a	b
+1	NULL
+2	NULL
+SELECT * FROM t1 WHERE b NOT IN ( SELECT c FROM t2 WHERE c = 1 );
+a	b
+1	NULL
+2	NULL
+SELECT * FROM t1 WHERE NULL NOT IN ( SELECT c FROM t2 WHERE c = 1 AND c <> 1 );
+a	b
+1	NULL
+2	NULL
+DROP TABLE t1, t2, t3, t4, t5;
 #
 # End of 5.1 tests.
 #

=== modified file 'mysql-test/r/trigger_notembedded.result'
--- a/mysql-test/r/trigger_notembedded.result	2009-09-17 11:33:23 +0000
+++ b/mysql-test/r/trigger_notembedded.result	2010-09-07 08:53:46 +0000
@@ -474,4 +474,25 @@ SHOW CREATE TRIGGER db1.trg;
 ERROR 42000: Access denied; you need the TRIGGER privilege for this operation
 DROP USER 'no_rights'@'localhost';
 DROP DATABASE db1;
+DROP DATABASE IF EXISTS mysqltest_db1;
+CREATE DATABASE mysqltest_db1;
+USE mysqltest_db1;
+GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost;
+CREATE TABLE t1 (
+a1 int,
+a2 int
+);
+INSERT INTO t1 VALUES (1, 20);
+CREATE TRIGGER mysqltest_db1.upd_t1
+BEFORE UPDATE ON t1 FOR EACH ROW SET new.a2 = 200;
+CREATE TABLE t2 (
+a1 int
+);
+INSERT INTO t2 VALUES (2);
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
+UPDATE IGNORE t1, t2 SET t1.a1 = 2, t2.a1 = 3 WHERE t1.a1 = 1 AND t2.a1 = 2;
+ERROR 42000: TRIGGER command denied to user 'mysqltest_u1'@'localhost' for table 't1'
+DROP DATABASE mysqltest_db1;
+DROP USER mysqltest_u1@localhost;
+USE test;
 End of 5.1 tests.

=== modified file 'mysql-test/r/type_timestamp.result'
--- a/mysql-test/r/type_timestamp.result	2010-02-09 10:30:50 +0000
+++ b/mysql-test/r/type_timestamp.result	2010-09-13 07:18:35 +0000
@@ -527,3 +527,24 @@ f1	f2-f3
 5	0
 DROP TABLE t1;
 End of 5.0 tests
+#
+# Bug #55779: select does not work properly in mysql server
+#             Version "5.1.42 SUSE MySQL RPM"
+#
+CREATE TABLE t1 (a TIMESTAMP, KEY (a));
+INSERT INTO t1 VALUES ('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'),
+('2000-01-01 00:00:01'), ('2000-01-01 00:00:01');
+SELECT a FROM t1 WHERE a >=  20000101000000;
+a
+2000-01-01 00:00:00
+2000-01-01 00:00:00
+2000-01-01 00:00:01
+2000-01-01 00:00:01
+SELECT a FROM t1 WHERE a >= '20000101000000';
+a
+2000-01-01 00:00:00
+2000-01-01 00:00:00
+2000-01-01 00:00:01
+2000-01-01 00:00:01
+DROP TABLE t1;
+End of 5.1 tests

=== modified file 'mysql-test/r/variables_debug.result'
--- a/mysql-test/r/variables_debug.result	2010-05-20 06:31:03 +0000
+++ b/mysql-test/r/variables_debug.result	2010-09-22 19:33:18 +0000
@@ -24,4 +24,17 @@ SELECT @@global.debug;
 @@global.debug
 
 SET GLOBAL debug=@old_debug;
+#
+# Bug #56709: Memory leaks at running the 5.1 test suite
+# 
+SET @old_local_debug = @@debug;
+SET @@debug='d,foo';
+SELECT @@debug;
+@@debug
+d,foo
+SET @@debug='';
+SELECT @@debug;
+@@debug
+
+SET @@debug = @old_local_debug;
 End of 5.1 tests

=== modified file 'mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result'
--- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2010-05-04 19:31:49 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2010-09-02 13:05:06 +0000
@@ -48,12 +48,12 @@ Log_name	Pos	Event_type	Server_id	End_lo
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	SAVEPOINT my_savepoint
+master-bin.000001	#	Query	#	#	SAVEPOINT `my_savepoint`
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	ROLLBACK TO my_savepoint
+master-bin.000001	#	Query	#	#	ROLLBACK TO `my_savepoint`
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 delete from t1;
 delete from t2;
@@ -77,12 +77,12 @@ Log_name	Pos	Event_type	Server_id	End_lo
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	SAVEPOINT my_savepoint
+master-bin.000001	#	Query	#	#	SAVEPOINT `my_savepoint`
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	ROLLBACK TO my_savepoint
+master-bin.000001	#	Query	#	#	ROLLBACK TO `my_savepoint`
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result	2010-05-19 17:01:12 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result	2010-09-02 13:05:06 +0000
@@ -44,10 +44,10 @@ show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(3)
-master-bin.000001	#	Query	#	#	SAVEPOINT my_savepoint
+master-bin.000001	#	Query	#	#	SAVEPOINT `my_savepoint`
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(4)
 master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
-master-bin.000001	#	Query	#	#	ROLLBACK TO my_savepoint
+master-bin.000001	#	Query	#	#	ROLLBACK TO `my_savepoint`
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 delete from t1;
 delete from t2;
@@ -70,10 +70,10 @@ show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(5)
-master-bin.000001	#	Query	#	#	SAVEPOINT my_savepoint
+master-bin.000001	#	Query	#	#	SAVEPOINT `my_savepoint`
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(6)
 master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
-master-bin.000001	#	Query	#	#	ROLLBACK TO my_savepoint
+master-bin.000001	#	Query	#	#	ROLLBACK TO `my_savepoint`
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(7)
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 delete from t1;

=== added file 'mysql-test/suite/innodb/r/innodb_bug56716.result'
--- a/mysql-test/suite/innodb/r/innodb_bug56716.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug56716.result	2010-10-04 10:05:21 +0000
@@ -0,0 +1,4 @@
+CREATE TABLE bug56716 (a INT PRIMARY KEY,b INT,c INT,INDEX(b)) ENGINE=InnoDB;
+SELECT * FROM bug56716 WHERE b<=42 ORDER BY b DESC FOR UPDATE;
+a	b	c
+DROP TABLE bug56716;

=== added file 'mysql-test/suite/innodb/r/innodb_bug57255.result'
--- a/mysql-test/suite/innodb/r/innodb_bug57255.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug57255.result	2010-10-06 10:41:26 +0000
@@ -0,0 +1,10 @@
+create table A(id int not null primary key) engine=innodb;
+create table B(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references A(id) on delete cascade) engine=innodb;
+create table C(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references B(id) on delete cascade) engine=innodb;
+insert into A values(1), (2);
+DELETE FROM A where id = 1;
+DELETE FROM C where f1 = 2;
+DELETE FROM A where id = 1;
+DROP TABLE C;
+DROP TABLE B;
+DROP TABLE A;

=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result	2010-09-02 00:43:02 +0000
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result	2010-10-05 08:11:56 +0000
@@ -2600,3 +2600,23 @@ Extra	Using index
 DROP TABLE t1;
 #
 End of 5.1 tests
+#
+# Test for bug #39932 "create table fails if column for FK is in different
+#                      case than in corr index".
+#
+drop tables if exists t1, t2;
+create table t1 (pk int primary key) engine=InnoDB;
+# Even although the below statement uses uppercased field names in
+# foreign key definition it still should be able to find explicitly
+# created supporting index. So it should succeed and should not
+# create any additional supporting indexes.
+create table t2 (fk int, key x (fk),
+constraint x foreign key (FK) references t1 (PK)) engine=InnoDB;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `fk` int(11) DEFAULT NULL,
+  KEY `x` (`fk`),
+  CONSTRAINT `x` FOREIGN KEY (`fk`) REFERENCES `t1` (`pk`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2, t1;

=== modified file 'mysql-test/suite/innodb/t/innodb_bug53756.test'
--- a/mysql-test/suite/innodb/t/innodb_bug53756.test	2010-07-06 02:26:38 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug53756.test	2010-09-30 08:28:22 +0000
@@ -34,8 +34,8 @@ INSERT INTO bug_53756 VALUES(1, 11), (2,
 --echo
 --echo # Select a less restrictive isolation level.
 # Don't use user variables. They won't survive server crash.
---let $global_isolation= `SELECT @@global.tx_isolation`;
---let $session_isolation= `SELECT @@session.tx_isolation`;
+--let $global_isolation= `SELECT @@global.tx_isolation`
+--let $session_isolation= `SELECT @@session.tx_isolation`
 SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 COMMIT;

=== added file 'mysql-test/suite/innodb/t/innodb_bug56716.test'
--- a/mysql-test/suite/innodb/t/innodb_bug56716.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug56716.test	2010-10-04 10:05:21 +0000
@@ -0,0 +1,10 @@
+#
+# Bug #56716 InnoDB locks a record gap without locking the table
+#
+-- source include/have_innodb.inc
+
+CREATE TABLE bug56716 (a INT PRIMARY KEY,b INT,c INT,INDEX(b)) ENGINE=InnoDB;
+
+SELECT * FROM bug56716 WHERE b<=42 ORDER BY b DESC FOR UPDATE;
+
+DROP TABLE bug56716;

=== added file 'mysql-test/suite/innodb/t/innodb_bug57255.test'
--- a/mysql-test/suite/innodb/t/innodb_bug57255.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug57255.test	2010-10-06 10:41:26 +0000
@@ -0,0 +1,36 @@
+# Test Bug #57255. Cascade deletes that affect different rows should not
+# result in DB_FOREIGN_EXCEED_MAX_CASCADE error
+
+--source include/have_innodb.inc
+
+create table A(id int not null primary key) engine=innodb;
+
+create table B(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references A(id) on delete cascade) engine=innodb;
+
+create table C(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references B(id) on delete cascade) engine=innodb;
+
+insert into A values(1), (2);
+
+--disable_query_log
+let $i=257;
+while ($i)
+{
+insert into B(f1) values(1);
+dec $i;
+}
+let $i=486;
+while ($i)
+{
+insert into C(f1) values(2);
+dec $i;
+}
+--enable_query_log
+
+# Following Deletes should not report error
+DELETE FROM A where id = 1;
+DELETE FROM C where f1 = 2;
+DELETE FROM A where id = 1;
+
+DROP TABLE C;
+DROP TABLE B;
+DROP TABLE A;

=== modified file 'mysql-test/suite/innodb/t/innodb_mysql.test'
--- a/mysql-test/suite/innodb/t/innodb_mysql.test	2010-09-02 00:43:02 +0000
+++ b/mysql-test/suite/innodb/t/innodb_mysql.test	2010-10-05 08:11:56 +0000
@@ -827,3 +827,21 @@ DROP TABLE t1;
 
 
 --echo End of 5.1 tests
+
+
+--echo #
+--echo # Test for bug #39932 "create table fails if column for FK is in different
+--echo #                      case than in corr index".
+--echo #
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+create table t1 (pk int primary key) engine=InnoDB;
+--echo # Even although the below statement uses uppercased field names in
+--echo # foreign key definition it still should be able to find explicitly
+--echo # created supporting index. So it should succeed and should not
+--echo # create any additional supporting indexes.
+create table t2 (fk int, key x (fk),
+                 constraint x foreign key (FK) references t1 (PK)) engine=InnoDB;
+show create table t2;
+drop table t2, t1;

=== added file 'mysql-test/suite/innodb_plugin/r/innodb_bug53756.result'
--- a/mysql-test/suite/innodb_plugin/r/innodb_bug53756.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/r/innodb_bug53756.result	2010-09-07 05:41:37 +0000
@@ -0,0 +1,118 @@
+DROP TABLE IF EXISTS bug_53756 ;
+CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB;
+ALTER TABLE bug_53756 ADD PRIMARY KEY (pk);
+INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44);
+
+# Select a less restrictive isolation level.
+SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+COMMIT;
+
+# Start a transaction in the default connection for isolation.
+START TRANSACTION;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-COMMITTED
+SELECT * FROM bug_53756;
+pk	c1
+1	11
+2	22
+3	33
+4	44
+
+# connection con1 deletes row 1
+START TRANSACTION;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-COMMITTED
+DELETE FROM bug_53756 WHERE pk=1;
+
+# connection con2 deletes row 2
+START TRANSACTION;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-COMMITTED
+DELETE FROM bug_53756 WHERE pk=2;
+
+# connection con3 updates row 3
+START TRANSACTION;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-COMMITTED
+UPDATE bug_53756 SET c1=77 WHERE pk=3;
+
+# connection con4 updates row 4
+START TRANSACTION;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-COMMITTED
+UPDATE bug_53756 SET c1=88 WHERE pk=4;
+
+# connection con5 inserts row 5
+START TRANSACTION;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-COMMITTED
+INSERT INTO bug_53756 VALUES(5, 55);
+
+# connection con6 inserts row 6
+START TRANSACTION;
+SELECT @@tx_isolation;
+@@tx_isolation
+READ-COMMITTED
+INSERT INTO bug_53756 VALUES(6, 66);
+
+# connection con1 commits.
+COMMIT;
+
+# connection con3 commits.
+COMMIT;
+
+# connection con4 rolls back.
+ROLLBACK;
+
+# connection con6 rolls back.
+ROLLBACK;
+
+# The connections 2 and 5 stay open.
+
+# connection default selects resulting data.
+# Delete of row 1 was committed.
+# Update of row 3 was committed.
+# Due to isolation level read committed, these should be included.
+# All other changes should not be included.
+SELECT * FROM bug_53756;
+pk	c1
+2	22
+3	77
+4	44
+
+# connection default
+#
+# Crash server.
+START TRANSACTION;
+INSERT INTO bug_53756 VALUES (666,666);
+SET SESSION debug="+d,crash_commit_before";
+COMMIT;
+ERROR HY000: Lost connection to MySQL server during query
+
+#
+# disconnect con1, con2, con3, con4, con5, con6.
+#
+# Restart server.
+
+#
+# Select recovered data.
+# Delete of row 1 was committed.
+# Update of row 3 was committed.
+# These should be included.
+# All other changes should not be included.
+# Delete of row 2 and insert of row 5 should be rolled back
+SELECT * FROM bug_53756;
+pk	c1
+2	22
+3	77
+4	44
+
+# Clean up.
+DROP TABLE bug_53756;

=== added file 'mysql-test/suite/innodb_plugin/r/innodb_bug56716.result'
--- a/mysql-test/suite/innodb_plugin/r/innodb_bug56716.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/r/innodb_bug56716.result	2010-10-04 10:06:41 +0000
@@ -0,0 +1,4 @@
+CREATE TABLE bug56716 (a INT PRIMARY KEY,b INT,c INT,INDEX(b)) ENGINE=InnoDB;
+SELECT * FROM bug56716 WHERE b<=42 ORDER BY b DESC FOR UPDATE;
+a	b	c
+DROP TABLE bug56716;

=== added file 'mysql-test/suite/innodb_plugin/r/innodb_bug57255.result'
--- a/mysql-test/suite/innodb_plugin/r/innodb_bug57255.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/r/innodb_bug57255.result	2010-10-06 10:41:26 +0000
@@ -0,0 +1,10 @@
+create table A(id int not null primary key) engine=innodb;
+create table B(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references A(id) on delete cascade) engine=innodb;
+create table C(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references B(id) on delete cascade) engine=innodb;
+insert into A values(1), (2);
+DELETE FROM A where id = 1;
+DELETE FROM C where f1 = 2;
+DELETE FROM A where id = 1;
+DROP TABLE C;
+DROP TABLE B;
+DROP TABLE A;

=== modified file 'mysql-test/suite/innodb_plugin/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result	2010-06-09 12:17:18 +0000
+++ b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result	2010-09-16 10:51:08 +0000
@@ -2390,4 +2390,14 @@ a
 2
 UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1;
 DROP TABLE t1,t2;
+#
+# Bug#54606 innodb fast alter table + pack_keys=0 
+#           prevents adding new indexes
+#
+CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) 
+ENGINE=InnoDB 
+PACK_KEYS=0;
+CREATE INDEX a ON t1 (a);
+CREATE INDEX c on t1 (c);
+DROP TABLE t1;
 End of 5.1 tests

=== added file 'mysql-test/suite/innodb_plugin/t/innodb_bug53756-master.opt'
--- a/mysql-test/suite/innodb_plugin/t/innodb_bug53756-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug53756-master.opt	2010-09-07 05:41:37 +0000
@@ -0,0 +1 @@
+--skip-stack-trace --skip-core-file

=== added file 'mysql-test/suite/innodb_plugin/t/innodb_bug53756.test'
--- a/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test	2010-10-03 17:39:28 +0000
@@ -0,0 +1,184 @@
+# This is the test case for bug #53756. Alter table operation could
+# leave a deleted record for the temp table (later renamed to the altered
+# table) in the SYS_TABLES secondary index, we should ignore this row and
+# find the first non-deleted row for the specified table_id when load table
+# metadata in the function dict_load_table_on_id() during crash recovery.
+
+#
+# innobackup needs to connect to the server. Not supported in embedded.
+--source include/not_embedded.inc
+#
+# This test case needs to crash the server. Needs a debug server.
+--source include/have_debug.inc
+#
+# Don't test this under valgrind, memory leaks will occur.
+--source include/not_valgrind.inc
+#
+# This test case needs InnoDB.
+-- source include/have_innodb_plugin.inc
+
+#
+# Precautionary clean up.
+#
+--disable_warnings
+DROP TABLE IF EXISTS bug_53756 ;
+--enable_warnings
+
+#
+# Create test data.
+#
+CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB;
+ALTER TABLE bug_53756 ADD PRIMARY KEY (pk);
+INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44);
+
+--echo
+--echo # Select a less restrictive isolation level.
+# Don't use user variables. They won't survive server crash.
+--let $global_isolation= `SELECT @@global.tx_isolation`
+--let $session_isolation= `SELECT @@session.tx_isolation`
+SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+COMMIT;
+
+--echo
+--echo # Start a transaction in the default connection for isolation.
+START TRANSACTION;
+SELECT @@tx_isolation;
+SELECT * FROM bug_53756;
+
+--echo
+--echo # connection con1 deletes row 1
+--connect (con1,localhost,root,,)
+START TRANSACTION;
+SELECT @@tx_isolation;
+DELETE FROM bug_53756 WHERE pk=1;
+
+--echo
+--echo # connection con2 deletes row 2
+--connect (con2,localhost,root,,)
+START TRANSACTION;
+SELECT @@tx_isolation;
+DELETE FROM bug_53756 WHERE pk=2;
+
+--echo
+--echo # connection con3 updates row 3
+--connect (con3,localhost,root,,)
+START TRANSACTION;
+SELECT @@tx_isolation;
+UPDATE bug_53756 SET c1=77 WHERE pk=3;
+
+--echo
+--echo # connection con4 updates row 4
+--connect (con4,localhost,root,,)
+START TRANSACTION;
+SELECT @@tx_isolation;
+UPDATE bug_53756 SET c1=88 WHERE pk=4;
+
+--echo
+--echo # connection con5 inserts row 5
+--connect (con5,localhost,root,,)
+START TRANSACTION;
+SELECT @@tx_isolation;
+INSERT INTO bug_53756 VALUES(5, 55);
+
+--echo
+--echo # connection con6 inserts row 6
+--connect (con6,localhost,root,,)
+START TRANSACTION;
+SELECT @@tx_isolation;
+INSERT INTO bug_53756 VALUES(6, 66);
+
+--echo
+--echo # connection con1 commits.
+--connection con1
+COMMIT;
+
+--echo
+--echo # connection con3 commits.
+--connection con3
+COMMIT;
+
+--echo
+--echo # connection con4 rolls back.
+--connection con4
+ROLLBACK;
+
+--echo
+--echo # connection con6 rolls back.
+--connection con6
+ROLLBACK;
+
+--echo
+--echo # The connections 2 and 5 stay open.
+
+--echo
+--echo # connection default selects resulting data.
+--echo # Delete of row 1 was committed.
+--echo # Update of row 3 was committed.
+--echo # Due to isolation level read committed, these should be included.
+--echo # All other changes should not be included.
+--connection default
+SELECT * FROM bug_53756;
+
+--echo
+--echo # connection default
+--connection default
+--echo #
+--echo # Crash server.
+#
+# Write file to make mysql-test-run.pl expect the "crash", but don't start
+# it until it's told to
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+#
+START TRANSACTION;
+INSERT INTO bug_53756 VALUES (666,666);
+#
+# Request a crash on next execution of commit.
+SET SESSION debug="+d,crash_commit_before";
+#
+# Execute the statement that causes the crash.
+--error 2013
+COMMIT;
+--echo
+--echo #
+--echo # disconnect con1, con2, con3, con4, con5, con6.
+--disconnect con1
+--disconnect con2
+--disconnect con3
+--disconnect con4
+--disconnect con5
+--disconnect con6
+--echo #
+--echo # Restart server.
+#
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+#
+# Turn on reconnect
+--enable_reconnect
+#
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+#
+# Turn off reconnect again
+--disable_reconnect
+--echo
+
+--echo #
+--echo # Select recovered data.
+--echo # Delete of row 1 was committed.
+--echo # Update of row 3 was committed.
+--echo # These should be included.
+--echo # All other changes should not be included.
+--echo # Delete of row 2 and insert of row 5 should be rolled back
+SELECT * FROM bug_53756;
+
+--echo
+--echo # Clean up.
+DROP TABLE bug_53756;
+
+--disable_query_log
+eval SET GLOBAL tx_isolation= '$global_isolation';
+eval SET SESSION tx_isolation= '$session_isolation';
+--enable_query_log
+

=== added file 'mysql-test/suite/innodb_plugin/t/innodb_bug56716.test'
--- a/mysql-test/suite/innodb_plugin/t/innodb_bug56716.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug56716.test	2010-10-04 10:06:41 +0000
@@ -0,0 +1,10 @@
+#
+# Bug #56716 InnoDB locks a record gap without locking the table
+#
+-- source include/have_innodb_plugin.inc
+
+CREATE TABLE bug56716 (a INT PRIMARY KEY,b INT,c INT,INDEX(b)) ENGINE=InnoDB;
+
+SELECT * FROM bug56716 WHERE b<=42 ORDER BY b DESC FOR UPDATE;
+
+DROP TABLE bug56716;

=== added file 'mysql-test/suite/innodb_plugin/t/innodb_bug57255.test'
--- a/mysql-test/suite/innodb_plugin/t/innodb_bug57255.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug57255.test	2010-10-06 10:41:26 +0000
@@ -0,0 +1,36 @@
+# Test Bug #57255. Cascade deletes that affect different rows should not
+# result in DB_FOREIGN_EXCEED_MAX_CASCADE error
+
+--source include/have_innodb_plugin.inc
+
+create table A(id int not null primary key) engine=innodb;
+
+create table B(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references A(id) on delete cascade) engine=innodb;
+
+create table C(id int not null auto_increment primary key, f1 int not null, foreign key(f1) references B(id) on delete cascade) engine=innodb;
+
+insert into A values(1), (2);
+
+--disable_query_log
+let $i=257;
+while ($i)
+{
+insert into B(f1) values(1);
+dec $i;
+}
+let $i=486;
+while ($i)
+{
+insert into C(f1) values(2);
+dec $i;
+}
+--enable_query_log
+
+# Following Deletes should not report error
+DELETE FROM A where id = 1;
+DELETE FROM C where f1 = 2;
+DELETE FROM A where id = 1;
+
+DROP TABLE C;
+DROP TABLE B;
+DROP TABLE A;

=== modified file 'mysql-test/suite/innodb_plugin/t/innodb_mysql.test'
--- a/mysql-test/suite/innodb_plugin/t/innodb_mysql.test	2010-06-09 12:17:18 +0000
+++ b/mysql-test/suite/innodb_plugin/t/innodb_mysql.test	2010-09-16 10:51:08 +0000
@@ -632,4 +632,18 @@ UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # Bug#54606 innodb fast alter table + pack_keys=0 
+--echo #           prevents adding new indexes
+--echo #
+
+CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) 
+  ENGINE=InnoDB 
+  PACK_KEYS=0;
+CREATE INDEX a ON t1 (a);
+CREATE INDEX c on t1 (c);
+
+DROP TABLE t1;
+
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/suite/ndb/r/ps_7ndb.result'
--- a/mysql-test/suite/ndb/r/ps_7ndb.result	2009-02-05 09:49:32 +0000
+++ b/mysql-test/suite/ndb/r/ps_7ndb.result	2010-10-05 08:47:03 +0000
@@ -1912,26 +1912,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select @arg01:=  c1, @arg02:=  c2, @arg03:=  c3, @arg04:=  c4,
@@ -1959,26 +1959,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select 
@@ -2009,26 +2009,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2049,26 +2049,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select ? := c1 from t9 where c1= 1" ;
@@ -2097,26 +2097,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2141,26 +2141,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2187,26 +2187,26 @@ def					@arg09	5	23	1	Y	32896	31	63
 def					@arg10	5	23	1	Y	32896	31	63
 def					@arg11	246	83	6	Y	128	30	63
 def					@arg12	246	83	6	Y	128	30	63
-def					@arg13	251	16777216	10	Y	128	31	63
-def					@arg14	251	16777216	19	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	8	Y	128	31	63
+def					@arg13	250	16777215	10	Y	128	31	63
+def					@arg14	250	16777215	19	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	8	Y	128	31	63
 def					@arg17	8	20	4	Y	32928	0	63
 def					@arg18	8	20	1	Y	32896	0	63
 def					@arg19	8	20	1	Y	32896	0	63
-def					@arg20	251	16777216	1	Y	0	31	8
-def					@arg21	251	16777216	10	Y	0	31	8
-def					@arg22	251	16777216	30	Y	0	31	8
-def					@arg23	251	16777216	8	Y	128	31	63
-def					@arg24	251	16777216	8	Y	0	31	8
-def					@arg25	251	16777216	4	Y	128	31	63
-def					@arg26	251	16777216	4	Y	0	31	8
-def					@arg27	251	16777216	10	Y	128	31	63
-def					@arg28	251	16777216	10	Y	0	31	8
-def					@arg29	251	16777216	8	Y	128	31	63
-def					@arg30	251	16777216	8	Y	0	31	8
-def					@arg31	251	16777216	3	Y	0	31	8
-def					@arg32	251	16777216	6	Y	0	31	8
+def					@arg20	250	16777215	1	Y	0	31	8
+def					@arg21	250	16777215	10	Y	0	31	8
+def					@arg22	250	16777215	30	Y	0	31	8
+def					@arg23	250	16777215	8	Y	128	31	63
+def					@arg24	250	16777215	8	Y	0	31	8
+def					@arg25	250	16777215	4	Y	128	31	63
+def					@arg26	250	16777215	4	Y	0	31	8
+def					@arg27	250	16777215	10	Y	128	31	63
+def					@arg28	250	16777215	10	Y	0	31	8
+def					@arg29	250	16777215	8	Y	128	31	63
+def					@arg30	250	16777215	8	Y	0	31	8
+def					@arg31	250	16777215	3	Y	0	31	8
+def					@arg32	250	16777215	6	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 1	1	1	1	1	1	1	1	1	1	1.0000	1.0000	2004-02-29	2004-02-29 11:11:11	2004-02-29 11:11:11	11:11:11	2004	1	1	a	123456789a	123456789a123456789b123456789c	tinyblob	tinytext	blob	text	mediumblob	mediumtext	longblob	longtext	one	monday
 set @my_key= 0 ;
@@ -2225,26 +2225,26 @@ def					@arg09	5	23	0	Y	32896	31	63
 def					@arg10	5	23	0	Y	32896	31	63
 def					@arg11	246	83	0	Y	128	30	63
 def					@arg12	246	83	0	Y	128	30	63
-def					@arg13	251	16777216	0	Y	128	31	63
-def					@arg14	251	16777216	0	Y	128	31	63
-def					@arg15	251	16777216	19	Y	128	31	63
-def					@arg16	251	16777216	0	Y	128	31	63
+def					@arg13	250	16777215	0	Y	128	31	63
+def					@arg14	250	16777215	0	Y	128	31	63
+def					@arg15	250	16777215	19	Y	128	31	63
+def					@arg16	250	16777215	0	Y	128	31	63
 def					@arg17	8	20	0	Y	32928	0	63
 def					@arg18	8	20	0	Y	32896	0	63
 def					@arg19	8	20	0	Y	32896	0	63
-def					@arg20	251	16777216	0	Y	0	31	8
-def					@arg21	251	16777216	0	Y	0	31	8
-def					@arg22	251	16777216	0	Y	0	31	8
-def					@arg23	251	16777216	0	Y	128	31	63
-def					@arg24	251	16777216	0	Y	0	31	8
-def					@arg25	251	16777216	0	Y	128	31	63
-def					@arg26	251	16777216	0	Y	0	31	8
-def					@arg27	251	16777216	0	Y	128	31	63
-def					@arg28	251	16777216	0	Y	0	31	8
-def					@arg29	251	16777216	0	Y	128	31	63
-def					@arg30	251	16777216	0	Y	0	31	8
-def					@arg31	251	16777216	0	Y	0	31	8
-def					@arg32	251	16777216	0	Y	0	31	8
+def					@arg20	250	16777215	0	Y	0	31	8
+def					@arg21	250	16777215	0	Y	0	31	8
+def					@arg22	250	16777215	0	Y	0	31	8
+def					@arg23	250	16777215	0	Y	128	31	63
+def					@arg24	250	16777215	0	Y	0	31	8
+def					@arg25	250	16777215	0	Y	128	31	63
+def					@arg26	250	16777215	0	Y	0	31	8
+def					@arg27	250	16777215	0	Y	128	31	63
+def					@arg28	250	16777215	0	Y	0	31	8
+def					@arg29	250	16777215	0	Y	128	31	63
+def					@arg30	250	16777215	0	Y	0	31	8
+def					@arg31	250	16777215	0	Y	0	31	8
+def					@arg32	250	16777215	0	Y	0	31	8
 @arg01	@arg02	@arg03	@arg04	@arg05	@arg06	@arg07	@arg08	@arg09	@arg10	@arg11	@arg12	@arg13	@arg14	@arg15	@arg16	@arg17	@arg18	@arg19	@arg20	@arg21	@arg22	@arg23	@arg24	@arg25	@arg26	@arg27	@arg28	@arg29	@arg30	@arg31	@arg32
 0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	1991-01-01 01:01:01	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 prepare stmt1 from "select c1 into ? from t9 where c1= 1" ;

=== modified file 'mysql-test/suite/parts/r/partition_alter3_innodb.result'
--- a/mysql-test/suite/parts/r/partition_alter3_innodb.result	2008-11-12 17:51:47 +0000
+++ b/mysql-test/suite/parts/r/partition_alter3_innodb.result	2010-08-27 08:43:51 +0000
@@ -141,7 +141,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part1	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part1	ALL	NULL	NULL	NULL	NULL	7	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -165,7 +165,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	5	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -190,7 +190,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	3	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -226,7 +226,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p6	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p6	ALL	NULL	NULL	NULL	NULL	3	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -248,7 +248,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	4	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -269,7 +269,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	4	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -289,7 +289,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	5	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -308,7 +308,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part1	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part1	ALL	NULL	NULL	NULL	NULL	7	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -326,7 +326,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	10	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -452,7 +452,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	7	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -476,7 +476,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	5	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -504,7 +504,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p6	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p6	ALL	NULL	NULL	NULL	NULL	3	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -538,7 +538,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	4	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -563,7 +563,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	3	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -587,7 +587,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	23	Using where
+1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	10	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -610,7 +610,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	5	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -632,7 +632,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	7	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -653,7 +653,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	10	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1

=== modified file 'mysql-test/suite/parts/r/partition_alter3_myisam.result'
--- a/mysql-test/suite/parts/r/partition_alter3_myisam.result	2008-11-12 17:51:47 +0000
+++ b/mysql-test/suite/parts/r/partition_alter3_myisam.result	2010-08-27 08:43:51 +0000
@@ -155,7 +155,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part1	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part1	ALL	NULL	NULL	NULL	NULL	7	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -187,7 +187,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	5	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -228,7 +228,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	3	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -278,7 +278,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p6	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p6	ALL	NULL	NULL	NULL	NULL	3	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -312,7 +312,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	4	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -343,7 +343,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	4	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -371,7 +371,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	5	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -396,7 +396,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part1	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part1	ALL	NULL	NULL	NULL	NULL	7	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -418,7 +418,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	10	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -552,7 +552,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	7	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -584,7 +584,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	5	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -628,7 +628,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p6	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p6	ALL	NULL	NULL	NULL	NULL	3	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -676,7 +676,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	4	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -713,7 +713,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	3	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -747,7 +747,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p4	ALL	NULL	NULL	NULL	NULL	10	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -778,7 +778,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	5	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -806,7 +806,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	part7	ALL	NULL	NULL	NULL	NULL	7	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1
@@ -831,7 +831,7 @@ t1.frm
 t1.par
 EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	20	Using where
+1	SIMPLE	t1	p0	ALL	NULL	NULL	NULL	NULL	10	Using where
 # check read single success: 1
 # check read all success: 1
 # check read row by row success: 1

=== modified file 'mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result'
--- a/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result	2010-03-28 11:57:33 +0000
+++ b/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result	2010-09-02 13:05:06 +0000
@@ -139,14 +139,14 @@ show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO db1.t1 VALUES(20)
-master-bin.000001	#	Query	#	#	SAVEPOINT has_comment
+master-bin.000001	#	Query	#	#	SAVEPOINT `has_comment`
 master-bin.000001	#	Query	#	#	use `db1`; INSERT INTO db1.t1 VALUES(30)
 master-bin.000001	#	Query	#	#	use `db1`; INSERT INTO db1.t2 VALUES("in savepoint has_comment")
-master-bin.000001	#	Query	#	#	SAVEPOINT mixed_cases
+master-bin.000001	#	Query	#	#	SAVEPOINT `mixed_cases`
 master-bin.000001	#	Query	#	#	use `db1`; INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
 master-bin.000001	#	Query	#	#	use `db1`; INSERT INTO db1.t1 VALUES(40)
-master-bin.000001	#	Query	#	#	ROLLBACK TO mixed_cases
-master-bin.000001	#	Query	#	#	ROLLBACK TO has_comment
+master-bin.000001	#	Query	#	#	ROLLBACK TO `mixed_cases`
+master-bin.000001	#	Query	#	#	ROLLBACK TO `has_comment`
 master-bin.000001	#	Query	#	#	use `db1`; INSERT INTO db1.t2 VALUES("after rollback to")
 master-bin.000001	#	Query	#	#	use `db1`; INSERT INTO db1.t1 VALUES(50)
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */

=== modified file 'mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result'
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result	2010-08-03 02:22:19 +0000
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result	2010-09-02 13:05:06 +0000
@@ -997,7 +997,7 @@ master-bin.000001	#	Query	#	#	use `test_
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test_rpl`; INSERT INTO t1 VALUES (5, 'before savepoint s2')
-master-bin.000001	#	Query	#	#	SAVEPOINT s2
+master-bin.000001	#	Query	#	#	SAVEPOINT `s2`
 master-bin.000001	#	Query	#	#	use `test_rpl`; INSERT INTO t1 VALUES (6, 'after savepoint s2')
 master-bin.000001	#	Table_map	#	#	table_id: # (test_rpl.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F

=== modified file 'mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test'
--- a/mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test	2010-01-14 10:49:40 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_tbl_metadata.test	2010-09-15 12:56:22 +0000
@@ -205,7 +205,7 @@ DROP TABLE `t1`;
 
 -- echo === Using mysqlbinlog to detect failure. Before the patch mysqlbinlog would find a corrupted event, thence would fail.
 
--- let $MYSQLD_DATADIR= `SELECT @@datadir`;
+-- let $MYSQLD_DATADIR= `SELECT @@datadir`
 -- exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog
 -- remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog
 
@@ -330,7 +330,7 @@ while($ntables)
 -- echo ### assertion: check that binlog is not corrupt. Using mysqlbinlog to 
 -- echo ###            detect failure. Before the patch mysqlbinlog would find 
 -- echo ###            a corrupted event, thence would fail.
--- let $MYSQLD_DATADIR= `SELECT @@datadir`;
+-- let $MYSQLD_DATADIR= `SELECT @@datadir`
 -- exec $MYSQL_BINLOG -v --hex $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug50018.binlog
 
 ## clean up

=== modified file 'mysql-test/suite/sys_vars/t/secure_file_priv.test'
--- a/mysql-test/suite/sys_vars/t/secure_file_priv.test	2010-04-16 14:10:47 +0000
+++ b/mysql-test/suite/sys_vars/t/secure_file_priv.test	2010-09-21 09:16:20 +0000
@@ -9,7 +9,7 @@ SHOW VARIABLES LIKE 'secure_file_priv';
 # Doing this in a portable manner is difficult but we should be able to
 # count on the depth of the directory hierarchy used. Three steps up from
 # the datadir is the 'mysql_test' directory.
---let $PROTECTED_FILE=`SELECT concat(@@datadir,'/../../../bug50373.txt')`;
+--let $PROTECTED_FILE=`SELECT concat(@@datadir,'/../../../bug50373.txt')`
 --eval SELECT * FROM t1 INTO OUTFILE '$PROTECTED_FILE';
 DELETE FROM t1;
 --eval LOAD DATA INFILE '$PROTECTED_FILE' INTO TABLE t1;

=== modified file 'mysql-test/t/merge.test'
--- a/mysql-test/t/merge.test	2010-03-19 06:01:02 +0000
+++ b/mysql-test/t/merge.test	2010-04-26 13:44:10 +0000
@@ -1705,4 +1705,82 @@ t2 WHERE b SOUNDS LIKE e AND d = 1;
 
 DROP TABLE t2, t1;
 
+--echo #
+--echo # Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS m1, t1;
+--enable_warnings
+#
+# Test derived from a proposal of Shane Bester.
+#
+CREATE TABLE t1 (c1 INT) ENGINE=MYISAM;
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST;
+#
+# REPAIR ... USE_FRM with LOCK TABLES.
+#
+LOCK TABLE m1 READ;
+REPAIR TABLE m1 USE_FRM;
+UNLOCK TABLES;
+#
+# REPAIR ... USE_FRM without LOCK TABLES.
+#
+# This statement crashed the server (Bug#46339).
+#
+REPAIR TABLE m1 USE_FRM;
+#
+DROP TABLE m1,t1;
+#
+# Test derived from a proposal of Matthias Leich.
+#
+# Base table is missing.
+#
+CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
+#
+# This statement crashed the server (Bug#46339).
+#
+REPAIR TABLE m1 USE_FRM;
+#
+# Create base table.
+#
+CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM;
+#
+# This statement crashed the server (Bug#46339).
+#
+REPAIR TABLE m1 USE_FRM;
+#
+# Normal repair as reference.
+#
+REPAIR TABLE m1;
+#
+# Cleanup.
+#
+DROP TABLE m1, t1;
+#
+# Same with temporary tables.
+#
+# Base table is missing.
+#
+CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1);
+#
+# This statement crashed the server (Bug#46339).
+#
+REPAIR TABLE m1 USE_FRM;
+#
+# Create base table.
+#
+CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM;
+#
+# This statement crashed the server (Bug#46339).
+#
+REPAIR TABLE m1 USE_FRM;
+#
+# Normal repair as reference.
+#
+REPAIR TABLE m1;
+#
+# Cleanup.
+#
+DROP TABLE m1, t1;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/multi_update.test'
--- a/mysql-test/t/multi_update.test	2010-05-24 13:54:08 +0000
+++ b/mysql-test/t/multi_update.test	2010-09-07 07:58:05 +0000
@@ -651,5 +651,26 @@ SET SESSION sql_safe_updates = 1;
 UPDATE IGNORE t1, t1 t1a SET t1.a = 1 WHERE t1a.a = 1;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#54543: update ignore with incorrect subquery leads to assertion
+--echo # failure: inited==INDEX
+--echo #
+SET SESSION sql_safe_updates = 0;
+CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES (1), (2);
+
+CREATE TABLE t2 ( a INT );
+INSERT INTO t2 VALUES (1), (2);
+
+CREATE TABLE t3 ( a INT );
+INSERT INTO t3 VALUES (1), (2);
+
+--echo # Should not crash
+UPDATE IGNORE
+  ( SELECT ( SELECT COUNT(*) FROM t1 GROUP BY a, @v ) a FROM t2 ) x, t3
+SET t3.a = 0;
+
+DROP TABLE t1, t2, t3;
+SET SESSION sql_safe_updates = DEFAULT;
 
 --echo end of tests

=== modified file 'mysql-test/t/mysqltest.test'
--- a/mysql-test/t/mysqltest.test	2010-08-04 08:52:45 +0000
+++ b/mysql-test/t/mysqltest.test	2010-09-22 08:57:10 +0000
@@ -494,6 +494,32 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqlt
 --error 1
 --exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1
 
+#
+# Extra text after ``
+#
+# Cannot use exec echo here as ` may or may not need to be escaped
+--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
+let $x= `select 1` BOO ;
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
+remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
+--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
+--let $x= `select 1`;
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
+remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
+--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
+# Missing ; in next line should be detected and cause failure
+let $x= `select 1`
+let $x= 2;
+echo $x;
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
+remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
+
 
 # Allow trailing # comment
 --sleep 1 # Wait for insert delayed to be executed.
@@ -701,6 +727,16 @@ echo banana = $cat;
 let $cat=ba\\\$cat\\\$cat;
 echo Not a banana: $cat;
 
+# Bug #55413 would cause this to fail
+let $escape= with\`some\"escaped\'quotes;
+echo $escape;
+
+--let $escape= with\`some\"escaped\'quotes
+echo $escape;
+
+# This only works with "--let" syntax
+--let $tick= single'tick`backtick
+echo $tick;
 
 # Test illegal uses of let
 
@@ -1431,19 +1467,6 @@ eval select "$long_rep" as x;
 
 # Repeat connect/disconnect
 --write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
-let $i=100;
-while ($i)
-{
-  connect (test_con1,localhost,root,,);
-  disconnect test_con1;
-  dec $i;
-}
-EOF
---exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK; exit;" | $MYSQL_TEST 2>&1
-remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
-
-# Repeat connect/disconnect
---write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
 let $i=200;
 while ($i)
 {
@@ -1451,9 +1474,8 @@ while ($i)
  disconnect test_con1;
  dec $i;
 }
+echo 200 connects succeeded;
 EOF
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---error 1
 --exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
 remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
 
@@ -1494,6 +1516,22 @@ show tables;
 disconnect con2;
 connection default;
 
+# Test enable_connect_log
+--enable_connect_log
+connect (con1,localhost,root,,);
+connection default;
+connection con1;
+--disable_query_log
+# These should not be logged
+connect (con2,localhost,root,,*NO-ONE*);
+connection con2;
+disconnect con2;
+connection con1;
+--enable_query_log
+disconnect con1;
+connection default;
+--disable_connect_log
+
 # ----------------------------------------------------------------------------
 # Test mysqltest arguments
 # ----------------------------------------------------------------------------

=== modified file 'mysql-test/t/order_by.test'
--- a/mysql-test/t/order_by.test	2009-12-10 15:38:01 +0000
+++ b/mysql-test/t/order_by.test	2010-09-13 11:33:19 +0000
@@ -1467,4 +1467,29 @@ SELECT * FROM t1 FORCE INDEX FOR JOIN (a
 
 DROP TABLE t1, t2;
 
+--echo #
+--echo # Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and
+--echo # ORDER BY computed col
+--echo #
+CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, KEY( a, b ) );
+
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+INSERT INTO t1 SELECT a + 5, b + 5 FROM t1;
+
+CREATE TABLE t2( a INT PRIMARY KEY, b INT );
+
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+INSERT INTO t2 SELECT a + 5, b + 5 FROM t2;
+
+EXPLAIN
+SELECT count(*) AS c, t1.a
+FROM t1 JOIN t2 ON t1.b = t2.a
+WHERE t2.b = 1
+GROUP BY t1.a
+ORDER by c
+LIMIT 2;
+
+DROP TABLE t1, t2;
+
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2010-03-22 12:30:27 +0000
+++ b/mysql-test/t/partition.test	2010-09-30 13:57:33 +0000
@@ -14,6 +14,55 @@
 drop table if exists t1, t2;
 --enable_warnings
 
+--echo #
+--echo # Bug#57113: ha_partition::extra(ha_extra_function):
+--echo #            Assertion `m_extra_cache' failed
+CREATE TABLE t1
+(id INT NOT NULL PRIMARY KEY,
+ name VARCHAR(16) NOT NULL,
+ year YEAR,
+ INDEX name (name(8))
+)
+PARTITION BY HASH(id) PARTITIONS 2;
+
+INSERT INTO t1 VALUES ( 1, 'FooBar', '1924' );
+
+CREATE TABLE t2 (id INT);
+
+INSERT INTO t2 VALUES (1),(2);
+
+UPDATE t1, t2 SET t1.year = '1955' WHERE t1.name = 'FooBar';
+
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # Bug#55458: Partitioned MyISAM table gets crashed by multi-table update 
+--echo #
+CREATE TABLE t1 (
+  `id` int NOT NULL,
+  `user_num` int DEFAULT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1,8601);
+INSERT INTO t1 VALUES (2,8601);
+INSERT INTO t1 VALUES (3,8601);
+INSERT INTO t1 VALUES (4,8601);
+CREATE TABLE t2 (
+  `id` int(11) NOT NULL,
+  `user_num` int DEFAULT NULL,
+  `name` varchar(64) NOT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM CHARSET=latin1
+PARTITION BY HASH (id)
+PARTITIONS 2;
+INSERT INTO t2 VALUES (1,8601,'John');
+INSERT INTO t2 VALUES (2,8601,'JS');
+INSERT INTO t2 VALUES (3,8601,'John S');
+
+UPDATE t1, t2 SET t2.name = 'John Smith' WHERE t1.user_num = t2.user_num;
+
+DROP TABLE t1, t2;
 #
 # Bug#48276: can't add column if subpartition exists
 CREATE TABLE t1 (a INT, b INT)

=== added file 'mysql-test/t/partition_binlog_stmt.test'
--- a/mysql-test/t/partition_binlog_stmt.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/partition_binlog_stmt.test	2010-10-01 11:39:04 +0000
@@ -0,0 +1,26 @@
+--source include/have_partition.inc
+--source include/have_binlog_format_statement.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Bug#51851: Server with SBR locks mutex twice on LOAD DATA into
+--echo #            partitioned MyISAM table
+--write_file init_file.txt
+abcd
+EOF
+
+CREATE TABLE t1
+(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ name TINYBLOB NOT NULL,
+ modified TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ INDEX namelocs (name(255))) ENGINE = MyISAM
+PARTITION BY HASH(id) PARTITIONS 2;
+
+LOAD DATA LOCAL INFILE 'init_file.txt'
+INTO TABLE t1 (name);
+
+--remove_file init_file.txt
+DROP TABLE t1;

=== modified file 'mysql-test/t/partition_error.test'
--- a/mysql-test/t/partition_error.test	2010-06-01 07:02:28 +0000
+++ b/mysql-test/t/partition_error.test	2010-09-22 19:33:18 +0000
@@ -1252,4 +1252,18 @@ PARTITION pmax VALUES LESS THAN MAXVALUE
 
 DROP TABLE old;
 
+--echo #
+--echo # Bug #56709: Memory leaks at running the 5.1 test suite
+--echo # 
+
+CREATE TABLE t1 (a TIMESTAMP NOT NULL PRIMARY KEY);
+
+--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
+ALTER TABLE t1
+PARTITION BY RANGE (EXTRACT(DAY FROM a)) (
+PARTITION p VALUES LESS THAN (18),
+PARTITION pmax VALUES LESS THAN MAXVALUE);
+
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/partition_pruning.test'
--- a/mysql-test/t/partition_pruning.test	2010-03-10 11:56:05 +0000
+++ b/mysql-test/t/partition_pruning.test	2010-08-26 15:14:18 +0000
@@ -9,6 +9,30 @@ drop table if exists t1,t2,t3,t4,t5,t6,t
 --enable_warnings
 
 --echo #
+--echo # Bug#53806: Wrong estimates for range query in partitioned MyISAM table
+--echo # Bug#46754: 'rows' field doesn't reflect partition pruning
+--echo #
+CREATE TABLE t1 (a INT PRIMARY KEY)
+PARTITION BY RANGE (a) (
+PARTITION p0 VALUES LESS THAN (1),
+PARTITION p1 VALUES LESS THAN (2),
+PARTITION p2 VALUES LESS THAN (3),
+PARTITION p3 VALUES LESS THAN (4),
+PARTITION p4 VALUES LESS THAN (5),
+PARTITION p5 VALUES LESS THAN (6),
+PARTITION max VALUES LESS THAN MAXVALUE);
+
+INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8);
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 #
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 #
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 #
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
+DROP TABLE t1;
+
+--echo #
 --echo # Bug#49742: Partition Pruning not working correctly for RANGE
 --echo #
 CREATE TABLE t1 (a INT PRIMARY KEY)

=== modified file 'mysql-test/t/ps.test'
--- a/mysql-test/t/ps.test	2010-04-16 11:42:34 +0000
+++ b/mysql-test/t/ps.test	2010-10-01 10:08:38 +0000
@@ -3079,4 +3079,26 @@ EXECUTE stmt;
 DEALLOCATE PREPARE stmt;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#54494 crash with explain extended and prepared statements
+--echo #
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1),(2);
+PREPARE stmt FROM 'EXPLAIN EXTENDED SELECT 1 FROM t1 RIGHT JOIN t1 t2 ON 1';
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#54488 crash when using explain and prepared statements with subqueries
+--echo #
+CREATE TABLE t1(f1 INT);
+INSERT INTO t1 VALUES (1),(1);
+PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))';
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+
 --echo End of 5.1 tests.

=== modified file 'mysql-test/t/row.test'
--- a/mysql-test/t/row.test	2010-04-16 11:42:34 +0000
+++ b/mysql-test/t/row.test	2010-09-09 12:46:13 +0000
@@ -266,3 +266,22 @@ SELECT 1 FROM t1 WHERE ROW(a, b) >=
 ROW('1', (SELECT 1 FROM t1 WHERE a > 1234));
 --enable_warnings
 DROP TABLE t1;
+
+--echo #
+--echo # Bug #54190: Comparison to row subquery produces incorrect result
+--echo # 
+
+SELECT ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0);
+SELECT ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0);
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 () VALUES (1), (2), (3);
+
+SELECT ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0);
+SELECT ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0);
+SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0);
+SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0);
+
+DROP TABLE t1;
+
+--echo End of 5.1 tests

=== modified file 'mysql-test/t/subselect4.test'
--- a/mysql-test/t/subselect4.test	2010-08-05 10:42:14 +0000
+++ b/mysql-test/t/subselect4.test	2010-09-07 09:21:09 +0000
@@ -74,6 +74,68 @@ CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN (
 CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) );
 DROP VIEW v1, v2;
 
+--echo # 
+--echo # Bug#51070: Query with a NOT IN subquery predicate returns a wrong
+--echo # result set
+--echo # 
+CREATE TABLE t1 ( a INT, b INT );
+INSERT INTO t1 VALUES ( 1, NULL ), ( 2, NULL );
+
+CREATE TABLE t2 ( c INT, d INT );
+INSERT INTO t2 VALUES ( NULL, 3 ), ( NULL, 4 );
+
+CREATE TABLE t3 ( e INT, f INT );
+INSERT INTO t3 VALUES ( NULL, NULL ), ( NULL, NULL );
+
+CREATE TABLE t4 ( a INT );
+INSERT INTO t4 VALUES (1), (2), (3);
+
+CREATE TABLE t5 ( a INT );
+INSERT INTO t5 VALUES (NULL), (2);
+
+--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
+
+EXPLAIN
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
+SELECT * FROM t1 WHERE ( a, b ) IN ( SELECT c, d FROM t2 ) IS NULL;
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS UNKNOWN;
+SELECT * FROM t1 WHERE (( a, b ) NOT IN ( SELECT c, d FROM t2 )) IS UNKNOWN;
+
+SELECT * FROM t1 WHERE 1 = 1 AND ( a, b ) NOT IN ( SELECT c, d FROM t2 );
+
+--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
+SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
+
+--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
+SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
+
+--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
+SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
+
+--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
+SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
+
+SELECT * FROM t1 WHERE ( a, b ) NOT IN 
+  ( SELECT c, d FROM t2 WHERE c = 1 AND c <> 1 );
+
+SELECT * FROM t1 WHERE b NOT IN ( SELECT c FROM t2 WHERE c = 1 );
+
+SELECT * FROM t1 WHERE NULL NOT IN ( SELECT c FROM t2 WHERE c = 1 AND c <> 1 );
+
+DROP TABLE t1, t2, t3, t4, t5;
+
 
 --echo #
 --echo # End of 5.1 tests.

=== modified file 'mysql-test/t/trigger_notembedded.test'
--- a/mysql-test/t/trigger_notembedded.test	2009-06-25 10:52:50 +0000
+++ b/mysql-test/t/trigger_notembedded.test	2010-09-07 08:53:46 +0000
@@ -932,4 +932,52 @@ disconnect con1;
 DROP USER 'no_rights'@'localhost';
 DROP DATABASE db1;
 
+#
+# Bug#55421 Protocol::end_statement(): Assertion `0' on multi-table UPDATE IGNORE
+# To reproduce a crash we need to provoke a trigger execution with
+# the following conditions:
+#   - active SELECT statement during trigger execution
+#    (i.e. LEX::current_select != NULL);
+#   - IGNORE option (i.e. LEX::current_select->no_error == TRUE);
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest_db1;
+--enable_warnings
+
+CREATE DATABASE mysqltest_db1;
+USE mysqltest_db1;
+
+GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--connect(con1,localhost,mysqltest_u1,,mysqltest_db1)
+
+CREATE TABLE t1 (
+  a1 int,
+  a2 int
+);
+INSERT INTO t1 VALUES (1, 20);
+
+CREATE TRIGGER mysqltest_db1.upd_t1
+BEFORE UPDATE ON t1 FOR EACH ROW SET new.a2 = 200;
+
+CREATE TABLE t2 (
+  a1 int
+);
+
+INSERT INTO t2 VALUES (2);
+
+--connection default
+
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE IGNORE t1, t2 SET t1.a1 = 2, t2.a1 = 3 WHERE t1.a1 = 1 AND t2.a1 = 2;
+# Cleanup
+
+DROP DATABASE mysqltest_db1;
+DROP USER mysqltest_u1@localhost;
+
+--disconnect con1
+--connection default
+USE test;
+
 --echo End of 5.1 tests.

=== modified file 'mysql-test/t/type_timestamp.test'
--- a/mysql-test/t/type_timestamp.test	2009-01-31 01:08:41 +0000
+++ b/mysql-test/t/type_timestamp.test	2010-09-13 07:18:35 +0000
@@ -357,3 +357,20 @@ SELECT f1,f2-f3 FROM t1;
 DROP TABLE t1;
 
 --echo End of 5.0 tests
+
+--echo #
+--echo # Bug #55779: select does not work properly in mysql server
+--echo #             Version "5.1.42 SUSE MySQL RPM"
+--echo #
+
+CREATE TABLE t1 (a TIMESTAMP, KEY (a));
+
+INSERT INTO t1 VALUES ('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'),
+                      ('2000-01-01 00:00:01'), ('2000-01-01 00:00:01');
+
+SELECT a FROM t1 WHERE a >=  20000101000000;
+SELECT a FROM t1 WHERE a >= '20000101000000';
+
+DROP TABLE t1;
+
+--echo End of 5.1 tests

=== modified file 'mysql-test/t/variables_debug.test'
--- a/mysql-test/t/variables_debug.test	2010-05-20 06:31:03 +0000
+++ b/mysql-test/t/variables_debug.test	2010-09-22 19:33:18 +0000
@@ -25,4 +25,17 @@ SELECT @@global.debug;
 
 SET GLOBAL debug=@old_debug;
 
+--echo #
+--echo # Bug #56709: Memory leaks at running the 5.1 test suite
+--echo # 
+
+SET @old_local_debug = @@debug;
+
+SET @@debug='d,foo';
+SELECT @@debug;
+SET @@debug='';
+SELECT @@debug;
+
+SET @@debug = @old_local_debug;
+
 --echo End of 5.1 tests

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2010-08-04 12:58:09 +0000
+++ b/mysys/my_getopt.c	2010-09-24 22:13:51 +0000
@@ -112,7 +112,7 @@ int handle_options(int *argc, char ***ar
 		   const struct my_option *longopts,
                    my_get_one_option get_one_option)
 {
-  uint opt_found, argvpos= 0, length;
+  uint UNINIT_VAR(opt_found), argvpos= 0, length;
   my_bool end_of_options= 0, must_be_var, set_maximum_value,
           option_is_loose;
   char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN];
@@ -121,7 +121,6 @@ int handle_options(int *argc, char ***ar
   void *value;
   int error, i;
 
-  LINT_INIT(opt_found);
   /* handle_options() assumes arg0 (program name) always exists */
   DBUG_ASSERT(argc && *argc >= 1);
   DBUG_ASSERT(argv && *argv);

=== modified file 'mysys/sha1.c'
--- a/mysys/sha1.c	2007-01-22 12:10:46 +0000
+++ b/mysys/sha1.c	2010-10-05 14:03:04 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004, 2006 MySQL AB
+/* Copyright (c) 2002, 2004, 2006 MySQL AB
 
  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
@@ -6,26 +6,57 @@
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
 
 /*
   Original Source from: http://www.faqs.org/rfcs/rfc3174.html
 
+  Copyright (C) The Internet Society (2001).  All Rights Reserved.
+
+  This document and translations of it may be copied and furnished to
+  others, and derivative works that comment on or otherwise explain it
+  or assist in its implementation may be prepared, copied, published
+  and distributed, in whole or in part, without restriction of any
+  kind, provided that the above copyright notice and this paragraph are
+  included on all such copies and derivative works.  However, this
+  document itself may not be modified in any way, such as by removing
+  the copyright notice or references to the Internet Society or other
+  Internet organizations, except as needed for the purpose of
+  developing Internet standards in which case the procedures for
+  copyrights defined in the Internet Standards process must be
+  followed, or as required to translate it into languages other than
+  English.
+
+  The limited permissions granted above are perpetual and will not be
+  revoked by the Internet Society or its successors or assigns.
+
+  This document and the information contained herein is provided on an
+  "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
+  TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+  BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+  HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+
+  Acknowledgement 
+  Funding for the RFC Editor function is currently provided by the 
+  Internet Society. 
+
  DESCRIPTION
-   This file implements the Secure Hashing Algorithm 1 as
-   defined in FIPS PUB 180-1 published April 17, 1995.
+  This file implements the Secure Hashing Algorithm 1 as
+  defined in FIPS PUB 180-1 published April 17, 1995.
 
-   The SHA-1, produces a 160-bit message digest for a given data
-   stream.  It should take about 2**n steps to find a message with the
-   same digest as a given message and 2**(n/2) to find any two
-   messages with the same digest, when n is the digest size in bits.
-   Therefore, this algorithm can serve as a means of providing a
-   "fingerprint" for a message.
+  The SHA-1, produces a 160-bit message digest for a given data
+  stream.  It should take about 2**n steps to find a message with the
+  same digest as a given message and 2**(n/2) to find any two
+  messages with the same digest, when n is the digest size in bits.
+  Therefore, this algorithm can serve as a means of providing a
+  "fingerprint" for a message.
 
  PORTABILITY ISSUES
    SHA-1 is defined in terms of 32-bit "words".  This code uses

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2010-08-19 07:20:17 +0000
+++ b/sql/ha_partition.cc	2010-10-01 13:41:27 +0000
@@ -232,6 +232,8 @@ void ha_partition::init_handler_variable
   m_innodb= FALSE;
   m_extra_cache= FALSE;
   m_extra_cache_size= 0;
+  m_extra_prepare_for_update= FALSE;
+  m_extra_cache_part_id= NO_CURRENT_PART_ID;
   m_handler_status= handler_not_initialized;
   m_low_byte_first= 1;
   m_part_field_array= NULL;
@@ -2449,6 +2451,21 @@ err1:
 /****************************************************************************
                 MODULE open/close object
 ****************************************************************************/
+
+
+/**
+  A destructor for partition-specific TABLE_SHARE data.
+*/
+
+void ha_data_partition_destroy(void *ha_data)
+{
+  if (ha_data)
+  {
+    HA_DATA_PARTITION *ha_part_data= (HA_DATA_PARTITION*) ha_data;
+    pthread_mutex_destroy(&ha_part_data->LOCK_auto_inc);
+  }
+}
+
 /*
   Open handler object
 
@@ -2605,6 +2622,8 @@ int ha_partition::open(const char *name,
     }
     DBUG_PRINT("info", ("table_share->ha_data 0x%p", ha_data));
     bzero(ha_data, sizeof(HA_DATA_PARTITION));
+    table_share->ha_data_destroy= ha_data_partition_destroy;
+    VOID(pthread_mutex_init(&ha_data->LOCK_auto_inc, MY_MUTEX_INIT_FAST));
   }
   if (is_not_tmp_table)
     pthread_mutex_unlock(&table_share->mutex);
@@ -5380,9 +5399,6 @@ void ha_partition::get_dynamic_partition
     when performing the sequential scan we will check this recorded value
     and call extra_opt whenever we start scanning a new partition.
 
-    monty: Neads to be fixed so that it's passed to all handlers when we
-    move to another partition during table scan.
-
   HA_EXTRA_NO_CACHE:
     When performing a UNION SELECT HA_EXTRA_NO_CACHE is called from the
     flush method in the select_union class.
@@ -5394,7 +5410,7 @@ void ha_partition::get_dynamic_partition
     for. If no cache is in use they will quickly return after finding
     this out. And we also ensure that all caches are disabled and no one
     is left by mistake.
-    In the future this call will probably be deleted an we will instead call
+    In the future this call will probably be deleted and we will instead call
     ::reset();
 
   HA_EXTRA_WRITE_CACHE:
@@ -5406,8 +5422,9 @@ void ha_partition::get_dynamic_partition
     This is called as part of a multi-table update. When the table to be
     updated is also scanned then this informs MyISAM handler to drop any
     caches if dynamic records are used (fixed size records do not care
-    about this call). We pass this along to all underlying MyISAM handlers
-    and ignore it for the rest.
+    about this call). We pass this along to the first partition to scan, and
+    flag that it is to be called after HA_EXTRA_CACHE when moving to the next
+    partition to scan.
 
   HA_EXTRA_PREPARE_FOR_DROP:
     Only used by MyISAM, called in preparation for a DROP TABLE.
@@ -5554,9 +5571,22 @@ int ha_partition::extra(enum ha_extra_fu
   case HA_EXTRA_PREPARE_FOR_RENAME:
     DBUG_RETURN(prepare_for_rename());
     break;
+  case HA_EXTRA_PREPARE_FOR_UPDATE:
+    /*
+      Needs to be run on the first partition in the range now, and 
+      later in late_extra_cache, when switching to a new partition to scan.
+    */
+    m_extra_prepare_for_update= TRUE;
+    if (m_part_spec.start_part != NO_CURRENT_PART_ID)
+    {
+      if (!m_extra_cache)
+        m_extra_cache_part_id= m_part_spec.start_part;
+      DBUG_ASSERT(m_extra_cache_part_id == m_part_spec.start_part);
+      VOID(m_file[m_part_spec.start_part]->extra(HA_EXTRA_PREPARE_FOR_UPDATE));
+    }
+    break;
   case HA_EXTRA_NORMAL:
   case HA_EXTRA_QUICK:
-  case HA_EXTRA_PREPARE_FOR_UPDATE:
   case HA_EXTRA_FORCE_REOPEN:
   case HA_EXTRA_PREPARE_FOR_DROP:
   case HA_EXTRA_FLUSH_CACHE:
@@ -5579,10 +5609,22 @@ int ha_partition::extra(enum ha_extra_fu
     break;
   }
   case HA_EXTRA_NO_CACHE:
+  {
+    int ret= 0;
+    if (m_extra_cache_part_id != NO_CURRENT_PART_ID)
+      ret= m_file[m_extra_cache_part_id]->extra(HA_EXTRA_NO_CACHE);
+    m_extra_cache= FALSE;
+    m_extra_cache_size= 0;
+    m_extra_prepare_for_update= FALSE;
+    m_extra_cache_part_id= NO_CURRENT_PART_ID;
+    DBUG_RETURN(ret);
+  }
   case HA_EXTRA_WRITE_CACHE:
   {
     m_extra_cache= FALSE;
     m_extra_cache_size= 0;
+    m_extra_prepare_for_update= FALSE;
+    m_extra_cache_part_id= NO_CURRENT_PART_ID;
     DBUG_RETURN(loop_extra(operation));
   }
   case HA_EXTRA_IGNORE_NO_KEY:
@@ -5710,6 +5752,7 @@ int ha_partition::extra_opt(enum ha_extr
 void ha_partition::prepare_extra_cache(uint cachesize)
 {
   DBUG_ENTER("ha_partition::prepare_extra_cache()");
+  DBUG_PRINT("info", ("cachesize %u", cachesize));
 
   m_extra_cache= TRUE;
   m_extra_cache_size= cachesize;
@@ -5768,16 +5811,18 @@ int ha_partition::loop_extra(enum ha_ext
 {
   int result= 0, tmp;
   handler **file;
+  bool is_select;
   DBUG_ENTER("ha_partition::loop_extra()");
   
-  /* 
-    TODO, 5.2: this is where you could possibly add optimisations to add the bitmap
-    _if_ a SELECT.
-  */
+  is_select= (thd_sql_command(ha_thd()) == SQLCOM_SELECT);
   for (file= m_file; *file; file++)
   {
-    if ((tmp= (*file)->extra(operation)))
-      result= tmp;
+    if (!is_select ||
+        bitmap_is_set(&(m_part_info->used_partitions), file - m_file))
+    {
+      if ((tmp= (*file)->extra(operation)))
+        result= tmp;
+    }
   }
   DBUG_RETURN(result);
 }
@@ -5798,14 +5843,25 @@ void ha_partition::late_extra_cache(uint
 {
   handler *file;
   DBUG_ENTER("ha_partition::late_extra_cache");
+  DBUG_PRINT("info", ("extra_cache %u prepare %u partid %u size %u",
+                      m_extra_cache, m_extra_prepare_for_update,
+                      partition_id, m_extra_cache_size));
 
-  if (!m_extra_cache)
+  if (!m_extra_cache && !m_extra_prepare_for_update)
     DBUG_VOID_RETURN;
   file= m_file[partition_id];
-  if (m_extra_cache_size == 0)
-    VOID(file->extra(HA_EXTRA_CACHE));
-  else
-    VOID(file->extra_opt(HA_EXTRA_CACHE, m_extra_cache_size));
+  if (m_extra_cache)
+  {
+    if (m_extra_cache_size == 0)
+      VOID(file->extra(HA_EXTRA_CACHE));
+    else
+      VOID(file->extra_opt(HA_EXTRA_CACHE, m_extra_cache_size));
+  }
+  if (m_extra_prepare_for_update)
+  {
+    VOID(file->extra(HA_EXTRA_PREPARE_FOR_UPDATE));
+  }
+  m_extra_cache_part_id= partition_id;
   DBUG_VOID_RETURN;
 }
 
@@ -5826,10 +5882,12 @@ void ha_partition::late_extra_no_cache(u
   handler *file;
   DBUG_ENTER("ha_partition::late_extra_no_cache");
 
-  if (!m_extra_cache)
+  if (!m_extra_cache && !m_extra_prepare_for_update)
     DBUG_VOID_RETURN;
   file= m_file[partition_id];
   VOID(file->extra(HA_EXTRA_NO_CACHE));
+  DBUG_ASSERT(partition_id == m_extra_cache_part_id);
+  m_extra_cache_part_id= NO_CURRENT_PART_ID;
   DBUG_VOID_RETURN;
 }
 

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	2010-07-09 13:00:33 +0000
+++ b/sql/ha_partition.h	2010-10-01 11:39:49 +0000
@@ -44,6 +44,7 @@ typedef struct st_partition_share
 typedef struct st_ha_data_partition
 {
   ulonglong next_auto_inc_val;                 /**< first non reserved value */
+  pthread_mutex_t LOCK_auto_inc;
   bool auto_inc_initialized;
 } HA_DATA_PARTITION;
 
@@ -154,6 +155,10 @@ private:
   */
   bool m_extra_cache;
   uint m_extra_cache_size;
+  /* The same goes for HA_EXTRA_PREPARE_FOR_UPDATE */
+  bool m_extra_prepare_for_update;
+  /* Which partition has active cache */
+  uint m_extra_cache_part_id;
 
   void init_handler_variables();
   /*
@@ -944,8 +949,9 @@ private:
     DBUG_ASSERT(table_share->ha_data && !auto_increment_lock);
     if(table_share->tmp_table == NO_TMP_TABLE)
     {
+      HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data;
       auto_increment_lock= TRUE;
-      pthread_mutex_lock(&table_share->mutex);
+      pthread_mutex_lock(&ha_data->LOCK_auto_inc);
     }
   }
   virtual void unlock_auto_increment()
@@ -958,7 +964,8 @@ private:
     */
     if(auto_increment_lock && !auto_increment_safe_stmt_log_lock)
     {
-      pthread_mutex_unlock(&table_share->mutex);
+      HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data;
+      pthread_mutex_unlock(&ha_data->LOCK_auto_inc);
       auto_increment_lock= FALSE;
     }
   }

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2010-07-20 18:07:36 +0000
+++ b/sql/item.cc	2010-09-13 07:18:35 +0000
@@ -6970,14 +6970,16 @@ int stored_field_cmp_to_item(THD *thd, F
 
     enum_field_types field_type= field->type();
 
-    if (field_type == MYSQL_TYPE_DATE || field_type == MYSQL_TYPE_DATETIME)
+    if (field_type == MYSQL_TYPE_DATE || field_type == MYSQL_TYPE_DATETIME ||
+        field_type == MYSQL_TYPE_TIMESTAMP)
     {
       enum_mysql_timestamp_type type= MYSQL_TIMESTAMP_ERROR;
 
       if (field_type == MYSQL_TYPE_DATE)
         type= MYSQL_TIMESTAMP_DATE;
 
-      if (field_type == MYSQL_TYPE_DATETIME)
+      if (field_type == MYSQL_TYPE_DATETIME ||
+          field_type == MYSQL_TYPE_TIMESTAMP)
         type= MYSQL_TIMESTAMP_DATETIME;
         
       const char *field_name= field->field_name;
@@ -7404,9 +7406,12 @@ bool Item_cache_row::null_inside()
 
 void Item_cache_row::bring_value()
 {
+  if (!example)
+    return;
+  example->bring_value();
+  null_value= example->null_value;
   for (uint i= 0; i < item_count; i++)
     values[i]->bring_value();
-  return;
 }
 
 

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2010-08-05 10:42:14 +0000
+++ b/sql/item_cmpfunc.cc	2010-09-09 12:48:06 +0000
@@ -1583,6 +1583,13 @@ int Arg_comparator::compare_row()
   bool was_null= 0;
   (*a)->bring_value();
   (*b)->bring_value();
+
+  if ((*a)->null_value || (*b)->null_value)
+  {
+    owner->null_value= 1;
+    return -1;
+  }
+
   uint n= (*a)->cols();
   for (uint i= 0; i<n; i++)
   {
@@ -1751,6 +1758,76 @@ bool Item_in_optimizer::fix_fields(THD *
 }
 
 
+/**
+   The implementation of optimized \<outer expression\> [NOT] IN \<subquery\>
+   predicates. The implementation works as follows.
+
+   For the current value of the outer expression
+   
+   - If it contains only NULL values, the original (before rewrite by the
+     Item_in_subselect rewrite methods) inner subquery is non-correlated and
+     was previously executed, there is no need to re-execute it, and the
+     previous return value is returned.
+
+   - If it contains NULL values, check if there is a partial match for the
+     inner query block by evaluating it. For clarity we repeat here the
+     transformation previously performed on the sub-query. The expression
+
+     <tt>
+     ( oc_1, ..., oc_n ) 
+     \<in predicate\>
+     ( SELECT ic_1, ..., ic_n
+       FROM \<table\>
+       WHERE \<inner where\> 
+     )
+     </tt>
+
+     was transformed into
+     
+     <tt>
+     ( oc_1, ..., oc_n ) 
+     \<in predicate\>
+     ( SELECT ic_1, ..., ic_n 
+       FROM \<table\> 
+       WHERE \<inner where\> AND ... ( ic_k = oc_k OR ic_k IS NULL ) 
+       HAVING ... NOT ic_k IS NULL
+     )
+     </tt>
+
+     The evaluation will now proceed according to special rules set up
+     elsewhere. These rules include:
+
+     - The HAVING NOT \<inner column\> IS NULL conditions added by the
+       aforementioned rewrite methods will detect whether they evaluated (and
+       rejected) a NULL value and if so, will cause the subquery to evaluate
+       to NULL. 
+
+     - The added WHERE and HAVING conditions are present only for those inner
+       columns that correspond to outer column that are not NULL at the moment.
+     
+     - If there is an eligible index for executing the subquery, the special
+       access method "Full scan on NULL key" is employed which ensures that
+       the inner query will detect if there are NULL values resulting from the
+       inner query. This access method will quietly resort to table scan if it
+       needs to find NULL values as well.
+
+     - Under these conditions, the sub-query need only be evaluated in order to
+       find out whether it produced any rows.
+     
+       - If it did, we know that there was a partial match since there are
+         NULL values in the outer row expression.
+
+       - If it did not, the result is FALSE or UNKNOWN. If at least one of the
+         HAVING sub-predicates rejected a NULL value corresponding to an outer
+         non-NULL, and hence the inner query block returns UNKNOWN upon
+         evaluation, there was a partial match and the result is UNKNOWN.
+
+   - If it contains no NULL values, the call is forwarded to the inner query
+     block.
+
+     @see Item_in_subselect::val_bool()
+     @see Item_is_not_null_test::val_int()
+ */
 longlong Item_in_optimizer::val_int()
 {
   bool tmp;
@@ -1804,7 +1881,7 @@ longlong Item_in_optimizer::val_int()
           all_left_cols_null= false;
       }
 
-      if (!((Item_in_subselect*)args[1])->is_correlated && 
+      if (!item_subs->is_correlated && 
           all_left_cols_null && result_for_null_param != UNKNOWN)
       {
         /* 
@@ -1818,8 +1895,11 @@ longlong Item_in_optimizer::val_int()
       else 
       {
         /* The subquery has to be evaluated */
-        (void) args[1]->val_bool_result();
-        null_value= !item_subs->engine->no_rows();
+        (void) item_subs->val_bool_result();
+        if (item_subs->engine->no_rows())
+          null_value= item_subs->null_value;
+        else
+          null_value= TRUE;
         if (all_left_cols_null)
           result_for_null_param= null_value;
       }

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2010-08-20 08:52:16 +0000
+++ b/sql/item_func.cc	2010-10-05 08:11:56 +0000
@@ -4662,7 +4662,7 @@ void Item_func_get_user_var::fix_length_
       decimals=0;
       break;
     case STRING_RESULT:
-      max_length= MAX_BLOB_WIDTH;
+      max_length= MAX_BLOB_WIDTH - 1;
       break;
     case DECIMAL_RESULT:
       max_length= DECIMAL_MAX_STR_LENGTH;

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2010-06-10 20:45:22 +0000
+++ b/sql/item_subselect.cc	2010-10-06 08:58:31 +0000
@@ -47,7 +47,7 @@ Item_subselect::Item_subselect():
     item value is NULL if select_subselect not changed this value
     (i.e. some rows will be found returned)
   */
-  null_value= 1;
+  null_value= TRUE;
 }
 
 
@@ -427,9 +427,9 @@ void Item_maxmin_subselect::print(String
 
 void Item_singlerow_subselect::reset()
 {
-  null_value= 1;
+  null_value= TRUE;
   if (value)
-    value->null_value= 1;
+    value->null_value= TRUE;
 }
 
 
@@ -566,7 +566,10 @@ bool Item_singlerow_subselect::null_insi
 
 void Item_singlerow_subselect::bring_value()
 {
-  exec();
+  if (!exec() && assigned())
+    null_value= 0;
+  else
+    reset();
 }
 
 double Item_singlerow_subselect::val_real()
@@ -574,7 +577,7 @@ double Item_singlerow_subselect::val_rea
   DBUG_ASSERT(fixed == 1);
   if (!exec() && !value->null_value)
   {
-    null_value= 0;
+    null_value= FALSE;
     return value->val_real();
   }
   else
@@ -589,7 +592,7 @@ longlong Item_singlerow_subselect::val_i
   DBUG_ASSERT(fixed == 1);
   if (!exec() && !value->null_value)
   {
-    null_value= 0;
+    null_value= FALSE;
     return value->val_int();
   }
   else
@@ -603,7 +606,7 @@ String *Item_singlerow_subselect::val_st
 {
   if (!exec() && !value->null_value)
   {
-    null_value= 0;
+    null_value= FALSE;
     return value->val_str(str);
   }
   else
@@ -618,7 +621,7 @@ my_decimal *Item_singlerow_subselect::va
 {
   if (!exec() && !value->null_value)
   {
-    null_value= 0;
+    null_value= FALSE;
     return value->val_decimal(decimal_value);
   }
   else
@@ -633,7 +636,7 @@ bool Item_singlerow_subselect::val_bool(
 {
   if (!exec() && !value->null_value)
   {
-    null_value= 0;
+    null_value= FALSE;
     return value->val_bool();
   }
   else
@@ -651,7 +654,7 @@ Item_exists_subselect::Item_exists_subse
   bool val_bool();
   init(select_lex, new select_exists_subselect(this));
   max_columns= UINT_MAX;
-  null_value= 0; //can't be NULL
+  null_value= FALSE; //can't be NULL
   maybe_null= 0; //can't be NULL
   value= 0;
   DBUG_VOID_RETURN;
@@ -814,15 +817,14 @@ double Item_in_subselect::val_real()
   */
   DBUG_ASSERT(0);
   DBUG_ASSERT(fixed == 1);
-  null_value= 0;
+  null_value= was_null= FALSE;
   if (exec())
   {
     reset();
-    null_value= 1;
     return 0;
   }
   if (was_null && !value)
-    null_value= 1;
+    null_value= TRUE;
   return (double) value;
 }
 
@@ -835,15 +837,14 @@ longlong Item_in_subselect::val_int()
   */
   DBUG_ASSERT(0);
   DBUG_ASSERT(fixed == 1);
-  null_value= 0;
+  null_value= was_null= FALSE;
   if (exec())
   {
     reset();
-    null_value= 1;
     return 0;
   }
   if (was_null && !value)
-    null_value= 1;
+    null_value= TRUE;
   return value;
 }
 
@@ -856,16 +857,15 @@ String *Item_in_subselect::val_str(Strin
   */
   DBUG_ASSERT(0);
   DBUG_ASSERT(fixed == 1);
-  null_value= 0;
+  null_value= was_null= FALSE;
   if (exec())
   {
     reset();
-    null_value= 1;
     return 0;
   }
   if (was_null && !value)
   {
-    null_value= 1;
+    null_value= TRUE;
     return 0;
   }
   str->set((ulonglong)value, &my_charset_bin);
@@ -876,20 +876,14 @@ String *Item_in_subselect::val_str(Strin
 bool Item_in_subselect::val_bool()
 {
   DBUG_ASSERT(fixed == 1);
-  null_value= 0;
+  null_value= was_null= FALSE;
   if (exec())
   {
     reset();
-    /* 
-      Must mark the IN predicate as NULL so as to make sure an enclosing NOT
-      predicate will return FALSE. See the comments in 
-      subselect_uniquesubquery_engine::copy_ref_key for further details.
-    */
-    null_value= 1;
     return 0;
   }
   if (was_null && !value)
-    null_value= 1;
+    null_value= TRUE;
   return value;
 }
 
@@ -900,16 +894,15 @@ my_decimal *Item_in_subselect::val_decim
     method should not be used
   */
   DBUG_ASSERT(0);
-  null_value= 0;
+  null_value= was_null= FALSE;
   DBUG_ASSERT(fixed == 1);
   if (exec())
   {
     reset();
-    null_value= 1;
     return 0;
   }
   if (was_null && !value)
-    null_value= 1;
+    null_value= TRUE;
   int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value);
   return decimal_value;
 }
@@ -1914,18 +1907,22 @@ int subselect_single_select_engine::exec
     }
     if (!select_lex->uncacheable && thd->lex->describe && 
         !(join->select_options & SELECT_DESCRIBE) && 
-        join->need_tmp && item->const_item())
+        join->need_tmp)
     {
-      /*
-        Force join->join_tmp creation, because this subquery will be replaced
-        by a simple select from the materialization temp table by optimize()
-        called by EXPLAIN and we need to preserve the initial query structure
-        so we can display it.
-       */
-      select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
-      select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
-      if (join->init_save_join_tab())
-        DBUG_RETURN(1);                        /* purecov: inspected */
+      item->update_used_tables();
+      if (item->const_item())
+      {
+        /*
+          Force join->join_tmp creation, because this subquery will be replaced
+          by a simple select from the materialization temp table by optimize()
+          called by EXPLAIN and we need to preserve the initial query structure
+          so we can display it.
+        */
+        select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
+        select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
+        if (join->init_save_join_tab())
+          DBUG_RETURN(1);                        /* purecov: inspected */
+      }
     }
     if (item->engine_changed)
     {

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2010-07-09 12:00:17 +0000
+++ b/sql/item_timefunc.cc	2010-09-22 19:33:18 +0000
@@ -2270,8 +2270,6 @@ void Item_extract::print(String *str, en
 
 void Item_extract::fix_length_and_dec()
 {
-  value.alloc(32);				// alloc buffer
-
   maybe_null=1;					// If wrong date
   switch (int_type) {
   case INTERVAL_YEAR:		max_length=4; date_value=1; break;
@@ -2314,6 +2312,8 @@ longlong Item_extract::val_int()
   }
   else
   {
+    char buf[40];
+    String value(buf, sizeof(buf), &my_charset_bin);;
     String *res= args[0]->val_str(&value);
     if (!res || str_to_time_with_warn(res->ptr(), res->length(), &ltime))
     {

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2010-08-13 13:05:46 +0000
+++ b/sql/item_timefunc.h	2010-09-22 19:33:18 +0000
@@ -702,7 +702,6 @@ public:
 
 class Item_extract :public Item_int_func
 {
-  String value;
   bool date_value;
  public:
   const interval_type int_type; // keep it public

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-08-25 08:47:45 +0000
+++ b/sql/log.cc	2010-09-22 12:53:06 +0000
@@ -1712,7 +1712,9 @@ static int binlog_savepoint_set(handlert
 
   String log_query;
   if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
-      log_query.append(thd->lex->ident.str, thd->lex->ident.length))
+      log_query.append("`") ||
+      log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
+      log_query.append("`"))
     DBUG_RETURN(1);
   int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
   Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
@@ -1734,7 +1736,9 @@ static int binlog_savepoint_rollback(han
   {
     String log_query;
     if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
-        log_query.append(thd->lex->ident.str, thd->lex->ident.length))
+        log_query.append("`") ||
+        log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
+        log_query.append("`"))
       DBUG_RETURN(1);
     int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
     Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
@@ -5068,10 +5072,32 @@ extern "C" my_bool reopen_fstreams(const
                                    FILE *outstream, FILE *errstream)
 {
   int handle_fd;
-  int stream_fd;
+  int err_fd, out_fd;
   HANDLE osfh;
 
-  DBUG_ASSERT(filename && (outstream || errstream));
+  DBUG_ASSERT(filename && errstream);
+
+  // Services don't have stdout/stderr on Windows, so _fileno returns -1.
+  err_fd= _fileno(errstream);
+  if (err_fd < 0)
+  {
+    if (!freopen(filename, "a+", errstream))
+      return TRUE;
+
+    setbuf(errstream, NULL);
+    err_fd= _fileno(errstream);
+  }
+
+  if (outstream)
+  {
+    out_fd= _fileno(outstream);
+    if (out_fd < 0)
+    {
+      if (!freopen(filename, "a+", outstream))
+        return TRUE;
+      out_fd= _fileno(outstream);
+    }
+  }
 
   if ((osfh= CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
                         FILE_SHARE_READ | FILE_SHARE_WRITE |
@@ -5087,24 +5113,16 @@ extern "C" my_bool reopen_fstreams(const
     return TRUE;
   }
 
-  if (outstream)
+  if (_dup2(handle_fd, err_fd) < 0)
   {
-    stream_fd= _fileno(outstream);
-    if (_dup2(handle_fd, stream_fd) < 0)
-    {
-      CloseHandle(osfh);
-      return TRUE;
-    }
+    CloseHandle(osfh);
+    return TRUE;
   }
 
-  if (errstream)
+  if (outstream && _dup2(handle_fd, out_fd) < 0)
   {
-    stream_fd= _fileno(errstream);
-    if (_dup2(handle_fd, stream_fd) < 0)
-    {
-      CloseHandle(osfh);
-      return TRUE;
-    }
+    CloseHandle(osfh);
+    return TRUE;
   }
 
   _close(handle_fd);

=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc	2010-07-19 14:30:34 +0000
+++ b/sql/net_serv.cc	2010-09-16 10:24:27 +0000
@@ -170,7 +170,17 @@ my_bool net_realloc(NET *net, size_t len
   DBUG_ENTER("net_realloc");
   DBUG_PRINT("enter",("length: %lu", (ulong) length));
 
-  if (length >= net->max_packet_size)
+  /*
+    When compression is off, net->where_b is always 0.
+    With compression turned on, net->where_b may indicate
+    that we still have a piece of the previous logical
+    packet in the buffer, unprocessed. Take it into account
+    when checking that max_allowed_packet is not exceeded.
+    This ensures that the client treats max_allowed_packet
+    limit identically, regardless of compression being on
+    or off.
+  */
+  if (length >= (net->max_packet_size + net->where_b))
   {
     DBUG_PRINT("error", ("Packet too large. Max size: %lu",
                          net->max_packet_size));

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2010-08-24 15:51:32 +0000
+++ b/sql/opt_range.cc	2010-09-16 12:13:53 +0000
@@ -8451,9 +8451,14 @@ int QUICK_RANGE_SELECT::reset()
   in_range= FALSE;
   cur_range= (QUICK_RANGE**) ranges.buffer;
 
-  if (file->inited == handler::NONE && (error= file->ha_index_init(index,1)))
-    DBUG_RETURN(error);
- 
+  if (file->inited == handler::NONE)
+  {
+    if (in_ror_merged_scan)
+      head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap);
+    if ((error= file->ha_index_init(index,1)))
+        DBUG_RETURN(error);
+  }
+
   /* Do not allocate the buffers twice. */
   if (multi_range_length)
   {

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2010-07-21 07:56:43 +0000
+++ b/sql/sql_cache.cc	2010-09-24 12:03:28 +0000
@@ -1330,6 +1330,57 @@ end:
 }
 
 
+#ifndef EMBEDDED_LIBRARY
+/**
+  Send a single memory block from the query cache.
+
+  Respects the client/server protocol limits for the
+  size of the network packet, and splits a large block
+  in pieces to ensure that individual piece doesn't exceed
+  the maximal allowed size of the network packet (16M).
+
+  @param[in] net NET handler
+  @param[in] packet packet to send
+  @param[in] len packet length
+
+  @return Operation status
+    @retval FALSE On success
+    @retval TRUE On error
+*/
+static bool
+send_data_in_chunks(NET *net, const uchar *packet, ulong len)
+{
+  /*
+    On the client we may require more memory than max_allowed_packet
+    to keep, both, the truncated last logical packet, and the
+    compressed next packet.  This never (or in practice never)
+    happens without compression, since without compression it's very
+    unlikely that a) a truncated logical packet would remain on the
+    client when it's time to read the next packet b) a subsequent
+    logical packet that is being read would be so large that
+    size-of-new-packet + size-of-old-packet-tail >
+    max_allowed_packet.  To remedy this issue, we send data in 1MB
+    sized packets, that's below the current client default of 16MB
+    for max_allowed_packet, but large enough to ensure there is no
+    unnecessary overhead from too many syscalls per result set.
+  */
+  static const ulong MAX_CHUNK_LENGTH= 1024*1024;
+
+  while (len > MAX_CHUNK_LENGTH)
+  {
+    if (net_real_write(net, packet, MAX_CHUNK_LENGTH))
+      return TRUE;
+    packet+= MAX_CHUNK_LENGTH;
+    len-= MAX_CHUNK_LENGTH;
+  }
+  if (len && net_real_write(net, packet, len))
+    return TRUE;
+
+  return FALSE;
+}
+#endif
+
+
 /*
   Check if the query is in the cache. If it was cached, send it
   to the user.
@@ -1635,11 +1686,11 @@ def_week_frmt: %lu, in_trans: %d, autoco
                                    ALIGN_SIZE(sizeof(Query_cache_result)))));
     
     Query_cache_result *result = result_block->result();
-    if (net_real_write(&thd->net, result->data(),
-		       result_block->used -
-		       result_block->headers_len() -
-		       ALIGN_SIZE(sizeof(Query_cache_result))))
-      break;					// Client aborted
+    if (send_data_in_chunks(&thd->net, result->data(),
+                            result_block->used -
+                            result_block->headers_len() -
+                            ALIGN_SIZE(sizeof(Query_cache_result))))
+      break;                                    // Client aborted
     result_block = result_block->next;
     thd->net.pkt_nr= query->last_pkt_nr; // Keep packet number updated
   } while (result_block != first_result_block);

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-07-23 11:15:56 +0000
+++ b/sql/sql_class.cc	2010-09-01 17:38:34 +0000
@@ -91,7 +91,9 @@ extern "C" void free_user_var(user_var_e
 
 bool Key_part_spec::operator==(const Key_part_spec& other) const
 {
-  return length == other.length && !strcmp(field_name, other.field_name);
+  return length == other.length &&
+         !my_strcasecmp(system_charset_info, field_name,
+                        other.field_name);
 }
 
 /**

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2010-08-03 02:22:19 +0000
+++ b/sql/sql_load.cc	2010-09-22 19:33:18 +0000
@@ -1116,6 +1116,7 @@ READ_INFO::READ_INFO(File file_par, uint
 		      MYF(MY_WME)))
     {
       my_free((uchar*) buffer,MYF(0)); /* purecov: inspected */
+      buffer= NULL;
       error=1;
     }
     else
@@ -1142,13 +1143,10 @@ READ_INFO::READ_INFO(File file_par, uint
 
 READ_INFO::~READ_INFO()
 {
-  if (!error)
-  {
-    if (need_end_io_cache)
-      ::end_io_cache(&cache);
-    my_free((uchar*) buffer,MYF(0));
-    error=1;
-  }
+  if (!error && need_end_io_cache)
+    ::end_io_cache(&cache);
+
+  my_free(buffer, MYF(MY_ALLOW_ZERO_PTR));
 }
 
 

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2010-10-07 19:44:09 +0000
+++ b/sql/sql_prepare.cc	2010-11-01 18:44:43 +0000
@@ -2362,11 +2362,15 @@ void reinit_stmt_before_use(THD *thd, LE
         sl->where= sl->prep_where->copy_andor_structure(thd);
         sl->where->cleanup();
       }
+      else
+        sl->where= NULL;
       if (sl->prep_having)
       {
         sl->having= sl->prep_having->copy_andor_structure(thd);
         sl->having->cleanup();
       }
+      else
+        sl->having= NULL;
       DBUG_ASSERT(sl->join == 0);
       ORDER *order;
       /* Fix GROUP list */

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-09-02 00:43:02 +0000
+++ b/sql/sql_select.cc	2010-10-05 08:11:56 +0000
@@ -1487,6 +1487,15 @@ JOIN::optimize()
     if (order)
     {
       /*
+        Do we need a temporary table due to the ORDER BY not being equal to
+        the GROUP BY? The call to test_if_skip_sort_order above tests for the
+        GROUP BY clause only and hence is not valid in this case. So the
+        estimated number of rows to be read from the first table is not valid.
+        We clear it here so that it doesn't show up in EXPLAIN.
+       */
+      if (need_tmp && (select_options & SELECT_DESCRIBE) != 0)
+        join_tab[const_tables].limit= 0;
+      /*
         Force using of tmp table if sorting by a SP or UDF function due to
         their expensive and probably non-deterministic nature.
       */
@@ -11165,22 +11174,20 @@ do_select(JOIN *join,List<Item> *fields,
   if (error == NESTED_LOOP_NO_MORE_ROWS)
     error= NESTED_LOOP_OK;
 
+  if (table == NULL)					// If sending data to client
+    /*
+      The following will unlock all cursors if the command wasn't an
+      update command
+    */
+    join->join_free();			// Unlock all cursors
   if (error == NESTED_LOOP_OK)
   {
     /*
       Sic: this branch works even if rc != 0, e.g. when
       send_data above returns an error.
     */
-    if (!table)					// If sending data to client
-    {
-      /*
-	The following will unlock all cursors if the command wasn't an
-	update command
-      */
-      join->join_free();			// Unlock all cursors
-      if (join->result->send_eof())
-	rc= 1;                                  // Don't send error
-    }
+    if (table == NULL && join->result->send_eof()) // If sending data to client
+      rc= 1;                                  // Don't send error 
     DBUG_PRINT("info",("%ld records output", (long) join->send_records));
   }
   else
@@ -16672,7 +16679,15 @@ static void select_describe(JOIN *join,
         if (tab->select && tab->select->quick)
           examined_rows= tab->select->quick->records;
         else if (tab->type == JT_NEXT || tab->type == JT_ALL)
-          examined_rows= tab->limit ? tab->limit : tab->table->file->records();
+        {
+          if (tab->limit)
+            examined_rows= tab->limit;
+          else
+          {
+            tab->table->file->info(HA_STATUS_VARIABLE);
+            examined_rows= tab->table->file->stats.records;
+          }
+        }
         else
           examined_rows=(ha_rows)join->best_positions[i].records_read; 
  

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-07-21 15:54:11 +0000
+++ b/sql/sql_table.cc	2010-09-21 14:37:18 +0000
@@ -3325,6 +3325,7 @@ mysql_prepare_create_table(THD *thd, HA_
       key_part_info->length=(uint16) length;
       /* Use packed keys for long strings on the first column */
       if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) &&
+          !((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) &&
 	  (length >= KEY_DEFAULT_PACK_LENGTH &&
 	   (sql_field->sql_type == MYSQL_TYPE_STRING ||
 	    sql_field->sql_type == MYSQL_TYPE_VARCHAR ||
@@ -4415,9 +4416,6 @@ static int prepare_for_repair(THD *thd,
     pthread_mutex_unlock(&LOCK_open);
   }
 
-  /* A MERGE table must not come here. */
-  DBUG_ASSERT(!table->child_l);
-
   /*
     REPAIR TABLE ... USE_FRM for temporary tables makes little sense.
   */

=== modified file 'sql/sql_trigger.cc'
--- a/sql/sql_trigger.cc	2010-06-11 12:52:06 +0000
+++ b/sql/sql_trigger.cc	2010-09-07 08:53:46 +0000
@@ -1989,6 +1989,7 @@ bool Table_triggers_list::process_trigge
   bool err_status;
   Sub_statement_state statement_state;
   sp_head *sp_trigger= bodies[event][time_type];
+  SELECT_LEX *save_current_select;
 
   if (sp_trigger == NULL)
     return FALSE;
@@ -2012,11 +2013,19 @@ bool Table_triggers_list::process_trigge
 
   thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER);
 
+  /*
+    Reset current_select before call execute_trigger() and
+    restore it after return from one. This way error is set
+    in case of failure during trigger execution.
+  */
+  save_current_select= thd->lex->current_select;
+  thd->lex->current_select= NULL;
   err_status=
     sp_trigger->execute_trigger(thd,
                                 &trigger_table->s->db,
                                 &trigger_table->s->table_name,
                                 &subject_table_grants[event][time_type]);
+  thd->lex->current_select= save_current_select;
 
   thd->restore_sub_statement_state(&statement_state);
 

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-07-20 18:07:36 +0000
+++ b/sql/table.cc	2010-10-01 11:39:04 +0000
@@ -425,6 +425,11 @@ void free_table_share(TABLE_SHARE *share
       key_info->flags= 0;
     }
   }
+  if (share->ha_data_destroy)
+  {
+    share->ha_data_destroy(share->ha_data);
+    share->ha_data_destroy= NULL;
+  }
   /* We must copy mem_root from share because share is allocated through it */
   memcpy((char*) &mem_root, (char*) &share->mem_root, sizeof(mem_root));
   free_root(&mem_root, MYF(0));                 // Free's share
@@ -1616,6 +1621,11 @@ static int open_binary_frm(THD *thd, TAB
   delete crypted;
   delete handler_file;
   hash_free(&share->name_hash);
+  if (share->ha_data_destroy)
+  {
+    share->ha_data_destroy(share->ha_data);
+    share->ha_data_destroy= NULL;
+  }
 
   open_table_error(share, error, share->open_errno, errarg);
   DBUG_RETURN(error);

=== modified file 'sql/table.h'
--- a/sql/table.h	2010-08-02 07:50:15 +0000
+++ b/sql/table.h	2010-10-01 11:39:04 +0000
@@ -463,6 +463,7 @@ typedef struct st_table_share
 
   /** place to store storage engine specific data */
   void *ha_data;
+  void (*ha_data_destroy)(void *); /* An optional destructor for ha_data. */
 
 
   /*

=== modified file 'storage/innobase/btr/btr0btr.c'
--- a/storage/innobase/btr/btr0btr.c	2009-11-19 13:12:22 +0000
+++ b/storage/innobase/btr/btr0btr.c	2010-09-13 13:39:40 +0000
@@ -2060,7 +2060,6 @@ btr_compress(
 	ulint		n_recs;
 	ulint		max_ins_size;
 	ulint		max_ins_size_reorg;
-	ulint		level;
 	ulint		comp;
 
 	page = btr_cur_get_page(cursor);
@@ -2072,7 +2071,6 @@ btr_compress(
 				MTR_MEMO_X_LOCK));
 	ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
 				MTR_MEMO_PAGE_X_FIX));
-	level = btr_page_get_level(page, mtr);
 	space = dict_index_get_space(index);
 
 	left_page_no = btr_page_get_prev(page, mtr);

=== modified file 'storage/innobase/btr/btr0cur.c'
--- a/storage/innobase/btr/btr0cur.c	2009-06-17 07:01:37 +0000
+++ b/storage/innobase/btr/btr0cur.c	2010-09-14 08:37:21 +0000
@@ -3365,7 +3365,9 @@ btr_store_big_rec_extern_fields(
 	page_t*	page;
 	ulint	space_id;
 	page_t*	prev_page;
+#ifdef UNIV_SYNC_DEBUG
 	page_t*	rec_page;
+#endif /* UNIV_SYNC_DEBUG */
 	ulint	prev_page_no;
 	ulint	hint_page_no;
 	ulint	i;
@@ -3460,9 +3462,12 @@ btr_store_big_rec_extern_fields(
 
 			extern_len -= store_len;
 
-			rec_page = buf_page_get(space_id,
-						buf_frame_get_page_no(data),
-						RW_X_LATCH, &mtr);
+#ifdef UNIV_SYNC_DEBUG
+			rec_page =
+#endif /* UNIV_SYNC_DEBUG */
+			buf_page_get(space_id,
+				     buf_frame_get_page_no(data),
+				     RW_X_LATCH, &mtr);
 #ifdef UNIV_SYNC_DEBUG
 			buf_page_dbg_add_level(rec_page, SYNC_NO_ORDER_CHECK);
 #endif /* UNIV_SYNC_DEBUG */
@@ -3536,10 +3541,11 @@ btr_free_externally_stored_field(
 					X-latch to the index tree */
 {
 	page_t*	page;
+#ifdef UNIV_SYNC_DEBUG
 	page_t*	rec_page;
+#endif /* UNIV_SYNC_DEBUG */
 	ulint	space_id;
 	ulint	page_no;
-	ulint	offset;
 	ulint	extern_len;
 	ulint	next_page_no;
 	ulint	part_len;
@@ -3556,9 +3562,12 @@ btr_free_externally_stored_field(
 	for (;;) {
 		mtr_start(&mtr);
 
-		rec_page = buf_page_get(buf_frame_get_space_id(data),
-					buf_frame_get_page_no(data),
-					RW_X_LATCH, &mtr);
+#ifdef UNIV_SYNC_DEBUG
+		rec_page =
+#endif /* UNIV_SYNC_DEBUG */
+		buf_page_get(buf_frame_get_space_id(data),
+			     buf_frame_get_page_no(data),
+			     RW_X_LATCH, &mtr);
 #ifdef UNIV_SYNC_DEBUG
 		buf_page_dbg_add_level(rec_page, SYNC_NO_ORDER_CHECK);
 #endif /* UNIV_SYNC_DEBUG */
@@ -3568,8 +3577,6 @@ btr_free_externally_stored_field(
 		page_no = mach_read_from_4(data + local_len
 					   + BTR_EXTERN_PAGE_NO);
 
-		offset = mach_read_from_4(data + local_len
-					  + BTR_EXTERN_OFFSET);
 		extern_len = mach_read_from_4(data + local_len
 					      + BTR_EXTERN_LEN + 4);
 

=== modified file 'storage/innobase/btr/btr0pcur.c'
--- a/storage/innobase/btr/btr0pcur.c	2006-09-19 07:22:21 +0000
+++ b/storage/innobase/btr/btr0pcur.c	2010-09-14 08:38:59 +0000
@@ -429,7 +429,6 @@ btr_pcur_move_backward_from_page(
 	mtr_t*		mtr)	/* in: mtr */
 {
 	ulint	prev_page_no;
-	ulint	space;
 	page_t*	page;
 	page_t*	prev_page;
 	ulint	latch_mode;
@@ -465,7 +464,6 @@ btr_pcur_move_backward_from_page(
 	page = btr_pcur_get_page(cursor);
 
 	prev_page_no = btr_page_get_prev(page, mtr);
-	space = buf_frame_get_space_id(page);
 
 	if (btr_pcur_is_before_first_on_page(cursor, mtr)
 	    && (prev_page_no != FIL_NULL)) {

=== modified file 'storage/innobase/btr/btr0sea.c'
--- a/storage/innobase/btr/btr0sea.c	2009-01-23 13:43:51 +0000
+++ b/storage/innobase/btr/btr0sea.c	2010-09-14 08:39:34 +0000
@@ -1401,7 +1401,6 @@ btr_search_update_hash_on_delete(
 	rec_t*		rec;
 	ulint		fold;
 	dulint		index_id;
-	ibool		found;
 	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
 	mem_heap_t*	heap		= NULL;
 	*offsets_ = (sizeof offsets_) / sizeof *offsets_;
@@ -1433,7 +1432,7 @@ btr_search_update_hash_on_delete(
 	}
 	rw_lock_x_lock(&btr_search_latch);
 
-	found = ha_search_and_delete_if_found(table, fold, rec);
+	ha_search_and_delete_if_found(table, fold, rec);
 
 	rw_lock_x_unlock(&btr_search_latch);
 }

=== modified file 'storage/innobase/buf/buf0flu.c'
--- a/storage/innobase/buf/buf0flu.c	2010-05-04 12:55:10 +0000
+++ b/storage/innobase/buf/buf0flu.c	2010-09-14 09:00:58 +0000
@@ -841,7 +841,6 @@ buf_flush_batch(
 {
 	buf_block_t*	block;
 	ulint		page_count	= 0;
-	ulint		old_page_count;
 	ulint		space;
 	ulint		offset;
 	ibool		found;
@@ -913,15 +912,9 @@ buf_flush_batch(
 				mutex_exit(&block->mutex);
 				mutex_exit(&(buf_pool->mutex));
 
-				old_page_count = page_count;
-
 				/* Try to flush also all the neighbors */
 				page_count += buf_flush_try_neighbors(
 					space, offset, flush_type);
-				/* fprintf(stderr,
-				"Flush type %lu, page no %lu, neighb %lu\n",
-				flush_type, offset,
-				page_count - old_page_count); */
 
 				mutex_enter(&(buf_pool->mutex));
 

=== modified file 'storage/innobase/eval/eval0eval.c'
--- a/storage/innobase/eval/eval0eval.c	2006-09-15 07:32:15 +0000
+++ b/storage/innobase/eval/eval0eval.c	2010-09-14 09:11:00 +0000
@@ -367,18 +367,13 @@ eval_notfound(
 /*==========*/
 	func_node_t*	func_node)	/* in: function node */
 {
-	que_node_t*	arg1;
-	que_node_t*	arg2;
 	sym_node_t*	cursor;
 	sel_node_t*	sel_node;
 	ibool		ibool_val;
 
-	arg1 = func_node->args;
-	arg2 = que_node_get_next(arg1);
-
 	ut_ad(func_node->func == PARS_NOTFOUND_TOKEN);
 
-	cursor = arg1;
+	cursor = func_node->args;
 
 	ut_ad(que_node_get_type(cursor) == QUE_NODE_SYMBOL);
 

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2010-09-02 00:43:02 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2010-10-05 08:11:56 +0000
@@ -5983,7 +5983,6 @@ innobase_drop_database(
 	trx_t*	parent_trx;
 	trx_t*	trx;
 	char*	ptr;
-	int	error;
 	char*	namebuf;
 	THD*	thd		= current_thd;
 
@@ -6021,7 +6020,7 @@ innobase_drop_database(
 		trx->check_foreigns = FALSE;
 	}
 
-	error = row_drop_database_for_mysql(namebuf, trx);
+	row_drop_database_for_mysql(namebuf, trx);
 	my_free(namebuf, MYF(0));
 
 	/* Flush the log to reduce probability that the .frm files and
@@ -6037,13 +6036,7 @@ innobase_drop_database(
 
 	innobase_commit_low(trx);
 	trx_free_for_mysql(trx);
-#ifdef NO_LONGER_INTERESTED_IN_DROP_DB_ERROR
-	error = convert_error_code_to_mysql(error, NULL);
-
-	return(error);
-#else
 	return;
-#endif
 }
 
 /*************************************************************************
@@ -7560,12 +7553,9 @@ innodb_show_status(
 
 	mutex_exit_noninline(&srv_monitor_file_mutex);
 
-	bool result = FALSE;
+	stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name),
+		   STRING_WITH_LEN(""), str, flen);
 
-	if (stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name),
-			STRING_WITH_LEN(""), str, flen)) {
-		result= TRUE;
-	}
 	my_free(str, MYF(0));
 
 	DBUG_RETURN(FALSE);

=== modified file 'storage/innobase/include/ut0rnd.ic'
--- a/storage/innobase/include/ut0rnd.ic	2006-08-29 08:27:56 +0000
+++ b/storage/innobase/include/ut0rnd.ic	2010-09-13 13:33:25 +0000
@@ -67,9 +67,6 @@ ut_rnd_gen_ulint(void)
 			/* out: the 'random' number */
 {
 	ulint	rnd;
-	ulint	n_bits;
-
-	n_bits = 8 * sizeof(ulint);
 
 	ut_rnd_ulint_counter = UT_RND1 * ut_rnd_ulint_counter + UT_RND2;
 

=== modified file 'storage/innobase/lock/lock0lock.c'
--- a/storage/innobase/lock/lock0lock.c	2010-06-02 10:26:37 +0000
+++ b/storage/innobase/lock/lock0lock.c	2010-09-14 09:37:03 +0000
@@ -4296,7 +4296,6 @@ lock_print_info_all_transactions(
 	lock_t*	lock;
 	ulint	space;
 	ulint	page_no;
-	page_t*	page;
 	ibool	load_page_first = TRUE;
 	ulint	nth_trx		= 0;
 	ulint	nth_lock	= 0;
@@ -4410,8 +4409,7 @@ loop:
 
 			mtr_start(&mtr);
 
-			page = buf_page_get_with_no_latch(
-				space, page_no, &mtr);
+			buf_page_get_with_no_latch(space, page_no, &mtr);
 
 			mtr_commit(&mtr);
 

=== modified file 'storage/innobase/log/log0recv.c'
--- a/storage/innobase/log/log0recv.c	2010-04-29 13:41:47 +0000
+++ b/storage/innobase/log/log0recv.c	2010-09-14 09:46:23 +0000
@@ -400,10 +400,8 @@ recv_synchronize_groups(
 	dulint		start_lsn;
 	dulint		end_lsn;
 	dulint		recovered_lsn;
-	dulint		limit_lsn;
 
 	recovered_lsn = recv_sys->recovered_lsn;
-	limit_lsn = recv_sys->limit_lsn;
 
 	/* Read the last recovered log block to the recovery system buffer:
 	the block is always incomplete */
@@ -2506,7 +2504,9 @@ recv_recovery_from_checkpoint_start(
 	dulint		old_scanned_lsn;
 	dulint		group_scanned_lsn;
 	dulint		contiguous_lsn;
+#ifdef UNIV_LOG_ARCHIVE
 	dulint		archived_lsn;
+#endif /* UNIV_LOG_ARCHIVE */
 	ulint		capacity;
 	byte*		buf;
 	byte		log_hdr_buf[LOG_FILE_HDR_SIZE];
@@ -2552,7 +2552,9 @@ recv_recovery_from_checkpoint_start(
 
 	checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
 	checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
+#ifdef UNIV_LOG_ARCHIVE
 	archived_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN);
+#endif /* UNIV_LOG_ARCHIVE */
 
 	/* Read the first log file header to print a note if this is
 	a recovery from a restored InnoDB Hot Backup */

=== modified file 'storage/innobase/os/os0file.c'
--- a/storage/innobase/os/os0file.c	2010-07-02 18:30:47 +0000
+++ b/storage/innobase/os/os0file.c	2010-09-14 10:01:25 +0000
@@ -1314,8 +1314,6 @@ try_again:
 	int		create_flag;
 	ibool		retry;
 	const char*	mode_str	= NULL;
-	const char*	type_str	= NULL;
-	const char*	purpose_str	= NULL;
 
 try_again:
 	ut_a(name);
@@ -1335,26 +1333,9 @@ try_again:
 		ut_error;
 	}
 
-	if (type == OS_LOG_FILE) {
-		type_str = "LOG";
-	} else if (type == OS_DATA_FILE) {
-		type_str = "DATA";
-	} else {
-		ut_error;
-	}
-
-	if (purpose == OS_FILE_AIO) {
-		purpose_str = "AIO";
-	} else if (purpose == OS_FILE_NORMAL) {
-		purpose_str = "NORMAL";
-	} else {
-		ut_error;
-	}
+	ut_a(type == OS_LOG_FILE || type == OS_DATA_FILE);
+	ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL);
 
-#if 0
-	fprintf(stderr, "Opening file %s, mode %s, type %s, purpose %s\n",
-		name, mode_str, type_str, purpose_str);
-#endif
 #ifdef O_SYNC
 	/* We let O_SYNC only affect log files; note that we map O_DSYNC to
 	O_SYNC because the datasync options seemed to corrupt files in 2001

=== modified file 'storage/innobase/que/que0que.c'
--- a/storage/innobase/que/que0que.c	2007-01-18 21:27:31 +0000
+++ b/storage/innobase/que/que0que.c	2010-09-14 10:39:52 +0000
@@ -802,13 +802,11 @@ que_thr_dec_refer_count(
 {
 	que_fork_t*	fork;
 	trx_t*		trx;
-	sess_t*		sess;
 	ulint		fork_type;
 	ibool		stopped;
 
 	fork = thr->common.parent;
 	trx = thr_get_trx(thr);
-	sess = trx->sess;
 
 	mutex_enter(&kernel_mutex);
 
@@ -1292,18 +1290,13 @@ que_run_threads_low(
 	que_thr_t*	thr)	/* in: query thread */
 {
 	que_thr_t*	next_thr;
-	ulint		cumul_resource;
 	ulint		loop_count;
 
 	ut_ad(thr->state == QUE_THR_RUNNING);
 	ut_a(thr_get_trx(thr)->error_state == DB_SUCCESS);
 	ut_ad(!mutex_own(&kernel_mutex));
 
-	/* cumul_resource counts how much resources the OS thread (NOT the
-	query thread) has spent in this function */
-
 	loop_count = QUE_MAX_LOOPS_WITHOUT_CHECK;
-	cumul_resource = 0;
 loop:
 	/* Check that there is enough space in the log to accommodate
 	possible log entries by this query step; if the operation can touch

=== modified file 'storage/innobase/row/row0mysql.c'
--- a/storage/innobase/row/row0mysql.c	2010-08-25 03:42:33 +0000
+++ b/storage/innobase/row/row0mysql.c	2010-10-06 10:41:26 +0000
@@ -1457,7 +1457,12 @@ run_again:
 		srv_n_rows_updated++;
 	}
 
-	row_update_statistics_if_needed(prebuilt->table);
+	/* We update table statistics only if it is a DELETE or UPDATE
+	that changes indexed columns, UPDATEs that change only non-indexed
+	columns would not affect statistics. */
+	if (node->is_delete || !(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
+		row_update_statistics_if_needed(prebuilt->table);
+	}
 
 	trx->op_info = "";
 
@@ -1608,6 +1613,9 @@ row_update_cascade_for_mysql(
 
 	trx = thr_get_trx(thr);
 
+	/* Increment fk_cascade_depth to record the recursive call depth on
+	a single update/delete that affects multiple tables chained
+	together with foreign key relations. */
 	thr->fk_cascade_depth++;
 
 	if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) {
@@ -1619,6 +1627,12 @@ run_again:
 
 	row_upd_step(thr);
 
+	/* The recursive call for cascading update/delete happens
+	in above row_upd_step(), reset the counter once we come
+	out of the recursive call, so it does not accumulate for
+	different row deletes */
+	thr->fk_cascade_depth = 0;
+
 	err = trx->error_state;
 
 	/* Note that the cascade node is a subnode of another InnoDB

=== modified file 'storage/innobase/row/row0purge.c'
--- a/storage/innobase/row/row0purge.c	2006-09-26 11:37:58 +0000
+++ b/storage/innobase/row/row0purge.c	2010-09-14 10:56:29 +0000
@@ -667,7 +667,7 @@ row_purge_step(
 
 	err = row_purge(node, thr);
 
-	ut_ad(err == DB_SUCCESS);
+	ut_a(err == DB_SUCCESS);
 
 	return(thr);
 }

=== modified file 'storage/innobase/row/row0sel.c'
--- a/storage/innobase/row/row0sel.c	2010-06-09 12:07:34 +0000
+++ b/storage/innobase/row/row0sel.c	2010-10-11 20:13:47 +0000
@@ -3259,6 +3259,7 @@ row_search_for_mysql(
 	mem_heap_t*	heap				= NULL;
 	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
 	ulint*		offsets				= offsets_;
+	ibool		table_lock_waited		= FALSE;
 
 	*offsets_ = (sizeof offsets_) / sizeof *offsets_;
 
@@ -3599,6 +3600,44 @@ shortcut_fails_too_big_rec:
 
 	clust_index = dict_table_get_first_index(index->table);
 
+	/* Do some start-of-statement preparations */
+
+	if (!prebuilt->sql_stat_start) {
+		/* No need to set an intention lock or assign a read view */
+
+		if (trx->read_view == NULL
+		    && prebuilt->select_lock_type == LOCK_NONE) {
+
+			fputs("InnoDB: Error: MySQL is trying to"
+			      " perform a consistent read\n"
+			      "InnoDB: but the read view is not assigned!\n",
+			      stderr);
+			trx_print(stderr, trx, 600);
+			fputc('\n', stderr);
+			ut_error;
+		}
+	} else if (prebuilt->select_lock_type == LOCK_NONE) {
+		/* This is a consistent read */
+		/* Assign a read view for the query */
+
+		trx_assign_read_view(trx);
+		prebuilt->sql_stat_start = FALSE;
+	} else {
+wait_table_again:
+		err = lock_table(0, index->table,
+				 prebuilt->select_lock_type == LOCK_S
+				 ? LOCK_IS : LOCK_IX, thr);
+
+		if (err != DB_SUCCESS) {
+
+			table_lock_waited = TRUE;
+			goto lock_table_wait;
+		}
+		prebuilt->sql_stat_start = FALSE;
+	}
+
+	/* Open or restore index cursor position */
+
 	if (UNIV_LIKELY(direction != 0)) {
 		ibool	need_to_process = sel_restore_position_for_mysql(
 			&same_user_rec, BTR_SEARCH_LEAF,
@@ -3674,42 +3713,6 @@ shortcut_fails_too_big_rec:
 		}
 	}
 
-	if (!prebuilt->sql_stat_start) {
-		/* No need to set an intention lock or assign a read view */
-
-		if (trx->read_view == NULL
-		    && prebuilt->select_lock_type == LOCK_NONE) {
-
-			fputs("InnoDB: Error: MySQL is trying to"
-			      " perform a consistent read\n"
-			      "InnoDB: but the read view is not assigned!\n",
-			      stderr);
-			trx_print(stderr, trx, 600);
-			fputc('\n', stderr);
-			ut_a(0);
-		}
-	} else if (prebuilt->select_lock_type == LOCK_NONE) {
-		/* This is a consistent read */
-		/* Assign a read view for the query */
-
-		trx_assign_read_view(trx);
-		prebuilt->sql_stat_start = FALSE;
-	} else {
-		ulint	lock_mode;
-		if (prebuilt->select_lock_type == LOCK_S) {
-			lock_mode = LOCK_IS;
-		} else {
-			lock_mode = LOCK_IX;
-		}
-		err = lock_table(0, index->table, lock_mode, thr);
-
-		if (err != DB_SUCCESS) {
-
-			goto lock_wait_or_error;
-		}
-		prebuilt->sql_stat_start = FALSE;
-	}
-
 rec_loop:
 	/*-------------------------------------------------------------*/
 	/* PHASE 4: Look for matching records in a loop */
@@ -4408,6 +4411,7 @@ lock_wait_or_error:
 
 	btr_pcur_store_position(pcur, &mtr);
 
+lock_table_wait:
 	mtr_commit(&mtr);
 	mtr_has_extra_clust_latch = FALSE;
 
@@ -4425,6 +4429,14 @@ lock_wait_or_error:
 		thr->lock_state = QUE_THR_LOCK_NOLOCK;
 		mtr_start(&mtr);
 
+		/* Table lock waited, go try to obtain table lock
+		again */
+		if (table_lock_waited) {
+			table_lock_waited = FALSE;
+
+			goto wait_table_again;
+		}
+
 		sel_restore_position_for_mysql(&same_user_rec,
 					       BTR_SEARCH_LEAF, pcur,
 					       moves_up, &mtr);

=== modified file 'storage/innobase/row/row0umod.c'
--- a/storage/innobase/row/row0umod.c	2006-09-19 07:22:21 +0000
+++ b/storage/innobase/row/row0umod.c	2010-09-14 11:09:36 +0000
@@ -89,12 +89,17 @@ row_undo_mod_clust_low(
 	btr_pcur_t*	pcur;
 	btr_cur_t*	btr_cur;
 	ulint		err;
+#ifdef UNIV_DEBUG
 	ibool		success;
+#endif /* UNIV_DEBUG */
 
 	pcur = &(node->pcur);
 	btr_cur = btr_pcur_get_btr_cur(pcur);
 
-	success = btr_pcur_restore_position(mode, pcur, mtr);
+#ifdef UNIV_DEBUG
+	success =
+#endif /* UNIV_DEBUG */
+	btr_pcur_restore_position(mode, pcur, mtr);
 
 	ut_ad(success);
 

=== modified file 'storage/innobase/row/row0upd.c'
--- a/storage/innobase/row/row0upd.c	2006-12-12 09:37:18 +0000
+++ b/storage/innobase/row/row0upd.c	2010-09-14 11:46:13 +0000
@@ -2037,7 +2037,9 @@ row_upd_in_place_in_select(
 	upd_node_t*	node;
 	btr_pcur_t*	pcur;
 	btr_cur_t*	btr_cur;
+#ifdef UNIV_DEBUG
 	ulint		err;
+#endif /* UNIV_DEBUG */
 	mem_heap_t*	heap		= NULL;
 	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
 	*offsets_ = (sizeof offsets_) / sizeof *offsets_;
@@ -2074,8 +2076,11 @@ row_upd_in_place_in_select(
 	ut_ad(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE);
 	ut_ad(node->select_will_do_update);
 
-	err = btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, btr_cur,
-				      node->update, node->cmpl_info,
-				      thr, mtr);
+#ifdef UNIV_DEBUG
+	err =
+#endif /* UNIV_DEBUG */
+	btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, btr_cur,
+				node->update, node->cmpl_info,
+				thr, mtr);
 	ut_ad(err == DB_SUCCESS);
 }

=== modified file 'storage/innobase/row/row0vers.c'
--- a/storage/innobase/row/row0vers.c	2007-01-18 21:27:31 +0000
+++ b/storage/innobase/row/row0vers.c	2010-09-14 11:50:13 +0000
@@ -59,7 +59,9 @@ row_vers_impl_x_locked_off_kernel(
 	trx_t*		trx;
 	ulint		vers_del;
 	ulint		rec_del;
+#ifdef UNIV_DEBUG
 	ulint		err;
+#endif /* UNIV_DEBUG */
 	mtr_t		mtr;
 	ulint		comp;
 
@@ -152,9 +154,12 @@ row_vers_impl_x_locked_off_kernel(
 
 		heap2 = heap;
 		heap = mem_heap_create(1024);
-		err = trx_undo_prev_version_build(clust_rec, &mtr, version,
-						  clust_index, clust_offsets,
-						  heap, &prev_version);
+#ifdef UNIV_DEBUG
+		err =
+#endif /* UNIV_DEBUG */
+		trx_undo_prev_version_build(clust_rec, &mtr, version,
+					    clust_index, clust_offsets,
+					    heap, &prev_version);
 		mem_heap_free(heap2); /* free version and clust_offsets */
 
 		if (prev_version) {

=== modified file 'storage/innobase/trx/trx0purge.c'
--- a/storage/innobase/trx/trx0purge.c	2009-06-24 18:26:34 +0000
+++ b/storage/innobase/trx/trx0purge.c	2010-09-14 12:19:04 +0000
@@ -249,9 +249,10 @@ trx_purge_add_update_undo_to_history(
 	trx_undo_t*	undo;
 	trx_rseg_t*	rseg;
 	trx_rsegf_t*	rseg_header;
+#ifdef UNIV_DEBUG
 	trx_usegf_t*	seg_header;
+#endif /* UNIV_DEBUG */
 	trx_ulogf_t*	undo_header;
-	trx_upagef_t*	page_header;
 	ulint		hist_size;
 
 	undo = trx->update_undo;
@@ -265,8 +266,9 @@ trx_purge_add_update_undo_to_history(
 	rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, mtr);
 
 	undo_header = undo_page + undo->hdr_offset;
+#ifdef UNIV_DEBUG
 	seg_header  = undo_page + TRX_UNDO_SEG_HDR;
-	page_header = undo_page + TRX_UNDO_PAGE_HDR;
+#endif /* UNIV_DEBUG */
 
 	if (undo->state != TRX_UNDO_CACHED) {
 		/* The undo log segment will not be reused */
@@ -594,7 +596,6 @@ trx_purge_rseg_get_next_history_log(
 {
 	page_t*		undo_page;
 	trx_ulogf_t*	log_hdr;
-	trx_usegf_t*	seg_hdr;
 	fil_addr_t	prev_log_addr;
 	dulint		trx_no;
 	ibool		del_marks;
@@ -615,7 +616,6 @@ trx_purge_rseg_get_next_history_log(
 	undo_page = trx_undo_page_get_s_latched(rseg->space,
 						rseg->last_page_no, &mtr);
 	log_hdr = undo_page + rseg->last_offset;
-	seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
 
 	/* Increase the purge page count by one for every handled log */
 
@@ -1004,12 +1004,8 @@ trx_purge_rec_release(
 /*==================*/
 	trx_undo_inf_t*	cell)	/* in: storage cell */
 {
-	trx_undo_arr_t*	arr;
-
 	mutex_enter(&(purge_sys->mutex));
 
-	arr = purge_sys->arr;
-
 	trx_purge_arr_remove_info(cell);
 
 	mutex_exit(&(purge_sys->mutex));

=== modified file 'storage/innobase/trx/trx0roll.c'
--- a/storage/innobase/trx/trx0roll.c	2009-01-13 12:15:24 +0000
+++ b/storage/innobase/trx/trx0roll.c	2010-09-14 12:21:32 +0000
@@ -713,13 +713,8 @@ trx_undo_arr_remove_info(
 	dulint		undo_no)/* in: undo number */
 {
 	trx_undo_inf_t*	cell;
-	ulint		n_used;
-	ulint		n;
 	ulint		i;
 
-	n_used = arr->n_used;
-	n = 0;
-
 	for (i = 0;; i++) {
 		cell = trx_undo_arr_get_nth_info(arr, i);
 

=== modified file 'storage/innobase/trx/trx0sys.c'
--- a/storage/innobase/trx/trx0sys.c	2010-03-03 21:56:10 +0000
+++ b/storage/innobase/trx/trx0sys.c	2010-09-14 12:28:48 +0000
@@ -165,7 +165,9 @@ trx_sys_create_doublewrite_buf(void)
 {
 	page_t*	page;
 	page_t*	page2;
+#ifdef UNIV_SYNC_DEBUG
 	page_t*	new_page;
+#endif /* UNIV_SYNC_DEBUG */
 	byte*	doublewrite;
 	byte*	fseg_header;
 	ulint	page_no;
@@ -271,8 +273,11 @@ start_again:
 			the page position in the tablespace, then the page
 			has not been written to in doublewrite. */
 
-			new_page = buf_page_get(TRX_SYS_SPACE, page_no,
-						RW_X_LATCH, &mtr);
+#ifdef UNIV_SYNC_DEBUG
+			new_page =
+#endif /* UNIV_SYNC_DEBUG */
+			buf_page_get(TRX_SYS_SPACE, page_no,
+				     RW_X_LATCH, &mtr);
 #ifdef UNIV_SYNC_DEBUG
 			buf_page_dbg_add_level(new_page, SYNC_NO_ORDER_CHECK);
 #endif /* UNIV_SYNC_DEBUG */

=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c	2010-05-14 13:02:28 +0000
+++ b/storage/innobase/trx/trx0trx.c	2010-09-14 12:30:26 +0000
@@ -1827,7 +1827,6 @@ trx_prepare_off_kernel(
 /*===================*/
 	trx_t*	trx)	/* in: transaction */
 {
-	page_t*		update_hdr_page;
 	trx_rseg_t*	rseg;
 	ibool		must_flush_log	= FALSE;
 	dulint		lsn;
@@ -1863,7 +1862,7 @@ trx_prepare_off_kernel(
 		}
 
 		if (trx->update_undo) {
-			update_hdr_page = trx_undo_set_state_at_prepare(
+			trx_undo_set_state_at_prepare(
 				trx, trx->update_undo, &mtr);
 		}
 

=== modified file 'storage/innobase/trx/trx0undo.c'
--- a/storage/innobase/trx/trx0undo.c	2009-06-24 18:26:34 +0000
+++ b/storage/innobase/trx/trx0undo.c	2010-09-14 14:55:44 +0000
@@ -1012,14 +1012,11 @@ trx_undo_truncate_end(
 	ulint		last_page_no;
 	trx_undo_rec_t* rec;
 	trx_undo_rec_t* trunc_here;
-	trx_rseg_t*	rseg;
 	mtr_t		mtr;
 
 	ut_ad(mutex_own(&(trx->undo_mutex)));
 	ut_ad(mutex_own(&(trx->rseg->mutex)));
 
-	rseg = trx->rseg;
-
 	for (;;) {
 		mtr_start(&mtr);
 
@@ -1798,7 +1795,6 @@ trx_undo_set_state_at_prepare(
 	mtr_t*		mtr)	/* in: mtr */
 {
 	trx_usegf_t*	seg_hdr;
-	trx_upagef_t*	page_hdr;
 	trx_ulogf_t*	undo_header;
 	page_t*		undo_page;
 	ulint		offset;
@@ -1815,7 +1811,6 @@ trx_undo_set_state_at_prepare(
 	undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr);
 
 	seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
-	page_hdr = undo_page + TRX_UNDO_PAGE_HDR;
 
 	/*------------------------------*/
 	undo->state = TRX_UNDO_PREPARED;

=== modified file 'storage/innodb_plugin/ChangeLog'
--- a/storage/innodb_plugin/ChangeLog	2010-09-02 00:43:02 +0000
+++ b/storage/innodb_plugin/ChangeLog	2010-10-11 20:13:47 +0000
@@ -1,3 +1,21 @@
+2010-10-11	The InnoDB Team
+	* row/row0sel.c
+	Fix Bug #57345 btr_pcur_store_position abort for load with
+	concurrent lock/unlock tables
+
+2010-10-06	The InnoDB Team
+	* row/row0mysql.c, innodb_bug57255.result, innodb_bug57255.test
+	Fix Bug #Cascade Delete results in "Got error -1 from storage engine"
+ 
+2010-09-27	The InnoDB Team
+
+	* row/row0sel.c, innodb_bug56716.result, innodb_bug56716.test:
+	Fix Bug #56716 InnoDB locks a record gap without locking the table
+
+2010-09-06	The InnoDB Team
+	* dict/dict0load.c, innodb_bug53756.test innodb_bug53756.result
+	Fix Bug #53756 	ALTER TABLE ADD PRIMARY KEY affects crash recovery
+
 2010-08-24	The InnoDB Team
 
 	* handler/ha_innodb.c, dict/dict0dict.c:
@@ -27,7 +45,6 @@
 	* handler/ha_innodb.cc
 	Fix Bug #55382 Assignment with SELECT expressions takes unexpected
 	S locks in READ COMMITTED
->>>>>>> MERGE-SOURCE
 
 2010-07-27	The InnoDB Team
 

=== modified file 'storage/innodb_plugin/btr/btr0btr.c'
--- a/storage/innodb_plugin/btr/btr0btr.c	2010-05-11 10:49:10 +0000
+++ b/storage/innodb_plugin/btr/btr0btr.c	2010-09-14 18:14:42 +0000
@@ -1895,7 +1895,6 @@ btr_page_split_and_insert(
 	buf_block_t*	left_block;
 	buf_block_t*	right_block;
 	buf_block_t*	insert_block;
-	page_t*		insert_page;
 	page_cur_t*	page_cursor;
 	rec_t*		first_rec;
 	byte*		buf = 0; /* remove warning */
@@ -2153,8 +2152,6 @@ insert_empty:
 		insert_block = right_block;
 	}
 
-	insert_page = buf_block_get_frame(insert_block);
-
 	/* 7. Reposition the cursor for insert and try insertion */
 	page_cursor = btr_cur_get_page_cur(cursor);
 
@@ -2166,8 +2163,12 @@ insert_empty:
 
 #ifdef UNIV_ZIP_DEBUG
 	{
+		page_t*		insert_page
+			= buf_block_get_frame(insert_block);
+
 		page_zip_des_t*	insert_page_zip
 			= buf_block_get_page_zip(insert_block);
+
 		ut_a(!insert_page_zip
 		     || page_zip_validate(insert_page_zip, insert_page));
 	}
@@ -2560,7 +2561,6 @@ btr_compress(
 	ulint		n_recs;
 	ulint		max_ins_size;
 	ulint		max_ins_size_reorg;
-	ulint		level;
 
 	block = btr_cur_get_block(cursor);
 	page = btr_cur_get_page(cursor);
@@ -2570,7 +2570,6 @@ btr_compress(
 	ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
 				MTR_MEMO_X_LOCK));
 	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
-	level = btr_page_get_level(page, mtr);
 	space = dict_index_get_space(index);
 	zip_size = dict_table_zip_size(index->table);
 

=== modified file 'storage/innodb_plugin/btr/btr0cur.c'
--- a/storage/innodb_plugin/btr/btr0cur.c	2010-08-05 09:18:17 +0000
+++ b/storage/innodb_plugin/btr/btr0cur.c	2010-10-05 08:11:56 +0000
@@ -1836,7 +1836,6 @@ btr_cur_optimistic_update(
 	page_t*		page;
 	page_zip_des_t*	page_zip;
 	rec_t*		rec;
-	rec_t*		orig_rec;
 	ulint		max_size;
 	ulint		new_rec_size;
 	ulint		old_rec_size;
@@ -1850,7 +1849,7 @@ btr_cur_optimistic_update(
 
 	block = btr_cur_get_block(cursor);
 	page = buf_block_get_frame(block);
-	orig_rec = rec = btr_cur_get_rec(cursor);
+	rec = btr_cur_get_rec(cursor);
 	index = cursor->index;
 	ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
 	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
@@ -4285,12 +4284,17 @@ btr_free_externally_stored_field(
 	}
 
 	for (;;) {
+#ifdef UNIV_SYNC_DEBUG
 		buf_block_t*	rec_block;
+#endif /* UNIV_SYNC_DEBUG */
 		buf_block_t*	ext_block;
 
 		mtr_start(&mtr);
 
-		rec_block = buf_page_get(page_get_space_id(
+#ifdef UNIV_SYNC_DEBUG
+		rec_block =
+#endif /* UNIV_SYNC_DEBUG */
+			buf_page_get(page_get_space_id(
 						 page_align(field_ref)),
 					 rec_zip_size,
 					 page_get_page_no(

=== modified file 'storage/innodb_plugin/btr/btr0pcur.c'
--- a/storage/innodb_plugin/btr/btr0pcur.c	2010-03-11 10:02:57 +0000
+++ b/storage/innodb_plugin/btr/btr0pcur.c	2010-09-14 18:35:37 +0000
@@ -452,7 +452,6 @@ btr_pcur_move_backward_from_page(
 	mtr_t*		mtr)	/*!< in: mtr */
 {
 	ulint		prev_page_no;
-	ulint		space;
 	page_t*		page;
 	buf_block_t*	prev_block;
 	ulint		latch_mode;
@@ -488,7 +487,6 @@ btr_pcur_move_backward_from_page(
 	page = btr_pcur_get_page(cursor);
 
 	prev_page_no = btr_page_get_prev(page, mtr);
-	space = buf_block_get_space(btr_pcur_get_block(cursor));
 
 	if (prev_page_no == FIL_NULL) {
 	} else if (btr_pcur_is_before_first_on_page(cursor)) {

=== modified file 'storage/innodb_plugin/btr/btr0sea.c'
--- a/storage/innodb_plugin/btr/btr0sea.c	2010-08-05 15:34:44 +0000
+++ b/storage/innodb_plugin/btr/btr0sea.c	2010-09-14 18:36:29 +0000
@@ -1495,7 +1495,6 @@ btr_search_update_hash_on_delete(
 	rec_t*		rec;
 	ulint		fold;
 	dulint		index_id;
-	ibool		found;
 	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
 	mem_heap_t*	heap		= NULL;
 	rec_offs_init(offsets_);
@@ -1528,7 +1527,7 @@ btr_search_update_hash_on_delete(
 	}
 	rw_lock_x_lock(&btr_search_latch);
 
-	found = ha_search_and_delete_if_found(table, fold, rec);
+	ha_search_and_delete_if_found(table, fold, rec);
 
 	rw_lock_x_unlock(&btr_search_latch);
 }

=== modified file 'storage/innodb_plugin/buf/buf0flu.c'
--- a/storage/innodb_plugin/buf/buf0flu.c	2010-05-04 12:47:44 +0000
+++ b/storage/innodb_plugin/buf/buf0flu.c	2010-09-15 08:30:57 +0000
@@ -128,10 +128,15 @@ buf_flush_delete_from_flush_rbt(
 	buf_page_t*	bpage)		/*!< in: bpage to be removed. */
 {
 
+#ifdef UNIV_DEBUG
 	ibool	ret = FALSE;
+#endif /* UNIV_DEBUG */
 
 	ut_ad(buf_pool_mutex_own());
-	ret = rbt_delete(buf_pool->flush_rbt, &bpage);
+#ifdef UNIV_DEBUG
+	ret =
+#endif /* UNIV_DEBUG */
+	rbt_delete(buf_pool->flush_rbt, &bpage);
 	ut_ad(ret);
 }
 
@@ -1266,7 +1271,6 @@ buf_flush_batch(
 {
 	buf_page_t*	bpage;
 	ulint		page_count	= 0;
-	ulint		old_page_count;
 	ulint		space;
 	ulint		offset;
 
@@ -1338,15 +1342,9 @@ flush_next:
 
 				buf_pool_mutex_exit();
 
-				old_page_count = page_count;
-
 				/* Try to flush also all the neighbors */
 				page_count += buf_flush_try_neighbors(
 					space, offset, flush_type);
-				/* fprintf(stderr,
-				"Flush type %lu, page no %lu, neighb %lu\n",
-				flush_type, offset,
-				page_count - old_page_count); */
 
 				buf_pool_mutex_enter();
 				goto flush_next;

=== modified file 'storage/innodb_plugin/dict/dict0crea.c'
--- a/storage/innodb_plugin/dict/dict0crea.c	2010-07-21 15:51:36 +0000
+++ b/storage/innodb_plugin/dict/dict0crea.c	2010-09-28 06:38:33 +0000
@@ -627,7 +627,6 @@ dict_create_index_tree_step(
 {
 	dict_index_t*	index;
 	dict_table_t*	sys_indexes;
-	dict_table_t*	table;
 	dtuple_t*	search_tuple;
 	ulint		zip_size;
 	btr_pcur_t	pcur;
@@ -636,7 +635,6 @@ dict_create_index_tree_step(
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
 	index = node->index;
-	table = node->table;
 
 	sys_indexes = dict_sys->sys_indexes;
 

=== modified file 'storage/innodb_plugin/dict/dict0dict.c'
--- a/storage/innodb_plugin/dict/dict0dict.c	2010-08-24 08:10:03 +0000
+++ b/storage/innodb_plugin/dict/dict0dict.c	2010-09-15 15:00:49 +0000
@@ -4441,7 +4441,6 @@ dict_index_print_low(
 {
 	ib_int64_t	n_vals;
 	ulint		i;
-	const char*	type_string;
 
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
@@ -4456,14 +4455,6 @@ dict_index_print_low(
 
 	dict_index_stat_mutex_exit(index);
 
-	if (dict_index_is_clust(index)) {
-		type_string = "clustered index";
-	} else if (dict_index_is_unique(index)) {
-		type_string = "unique index";
-	} else {
-		type_string = "secondary index";
-	}
-
 	fprintf(stderr,
 		"  INDEX: name %s, id %lu %lu, fields %lu/%lu,"
 		" uniq %lu, type %lu\n"

=== modified file 'storage/innodb_plugin/dict/dict0load.c'
--- a/storage/innodb_plugin/dict/dict0load.c	2010-08-04 10:11:33 +0000
+++ b/storage/innodb_plugin/dict/dict0load.c	2010-10-05 08:11:56 +0000
@@ -1083,6 +1083,8 @@ dict_load_table_on_id(
 
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
+	table = NULL;
+
 	/* NOTE that the operation of this function is protected by
 	the dictionary mutex, and therefore no deadlocks can occur
 	with other dictionary operations. */
@@ -1109,15 +1111,17 @@ dict_load_table_on_id(
 				  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)) {
+	if (!btr_pcur_is_on_user_rec(&pcur)) {
 		/* Not found */
+		goto func_exit;
+	}
 
-		btr_pcur_close(&pcur);
-		mtr_commit(&mtr);
-		mem_heap_free(heap);
-
-		return(NULL);
+	/* Find the first record that is not delete marked */
+	while (rec_get_deleted_flag(rec, 0)) {
+		if (!btr_pcur_move_to_next_user_rec(&pcur, &mtr)) {
+			goto func_exit;
+		}
+		rec = btr_pcur_get_rec(&pcur);
 	}
 
 	/*---------------------------------------------------*/
@@ -1130,19 +1134,14 @@ dict_load_table_on_id(
 
 	/* Check if the table id in record is the one searched for */
 	if (ut_dulint_cmp(table_id, mach_read_from_8(field)) != 0) {
-
-		btr_pcur_close(&pcur);
-		mtr_commit(&mtr);
-		mem_heap_free(heap);
-
-		return(NULL);
+		goto func_exit;
 	}
 
 	/* Now we get the table name from the record */
 	field = rec_get_nth_field_old(rec, 1, &len);
 	/* Load the table definition to memory */
 	table = dict_load_table(mem_heap_strdupl(heap, (char*) field, len));
-
+func_exit:
 	btr_pcur_close(&pcur);
 	mtr_commit(&mtr);
 	mem_heap_free(heap);

=== modified file 'storage/innodb_plugin/eval/eval0eval.c'
--- a/storage/innodb_plugin/eval/eval0eval.c	2009-05-26 12:28:49 +0000
+++ b/storage/innodb_plugin/eval/eval0eval.c	2010-09-15 15:03:24 +0000
@@ -384,18 +384,13 @@ eval_notfound(
 /*==========*/
 	func_node_t*	func_node)	/*!< in: function node */
 {
-	que_node_t*	arg1;
-	que_node_t*	arg2;
 	sym_node_t*	cursor;
 	sel_node_t*	sel_node;
 	ibool		ibool_val;
 
-	arg1 = func_node->args;
-	arg2 = que_node_get_next(arg1);
-
 	ut_ad(func_node->func == PARS_NOTFOUND_TOKEN);
 
-	cursor = arg1;
+	cursor = func_node->args;
 
 	ut_ad(que_node_get_type(cursor) == QUE_NODE_SYMBOL);
 

=== modified file 'storage/innodb_plugin/handler/ha_innodb.cc'
--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-09-02 00:43:02 +0000
+++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-10-05 08:11:56 +0000
@@ -7027,7 +7027,6 @@ innobase_drop_database(
 	ulint	len		= 0;
 	trx_t*	trx;
 	char*	ptr;
-	int	error;
 	char*	namebuf;
 	THD*	thd		= current_thd;
 
@@ -7070,7 +7069,7 @@ innobase_drop_database(
 #else
 	trx = innobase_trx_allocate(thd);
 #endif
-	error = row_drop_database_for_mysql(namebuf, trx);
+	row_drop_database_for_mysql(namebuf, trx);
 	my_free(namebuf, MYF(0));
 
 	/* Flush the log to reduce probability that the .frm files and
@@ -8868,12 +8867,9 @@ innodb_show_status(
 
 	mutex_exit(&srv_monitor_file_mutex);
 
-	bool result = FALSE;
+	stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name),
+		   STRING_WITH_LEN(""), str, flen);
 
-	if (stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name),
-			STRING_WITH_LEN(""), str, flen)) {
-		result= TRUE;
-	}
 	my_free(str, MYF(0));
 
 	DBUG_RETURN(FALSE);

=== modified file 'storage/innodb_plugin/handler/i_s.cc'
--- a/storage/innodb_plugin/handler/i_s.cc	2009-09-22 05:42:46 +0000
+++ b/storage/innodb_plugin/handler/i_s.cc	2010-09-28 08:12:34 +0000
@@ -1012,6 +1012,7 @@ trx_i_s_common_fill_table(
 	deadlock occurs between the mysqld server and mysql client,
 	see http://bugs.mysql.com/29900 ; when that bug is resolved
 	we can enable the DBUG_RETURN(ret) above */
+	ret++;  // silence a gcc46 warning
 	DBUG_RETURN(0);
 #endif
 }

=== modified file 'storage/innodb_plugin/include/os0sync.h'
--- a/storage/innodb_plugin/include/os0sync.h	2009-09-14 07:38:45 +0000
+++ b/storage/innodb_plugin/include/os0sync.h	2010-09-30 10:26:18 +0000
@@ -330,7 +330,7 @@ amount of increment. */
 Returns the old value of *ptr, atomically sets *ptr to new_val */
 
 # define os_atomic_test_and_set_byte(ptr, new_val) \
-	__sync_lock_test_and_set(ptr, new_val)
+	__sync_lock_test_and_set(ptr, (byte) new_val)
 
 #elif defined(HAVE_IB_SOLARIS_ATOMICS)
 

=== modified file 'storage/innodb_plugin/include/univ.i'
--- a/storage/innodb_plugin/include/univ.i	2010-08-26 15:06:07 +0000
+++ b/storage/innodb_plugin/include/univ.i	2010-09-28 12:31:33 +0000
@@ -46,7 +46,7 @@ Created 1/20/1994 Heikki Tuuri
 
 #define INNODB_VERSION_MAJOR	1
 #define INNODB_VERSION_MINOR	0
-#define INNODB_VERSION_BUGFIX	12
+#define INNODB_VERSION_BUGFIX	13
 
 /* The following is the InnoDB version as shown in
 SELECT plugin_version FROM information_schema.plugins;

=== modified file 'storage/innodb_plugin/include/ut0rnd.ic'
--- a/storage/innodb_plugin/include/ut0rnd.ic	2010-03-29 09:54:57 +0000
+++ b/storage/innodb_plugin/include/ut0rnd.ic	2010-09-14 17:58:02 +0000
@@ -85,9 +85,6 @@ ut_rnd_gen_ulint(void)
 /*==================*/
 {
 	ulint	rnd;
-	ulint	n_bits;
-
-	n_bits = 8 * sizeof(ulint);
 
 	ut_rnd_ulint_counter = UT_RND1 * ut_rnd_ulint_counter + UT_RND2;
 

=== modified file 'storage/innodb_plugin/log/log0recv.c'
--- a/storage/innodb_plugin/log/log0recv.c	2010-04-29 13:37:50 +0000
+++ b/storage/innodb_plugin/log/log0recv.c	2010-09-15 15:32:12 +0000
@@ -559,10 +559,8 @@ recv_synchronize_groups(
 	ib_uint64_t	start_lsn;
 	ib_uint64_t	end_lsn;
 	ib_uint64_t	recovered_lsn;
-	ib_uint64_t	limit_lsn;
 
 	recovered_lsn = recv_sys->recovered_lsn;
-	limit_lsn = recv_sys->limit_lsn;
 
 	/* Read the last recovered log block to the recovery system buffer:
 	the block is always incomplete */
@@ -2891,7 +2889,9 @@ recv_recovery_from_checkpoint_start_func
 	ib_uint64_t	old_scanned_lsn;
 	ib_uint64_t	group_scanned_lsn;
 	ib_uint64_t	contiguous_lsn;
+#ifdef UNIV_LOG_ARCHIVE
 	ib_uint64_t	archived_lsn;
+#endif /* UNIV_LOG_ARCHIVE */
 	byte*		buf;
 	byte		log_hdr_buf[LOG_FILE_HDR_SIZE];
 	ulint		err;
@@ -2946,7 +2946,9 @@ recv_recovery_from_checkpoint_start_func
 
 	checkpoint_lsn = mach_read_ull(buf + LOG_CHECKPOINT_LSN);
 	checkpoint_no = mach_read_ull(buf + LOG_CHECKPOINT_NO);
+#ifdef UNIV_LOG_ARCHIVE
 	archived_lsn = mach_read_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN);
+#endif /* UNIV_LOG_ARCHIVE */
 
 	/* Read the first log file header to print a note if this is
 	a recovery from a restored InnoDB Hot Backup */

=== modified file 'storage/innodb_plugin/os/os0file.c'
--- a/storage/innodb_plugin/os/os0file.c	2010-07-21 15:51:36 +0000
+++ b/storage/innodb_plugin/os/os0file.c	2010-09-28 06:38:33 +0000
@@ -1367,8 +1367,6 @@ try_again:
 	int		create_flag;
 	ibool		retry;
 	const char*	mode_str	= NULL;
-	const char*	type_str	= NULL;
-	const char*	purpose_str	= NULL;
 
 try_again:
 	ut_a(name);
@@ -1388,26 +1386,9 @@ try_again:
 		ut_error;
 	}
 
-	if (type == OS_LOG_FILE) {
-		type_str = "LOG";
-	} else if (type == OS_DATA_FILE) {
-		type_str = "DATA";
-	} else {
-		ut_error;
-	}
-
-	if (purpose == OS_FILE_AIO) {
-		purpose_str = "AIO";
-	} else if (purpose == OS_FILE_NORMAL) {
-		purpose_str = "NORMAL";
-	} else {
-		ut_error;
-	}
+	ut_a(type == OS_LOG_FILE || type == OS_DATA_FILE);
+	ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL);
 
-#if 0
-	fprintf(stderr, "Opening file %s, mode %s, type %s, purpose %s\n",
-		name, mode_str, type_str, purpose_str);
-#endif
 #ifdef O_SYNC
 	/* We let O_SYNC only affect log files; note that we map O_DSYNC to
 	O_SYNC because the datasync options seemed to corrupt files in 2001

=== modified file 'storage/innodb_plugin/que/que0que.c'
--- a/storage/innodb_plugin/que/que0que.c	2009-11-02 09:42:56 +0000
+++ b/storage/innodb_plugin/que/que0que.c	2010-09-15 15:35:59 +0000
@@ -1284,18 +1284,13 @@ que_run_threads_low(
 	que_thr_t*	thr)	/*!< in: query thread */
 {
 	que_thr_t*	next_thr;
-	ulint		cumul_resource;
 	ulint		loop_count;
 
 	ut_ad(thr->state == QUE_THR_RUNNING);
 	ut_a(thr_get_trx(thr)->error_state == DB_SUCCESS);
 	ut_ad(!mutex_own(&kernel_mutex));
 
-	/* cumul_resource counts how much resources the OS thread (NOT the
-	query thread) has spent in this function */
-
 	loop_count = QUE_MAX_LOOPS_WITHOUT_CHECK;
-	cumul_resource = 0;
 loop:
 	/* Check that there is enough space in the log to accommodate
 	possible log entries by this query step; if the operation can touch

=== modified file 'storage/innodb_plugin/row/row0mysql.c'
--- a/storage/innodb_plugin/row/row0mysql.c	2010-08-04 10:37:44 +0000
+++ b/storage/innodb_plugin/row/row0mysql.c	2010-10-06 10:41:26 +0000
@@ -1433,7 +1433,12 @@ run_again:
 		srv_n_rows_updated++;
 	}
 
-	row_update_statistics_if_needed(prebuilt->table);
+	/* We update table statistics only if it is a DELETE or UPDATE
+	that changes indexed columns, UPDATEs that change only non-indexed
+	columns would not affect statistics. */
+	if (node->is_delete || !(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
+		row_update_statistics_if_needed(prebuilt->table);
+	}
 
 	trx->op_info = "";
 
@@ -1588,6 +1593,9 @@ row_update_cascade_for_mysql(
 
 	trx = thr_get_trx(thr);
 
+	/* Increment fk_cascade_depth to record the recursive call depth on
+	a single update/delete that affects multiple tables chained
+	together with foreign key relations. */
 	thr->fk_cascade_depth++;
 
 	if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) {
@@ -1599,6 +1607,12 @@ run_again:
 
 	row_upd_step(thr);
 
+	/* The recursive call for cascading update/delete happens
+	in above row_upd_step(), reset the counter once we come
+	out of the recursive call, so it does not accumulate for
+	different row deletes */
+	thr->fk_cascade_depth = 0;
+
 	err = trx->error_state;
 
 	/* Note that the cascade node is a subnode of another InnoDB

=== modified file 'storage/innodb_plugin/row/row0purge.c'
--- a/storage/innodb_plugin/row/row0purge.c	2010-06-10 13:58:11 +0000
+++ b/storage/innodb_plugin/row/row0purge.c	2010-09-15 15:37:24 +0000
@@ -684,7 +684,9 @@ row_purge_step(
 	que_thr_t*	thr)	/*!< in: query thread */
 {
 	purge_node_t*	node;
+#ifdef UNIV_DEBUG
 	ulint		err;
+#endif /* UNIV_DEBUG */
 
 	ut_ad(thr);
 
@@ -692,7 +694,10 @@ row_purge_step(
 
 	ut_ad(que_node_get_type(node) == QUE_NODE_PURGE);
 
-	err = row_purge(node, thr);
+#ifdef UNIV_DEBUG
+	err =
+#endif /* UNIV_DEBUG */
+	row_purge(node, thr);
 
 	ut_ad(err == DB_SUCCESS);
 

=== modified file 'storage/innodb_plugin/row/row0sel.c'
--- a/storage/innodb_plugin/row/row0sel.c	2010-08-18 11:01:10 +0000
+++ b/storage/innodb_plugin/row/row0sel.c	2010-10-11 20:13:47 +0000
@@ -3356,6 +3356,7 @@ row_search_for_mysql(
 	mem_heap_t*	heap				= NULL;
 	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
 	ulint*		offsets				= offsets_;
+	ibool		table_lock_waited		= FALSE;
 
 	rec_offs_init(offsets_);
 
@@ -3719,6 +3720,44 @@ release_search_latch_if_needed:
 
 	clust_index = dict_table_get_first_index(index->table);
 
+	/* Do some start-of-statement preparations */
+
+	if (!prebuilt->sql_stat_start) {
+		/* No need to set an intention lock or assign a read view */
+
+		if (trx->read_view == NULL
+		    && prebuilt->select_lock_type == LOCK_NONE) {
+
+			fputs("InnoDB: Error: MySQL is trying to"
+			      " perform a consistent read\n"
+			      "InnoDB: but the read view is not assigned!\n",
+			      stderr);
+			trx_print(stderr, trx, 600);
+			fputc('\n', stderr);
+			ut_error;
+		}
+	} else if (prebuilt->select_lock_type == LOCK_NONE) {
+		/* This is a consistent read */
+		/* Assign a read view for the query */
+
+		trx_assign_read_view(trx);
+		prebuilt->sql_stat_start = FALSE;
+	} else {
+wait_table_again:
+		err = lock_table(0, index->table,
+				 prebuilt->select_lock_type == LOCK_S
+				 ? LOCK_IS : LOCK_IX, thr);
+
+		if (err != DB_SUCCESS) {
+
+			table_lock_waited = TRUE;
+			goto lock_table_wait;
+		}
+		prebuilt->sql_stat_start = FALSE;
+	}
+
+	/* Open or restore index cursor position */
+
 	if (UNIV_LIKELY(direction != 0)) {
 		ibool	need_to_process = sel_restore_position_for_mysql(
 			&same_user_rec, BTR_SEARCH_LEAF,
@@ -3794,42 +3833,6 @@ release_search_latch_if_needed:
 		}
 	}
 
-	if (!prebuilt->sql_stat_start) {
-		/* No need to set an intention lock or assign a read view */
-
-		if (trx->read_view == NULL
-		    && prebuilt->select_lock_type == LOCK_NONE) {
-
-			fputs("InnoDB: Error: MySQL is trying to"
-			      " perform a consistent read\n"
-			      "InnoDB: but the read view is not assigned!\n",
-			      stderr);
-			trx_print(stderr, trx, 600);
-			fputc('\n', stderr);
-			ut_a(0);
-		}
-	} else if (prebuilt->select_lock_type == LOCK_NONE) {
-		/* This is a consistent read */
-		/* Assign a read view for the query */
-
-		trx_assign_read_view(trx);
-		prebuilt->sql_stat_start = FALSE;
-	} else {
-		ulint	lock_mode;
-		if (prebuilt->select_lock_type == LOCK_S) {
-			lock_mode = LOCK_IS;
-		} else {
-			lock_mode = LOCK_IX;
-		}
-		err = lock_table(0, index->table, lock_mode, thr);
-
-		if (err != DB_SUCCESS) {
-
-			goto lock_wait_or_error;
-		}
-		prebuilt->sql_stat_start = FALSE;
-	}
-
 rec_loop:
 	/*-------------------------------------------------------------*/
 	/* PHASE 4: Look for matching records in a loop */
@@ -4559,6 +4562,7 @@ lock_wait_or_error:
 
 	btr_pcur_store_position(pcur, &mtr);
 
+lock_table_wait:
 	mtr_commit(&mtr);
 	mtr_has_extra_clust_latch = FALSE;
 
@@ -4576,6 +4580,14 @@ lock_wait_or_error:
 		thr->lock_state = QUE_THR_LOCK_NOLOCK;
 		mtr_start(&mtr);
 
+		/* Table lock waited, go try to obtain table lock
+		again */
+		if (table_lock_waited) {
+			table_lock_waited = FALSE;
+
+			goto wait_table_again;
+		}
+
 		sel_restore_position_for_mysql(&same_user_rec,
 					       BTR_SEARCH_LEAF, pcur,
 					       moves_up, &mtr);

=== modified file 'storage/innodb_plugin/row/row0umod.c'
--- a/storage/innodb_plugin/row/row0umod.c	2010-06-10 13:58:11 +0000
+++ b/storage/innodb_plugin/row/row0umod.c	2010-09-15 15:41:35 +0000
@@ -114,12 +114,17 @@ row_undo_mod_clust_low(
 	btr_pcur_t*	pcur;
 	btr_cur_t*	btr_cur;
 	ulint		err;
+#ifdef UNIV_DEBUG
 	ibool		success;
+#endif /* UNIV_DEBUG */
 
 	pcur = &(node->pcur);
 	btr_cur = btr_pcur_get_btr_cur(pcur);
 
-	success = btr_pcur_restore_position(mode, pcur, mtr);
+#ifdef UNIV_DEBUG
+	success =
+#endif /* UNIV_DEBUG */
+	btr_pcur_restore_position(mode, pcur, mtr);
 
 	ut_ad(success);
 

=== modified file 'storage/innodb_plugin/row/row0vers.c'
--- a/storage/innodb_plugin/row/row0vers.c	2009-05-25 09:52:29 +0000
+++ b/storage/innodb_plugin/row/row0vers.c	2010-09-15 15:43:07 +0000
@@ -71,7 +71,9 @@ row_vers_impl_x_locked_off_kernel(
 					warning */
 	trx_t*		trx;
 	ulint		rec_del;
+#ifdef UNIV_DEBUG
 	ulint		err;
+#endif /* UNIV_DEBUG */
 	mtr_t		mtr;
 	ulint		comp;
 
@@ -169,9 +171,12 @@ row_vers_impl_x_locked_off_kernel(
 
 		heap2 = heap;
 		heap = mem_heap_create(1024);
-		err = trx_undo_prev_version_build(clust_rec, &mtr, version,
-						  clust_index, clust_offsets,
-						  heap, &prev_version);
+#ifdef UNIV_DEBUG
+		err =
+#endif /* UNIV_DEBUG */
+		trx_undo_prev_version_build(clust_rec, &mtr, version,
+					    clust_index, clust_offsets,
+					    heap, &prev_version);
 		mem_heap_free(heap2); /* free version and clust_offsets */
 
 		if (prev_version == NULL) {

=== modified file 'storage/innodb_plugin/trx/trx0purge.c'
--- a/storage/innodb_plugin/trx/trx0purge.c	2009-11-02 09:42:56 +0000
+++ b/storage/innodb_plugin/trx/trx0purge.c	2010-09-15 16:05:35 +0000
@@ -304,9 +304,10 @@ trx_purge_add_update_undo_to_history(
 	trx_undo_t*	undo;
 	trx_rseg_t*	rseg;
 	trx_rsegf_t*	rseg_header;
+#ifdef UNIV_DEBUG
 	trx_usegf_t*	seg_header;
+#endif /* UNIV_DEBUG */
 	trx_ulogf_t*	undo_header;
-	trx_upagef_t*	page_header;
 	ulint		hist_size;
 
 	undo = trx->update_undo;
@@ -321,8 +322,9 @@ trx_purge_add_update_undo_to_history(
 				    rseg->page_no, mtr);
 
 	undo_header = undo_page + undo->hdr_offset;
+#ifdef UNIV_DEBUG
 	seg_header  = undo_page + TRX_UNDO_SEG_HDR;
-	page_header = undo_page + TRX_UNDO_PAGE_HDR;
+#endif /* UNIV_DEBUG */
 
 	if (undo->state != TRX_UNDO_CACHED) {
 		/* The undo log segment will not be reused */
@@ -655,7 +657,6 @@ trx_purge_rseg_get_next_history_log(
 {
 	page_t*		undo_page;
 	trx_ulogf_t*	log_hdr;
-	trx_usegf_t*	seg_hdr;
 	fil_addr_t	prev_log_addr;
 	trx_id_t	trx_no;
 	ibool		del_marks;
@@ -676,7 +677,6 @@ trx_purge_rseg_get_next_history_log(
 	undo_page = trx_undo_page_get_s_latched(rseg->space, rseg->zip_size,
 						rseg->last_page_no, &mtr);
 	log_hdr = undo_page + rseg->last_offset;
-	seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
 
 	/* Increase the purge page count by one for every handled log */
 
@@ -1068,12 +1068,8 @@ trx_purge_rec_release(
 /*==================*/
 	trx_undo_inf_t*	cell)	/*!< in: storage cell */
 {
-	trx_undo_arr_t*	arr;
-
 	mutex_enter(&(purge_sys->mutex));
 
-	arr = purge_sys->arr;
-
 	trx_purge_arr_remove_info(cell);
 
 	mutex_exit(&(purge_sys->mutex));

=== modified file 'storage/innodb_plugin/trx/trx0roll.c'
--- a/storage/innodb_plugin/trx/trx0roll.c	2009-09-10 10:29:46 +0000
+++ b/storage/innodb_plugin/trx/trx0roll.c	2010-09-15 16:06:31 +0000
@@ -740,13 +740,8 @@ trx_undo_arr_remove_info(
 	undo_no_t	undo_no)/*!< in: undo number */
 {
 	trx_undo_inf_t*	cell;
-	ulint		n_used;
-	ulint		n;
 	ulint		i;
 
-	n_used = arr->n_used;
-	n = 0;
-
 	for (i = 0;; i++) {
 		cell = trx_undo_arr_get_nth_info(arr, i);
 

=== modified file 'storage/innodb_plugin/trx/trx0sys.c'
--- a/storage/innodb_plugin/trx/trx0sys.c	2010-03-26 14:19:01 +0000
+++ b/storage/innodb_plugin/trx/trx0sys.c	2010-09-15 16:58:36 +0000
@@ -241,7 +241,9 @@ trx_sys_create_doublewrite_buf(void)
 {
 	buf_block_t*	block;
 	buf_block_t*	block2;
+#ifdef UNIV_SYNC_DEBUG
 	buf_block_t*	new_block;
+#endif /* UNIV_SYNC_DEBUG */
 	byte*	doublewrite;
 	byte*	fseg_header;
 	ulint	page_no;
@@ -344,8 +346,11 @@ start_again:
 			the page position in the tablespace, then the page
 			has not been written to in doublewrite. */
 
-			new_block = buf_page_get(TRX_SYS_SPACE, 0, page_no,
-						 RW_X_LATCH, &mtr);
+#ifdef UNIV_SYNC_DEBUG
+			new_block =
+#endif /* UNIV_SYNC_DEBUG */
+			buf_page_get(TRX_SYS_SPACE, 0, page_no,
+				     RW_X_LATCH, &mtr);
 			buf_block_dbg_add_level(new_block,
 						SYNC_NO_ORDER_CHECK);
 

=== modified file 'storage/innodb_plugin/trx/trx0trx.c'
--- a/storage/innodb_plugin/trx/trx0trx.c	2010-05-14 13:08:15 +0000
+++ b/storage/innodb_plugin/trx/trx0trx.c	2010-09-15 16:48:37 +0000
@@ -1805,7 +1805,6 @@ trx_prepare_off_kernel(
 /*===================*/
 	trx_t*	trx)	/*!< in: transaction */
 {
-	page_t*		update_hdr_page;
 	trx_rseg_t*	rseg;
 	ib_uint64_t	lsn		= 0;
 	mtr_t		mtr;
@@ -1838,7 +1837,7 @@ trx_prepare_off_kernel(
 		}
 
 		if (trx->update_undo) {
-			update_hdr_page = trx_undo_set_state_at_prepare(
+			trx_undo_set_state_at_prepare(
 				trx, trx->update_undo, &mtr);
 		}
 

=== modified file 'storage/innodb_plugin/trx/trx0undo.c'
--- a/storage/innodb_plugin/trx/trx0undo.c	2010-08-20 02:55:52 +0000
+++ b/storage/innodb_plugin/trx/trx0undo.c	2010-09-15 16:50:05 +0000
@@ -1066,14 +1066,11 @@ trx_undo_truncate_end(
 	ulint		last_page_no;
 	trx_undo_rec_t* rec;
 	trx_undo_rec_t* trunc_here;
-	trx_rseg_t*	rseg;
 	mtr_t		mtr;
 
 	ut_ad(mutex_own(&(trx->undo_mutex)));
 	ut_ad(mutex_own(&(trx->rseg->mutex)));
 
-	rseg = trx->rseg;
-
 	for (;;) {
 		mtr_start(&mtr);
 
@@ -1868,7 +1865,6 @@ trx_undo_set_state_at_prepare(
 	mtr_t*		mtr)	/*!< in: mtr */
 {
 	trx_usegf_t*	seg_hdr;
-	trx_upagef_t*	page_hdr;
 	trx_ulogf_t*	undo_header;
 	page_t*		undo_page;
 	ulint		offset;
@@ -1886,7 +1882,6 @@ trx_undo_set_state_at_prepare(
 				      undo->hdr_page_no, mtr);
 
 	seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
-	page_hdr = undo_page + TRX_UNDO_PAGE_HDR;
 
 	/*------------------------------*/
 	undo->state = TRX_UNDO_PREPARED;

=== modified file 'storage/myisam/mi_range.c'
--- a/storage/myisam/mi_range.c	2007-10-11 15:07:40 +0000
+++ b/storage/myisam/mi_range.c	2010-09-24 22:13:51 +0000
@@ -193,12 +193,11 @@ static double _mi_search_pos(register MI
 			     register my_off_t pos)
 {
   int flag;
-  uint nod_flag,keynr,max_keynr;
+  uint nod_flag,keynr,UNINIT_VAR(max_keynr);
   my_bool after_key;
   uchar *keypos,*buff;
   double offset;
   DBUG_ENTER("_mi_search_pos");
-  LINT_INIT(max_keynr);
 
   if (pos == HA_OFFSET_ERROR)
     DBUG_RETURN(0.5);

=== modified file 'storage/myisam/mi_search.c'
--- a/storage/myisam/mi_search.c	2010-07-02 18:30:47 +0000
+++ b/storage/myisam/mi_search.c	2010-09-24 22:13:51 +0000
@@ -296,9 +296,9 @@ int _mi_prefix_search(MI_INFO *info, reg
     flag is the value returned by ha_key_cmp and as treated as final
   */
   int flag=0, my_flag=-1;
-  uint nod_flag, length, len, matched, cmplen, kseg_len;
-  uint prefix_len,suffix_len;
-  int key_len_skip, seg_len_pack, key_len_left;
+  uint nod_flag, UNINIT_VAR(length), len, matched, cmplen, kseg_len;
+  uint UNINIT_VAR(prefix_len), suffix_len;
+  int key_len_skip, UNINIT_VAR(seg_len_pack), key_len_left;
   uchar *end, *kseg, *vseg;
   uchar *sort_order=keyinfo->seg->charset->sort_order;
   uchar tt_buff[MI_MAX_KEY_BUFF+2], *t_buff=tt_buff+2;
@@ -308,10 +308,6 @@ int _mi_prefix_search(MI_INFO *info, reg
   uint  length_pack;
   DBUG_ENTER("_mi_prefix_search");
 
-  LINT_INIT(length);
-  LINT_INIT(prefix_len);
-  LINT_INIT(seg_len_pack);
-
   t_buff[0]=0;                                  /* Avoid bugs */
   end= page+mi_getint(page);
   nod_flag=mi_test_if_nod(page);

=== modified file 'storage/myisam/rt_index.c'
--- a/storage/myisam/rt_index.c	2010-03-25 11:18:14 +0000
+++ b/storage/myisam/rt_index.c	2010-09-24 22:13:51 +0000
@@ -481,17 +481,13 @@ static uchar *rtree_pick_key(MI_INFO *in
 			     uint key_length, uchar *page_buf, uint nod_flag)
 {
   double increase;
-  double best_incr;
+  double UNINIT_VAR(best_incr);
   double area;
-  double best_area;
+  double UNINIT_VAR(best_area);
   uchar *best_key= NULL;
   uchar *k = rt_PAGE_FIRST_KEY(page_buf, nod_flag);
   uchar *last = rt_PAGE_END(page_buf);
 
-  LINT_INIT(best_area);
-  LINT_INIT(best_key);
-  LINT_INIT(best_incr);
-
   for (; k < last; k = rt_PAGE_NEXT_KEY(k, key_length, nod_flag))
   {
     /* The following is safe as -1.0 is an exact number */

=== modified file 'storage/myisam/rt_split.c'
--- a/storage/myisam/rt_split.c	2010-07-20 18:07:36 +0000
+++ b/storage/myisam/rt_split.c	2010-09-24 22:13:51 +0000
@@ -178,18 +178,13 @@ static int split_rtree_node(SplitStruct
                    double **d_buffer, int n_dim)
 {
   SplitStruct *cur;
-  SplitStruct *a;
-  SplitStruct *b;
+  SplitStruct *UNINIT_VAR(a), *UNINIT_VAR(b);
   double *g1 = reserve_coords(d_buffer, n_dim);
   double *g2 = reserve_coords(d_buffer, n_dim);
-  SplitStruct *next;
-  int next_node;
+  SplitStruct *UNINIT_VAR(next);
+  int UNINIT_VAR(next_node);
   int i;
   SplitStruct *end = node + n_entries;
-  LINT_INIT(a);
-  LINT_INIT(b);
-  LINT_INIT(next);
-  LINT_INIT(next_node);
 
   if (all_size < min_size * 2)
   {

=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c	2010-10-07 19:44:09 +0000
+++ b/tests/mysql_client_test.c	2010-11-01 18:44:43 +0000
@@ -18297,6 +18297,107 @@ static void test_bug54041()
 }
 
 
+/**
+  Bug#47485: mysql_store_result returns a result set for a prepared statement
+*/
+static void test_bug47485()
+{
+  MYSQL_STMT   *stmt;
+  MYSQL_RES    *res;
+  MYSQL_BIND    bind[2];
+  int           rc;
+  const char*   sql_select = "SELECT 1, 'a'";
+  int           int_data;
+  char          str_data[16];
+  my_bool       is_null[2];
+  my_bool       error[2];
+  unsigned long length[2];
+
+  DBUG_ENTER("test_bug47485");
+  myheader("test_bug47485");
+
+  stmt= mysql_stmt_init(mysql);
+  check_stmt(stmt);
+  rc= mysql_stmt_prepare(stmt, sql_select, strlen(sql_select));
+  check_execute(stmt, rc);
+
+  rc= mysql_stmt_execute(stmt);
+  check_execute(stmt, rc);
+
+  res = mysql_store_result(mysql);
+  DIE_UNLESS(res == NULL);
+
+  mysql_stmt_reset(stmt);
+
+  rc= mysql_stmt_execute(stmt);
+  check_execute(stmt, rc);
+
+  res = mysql_use_result(mysql);
+  DIE_UNLESS(res == NULL);
+
+  mysql_stmt_reset(stmt);
+
+  memset(bind, 0, sizeof(bind));
+  bind[0].buffer_type= MYSQL_TYPE_LONG;
+  bind[0].buffer= (char *)&int_data;
+  bind[0].is_null= &is_null[0];
+  bind[0].length= &length[0];
+  bind[0].error= &error[0];
+
+  bind[1].buffer_type= MYSQL_TYPE_STRING;
+  bind[1].buffer= (char *)str_data;
+  bind[1].buffer_length= sizeof(str_data);
+  bind[1].is_null= &is_null[1];
+  bind[1].length= &length[1];
+  bind[1].error= &error[1];
+
+  rc= mysql_stmt_bind_result(stmt, bind);
+  check_execute(stmt, rc);
+
+  rc= mysql_stmt_execute(stmt);
+  check_execute(stmt, rc);
+
+  rc= mysql_stmt_store_result(stmt);
+  check_execute(stmt, rc);
+
+  while (!(rc= mysql_stmt_fetch(stmt)))
+    ;
+
+  DIE_UNLESS(rc == MYSQL_NO_DATA);
+
+  mysql_stmt_reset(stmt);
+
+  memset(bind, 0, sizeof(bind));
+  bind[0].buffer_type= MYSQL_TYPE_LONG;
+  bind[0].buffer= (char *)&int_data;
+  bind[0].is_null= &is_null[0];
+  bind[0].length= &length[0];
+  bind[0].error= &error[0];
+
+  bind[1].buffer_type= MYSQL_TYPE_STRING;
+  bind[1].buffer= (char *)str_data;
+  bind[1].buffer_length= sizeof(str_data);
+  bind[1].is_null= &is_null[1];
+  bind[1].length= &length[1];
+  bind[1].error= &error[1];
+
+  rc= mysql_stmt_bind_result(stmt, bind);
+  check_execute(stmt, rc);
+
+  rc= mysql_stmt_execute(stmt);
+  check_execute(stmt, rc);
+
+  while (!(rc= mysql_stmt_fetch(stmt)))
+    ;
+
+  DIE_UNLESS(rc == MYSQL_NO_DATA);
+
+  mysql_stmt_close(stmt);
+
+  DBUG_VOID_RETURN;
+}
+
+
 /*
   Read and parse arguments and MySQL options from my.cnf
 */
@@ -18622,6 +18723,7 @@ static struct my_tests_st my_tests[]= {
   { "test_bug44495", test_bug44495 },
   { "test_bug42373", test_bug42373 },
   { "test_bug54041", test_bug54041 },
+  { "test_bug47485", test_bug47485 },
   { 0, 0 }
 };
 


Attachment: [text/bzr-bundle] bzr/build@mysql.com-20101101184443-o2olipi8vkaxzsqk.bundle
Thread
bzr push into mysql-5.1 branch (build:3472 to 3473) MySQL Build Team1 Nov