← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2712)

 

#At lp:maria

 2712 knielsen@xxxxxxxxxxxxxxx	2009-06-11 [merge]
      Merge of Percona XtraDB into MariaDB.
      removed:
        mysql-test/include/ctype_innodb_like.inc
        mysql-test/include/have_innodb.inc
        mysql-test/include/innodb_trx_weight.inc
        mysql-test/r/innodb-autoinc.result
        mysql-test/r/innodb-lock.result
        mysql-test/r/innodb-replace.result
        mysql-test/r/innodb-semi-consistent.result
        mysql-test/r/innodb.result
        mysql-test/r/innodb_bug34053.result
        mysql-test/r/innodb_bug34300.result
        mysql-test/r/innodb_bug35220.result
        mysql-test/r/innodb_trx_weight.result
        mysql-test/t/innodb-autoinc.test
        mysql-test/t/innodb-lock.test
        mysql-test/t/innodb-master.opt
        mysql-test/t/innodb-replace.test
        mysql-test/t/innodb-semi-consistent-master.opt
        mysql-test/t/innodb-semi-consistent.test
        mysql-test/t/innodb.test
        mysql-test/t/innodb_bug34053.test
        mysql-test/t/innodb_bug34300.test
        mysql-test/t/innodb_bug35220.test
        mysql-test/t/innodb_trx_weight.test
      added:
        BUILD/compile-innodb
        BUILD/compile-innodb-debug
        mysql-test/include/ctype_innodb_like.inc
        mysql-test/include/have_innodb.inc
        mysql-test/include/innodb-index.inc
        mysql-test/include/innodb_trx_weight.inc
        mysql-test/r/innodb-analyze.result
        mysql-test/r/innodb-autoinc.result
        mysql-test/r/innodb-index.result
        mysql-test/r/innodb-index_ucs2.result
        mysql-test/r/innodb-lock.result
        mysql-test/r/innodb-replace.result
        mysql-test/r/innodb-semi-consistent.result
        mysql-test/r/innodb-timeout.result
        mysql-test/r/innodb-use-sys-malloc.result
        mysql-test/r/innodb-zip.result
        mysql-test/r/innodb.result
        mysql-test/r/innodb_bug34053.result
        mysql-test/r/innodb_bug34300.result
        mysql-test/r/innodb_bug35220.result
        mysql-test/r/innodb_bug36169.result
        mysql-test/r/innodb_bug36172.result
        mysql-test/r/innodb_bug40360.result
        mysql-test/r/innodb_bug41904.result
        mysql-test/r/innodb_information_schema.result
        mysql-test/r/innodb_trx_weight.result
        mysql-test/r/innodb_xtradb_bug317074.result
        mysql-test/t/innodb-analyze.test
        mysql-test/t/innodb-autoinc.test
        mysql-test/t/innodb-index.test
        mysql-test/t/innodb-index_ucs2.test
        mysql-test/t/innodb-lock.test
        mysql-test/t/innodb-master.opt
        mysql-test/t/innodb-replace.test
        mysql-test/t/innodb-semi-consistent-master.opt
        mysql-test/t/innodb-semi-consistent.test
        mysql-test/t/innodb-timeout.test
        mysql-test/t/innodb-use-sys-malloc-master.opt
        mysql-test/t/innodb-use-sys-malloc.test
        mysql-test/t/innodb-zip.test
        mysql-test/t/innodb.test
        mysql-test/t/innodb_bug34053.test
        mysql-test/t/innodb_bug34300.test
        mysql-test/t/innodb_bug35220.test
        mysql-test/t/innodb_bug36169.test
        mysql-test/t/innodb_bug36172.test
        mysql-test/t/innodb_bug40360.test
        mysql-test/t/innodb_bug41904.test
        mysql-test/t/innodb_information_schema.test
        mysql-test/t/innodb_trx_weight.test
        mysql-test/t/innodb_xtradb_bug317074.test
        storage/xtradb/
        storage/xtradb/CMakeLists.txt
        storage/xtradb/COPYING.Google
        storage/xtradb/ChangeLog
        storage/xtradb/Makefile.am
        storage/xtradb/btr/
        storage/xtradb/btr/btr0btr.c
        storage/xtradb/btr/btr0cur.c
        storage/xtradb/btr/btr0pcur.c
        storage/xtradb/btr/btr0sea.c
        storage/xtradb/buf/
        storage/xtradb/buf/buf0buddy.c
        storage/xtradb/buf/buf0buf.c
        storage/xtradb/buf/buf0flu.c
        storage/xtradb/buf/buf0lru.c
        storage/xtradb/buf/buf0rea.c
        storage/xtradb/data/
        storage/xtradb/data/data0data.c
        storage/xtradb/data/data0type.c
        storage/xtradb/dict/
        storage/xtradb/dict/dict0boot.c
        storage/xtradb/dict/dict0crea.c
        storage/xtradb/dict/dict0dict.c
        storage/xtradb/dict/dict0load.c
        storage/xtradb/dict/dict0mem.c
        storage/xtradb/dyn/
        storage/xtradb/dyn/dyn0dyn.c
        storage/xtradb/eval/
        storage/xtradb/eval/eval0eval.c
        storage/xtradb/eval/eval0proc.c
        storage/xtradb/fil/
        storage/xtradb/fil/fil0fil.c
        storage/xtradb/fsp/
        storage/xtradb/fsp/fsp0fsp.c
        storage/xtradb/fut/
        storage/xtradb/fut/fut0fut.c
        storage/xtradb/fut/fut0lst.c
        storage/xtradb/ha/
        storage/xtradb/ha/ha0ha.c
        storage/xtradb/ha/ha0storage.c
        storage/xtradb/ha/hash0hash.c
        storage/xtradb/ha_innodb.def
        storage/xtradb/handler/
        storage/xtradb/handler/ha_innodb.cc
        storage/xtradb/handler/ha_innodb.h
        storage/xtradb/handler/handler0alter.cc
        storage/xtradb/handler/handler0vars.h
        storage/xtradb/handler/i_s.cc
        storage/xtradb/handler/i_s.h
        storage/xtradb/handler/innodb_patch_info.h
        storage/xtradb/handler/mysql_addons.cc
        storage/xtradb/handler/win_delay_loader.cc
        storage/xtradb/ibuf/
        storage/xtradb/ibuf/ibuf0ibuf.c
        storage/xtradb/include/
        storage/xtradb/include/btr0btr.h
        storage/xtradb/include/btr0btr.ic
        storage/xtradb/include/btr0cur.h
        storage/xtradb/include/btr0cur.ic
        storage/xtradb/include/btr0pcur.h
        storage/xtradb/include/btr0pcur.ic
        storage/xtradb/include/btr0sea.h
        storage/xtradb/include/btr0sea.ic
        storage/xtradb/include/btr0types.h
        storage/xtradb/include/buf0buddy.h
        storage/xtradb/include/buf0buddy.ic
        storage/xtradb/include/buf0buf.h
        storage/xtradb/include/buf0buf.ic
        storage/xtradb/include/buf0flu.h
        storage/xtradb/include/buf0flu.ic
        storage/xtradb/include/buf0lru.h
        storage/xtradb/include/buf0lru.ic
        storage/xtradb/include/buf0rea.h
        storage/xtradb/include/buf0types.h
        storage/xtradb/include/data0data.h
        storage/xtradb/include/data0data.ic
        storage/xtradb/include/data0type.h
        storage/xtradb/include/data0type.ic
        storage/xtradb/include/data0types.h
        storage/xtradb/include/db0err.h
        storage/xtradb/include/dict0boot.h
        storage/xtradb/include/dict0boot.ic
        storage/xtradb/include/dict0crea.h
        storage/xtradb/include/dict0crea.ic
        storage/xtradb/include/dict0dict.h
        storage/xtradb/include/dict0dict.ic
        storage/xtradb/include/dict0load.h
        storage/xtradb/include/dict0load.ic
        storage/xtradb/include/dict0mem.h
        storage/xtradb/include/dict0mem.ic
        storage/xtradb/include/dict0types.h
        storage/xtradb/include/dyn0dyn.h
        storage/xtradb/include/dyn0dyn.ic
        storage/xtradb/include/eval0eval.h
        storage/xtradb/include/eval0eval.ic
        storage/xtradb/include/eval0proc.h
        storage/xtradb/include/eval0proc.ic
        storage/xtradb/include/fil0fil.h
        storage/xtradb/include/fsp0fsp.h
        storage/xtradb/include/fsp0fsp.ic
        storage/xtradb/include/fut0fut.h
        storage/xtradb/include/fut0fut.ic
        storage/xtradb/include/fut0lst.h
        storage/xtradb/include/fut0lst.ic
        storage/xtradb/include/ha0ha.h
        storage/xtradb/include/ha0ha.ic
        storage/xtradb/include/ha0storage.h
        storage/xtradb/include/ha0storage.ic
        storage/xtradb/include/ha_prototypes.h
        storage/xtradb/include/handler0alter.h
        storage/xtradb/include/hash0hash.h
        storage/xtradb/include/hash0hash.ic
        storage/xtradb/include/ibuf0ibuf.h
        storage/xtradb/include/ibuf0ibuf.ic
        storage/xtradb/include/ibuf0types.h
        storage/xtradb/include/lock0iter.h
        storage/xtradb/include/lock0lock.h
        storage/xtradb/include/lock0lock.ic
        storage/xtradb/include/lock0priv.h
        storage/xtradb/include/lock0priv.ic
        storage/xtradb/include/lock0types.h
        storage/xtradb/include/log0log.h
        storage/xtradb/include/log0log.ic
        storage/xtradb/include/log0recv.h
        storage/xtradb/include/log0recv.ic
        storage/xtradb/include/mach0data.h
        storage/xtradb/include/mach0data.ic
        storage/xtradb/include/mem0dbg.h
        storage/xtradb/include/mem0dbg.ic
        storage/xtradb/include/mem0mem.h
        storage/xtradb/include/mem0mem.ic
        storage/xtradb/include/mem0pool.h
        storage/xtradb/include/mem0pool.ic
        storage/xtradb/include/mtr0log.h
        storage/xtradb/include/mtr0log.ic
        storage/xtradb/include/mtr0mtr.h
        storage/xtradb/include/mtr0mtr.ic
        storage/xtradb/include/mtr0types.h
        storage/xtradb/include/mysql_addons.h
        storage/xtradb/include/os0file.h
        storage/xtradb/include/os0proc.h
        storage/xtradb/include/os0proc.ic
        storage/xtradb/include/os0sync.h
        storage/xtradb/include/os0sync.ic
        storage/xtradb/include/os0thread.h
        storage/xtradb/include/os0thread.ic
        storage/xtradb/include/page0cur.h
        storage/xtradb/include/page0cur.ic
        storage/xtradb/include/page0page.h
        storage/xtradb/include/page0page.ic
        storage/xtradb/include/page0types.h
        storage/xtradb/include/page0zip.h
        storage/xtradb/include/page0zip.ic
        storage/xtradb/include/pars0grm.h
        storage/xtradb/include/pars0opt.h
        storage/xtradb/include/pars0opt.ic
        storage/xtradb/include/pars0pars.h
        storage/xtradb/include/pars0pars.ic
        storage/xtradb/include/pars0sym.h
        storage/xtradb/include/pars0sym.ic
        storage/xtradb/include/pars0types.h
        storage/xtradb/include/que0que.h
        storage/xtradb/include/que0que.ic
        storage/xtradb/include/que0types.h
        storage/xtradb/include/read0read.h
        storage/xtradb/include/read0read.ic
        storage/xtradb/include/read0types.h
        storage/xtradb/include/rem0cmp.h
        storage/xtradb/include/rem0cmp.ic
        storage/xtradb/include/rem0rec.h
        storage/xtradb/include/rem0rec.ic
        storage/xtradb/include/rem0types.h
        storage/xtradb/include/row0ext.h
        storage/xtradb/include/row0ext.ic
        storage/xtradb/include/row0ins.h
        storage/xtradb/include/row0ins.ic
        storage/xtradb/include/row0merge.h
        storage/xtradb/include/row0mysql.h
        storage/xtradb/include/row0mysql.ic
        storage/xtradb/include/row0purge.h
        storage/xtradb/include/row0purge.ic
        storage/xtradb/include/row0row.h
        storage/xtradb/include/row0row.ic
        storage/xtradb/include/row0sel.h
        storage/xtradb/include/row0sel.ic
        storage/xtradb/include/row0types.h
        storage/xtradb/include/row0uins.h
        storage/xtradb/include/row0uins.ic
        storage/xtradb/include/row0umod.h
        storage/xtradb/include/row0umod.ic
        storage/xtradb/include/row0undo.h
        storage/xtradb/include/row0undo.ic
        storage/xtradb/include/row0upd.h
        storage/xtradb/include/row0upd.ic
        storage/xtradb/include/row0vers.h
        storage/xtradb/include/row0vers.ic
        storage/xtradb/include/srv0que.h
        storage/xtradb/include/srv0srv.h
        storage/xtradb/include/srv0srv.ic
        storage/xtradb/include/srv0start.h
        storage/xtradb/include/sync0arr.h
        storage/xtradb/include/sync0arr.ic
        storage/xtradb/include/sync0rw.h
        storage/xtradb/include/sync0rw.ic
        storage/xtradb/include/sync0sync.h
        storage/xtradb/include/sync0sync.ic
        storage/xtradb/include/sync0types.h
        storage/xtradb/include/thr0loc.h
        storage/xtradb/include/thr0loc.ic
        storage/xtradb/include/trx0i_s.h
        storage/xtradb/include/trx0purge.h
        storage/xtradb/include/trx0purge.ic
        storage/xtradb/include/trx0rec.h
        storage/xtradb/include/trx0rec.ic
        storage/xtradb/include/trx0roll.h
        storage/xtradb/include/trx0roll.ic
        storage/xtradb/include/trx0rseg.h
        storage/xtradb/include/trx0rseg.ic
        storage/xtradb/include/trx0sys.h
        storage/xtradb/include/trx0sys.ic
        storage/xtradb/include/trx0trx.h
        storage/xtradb/include/trx0trx.ic
        storage/xtradb/include/trx0types.h
        storage/xtradb/include/trx0undo.h
        storage/xtradb/include/trx0undo.ic
        storage/xtradb/include/trx0xa.h
        storage/xtradb/include/univ.i
        storage/xtradb/include/usr0sess.h
        storage/xtradb/include/usr0sess.ic
        storage/xtradb/include/usr0types.h
        storage/xtradb/include/ut0auxconf.h
        storage/xtradb/include/ut0byte.h
        storage/xtradb/include/ut0byte.ic
        storage/xtradb/include/ut0dbg.h
        storage/xtradb/include/ut0list.h
        storage/xtradb/include/ut0list.ic
        storage/xtradb/include/ut0lst.h
        storage/xtradb/include/ut0mem.h
        storage/xtradb/include/ut0mem.ic
        storage/xtradb/include/ut0rnd.h
        storage/xtradb/include/ut0rnd.ic
        storage/xtradb/include/ut0sort.h
        storage/xtradb/include/ut0ut.h
        storage/xtradb/include/ut0ut.ic
        storage/xtradb/include/ut0vec.h
        storage/xtradb/include/ut0vec.ic
        storage/xtradb/include/ut0wqueue.h
        storage/xtradb/lock/
        storage/xtradb/lock/lock0iter.c
        storage/xtradb/lock/lock0lock.c
        storage/xtradb/log/
        storage/xtradb/log/log0log.c
        storage/xtradb/log/log0recv.c
        storage/xtradb/mach/
        storage/xtradb/mach/mach0data.c
        storage/xtradb/mem/
        storage/xtradb/mem/mem0dbg.c
        storage/xtradb/mem/mem0mem.c
        storage/xtradb/mem/mem0pool.c
        storage/xtradb/mtr/
        storage/xtradb/mtr/mtr0log.c
        storage/xtradb/mtr/mtr0mtr.c
        storage/xtradb/os/
        storage/xtradb/os/os0file.c
        storage/xtradb/os/os0proc.c
        storage/xtradb/os/os0sync.c
        storage/xtradb/os/os0thread.c
        storage/xtradb/page/
        storage/xtradb/page/page0cur.c
        storage/xtradb/page/page0page.c
        storage/xtradb/page/page0zip.c
        storage/xtradb/pars/
        storage/xtradb/pars/lexyy.c
        storage/xtradb/pars/make_bison.sh
        storage/xtradb/pars/make_flex.sh
        storage/xtradb/pars/pars0grm.c
        storage/xtradb/pars/pars0grm.y
        storage/xtradb/pars/pars0lex.l
        storage/xtradb/pars/pars0opt.c
        storage/xtradb/pars/pars0pars.c
        storage/xtradb/pars/pars0sym.c
        storage/xtradb/plug.in
        storage/xtradb/que/
        storage/xtradb/que/que0que.c
        storage/xtradb/read/
        storage/xtradb/read/read0read.c
        storage/xtradb/rem/
        storage/xtradb/rem/rem0cmp.c
        storage/xtradb/rem/rem0rec.c
        storage/xtradb/row/
        storage/xtradb/row/row0ext.c
        storage/xtradb/row/row0ins.c
        storage/xtradb/row/row0merge.c
        storage/xtradb/row/row0mysql.c
        storage/xtradb/row/row0purge.c
        storage/xtradb/row/row0row.c
        storage/xtradb/row/row0sel.c
        storage/xtradb/row/row0uins.c
        storage/xtradb/row/row0umod.c
        storage/xtradb/row/row0undo.c
        storage/xtradb/row/row0upd.c
        storage/xtradb/row/row0vers.c
        storage/xtradb/scripts/
        storage/xtradb/scripts/install_innodb_plugins.sql
        storage/xtradb/scripts/install_innodb_plugins_win.sql
        storage/xtradb/srv/
        storage/xtradb/srv/srv0que.c
        storage/xtradb/srv/srv0srv.c
        storage/xtradb/srv/srv0start.c
        storage/xtradb/sync/
        storage/xtradb/sync/sync0arr.c
        storage/xtradb/sync/sync0rw.c
        storage/xtradb/sync/sync0sync.c
        storage/xtradb/thr/
        storage/xtradb/thr/thr0loc.c
        storage/xtradb/trx/
        storage/xtradb/trx/trx0i_s.c
        storage/xtradb/trx/trx0purge.c
        storage/xtradb/trx/trx0rec.c
        storage/xtradb/trx/trx0roll.c
        storage/xtradb/trx/trx0rseg.c
        storage/xtradb/trx/trx0sys.c
        storage/xtradb/trx/trx0trx.c
        storage/xtradb/trx/trx0undo.c
        storage/xtradb/usr/
        storage/xtradb/usr/usr0sess.c
        storage/xtradb/ut/
        storage/xtradb/ut/ut0auxconf.c
        storage/xtradb/ut/ut0byte.c
        storage/xtradb/ut/ut0dbg.c
        storage/xtradb/ut/ut0list.c
        storage/xtradb/ut/ut0mem.c
        storage/xtradb/ut/ut0rnd.c
        storage/xtradb/ut/ut0ut.c
        storage/xtradb/ut/ut0vec.c
        storage/xtradb/ut/ut0wqueue.c
        storage/xtradb/win-plugin/
        storage/xtradb/win-plugin/README
        storage/xtradb/win-plugin/win-plugin.diff
      renamed:
        storage/innobase/plug.in => storage/innobase/plug.in.disabled
      modified:
        .bzrignore
        CMakeLists.txt
        configure.in
        include/atomic/nolock.h
        include/my_sys.h
        libmysqld/CMakeLists.txt
        mysql-test/r/index_merge_innodb.result
        mysql-test/r/information_schema.result
        mysql-test/r/information_schema_all_engines.result
        mysql-test/r/mysqlbinlog_row_big.result
        mysql-test/r/row-checksum-old.result
        mysql-test/r/row-checksum.result
        mysql-test/r/variables-big.result
        mysql-test/t/information_schema.test
        mysql-test/t/mysqlbinlog_row_big.test
        mysql-test/t/partition_innodb.test
        mysql-test/t/type_bit_innodb.test
        mysql-test/t/variables-big.test
        mysys/mf_iocache2.c
        mysys/thr_mutex.c
        sql/log_event.cc
        sql/log_event.h
        sql/rpl_mi.cc
        sql/rpl_rli.cc
        sql/slave.cc

=== modified file '.bzrignore'
--- a/.bzrignore	2009-04-25 09:04:38 +0000
+++ b/.bzrignore	2009-06-11 17:49:51 +0000
@@ -1444,6 +1444,21 @@ storage/innobase/ib_config.h
 storage/innobase/ib_config.h.in
 storage/innobase/mkinstalldirs
 storage/innobase/stamp-h1
+storage/xtradb/autom4te-2.53.cache/*
+storage/xtradb/autom4te-2.53.cache/output.0
+storage/xtradb/autom4te-2.53.cache/requests
+storage/xtradb/autom4te-2.53.cache/traces.0
+storage/xtradb/autom4te.cache/*
+storage/xtradb/autom4te.cache/output.0
+storage/xtradb/autom4te.cache/requests
+storage/xtradb/autom4te.cache/traces.0
+storage/xtradb/configure.lineno
+storage/xtradb/conftest.s1
+storage/xtradb/conftest.subs
+storage/xtradb/ib_config.h
+storage/xtradb/ib_config.h.in
+storage/xtradb/mkinstalldirs
+storage/xtradb/stamp-h1
 storage/maria/*.MAD
 storage/maria/*.MAI
 storage/maria/ma_rt_test

=== added file 'BUILD/compile-innodb'
--- a/BUILD/compile-innodb	1970-01-01 00:00:00 +0000
+++ b/BUILD/compile-innodb	2009-06-09 13:19:13 +0000
@@ -0,0 +1,24 @@
+#! /bin/sh
+#
+# Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved.
+# 
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 2 of the License.
+# 
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+path=`dirname $0`
+. "$path/SETUP.sh"
+
+extra_flags="$pentium_cflags $fast_cflags -g"
+extra_configs="$pentium_configs $static_link --with-plugins=innobase"
+
+. "$path/FINISH.sh"

=== added file 'BUILD/compile-innodb-debug'
--- a/BUILD/compile-innodb-debug	1970-01-01 00:00:00 +0000
+++ b/BUILD/compile-innodb-debug	2009-06-09 13:19:13 +0000
@@ -0,0 +1,24 @@
+#! /bin/sh
+#
+# Copyright (c) 2005, 2009, Innobase Oy. All Rights Reserved.
+# 
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 2 of the License.
+# 
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+path=`dirname $0`
+. "$path/SETUP.sh" $@ --with-debug=full
+
+extra_flags="$pentium_cflags $debug_cflags"
+extra_configs="$pentium_configs $debug_configs --with-plugins=innobase"
+
+. "$path/FINISH.sh"

=== modified file 'CMakeLists.txt'
--- a/CMakeLists.txt	2009-04-25 09:04:38 +0000
+++ b/CMakeLists.txt	2009-06-11 17:49:51 +0000
@@ -263,7 +263,7 @@ IF(WITH_FEDERATED_STORAGE_ENGINE)
   ADD_SUBDIRECTORY(storage/federated)
 ENDIF(WITH_FEDERATED_STORAGE_ENGINE)
 IF(WITH_INNOBASE_STORAGE_ENGINE)
-  ADD_SUBDIRECTORY(storage/innobase)
+  ADD_SUBDIRECTORY(storage/xtradb)
 ENDIF(WITH_INNOBASE_STORAGE_ENGINE)
 IF(WITH_MARIA_STORAGE_ENGINE)
   ADD_SUBDIRECTORY(storage/maria)

=== modified file 'configure.in'
--- a/configure.in	2009-05-22 12:38:50 +0000
+++ b/configure.in	2009-06-11 17:49:51 +0000
@@ -1729,6 +1729,30 @@ then
   fi
 fi
 
+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
+	       [mysql_cv_gcc_atomic_builtins], [AC_TRY_RUN([
+  int main()
+  {
+    int foo= -10; int bar= 10;
+    if (!__sync_fetch_and_add(&foo, bar) || foo)
+      return -1;
+    bar= __sync_lock_test_and_set(&foo, bar);
+    if (bar || foo != 10)
+      return -1;
+    bar= __sync_val_compare_and_swap(&bar, foo, 15);
+    if (bar)
+      return -1;
+    return 0;
+  }
+], [mysql_cv_gcc_atomic_builtins=yes],
+   [mysql_cv_gcc_atomic_builtins=no],
+   [mysql_cv_gcc_atomic_builtins=no])])
+
+if test "x$mysql_cv_gcc_atomic_builtins" = xyes; then
+  AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS, 1,
+	    [Define to 1 if compiler provides atomic builtins.])
+fi
+
 AC_ARG_WITH([atomic-ops],
 	    AC_HELP_STRING([--with-atomic-ops=rwlocks|smp|up],
 	    [Implement atomic operations using pthread rwlocks or atomic CPU
@@ -1742,28 +1766,9 @@ case "$with_atomic_ops" in
                   [Use pthread rwlocks for atomic ops]) ;;
   "smp") ;;
   "")
-    AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-                   [mysql_cv_gcc_atomic_builtins], [AC_TRY_RUN([
-      int main()
-      {
-        int foo= -10; int bar= 10;
-        if (!__sync_fetch_and_add(&foo, bar) || foo)
-          return -1;
-        bar= __sync_lock_test_and_set(&foo, bar);
-        if (bar || foo != 10)
-          return -1;
-        bar= __sync_val_compare_and_swap(&bar, foo, 15);
-        if (bar)
-          return -1;
-        return 0;
-      }
-    ], [mysql_cv_gcc_atomic_builtins=yes_but_disabled],
-       [mysql_cv_gcc_atomic_builtins=no],
-       [mysql_cv_gcc_atomic_builtins=no])])
-
-    if test "x$mysql_cv_gcc_atomic_builtins" = xyes; then
-      AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS, 1,
-                [Define to 1 if compiler provides atomic builtins.])
+    if test "x$mysql_cv_gcc_atomic_builtins" = xyes_but_disabled; then
+      AC_DEFINE([MY_ATOMIC_MODE_GCC_BUILTINS], [1],
+                [Use GCC atomic builtins for atomic ops])
     fi
    ;;
    *) AC_MSG_ERROR(["$with_atomic_ops" is not a valid value for --with-atomic-ops]) ;;

=== modified file 'include/atomic/nolock.h'
--- a/include/atomic/nolock.h	2008-02-05 15:47:11 +0000
+++ b/include/atomic/nolock.h	2009-06-10 09:13:53 +0000
@@ -14,7 +14,7 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #if defined(__i386__) || defined(_MSC_VER) || \
-    defined(__x86_64__) || defined(HAVE_GCC_ATOMIC_BUILTINS)
+    defined(__x86_64__) || defined(MY_ATOMIC_MODE_GCC_BUILTINS)
 
 #  ifdef MY_ATOMIC_MODE_DUMMY
 #    define LOCK_prefix ""
@@ -22,7 +22,7 @@
 #    define LOCK_prefix "lock"
 #  endif
 
-#  ifdef HAVE_GCC_ATOMIC_BUILTINS
+#  ifdef MY_ATOMIC_MODE_GCC_BUILTINS
 #    include "gcc_builtins.h"
 #  elif __GNUC__
 #    include "x86-gcc.h"

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2009-05-22 12:38:50 +0000
+++ b/include/my_sys.h	2009-06-11 17:49:51 +0000
@@ -791,6 +791,9 @@ extern size_t my_b_gets(IO_CACHE *info, 
 extern my_off_t my_b_filelength(IO_CACHE *info);
 extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
 extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
+extern int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
+                                 const char *default_val);
+extern int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
 extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
 				 const char *prefix, size_t cache_size,
 				 myf cache_myflags);

=== modified file 'libmysqld/CMakeLists.txt'
--- a/libmysqld/CMakeLists.txt	2009-04-25 10:05:32 +0000
+++ b/libmysqld/CMakeLists.txt	2009-06-11 17:49:51 +0000
@@ -132,9 +132,9 @@ IF(WITH_FEDERATED_STORAGE_ENGINE)
 ENDIF(WITH_FEDERATED_STORAGE_ENGINE)
 
 IF(WITH_INNOBASE_STORAGE_ENGINE)
-  INCLUDE(${CMAKE_SOURCE_DIR}/storage/innobase/CMakeLists.txt)
+  INCLUDE(${CMAKE_SOURCE_DIR}/storage/xtradb/CMakeLists.txt)
   FOREACH(rpath ${INNOBASE_SOURCES})
-    SET(LIB_SOURCES ${LIB_SOURCES} ../storage/innobase/${rpath})
+    SET(LIB_SOURCES ${LIB_SOURCES} ../storage/xtradb/${rpath})
   ENDFOREACH(rpath)
 ENDIF(WITH_INNOBASE_STORAGE_ENGINE)
 

=== added file 'mysql-test/include/ctype_innodb_like.inc'
--- a/mysql-test/include/ctype_innodb_like.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/ctype_innodb_like.inc	2009-06-09 13:19:13 +0000
@@ -0,0 +1,21 @@
+#
+# Bug#11650: LIKE pattern matching using prefix index
+# doesn't return correct result
+#
+--disable_warnings
+#
+# This query creates a column using
+# character_set_connection and
+# collation_connection.
+#
+create table t1 engine=innodb select repeat('a',50) as c1;
+--enable_warnings
+alter table t1 add index(c1(5));
+
+insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
+select collation(c1) from t1 limit 1;
+select c1 from t1 where c1 like 'abcdef%' order by c1;
+select c1 from t1 where c1 like 'abcde1%' order by c1;
+select c1 from t1 where c1 like 'abcde11%' order by c1;
+select c1 from t1 where c1 like 'abcde111%' order by c1;
+drop table t1;

=== removed file 'mysql-test/include/ctype_innodb_like.inc'
--- a/mysql-test/include/ctype_innodb_like.inc	2005-07-06 12:16:22 +0000
+++ b/mysql-test/include/ctype_innodb_like.inc	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-#
-# Bug#11650: LIKE pattern matching using prefix index
-# doesn't return correct result
-#
---disable_warnings
-#
-# This query creates a column using
-# character_set_connection and
-# collation_connection.
-#
-create table t1 engine=innodb select repeat('a',50) as c1;
---enable_warnings
-alter table t1 add index(c1(5));
-
-insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
-select collation(c1) from t1 limit 1;
-select c1 from t1 where c1 like 'abcdef%' order by c1;
-select c1 from t1 where c1 like 'abcde1%' order by c1;
-select c1 from t1 where c1 like 'abcde11%' order by c1;
-select c1 from t1 where c1 like 'abcde111%' order by c1;
-drop table t1;

=== added file 'mysql-test/include/have_innodb.inc'
--- a/mysql-test/include/have_innodb.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/have_innodb.inc	2009-06-09 13:19:13 +0000
@@ -0,0 +1,4 @@
+disable_query_log;
+--require r/true.require
+select (support = 'YES' or support = 'DEFAULT' or support = 'ENABLED') as `TRUE` from information_schema.engines where engine = 'innodb';
+enable_query_log;

=== removed file 'mysql-test/include/have_innodb.inc'
--- a/mysql-test/include/have_innodb.inc	2008-07-04 18:48:25 +0000
+++ b/mysql-test/include/have_innodb.inc	1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
-disable_query_log;
---require r/true.require
-select (support = 'YES' or support = 'DEFAULT' or support = 'ENABLED') as `TRUE` from information_schema.engines where engine = 'innodb';
-enable_query_log;

=== added file 'mysql-test/include/innodb-index.inc'
--- a/mysql-test/include/innodb-index.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/innodb-index.inc	2009-06-09 13:19:13 +0000
@@ -0,0 +1,26 @@
+--eval create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=$charset
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
+commit;
+--error ER_DUP_ENTRY
+alter table t1 add unique index (b);
+insert into t1 values(8,9,'fff','fff');
+select * from t1;
+show create table t1;
+alter table t1 add index (b);
+insert into t1 values(10,10,'kkk','iii');
+select * from t1;
+select * from t1 force index(b) order by b;
+explain select * from t1 force index(b) order by b;
+show create table t1;
+alter table t1 add unique index (c), add index (d);
+insert into t1 values(11,11,'aaa','mmm');
+select * from t1;
+select * from t1 force index(b) order by b;
+select * from t1 force index(c) order by c;
+select * from t1 force index(d) order by d;
+explain select * from t1 force index(b) order by b;
+explain select * from t1 force index(c) order by c;
+explain select * from t1 force index(d) order by d;
+show create table t1;
+check table t1;
+drop table t1;

=== added file 'mysql-test/include/innodb_trx_weight.inc'
--- a/mysql-test/include/innodb_trx_weight.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/innodb_trx_weight.inc	2009-06-09 13:19:13 +0000
@@ -0,0 +1,51 @@
+-- connect (con1,localhost,root,,)
+-- connect (con2,localhost,root,,)
+
+-- connection con1
+SET autocommit=0;
+SELECT * FROM t1 FOR UPDATE;
+-- if ($con1_extra_sql_present) {
+	-- eval $con1_extra_sql
+-- }
+
+-- connection con2
+SET autocommit=0;
+SELECT * FROM t2 FOR UPDATE;
+-- if ($con2_extra_sql_present) {
+	-- eval $con2_extra_sql
+-- }
+
+-- if ($con1_should_be_rolledback) {
+	-- connection con1
+	-- send
+	INSERT INTO t2 VALUES (0);
+
+	-- connection con2
+	INSERT INTO t1 VALUES (0);
+	ROLLBACK;
+
+	-- connection con1
+	-- error ER_LOCK_DEADLOCK
+	-- reap
+-- }
+# else
+-- if (!$con1_should_be_rolledback) {
+	-- connection con2
+	-- send
+	INSERT INTO t1 VALUES (0);
+
+	-- connection con1
+	INSERT INTO t2 VALUES (0);
+	ROLLBACK;
+
+	-- connection con2
+	-- error ER_LOCK_DEADLOCK
+	-- reap
+-- }
+
+-- connection default
+
+DELETE FROM t5_nontrans;
+
+-- disconnect con1
+-- disconnect con2

=== removed file 'mysql-test/include/innodb_trx_weight.inc'
--- a/mysql-test/include/innodb_trx_weight.inc	2007-07-10 11:37:43 +0000
+++ b/mysql-test/include/innodb_trx_weight.inc	1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
--- connect (con1,localhost,root,,)
--- connect (con2,localhost,root,,)
-
--- connection con1
-SET autocommit=0;
-SELECT * FROM t1 FOR UPDATE;
--- if ($con1_extra_sql_present) {
-	-- eval $con1_extra_sql
--- }
-
--- connection con2
-SET autocommit=0;
-SELECT * FROM t2 FOR UPDATE;
--- if ($con2_extra_sql_present) {
-	-- eval $con2_extra_sql
--- }
-
--- if ($con1_should_be_rolledback) {
-	-- connection con1
-	-- send
-	INSERT INTO t2 VALUES (0);
-
-	-- connection con2
-	INSERT INTO t1 VALUES (0);
-	ROLLBACK;
-
-	-- connection con1
-	-- error ER_LOCK_DEADLOCK
-	-- reap
--- }
-# else
--- if (!$con1_should_be_rolledback) {
-	-- connection con2
-	-- send
-	INSERT INTO t1 VALUES (0);
-
-	-- connection con1
-	INSERT INTO t2 VALUES (0);
-	ROLLBACK;
-
-	-- connection con2
-	-- error ER_LOCK_DEADLOCK
-	-- reap
--- }
-
--- connection default
-
-DELETE FROM t5_nontrans;
-
--- disconnect con1
--- disconnect con2

=== 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	2009-06-09 13:19:13 +0000
@@ -111,7 +111,7 @@ count(*)
 explain select count(*) from t1 where
 key1a = 2 and key1b is null and  key2a = 2 and key2b is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index_merge	i1,i2	i1,i2	10,10	NULL	4	Using intersect(i1,i2); Using where; Using index
+1	SIMPLE	t1	index_merge	i1,i2	i1,i2	10,10	NULL	3	Using intersect(i1,i2); Using where; Using index
 select count(*) from t1 where
 key1a = 2 and key1b is null and key2a = 2 and key2b is null;
 count(*)
@@ -119,7 +119,7 @@ count(*)
 explain select count(*) from t1 where
 key1a = 2 and key1b is null and key3a = 2 and key3b is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index_merge	i1,i3	i1,i3	10,10	NULL	4	Using intersect(i1,i3); Using where; Using index
+1	SIMPLE	t1	index_merge	i1,i3	i1,i3	10,10	NULL	3	Using intersect(i1,i3); Using where; Using index
 select count(*) from t1 where
 key1a = 2 and key1b is null and key3a = 2 and key3b is null;
 count(*)

=== modified file 'mysql-test/r/information_schema.result'
--- a/mysql-test/r/information_schema.result	2009-05-19 09:28:05 +0000
+++ b/mysql-test/r/information_schema.result	2009-06-11 17:49:51 +0000
@@ -42,7 +42,7 @@ WHERE table_schema IN ('mysql', 'INFORMA
 table_name<>'ndb_binlog_index' AND
 table_name<>'ndb_apply_status' AND
 NOT (table_schema = 'INFORMATION_SCHEMA' AND table_name LIKE 'PBXT_%');
-select * from v1;
+select * from v1 ORDER BY c COLLATE utf8_bin;
 c
 CHARACTER_SETS
 COLLATIONS
@@ -54,6 +54,17 @@ EVENTS
 FILES
 GLOBAL_STATUS
 GLOBAL_VARIABLES
+INNODB_BUFFER_POOL_PAGES
+INNODB_BUFFER_POOL_PAGES_BLOB
+INNODB_BUFFER_POOL_PAGES_INDEX
+INNODB_CMP
+INNODB_CMPMEM
+INNODB_CMPMEM_RESET
+INNODB_CMP_RESET
+INNODB_LOCKS
+INNODB_LOCK_WAITS
+INNODB_RSEG
+INNODB_TRX
 KEY_COLUMN_USAGE
 PARTITIONS
 PLUGINS
@@ -72,6 +83,7 @@ TABLE_PRIVILEGES
 TRIGGERS
 USER_PRIVILEGES
 VIEWS
+XTRADB_ENHANCEMENTS
 columns_priv
 db
 event
@@ -87,6 +99,11 @@ proc
 procs_priv
 servers
 slow_log
+t1
+t2
+t3
+t4
+t5
 tables_priv
 time_zone
 time_zone_leap_second
@@ -94,11 +111,6 @@ time_zone_name
 time_zone_transition
 time_zone_transition_type
 user
-t1
-t4
-t2
-t3
-t5
 v1
 select c,table_name from v1 
 inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
@@ -800,6 +812,8 @@ TABLES	CREATE_TIME	datetime
 TABLES	UPDATE_TIME	datetime
 TABLES	CHECK_TIME	datetime
 TRIGGERS	CREATED	datetime
+INNODB_TRX	trx_started	datetime
+INNODB_TRX	trx_wait_started	datetime
 event	execute_at	datetime
 event	last_executed	datetime
 event	starts	datetime
@@ -848,6 +862,7 @@ TABLES	TABLE_NAME	select
 TABLE_CONSTRAINTS	TABLE_NAME	select
 TABLE_PRIVILEGES	TABLE_NAME	select
 VIEWS	TABLE_NAME	select
+INNODB_BUFFER_POOL_PAGES_INDEX	table_name	select
 delete from mysql.user where user='mysqltest_4';
 delete from mysql.db where user='mysqltest_4';
 flush privileges;
@@ -1223,12 +1238,12 @@ DROP PROCEDURE p1;
 DROP USER mysql_bug20230@localhost;
 SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test');
 MAX(table_name)
-VIEWS
+XTRADB_ENHANCEMENTS
 SELECT table_name from information_schema.tables
 WHERE table_name=(SELECT MAX(table_name)
 FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'));
 table_name
-VIEWS
+XTRADB_ENHANCEMENTS
 DROP TABLE IF EXISTS bug23037;
 DROP FUNCTION IF EXISTS get_value;
 SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT), LENGTH(COLUMN_DEFAULT) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='bug23037';

=== modified file 'mysql-test/r/information_schema_all_engines.result'
--- a/mysql-test/r/information_schema_all_engines.result	2009-04-08 16:55:26 +0000
+++ b/mysql-test/r/information_schema_all_engines.result	2009-06-11 12:53:26 +0000
@@ -29,7 +29,19 @@ TABLE_PRIVILEGES
 TRIGGERS
 USER_PRIVILEGES
 VIEWS
+INNODB_BUFFER_POOL_PAGES
 PBXT_STATISTICS
+INNODB_CMP
+INNODB_RSEG
+XTRADB_ENHANCEMENTS
+INNODB_BUFFER_POOL_PAGES_INDEX
+INNODB_BUFFER_POOL_PAGES_BLOB
+INNODB_TRX
+INNODB_CMP_RESET
+INNODB_LOCK_WAITS
+INNODB_CMPMEM_RESET
+INNODB_LOCKS
+INNODB_CMPMEM
 SELECT t.table_name, c1.column_name
 FROM information_schema.tables t
 INNER JOIN
@@ -73,7 +85,19 @@ TABLE_PRIVILEGES	TABLE_SCHEMA
 TRIGGERS	TRIGGER_SCHEMA
 USER_PRIVILEGES	GRANTEE
 VIEWS	TABLE_SCHEMA
+INNODB_BUFFER_POOL_PAGES	page_type
 PBXT_STATISTICS	ID
+INNODB_CMP	page_size
+INNODB_RSEG	rseg_id
+XTRADB_ENHANCEMENTS	name
+INNODB_BUFFER_POOL_PAGES_INDEX	schema_name
+INNODB_BUFFER_POOL_PAGES_BLOB	space_id
+INNODB_TRX	trx_id
+INNODB_CMP_RESET	page_size
+INNODB_LOCK_WAITS	requesting_trx_id
+INNODB_CMPMEM_RESET	page_size
+INNODB_LOCKS	lock_id
+INNODB_CMPMEM	page_size
 SELECT t.table_name, c1.column_name
 FROM information_schema.tables t
 INNER JOIN
@@ -117,7 +141,19 @@ TABLE_PRIVILEGES	TABLE_SCHEMA
 TRIGGERS	TRIGGER_SCHEMA
 USER_PRIVILEGES	GRANTEE
 VIEWS	TABLE_SCHEMA
+INNODB_BUFFER_POOL_PAGES	page_type
 PBXT_STATISTICS	ID
+INNODB_CMP	page_size
+INNODB_RSEG	rseg_id
+XTRADB_ENHANCEMENTS	name
+INNODB_BUFFER_POOL_PAGES_INDEX	schema_name
+INNODB_BUFFER_POOL_PAGES_BLOB	space_id
+INNODB_TRX	trx_id
+INNODB_CMP_RESET	page_size
+INNODB_LOCK_WAITS	requesting_trx_id
+INNODB_CMPMEM_RESET	page_size
+INNODB_LOCKS	lock_id
+INNODB_CMPMEM	page_size
 select 1 as f1 from information_schema.tables  where "CHARACTER_SETS"=
 (select cast(table_name as char)  from information_schema.tables
 order by table_name limit 1) limit 1;
@@ -149,6 +185,17 @@ EVENTS	information_schema.EVENTS	1
 FILES	information_schema.FILES	1
 GLOBAL_STATUS	information_schema.GLOBAL_STATUS	1
 GLOBAL_VARIABLES	information_schema.GLOBAL_VARIABLES	1
+INNODB_BUFFER_POOL_PAGES	information_schema.INNODB_BUFFER_POOL_PAGES	1
+INNODB_BUFFER_POOL_PAGES_BLOB	information_schema.INNODB_BUFFER_POOL_PAGES_BLOB	1
+INNODB_BUFFER_POOL_PAGES_INDEX	information_schema.INNODB_BUFFER_POOL_PAGES_INDEX	1
+INNODB_CMP	information_schema.INNODB_CMP	1
+INNODB_CMPMEM	information_schema.INNODB_CMPMEM	1
+INNODB_CMPMEM_RESET	information_schema.INNODB_CMPMEM_RESET	1
+INNODB_CMP_RESET	information_schema.INNODB_CMP_RESET	1
+INNODB_LOCKS	information_schema.INNODB_LOCKS	1
+INNODB_LOCK_WAITS	information_schema.INNODB_LOCK_WAITS	1
+INNODB_RSEG	information_schema.INNODB_RSEG	1
+INNODB_TRX	information_schema.INNODB_TRX	1
 KEY_COLUMN_USAGE	information_schema.KEY_COLUMN_USAGE	1
 PARTITIONS	information_schema.PARTITIONS	1
 PBXT_STATISTICS	information_schema.PBXT_STATISTICS	1
@@ -168,6 +215,7 @@ TABLE_PRIVILEGES	information_schema.TABL
 TRIGGERS	information_schema.TRIGGERS	1
 USER_PRIVILEGES	information_schema.USER_PRIVILEGES	1
 VIEWS	information_schema.VIEWS	1
+XTRADB_ENHANCEMENTS	information_schema.XTRADB_ENHANCEMENTS	1
 Database: information_schema
 +---------------------------------------+
 |                Tables                 |
@@ -200,7 +248,19 @@ Database: information_schema
 | TRIGGERS                              |
 | USER_PRIVILEGES                       |
 | VIEWS                                 |
+| INNODB_BUFFER_POOL_PAGES              |
 | PBXT_STATISTICS                       |
+| INNODB_CMP                            |
+| INNODB_RSEG                           |
+| XTRADB_ENHANCEMENTS                   |
+| INNODB_BUFFER_POOL_PAGES_INDEX        |
+| INNODB_BUFFER_POOL_PAGES_BLOB         |
+| INNODB_TRX                            |
+| INNODB_CMP_RESET                      |
+| INNODB_LOCK_WAITS                     |
+| INNODB_CMPMEM_RESET                   |
+| INNODB_LOCKS                          |
+| INNODB_CMPMEM                         |
 +---------------------------------------+
 Database: INFORMATION_SCHEMA
 +---------------------------------------+
@@ -234,7 +294,19 @@ Database: INFORMATION_SCHEMA
 | TRIGGERS                              |
 | USER_PRIVILEGES                       |
 | VIEWS                                 |
+| INNODB_BUFFER_POOL_PAGES              |
 | PBXT_STATISTICS                       |
+| INNODB_CMP                            |
+| INNODB_RSEG                           |
+| XTRADB_ENHANCEMENTS                   |
+| INNODB_BUFFER_POOL_PAGES_INDEX        |
+| INNODB_BUFFER_POOL_PAGES_BLOB         |
+| INNODB_TRX                            |
+| INNODB_CMP_RESET                      |
+| INNODB_LOCK_WAITS                     |
+| INNODB_CMPMEM_RESET                   |
+| INNODB_LOCKS                          |
+| INNODB_CMPMEM                         |
 +---------------------------------------+
 Wildcard: inf_rmation_schema
 +--------------------+
@@ -244,5 +316,5 @@ Wildcard: inf_rmation_schema
 +--------------------+
 SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
 table_schema	count(*)
-information_schema	29
+information_schema	41
 mysql	22

=== added file 'mysql-test/r/innodb-analyze.result'
--- a/mysql-test/r/innodb-analyze.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-analyze.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,2 @@
+Variable_name	Value
+innodb_stats_sample_pages	1

=== added file 'mysql-test/r/innodb-autoinc.result'
--- a/mysql-test/r/innodb-autoinc.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-autoinc.result	2009-06-09 15:08:46 +0000
@@ -0,0 +1,869 @@
+drop table if exists t1;
+CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (9223372036854775807, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+9223372036854775807	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (127, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+127	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (255, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+255	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (32767, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+32767	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (65535, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+65535	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (8388607, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+8388607	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (16777215, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+16777215	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (2147483647, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+2147483647	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (4294967295, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+4294967295	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (9223372036854775807, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+9223372036854775807	NULL
+DROP TABLE t1;
+CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (18446744073709551615, null);
+INSERT INTO t1 (c2) VALUES ('innodb');
+Got one of the listed errors
+SELECT * FROM t1;
+c1	c2
+18446744073709551615	NULL
+DROP TABLE t1;
+CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT c1 FROM t1;
+c1
+1
+2
+3
+4
+5
+6
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
+TRUNCATE TABLE t1;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT c1 FROM t1;
+c1
+1
+2
+3
+4
+5
+6
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT c1 FROM t1;
+c1
+1
+2
+3
+4
+5
+6
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
+DELETE FROM t1;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT c1 FROM t1;
+c1
+1
+2
+3
+7
+8
+9
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL, 1);
+DELETE FROM t1 WHERE c1 = 1;
+INSERT INTO t1 VALUES (2,1);
+INSERT INTO t1 VALUES (NULL,8);
+SELECT * FROM t1;
+c1	c2
+2	1
+3	8
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL, 1);
+DELETE FROM t1 WHERE c1 = 1;
+INSERT INTO t1 VALUES (2,1), (NULL, 8);
+INSERT INTO t1 VALUES (NULL,9);
+SELECT * FROM t1;
+c1	c2
+2	1
+3	8
+5	9
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	100
+auto_increment_offset	10
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(5),(NULL);
+INSERT INTO t1 VALUES (250),(NULL);
+SELECT * FROM t1;
+c1
+5
+10
+110
+250
+310
+INSERT INTO t1 VALUES (1000);
+SET @@INSERT_ID=400;
+INSERT INTO t1 VALUES(NULL),(NULL);
+SELECT * FROM t1;
+c1
+5
+10
+110
+250
+310
+400
+410
+1000
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(0);
+SELECT * FROM t1;
+c1
+1
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+INSERT INTO t1 VALUES (-1), (NULL),(2),(NULL);
+INSERT INTO t1 VALUES (250),(NULL);
+SELECT * FROM t1;
+c1
+-1
+1
+2
+10
+110
+250
+410
+SET @@INSERT_ID=400;
+INSERT INTO t1 VALUES(NULL),(NULL);
+Got one of the listed errors
+SELECT * FROM t1;
+c1
+-1
+1
+2
+10
+110
+250
+410
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(-1);
+SELECT * FROM t1;
+c1
+-1
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	100
+auto_increment_offset	10
+INSERT INTO t1 VALUES (-2), (NULL),(2),(NULL);
+INSERT INTO t1 VALUES (250),(NULL);
+SELECT * FROM t1;
+c1
+-2
+-1
+1
+2
+10
+250
+310
+INSERT INTO t1 VALUES (1000);
+SET @@INSERT_ID=400;
+INSERT INTO t1 VALUES(NULL),(NULL);
+SELECT * FROM t1;
+c1
+-2
+-1
+1
+2
+10
+250
+310
+400
+410
+1000
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(-1);
+Warnings:
+Warning	1264	Out of range value for column 'c1' at row 1
+SELECT * FROM t1;
+c1
+1
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	100
+auto_increment_offset	10
+INSERT INTO t1 VALUES (-2);
+Warnings:
+Warning	1264	Out of range value for column 'c1' at row 1
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (250);
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+c1
+1
+2
+10
+110
+210
+250
+310
+INSERT INTO t1 VALUES (1000);
+SET @@INSERT_ID=400;
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+c1
+1
+2
+10
+110
+210
+250
+310
+400
+1000
+1010
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(-1);
+Warnings:
+Warning	1264	Out of range value for column 'c1' at row 1
+SELECT * FROM t1;
+c1
+1
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	100
+auto_increment_offset	10
+INSERT INTO t1 VALUES (-2),(NULL),(2),(NULL);
+Warnings:
+Warning	1264	Out of range value for column 'c1' at row 1
+INSERT INTO t1 VALUES (250),(NULL);
+SELECT * FROM t1;
+c1
+1
+2
+10
+110
+210
+250
+410
+INSERT INTO t1 VALUES (1000);
+SET @@INSERT_ID=400;
+INSERT INTO t1 VALUES(NULL),(NULL);
+Got one of the listed errors
+SELECT * FROM t1;
+c1
+1
+2
+10
+110
+210
+250
+410
+1000
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES (9223372036854775794);
+SELECT * FROM t1;
+c1
+1
+9223372036854775794
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	2
+auto_increment_offset	10
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+SELECT * FROM t1;
+c1
+1
+9223372036854775794
+9223372036854775796
+9223372036854775798
+9223372036854775800
+9223372036854775802
+9223372036854775804
+9223372036854775806
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES (18446744073709551603);
+SELECT * FROM t1;
+c1
+1
+18446744073709551603
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	2
+auto_increment_offset	10
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+SELECT * FROM t1;
+c1
+1
+18446744073709551603
+18446744073709551604
+18446744073709551606
+18446744073709551608
+18446744073709551610
+18446744073709551612
+18446744073709551614
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES (18446744073709551603);
+SELECT * FROM t1;
+c1
+1
+18446744073709551603
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	5
+auto_increment_offset	7
+INSERT INTO t1 VALUES (NULL),(NULL);
+SELECT * FROM t1;
+c1
+1
+18446744073709551603
+18446744073709551607
+18446744073709551612
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES(-9223372036854775806);
+INSERT INTO t1 VALUES(-9223372036854775807);
+INSERT INTO t1 VALUES(-9223372036854775808);
+SELECT * FROM t1;
+c1
+-9223372036854775808
+-9223372036854775807
+-9223372036854775806
+1
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	3
+auto_increment_offset	3
+INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
+SELECT * FROM t1;
+c1
+-9223372036854775808
+-9223372036854775807
+-9223372036854775806
+1
+3
+6
+9
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES (18446744073709551610);
+SELECT * FROM t1;
+c1
+1
+18446744073709551610
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
+Warnings:
+Warning	1292	Truncated incorrect auto_increment_increment value: '1152921504606846976'
+Warning	1292	Truncated incorrect auto_increment_offset value: '1152921504606846976'
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	65535
+auto_increment_offset	65535
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+c1
+1
+18446744073709551610
+18446744073709551615
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+Variable_name	Value
+auto_increment_increment	1
+auto_increment_offset	1
+CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+c1	c2
+1	1
+2	2
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+c1	c2
+1	1
+2	2
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+c1	c2
+1	1
+2	2
+3	3
+4	4
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+c1	c2
+1	1
+2	2
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+c1	c2
+1	1
+2	2
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+c1	c2
+1	1
+2	2
+3	3
+4	4
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note	1051	Unknown table 't2'
+CREATE TABLE t1 (
+a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+b INT(10) UNSIGNED NOT NULL,
+c ENUM('FALSE','TRUE') DEFAULT NULL,
+PRIMARY KEY (a)) ENGINE = InnoDB;
+CREATE TABLE t2 (
+m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+n INT(10) UNSIGNED NOT NULL,
+o enum('FALSE','TRUE') DEFAULT NULL,
+PRIMARY KEY (m)) ENGINE = InnoDB;
+INSERT INTO t2 (n,o) VALUES
+(1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
+(3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `m` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `n` int(10) unsigned NOT NULL,
+  `o` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`m`)
+) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SELECT * FROM t1;
+a	b	c
+1	1	TRUE
+2	1	FALSE
+3	2	TRUE
+4	2	FALSE
+5	3	TRUE
+6	3	FALSE
+7	4	TRUE
+8	4	FALSE
+9	5	TRUE
+10	5	FALSE
+13	1	TRUE
+14	1	FALSE
+15	2	TRUE
+16	2	FALSE
+17	3	TRUE
+18	3	FALSE
+19	4	TRUE
+20	4	FALSE
+21	5	TRUE
+22	5	FALSE
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a	b	c
+1	1	TRUE
+2	1	FALSE
+3	2	TRUE
+4	2	FALSE
+5	3	TRUE
+6	3	FALSE
+7	4	TRUE
+8	4	FALSE
+9	5	TRUE
+10	5	FALSE
+13	1	TRUE
+14	1	FALSE
+15	2	TRUE
+16	2	FALSE
+17	3	TRUE
+18	3	FALSE
+19	4	TRUE
+20	4	FALSE
+21	5	TRUE
+22	5	FALSE
+23	1	FALSE
+24	2	FALSE
+25	3	FALSE
+26	4	FALSE
+27	5	FALSE
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a	b	c
+1	1	TRUE
+2	1	FALSE
+3	2	TRUE
+4	2	FALSE
+5	3	TRUE
+6	3	FALSE
+7	4	TRUE
+8	4	FALSE
+9	5	TRUE
+10	5	FALSE
+13	1	TRUE
+14	1	FALSE
+15	2	TRUE
+16	2	FALSE
+17	3	TRUE
+18	3	FALSE
+19	4	TRUE
+20	4	FALSE
+21	5	TRUE
+22	5	FALSE
+23	1	FALSE
+24	2	FALSE
+25	3	FALSE
+26	4	FALSE
+27	5	FALSE
+30	1	FALSE
+31	2	FALSE
+32	3	FALSE
+33	4	FALSE
+34	5	FALSE
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a	b	c
+1	1	TRUE
+2	1	FALSE
+3	2	TRUE
+4	2	FALSE
+5	3	TRUE
+6	3	FALSE
+7	4	TRUE
+8	4	FALSE
+9	5	TRUE
+10	5	FALSE
+13	1	TRUE
+14	1	FALSE
+15	2	TRUE
+16	2	FALSE
+17	3	TRUE
+18	3	FALSE
+19	4	TRUE
+20	4	FALSE
+21	5	TRUE
+22	5	FALSE
+23	1	FALSE
+24	2	FALSE
+25	3	FALSE
+26	4	FALSE
+27	5	FALSE
+30	1	FALSE
+31	2	FALSE
+32	3	FALSE
+33	4	FALSE
+34	5	FALSE
+37	1	FALSE
+38	2	FALSE
+39	3	FALSE
+40	4	FALSE
+41	5	FALSE
+44	1	FALSE
+45	2	FALSE
+46	3	FALSE
+47	4	FALSE
+48	5	FALSE
+51	1	FALSE
+52	2	FALSE
+53	3	FALSE
+54	4	FALSE
+55	5	FALSE
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(10) unsigned NOT NULL,
+  `c` enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=latin1
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note	1051	Unknown table 't2'
+CREATE TABLE t1(
+c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
+PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+CREATE TABLE t2(
+c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
+PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t2 SELECT c1 FROM t1;
+Got one of the listed errors
+INSERT INTO t2 SELECT NULL FROM t1;
+Got one of the listed errors
+DROP TABLE t1;
+DROP TABLE t2;

=== removed file 'mysql-test/r/innodb-autoinc.result'
--- a/mysql-test/r/innodb-autoinc.result	2009-05-19 09:28:05 +0000
+++ b/mysql-test/r/innodb-autoinc.result	1970-01-01 00:00:00 +0000
@@ -1,870 +0,0 @@
-drop table if exists t1;
-CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (9223372036854775807, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-9223372036854775807	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (127, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-127	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (255, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-255	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (32767, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-32767	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (65535, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-65535	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (8388607, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-8388607	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (16777215, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-16777215	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (2147483647, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-2147483647	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (4294967295, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-4294967295	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (9223372036854775807, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-9223372036854775807	NULL
-DROP TABLE t1;
-CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (18446744073709551615, null);
-INSERT INTO t1 (c2) VALUES ('innodb');
-Got one of the listed errors
-SELECT * FROM t1;
-c1	c2
-18446744073709551615	NULL
-DROP TABLE t1;
-CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-c1
-1
-2
-3
-4
-5
-6
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `c1` int(11) NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
-TRUNCATE TABLE t1;
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `c1` int(11) NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`c1`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-c1
-1
-2
-3
-4
-5
-6
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `c1` int(11) NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
-DROP TABLE t1;
-CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-c1
-1
-2
-3
-4
-5
-6
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `c1` int(11) NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
-DELETE FROM t1;
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `c1` int(11) NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-c1
-1
-2
-3
-7
-8
-9
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `c1` int(11) NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
-DROP TABLE t1;
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL, 1);
-DELETE FROM t1 WHERE c1 = 1;
-INSERT INTO t1 VALUES (2,1);
-INSERT INTO t1 VALUES (NULL,8);
-SELECT * FROM t1;
-c1	c2
-2	1
-3	8
-DROP TABLE t1;
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL, 1);
-DELETE FROM t1 WHERE c1 = 1;
-INSERT INTO t1 VALUES (2,1), (NULL, 8);
-INSERT INTO t1 VALUES (NULL,9);
-SELECT * FROM t1;
-c1	c2
-2	1
-3	8
-5	9
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	100
-auto_increment_offset	10
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL),(5),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-c1
-5
-10
-110
-250
-310
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-c1
-5
-10
-110
-250
-310
-400
-410
-1000
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(0);
-SELECT * FROM t1;
-c1
-1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-INSERT INTO t1 VALUES (-1), (NULL),(2),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-c1
--1
-1
-2
-10
-110
-250
-410
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL),(NULL);
-Got one of the listed errors
-SELECT * FROM t1;
-c1
--1
-1
-2
-10
-110
-250
-410
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-SELECT * FROM t1;
-c1
--1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	100
-auto_increment_offset	10
-INSERT INTO t1 VALUES (-2), (NULL),(2),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-c1
--2
--1
-1
-2
-10
-250
-310
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-c1
--2
--1
-1
-2
-10
-250
-310
-400
-410
-1000
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-Warnings:
-Warning	1264	Out of range value for column 'c1' at row 1
-SELECT * FROM t1;
-c1
-1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	100
-auto_increment_offset	10
-INSERT INTO t1 VALUES (-2);
-Warnings:
-Warning	1264	Out of range value for column 'c1' at row 1
-INSERT INTO t1 VALUES (NULL);
-INSERT INTO t1 VALUES (2);
-INSERT INTO t1 VALUES (NULL);
-INSERT INTO t1 VALUES (250);
-INSERT INTO t1 VALUES (NULL);
-SELECT * FROM t1;
-c1
-1
-2
-10
-110
-210
-250
-310
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES(NULL);
-SELECT * FROM t1;
-c1
-1
-2
-10
-110
-210
-250
-310
-400
-1000
-1010
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-Warnings:
-Warning	1264	Out of range value for column 'c1' at row 1
-SELECT * FROM t1;
-c1
-1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	100
-auto_increment_offset	10
-INSERT INTO t1 VALUES (-2),(NULL),(2),(NULL);
-Warnings:
-Warning	1264	Out of range value for column 'c1' at row 1
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-c1
-1
-2
-10
-110
-210
-250
-410
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL),(NULL);
-Got one of the listed errors
-SELECT * FROM t1;
-c1
-1
-2
-10
-110
-210
-250
-410
-1000
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (9223372036854775794);
-SELECT * FROM t1;
-c1
-1
-9223372036854775794
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	2
-auto_increment_offset	10
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-SELECT * FROM t1;
-c1
-1
-9223372036854775794
-9223372036854775796
-9223372036854775798
-9223372036854775800
-9223372036854775802
-9223372036854775804
-9223372036854775806
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551603);
-SELECT * FROM t1;
-c1
-1
-18446744073709551603
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	2
-auto_increment_offset	10
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-SELECT * FROM t1;
-c1
-1
-18446744073709551603
-18446744073709551604
-18446744073709551606
-18446744073709551608
-18446744073709551610
-18446744073709551612
-18446744073709551614
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551603);
-SELECT * FROM t1;
-c1
-1
-18446744073709551603
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	5
-auto_increment_offset	7
-INSERT INTO t1 VALUES (NULL),(NULL);
-SELECT * FROM t1;
-c1
-1
-18446744073709551603
-18446744073709551607
-18446744073709551612
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES(-9223372036854775806);
-INSERT INTO t1 VALUES(-9223372036854775807);
-INSERT INTO t1 VALUES(-9223372036854775808);
-SELECT * FROM t1;
-c1
--9223372036854775808
--9223372036854775807
--9223372036854775806
-1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	3
-auto_increment_offset	3
-INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
-SELECT * FROM t1;
-c1
--9223372036854775808
--9223372036854775807
--9223372036854775806
-1
-3
-6
-9
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551610);
-SELECT * FROM t1;
-c1
-1
-18446744073709551610
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
-Warnings:
-Warning	1292	Truncated incorrect auto_increment_increment value: '1152921504606846976'
-Warning	1292	Truncated incorrect auto_increment_offset value: '1152921504606846976'
-SHOW VARIABLES LIKE "auto_inc%";
-Variable_name	Value
-auto_increment_increment	65535
-auto_increment_offset	65535
-INSERT INTO t1 VALUES (NULL);
-SELECT * FROM t1;
-c1
-1
-18446744073709551610
-18446744073709551615
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "%auto_inc%";
-Variable_name	Value
-auto_increment_increment	1
-auto_increment_offset	1
-pbxt_auto_increment_mode	0
-CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL, 1);
-INSERT INTO t1 VALUES(NULL, 2);
-SELECT * FROM t1;
-c1	c2
-1	1
-2	2
-ALTER TABLE t1 CHANGE c1 c1 SERIAL;
-SELECT * FROM t1;
-c1	c2
-1	1
-2	2
-INSERT INTO t1 VALUES(NULL, 3);
-INSERT INTO t1 VALUES(NULL, 4);
-SELECT * FROM t1;
-c1	c2
-1	1
-2	2
-3	3
-4	4
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL, 1);
-INSERT INTO t1 VALUES(NULL, 2);
-SELECT * FROM t1;
-c1	c2
-1	1
-2	2
-ALTER TABLE t1 CHANGE c1 c1 SERIAL;
-SELECT * FROM t1;
-c1	c2
-1	1
-2	2
-INSERT INTO t1 VALUES(NULL, 3);
-INSERT INTO t1 VALUES(NULL, 4);
-SELECT * FROM t1;
-c1	c2
-1	1
-2	2
-3	3
-4	4
-DROP TABLE t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-DROP TABLE IF EXISTS t2;
-Warnings:
-Note	1051	Unknown table 't2'
-CREATE TABLE t1 (
-a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
-b INT(10) UNSIGNED NOT NULL,
-c ENUM('FALSE','TRUE') DEFAULT NULL,
-PRIMARY KEY (a)) ENGINE = InnoDB;
-CREATE TABLE t2 (
-m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
-n INT(10) UNSIGNED NOT NULL,
-o enum('FALSE','TRUE') DEFAULT NULL,
-PRIMARY KEY (m)) ENGINE = InnoDB;
-INSERT INTO t2 (n,o) VALUES
-(1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
-(3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
-SHOW CREATE TABLE t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `m` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `n` int(10) unsigned NOT NULL,
-  `o` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`m`)
-) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
-SELECT * FROM t1;
-a	b	c
-1	1	TRUE
-2	1	FALSE
-3	2	TRUE
-4	2	FALSE
-5	3	TRUE
-6	3	FALSE
-7	4	TRUE
-8	4	FALSE
-9	5	TRUE
-10	5	FALSE
-13	1	TRUE
-14	1	FALSE
-15	2	TRUE
-16	2	FALSE
-17	3	TRUE
-18	3	FALSE
-19	4	TRUE
-20	4	FALSE
-21	5	TRUE
-22	5	FALSE
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-a	b	c
-1	1	TRUE
-2	1	FALSE
-3	2	TRUE
-4	2	FALSE
-5	3	TRUE
-6	3	FALSE
-7	4	TRUE
-8	4	FALSE
-9	5	TRUE
-10	5	FALSE
-13	1	TRUE
-14	1	FALSE
-15	2	TRUE
-16	2	FALSE
-17	3	TRUE
-18	3	FALSE
-19	4	TRUE
-20	4	FALSE
-21	5	TRUE
-22	5	FALSE
-23	1	FALSE
-24	2	FALSE
-25	3	FALSE
-26	4	FALSE
-27	5	FALSE
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-a	b	c
-1	1	TRUE
-2	1	FALSE
-3	2	TRUE
-4	2	FALSE
-5	3	TRUE
-6	3	FALSE
-7	4	TRUE
-8	4	FALSE
-9	5	TRUE
-10	5	FALSE
-13	1	TRUE
-14	1	FALSE
-15	2	TRUE
-16	2	FALSE
-17	3	TRUE
-18	3	FALSE
-19	4	TRUE
-20	4	FALSE
-21	5	TRUE
-22	5	FALSE
-23	1	FALSE
-24	2	FALSE
-25	3	FALSE
-26	4	FALSE
-27	5	FALSE
-30	1	FALSE
-31	2	FALSE
-32	3	FALSE
-33	4	FALSE
-34	5	FALSE
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-a	b	c
-1	1	TRUE
-2	1	FALSE
-3	2	TRUE
-4	2	FALSE
-5	3	TRUE
-6	3	FALSE
-7	4	TRUE
-8	4	FALSE
-9	5	TRUE
-10	5	FALSE
-13	1	TRUE
-14	1	FALSE
-15	2	TRUE
-16	2	FALSE
-17	3	TRUE
-18	3	FALSE
-19	4	TRUE
-20	4	FALSE
-21	5	TRUE
-22	5	FALSE
-23	1	FALSE
-24	2	FALSE
-25	3	FALSE
-26	4	FALSE
-27	5	FALSE
-30	1	FALSE
-31	2	FALSE
-32	3	FALSE
-33	4	FALSE
-34	5	FALSE
-37	1	FALSE
-38	2	FALSE
-39	3	FALSE
-40	4	FALSE
-41	5	FALSE
-44	1	FALSE
-45	2	FALSE
-46	3	FALSE
-47	4	FALSE
-48	5	FALSE
-51	1	FALSE
-52	2	FALSE
-53	3	FALSE
-54	4	FALSE
-55	5	FALSE
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `b` int(10) unsigned NOT NULL,
-  `c` enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (`a`)
-) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=latin1
-DROP TABLE t1;
-DROP TABLE t2;
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-DROP TABLE IF EXISTS t2;
-Warnings:
-Note	1051	Unknown table 't2'
-CREATE TABLE t1(
-c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
-PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-CREATE TABLE t2(
-c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
-PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t2 SELECT c1 FROM t1;
-Got one of the listed errors
-INSERT INTO t2 SELECT NULL FROM t1;
-Got one of the listed errors
-DROP TABLE t1;
-DROP TABLE t2;

=== added file 'mysql-test/r/innodb-index.result'
--- a/mysql-test/r/innodb-index.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-index.result	2009-06-11 12:53:26 +0000
@@ -0,0 +1,1137 @@
+SET @save_innodb_file_format_check=@@global.innodb_file_format_check;
+create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb;
+insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak');
+commit;
+alter table t1 add index b (b), add index b (b);
+ERROR 42000: Duplicate key name 'b'
+alter table t1 add index (b,b);
+ERROR 42S21: Duplicate column name 'b'
+alter table t1 add index d2 (d);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) NOT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  KEY `d2` (`d`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+explain select * from t1 force index(d2) order by d;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	d2	23	NULL	4	
+select * from t1 force index (d2) order by d;
+a	b	c	d
+3	4	ad	ad
+2	3	ak	ak
+5	5	oo	oo
+4	4	tr	tr
+alter table t1 add unique index (b);
+ERROR 23000: Duplicate entry '4' for key 'b'
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) NOT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  KEY `d2` (`d`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 add index (b);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) NOT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  KEY `d2` (`d`),
+  KEY `b` (`b`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB;
+call mtr.add_suppression(" table `test`\\.`t1#[12]` already exists in InnoDB internal");
+alter table t1 add unique index (c), add index (d);
+ERROR HY000: Table 'test.t1#1' already exists
+rename table `t1#1` to `t1#2`;
+alter table t1 add unique index (c), add index (d);
+ERROR HY000: Table 'test.t1#2' already exists
+drop table `t1#2`;
+alter table t1 add unique index (c), add index (d);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) NOT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  UNIQUE KEY `c` (`c`),
+  KEY `d2` (`d`),
+  KEY `b` (`b`),
+  KEY `d` (`d`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	c	10	NULL	4	
+alter table t1 add primary key (a), drop index c;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) NOT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  KEY `d2` (`d`),
+  KEY `b` (`b`),
+  KEY `d` (`d`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 add primary key (c);
+ERROR 42000: Multiple primary key defined
+alter table t1 drop primary key, add primary key (b);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+create unique index c on t1 (c);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) NOT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `c` (`c`),
+  KEY `d2` (`d`),
+  KEY `b` (`b`),
+  KEY `d` (`d`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	c	10	NULL	4	
+select * from t1 force index(c) order by c;
+a	b	c	d
+3	4	ad	ad
+2	3	ak	ak
+5	5	oo	oo
+4	4	tr	tr
+alter table t1 drop index b, add index (b);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) NOT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `c` (`c`),
+  KEY `d2` (`d`),
+  KEY `d` (`d`),
+  KEY `b` (`b`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values(6,1,'ggg','ggg');
+select * from t1;
+a	b	c	d
+2	3	ak	ak
+3	4	ad	ad
+4	4	tr	tr
+5	5	oo	oo
+6	1	ggg	ggg
+select * from t1 force index(b) order by b;
+a	b	c	d
+6	1	ggg	ggg
+2	3	ak	ak
+3	4	ad	ad
+4	4	tr	tr
+5	5	oo	oo
+select * from t1 force index(c) order by c;
+a	b	c	d
+3	4	ad	ad
+2	3	ak	ak
+6	1	ggg	ggg
+5	5	oo	oo
+4	4	tr	tr
+select * from t1 force index(d) order by d;
+a	b	c	d
+3	4	ad	ad
+2	3	ak	ak
+6	1	ggg	ggg
+5	5	oo	oo
+4	4	tr	tr
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	5	NULL	5	
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	c	10	NULL	5	
+explain select * from t1 force index(d) order by d;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	d	23	NULL	5	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) NOT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `c` (`c`),
+  KEY `d2` (`d`),
+  KEY `d` (`d`),
+  KEY `b` (`b`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe');
+commit;
+alter table t1 add index (c(2));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  KEY `c` (`c`(2))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 add unique index (d(10));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `d` (`d`(10)),
+  KEY `c` (`c`(2))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+insert into t1 values(5,1,'ggg','ggg');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	3	ad	ad
+4	4	afe	afe
+5	1	ggg	ggg
+select * from t1 force index(c) order by c;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	3	ad	ad
+4	4	afe	afe
+5	1	ggg	ggg
+select * from t1 force index(d) order by d;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	3	ad	ad
+4	4	afe	afe
+5	1	ggg	ggg
+explain select * from t1 order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	5	Using filesort
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	5	Using filesort
+explain select * from t1 force index(d) order by d;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	5	Using filesort
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `d` (`d`(10)),
+  KEY `c` (`c`(2))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 drop index d;
+insert into t1 values(8,9,'fff','fff');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	3	ad	ad
+4	4	afe	afe
+5	1	ggg	ggg
+8	9	fff	fff
+select * from t1 force index(c) order by c;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	3	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+5	1	ggg	ggg
+explain select * from t1 order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	6	Using filesort
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	6	Using filesort
+explain select * from t1 order by d;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	6	Using filesort
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  KEY `c` (`c`(2))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
+commit;
+alter table t1 add unique index (b,c);
+insert into t1 values(8,9,'fff','fff');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+select * from t1 force index(b) order by b;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	16	NULL	5	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `b` (`b`,`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 add index (b,c);
+insert into t1 values(11,11,'kkk','kkk');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+11	11	kkk	kkk
+select * from t1 force index(b) order by b;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+11	11	kkk	kkk
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	16	NULL	6	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `b` (`b`,`c`),
+  KEY `b_2` (`b`,`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 add unique index (c,d);
+insert into t1 values(13,13,'yyy','aaa');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+11	11	kkk	kkk
+13	13	yyy	aaa
+select * from t1 force index(b) order by b;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+11	11	kkk	kkk
+13	13	yyy	aaa
+select * from t1 force index(c) order by c;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+11	11	kkk	kkk
+13	13	yyy	aaa
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	16	NULL	7	
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	c	34	NULL	7	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `b` (`b`,`c`),
+  UNIQUE KEY `c` (`c`,`d`),
+  KEY `b_2` (`b`,`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb;
+create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb;
+create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb;
+create table t2(a int not null, b int not null, c int not null, d int not null, e int,
+foreign key (b) references t1(b) on delete cascade,
+foreign key (c) references t3(c), foreign key (d) references t4(d))
+engine = innodb;
+alter table t1 drop index b;
+ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint
+alter table t3 drop index c;
+ERROR HY000: Cannot drop index 'c': needed in a foreign key constraint
+alter table t4 drop index d;
+ERROR HY000: Cannot drop index 'd': needed in a foreign key constraint
+alter table t2 drop index b;
+ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint
+alter table t2 drop index b, drop index c, drop index d;
+ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint
+create unique index dc on t2 (d,c);
+create index dc on t1 (b,c);
+alter table t2 add primary key (a);
+insert into t1 values (1,1,1);
+insert into t3 values (1,1,1);
+insert into t4 values (1,1,1);
+insert into t2 values (1,1,1,1,1);
+commit;
+alter table t4 add constraint dc foreign key (a) references t1(a);
+show create table t4;
+Table	Create Table
+t4	CREATE TABLE `t4` (
+  `a` int(11) NOT NULL,
+  `d` int(11) NOT NULL,
+  `e` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  KEY `d` (`d`),
+  CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t3 add constraint dc foreign key (a) references t1(a);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 121)
+show create table t3;
+Table	Create Table
+t3	CREATE TABLE `t3` (
+  `a` int(11) NOT NULL,
+  `c` int(11) NOT NULL,
+  `d` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  KEY `c` (`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t2 drop index b, add index (b);
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` int(11) NOT NULL,
+  `b` int(11) NOT NULL,
+  `c` int(11) NOT NULL,
+  `d` int(11) NOT NULL,
+  `e` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `dc` (`d`,`c`),
+  KEY `c` (`c`),
+  KEY `b` (`b`),
+  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`b`) ON DELETE CASCADE,
+  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t3` (`c`),
+  CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`d`) REFERENCES `t4` (`d`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+delete from t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+drop index dc on t4;
+ERROR 42000: Can't DROP 'dc'; check that column/key exists
+alter table t3 drop foreign key dc;
+ERROR HY000: Error on rename of './test/t3' to '#sql2-temporary' (errno: 152)
+alter table t4 drop foreign key dc;
+select * from t2;
+a	b	c	d	e
+1	1	1	1	1
+delete from t1;
+select * from t2;
+a	b	c	d	e
+drop table t2,t4,t3,t1;
+create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=utf8;
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
+commit;
+alter table t1 add unique index (b);
+ERROR 23000: Duplicate entry '2' for key 'b'
+insert into t1 values(8,9,'fff','fff');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+alter table t1 add index (b);
+insert into t1 values(10,10,'kkk','iii');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+select * from t1 force index(b) order by b;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	5	NULL	6	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  KEY `b` (`b`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+alter table t1 add unique index (c), add index (d);
+insert into t1 values(11,11,'aaa','mmm');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+11	11	aaa	mmm
+select * from t1 force index(b) order by b;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+11	11	aaa	mmm
+select * from t1 force index(c) order by c;
+a	b	c	d
+11	11	aaa	mmm
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+select * from t1 force index(d) order by d;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+11	11	aaa	mmm
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	5	NULL	7	
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	c	31	NULL	7	
+explain select * from t1 force index(d) order by d;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	d	63	NULL	7	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `c` (`c`),
+  KEY `b` (`b`),
+  KEY `d` (`d`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+drop table t1;
+create table t1(a int not null, b int) engine = innodb;
+insert into t1 values (1,1),(1,1),(1,1),(1,1);
+alter table t1 add unique index (a);
+ERROR 23000: Duplicate entry '1' for key 'a'
+alter table t1 add unique index (b);
+ERROR 23000: Duplicate entry '1' for key 'b'
+alter table t1 add unique index (a), add unique index(b);
+ERROR 23000: Duplicate entry '1' for key 'a'
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int not null, c int not null,b int, primary key(a), unique key(c), key(b)) engine = innodb;
+alter table t1 drop index c, drop index b;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `c` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int not null, b int, primary key(a)) engine = innodb;
+alter table t1 add index (b);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  KEY `b` (`b`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ac','ac'),(4,4,'afe','afe'),(5,4,'affe','affe');
+alter table t1 add unique index (b), add unique index (c), add unique index (d);
+ERROR 23000: Duplicate entry '4' for key 'b'
+alter table t1 add unique index (c), add unique index (b), add index (d);
+ERROR 23000: Duplicate entry 'ac' for key 'c'
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb;
+insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1);
+alter table t1 add unique index (b);
+insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) NOT NULL,
+  `c` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `b` (`b`),
+  KEY `c` (`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	c	5	NULL	9	
+explain select * from t1 order by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	9	
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	4	NULL	9	
+select * from t1 order by a;
+a	b	c
+1	5	1
+2	4	2
+3	3	3
+4	2	4
+5	1	5
+10	20	20
+11	19	19
+12	18	18
+13	17	17
+select * from t1 force index(b) order by b;
+a	b	c
+5	1	5
+4	2	4
+3	3	3
+2	4	2
+1	5	1
+13	17	17
+12	18	18
+11	19	19
+10	20	20
+select * from t1 force index(c) order by c;
+a	b	c
+1	5	1
+2	4	2
+3	3	3
+4	2	4
+5	1	5
+13	17	17
+12	18	18
+11	19	19
+10	20	20
+drop table t1;
+create table t1(a int not null, b int not null) engine=innodb;
+insert into t1 values (1,1);
+alter table t1 add primary key(b);
+insert into t1 values (2,2);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) NOT NULL,
+  PRIMARY KEY (`b`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+select * from t1;
+a	b
+1	1
+2	2
+explain select * from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+explain select * from t1 order by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using filesort
+explain select * from t1 order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	2	
+checksum table t1;
+Table	Checksum
+test.t1	582702641
+drop table t1;
+create table t1(a int not null) engine=innodb;
+insert into t1 values (1);
+alter table t1 add primary key(a);
+insert into t1 values (2);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+commit;
+select * from t1;
+a
+1
+2
+explain select * from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	2	Using index
+explain select * from t1 order by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	2	Using index
+drop table t1;
+create table t2(d varchar(17) primary key) engine=innodb default charset=utf8;
+create table t3(a int primary key) engine=innodb;
+insert into t3 values(22),(44),(33),(55),(66);
+insert into t2 values ('jejdkrun87'),('adfd72nh9k'),
+('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik');
+create table t1(a int, b blob, c text, d text not null)
+engine=innodb default charset = utf8;
+insert into t1
+select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3;
+drop table t2, t3;
+select count(*) from t1 where a=44;
+count(*)
+5
+select a,
+length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
+a	length(b)	b=left(repeat(d,100*a),65535)	length(c)	c=repeat(d,20*a)	d
+22	22000	1	4400	1	adfd72nh9k
+22	35200	1	7040	1	adfdijn0loKNHJik
+22	28600	1	5720	1	adfdijnmnb78k
+22	26400	1	5280	1	adfdpplkeock
+22	22000	1	4400	1	jejdkrun87
+33	33000	1	6600	1	adfd72nh9k
+33	52800	1	10560	1	adfdijn0loKNHJik
+33	42900	1	8580	1	adfdijnmnb78k
+33	39600	1	7920	1	adfdpplkeock
+33	33000	1	6600	1	jejdkrun87
+44	44000	1	8800	1	adfd72nh9k
+44	65535	1	14080	1	adfdijn0loKNHJik
+44	57200	1	11440	1	adfdijnmnb78k
+44	52800	1	10560	1	adfdpplkeock
+44	44000	1	8800	1	jejdkrun87
+55	55000	1	11000	1	adfd72nh9k
+55	65535	1	17600	1	adfdijn0loKNHJik
+55	65535	1	14300	1	adfdijnmnb78k
+55	65535	1	13200	1	adfdpplkeock
+55	55000	1	11000	1	jejdkrun87
+66	65535	1	13200	1	adfd72nh9k
+66	65535	1	21120	1	adfdijn0loKNHJik
+66	65535	1	17160	1	adfdijnmnb78k
+66	65535	1	15840	1	adfdpplkeock
+66	65535	1	13200	1	jejdkrun87
+alter table t1 add primary key (a), add key (b(20));
+ERROR 23000: Duplicate entry '22' for key 'PRIMARY'
+delete from t1 where a%2;
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+alter table t1 add primary key (a,b(255),c(255)), add key (b(767));
+select count(*) from t1 where a=44;
+count(*)
+5
+select a,
+length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
+a	length(b)	b=left(repeat(d,100*a),65535)	length(c)	c=repeat(d,20*a)	d
+22	22000	1	4400	1	adfd72nh9k
+22	35200	1	7040	1	adfdijn0loKNHJik
+22	28600	1	5720	1	adfdijnmnb78k
+22	26400	1	5280	1	adfdpplkeock
+22	22000	1	4400	1	jejdkrun87
+44	44000	1	8800	1	adfd72nh9k
+44	65535	1	14080	1	adfdijn0loKNHJik
+44	57200	1	11440	1	adfdijnmnb78k
+44	52800	1	10560	1	adfdpplkeock
+44	44000	1	8800	1	jejdkrun87
+66	65535	1	13200	1	adfd72nh9k
+66	65535	1	21120	1	adfdijn0loKNHJik
+66	65535	1	17160	1	adfdijnmnb78k
+66	65535	1	15840	1	adfdpplkeock
+66	65535	1	13200	1	jejdkrun87
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL DEFAULT '0',
+  `b` blob NOT NULL,
+  `c` text NOT NULL,
+  `d` text NOT NULL,
+  PRIMARY KEY (`a`,`b`(255),`c`(255)),
+  KEY `b` (`b`(767))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+explain select * from t1 where b like 'adfd%';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	b	NULL	NULL	NULL	15	Using where
+create table t2(a int, b varchar(255), primary key(a,b)) engine=innodb;
+insert into t2 select a,left(b,255) from t1;
+drop table t1;
+rename table t2 to t1;
+set innodb_lock_wait_timeout=1;
+begin;
+select a from t1 limit 1 for update;
+a
+22
+set innodb_lock_wait_timeout=1;
+create index t1ba on t1 (b,a);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+commit;
+begin;
+select a from t1 limit 1 lock in share mode;
+a
+22
+create index t1ba on t1 (b,a);
+drop index t1ba on t1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+commit;
+explain select a from t1 order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	t1ba	261	NULL	15	Using index
+select a,sleep(2+a/100) from t1 order by b limit 3;
+select sleep(1);
+sleep(1)
+0
+drop index t1ba on t1;
+a	sleep(2+a/100)
+22	0
+44	0
+66	0
+explain select a from t1 order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	261	NULL	15	Using index; Using filesort
+select a from t1 order by b limit 3;
+a
+22
+66
+44
+commit;
+drop table t1;
+set global innodb_file_per_table=on;
+set global innodb_file_format='Barracuda';
+create table t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob,
+i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob,
+q blob,r blob,s blob,t blob,u blob)
+engine=innodb row_format=dynamic;
+create index t1a on t1 (a(1));
+create index t1b on t1 (b(1));
+create index t1c on t1 (c(1));
+create index t1d on t1 (d(1));
+create index t1e on t1 (e(1));
+create index t1f on t1 (f(1));
+create index t1g on t1 (g(1));
+create index t1h on t1 (h(1));
+create index t1i on t1 (i(1));
+create index t1j on t1 (j(1));
+create index t1k on t1 (k(1));
+create index t1l on t1 (l(1));
+create index t1m on t1 (m(1));
+create index t1n on t1 (n(1));
+create index t1o on t1 (o(1));
+create index t1p on t1 (p(1));
+create index t1q on t1 (q(1));
+create index t1r on t1 (r(1));
+create index t1s on t1 (s(1));
+create index t1t on t1 (t(1));
+create index t1u on t1 (u(1));
+ERROR HY000: Too big row
+create index t1ut on t1 (u(1), t(1));
+ERROR HY000: Too big row
+create index t1st on t1 (s(1), t(1));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` blob,
+  `b` blob,
+  `c` blob,
+  `d` blob,
+  `e` blob,
+  `f` blob,
+  `g` blob,
+  `h` blob,
+  `i` blob,
+  `j` blob,
+  `k` blob,
+  `l` blob,
+  `m` blob,
+  `n` blob,
+  `o` blob,
+  `p` blob,
+  `q` blob,
+  `r` blob,
+  `s` blob,
+  `t` blob,
+  `u` blob,
+  KEY `t1a` (`a`(1)),
+  KEY `t1b` (`b`(1)),
+  KEY `t1c` (`c`(1)),
+  KEY `t1d` (`d`(1)),
+  KEY `t1e` (`e`(1)),
+  KEY `t1f` (`f`(1)),
+  KEY `t1g` (`g`(1)),
+  KEY `t1h` (`h`(1)),
+  KEY `t1i` (`i`(1)),
+  KEY `t1j` (`j`(1)),
+  KEY `t1k` (`k`(1)),
+  KEY `t1l` (`l`(1)),
+  KEY `t1m` (`m`(1)),
+  KEY `t1n` (`n`(1)),
+  KEY `t1o` (`o`(1)),
+  KEY `t1p` (`p`(1)),
+  KEY `t1q` (`q`(1)),
+  KEY `t1r` (`r`(1)),
+  KEY `t1s` (`s`(1)),
+  KEY `t1t` (`t`(1)),
+  KEY `t1st` (`s`(1),`t`(1))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
+create index t1u on t1 (u(1));
+ERROR HY000: Too big row
+alter table t1 row_format=compact;
+create index t1u on t1 (u(1));
+drop table t1;
+set global innodb_file_per_table=0;
+set global innodb_file_format=Antelope;
+SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
+SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
+CREATE TABLE t1(
+c1	BIGINT(12) NOT NULL,
+PRIMARY KEY (c1)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+CREATE TABLE t2(
+c1	BIGINT(16) NOT NULL,
+c2	BIGINT(12) NOT NULL,
+c3	BIGINT(12) NOT NULL,
+PRIMARY KEY (c1)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+FOREIGN KEY (c3) REFERENCES t1(c1);
+SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
+SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `c1` bigint(16) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  `c3` bigint(12) NOT NULL,
+  PRIMARY KEY (`c1`),
+  KEY `fk_t2_ca` (`c3`),
+  CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `c1` bigint(16) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  `c3` bigint(12) NOT NULL,
+  PRIMARY KEY (`c1`),
+  KEY `i_t2_c3_c2` (`c3`,`c2`),
+  CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
+SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
+INSERT INTO t2 VALUES(0,0,0);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`))
+INSERT INTO t1 VALUES(0);
+INSERT INTO t2 VALUES(0,0,0);
+DROP TABLE t2;
+CREATE TABLE t2(
+c1	BIGINT(16) NOT NULL,
+c2	BIGINT(12) NOT NULL,
+c3	BIGINT(12) NOT NULL,
+PRIMARY KEY (c1,c2,c3)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+FOREIGN KEY (c3) REFERENCES t1(c1);
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `c1` bigint(16) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  `c3` bigint(12) NOT NULL,
+  PRIMARY KEY (`c1`,`c2`,`c3`),
+  KEY `fk_t2_ca` (`c3`),
+  CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `c1` bigint(16) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  `c3` bigint(12) NOT NULL,
+  PRIMARY KEY (`c1`,`c2`,`c3`),
+  KEY `i_t2_c3_c2` (`c3`,`c2`),
+  CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+INSERT INTO t2 VALUES(0,0,1);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`))
+INSERT INTO t2 VALUES(0,0,0);
+DELETE FROM t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`))
+DELETE FROM t2;
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1(
+c1	BIGINT(12) NOT NULL,
+c2	INT(4) NOT NULL,
+PRIMARY KEY (c2,c1)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+CREATE TABLE t2(
+c1	BIGINT(16) NOT NULL,
+c2	BIGINT(12) NOT NULL,
+c3	BIGINT(12) NOT NULL,
+PRIMARY KEY (c1)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+ALTER TABLE t1 MODIFY COLUMN c2 BIGINT(12) NOT NULL;
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` bigint(12) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  PRIMARY KEY (`c2`,`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `c1` bigint(16) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  `c3` bigint(12) NOT NULL,
+  PRIMARY KEY (`c1`),
+  KEY `fk_t2_ca` (`c3`,`c2`),
+  CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+CREATE INDEX i_t2_c2_c1 ON t2(c2, c1);
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `c1` bigint(16) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  `c3` bigint(12) NOT NULL,
+  PRIMARY KEY (`c1`),
+  KEY `fk_t2_ca` (`c3`,`c2`),
+  KEY `i_t2_c2_c1` (`c2`,`c1`),
+  CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+CREATE INDEX i_t2_c3_c1_c2 ON t2(c3, c1, c2);
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `c1` bigint(16) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  `c3` bigint(12) NOT NULL,
+  PRIMARY KEY (`c1`),
+  KEY `fk_t2_ca` (`c3`,`c2`),
+  KEY `i_t2_c2_c1` (`c2`,`c1`),
+  KEY `i_t2_c3_c1_c2` (`c3`,`c1`,`c2`),
+  CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `c1` bigint(16) NOT NULL,
+  `c2` bigint(12) NOT NULL,
+  `c3` bigint(12) NOT NULL,
+  PRIMARY KEY (`c1`),
+  KEY `i_t2_c2_c1` (`c2`,`c1`),
+  KEY `i_t2_c3_c1_c2` (`c3`,`c1`,`c2`),
+  KEY `i_t2_c3_c2` (`c3`,`c2`),
+  CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+SET GLOBAL innodb_file_format_check=@save_innodb_file_format_check;

=== added file 'mysql-test/r/innodb-index_ucs2.result'
--- a/mysql-test/r/innodb-index_ucs2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-index_ucs2.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,116 @@
+create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=ucs2;
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
+commit;
+alter table t1 add unique index (b);
+ERROR 23000: Duplicate entry '2' for key 'b'
+insert into t1 values(8,9,'fff','fff');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2
+alter table t1 add index (b);
+insert into t1 values(10,10,'kkk','iii');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+select * from t1 force index(b) order by b;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	5	NULL	6	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  KEY `b` (`b`)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2
+alter table t1 add unique index (c), add index (d);
+insert into t1 values(11,11,'aaa','mmm');
+select * from t1;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+11	11	aaa	mmm
+select * from t1 force index(b) order by b;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+11	11	aaa	mmm
+select * from t1 force index(c) order by c;
+a	b	c	d
+11	11	aaa	mmm
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+select * from t1 force index(d) order by d;
+a	b	c	d
+1	1	ab	ab
+2	2	ac	ac
+3	2	ad	ad
+4	4	afe	afe
+8	9	fff	fff
+10	10	kkk	iii
+11	11	aaa	mmm
+explain select * from t1 force index(b) order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	5	NULL	7	
+explain select * from t1 force index(c) order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	c	21	NULL	7	
+explain select * from t1 force index(d) order by d;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	d	43	NULL	7	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `d` varchar(20) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `c` (`c`),
+  KEY `b` (`b`),
+  KEY `d` (`d`)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+drop table t1;

=== added file 'mysql-test/r/innodb-lock.result'
--- a/mysql-test/r/innodb-lock.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-lock.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,57 @@
+set global innodb_table_locks=1;
+select @@innodb_table_locks;
+@@innodb_table_locks
+1
+drop table if exists t1;
+set @@innodb_table_locks=1;
+create table t1 (id integer, x integer) engine=INNODB;
+insert into t1 values(0, 0);
+set autocommit=0;
+SELECT * from t1 where id = 0 FOR UPDATE;
+id	x
+0	0
+set autocommit=0;
+lock table t1 write;
+update t1 set x=1 where id = 0;
+select * from t1;
+id	x
+0	1
+commit;
+update t1 set x=2 where id = 0;
+commit;
+unlock tables;
+select * from t1;
+id	x
+0	2
+commit;
+drop table t1;
+set @@innodb_table_locks=0;
+create table t1 (id integer primary key, x integer) engine=INNODB;
+insert into t1 values(0, 0),(1,1),(2,2);
+commit;
+SELECT * from t1 where id = 0 FOR UPDATE;
+id	x
+0	0
+set autocommit=0;
+set @@innodb_table_locks=0;
+lock table t1 write;
+update t1 set x=10 where id = 2;
+SELECT * from t1 where id = 2;
+id	x
+2	2
+UPDATE t1 set x=3 where id = 2;
+commit;
+SELECT * from t1;
+id	x
+0	0
+1	1
+2	3
+commit;
+unlock tables;
+commit;
+select * from t1;
+id	x
+0	0
+1	1
+2	10
+drop table t1;

=== removed file 'mysql-test/r/innodb-lock.result'
--- a/mysql-test/r/innodb-lock.result	2004-10-27 16:52:41 +0000
+++ b/mysql-test/r/innodb-lock.result	1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-set global innodb_table_locks=1;
-select @@innodb_table_locks;
-@@innodb_table_locks
-1
-drop table if exists t1;
-set @@innodb_table_locks=1;
-create table t1 (id integer, x integer) engine=INNODB;
-insert into t1 values(0, 0);
-set autocommit=0;
-SELECT * from t1 where id = 0 FOR UPDATE;
-id	x
-0	0
-set autocommit=0;
-lock table t1 write;
-update t1 set x=1 where id = 0;
-select * from t1;
-id	x
-0	1
-commit;
-update t1 set x=2 where id = 0;
-commit;
-unlock tables;
-select * from t1;
-id	x
-0	2
-commit;
-drop table t1;
-set @@innodb_table_locks=0;
-create table t1 (id integer primary key, x integer) engine=INNODB;
-insert into t1 values(0, 0),(1,1),(2,2);
-commit;
-SELECT * from t1 where id = 0 FOR UPDATE;
-id	x
-0	0
-set autocommit=0;
-set @@innodb_table_locks=0;
-lock table t1 write;
-update t1 set x=10 where id = 2;
-SELECT * from t1 where id = 2;
-id	x
-2	2
-UPDATE t1 set x=3 where id = 2;
-commit;
-SELECT * from t1;
-id	x
-0	0
-1	1
-2	3
-commit;
-unlock tables;
-commit;
-select * from t1;
-id	x
-0	0
-1	1
-2	10
-drop table t1;

=== added file 'mysql-test/r/innodb-replace.result'
--- a/mysql-test/r/innodb-replace.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-replace.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,13 @@
+drop table if exists t1;
+create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb;
+select * from t1;
+c1	c2	stamp
+replace delayed into t1 (c1, c2)  values ( "text1","11");
+ERROR HY000: DELAYED option not supported for table 't1'
+select * from t1;
+c1	c2	stamp
+replace delayed into t1 (c1, c2)  values ( "text1","12");
+ERROR HY000: DELAYED option not supported for table 't1'
+select * from t1;
+c1	c2	stamp
+drop table t1;

=== removed file 'mysql-test/r/innodb-replace.result'
--- a/mysql-test/r/innodb-replace.result	2008-06-03 11:25:41 +0000
+++ b/mysql-test/r/innodb-replace.result	1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
-drop table if exists t1;
-create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb;
-select * from t1;
-c1	c2	stamp
-replace delayed into t1 (c1, c2)  values ( "text1","11");
-ERROR HY000: DELAYED option not supported for table 't1'
-select * from t1;
-c1	c2	stamp
-replace delayed into t1 (c1, c2)  values ( "text1","12");
-ERROR HY000: DELAYED option not supported for table 't1'
-select * from t1;
-c1	c2	stamp
-drop table t1;

=== added file 'mysql-test/r/innodb-semi-consistent.result'
--- a/mysql-test/r/innodb-semi-consistent.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-semi-consistent.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,40 @@
+drop table if exists t1;
+set binlog_format=mixed;
+set session transaction isolation level repeatable read;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+set autocommit=0;
+select * from t1 where a=3 lock in share mode;
+a
+3
+set binlog_format=mixed;
+set session transaction isolation level repeatable read;
+set autocommit=0;
+update t1 set a=10 where a=5;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+commit;
+set session transaction isolation level read committed;
+update t1 set a=10 where a=5;
+select * from t1 where a=2 for update;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+select * from t1 where a=2 limit 1 for update;
+a
+2
+update t1 set a=11 where a=6;
+update t1 set a=12 where a=2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+update t1 set a=13 where a=1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+commit;
+update t1 set a=14 where a=1;
+commit;
+select * from t1;
+a
+14
+2
+3
+4
+10
+11
+7
+drop table t1;

=== removed file 'mysql-test/r/innodb-semi-consistent.result'
--- a/mysql-test/r/innodb-semi-consistent.result	2009-01-13 14:14:11 +0000
+++ b/mysql-test/r/innodb-semi-consistent.result	1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
-drop table if exists t1;
-set binlog_format=mixed;
-set session transaction isolation level repeatable read;
-create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into t1 values (1),(2),(3),(4),(5),(6),(7);
-set autocommit=0;
-select * from t1 where a=3 lock in share mode;
-a
-3
-set binlog_format=mixed;
-set session transaction isolation level repeatable read;
-set autocommit=0;
-update t1 set a=10 where a=5;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-commit;
-set session transaction isolation level read committed;
-update t1 set a=10 where a=5;
-select * from t1 where a=2 for update;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-select * from t1 where a=2 limit 1 for update;
-a
-2
-update t1 set a=11 where a=6;
-update t1 set a=12 where a=2;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-update t1 set a=13 where a=1;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-commit;
-update t1 set a=14 where a=1;
-commit;
-select * from t1;
-a
-14
-2
-3
-4
-10
-11
-7
-drop table t1;

=== added file 'mysql-test/r/innodb-timeout.result'
--- a/mysql-test/r/innodb-timeout.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-timeout.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,38 @@
+set global innodb_lock_wait_timeout=42;
+select @@innodb_lock_wait_timeout;
+@@innodb_lock_wait_timeout
+42
+set innodb_lock_wait_timeout=1;
+select @@innodb_lock_wait_timeout;
+@@innodb_lock_wait_timeout
+1
+select @@innodb_lock_wait_timeout;
+@@innodb_lock_wait_timeout
+42
+set global innodb_lock_wait_timeout=347;
+select @@innodb_lock_wait_timeout;
+@@innodb_lock_wait_timeout
+42
+set innodb_lock_wait_timeout=1;
+select @@innodb_lock_wait_timeout;
+@@innodb_lock_wait_timeout
+1
+select @@innodb_lock_wait_timeout;
+@@innodb_lock_wait_timeout
+347
+create table t1(a int primary key)engine=innodb;
+begin;
+insert into t1 values(1),(2),(3);
+select * from t1 for update;
+commit;
+a
+1
+2
+3
+begin;
+insert into t1 values(4);
+select * from t1 for update;
+commit;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+drop table t1;
+set global innodb_lock_wait_timeout=50;

=== added file 'mysql-test/r/innodb-use-sys-malloc.result'
--- a/mysql-test/r/innodb-use-sys-malloc.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-use-sys-malloc.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,48 @@
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+@@GLOBAL.innodb_use_sys_malloc
+1
+1 Expected
+SET @@GLOBAL.innodb_use_sys_malloc=0;
+ERROR HY000: Variable 'innodb_use_sys_malloc' is a read only variable
+Expected error 'Read only variable'
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+@@GLOBAL.innodb_use_sys_malloc
+1
+1 Expected
+drop table if exists t1;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+select * from t1;
+a
+1
+2
+3
+4
+5
+6
+7
+drop table t1;
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+@@GLOBAL.innodb_use_sys_malloc
+1
+1 Expected
+SET @@GLOBAL.innodb_use_sys_malloc=0;
+ERROR HY000: Variable 'innodb_use_sys_malloc' is a read only variable
+Expected error 'Read only variable'
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+@@GLOBAL.innodb_use_sys_malloc
+1
+1 Expected
+drop table if exists t1;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+select * from t1;
+a
+1
+2
+3
+4
+5
+6
+7
+drop table t1;

=== added file 'mysql-test/r/innodb-zip.result'
--- a/mysql-test/r/innodb-zip.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb-zip.result	2009-06-09 15:08:46 +0000
@@ -0,0 +1,421 @@
+set global innodb_file_per_table=off;
+set global innodb_file_format=`0`;
+create table t0(a int primary key) engine=innodb row_format=compressed;
+Warnings:
+Warning	1478	InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table.
+Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
+create table t00(a int primary key) engine=innodb
+key_block_size=4 row_format=compressed;
+Warnings:
+Warning	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Warning	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=4.
+Warning	1478	InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table.
+Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
+create table t1(a int primary key) engine=innodb row_format=dynamic;
+Warnings:
+Warning	1478	InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
+Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
+create table t2(a int primary key) engine=innodb row_format=redundant;
+create table t3(a int primary key) engine=innodb row_format=compact;
+create table t4(a int primary key) engine=innodb key_block_size=9;
+Warnings:
+Warning	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Warning	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=9.
+create table t5(a int primary key) engine=innodb
+key_block_size=1 row_format=redundant;
+Warnings:
+Warning	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Warning	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=1.
+set global innodb_file_per_table=on;
+create table t6(a int primary key) engine=innodb
+key_block_size=1 row_format=redundant;
+Warnings:
+Warning	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=1.
+set global innodb_file_format=`1`;
+create table t7(a int primary key) engine=innodb
+key_block_size=1 row_format=redundant;
+Warnings:
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=1 unless ROW_FORMAT=COMPRESSED.
+create table t8(a int primary key) engine=innodb
+key_block_size=1 row_format=fixed;
+Warnings:
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=1 unless ROW_FORMAT=COMPRESSED.
+Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
+create table t9(a int primary key) engine=innodb
+key_block_size=1 row_format=compact;
+Warnings:
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=1 unless ROW_FORMAT=COMPRESSED.
+create table t10(a int primary key) engine=innodb
+key_block_size=1 row_format=dynamic;
+Warnings:
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=1 unless ROW_FORMAT=COMPRESSED.
+create table t11(a int primary key) engine=innodb
+key_block_size=1 row_format=compressed;
+create table t12(a int primary key) engine=innodb
+key_block_size=1;
+create table t13(a int primary key) engine=innodb
+row_format=compressed;
+create table t14(a int primary key) engine=innodb key_block_size=9;
+Warnings:
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=9.
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t0	Compact
+test	t00	Compact
+test	t1	Compact
+test	t10	Dynamic
+test	t11	Compressed
+test	t12	Compressed
+test	t13	Compressed
+test	t14	Compact
+test	t2	Redundant
+test	t3	Compact
+test	t4	Compact
+test	t5	Redundant
+test	t6	Redundant
+test	t7	Redundant
+test	t8	Compact
+test	t9	Compact
+drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
+alter table t1 key_block_size=0;
+Warnings:
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=0.
+alter table t1 row_format=dynamic;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t1	Dynamic
+alter table t1 row_format=compact;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t1	Compact
+alter table t1 row_format=redundant;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t1	Redundant
+drop table t1;
+create table t1(a int not null, b text, index(b(10))) engine=innodb
+key_block_size=1;
+create table t2(b text)engine=innodb;
+insert into t2 values(concat('1abcdefghijklmnopqrstuvwxyz', repeat('A',5000)));
+insert into t1 select 1, b from t2;
+commit;
+begin;
+update t1 set b=repeat('B',100);
+select a,left(b,40) from t1 natural join t2;
+a	left(b,40)
+1	1abcdefghijklmnopqrstuvwxyzAAAAAAAAAAAAA
+rollback;
+select a,left(b,40) from t1 natural join t2;
+a	left(b,40)
+1	1abcdefghijklmnopqrstuvwxyzAAAAAAAAAAAAA
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t1	Compressed
+test	t2	Compact
+drop table t1,t2;
+SET SESSION innodb_strict_mode = off;
+CREATE TABLE t1(
+c TEXT NOT NULL, d TEXT NOT NULL,
+PRIMARY KEY (c(767),d(767)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
+ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
+CREATE TABLE t1(
+c TEXT NOT NULL, d TEXT NOT NULL,
+PRIMARY KEY (c(767),d(767)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 CHARSET=ASCII;
+ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
+CREATE TABLE t1(
+c TEXT NOT NULL, d TEXT NOT NULL,
+PRIMARY KEY (c(767),d(767)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 CHARSET=ASCII;
+drop table t1;
+CREATE TABLE t1(c TEXT, PRIMARY KEY (c(440)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
+ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
+CREATE TABLE t1(c TEXT, PRIMARY KEY (c(438)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
+INSERT INTO t1 VALUES(REPEAT('A',512)),(REPEAT('B',512));
+DROP TABLE t1;
+create table t1( c1 int not null, c2 blob, c3 blob, c4 blob,
+primary key(c1, c2(22), c3(22)))
+engine = innodb row_format = dynamic;
+begin;
+insert into t1 values(1, repeat('A', 20000), repeat('B', 20000),
+repeat('C', 20000));
+update t1 set c3 = repeat('D', 20000) where c1 = 1;
+commit;
+select count(*) from t1 where c2 = repeat('A', 20000);
+count(*)
+1
+select count(*) from t1 where c3 = repeat('D', 20000);
+count(*)
+1
+select count(*) from t1 where c4 = repeat('C', 20000);
+count(*)
+1
+update t1 set c3 = repeat('E', 20000) where c1 = 1;
+drop table t1;
+set global innodb_file_format=`0`;
+select @@innodb_file_format;
+@@innodb_file_format
+Antelope
+set global innodb_file_format=`1`;
+select @@innodb_file_format;
+@@innodb_file_format
+Barracuda
+set global innodb_file_format=`2`;
+ERROR HY000: Incorrect arguments to SET
+set global innodb_file_format=`-1`;
+ERROR HY000: Incorrect arguments to SET
+set global innodb_file_format=`Antelope`;
+set global innodb_file_format=`Barracuda`;
+set global innodb_file_format=`Cheetah`;
+ERROR HY000: Incorrect arguments to SET
+set global innodb_file_format=`abc`;
+ERROR HY000: Incorrect arguments to SET
+set global innodb_file_format=`1a`;
+ERROR HY000: Incorrect arguments to SET
+set global innodb_file_format=``;
+ERROR HY000: Incorrect arguments to SET
+set global innodb_file_per_table = on;
+set global innodb_file_format = `1`;
+set innodb_strict_mode = off;
+create table t1 (id int primary key) engine = innodb key_block_size = 0;
+Warnings:
+Warning	1478	InnoDB: ignoring KEY_BLOCK_SIZE=0.
+drop table t1;
+set innodb_strict_mode = on;
+create table t1 (id int primary key) engine = innodb key_block_size = 0;
+ERROR HY000: Can't create table 'test.t1' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: invalid KEY_BLOCK_SIZE = 0. Valid values are [1, 2, 4, 8, 16]
+Error	1005	Can't create table 'test.t1' (errno: 1478)
+create table t2 (id int primary key) engine = innodb key_block_size = 9;
+ERROR HY000: Can't create table 'test.t2' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
+Error	1005	Can't create table 'test.t2' (errno: 1478)
+create table t3 (id int primary key) engine = innodb key_block_size = 1;
+create table t4 (id int primary key) engine = innodb key_block_size = 2;
+create table t5 (id int primary key) engine = innodb key_block_size = 4;
+create table t6 (id int primary key) engine = innodb key_block_size = 8;
+create table t7 (id int primary key) engine = innodb key_block_size = 16;
+create table t8 (id int primary key) engine = innodb row_format = compressed;
+create table t9 (id int primary key) engine = innodb row_format = dynamic;
+create table t10(id int primary key) engine = innodb row_format = compact;
+create table t11(id int primary key) engine = innodb row_format = redundant;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t10	Compact
+test	t11	Redundant
+test	t3	Compressed
+test	t4	Compressed
+test	t5	Compressed
+test	t6	Compressed
+test	t7	Compressed
+test	t8	Compressed
+test	t9	Dynamic
+drop table t3, t4, t5, t6, t7, t8, t9, t10, t11;
+create table t1 (id int primary key) engine = innodb
+key_block_size = 8 row_format = compressed;
+create table t2 (id int primary key) engine = innodb
+key_block_size = 8 row_format = redundant;
+ERROR HY000: Can't create table 'test.t2' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE.
+Error	1005	Can't create table 'test.t2' (errno: 1478)
+create table t3 (id int primary key) engine = innodb
+key_block_size = 8 row_format = compact;
+ERROR HY000: Can't create table 'test.t3' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
+Error	1005	Can't create table 'test.t3' (errno: 1478)
+create table t4 (id int primary key) engine = innodb
+key_block_size = 8 row_format = dynamic;
+ERROR HY000: Can't create table 'test.t4' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
+Error	1005	Can't create table 'test.t4' (errno: 1478)
+create table t5 (id int primary key) engine = innodb
+key_block_size = 8 row_format = default;
+ERROR HY000: Can't create table 'test.t5' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
+Error	1005	Can't create table 'test.t5' (errno: 1478)
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t1	Compressed
+drop table t1;
+create table t1 (id int primary key) engine = innodb
+key_block_size = 9 row_format = redundant;
+ERROR HY000: Can't create table 'test.t1' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
+Error	1478	InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE.
+Error	1005	Can't create table 'test.t1' (errno: 1478)
+create table t2 (id int primary key) engine = innodb
+key_block_size = 9 row_format = compact;
+ERROR HY000: Can't create table 'test.t2' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
+Error	1478	InnoDB: cannot specify ROW_FORMAT = COMPACT with KEY_BLOCK_SIZE.
+Error	1005	Can't create table 'test.t2' (errno: 1478)
+create table t2 (id int primary key) engine = innodb
+key_block_size = 9 row_format = dynamic;
+ERROR HY000: Can't create table 'test.t2' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16]
+Error	1478	InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE.
+Error	1005	Can't create table 'test.t2' (errno: 1478)
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+set global innodb_file_per_table = off;
+create table t1 (id int primary key) engine = innodb key_block_size = 1;
+ERROR HY000: Can't create table 'test.t1' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Error	1005	Can't create table 'test.t1' (errno: 1478)
+create table t2 (id int primary key) engine = innodb key_block_size = 2;
+ERROR HY000: Can't create table 'test.t2' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Error	1005	Can't create table 'test.t2' (errno: 1478)
+create table t3 (id int primary key) engine = innodb key_block_size = 4;
+ERROR HY000: Can't create table 'test.t3' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Error	1005	Can't create table 'test.t3' (errno: 1478)
+create table t4 (id int primary key) engine = innodb key_block_size = 8;
+ERROR HY000: Can't create table 'test.t4' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Error	1005	Can't create table 'test.t4' (errno: 1478)
+create table t5 (id int primary key) engine = innodb key_block_size = 16;
+ERROR HY000: Can't create table 'test.t5' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table.
+Error	1005	Can't create table 'test.t5' (errno: 1478)
+create table t6 (id int primary key) engine = innodb row_format = compressed;
+ERROR HY000: Can't create table 'test.t6' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table.
+Error	1005	Can't create table 'test.t6' (errno: 1478)
+create table t7 (id int primary key) engine = innodb row_format = dynamic;
+ERROR HY000: Can't create table 'test.t7' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
+Error	1005	Can't create table 'test.t7' (errno: 1478)
+create table t8 (id int primary key) engine = innodb row_format = compact;
+create table t9 (id int primary key) engine = innodb row_format = redundant;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t8	Compact
+test	t9	Redundant
+drop table t8, t9;
+set global innodb_file_per_table = on;
+set global innodb_file_format = `0`;
+create table t1 (id int primary key) engine = innodb key_block_size = 1;
+ERROR HY000: Can't create table 'test.t1' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Error	1005	Can't create table 'test.t1' (errno: 1478)
+create table t2 (id int primary key) engine = innodb key_block_size = 2;
+ERROR HY000: Can't create table 'test.t2' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Error	1005	Can't create table 'test.t2' (errno: 1478)
+create table t3 (id int primary key) engine = innodb key_block_size = 4;
+ERROR HY000: Can't create table 'test.t3' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Error	1005	Can't create table 'test.t3' (errno: 1478)
+create table t4 (id int primary key) engine = innodb key_block_size = 8;
+ERROR HY000: Can't create table 'test.t4' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Error	1005	Can't create table 'test.t4' (errno: 1478)
+create table t5 (id int primary key) engine = innodb key_block_size = 16;
+ERROR HY000: Can't create table 'test.t5' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope.
+Error	1005	Can't create table 'test.t5' (errno: 1478)
+create table t6 (id int primary key) engine = innodb row_format = compressed;
+ERROR HY000: Can't create table 'test.t6' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope.
+Error	1005	Can't create table 'test.t6' (errno: 1478)
+create table t7 (id int primary key) engine = innodb row_format = dynamic;
+ERROR HY000: Can't create table 'test.t7' (errno: 1478)
+show errors;
+Level	Code	Message
+Error	1478	InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope.
+Error	1005	Can't create table 'test.t7' (errno: 1478)
+create table t8 (id int primary key) engine = innodb row_format = compact;
+create table t9 (id int primary key) engine = innodb row_format = redundant;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+table_schema	table_name	row_format
+test	t8	Compact
+test	t9	Redundant
+drop table t8, t9;
+set global innodb_file_per_table=0;
+set global innodb_file_format=Antelope;
+set global innodb_file_per_table=on;
+set global innodb_file_format=`Barracuda`;
+set global innodb_file_format_check=`Antelope`;
+create table normal_table (
+c1 int
+) engine = innodb;
+select @@innodb_file_format_check;
+@@innodb_file_format_check
+Antelope
+create table zip_table (
+c1 int
+) engine = innodb key_block_size = 8;
+select @@innodb_file_format_check;
+@@innodb_file_format_check
+Barracuda
+set global innodb_file_format_check=`Antelope`;
+select @@innodb_file_format_check;
+@@innodb_file_format_check
+Antelope
+show table status;
+select @@innodb_file_format_check;
+@@innodb_file_format_check
+Barracuda
+drop table normal_table, zip_table;

=== added file 'mysql-test/r/innodb.result'
--- a/mysql-test/r/innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb.result	2009-06-09 15:08:46 +0000
@@ -0,0 +1,3310 @@
+drop table if exists t1,t2,t3,t4;
+drop database if exists mysqltest;
+create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
+insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
+select id, code, name from t1 order by id;
+id	code	name
+1	1	Tim
+2	1	Monty
+3	2	David
+4	2	Erik
+5	3	Sasha
+6	3	Jeremy
+7	4	Matt
+update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
+select id, code, name from t1 order by id;
+id	code	name
+2	1	Monty
+3	2	David
+4	2	Erik
+5	3	Sasha
+6	3	Jeremy
+7	4	Matt
+8	1	Sinisa
+update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
+select id, code, name from t1 order by id;
+id	code	name
+3	2	David
+4	2	Erik
+5	3	Sasha
+6	3	Jeremy
+7	4	Matt
+8	1	Sinisa
+12	1	Ralph
+drop table t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL auto_increment,
+parent_id int(11) DEFAULT '0' NOT NULL,
+level tinyint(4) DEFAULT '0' NOT NULL,
+PRIMARY KEY (id),
+KEY parent_id (parent_id),
+KEY level (level)
+) engine=innodb;
+INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
+update t1 set parent_id=parent_id+100;
+select * from t1 where parent_id=102;
+id	parent_id	level
+8	102	2
+9	102	2
+15	102	2
+update t1 set id=id+1000;
+update t1 set id=1024 where id=1009;
+Got one of the listed errors
+select * from t1;
+id	parent_id	level
+1001	100	0
+1002	101	1
+1003	101	1
+1004	101	1
+1005	101	1
+1006	101	1
+1007	101	1
+1008	102	2
+1009	102	2
+1015	102	2
+1016	103	2
+1017	103	2
+1018	103	2
+1019	103	2
+1020	103	2
+1021	104	2
+1022	104	2
+1024	104	2
+1025	105	2
+1026	105	2
+1027	105	2
+1028	105	2
+1029	105	2
+1030	105	2
+1031	106	2
+1032	106	2
+1033	106	2
+1034	106	2
+1035	106	2
+1036	107	2
+1037	107	2
+1038	107	2
+1040	107	2
+1157	100	0
+1179	105	2
+1183	104	2
+1193	105	2
+1202	107	2
+1203	107	2
+update ignore t1 set id=id+1;
+select * from t1;
+id	parent_id	level
+1001	100	0
+1002	101	1
+1003	101	1
+1004	101	1
+1005	101	1
+1006	101	1
+1007	101	1
+1008	102	2
+1010	102	2
+1015	102	2
+1016	103	2
+1017	103	2
+1018	103	2
+1019	103	2
+1020	103	2
+1021	104	2
+1023	104	2
+1024	104	2
+1025	105	2
+1026	105	2
+1027	105	2
+1028	105	2
+1029	105	2
+1030	105	2
+1031	106	2
+1032	106	2
+1033	106	2
+1034	106	2
+1035	106	2
+1036	107	2
+1037	107	2
+1039	107	2
+1041	107	2
+1158	100	0
+1180	105	2
+1184	104	2
+1194	105	2
+1202	107	2
+1204	107	2
+update ignore t1 set id=1023 where id=1010;
+select * from t1 where parent_id=102;
+id	parent_id	level
+1008	102	2
+1010	102	2
+1015	102	2
+explain select level from t1 where level=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	level	level	1	const	#	Using index
+explain select level,id from t1 where level=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	level	level	1	const	#	Using index
+explain select level,id,parent_id from t1 where level=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	level	level	1	const	#	
+select level,id from t1 where level=1;
+level	id
+1	1002
+1	1003
+1	1004
+1	1005
+1	1006
+1	1007
+select level,id,parent_id from t1 where level=1;
+level	id	parent_id
+1	1002	101
+1	1003	101
+1	1004	101
+1	1005	101
+1	1006	101
+1	1007	101
+optimize table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
+test.t1	optimize	status	OK
+show keys from t1;
+Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
+t1	0	PRIMARY	1	id	A	#	NULL	NULL		BTREE	
+t1	1	parent_id	1	parent_id	A	#	NULL	NULL		BTREE	
+t1	1	level	1	level	A	#	NULL	NULL		BTREE	
+drop table t1;
+CREATE TABLE t1 (
+gesuchnr int(11) DEFAULT '0' NOT NULL,
+benutzer_id int(11) DEFAULT '0' NOT NULL,
+PRIMARY KEY (gesuchnr,benutzer_id)
+) engine=innodb;
+replace into t1 (gesuchnr,benutzer_id) values (2,1);
+replace into t1 (gesuchnr,benutzer_id) values (1,1);
+replace into t1 (gesuchnr,benutzer_id) values (1,1);
+select * from t1;
+gesuchnr	benutzer_id
+1	1
+2	1
+drop table t1;
+create table t1 (a int) engine=innodb;
+insert into t1 values (1), (2);
+optimize table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
+test.t1	optimize	status	OK
+delete from t1 where a = 1;
+select * from t1;
+a
+2
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+drop table t1;
+create table t1 (a int,b varchar(20)) engine=innodb;
+insert into t1 values (1,""), (2,"testing");
+delete from t1 where a = 1;
+select * from t1;
+a	b
+2	testing
+create index skr on t1 (a);
+insert into t1 values (3,""), (4,"testing");
+analyze table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+show keys from t1;
+Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
+t1	1	skr	1	a	A	#	NULL	NULL	YES	BTREE	
+drop table t1;
+create table t1 (a int,b varchar(20),key(a)) engine=innodb;
+insert into t1 values (1,""), (2,"testing");
+select * from t1 where a = 1;
+a	b
+1	
+drop table t1;
+create table t1 (n int not null primary key) engine=innodb;
+set autocommit=0;
+insert into t1 values (4);
+rollback;
+select n, "after rollback" from t1;
+n	after rollback
+insert into t1 values (4);
+commit;
+select n, "after commit" from t1;
+n	after commit
+4	after commit
+commit;
+insert into t1 values (5);
+insert into t1 values (4);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+commit;
+select n, "after commit" from t1;
+n	after commit
+4	after commit
+5	after commit
+set autocommit=1;
+insert into t1 values (6);
+insert into t1 values (4);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+select n from t1;
+n
+4
+5
+6
+set autocommit=0;
+begin;
+savepoint `my_savepoint`;
+insert into t1 values (7);
+savepoint `savept2`;
+insert into t1 values (3);
+select n from t1;
+n
+3
+4
+5
+6
+7
+savepoint savept3;
+rollback to savepoint savept2;
+rollback to savepoint savept3;
+ERROR 42000: SAVEPOINT savept3 does not exist
+rollback to savepoint savept2;
+release savepoint `my_savepoint`;
+select n from t1;
+n
+4
+5
+6
+7
+rollback to savepoint `my_savepoint`;
+ERROR 42000: SAVEPOINT my_savepoint does not exist
+rollback to savepoint savept2;
+ERROR 42000: SAVEPOINT savept2 does not exist
+insert into t1 values (8);
+savepoint sv;
+commit;
+savepoint sv;
+set autocommit=1;
+rollback;
+drop table t1;
+create table t1 (n int not null primary key) engine=innodb;
+start transaction;
+insert into t1 values (4);
+flush tables with read lock;
+commit;
+unlock tables;
+commit;
+select * from t1;
+n
+4
+drop table t1;
+create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb;
+begin;
+insert into t1 values(1,'hamdouni');
+select id as afterbegin_id,nom as afterbegin_nom from t1;
+afterbegin_id	afterbegin_nom
+1	hamdouni
+rollback;
+select id as afterrollback_id,nom as afterrollback_nom from t1;
+afterrollback_id	afterrollback_nom
+set autocommit=0;
+insert into t1 values(2,'mysql');
+select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
+afterautocommit0_id	afterautocommit0_nom
+2	mysql
+rollback;
+select id as afterrollback_id,nom as afterrollback_nom from t1;
+afterrollback_id	afterrollback_nom
+set autocommit=1;
+drop table t1;
+CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb;
+insert into t1 values ('pippo', 12);
+insert into t1 values ('pippo', 12);
+ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY'
+delete from t1;
+delete from t1 where id = 'pippo';
+select * from t1;
+id	val
+insert into t1 values ('pippo', 12);
+set autocommit=0;
+delete from t1;
+rollback;
+select * from t1;
+id	val
+pippo	12
+delete from t1;
+commit;
+select * from t1;
+id	val
+drop table t1;
+create table t1 (a integer) engine=innodb;
+start transaction;
+rename table t1 to t2;
+create table t1 (b integer) engine=innodb;
+insert into t1 values (1);
+rollback;
+drop table t1;
+rename table t2 to t1;
+drop table t1;
+set autocommit=1;
+CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb;
+INSERT INTO t1 VALUES (1, 'Jochen');
+select * from t1;
+ID	NAME
+1	Jochen
+drop table t1;
+CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb;
+set autocommit=0;
+INSERT INTO t1  SET _userid='marc@xxxxxxxxxxxxx';
+COMMIT;
+SELECT * FROM t1;
+_userid
+marc@xxxxxxxxxxxxx
+SELECT _userid FROM t1 WHERE _userid='marc@xxxxxxxxxxxxx';
+_userid
+marc@xxxxxxxxxxxxx
+drop table t1;
+set autocommit=1;
+CREATE TABLE t1 (
+user_id int(10) DEFAULT '0' NOT NULL,
+name varchar(100),
+phone varchar(100),
+ref_email varchar(100) DEFAULT '' NOT NULL,
+detail varchar(200),
+PRIMARY KEY (user_id,ref_email)
+)engine=innodb;
+INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@xxxxxxxxxxx','xxx'),(10292,'shirish','2333604','shirish@xxxxxxxxx','ddsds'),(10292,'sonali','323232','sonali@xxxxxxxxx','filmstar');
+select * from t1 where user_id=10292;
+user_id	name	phone	ref_email	detail
+10292	sanjeev	29153373	sansh777@xxxxxxxxxxx	xxx
+10292	shirish	2333604	shirish@xxxxxxxxx	ddsds
+10292	sonali	323232	sonali@xxxxxxxxx	filmstar
+INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@xxxxxxxxxxx','xxx'),(10293,'shirish','2333604','shirish@xxxxxxxxx','ddsds');
+select * from t1 where user_id=10292;
+user_id	name	phone	ref_email	detail
+10292	sanjeev	29153373	sansh777@xxxxxxxxxxx	xxx
+10292	shirish	2333604	shirish@xxxxxxxxx	ddsds
+10292	sonali	323232	sonali@xxxxxxxxx	filmstar
+select * from t1 where user_id>=10292;
+user_id	name	phone	ref_email	detail
+10292	sanjeev	29153373	sansh777@xxxxxxxxxxx	xxx
+10292	shirish	2333604	shirish@xxxxxxxxx	ddsds
+10292	sonali	323232	sonali@xxxxxxxxx	filmstar
+10293	shirish	2333604	shirish@xxxxxxxxx	ddsds
+select * from t1 where user_id>10292;
+user_id	name	phone	ref_email	detail
+10293	shirish	2333604	shirish@xxxxxxxxx	ddsds
+select * from t1 where user_id<10292;
+user_id	name	phone	ref_email	detail
+10291	sanjeev	29153373	sansh777@xxxxxxxxxxx	xxx
+drop table t1;
+CREATE TABLE t1 (a int not null, b int not null,c int not null,
+key(a),primary key(a,b), unique(c),key(a),unique(b));
+show index from t1;
+Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
+t1	0	PRIMARY	1	a	A	#	NULL	NULL		BTREE	
+t1	0	PRIMARY	2	b	A	#	NULL	NULL		BTREE	
+t1	0	c	1	c	A	#	NULL	NULL		BTREE	
+t1	0	b	1	b	A	#	NULL	NULL		BTREE	
+t1	1	a	1	a	A	#	NULL	NULL		BTREE	
+t1	1	a_2	1	a	A	#	NULL	NULL		BTREE	
+drop table t1;
+create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
+alter table t1 engine=innodb;
+insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
+select * from t1;
+col1	col2
+1	1
+2	3
+3	4
+4	4
+5	2
+update t1 set col2='7' where col1='4';
+select * from t1;
+col1	col2
+1	1
+2	3
+3	4
+4	7
+5	2
+alter table t1 add co3 int not null;
+select * from t1;
+col1	col2	co3
+1	1	0
+2	3	0
+3	4	0
+4	7	0
+5	2	0
+update t1 set col2='9' where col1='2';
+select * from t1;
+col1	col2	co3
+1	1	0
+2	9	0
+3	4	0
+4	7	0
+5	2	0
+drop table t1;
+create table t1 (a int not null , b int, primary key (a)) engine = innodb;
+create table t2 (a int not null , b int, primary key (a)) engine = myisam;
+insert into t1 VALUES (1,3) , (2,3), (3,3);
+select * from t1;
+a	b
+1	3
+2	3
+3	3
+insert into t2 select * from t1;
+select * from t2;
+a	b
+1	3
+2	3
+3	3
+delete from t1 where b = 3;
+select * from t1;
+a	b
+insert into t1 select * from t2;
+select * from t1;
+a	b
+1	3
+2	3
+3	3
+select * from t2;
+a	b
+1	3
+2	3
+3	3
+drop table t1,t2;
+CREATE TABLE t1 (
+user_name varchar(12),
+password text,
+subscribed char(1),
+user_id int(11) DEFAULT '0' NOT NULL,
+quota bigint(20),
+weight double,
+access_date date,
+access_time time,
+approved datetime,
+dummy_primary_key int(11) NOT NULL auto_increment,
+PRIMARY KEY (dummy_primary_key)
+) ENGINE=innodb;
+INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
+INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
+INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
+INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
+INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
+select  user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
+user_name	password	subscribed	user_id	quota	weight	access_date	access_time	approved	dummy_primary_key
+user_0	somepassword	N	0	0	0	2000-09-07	23:06:59	2000-09-07 23:06:59	1
+user_1	somepassword	Y	1	1	1	2000-09-07	23:06:59	2000-09-07 23:06:59	2
+user_2	somepassword	N	2	2	1.4142135623731	2000-09-07	23:06:59	2000-09-07 23:06:59	3
+user_3	somepassword	Y	3	3	1.7320508075689	2000-09-07	23:06:59	2000-09-07 23:06:59	4
+user_4	somepassword	N	4	4	2	2000-09-07	23:06:59	2000-09-07 23:06:59	5
+drop table t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL auto_increment,
+parent_id int(11) DEFAULT '0' NOT NULL,
+level tinyint(4) DEFAULT '0' NOT NULL,
+KEY (id),
+KEY parent_id (parent_id),
+KEY level (level)
+) engine=innodb;
+INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
+INSERT INTO t1 values (179,5,2);
+update t1 set parent_id=parent_id+100;
+select * from t1 where parent_id=102;
+id	parent_id	level
+8	102	2
+9	102	2
+15	102	2
+update t1 set id=id+1000;
+update t1 set id=1024 where id=1009;
+select * from t1;
+id	parent_id	level
+1001	100	0
+1003	101	1
+1004	101	1
+1008	102	2
+1024	102	2
+1017	103	2
+1022	104	2
+1024	104	2
+1028	105	2
+1029	105	2
+1030	105	2
+1031	106	2
+1032	106	2
+1033	106	2
+1203	107	2
+1202	107	2
+1020	103	2
+1157	100	0
+1193	105	2
+1040	107	2
+1002	101	1
+1015	102	2
+1006	101	1
+1034	106	2
+1035	106	2
+1016	103	2
+1007	101	1
+1036	107	2
+1018	103	2
+1026	105	2
+1027	105	2
+1183	104	2
+1038	107	2
+1025	105	2
+1037	107	2
+1021	104	2
+1019	103	2
+1005	101	1
+1179	105	2
+update ignore t1 set id=id+1;
+select * from t1;
+id	parent_id	level
+1002	100	0
+1004	101	1
+1005	101	1
+1009	102	2
+1025	102	2
+1018	103	2
+1023	104	2
+1025	104	2
+1029	105	2
+1030	105	2
+1031	105	2
+1032	106	2
+1033	106	2
+1034	106	2
+1204	107	2
+1203	107	2
+1021	103	2
+1158	100	0
+1194	105	2
+1041	107	2
+1003	101	1
+1016	102	2
+1007	101	1
+1035	106	2
+1036	106	2
+1017	103	2
+1008	101	1
+1037	107	2
+1019	103	2
+1027	105	2
+1028	105	2
+1184	104	2
+1039	107	2
+1026	105	2
+1038	107	2
+1022	104	2
+1020	103	2
+1006	101	1
+1180	105	2
+update ignore t1 set id=1023 where id=1010;
+select * from t1 where parent_id=102;
+id	parent_id	level
+1009	102	2
+1025	102	2
+1016	102	2
+explain select level from t1 where level=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	level	level	1	const	#	Using index
+select level,id from t1 where level=1;
+level	id
+1	1004
+1	1005
+1	1003
+1	1007
+1	1008
+1	1006
+select level,id,parent_id from t1 where level=1;
+level	id	parent_id
+1	1004	101
+1	1005	101
+1	1003	101
+1	1007	101
+1	1008	101
+1	1006	101
+select level,id from t1 where level=1 order by id;
+level	id
+1	1003
+1	1004
+1	1005
+1	1006
+1	1007
+1	1008
+delete from t1 where level=1;
+select * from t1;
+id	parent_id	level
+1002	100	0
+1009	102	2
+1025	102	2
+1018	103	2
+1023	104	2
+1025	104	2
+1029	105	2
+1030	105	2
+1031	105	2
+1032	106	2
+1033	106	2
+1034	106	2
+1204	107	2
+1203	107	2
+1021	103	2
+1158	100	0
+1194	105	2
+1041	107	2
+1016	102	2
+1035	106	2
+1036	106	2
+1017	103	2
+1037	107	2
+1019	103	2
+1027	105	2
+1028	105	2
+1184	104	2
+1039	107	2
+1026	105	2
+1038	107	2
+1022	104	2
+1020	103	2
+1180	105	2
+drop table t1;
+CREATE TABLE t1 (
+sca_code char(6) NOT NULL,
+cat_code char(6) NOT NULL,
+sca_desc varchar(50),
+lan_code char(2) NOT NULL,
+sca_pic varchar(100),
+sca_sdesc varchar(50),
+sca_sch_desc varchar(16),
+PRIMARY KEY (sca_code, cat_code, lan_code),
+INDEX sca_pic (sca_pic)
+) engine = innodb ;
+INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
+select count(*) from t1 where sca_code = 'PD';
+count(*)
+1
+select count(*) from t1 where sca_code <= 'PD';
+count(*)
+1
+select count(*) from t1 where sca_pic is null;
+count(*)
+2
+alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
+select count(*) from t1 where sca_code='PD' and sca_pic is null;
+count(*)
+1
+select count(*) from t1 where cat_code='E';
+count(*)
+0
+alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
+select count(*) from t1 where sca_code='PD' and sca_pic is null;
+count(*)
+1
+select count(*) from t1 where sca_pic >= 'n';
+count(*)
+1
+select sca_pic from t1 where sca_pic is null;
+sca_pic
+NULL
+NULL
+update t1 set sca_pic="test" where sca_pic is null;
+delete from t1 where sca_code='pd';
+drop table t1;
+set @a:=now();
+CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
+insert into t1 (a) values(1),(2),(3);
+select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
+a
+1
+2
+3
+select a from t1 natural join t1 as t2 where b >= @a order by a;
+a
+1
+2
+3
+update t1 set a=5 where a=1;
+select a from t1;
+a
+2
+3
+5
+drop table t1;
+create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb;
+insert into t1 values("hello",1),("world",2);
+select * from t1 order by b desc;
+a	b
+world	2
+hello	1
+optimize table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
+test.t1	optimize	status	OK
+show keys from t1;
+Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
+t1	0	PRIMARY	1	a	A	#	NULL	NULL		BTREE	
+drop table t1;
+create table t1 (i int, j int ) ENGINE=innodb;
+insert into t1 values (1,2);
+select * from t1 where i=1 and j=2;
+i	j
+1	2
+create index ax1 on t1 (i,j);
+select * from t1 where i=1 and j=2;
+i	j
+1	2
+drop table t1;
+CREATE TABLE t1 (
+a int3 unsigned NOT NULL,
+b int1 unsigned NOT NULL,
+UNIQUE (a, b)
+) ENGINE = innodb;
+INSERT INTO t1 VALUES (1, 1);
+SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
+MIN(B)	MAX(b)
+1	1
+drop table t1;
+CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb;
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+a
+1
+DROP TABLE t1;
+create table t1 (a int  primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb;
+insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
+explain select * from t1 where a > 0 and a < 50;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	#	Using where
+drop table t1;
+create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
+insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
+LOCK TABLES t1 WRITE;
+insert into t1 values (99,1,2,'D'),(1,1,2,'D');
+ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
+select id from t1;
+id
+0
+1
+2
+select id from t1;
+id
+0
+1
+2
+UNLOCK TABLES;
+DROP TABLE t1;
+create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
+insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
+LOCK TABLES t1 WRITE;
+begin;
+insert into t1 values (99,1,2,'D'),(1,1,2,'D');
+ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
+select id from t1;
+id
+0
+1
+2
+insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
+commit;
+select id,id3 from t1;
+id	id3
+0	0
+1	1
+2	2
+100	2
+UNLOCK TABLES;
+DROP TABLE t1;
+create table t1 (a char(20), unique (a(5))) engine=innodb;
+drop table t1;
+create table t1 (a char(20), index (a(5))) engine=innodb;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` char(20) DEFAULT NULL,
+  KEY `a` (`a`(5))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;
+insert into t1 values (NULL),(NULL),(NULL);
+delete from t1 where a=3;
+insert into t1 values (NULL);
+select * from t1;
+a
+1
+2
+4
+alter table t1 add b int;
+select * from t1;
+a	b
+1	NULL
+2	NULL
+4	NULL
+drop table t1;
+create table t1
+(
+id int auto_increment primary key,
+name varchar(32) not null,
+value text not null,
+uid int not null,
+unique key(name,uid)
+) engine=innodb;
+insert into t1 values (1,'one','one value',101),
+(2,'two','two value',102),(3,'three','three value',103);
+set insert_id=5;
+replace into t1 (value,name,uid) values ('other value','two',102);
+delete from t1 where uid=102;
+set insert_id=5;
+replace into t1 (value,name,uid) values ('other value','two',102);
+set insert_id=6;
+replace into t1 (value,name,uid) values ('other value','two',102);
+select * from t1;
+id	name	value	uid
+1	one	one value	101
+3	three	three value	103
+6	two	other value	102
+drop table t1;
+create database mysqltest;
+create table mysqltest.t1 (a int not null) engine= innodb;
+insert into mysqltest.t1 values(1);
+create table mysqltest.t2 (a int not null) engine= myisam;
+insert into mysqltest.t2 values(1);
+create table mysqltest.t3 (a int not null) engine= heap;
+insert into mysqltest.t3 values(1);
+commit;
+drop database mysqltest;
+show tables from mysqltest;
+ERROR 42000: Unknown database 'mysqltest'
+set autocommit=0;
+create table t1 (a int not null) engine= innodb;
+insert into t1 values(1),(2);
+truncate table t1;
+commit;
+truncate table t1;
+truncate table t1;
+select * from t1;
+a
+insert into t1 values(1),(2);
+delete from t1;
+select * from t1;
+a
+commit;
+drop table t1;
+set autocommit=1;
+create table t1 (a int not null) engine= innodb;
+insert into t1 values(1),(2);
+truncate table t1;
+insert into t1 values(1),(2);
+select * from t1;
+a
+1
+2
+truncate table t1;
+insert into t1 values(1),(2);
+delete from t1;
+select * from t1;
+a
+drop table t1;
+create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb;
+insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
+explain select * from t1 order by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	#	
+explain select * from t1 order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	#	Using filesort
+explain select * from t1 order by c;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	#	Using filesort
+explain select a from t1 order by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	#	Using index
+explain select b from t1 order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	4	NULL	#	Using index
+explain select a,b from t1 order by b;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	4	NULL	#	Using index
+explain select a,b from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	b	4	NULL	#	Using index
+explain select a,b,c from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	#	
+drop table t1;
+create table t1 (t int not null default 1, key (t)) engine=innodb;
+desc t1;
+Field	Type	Null	Key	Default	Extra
+t	int(11)	NO	MUL	1	
+drop table t1;
+CREATE TABLE t1 (
+number bigint(20) NOT NULL default '0',
+cname char(15) NOT NULL default '',
+carrier_id smallint(6) NOT NULL default '0',
+privacy tinyint(4) NOT NULL default '0',
+last_mod_date timestamp NOT NULL,
+last_mod_id smallint(6) NOT NULL default '0',
+last_app_date timestamp NOT NULL,
+last_app_id smallint(6) default '-1',
+version smallint(6) NOT NULL default '0',
+assigned_scps int(11) default '0',
+status tinyint(4) default '0'
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
+INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
+INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
+INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
+INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
+INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
+CREATE TABLE t2 (
+number bigint(20) NOT NULL default '0',
+cname char(15) NOT NULL default '',
+carrier_id smallint(6) NOT NULL default '0',
+privacy tinyint(4) NOT NULL default '0',
+last_mod_date timestamp NOT NULL,
+last_mod_id smallint(6) NOT NULL default '0',
+last_app_date timestamp NOT NULL,
+last_app_id smallint(6) default '-1',
+version smallint(6) NOT NULL default '0',
+assigned_scps int(11) default '0',
+status tinyint(4) default '0'
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
+INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
+INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
+INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
+select * from t1;
+number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
+4077711111	SeanWheeler	90	2	2002-01-11 11:28:46	500	0000-00-00 00:00:00	-1	2	3	1
+9197722223	berry	90	3	2002-01-11 11:28:09	500	2002-01-02 11:45:32	501	4	10	0
+650	San Francisco	0	0	2001-12-27 11:13:36	342	0000-00-00 00:00:00	-1	1	24	1
+302467	Sue's Subshop	90	3	2002-01-09 11:32:41	500	2002-01-02 11:51:11	501	7	24	0
+6014911113	SudzCarwash	520	1	2002-01-02 11:52:34	500	2002-01-02 11:52:59	501	33	32768	0
+333	tubs	99	2	2002-01-09 11:34:40	501	2002-01-09 11:34:40	500	3	10	0
+select * from t2;
+number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
+4077711111	SeanWheeler	0	2	2002-01-11 11:28:53	500	0000-00-00 00:00:00	-1	2	3	1
+9197722223	berry	90	3	2002-01-11 11:28:18	500	2002-01-02 11:45:32	501	4	10	0
+650	San Francisco	90	0	2002-01-09 11:31:58	342	0000-00-00 00:00:00	-1	1	24	1
+333	tubs	99	2	2002-01-09 11:34:53	501	2002-01-09 11:34:53	500	3	10	0
+delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);
+select * from t1;
+number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
+6014911113	SudzCarwash	520	1	2002-01-02 11:52:34	500	2002-01-02 11:52:59	501	33	32768	0
+333	tubs	99	2	2002-01-09 11:34:40	501	2002-01-09 11:34:40	500	3	10	0
+select * from t2;
+number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
+333	tubs	99	2	2002-01-09 11:34:53	501	2002-01-09 11:34:53	500	3	10	0
+select * from t2;
+number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
+333	tubs	99	2	2002-01-09 11:34:53	501	2002-01-09 11:34:53	500	3	10	0
+drop table t1,t2;
+create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+SELECT @@tx_isolation,@@global.tx_isolation;
+@@tx_isolation	@@global.tx_isolation
+SERIALIZABLE	REPEATABLE-READ
+insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
+select id, code, name from t1 order by id;
+id	code	name
+1	1	Tim
+2	1	Monty
+3	2	David
+COMMIT;
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
+select id, code, name from t1 order by id;
+id	code	name
+1	1	Tim
+2	1	Monty
+3	2	David
+4	2	Erik
+5	3	Sasha
+COMMIT;
+SET binlog_format='MIXED';
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
+select id, code, name from t1 order by id;
+id	code	name
+1	1	Tim
+2	1	Monty
+3	2	David
+4	2	Erik
+5	3	Sasha
+6	3	Jeremy
+7	4	Matt
+COMMIT;
+DROP TABLE t1;
+create table t1 (n int(10), d int(10)) engine=innodb;
+create table t2 (n int(10), d int(10)) engine=innodb;
+insert into t1 values(1,1),(1,2);
+insert into t2 values(1,10),(2,20);
+UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
+select * from t1;
+n	d
+1	10
+1	10
+select * from t2;
+n	d
+1	30
+2	20
+drop table t1,t2;
+drop table if exists t1, t2;
+CREATE TABLE t1 (a int, PRIMARY KEY (a));
+CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
+create trigger trg_del_t2 after  delete on t2 for each row
+insert into t1 values (1);
+insert into t1 values (1);
+insert into t2 values (1),(2);
+delete t2 from t2;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
+count(*)
+2
+drop table t1, t2;
+drop table if exists t1, t2;
+CREATE TABLE t1 (a int, PRIMARY KEY (a));
+CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
+create trigger trg_del_t2 after  delete on t2 for each row
+insert into t1 values (1);
+insert into t1 values (1);
+insert into t2 values (1),(2);
+delete t2 from t2;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
+count(*)
+2
+drop table t1, t2;
+create table t1 (a int, b int) engine=innodb;
+insert into t1 values(20,null);
+select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
+t2.b=t3.a;
+b	ifnull(t2.b,"this is null")
+NULL	this is null
+select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
+t2.b=t3.a order by 1;
+b	ifnull(t2.b,"this is null")
+NULL	this is null
+insert into t1 values(10,null);
+select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
+t2.b=t3.a order by 1;
+b	ifnull(t2.b,"this is null")
+NULL	this is null
+NULL	this is null
+drop table t1;
+create table t1 (a varchar(10) not null) engine=myisam;
+create table t2 (b varchar(10) not null unique) engine=innodb;
+select t1.a from t1,t2 where t1.a=t2.b;
+a
+drop table t1,t2;
+create table t1 (a int not null, b int, primary key (a)) engine = innodb;
+create table t2 (a int not null, b int, primary key (a)) engine = innodb;
+insert into t1 values (10, 20);
+insert into t2 values (10, 20);
+update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
+drop table t1,t2;
+CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
+CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id)  ON DELETE CASCADE ) ENGINE=INNODB;
+insert into t1 set id=1;
+insert into t2 set id=1, t1_id=1;
+delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
+select * from t1;
+id
+select * from t2;
+id	t1_id
+drop table t2,t1;
+CREATE TABLE t1(id INT NOT NULL,  PRIMARY KEY (id)) ENGINE=INNODB;
+CREATE TABLE t2(id  INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id)  ) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2 VALUES(1, 1);
+SELECT * from t1;
+id
+1
+UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
+SELECT * from t1;
+id
+2
+UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
+SELECT * from t1;
+id
+3
+DROP TABLE t1,t2;
+set autocommit=0;
+CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
+CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
+CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB;
+INSERT INTO t3 VALUES("my-test-1", "my-test-2");
+COMMIT;
+INSERT INTO t1 VALUES("this-key", "will disappear");
+INSERT INTO t2 VALUES("this-key", "will also disappear");
+DELETE FROM t3 WHERE id1="my-test-1";
+SELECT * FROM t1;
+id	value
+this-key	will disappear
+SELECT * FROM t2;
+id	value
+this-key	will also disappear
+SELECT * FROM t3;
+id1	id2
+ROLLBACK;
+SELECT * FROM t1;
+id	value
+SELECT * FROM t2;
+id	value
+SELECT * FROM t3;
+id1	id2
+my-test-1	my-test-2
+SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE;
+id1	id2
+my-test-1	my-test-2
+COMMIT;
+set autocommit=1;
+DROP TABLE t1,t2,t3;
+CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb;
+INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
+UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
+SELECT * from t1;
+a	b
+1	1
+102	2
+103	3
+4	4
+5	5
+6	6
+7	7
+8	8
+9	9
+drop table t1;
+CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb;
+CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb;
+INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
+INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
+update t1,t2 set t1.a=t1.a+100;
+select * from t1;
+a	b
+101	1
+102	2
+103	3
+104	4
+105	5
+106	6
+107	7
+108	8
+109	9
+110	10
+111	11
+112	12
+update t1,t2 set t1.a=t1.a+100 where t1.a=101;
+select * from t1;
+a	b
+201	1
+102	2
+103	3
+104	4
+105	5
+106	6
+107	7
+108	8
+109	9
+110	10
+111	11
+112	12
+update t1,t2 set t1.b=t1.b+10 where t1.b=2;
+select * from t1;
+a	b
+201	1
+103	3
+104	4
+105	5
+106	6
+107	7
+108	8
+109	9
+110	10
+111	11
+102	12
+112	12
+update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
+select * from t1;
+a	b
+201	1
+103	5
+104	6
+106	6
+105	7
+107	7
+108	8
+109	9
+110	10
+111	11
+102	12
+112	12
+select * from t2;
+a	b
+1	1
+2	2
+6	6
+7	7
+8	8
+9	9
+3	13
+4	14
+5	15
+drop table t1,t2;
+CREATE TABLE t2 (   NEXT_T         BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
+CREATE TABLE t1 (  B_ID           INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
+SET AUTOCOMMIT=0;
+INSERT INTO t1 ( B_ID ) VALUES ( 1 );
+INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+SELECT * FROM t1;
+B_ID
+drop table  t1,t2;
+create table t1  ( pk         int primary key,    parent     int not null,    child      int not null,       index (parent)  ) engine = innodb;
+insert into t1 values   (1,0,4),  (2,1,3),  (3,2,1),  (4,1,2);
+select distinct  parent,child   from t1   order by parent;
+parent	child
+0	4
+1	2
+1	3
+2	1
+drop table t1;
+create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
+create table t2 (a int not null auto_increment primary key, b int);
+insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
+insert into t2 (a) select b from t1;
+insert into t1 (b) select b from t2;
+insert into t2 (a) select b from t1;
+insert into t1 (a) select b from t2;
+insert into t2 (a) select b from t1;
+insert into t1 (a) select b from t2;
+insert into t2 (a) select b from t1;
+insert into t1 (a) select b from t2;
+insert into t2 (a) select b from t1;
+insert into t1 (a) select b from t2;
+select count(*) from t1;
+count(*)
+623
+explain select * from t1 where c between 1 and 2500;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	5	NULL	#	Using where
+update t1 set c=a;
+explain select * from t1 where c between 1 and 2500;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	c	NULL	NULL	NULL	#	Using where
+drop table t1,t2;
+create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb;
+insert into t1 (id) values (null),(null),(null),(null),(null);
+update t1 set fk=69 where fk is null order by id limit 1;
+SELECT * from t1;
+id	fk
+2	NULL
+3	NULL
+4	NULL
+5	NULL
+1	69
+drop table t1;
+create table t1 (a int not null, b int not null, key (a));
+insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
+SET @tmp=0;
+update t1 set b=(@tmp:=@tmp+1) order by a;
+update t1 set b=99 where a=1 order by b asc limit 1;
+update t1 set b=100 where a=1 order by b desc limit 2;
+update t1 set a=a+10+b where a=1 order by b;
+select * from t1 order by a,b;
+a	b
+2	4
+2	5
+2	6
+3	7
+3	8
+3	9
+3	10
+3	11
+3	12
+13	2
+111	100
+111	100
+drop table t1;
+create table t1 ( c char(8) not null ) engine=innodb;
+insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
+insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
+alter table t1 add b char(8) not null;
+alter table t1 add a char(8) not null;
+alter table t1 add primary key (a,b,c);
+update t1 set a=c, b=c;
+create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
+insert into t2 select * from t1;
+delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
+drop table t1,t2;
+SET AUTOCOMMIT=1;
+create table t1 (a integer auto_increment primary key) engine=innodb;
+insert into t1 (a) values (NULL),(NULL);
+truncate table t1;
+insert into t1 (a) values (NULL),(NULL);
+SELECT * from t1;
+a
+1
+2
+drop table t1;
+CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB;
+CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`)  ON DELETE CASCADE ) ENGINE=INNODB;
+drop table t2,t1;
+create table `t1` (`id` int( 11 ) not null  ,primary key ( `id` )) engine = innodb;
+insert into `t1`values ( 1 ) ;
+create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
+insert into `t2`values ( 1 ) ;
+create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
+insert into `t3`values ( 1 ) ;
+delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
+update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
+update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
+ERROR 42S22: Unknown column 't1.id' in 'where clause'
+drop table t3,t2,t1;
+create table t1(
+id int primary key,
+pid int,
+index(pid),
+foreign key(pid) references t1(id) on delete cascade) engine=innodb;
+insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
+(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
+delete from t1 where id=0;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `t1` (`id`) ON DELETE CASCADE)
+delete from t1 where id=15;
+delete from t1 where id=0;
+drop table t1;
+CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
+CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
+(stamp))ENGINE=InnoDB;
+insert into t1 values (1),(2),(3);
+insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
+Warnings:
+Warning	1265	Data truncated for column 'stamp' at row 3
+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
+'20020204120000' GROUP BY col1;
+col1
+1
+2
+3
+4
+drop table t1,t2;
+CREATE TABLE t1 (
+`id` int(10) unsigned NOT NULL auto_increment,
+`id_object` int(10) unsigned default '0',
+`id_version` int(10) unsigned NOT NULL default '1',
+`label` varchar(100) NOT NULL default '',
+`description` text,
+PRIMARY KEY  (`id`),
+KEY `id_object` (`id_object`),
+KEY `id_version` (`id_version`)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
+CREATE TABLE t2 (
+`id` int(10) unsigned NOT NULL auto_increment,
+`id_version` int(10) unsigned NOT NULL default '1',
+PRIMARY KEY  (`id`),
+KEY `id_version` (`id_version`)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
+SELECT t2.id, t1.`label` FROM t2 INNER JOIN
+(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl 
+ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
+id	label
+3382	Test
+102	Le Pekin (Test)
+1794	Test de resto
+1822	Test 3
+3524	Societe Test
+3525	Fournisseur Test
+drop table t1,t2;
+create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
+create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
+create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
+insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
+insert t2 select * from t1;
+insert t3 select * from t1;
+checksum table t1, t2, t3, t4 quick;
+Table	Checksum
+test.t1	3442722830
+test.t2	NULL
+test.t3	NULL
+test.t4	NULL
+Warnings:
+Error	1146	Table 'test.t4' doesn't exist
+checksum table t1, t2, t3, t4;
+Table	Checksum
+test.t1	3442722830
+test.t2	3442722830
+test.t3	3442722830
+test.t4	NULL
+Warnings:
+Error	1146	Table 'test.t4' doesn't exist
+checksum table t1, t2, t3, t4 extended;
+Table	Checksum
+test.t1	3442722830
+test.t2	3442722830
+test.t3	3442722830
+test.t4	NULL
+Warnings:
+Error	1146	Table 'test.t4' doesn't exist
+drop table t1,t2,t3;
+create table t1 (id int,  name char(10) not null,  name2 char(10) not null) engine=innodb;
+insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
+select trim(name2) from t1  union all  select trim(name) from t1 union all select trim(id) from t1;
+trim(name2)
+fff
+sss
+ttt
+first
+second
+third
+1
+2
+3
+drop table t1;
+create table t1 (a int) engine=innodb;
+create table t2 like t1;
+drop table t1,t2;
+create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb;
+create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` int(11) NOT NULL,
+  `id2` int(11) NOT NULL,
+  UNIQUE KEY `id` (`id`,`id2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  KEY `t1_id_fk` (`id`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+create index id on t2 (id);
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  KEY `id` (`id`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+create index id2 on t2 (id);
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  KEY `id` (`id`),
+  KEY `id2` (`id`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop index id2 on t2;
+drop index id on t2;
+ERROR HY000: Cannot drop index 'id': needed in a foreign key constraint
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  KEY `id` (`id`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  `id2` int(11) NOT NULL,
+  KEY `t1_id_fk` (`id`,`id2`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+create unique index id on t2 (id,id2);
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  `id2` int(11) NOT NULL,
+  UNIQUE KEY `id` (`id`,`id2`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  `id2` int(11) NOT NULL,
+  UNIQUE KEY `id` (`id`,`id2`),
+  KEY `t1_id_fk` (`id2`,`id`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  `id2` int(11) NOT NULL,
+  UNIQUE KEY `id` (`id`,`id2`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  `id2` int(11) NOT NULL,
+  UNIQUE KEY `id` (`id`,`id2`),
+  KEY `t1_id_fk` (`id2`,`id`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `id2` int(11) NOT NULL,
+  PRIMARY KEY (`id`),
+  KEY `id` (`id`,`id2`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `id2` int(11) NOT NULL,
+  KEY `t1_id_fk` (`id`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t2 add index id_test (id), add index id_test2 (id,id2);
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `id2` int(11) NOT NULL,
+  KEY `id_test` (`id`),
+  KEY `id_test2` (`id`,`id2`),
+  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
+ERROR 42000: Incorrect foreign key definition for 't1_id_fk': Key reference and table reference don't match
+create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` int(11) NOT NULL AUTO_INCREMENT,
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `b_2` (`b`),
+  KEY `b` (`b`),
+  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2;
+create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` int(11) NOT NULL AUTO_INCREMENT,
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`),
+  UNIQUE KEY `b` (`b`),
+  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`),
+  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2, t1;
+create table t1 (c char(10), index (c,c)) engine=innodb;
+ERROR 42S21: Duplicate column name 'c'
+create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
+ERROR 42S21: Duplicate column name 'c1'
+create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
+ERROR 42S21: Duplicate column name 'c1'
+create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
+ERROR 42S21: Duplicate column name 'c1'
+create table t1 (c1 char(10), c2 char(10)) engine=innodb;
+alter table t1 add key (c1,c1);
+ERROR 42S21: Duplicate column name 'c1'
+alter table t1 add key (c2,c1,c1);
+ERROR 42S21: Duplicate column name 'c1'
+alter table t1 add key (c1,c2,c1);
+ERROR 42S21: Duplicate column name 'c1'
+alter table t1 add key (c1,c1,c2);
+ERROR 42S21: Duplicate column name 'c1'
+drop table t1;
+create table t1(a int(1) , b int(1)) engine=innodb;
+insert into t1 values ('1111', '3333');
+select distinct concat(a, b) from t1;
+concat(a, b)
+11113333
+drop table t1;
+CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
+SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
+ERROR HY000: The used table type doesn't support FULLTEXT indexes
+DROP TABLE t1;
+CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY  (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES (1),(2),(3);
+CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY  (b_id), KEY  (b_a), 
+CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
+SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
+a_id	b_list
+1	1,2,3
+2	4,5
+3	NULL
+DROP TABLE t2;
+DROP TABLE t1;
+create temporary table t1 (a int) engine=innodb;
+insert into t1 values (4711);
+truncate t1;
+insert into t1 values (42);
+select * from t1;
+a
+42
+drop table t1;
+create table t1 (a int) engine=innodb;
+insert into t1 values (4711);
+truncate t1;
+insert into t1 values (42);
+select * from t1;
+a
+42
+drop table t1;
+create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb;
+insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
+select * from t1 order by a,b,c,d;
+a	b	c	d	e
+1	1	a	1	1
+2	2	b	2	2
+3	3	ab	3	3
+explain select * from t1 order by a,b,c,d;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using filesort
+drop table t1;
+create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
+insert into t1 values ('8', '6'), ('4', '7');
+select min(a) from t1;
+min(a)
+4
+select min(b) from t1 where a='8';
+min(b)
+6
+drop table t1;
+create table t1 (x bigint unsigned not null primary key) engine=innodb;
+insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
+select * from t1;
+x
+18446744073709551600
+18446744073709551601
+select count(*) from t1 where x>0;
+count(*)
+2
+select count(*) from t1 where x=0;
+count(*)
+0
+select count(*) from t1 where x<0;
+count(*)
+0
+select count(*) from t1 where x < -16;
+count(*)
+0
+select count(*) from t1 where x = -16;
+count(*)
+0
+explain select count(*) from t1 where x > -16;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	PRIMARY	PRIMARY	8	NULL	2	Using where; Using index
+select count(*) from t1 where x > -16;
+count(*)
+2
+select * from t1 where x > -16;
+x
+18446744073709551600
+18446744073709551601
+select count(*) from t1 where x = 18446744073709551601;
+count(*)
+1
+drop table t1;
+show status like "Innodb_buffer_pool_pages_total";
+Variable_name	Value
+Innodb_buffer_pool_pages_total	511
+show status like "Innodb_page_size";
+Variable_name	Value
+Innodb_page_size	16384
+show status like "Innodb_rows_deleted";
+Variable_name	Value
+Innodb_rows_deleted	71
+show status like "Innodb_rows_inserted";
+Variable_name	Value
+Innodb_rows_inserted	1084
+show status like "Innodb_rows_updated";
+Variable_name	Value
+Innodb_rows_updated	885
+show status like "Innodb_row_lock_waits";
+Variable_name	Value
+Innodb_row_lock_waits	0
+show status like "Innodb_row_lock_current_waits";
+Variable_name	Value
+Innodb_row_lock_current_waits	0
+show status like "Innodb_row_lock_time";
+Variable_name	Value
+Innodb_row_lock_time	0
+show status like "Innodb_row_lock_time_max";
+Variable_name	Value
+Innodb_row_lock_time_max	0
+show status like "Innodb_row_lock_time_avg";
+Variable_name	Value
+Innodb_row_lock_time_avg	0
+show variables like "innodb_sync_spin_loops";
+Variable_name	Value
+innodb_sync_spin_loops	20
+set global innodb_sync_spin_loops=1000;
+show variables like "innodb_sync_spin_loops";
+Variable_name	Value
+innodb_sync_spin_loops	1000
+set global innodb_sync_spin_loops=0;
+show variables like "innodb_sync_spin_loops";
+Variable_name	Value
+innodb_sync_spin_loops	0
+set global innodb_sync_spin_loops=20;
+show variables like "innodb_sync_spin_loops";
+Variable_name	Value
+innodb_sync_spin_loops	20
+SET @old_innodb_thread_concurrency= @@global.innodb_thread_concurrency;
+show variables like "innodb_thread_concurrency";
+Variable_name	Value
+innodb_thread_concurrency	0
+set global innodb_thread_concurrency=1001;
+Warnings:
+Warning	1292	Truncated incorrect thread_concurrency value: '1001'
+show variables like "innodb_thread_concurrency";
+Variable_name	Value
+innodb_thread_concurrency	1000
+set global innodb_thread_concurrency=0;
+show variables like "innodb_thread_concurrency";
+Variable_name	Value
+innodb_thread_concurrency	0
+set global innodb_thread_concurrency=16;
+show variables like "innodb_thread_concurrency";
+Variable_name	Value
+innodb_thread_concurrency	16
+SET @@global.innodb_thread_concurrency= @old_innodb_thread_concurrency;
+show variables like "innodb_concurrency_tickets";
+Variable_name	Value
+innodb_concurrency_tickets	500
+set global innodb_concurrency_tickets=1000;
+show variables like "innodb_concurrency_tickets";
+Variable_name	Value
+innodb_concurrency_tickets	1000
+set global innodb_concurrency_tickets=0;
+Warnings:
+Warning	1292	Truncated incorrect concurrency_tickets value: '0'
+show variables like "innodb_concurrency_tickets";
+Variable_name	Value
+innodb_concurrency_tickets	1
+set global innodb_concurrency_tickets=500;
+show variables like "innodb_concurrency_tickets";
+Variable_name	Value
+innodb_concurrency_tickets	500
+show variables like "innodb_thread_sleep_delay";
+Variable_name	Value
+innodb_thread_sleep_delay	10000
+set global innodb_thread_sleep_delay=100000;
+show variables like "innodb_thread_sleep_delay";
+Variable_name	Value
+innodb_thread_sleep_delay	100000
+set global innodb_thread_sleep_delay=0;
+show variables like "innodb_thread_sleep_delay";
+Variable_name	Value
+innodb_thread_sleep_delay	0
+set global innodb_thread_sleep_delay=10000;
+show variables like "innodb_thread_sleep_delay";
+Variable_name	Value
+innodb_thread_sleep_delay	10000
+set storage_engine=INNODB;
+drop table if exists t1,t2,t3;
+--- Testing varchar ---
+--- Testing varchar ---
+create table t1 (v varchar(10), c char(10), t text);
+insert into t1 values('+ ', '+ ', '+ ');
+set @a=repeat(' ',20);
+insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
+Warnings:
+Note	1265	Data truncated for column 'v' at row 1
+select concat('*',v,'*',c,'*',t,'*') from t1;
+concat('*',v,'*',c,'*',t,'*')
+*+ *+*+ *
+*+         *+*+                    *
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` varchar(10) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `t` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+create table t2 like t1;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `v` varchar(10) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `t` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+create table t3 select * from t1;
+show create table t3;
+Table	Create Table
+t3	CREATE TABLE `t3` (
+  `v` varchar(10) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `t` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 modify c varchar(10);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` varchar(10) DEFAULT NULL,
+  `c` varchar(10) DEFAULT NULL,
+  `t` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 modify v char(10);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` char(10) DEFAULT NULL,
+  `c` varchar(10) DEFAULT NULL,
+  `t` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 modify t varchar(10);
+Warnings:
+Note	1265	Data truncated for column 't' at row 2
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` char(10) DEFAULT NULL,
+  `c` varchar(10) DEFAULT NULL,
+  `t` varchar(10) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+select concat('*',v,'*',c,'*',t,'*') from t1;
+concat('*',v,'*',c,'*',t,'*')
+*+*+*+ *
+*+*+*+         *
+drop table t1,t2,t3;
+create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` varchar(10) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `t` text,
+  KEY `v` (`v`),
+  KEY `c` (`c`),
+  KEY `t` (`t`(10))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+select count(*) from t1;
+count(*)
+270
+insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
+select count(*) from t1 where v='a';
+count(*)
+10
+select count(*) from t1 where c='a';
+count(*)
+10
+select count(*) from t1 where t='a';
+count(*)
+10
+select count(*) from t1 where v='a  ';
+count(*)
+10
+select count(*) from t1 where c='a  ';
+count(*)
+10
+select count(*) from t1 where t='a  ';
+count(*)
+10
+select count(*) from t1 where v between 'a' and 'a ';
+count(*)
+10
+select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
+count(*)
+10
+select count(*) from t1 where v like 'a%';
+count(*)
+11
+select count(*) from t1 where c like 'a%';
+count(*)
+11
+select count(*) from t1 where t like 'a%';
+count(*)
+11
+select count(*) from t1 where v like 'a %';
+count(*)
+9
+explain select count(*) from t1 where v='a  ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	13	const	#	Using where; Using index
+explain select count(*) from t1 where c='a  ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	c	c	11	const	#	Using where; Using index
+explain select count(*) from t1 where t='a  ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	t	t	13	const	#	Using where
+explain select count(*) from t1 where v like 'a%';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	13	NULL	#	Using where; Using index
+explain select count(*) from t1 where v between 'a' and 'a ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	13	const	#	Using where; Using index
+explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	13	const	#	Using where; Using index
+alter table t1 add unique(v);
+ERROR 23000: Duplicate entry 'v' for key 'v_2'
+alter table t1 add key(v);
+select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
+qq
+*a*a*a*
+*a *a*a *
+*a  *a*a  *
+*a   *a*a   *
+*a    *a*a    *
+*a     *a*a     *
+*a      *a*a      *
+*a       *a*a       *
+*a        *a*a        *
+*a         *a*a         *
+explain select * from t1 where v='a';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v,v_2	#	13	const	#	Using where
+select v,count(*) from t1 group by v limit 10;
+v	count(*)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select v,count(t) from t1 group by v limit 10;
+v	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select v,count(c) from t1 group by v limit 10;
+v	count(c)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select sql_big_result v,count(t) from t1 group by v limit 10;
+v	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select sql_big_result v,count(c) from t1 group by v limit 10;
+v	count(c)
+a	1
+a 	10
+b     	10
+c    	10
+d   	10
+e  	10
+f     	10
+g    	10
+h	10
+i     	10
+select c,count(*) from t1 group by c limit 10;
+c	count(*)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select c,count(t) from t1 group by c limit 10;
+c	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select sql_big_result c,count(t) from t1 group by c limit 10;
+c	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select t,count(*) from t1 group by t limit 10;
+t	count(*)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select t,count(t) from t1 group by t limit 10;
+t	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select sql_big_result t,count(t) from t1 group by t limit 10;
+t	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` varchar(300) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `t` text,
+  KEY `c` (`c`),
+  KEY `t` (`t`(10)),
+  KEY `v` (`v`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+select count(*) from t1 where v='a';
+count(*)
+10
+select count(*) from t1 where v='a  ';
+count(*)
+10
+select count(*) from t1 where v between 'a' and 'a ';
+count(*)
+10
+select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
+count(*)
+10
+select count(*) from t1 where v like 'a%';
+count(*)
+11
+select count(*) from t1 where v like 'a %';
+count(*)
+9
+explain select count(*) from t1 where v='a  ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	303	const	#	Using where; Using index
+explain select count(*) from t1 where v like 'a%';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	303	NULL	#	Using where; Using index
+explain select count(*) from t1 where v between 'a' and 'a ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	303	const	#	Using where; Using index
+explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	303	const	#	Using where; Using index
+explain select * from t1 where v='a';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	303	const	#	Using where
+select v,count(*) from t1 group by v limit 10;
+v	count(*)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select v,count(t) from t1 group by v limit 10;
+v	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select sql_big_result v,count(t) from t1 group by v limit 10;
+v	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+alter table t1 drop key v, add key v (v(30));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` varchar(300) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `t` text,
+  KEY `c` (`c`),
+  KEY `t` (`t`(10)),
+  KEY `v` (`v`(30))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+select count(*) from t1 where v='a';
+count(*)
+10
+select count(*) from t1 where v='a  ';
+count(*)
+10
+select count(*) from t1 where v between 'a' and 'a ';
+count(*)
+10
+select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
+count(*)
+10
+select count(*) from t1 where v like 'a%';
+count(*)
+11
+select count(*) from t1 where v like 'a %';
+count(*)
+9
+explain select count(*) from t1 where v='a  ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	33	const	#	Using where
+explain select count(*) from t1 where v like 'a%';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	33	NULL	#	Using where
+explain select count(*) from t1 where v between 'a' and 'a ';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	33	const	#	Using where
+explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	33	const	#	Using where
+explain select * from t1 where v='a';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	v	v	33	const	#	Using where
+select v,count(*) from t1 group by v limit 10;
+v	count(*)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select v,count(t) from t1 group by v limit 10;
+v	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select sql_big_result v,count(t) from t1 group by v limit 10;
+v	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+alter table t1 modify v varchar(600), drop key v, add key v (v);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` varchar(600) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `t` text,
+  KEY `c` (`c`),
+  KEY `t` (`t`(10)),
+  KEY `v` (`v`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+select v,count(*) from t1 group by v limit 10;
+v	count(*)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select v,count(t) from t1 group by v limit 10;
+v	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+select sql_big_result v,count(t) from t1 group by v limit 10;
+v	count(t)
+a	1
+a	10
+b	10
+c	10
+d	10
+e	10
+f	10
+g	10
+h	10
+i	10
+drop table t1;
+create table t1 (a char(10), unique (a));
+insert into t1 values ('a   ');
+insert into t1 values ('a ');
+ERROR 23000: Duplicate entry 'a' for key 'a'
+alter table t1 modify a varchar(10);
+insert into t1 values ('a '),('a  '),('a   '),('a         ');
+ERROR 23000: Duplicate entry 'a ' for key 'a'
+insert into t1 values ('a     ');
+ERROR 23000: Duplicate entry 'a     ' for key 'a'
+insert into t1 values ('a          ');
+ERROR 23000: Duplicate entry 'a         ' for key 'a'
+insert into t1 values ('a ');
+ERROR 23000: Duplicate entry 'a ' for key 'a'
+update t1 set a='a  ' where a like 'a%';
+select concat(a,'.') from t1;
+concat(a,'.')
+a  .
+update t1 set a='abc    ' where a like 'a ';
+select concat(a,'.') from t1;
+concat(a,'.')
+a  .
+update t1 set a='a      ' where a like 'a %';
+select concat(a,'.') from t1;
+concat(a,'.')
+a      .
+update t1 set a='a  ' where a like 'a      ';
+select concat(a,'.') from t1;
+concat(a,'.')
+a  .
+drop table t1;
+create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` varchar(10) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL,
+  `t` text,
+  KEY `v` (`v`(5)),
+  KEY `c` (`c`(5)),
+  KEY `t` (`t`(5))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (v char(10) character set utf8);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` char(10) CHARACTER SET utf8 DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (v varchar(10), c char(10)) row_format=fixed;
+Warnings:
+Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` varchar(10) DEFAULT NULL,
+  `c` char(10) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
+insert into t1 values('a','a'),('a ','a ');
+select concat('*',v,'*',c,'*') from t1;
+concat('*',v,'*',c,'*')
+*a*a*
+*a *a*
+drop table t1;
+create table t1 (v varchar(65530), key(v(10)));
+insert into t1 values(repeat('a',65530));
+select length(v) from t1 where v=repeat('a',65530);
+length(v)
+65530
+drop table t1;
+create table t1(a int, b varchar(12), key ba(b, a));
+insert into t1 values (1, 'A'), (20, NULL);
+explain select * from t1 where a=20 and b is null;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	ba	ba	20	const,const	1	Using where; Using index
+select * from t1 where a=20 and b is null;
+a	b
+20	NULL
+drop table t1;
+create table t1 (v varchar(65530), key(v));
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+drop table t1;
+create table t1 (v varchar(65536));
+Warnings:
+Note	1246	Converting column 'v' from VARCHAR to TEXT
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` mediumtext
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (v varchar(65530) character set utf8);
+Warnings:
+Note	1246	Converting column 'v' from VARCHAR to TEXT
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `v` mediumtext CHARACTER SET utf8
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
+set storage_engine=MyISAM;
+create table t1 (v varchar(16384)) engine=innodb;
+drop table t1;
+create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
+insert into t1 values ('8', '6'), ('4', '7');
+select min(a) from t1;
+min(a)
+4
+select min(b) from t1 where a='8';
+min(b)
+6
+drop table t1;
+CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
+insert into t1 (b) values (1);
+replace into t1 (b) values (2), (1), (3);
+select * from t1;
+a	b
+3	1
+2	2
+4	3
+truncate table t1;
+insert into t1 (b) values (1);
+replace into t1 (b) values (2);
+replace into t1 (b) values (1);
+replace into t1 (b) values (3);
+select * from t1;
+a	b
+3	1
+2	2
+4	3
+drop table t1;
+create table t1 (rowid int not null auto_increment, val int not null,primary
+key (rowid), unique(val)) engine=innodb;
+replace into t1 (val) values ('1'),('2');
+replace into t1 (val) values ('1'),('2');
+insert into t1 (val) values ('1'),('2');
+ERROR 23000: Duplicate entry '1' for key 'val'
+select * from t1;
+rowid	val
+3	1
+4	2
+drop table t1;
+create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
+insert into t1 (val) values (1);
+update t1 set a=2 where a=1;
+insert into t1 (val) values (1);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+select * from t1;
+a	val
+2	1
+drop table t1;
+CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
+INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
+SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
+GRADE
+252
+SELECT GRADE  FROM t1 WHERE GRADE= 151;
+GRADE
+151
+DROP TABLE t1;
+create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
+create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
+insert into t2 values ('aa','cc');
+insert into t1 values ('aa','bb'),('aa','cc');
+delete t1 from t1,t2 where f1=f3 and f4='cc';
+select * from t1;
+f1	f2
+drop table t1,t2;
+CREATE TABLE t1 (
+id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
+) ENGINE=InnoDB;
+CREATE TABLE t2 (
+id INTEGER NOT NULL,
+FOREIGN KEY (id) REFERENCES t1 (id)
+) ENGINE=InnoDB;
+INSERT INTO t1 (id) VALUES (NULL);
+SELECT * FROM t1;
+id
+1
+TRUNCATE t1;
+INSERT INTO t1 (id) VALUES (NULL);
+SELECT * FROM t1;
+id
+1
+DELETE FROM t1;
+TRUNCATE t1;
+INSERT INTO t1 (id) VALUES (NULL);
+SELECT * FROM t1;
+id
+1
+DROP TABLE t2, t1;
+CREATE TABLE t1
+(
+id INT PRIMARY KEY
+) ENGINE=InnoDB;
+CREATE TEMPORARY TABLE t2
+(
+id INT NOT NULL PRIMARY KEY,
+b INT,
+FOREIGN KEY (b) REFERENCES test.t1(id)
+) ENGINE=InnoDB;
+Got one of the listed errors
+DROP TABLE t1;
+create table t1 (col1 varchar(2000), index (col1(767)))
+character set = latin1 engine = innodb;
+create table t2 (col1 char(255), index (col1))
+character set = latin1 engine = innodb;
+create table t3 (col1 binary(255), index (col1))
+character set = latin1 engine = innodb;
+create table t4 (col1 varchar(767), index (col1))
+character set = latin1 engine = innodb;
+create table t5 (col1 varchar(767) primary key)
+character set = latin1 engine = innodb;
+create table t6 (col1 varbinary(767) primary key)
+character set = latin1 engine = innodb;
+create table t7 (col1 text, index(col1(767)))
+character set = latin1 engine = innodb;
+create table t8 (col1 blob, index(col1(767)))
+character set = latin1 engine = innodb;
+create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
+character set = latin1 engine = innodb;
+show create table t9;
+Table	Create Table
+t9	CREATE TABLE `t9` (
+  `col1` varchar(512) DEFAULT NULL,
+  `col2` varchar(512) DEFAULT NULL,
+  KEY `col1` (`col1`,`col2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
+create table t1 (col1 varchar(768), index(col1))
+character set = latin1 engine = innodb;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+create table t2 (col1 varbinary(768), index(col1))
+character set = latin1 engine = innodb;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+create table t3 (col1 text, index(col1(768)))
+character set = latin1 engine = innodb;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+create table t4 (col1 blob, index(col1(768)))
+character set = latin1 engine = innodb;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 767 bytes
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `col1` varchar(768) DEFAULT NULL,
+  KEY `col1` (`col1`(767))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1, t2, t3, t4;
+create table t1 (col1 varchar(768) primary key)
+character set = latin1 engine = innodb;
+ERROR 42000: Specified key was too long; max key length is 767 bytes
+create table t2 (col1 varbinary(768) primary key)
+character set = latin1 engine = innodb;
+ERROR 42000: Specified key was too long; max key length is 767 bytes
+create table t3 (col1 text, primary key(col1(768)))
+character set = latin1 engine = innodb;
+ERROR 42000: Specified key was too long; max key length is 767 bytes
+create table t4 (col1 blob, primary key(col1(768)))
+character set = latin1 engine = innodb;
+ERROR 42000: Specified key was too long; max key length is 767 bytes
+CREATE TABLE t1
+(
+id INT PRIMARY KEY
+) ENGINE=InnoDB;
+CREATE TABLE t2
+(
+v INT,
+CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2 VALUES(1);
+DELETE FROM t1 WHERE id = 1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
+DROP TABLE t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+SET FOREIGN_KEY_CHECKS=0;
+DROP TABLE t1;
+SET FOREIGN_KEY_CHECKS=1;
+INSERT INTO t2 VALUES(3);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
+DROP TABLE t2;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2);
+set autocommit=0;
+checksum table t1;
+Table	Checksum
+test.t1	1531596814
+insert into t1 values(3);
+checksum table t1;
+Table	Checksum
+test.t1	1531596814
+commit;
+checksum table t1;
+Table	Checksum
+test.t1	2050879373
+commit;
+drop table t1;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2);
+set autocommit=1;
+checksum table t1;
+Table	Checksum
+test.t1	1531596814
+set autocommit=1;
+insert into t1 values(3);
+checksum table t1;
+Table	Checksum
+test.t1	2050879373
+drop table t1;
+set foreign_key_checks=0;
+create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
+create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
+ERROR HY000: Can't create table 'test.t1' (errno: 150)
+set foreign_key_checks=1;
+drop table t2;
+set foreign_key_checks=0;
+create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
+ERROR HY000: Can't create table 'test.t2' (errno: 150)
+set foreign_key_checks=1;
+drop table t1;
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
+create table t1(a varchar(10) primary key) engine = innodb;
+alter table t1 modify column a int;
+Got one of the listed errors
+set foreign_key_checks=1;
+drop table t2,t1;
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
+create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
+alter table t1 convert to character set utf8;
+set foreign_key_checks=1;
+drop table t2,t1;
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
+create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
+rename table t3 to t1;
+ERROR HY000: Error on rename of './test/t3' to './test/t1' (errno: 150)
+set foreign_key_checks=1;
+drop table t2,t3;
+create table t1(a int primary key) row_format=redundant engine=innodb;
+create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
+create table t3(a int primary key) row_format=compact engine=innodb;
+create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
+insert into t1 values(1);
+insert into t3 values(1);
+insert into t2 values(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+insert into t4 values(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+insert into t2 values(1);
+insert into t4 values(1);
+update t1 set a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+update t2 set a=2;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+update t3 set a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+update t4 set a=2;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+truncate t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+truncate t3;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+truncate t2;
+truncate t4;
+truncate t1;
+truncate t3;
+drop table t4,t3,t2,t1;
+create table t1 (a varchar(255) character set utf8,
+b varchar(255) character set utf8,
+c varchar(255) character set utf8,
+d varchar(255) character set utf8,
+key (a,b,c,d)) engine=innodb;
+drop table t1;
+create table t1 (a varchar(255) character set utf8,
+b varchar(255) character set utf8,
+c varchar(255) character set utf8,
+d varchar(255) character set utf8,
+e varchar(255) character set utf8,
+key (a,b,c,d,e)) engine=innodb;
+ERROR 42000: Specified key was too long; max key length is 3072 bytes
+create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
+create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
+create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
+create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
+insert into t1 values (0x41),(0x4120),(0x4100);
+insert into t2 values (0x41),(0x4120),(0x4100);
+ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
+insert into t2 values (0x41),(0x4120);
+insert into t3 values (0x41),(0x4120),(0x4100);
+ERROR 23000: Duplicate entry 'A ' for key 'PRIMARY'
+insert into t3 values (0x41),(0x4100);
+insert into t4 values (0x41),(0x4120),(0x4100);
+ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
+insert into t4 values (0x41),(0x4100);
+select hex(s1) from t1;
+hex(s1)
+41
+4100
+4120
+select hex(s1) from t2;
+hex(s1)
+4100
+4120
+select hex(s1) from t3;
+hex(s1)
+4100
+41
+select hex(s1) from t4;
+hex(s1)
+4100
+41
+drop table t1,t2,t3,t4;
+create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
+create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
+insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
+insert into t2 values(0x42);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+insert into t2 values(0x41);
+select hex(s1) from t2;
+hex(s1)
+4100
+update t1 set s1=0x123456 where a=2;
+select hex(s1) from t2;
+hex(s1)
+4100
+update t1 set s1=0x12 where a=1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+update t1 set s1=0x12345678 where a=1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+update t1 set s1=0x123457 where a=1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+update t1 set s1=0x1220 where a=1;
+select hex(s1) from t2;
+hex(s1)
+1220
+update t1 set s1=0x1200 where a=1;
+select hex(s1) from t2;
+hex(s1)
+1200
+update t1 set s1=0x4200 where a=1;
+select hex(s1) from t2;
+hex(s1)
+4200
+delete from t1 where a=1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+delete from t1 where a=2;
+update t2 set s1=0x4120;
+delete from t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+delete from t1 where a!=3;
+select a,hex(s1) from t1;
+a	hex(s1)
+3	4120
+select hex(s1) from t2;
+hex(s1)
+4120
+drop table t2,t1;
+create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
+create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
+insert into t1 values(1,0x4100),(2,0x41);
+insert into t2 values(0x41);
+select hex(s1) from t2;
+hex(s1)
+41
+update t1 set s1=0x1234 where a=1;
+select hex(s1) from t2;
+hex(s1)
+41
+update t1 set s1=0x12 where a=2;
+select hex(s1) from t2;
+hex(s1)
+12
+delete from t1 where a=1;
+delete from t1 where a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+select a,hex(s1) from t1;
+a	hex(s1)
+2	12
+select hex(s1) from t2;
+hex(s1)
+12
+drop table t2,t1;
+CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
+CREATE TABLE t2(a INT) ENGINE=InnoDB;
+ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
+ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` int(11) DEFAULT NULL,
+  KEY `t2_ibfk_0` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t2,t1;
+create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+insert into t1(a) values (1),(2),(3);
+commit;
+set autocommit = 0;
+update t1 set b = 5 where a = 2;
+create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
+set autocommit = 0;
+insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
+(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
+(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
+(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
+(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
+commit;
+commit;
+drop trigger t1t;
+drop table t1;
+create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+insert into t1(a) values (1),(2),(3);
+insert into t2(a) values (1),(2),(3);
+insert into t3(a) values (1),(2),(3);
+insert into t4(a) values (1),(2),(3);
+insert into t3(a) values (5),(7),(8);
+insert into t4(a) values (5),(7),(8);
+insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
+create trigger t1t before insert on t1 for each row begin 
+INSERT INTO t2 SET a = NEW.a;
+end |
+create trigger t2t before insert on t2 for each row begin
+DELETE FROM t3 WHERE a = NEW.a;
+end |
+create trigger t3t before delete on t3 for each row begin  
+UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
+end |
+create trigger t4t before update on t4 for each row begin
+UPDATE t5 SET b = b + 1 where a = NEW.a;
+end |
+commit;
+set autocommit = 0;
+update t1 set b = b + 5 where a = 1;
+update t2 set b = b + 5 where a = 1;
+update t3 set b = b + 5 where a = 1;
+update t4 set b = b + 5 where a = 1;
+insert into t5(a) values(20);
+set autocommit = 0;
+insert into t1(a) values(7);
+insert into t2(a) values(8);
+delete from t2 where a = 3;
+update t4 set b = b + 1 where a = 3;
+commit;
+drop trigger t1t;
+drop trigger t2t;
+drop trigger t3t;
+drop trigger t4t;
+drop table t1, t2, t3, t4, t5;
+CREATE TABLE t1 (
+field1 varchar(8) NOT NULL DEFAULT '',
+field2 varchar(8) NOT NULL DEFAULT '',
+PRIMARY KEY  (field1, field2)
+) ENGINE=InnoDB;
+CREATE TABLE t2 (
+field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
+FOREIGN KEY (field1) REFERENCES t1 (field1)
+ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES ('old', 'somevalu');
+INSERT INTO t1 VALUES ('other', 'anyvalue');
+INSERT INTO t2 VALUES ('old');
+INSERT INTO t2 VALUES ('other');
+UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
+ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry
+DROP TABLE t2;
+DROP TABLE t1;
+create table t1 (
+c1 bigint not null,
+c2 bigint not null,
+primary key (c1),
+unique  key (c2)
+) engine=innodb;
+create table t2 (
+c1 bigint not null,
+primary key (c1)
+) engine=innodb;
+alter table t1 add constraint c2_fk foreign key (c2)
+references t2(c1) on delete cascade;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` bigint(20) NOT NULL,
+  `c2` bigint(20) NOT NULL,
+  PRIMARY KEY (`c1`),
+  UNIQUE KEY `c2` (`c2`),
+  CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table t1 drop foreign key c2_fk;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` bigint(20) NOT NULL,
+  `c2` bigint(20) NOT NULL,
+  PRIMARY KEY (`c1`),
+  UNIQUE KEY `c2` (`c2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t1, t2;
+create table t1(a date) engine=innodb;
+create table t2(a date, key(a)) engine=innodb;
+insert into t1 values('2005-10-01');
+insert into t2 values('2005-10-01');
+select * from t1, t2
+where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
+a	a
+2005-10-01	2005-10-01
+drop table t1, t2;
+create table t1 (id int not null, f_id int not null, f int not null,
+primary key(f_id, id)) engine=innodb;
+create table t2 (id int not null,s_id int not null,s varchar(200),
+primary key(id)) engine=innodb;
+INSERT INTO t1 VALUES (8, 1, 3);
+INSERT INTO t1 VALUES (1, 2, 1);
+INSERT INTO t2 VALUES (1, 0, '');
+INSERT INTO t2 VALUES (8, 1, '');
+commit;
+DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
+WHERE mm.id IS NULL;
+select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
+where mm.id is null lock in share mode;
+id	f_id	f
+drop table t1,t2;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
+commit;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+update t1 set b = 5 where b = 1;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+select * from t1 where a = 7 and b = 3 for update;
+a	b
+7	3
+commit;
+commit;
+drop table t1;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
+commit;
+set autocommit = 0;
+select * from t1 lock in share mode;
+a	b
+1	1
+2	2
+3	1
+4	2
+5	1
+6	2
+update t1 set b = 5 where b = 1;
+set autocommit = 0;
+select * from t1 where a = 2 and b = 2 for update;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+commit;
+commit;
+drop table t1;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values (1,2),(5,3),(4,2);
+create table t2(d int not null, e int, primary key(d)) engine=innodb;
+insert into t2 values (8,6),(12,1),(3,1);
+commit;
+set autocommit = 0;
+select * from t2 for update;
+d	e
+3	1
+8	6
+12	1
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+insert into t1 select * from t2;
+update t1 set b = (select e from t2 where a = d);
+create table t3(d int not null, e int, primary key(d)) engine=innodb
+select * from t2;
+commit;
+commit;
+drop table t1, t2, t3;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values (1,2),(5,3),(4,2);
+create table t2(a int not null, b int, primary key(a)) engine=innodb;
+insert into t2 values (8,6),(12,1),(3,1);
+create table t3(d int not null, b int, primary key(d)) engine=innodb;
+insert into t3 values (8,6),(12,1),(3,1);
+create table t5(a int not null, b int, primary key(a)) engine=innodb;
+insert into t5 values (1,2),(5,3),(4,2);
+create table t6(d int not null, e int, primary key(d)) engine=innodb;
+insert into t6 values (8,6),(12,1),(3,1);
+create table t8(a int not null, b int, primary key(a)) engine=innodb;
+insert into t8 values (1,2),(5,3),(4,2);
+create table t9(d int not null, e int, primary key(d)) engine=innodb;
+insert into t9 values (8,6),(12,1),(3,1);
+commit;
+set autocommit = 0;
+select * from t2 for update;
+a	b
+3	1
+8	6
+12	1
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+insert into t1 select * from t2;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+update t3 set b = (select b from t2 where a = d);
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+insert into t5 (select * from t2 lock in share mode);
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+update t6 set e = (select b from t2 where a = d lock in share mode);
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+insert into t8 (select * from t2 for update);
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+update t9 set e = (select b from t2 where a = d for update);
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+commit;
+drop table t1, t2, t3, t5, t6, t8, t9;
+CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
+ERROR HY000: Can't create table 'test.t1' (errno: -1)
+CREATE TABLE t1 (
+a BIGINT(20) NOT NULL,
+PRIMARY KEY  (a)
+) ENGINE=INNODB DEFAULT CHARSET=UTF8;
+CREATE TABLE t2 (
+a BIGINT(20) NOT NULL,
+b VARCHAR(128) NOT NULL,
+c TEXT NOT NULL,
+PRIMARY KEY  (a,b),
+KEY idx_t2_b_c (b,c(200)),
+CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) 
+ON DELETE CASCADE
+) ENGINE=INNODB DEFAULT CHARSET=UTF8;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1, 'bar', 'vbar');
+INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
+INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
+INSERT INTO t2 VALUES (1, 'customer_over', '1');
+SELECT * FROM t2 WHERE b = 'customer_over';
+a	b	c
+1	customer_over	1
+SELECT * FROM t2 WHERE BINARY b = 'customer_over';
+a	b	c
+1	customer_over	1
+SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
+a
+1
+/* Bang: Empty result set, above was expected: */
+SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
+a
+1
+SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
+a
+1
+drop table t2, t1;
+CREATE TABLE t1 ( a int ) ENGINE=innodb;
+BEGIN;
+INSERT INTO t1 VALUES (1);
+OPTIMIZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
+test.t1	optimize	status	OK
+DROP TABLE t1;
+CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
+CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
+CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
+ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
+ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
+DELETE CASCADE ON UPDATE CASCADE;
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `id` int(11) NOT NULL,
+  `f` int(11) NOT NULL,
+  PRIMARY KEY (`id`),
+  KEY `f` (`f`),
+  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t2, t1;
+CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
+ALTER TABLE t2 MODIFY a INT NOT NULL;
+ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150)
+DELETE FROM t1;
+DROP TABLE t2,t1;
+CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
+DELETE FROM t1;
+INSERT INTO t1 VALUES ('DDD');
+SELECT * FROM t1;
+a
+DDD
+DROP TABLE t1;
+CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
+AUTO_INCREMENT=42;
+INSERT INTO t1 VALUES (0),(347),(0);
+SELECT * FROM t1;
+id
+42
+347
+348
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
+CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t2 VALUES(42),(347),(348);
+ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`id`),
+  CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
+DROP TABLE t1,t2;
+set innodb_strict_mode=on;
+CREATE TABLE t1 (
+c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
+c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
+c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
+c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
+c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
+c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
+c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
+c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
+) ENGINE = InnoDB;
+ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note	1051	Unknown table 't1'
+CREATE TABLE t1(
+id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(-10);
+SELECT * FROM t1;
+id
+-10
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+id
+-10
+1
+DROP TABLE t1;
+SET binlog_format='MIXED';
+SET TX_ISOLATION='read-committed';
+SET AUTOCOMMIT=0;
+DROP TABLE IF EXISTS t1, t2;
+Warnings:
+Note	1051	Unknown table 't1'
+Note	1051	Unknown table 't2'
+CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
+CREATE TABLE t2 LIKE t1;
+SELECT * FROM t2;
+a
+SET binlog_format='MIXED';
+SET TX_ISOLATION='read-committed';
+SET AUTOCOMMIT=0;
+INSERT INTO t1 VALUES (1);
+COMMIT;
+SELECT * FROM t1 WHERE a=1;
+a
+1
+SET binlog_format='MIXED';
+SET TX_ISOLATION='read-committed';
+SET AUTOCOMMIT=0;
+SELECT * FROM t2;
+a
+SET binlog_format='MIXED';
+SET TX_ISOLATION='read-committed';
+SET AUTOCOMMIT=0;
+INSERT INTO t1 VALUES (2);
+COMMIT;
+SELECT * FROM t1 WHERE a=2;
+a
+2
+SELECT * FROM t1 WHERE a=2;
+a
+2
+DROP TABLE t1;
+DROP TABLE t2;
+create table t1 (i int, j int) engine=innodb;
+insert into t1 (i, j) values (1, 1), (2, 2);
+update t1 set j = 2;
+affected rows: 1
+info: Rows matched: 2  Changed: 1  Warnings: 0
+drop table t1;
+create table t1 (id int) comment='this is a comment' engine=innodb;
+select table_comment, data_free > 0 as data_free_is_set
+from information_schema.tables
+where table_schema='test' and table_name = 't1';
+table_comment	data_free_is_set
+this is a comment	1
+drop table t1;
+CREATE TABLE t1 (
+c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+c2 VARCHAR(128) NOT NULL,
+PRIMARY KEY(c1)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
+CREATE TABLE t2 (
+c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+c2 INT(10) UNSIGNED DEFAULT NULL,
+PRIMARY KEY(c1)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
+SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
+AUTO_INCREMENT
+200
+ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
+SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
+AUTO_INCREMENT
+200
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (c1 int default NULL,
+c2 int default NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+TRUNCATE TABLE t1;
+affected rows: 0
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+affected rows: 5
+info: Records: 5  Duplicates: 0  Warnings: 0
+TRUNCATE TABLE t1;
+affected rows: 0
+DROP TABLE t1;
+Variable_name	Value
+Handler_update	0
+Variable_name	Value
+Handler_delete	0
+Variable_name	Value
+Handler_update	1
+Variable_name	Value
+Handler_delete	1

=== removed file 'mysql-test/r/innodb.result'
--- a/mysql-test/r/innodb.result	2009-02-19 09:01:25 +0000
+++ b/mysql-test/r/innodb.result	1970-01-01 00:00:00 +0000
@@ -1,3307 +0,0 @@
-drop table if exists t1,t2,t3,t4;
-drop database if exists mysqltest;
-create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
-insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
-select id, code, name from t1 order by id;
-id	code	name
-1	1	Tim
-2	1	Monty
-3	2	David
-4	2	Erik
-5	3	Sasha
-6	3	Jeremy
-7	4	Matt
-update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
-select id, code, name from t1 order by id;
-id	code	name
-2	1	Monty
-3	2	David
-4	2	Erik
-5	3	Sasha
-6	3	Jeremy
-7	4	Matt
-8	1	Sinisa
-update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
-select id, code, name from t1 order by id;
-id	code	name
-3	2	David
-4	2	Erik
-5	3	Sasha
-6	3	Jeremy
-7	4	Matt
-8	1	Sinisa
-12	1	Ralph
-drop table t1;
-CREATE TABLE t1 (
-id int(11) NOT NULL auto_increment,
-parent_id int(11) DEFAULT '0' NOT NULL,
-level tinyint(4) DEFAULT '0' NOT NULL,
-PRIMARY KEY (id),
-KEY parent_id (parent_id),
-KEY level (level)
-) engine=innodb;
-INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
-update t1 set parent_id=parent_id+100;
-select * from t1 where parent_id=102;
-id	parent_id	level
-8	102	2
-9	102	2
-15	102	2
-update t1 set id=id+1000;
-update t1 set id=1024 where id=1009;
-Got one of the listed errors
-select * from t1;
-id	parent_id	level
-1001	100	0
-1002	101	1
-1003	101	1
-1004	101	1
-1005	101	1
-1006	101	1
-1007	101	1
-1008	102	2
-1009	102	2
-1015	102	2
-1016	103	2
-1017	103	2
-1018	103	2
-1019	103	2
-1020	103	2
-1021	104	2
-1022	104	2
-1024	104	2
-1025	105	2
-1026	105	2
-1027	105	2
-1028	105	2
-1029	105	2
-1030	105	2
-1031	106	2
-1032	106	2
-1033	106	2
-1034	106	2
-1035	106	2
-1036	107	2
-1037	107	2
-1038	107	2
-1040	107	2
-1157	100	0
-1179	105	2
-1183	104	2
-1193	105	2
-1202	107	2
-1203	107	2
-update ignore t1 set id=id+1;
-select * from t1;
-id	parent_id	level
-1001	100	0
-1002	101	1
-1003	101	1
-1004	101	1
-1005	101	1
-1006	101	1
-1007	101	1
-1008	102	2
-1010	102	2
-1015	102	2
-1016	103	2
-1017	103	2
-1018	103	2
-1019	103	2
-1020	103	2
-1021	104	2
-1023	104	2
-1024	104	2
-1025	105	2
-1026	105	2
-1027	105	2
-1028	105	2
-1029	105	2
-1030	105	2
-1031	106	2
-1032	106	2
-1033	106	2
-1034	106	2
-1035	106	2
-1036	107	2
-1037	107	2
-1039	107	2
-1041	107	2
-1158	100	0
-1180	105	2
-1184	104	2
-1194	105	2
-1202	107	2
-1204	107	2
-update ignore t1 set id=1023 where id=1010;
-select * from t1 where parent_id=102;
-id	parent_id	level
-1008	102	2
-1010	102	2
-1015	102	2
-explain select level from t1 where level=1;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	#	Using index
-explain select level,id from t1 where level=1;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	#	Using index
-explain select level,id,parent_id from t1 where level=1;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	#	
-select level,id from t1 where level=1;
-level	id
-1	1002
-1	1003
-1	1004
-1	1005
-1	1006
-1	1007
-select level,id,parent_id from t1 where level=1;
-level	id	parent_id
-1	1002	101
-1	1003	101
-1	1004	101
-1	1005	101
-1	1006	101
-1	1007	101
-optimize table t1;
-Table	Op	Msg_type	Msg_text
-test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
-test.t1	optimize	status	OK
-show keys from t1;
-Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
-t1	0	PRIMARY	1	id	A	#	NULL	NULL		BTREE	
-t1	1	parent_id	1	parent_id	A	#	NULL	NULL		BTREE	
-t1	1	level	1	level	A	#	NULL	NULL		BTREE	
-drop table t1;
-CREATE TABLE t1 (
-gesuchnr int(11) DEFAULT '0' NOT NULL,
-benutzer_id int(11) DEFAULT '0' NOT NULL,
-PRIMARY KEY (gesuchnr,benutzer_id)
-) engine=innodb;
-replace into t1 (gesuchnr,benutzer_id) values (2,1);
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-select * from t1;
-gesuchnr	benutzer_id
-1	1
-2	1
-drop table t1;
-create table t1 (a int) engine=innodb;
-insert into t1 values (1), (2);
-optimize table t1;
-Table	Op	Msg_type	Msg_text
-test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
-test.t1	optimize	status	OK
-delete from t1 where a = 1;
-select * from t1;
-a
-2
-check table t1;
-Table	Op	Msg_type	Msg_text
-test.t1	check	status	OK
-drop table t1;
-create table t1 (a int,b varchar(20)) engine=innodb;
-insert into t1 values (1,""), (2,"testing");
-delete from t1 where a = 1;
-select * from t1;
-a	b
-2	testing
-create index skr on t1 (a);
-insert into t1 values (3,""), (4,"testing");
-analyze table t1;
-Table	Op	Msg_type	Msg_text
-test.t1	analyze	status	OK
-show keys from t1;
-Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
-t1	1	skr	1	a	A	#	NULL	NULL	YES	BTREE	
-drop table t1;
-create table t1 (a int,b varchar(20),key(a)) engine=innodb;
-insert into t1 values (1,""), (2,"testing");
-select * from t1 where a = 1;
-a	b
-1	
-drop table t1;
-create table t1 (n int not null primary key) engine=innodb;
-set autocommit=0;
-insert into t1 values (4);
-rollback;
-select n, "after rollback" from t1;
-n	after rollback
-insert into t1 values (4);
-commit;
-select n, "after commit" from t1;
-n	after commit
-4	after commit
-commit;
-insert into t1 values (5);
-insert into t1 values (4);
-ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
-commit;
-select n, "after commit" from t1;
-n	after commit
-4	after commit
-5	after commit
-set autocommit=1;
-insert into t1 values (6);
-insert into t1 values (4);
-ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
-select n from t1;
-n
-4
-5
-6
-set autocommit=0;
-begin;
-savepoint `my_savepoint`;
-insert into t1 values (7);
-savepoint `savept2`;
-insert into t1 values (3);
-select n from t1;
-n
-3
-4
-5
-6
-7
-savepoint savept3;
-rollback to savepoint savept2;
-rollback to savepoint savept3;
-ERROR 42000: SAVEPOINT savept3 does not exist
-rollback to savepoint savept2;
-release savepoint `my_savepoint`;
-select n from t1;
-n
-4
-5
-6
-7
-rollback to savepoint `my_savepoint`;
-ERROR 42000: SAVEPOINT my_savepoint does not exist
-rollback to savepoint savept2;
-ERROR 42000: SAVEPOINT savept2 does not exist
-insert into t1 values (8);
-savepoint sv;
-commit;
-savepoint sv;
-set autocommit=1;
-rollback;
-drop table t1;
-create table t1 (n int not null primary key) engine=innodb;
-start transaction;
-insert into t1 values (4);
-flush tables with read lock;
-commit;
-unlock tables;
-commit;
-select * from t1;
-n
-4
-drop table t1;
-create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb;
-begin;
-insert into t1 values(1,'hamdouni');
-select id as afterbegin_id,nom as afterbegin_nom from t1;
-afterbegin_id	afterbegin_nom
-1	hamdouni
-rollback;
-select id as afterrollback_id,nom as afterrollback_nom from t1;
-afterrollback_id	afterrollback_nom
-set autocommit=0;
-insert into t1 values(2,'mysql');
-select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
-afterautocommit0_id	afterautocommit0_nom
-2	mysql
-rollback;
-select id as afterrollback_id,nom as afterrollback_nom from t1;
-afterrollback_id	afterrollback_nom
-set autocommit=1;
-drop table t1;
-CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb;
-insert into t1 values ('pippo', 12);
-insert into t1 values ('pippo', 12);
-ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY'
-delete from t1;
-delete from t1 where id = 'pippo';
-select * from t1;
-id	val
-insert into t1 values ('pippo', 12);
-set autocommit=0;
-delete from t1;
-rollback;
-select * from t1;
-id	val
-pippo	12
-delete from t1;
-commit;
-select * from t1;
-id	val
-drop table t1;
-create table t1 (a integer) engine=innodb;
-start transaction;
-rename table t1 to t2;
-create table t1 (b integer) engine=innodb;
-insert into t1 values (1);
-rollback;
-drop table t1;
-rename table t2 to t1;
-drop table t1;
-set autocommit=1;
-CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb;
-INSERT INTO t1 VALUES (1, 'Jochen');
-select * from t1;
-ID	NAME
-1	Jochen
-drop table t1;
-CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb;
-set autocommit=0;
-INSERT INTO t1  SET _userid='marc@xxxxxxxxxxxxx';
-COMMIT;
-SELECT * FROM t1;
-_userid
-marc@xxxxxxxxxxxxx
-SELECT _userid FROM t1 WHERE _userid='marc@xxxxxxxxxxxxx';
-_userid
-marc@xxxxxxxxxxxxx
-drop table t1;
-set autocommit=1;
-CREATE TABLE t1 (
-user_id int(10) DEFAULT '0' NOT NULL,
-name varchar(100),
-phone varchar(100),
-ref_email varchar(100) DEFAULT '' NOT NULL,
-detail varchar(200),
-PRIMARY KEY (user_id,ref_email)
-)engine=innodb;
-INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@xxxxxxxxxxx','xxx'),(10292,'shirish','2333604','shirish@xxxxxxxxx','ddsds'),(10292,'sonali','323232','sonali@xxxxxxxxx','filmstar');
-select * from t1 where user_id=10292;
-user_id	name	phone	ref_email	detail
-10292	sanjeev	29153373	sansh777@xxxxxxxxxxx	xxx
-10292	shirish	2333604	shirish@xxxxxxxxx	ddsds
-10292	sonali	323232	sonali@xxxxxxxxx	filmstar
-INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@xxxxxxxxxxx','xxx'),(10293,'shirish','2333604','shirish@xxxxxxxxx','ddsds');
-select * from t1 where user_id=10292;
-user_id	name	phone	ref_email	detail
-10292	sanjeev	29153373	sansh777@xxxxxxxxxxx	xxx
-10292	shirish	2333604	shirish@xxxxxxxxx	ddsds
-10292	sonali	323232	sonali@xxxxxxxxx	filmstar
-select * from t1 where user_id>=10292;
-user_id	name	phone	ref_email	detail
-10292	sanjeev	29153373	sansh777@xxxxxxxxxxx	xxx
-10292	shirish	2333604	shirish@xxxxxxxxx	ddsds
-10292	sonali	323232	sonali@xxxxxxxxx	filmstar
-10293	shirish	2333604	shirish@xxxxxxxxx	ddsds
-select * from t1 where user_id>10292;
-user_id	name	phone	ref_email	detail
-10293	shirish	2333604	shirish@xxxxxxxxx	ddsds
-select * from t1 where user_id<10292;
-user_id	name	phone	ref_email	detail
-10291	sanjeev	29153373	sansh777@xxxxxxxxxxx	xxx
-drop table t1;
-CREATE TABLE t1 (a int not null, b int not null,c int not null,
-key(a),primary key(a,b), unique(c),key(a),unique(b));
-show index from t1;
-Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
-t1	0	PRIMARY	1	a	A	#	NULL	NULL		BTREE	
-t1	0	PRIMARY	2	b	A	#	NULL	NULL		BTREE	
-t1	0	c	1	c	A	#	NULL	NULL		BTREE	
-t1	0	b	1	b	A	#	NULL	NULL		BTREE	
-t1	1	a	1	a	A	#	NULL	NULL		BTREE	
-t1	1	a_2	1	a	A	#	NULL	NULL		BTREE	
-drop table t1;
-create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
-alter table t1 engine=innodb;
-insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
-select * from t1;
-col1	col2
-1	1
-2	3
-3	4
-4	4
-5	2
-update t1 set col2='7' where col1='4';
-select * from t1;
-col1	col2
-1	1
-2	3
-3	4
-4	7
-5	2
-alter table t1 add co3 int not null;
-select * from t1;
-col1	col2	co3
-1	1	0
-2	3	0
-3	4	0
-4	7	0
-5	2	0
-update t1 set col2='9' where col1='2';
-select * from t1;
-col1	col2	co3
-1	1	0
-2	9	0
-3	4	0
-4	7	0
-5	2	0
-drop table t1;
-create table t1 (a int not null , b int, primary key (a)) engine = innodb;
-create table t2 (a int not null , b int, primary key (a)) engine = myisam;
-insert into t1 VALUES (1,3) , (2,3), (3,3);
-select * from t1;
-a	b
-1	3
-2	3
-3	3
-insert into t2 select * from t1;
-select * from t2;
-a	b
-1	3
-2	3
-3	3
-delete from t1 where b = 3;
-select * from t1;
-a	b
-insert into t1 select * from t2;
-select * from t1;
-a	b
-1	3
-2	3
-3	3
-select * from t2;
-a	b
-1	3
-2	3
-3	3
-drop table t1,t2;
-CREATE TABLE t1 (
-user_name varchar(12),
-password text,
-subscribed char(1),
-user_id int(11) DEFAULT '0' NOT NULL,
-quota bigint(20),
-weight double,
-access_date date,
-access_time time,
-approved datetime,
-dummy_primary_key int(11) NOT NULL auto_increment,
-PRIMARY KEY (dummy_primary_key)
-) ENGINE=innodb;
-INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
-INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
-INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
-INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
-INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
-select  user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
-user_name	password	subscribed	user_id	quota	weight	access_date	access_time	approved	dummy_primary_key
-user_0	somepassword	N	0	0	0	2000-09-07	23:06:59	2000-09-07 23:06:59	1
-user_1	somepassword	Y	1	1	1	2000-09-07	23:06:59	2000-09-07 23:06:59	2
-user_2	somepassword	N	2	2	1.4142135623731	2000-09-07	23:06:59	2000-09-07 23:06:59	3
-user_3	somepassword	Y	3	3	1.7320508075689	2000-09-07	23:06:59	2000-09-07 23:06:59	4
-user_4	somepassword	N	4	4	2	2000-09-07	23:06:59	2000-09-07 23:06:59	5
-drop table t1;
-CREATE TABLE t1 (
-id int(11) NOT NULL auto_increment,
-parent_id int(11) DEFAULT '0' NOT NULL,
-level tinyint(4) DEFAULT '0' NOT NULL,
-KEY (id),
-KEY parent_id (parent_id),
-KEY level (level)
-) engine=innodb;
-INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
-INSERT INTO t1 values (179,5,2);
-update t1 set parent_id=parent_id+100;
-select * from t1 where parent_id=102;
-id	parent_id	level
-8	102	2
-9	102	2
-15	102	2
-update t1 set id=id+1000;
-update t1 set id=1024 where id=1009;
-select * from t1;
-id	parent_id	level
-1001	100	0
-1003	101	1
-1004	101	1
-1008	102	2
-1024	102	2
-1017	103	2
-1022	104	2
-1024	104	2
-1028	105	2
-1029	105	2
-1030	105	2
-1031	106	2
-1032	106	2
-1033	106	2
-1203	107	2
-1202	107	2
-1020	103	2
-1157	100	0
-1193	105	2
-1040	107	2
-1002	101	1
-1015	102	2
-1006	101	1
-1034	106	2
-1035	106	2
-1016	103	2
-1007	101	1
-1036	107	2
-1018	103	2
-1026	105	2
-1027	105	2
-1183	104	2
-1038	107	2
-1025	105	2
-1037	107	2
-1021	104	2
-1019	103	2
-1005	101	1
-1179	105	2
-update ignore t1 set id=id+1;
-select * from t1;
-id	parent_id	level
-1002	100	0
-1004	101	1
-1005	101	1
-1009	102	2
-1025	102	2
-1018	103	2
-1023	104	2
-1025	104	2
-1029	105	2
-1030	105	2
-1031	105	2
-1032	106	2
-1033	106	2
-1034	106	2
-1204	107	2
-1203	107	2
-1021	103	2
-1158	100	0
-1194	105	2
-1041	107	2
-1003	101	1
-1016	102	2
-1007	101	1
-1035	106	2
-1036	106	2
-1017	103	2
-1008	101	1
-1037	107	2
-1019	103	2
-1027	105	2
-1028	105	2
-1184	104	2
-1039	107	2
-1026	105	2
-1038	107	2
-1022	104	2
-1020	103	2
-1006	101	1
-1180	105	2
-update ignore t1 set id=1023 where id=1010;
-select * from t1 where parent_id=102;
-id	parent_id	level
-1009	102	2
-1025	102	2
-1016	102	2
-explain select level from t1 where level=1;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	#	Using index
-select level,id from t1 where level=1;
-level	id
-1	1004
-1	1005
-1	1003
-1	1007
-1	1008
-1	1006
-select level,id,parent_id from t1 where level=1;
-level	id	parent_id
-1	1004	101
-1	1005	101
-1	1003	101
-1	1007	101
-1	1008	101
-1	1006	101
-select level,id from t1 where level=1 order by id;
-level	id
-1	1003
-1	1004
-1	1005
-1	1006
-1	1007
-1	1008
-delete from t1 where level=1;
-select * from t1;
-id	parent_id	level
-1002	100	0
-1009	102	2
-1025	102	2
-1018	103	2
-1023	104	2
-1025	104	2
-1029	105	2
-1030	105	2
-1031	105	2
-1032	106	2
-1033	106	2
-1034	106	2
-1204	107	2
-1203	107	2
-1021	103	2
-1158	100	0
-1194	105	2
-1041	107	2
-1016	102	2
-1035	106	2
-1036	106	2
-1017	103	2
-1037	107	2
-1019	103	2
-1027	105	2
-1028	105	2
-1184	104	2
-1039	107	2
-1026	105	2
-1038	107	2
-1022	104	2
-1020	103	2
-1180	105	2
-drop table t1;
-CREATE TABLE t1 (
-sca_code char(6) NOT NULL,
-cat_code char(6) NOT NULL,
-sca_desc varchar(50),
-lan_code char(2) NOT NULL,
-sca_pic varchar(100),
-sca_sdesc varchar(50),
-sca_sch_desc varchar(16),
-PRIMARY KEY (sca_code, cat_code, lan_code),
-INDEX sca_pic (sca_pic)
-) engine = innodb ;
-INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
-select count(*) from t1 where sca_code = 'PD';
-count(*)
-1
-select count(*) from t1 where sca_code <= 'PD';
-count(*)
-1
-select count(*) from t1 where sca_pic is null;
-count(*)
-2
-alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
-select count(*) from t1 where sca_code='PD' and sca_pic is null;
-count(*)
-1
-select count(*) from t1 where cat_code='E';
-count(*)
-0
-alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
-select count(*) from t1 where sca_code='PD' and sca_pic is null;
-count(*)
-1
-select count(*) from t1 where sca_pic >= 'n';
-count(*)
-1
-select sca_pic from t1 where sca_pic is null;
-sca_pic
-NULL
-NULL
-update t1 set sca_pic="test" where sca_pic is null;
-delete from t1 where sca_code='pd';
-drop table t1;
-set @a:=now();
-CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
-insert into t1 (a) values(1),(2),(3);
-select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
-a
-1
-2
-3
-select a from t1 natural join t1 as t2 where b >= @a order by a;
-a
-1
-2
-3
-update t1 set a=5 where a=1;
-select a from t1;
-a
-2
-3
-5
-drop table t1;
-create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb;
-insert into t1 values("hello",1),("world",2);
-select * from t1 order by b desc;
-a	b
-world	2
-hello	1
-optimize table t1;
-Table	Op	Msg_type	Msg_text
-test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
-test.t1	optimize	status	OK
-show keys from t1;
-Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
-t1	0	PRIMARY	1	a	A	#	NULL	NULL		BTREE	
-drop table t1;
-create table t1 (i int, j int ) ENGINE=innodb;
-insert into t1 values (1,2);
-select * from t1 where i=1 and j=2;
-i	j
-1	2
-create index ax1 on t1 (i,j);
-select * from t1 where i=1 and j=2;
-i	j
-1	2
-drop table t1;
-CREATE TABLE t1 (
-a int3 unsigned NOT NULL,
-b int1 unsigned NOT NULL,
-UNIQUE (a, b)
-) ENGINE = innodb;
-INSERT INTO t1 VALUES (1, 1);
-SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
-MIN(B)	MAX(b)
-1	1
-drop table t1;
-CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb;
-INSERT INTO t1 VALUES (1);
-SELECT * FROM t1;
-a
-1
-DROP TABLE t1;
-create table t1 (a int  primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb;
-insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
-explain select * from t1 where a > 0 and a < 50;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	#	Using where
-drop table t1;
-create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
-insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
-LOCK TABLES t1 WRITE;
-insert into t1 values (99,1,2,'D'),(1,1,2,'D');
-ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
-select id from t1;
-id
-0
-1
-2
-select id from t1;
-id
-0
-1
-2
-UNLOCK TABLES;
-DROP TABLE t1;
-create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
-insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
-LOCK TABLES t1 WRITE;
-begin;
-insert into t1 values (99,1,2,'D'),(1,1,2,'D');
-ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
-select id from t1;
-id
-0
-1
-2
-insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
-commit;
-select id,id3 from t1;
-id	id3
-0	0
-1	1
-2	2
-100	2
-UNLOCK TABLES;
-DROP TABLE t1;
-create table t1 (a char(20), unique (a(5))) engine=innodb;
-drop table t1;
-create table t1 (a char(20), index (a(5))) engine=innodb;
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` char(20) DEFAULT NULL,
-  KEY `a` (`a`(5))
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t1;
-create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;
-insert into t1 values (NULL),(NULL),(NULL);
-delete from t1 where a=3;
-insert into t1 values (NULL);
-select * from t1;
-a
-1
-2
-4
-alter table t1 add b int;
-select * from t1;
-a	b
-1	NULL
-2	NULL
-4	NULL
-drop table t1;
-create table t1
-(
-id int auto_increment primary key,
-name varchar(32) not null,
-value text not null,
-uid int not null,
-unique key(name,uid)
-) engine=innodb;
-insert into t1 values (1,'one','one value',101),
-(2,'two','two value',102),(3,'three','three value',103);
-set insert_id=5;
-replace into t1 (value,name,uid) values ('other value','two',102);
-delete from t1 where uid=102;
-set insert_id=5;
-replace into t1 (value,name,uid) values ('other value','two',102);
-set insert_id=6;
-replace into t1 (value,name,uid) values ('other value','two',102);
-select * from t1;
-id	name	value	uid
-1	one	one value	101
-3	three	three value	103
-6	two	other value	102
-drop table t1;
-create database mysqltest;
-create table mysqltest.t1 (a int not null) engine= innodb;
-insert into mysqltest.t1 values(1);
-create table mysqltest.t2 (a int not null) engine= myisam;
-insert into mysqltest.t2 values(1);
-create table mysqltest.t3 (a int not null) engine= heap;
-insert into mysqltest.t3 values(1);
-commit;
-drop database mysqltest;
-show tables from mysqltest;
-ERROR 42000: Unknown database 'mysqltest'
-set autocommit=0;
-create table t1 (a int not null) engine= innodb;
-insert into t1 values(1),(2);
-truncate table t1;
-commit;
-truncate table t1;
-truncate table t1;
-select * from t1;
-a
-insert into t1 values(1),(2);
-delete from t1;
-select * from t1;
-a
-commit;
-drop table t1;
-set autocommit=1;
-create table t1 (a int not null) engine= innodb;
-insert into t1 values(1),(2);
-truncate table t1;
-insert into t1 values(1),(2);
-select * from t1;
-a
-1
-2
-truncate table t1;
-insert into t1 values(1),(2);
-delete from t1;
-select * from t1;
-a
-drop table t1;
-create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb;
-insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
-explain select * from t1 order by a;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	#	
-explain select * from t1 order by b;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	#	Using filesort
-explain select * from t1 order by c;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	#	Using filesort
-explain select a from t1 order by a;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	PRIMARY	4	NULL	#	Using index
-explain select b from t1 order by b;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	b	4	NULL	#	Using index
-explain select a,b from t1 order by b;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	b	4	NULL	#	Using index
-explain select a,b from t1;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	b	4	NULL	#	Using index
-explain select a,b,c from t1;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	#	
-drop table t1;
-create table t1 (t int not null default 1, key (t)) engine=innodb;
-desc t1;
-Field	Type	Null	Key	Default	Extra
-t	int(11)	NO	MUL	1	
-drop table t1;
-CREATE TABLE t1 (
-number bigint(20) NOT NULL default '0',
-cname char(15) NOT NULL default '',
-carrier_id smallint(6) NOT NULL default '0',
-privacy tinyint(4) NOT NULL default '0',
-last_mod_date timestamp NOT NULL,
-last_mod_id smallint(6) NOT NULL default '0',
-last_app_date timestamp NOT NULL,
-last_app_id smallint(6) default '-1',
-version smallint(6) NOT NULL default '0',
-assigned_scps int(11) default '0',
-status tinyint(4) default '0'
-) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
-INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
-INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
-INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
-INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
-INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
-CREATE TABLE t2 (
-number bigint(20) NOT NULL default '0',
-cname char(15) NOT NULL default '',
-carrier_id smallint(6) NOT NULL default '0',
-privacy tinyint(4) NOT NULL default '0',
-last_mod_date timestamp NOT NULL,
-last_mod_id smallint(6) NOT NULL default '0',
-last_app_date timestamp NOT NULL,
-last_app_id smallint(6) default '-1',
-version smallint(6) NOT NULL default '0',
-assigned_scps int(11) default '0',
-status tinyint(4) default '0'
-) ENGINE=InnoDB;
-INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
-INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
-INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
-INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
-select * from t1;
-number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
-4077711111	SeanWheeler	90	2	2002-01-11 11:28:46	500	0000-00-00 00:00:00	-1	2	3	1
-9197722223	berry	90	3	2002-01-11 11:28:09	500	2002-01-02 11:45:32	501	4	10	0
-650	San Francisco	0	0	2001-12-27 11:13:36	342	0000-00-00 00:00:00	-1	1	24	1
-302467	Sue's Subshop	90	3	2002-01-09 11:32:41	500	2002-01-02 11:51:11	501	7	24	0
-6014911113	SudzCarwash	520	1	2002-01-02 11:52:34	500	2002-01-02 11:52:59	501	33	32768	0
-333	tubs	99	2	2002-01-09 11:34:40	501	2002-01-09 11:34:40	500	3	10	0
-select * from t2;
-number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
-4077711111	SeanWheeler	0	2	2002-01-11 11:28:53	500	0000-00-00 00:00:00	-1	2	3	1
-9197722223	berry	90	3	2002-01-11 11:28:18	500	2002-01-02 11:45:32	501	4	10	0
-650	San Francisco	90	0	2002-01-09 11:31:58	342	0000-00-00 00:00:00	-1	1	24	1
-333	tubs	99	2	2002-01-09 11:34:53	501	2002-01-09 11:34:53	500	3	10	0
-delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);
-select * from t1;
-number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
-6014911113	SudzCarwash	520	1	2002-01-02 11:52:34	500	2002-01-02 11:52:59	501	33	32768	0
-333	tubs	99	2	2002-01-09 11:34:40	501	2002-01-09 11:34:40	500	3	10	0
-select * from t2;
-number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
-333	tubs	99	2	2002-01-09 11:34:53	501	2002-01-09 11:34:53	500	3	10	0
-select * from t2;
-number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
-333	tubs	99	2	2002-01-09 11:34:53	501	2002-01-09 11:34:53	500	3	10	0
-drop table t1,t2;
-create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
-BEGIN;
-SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-SELECT @@tx_isolation,@@global.tx_isolation;
-@@tx_isolation	@@global.tx_isolation
-SERIALIZABLE	REPEATABLE-READ
-insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
-select id, code, name from t1 order by id;
-id	code	name
-1	1	Tim
-2	1	Monty
-3	2	David
-COMMIT;
-BEGIN;
-SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
-insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
-select id, code, name from t1 order by id;
-id	code	name
-1	1	Tim
-2	1	Monty
-3	2	David
-4	2	Erik
-5	3	Sasha
-COMMIT;
-SET binlog_format='MIXED';
-BEGIN;
-SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
-insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
-select id, code, name from t1 order by id;
-id	code	name
-1	1	Tim
-2	1	Monty
-3	2	David
-4	2	Erik
-5	3	Sasha
-6	3	Jeremy
-7	4	Matt
-COMMIT;
-DROP TABLE t1;
-create table t1 (n int(10), d int(10)) engine=innodb;
-create table t2 (n int(10), d int(10)) engine=innodb;
-insert into t1 values(1,1),(1,2);
-insert into t2 values(1,10),(2,20);
-UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
-select * from t1;
-n	d
-1	10
-1	10
-select * from t2;
-n	d
-1	30
-2	20
-drop table t1,t2;
-drop table if exists t1, t2;
-CREATE TABLE t1 (a int, PRIMARY KEY (a));
-CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
-create trigger trg_del_t2 after  delete on t2 for each row
-insert into t1 values (1);
-insert into t1 values (1);
-insert into t2 values (1),(2);
-delete t2 from t2;
-ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
-select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
-count(*)
-2
-drop table t1, t2;
-drop table if exists t1, t2;
-CREATE TABLE t1 (a int, PRIMARY KEY (a));
-CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
-create trigger trg_del_t2 after  delete on t2 for each row
-insert into t1 values (1);
-insert into t1 values (1);
-insert into t2 values (1),(2);
-delete t2 from t2;
-ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
-select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
-count(*)
-2
-drop table t1, t2;
-create table t1 (a int, b int) engine=innodb;
-insert into t1 values(20,null);
-select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
-t2.b=t3.a;
-b	ifnull(t2.b,"this is null")
-NULL	this is null
-select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
-t2.b=t3.a order by 1;
-b	ifnull(t2.b,"this is null")
-NULL	this is null
-insert into t1 values(10,null);
-select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
-t2.b=t3.a order by 1;
-b	ifnull(t2.b,"this is null")
-NULL	this is null
-NULL	this is null
-drop table t1;
-create table t1 (a varchar(10) not null) engine=myisam;
-create table t2 (b varchar(10) not null unique) engine=innodb;
-select t1.a from t1,t2 where t1.a=t2.b;
-a
-drop table t1,t2;
-create table t1 (a int not null, b int, primary key (a)) engine = innodb;
-create table t2 (a int not null, b int, primary key (a)) engine = innodb;
-insert into t1 values (10, 20);
-insert into t2 values (10, 20);
-update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
-drop table t1,t2;
-CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
-CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id)  ON DELETE CASCADE ) ENGINE=INNODB;
-insert into t1 set id=1;
-insert into t2 set id=1, t1_id=1;
-delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
-select * from t1;
-id
-select * from t2;
-id	t1_id
-drop table t2,t1;
-CREATE TABLE t1(id INT NOT NULL,  PRIMARY KEY (id)) ENGINE=INNODB;
-CREATE TABLE t2(id  INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id)  ) ENGINE=INNODB;
-INSERT INTO t1 VALUES(1);
-INSERT INTO t2 VALUES(1, 1);
-SELECT * from t1;
-id
-1
-UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
-SELECT * from t1;
-id
-2
-UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
-SELECT * from t1;
-id
-3
-DROP TABLE t1,t2;
-set autocommit=0;
-CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
-CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
-CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB;
-INSERT INTO t3 VALUES("my-test-1", "my-test-2");
-COMMIT;
-INSERT INTO t1 VALUES("this-key", "will disappear");
-INSERT INTO t2 VALUES("this-key", "will also disappear");
-DELETE FROM t3 WHERE id1="my-test-1";
-SELECT * FROM t1;
-id	value
-this-key	will disappear
-SELECT * FROM t2;
-id	value
-this-key	will also disappear
-SELECT * FROM t3;
-id1	id2
-ROLLBACK;
-SELECT * FROM t1;
-id	value
-SELECT * FROM t2;
-id	value
-SELECT * FROM t3;
-id1	id2
-my-test-1	my-test-2
-SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE;
-id1	id2
-my-test-1	my-test-2
-COMMIT;
-set autocommit=1;
-DROP TABLE t1,t2,t3;
-CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb;
-INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
-UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
-SELECT * from t1;
-a	b
-1	1
-102	2
-103	3
-4	4
-5	5
-6	6
-7	7
-8	8
-9	9
-drop table t1;
-CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb;
-CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb;
-INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
-INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
-update t1,t2 set t1.a=t1.a+100;
-select * from t1;
-a	b
-101	1
-102	2
-103	3
-104	4
-105	5
-106	6
-107	7
-108	8
-109	9
-110	10
-111	11
-112	12
-update t1,t2 set t1.a=t1.a+100 where t1.a=101;
-select * from t1;
-a	b
-201	1
-102	2
-103	3
-104	4
-105	5
-106	6
-107	7
-108	8
-109	9
-110	10
-111	11
-112	12
-update t1,t2 set t1.b=t1.b+10 where t1.b=2;
-select * from t1;
-a	b
-201	1
-103	3
-104	4
-105	5
-106	6
-107	7
-108	8
-109	9
-110	10
-111	11
-102	12
-112	12
-update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
-select * from t1;
-a	b
-201	1
-103	5
-104	6
-106	6
-105	7
-107	7
-108	8
-109	9
-110	10
-111	11
-102	12
-112	12
-select * from t2;
-a	b
-1	1
-2	2
-6	6
-7	7
-8	8
-9	9
-3	13
-4	14
-5	15
-drop table t1,t2;
-CREATE TABLE t2 (   NEXT_T         BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
-CREATE TABLE t1 (  B_ID           INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
-SET AUTOCOMMIT=0;
-INSERT INTO t1 ( B_ID ) VALUES ( 1 );
-INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
-ROLLBACK;
-Warnings:
-Warning	1196	Some non-transactional changed tables couldn't be rolled back
-SELECT * FROM t1;
-B_ID
-drop table  t1,t2;
-create table t1  ( pk         int primary key,    parent     int not null,    child      int not null,       index (parent)  ) engine = innodb;
-insert into t1 values   (1,0,4),  (2,1,3),  (3,2,1),  (4,1,2);
-select distinct  parent,child   from t1   order by parent;
-parent	child
-0	4
-1	2
-1	3
-2	1
-drop table t1;
-create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
-create table t2 (a int not null auto_increment primary key, b int);
-insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
-insert into t2 (a) select b from t1;
-insert into t1 (b) select b from t2;
-insert into t2 (a) select b from t1;
-insert into t1 (a) select b from t2;
-insert into t2 (a) select b from t1;
-insert into t1 (a) select b from t2;
-insert into t2 (a) select b from t1;
-insert into t1 (a) select b from t2;
-insert into t2 (a) select b from t1;
-insert into t1 (a) select b from t2;
-select count(*) from t1;
-count(*)
-623
-explain select * from t1 where c between 1 and 2500;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	c	c	5	NULL	#	Using where
-update t1 set c=a;
-explain select * from t1 where c between 1 and 2500;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	c	NULL	NULL	NULL	#	Using where
-drop table t1,t2;
-create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb;
-insert into t1 (id) values (null),(null),(null),(null),(null);
-update t1 set fk=69 where fk is null order by id limit 1;
-SELECT * from t1;
-id	fk
-2	NULL
-3	NULL
-4	NULL
-5	NULL
-1	69
-drop table t1;
-create table t1 (a int not null, b int not null, key (a));
-insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
-SET @tmp=0;
-update t1 set b=(@tmp:=@tmp+1) order by a;
-update t1 set b=99 where a=1 order by b asc limit 1;
-update t1 set b=100 where a=1 order by b desc limit 2;
-update t1 set a=a+10+b where a=1 order by b;
-select * from t1 order by a,b;
-a	b
-2	4
-2	5
-2	6
-3	7
-3	8
-3	9
-3	10
-3	11
-3	12
-13	2
-111	100
-111	100
-drop table t1;
-create table t1 ( c char(8) not null ) engine=innodb;
-insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
-insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
-alter table t1 add b char(8) not null;
-alter table t1 add a char(8) not null;
-alter table t1 add primary key (a,b,c);
-update t1 set a=c, b=c;
-create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
-insert into t2 select * from t1;
-delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
-drop table t1,t2;
-SET AUTOCOMMIT=1;
-create table t1 (a integer auto_increment primary key) engine=innodb;
-insert into t1 (a) values (NULL),(NULL);
-truncate table t1;
-insert into t1 (a) values (NULL),(NULL);
-SELECT * from t1;
-a
-1
-2
-drop table t1;
-CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB;
-CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`)  ON DELETE CASCADE ) ENGINE=INNODB;
-drop table t2,t1;
-create table `t1` (`id` int( 11 ) not null  ,primary key ( `id` )) engine = innodb;
-insert into `t1`values ( 1 ) ;
-create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
-insert into `t2`values ( 1 ) ;
-create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
-insert into `t3`values ( 1 ) ;
-delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
-update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
-update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
-ERROR 42S22: Unknown column 't1.id' in 'where clause'
-drop table t3,t2,t1;
-create table t1(
-id int primary key,
-pid int,
-index(pid),
-foreign key(pid) references t1(id) on delete cascade) engine=innodb;
-insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
-(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
-delete from t1 where id=0;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `t1` (`id`) ON DELETE CASCADE)
-delete from t1 where id=15;
-delete from t1 where id=0;
-drop table t1;
-CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
-CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
-(stamp))ENGINE=InnoDB;
-insert into t1 values (1),(2),(3);
-insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
-Warnings:
-Warning	1265	Data truncated for column 'stamp' at row 3
-SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
-'20020204120000' GROUP BY col1;
-col1
-1
-2
-3
-4
-drop table t1,t2;
-CREATE TABLE t1 (
-`id` int(10) unsigned NOT NULL auto_increment,
-`id_object` int(10) unsigned default '0',
-`id_version` int(10) unsigned NOT NULL default '1',
-`label` varchar(100) NOT NULL default '',
-`description` text,
-PRIMARY KEY  (`id`),
-KEY `id_object` (`id_object`),
-KEY `id_version` (`id_version`)
-) ENGINE=InnoDB;
-INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
-CREATE TABLE t2 (
-`id` int(10) unsigned NOT NULL auto_increment,
-`id_version` int(10) unsigned NOT NULL default '1',
-PRIMARY KEY  (`id`),
-KEY `id_version` (`id_version`)
-) ENGINE=InnoDB;
-INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
-SELECT t2.id, t1.`label` FROM t2 INNER JOIN
-(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl 
-ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
-id	label
-3382	Test
-102	Le Pekin (Test)
-1794	Test de resto
-1822	Test 3
-3524	Societe Test
-3525	Fournisseur Test
-drop table t1,t2;
-create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
-create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
-create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
-insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
-insert t2 select * from t1;
-insert t3 select * from t1;
-checksum table t1, t2, t3, t4 quick;
-Table	Checksum
-test.t1	3442722830
-test.t2	NULL
-test.t3	NULL
-test.t4	NULL
-Warnings:
-Error	1146	Table 'test.t4' doesn't exist
-checksum table t1, t2, t3, t4;
-Table	Checksum
-test.t1	3442722830
-test.t2	3442722830
-test.t3	3442722830
-test.t4	NULL
-Warnings:
-Error	1146	Table 'test.t4' doesn't exist
-checksum table t1, t2, t3, t4 extended;
-Table	Checksum
-test.t1	3442722830
-test.t2	3442722830
-test.t3	3442722830
-test.t4	NULL
-Warnings:
-Error	1146	Table 'test.t4' doesn't exist
-drop table t1,t2,t3;
-create table t1 (id int,  name char(10) not null,  name2 char(10) not null) engine=innodb;
-insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
-select trim(name2) from t1  union all  select trim(name) from t1 union all select trim(id) from t1;
-trim(name2)
-fff
-sss
-ttt
-first
-second
-third
-1
-2
-3
-drop table t1;
-create table t1 (a int) engine=innodb;
-create table t2 like t1;
-drop table t1,t2;
-create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb;
-create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb;
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `id` int(11) NOT NULL,
-  `id2` int(11) NOT NULL,
-  UNIQUE KEY `id` (`id`,`id2`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  KEY `t1_id_fk` (`id`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-create index id on t2 (id);
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  KEY `id` (`id`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-create index id2 on t2 (id);
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  KEY `id` (`id`),
-  KEY `id2` (`id`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop index id2 on t2;
-drop index id on t2;
-Got one of the listed errors
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  KEY `id` (`id`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2;
-create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  `id2` int(11) NOT NULL,
-  KEY `t1_id_fk` (`id`,`id2`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-create unique index id on t2 (id,id2);
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  `id2` int(11) NOT NULL,
-  UNIQUE KEY `id` (`id`,`id2`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2;
-create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  `id2` int(11) NOT NULL,
-  UNIQUE KEY `id` (`id`,`id2`),
-  KEY `t1_id_fk` (`id2`,`id`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2;
-create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  `id2` int(11) NOT NULL,
-  UNIQUE KEY `id` (`id`,`id2`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2;
-create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  `id2` int(11) NOT NULL,
-  UNIQUE KEY `id` (`id`,`id2`),
-  KEY `t1_id_fk` (`id2`,`id`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2;
-create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `id2` int(11) NOT NULL,
-  PRIMARY KEY (`id`),
-  KEY `id` (`id`,`id2`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2;
-create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `id2` int(11) NOT NULL,
-  KEY `t1_id_fk` (`id`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-alter table t2 add index id_test (id), add index id_test2 (id,id2);
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `id2` int(11) NOT NULL,
-  KEY `id_test` (`id`),
-  KEY `id_test2` (`id`,`id2`),
-  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2;
-create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
-ERROR 42000: Incorrect foreign key definition for 't1_id_fk': Key reference and table reference don't match
-create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `a` int(11) NOT NULL AUTO_INCREMENT,
-  `b` int(11) DEFAULT NULL,
-  PRIMARY KEY (`a`),
-  UNIQUE KEY `b_2` (`b`),
-  KEY `b` (`b`),
-  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2;
-create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `a` int(11) NOT NULL AUTO_INCREMENT,
-  `b` int(11) DEFAULT NULL,
-  PRIMARY KEY (`a`),
-  UNIQUE KEY `b` (`b`),
-  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`),
-  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t2, t1;
-create table t1 (c char(10), index (c,c)) engine=innodb;
-ERROR 42S21: Duplicate column name 'c'
-create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
-ERROR 42S21: Duplicate column name 'c1'
-create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
-ERROR 42S21: Duplicate column name 'c1'
-create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
-ERROR 42S21: Duplicate column name 'c1'
-create table t1 (c1 char(10), c2 char(10)) engine=innodb;
-alter table t1 add key (c1,c1);
-ERROR 42S21: Duplicate column name 'c1'
-alter table t1 add key (c2,c1,c1);
-ERROR 42S21: Duplicate column name 'c1'
-alter table t1 add key (c1,c2,c1);
-ERROR 42S21: Duplicate column name 'c1'
-alter table t1 add key (c1,c1,c2);
-ERROR 42S21: Duplicate column name 'c1'
-drop table t1;
-create table t1(a int(1) , b int(1)) engine=innodb;
-insert into t1 values ('1111', '3333');
-select distinct concat(a, b) from t1;
-concat(a, b)
-11113333
-drop table t1;
-CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
-SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
-ERROR HY000: The used table type doesn't support FULLTEXT indexes
-DROP TABLE t1;
-CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY  (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-INSERT INTO t1 VALUES (1),(2),(3);
-CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY  (b_id), KEY  (b_a), 
-CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
-SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
-a_id	b_list
-1	1,2,3
-2	4,5
-3	NULL
-DROP TABLE t2;
-DROP TABLE t1;
-create temporary table t1 (a int) engine=innodb;
-insert into t1 values (4711);
-truncate t1;
-insert into t1 values (42);
-select * from t1;
-a
-42
-drop table t1;
-create table t1 (a int) engine=innodb;
-insert into t1 values (4711);
-truncate t1;
-insert into t1 values (42);
-select * from t1;
-a
-42
-drop table t1;
-create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb;
-insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
-select * from t1 order by a,b,c,d;
-a	b	c	d	e
-1	1	a	1	1
-2	2	b	2	2
-3	3	ab	3	3
-explain select * from t1 order by a,b,c,d;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using filesort
-drop table t1;
-create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
-insert into t1 values ('8', '6'), ('4', '7');
-select min(a) from t1;
-min(a)
-4
-select min(b) from t1 where a='8';
-min(b)
-6
-drop table t1;
-create table t1 (x bigint unsigned not null primary key) engine=innodb;
-insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
-select * from t1;
-x
-18446744073709551600
-18446744073709551601
-select count(*) from t1 where x>0;
-count(*)
-2
-select count(*) from t1 where x=0;
-count(*)
-0
-select count(*) from t1 where x<0;
-count(*)
-0
-select count(*) from t1 where x < -16;
-count(*)
-0
-select count(*) from t1 where x = -16;
-count(*)
-0
-explain select count(*) from t1 where x > -16;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	PRIMARY	PRIMARY	8	NULL	2	Using where; Using index
-select count(*) from t1 where x > -16;
-count(*)
-2
-select * from t1 where x > -16;
-x
-18446744073709551600
-18446744073709551601
-select count(*) from t1 where x = 18446744073709551601;
-count(*)
-1
-drop table t1;
-show status like "Innodb_buffer_pool_pages_total";
-Variable_name	Value
-Innodb_buffer_pool_pages_total	512
-show status like "Innodb_page_size";
-Variable_name	Value
-Innodb_page_size	16384
-show status like "Innodb_rows_deleted";
-Variable_name	Value
-Innodb_rows_deleted	71
-show status like "Innodb_rows_inserted";
-Variable_name	Value
-Innodb_rows_inserted	1084
-show status like "Innodb_rows_updated";
-Variable_name	Value
-Innodb_rows_updated	885
-show status like "Innodb_row_lock_waits";
-Variable_name	Value
-Innodb_row_lock_waits	0
-show status like "Innodb_row_lock_current_waits";
-Variable_name	Value
-Innodb_row_lock_current_waits	0
-show status like "Innodb_row_lock_time";
-Variable_name	Value
-Innodb_row_lock_time	0
-show status like "Innodb_row_lock_time_max";
-Variable_name	Value
-Innodb_row_lock_time_max	0
-show status like "Innodb_row_lock_time_avg";
-Variable_name	Value
-Innodb_row_lock_time_avg	0
-show variables like "innodb_sync_spin_loops";
-Variable_name	Value
-innodb_sync_spin_loops	20
-set global innodb_sync_spin_loops=1000;
-show variables like "innodb_sync_spin_loops";
-Variable_name	Value
-innodb_sync_spin_loops	1000
-set global innodb_sync_spin_loops=0;
-show variables like "innodb_sync_spin_loops";
-Variable_name	Value
-innodb_sync_spin_loops	0
-set global innodb_sync_spin_loops=20;
-show variables like "innodb_sync_spin_loops";
-Variable_name	Value
-innodb_sync_spin_loops	20
-SET @old_innodb_thread_concurrency= @@global.innodb_thread_concurrency;
-show variables like "innodb_thread_concurrency";
-Variable_name	Value
-innodb_thread_concurrency	8
-set global innodb_thread_concurrency=1001;
-Warnings:
-Warning	1292	Truncated incorrect thread_concurrency value: '1001'
-show variables like "innodb_thread_concurrency";
-Variable_name	Value
-innodb_thread_concurrency	1000
-set global innodb_thread_concurrency=0;
-show variables like "innodb_thread_concurrency";
-Variable_name	Value
-innodb_thread_concurrency	0
-set global innodb_thread_concurrency=16;
-show variables like "innodb_thread_concurrency";
-Variable_name	Value
-innodb_thread_concurrency	16
-SET @@global.innodb_thread_concurrency= @old_innodb_thread_concurrency;
-show variables like "innodb_concurrency_tickets";
-Variable_name	Value
-innodb_concurrency_tickets	500
-set global innodb_concurrency_tickets=1000;
-show variables like "innodb_concurrency_tickets";
-Variable_name	Value
-innodb_concurrency_tickets	1000
-set global innodb_concurrency_tickets=0;
-Warnings:
-Warning	1292	Truncated incorrect concurrency_tickets value: '0'
-show variables like "innodb_concurrency_tickets";
-Variable_name	Value
-innodb_concurrency_tickets	1
-set global innodb_concurrency_tickets=500;
-show variables like "innodb_concurrency_tickets";
-Variable_name	Value
-innodb_concurrency_tickets	500
-show variables like "innodb_thread_sleep_delay";
-Variable_name	Value
-innodb_thread_sleep_delay	10000
-set global innodb_thread_sleep_delay=100000;
-show variables like "innodb_thread_sleep_delay";
-Variable_name	Value
-innodb_thread_sleep_delay	100000
-set global innodb_thread_sleep_delay=0;
-show variables like "innodb_thread_sleep_delay";
-Variable_name	Value
-innodb_thread_sleep_delay	0
-set global innodb_thread_sleep_delay=10000;
-show variables like "innodb_thread_sleep_delay";
-Variable_name	Value
-innodb_thread_sleep_delay	10000
-set storage_engine=INNODB;
-drop table if exists t1,t2,t3;
---- Testing varchar ---
---- Testing varchar ---
-create table t1 (v varchar(10), c char(10), t text);
-insert into t1 values('+ ', '+ ', '+ ');
-set @a=repeat(' ',20);
-insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
-Warnings:
-Note	1265	Data truncated for column 'v' at row 1
-select concat('*',v,'*',c,'*',t,'*') from t1;
-concat('*',v,'*',c,'*',t,'*')
-*+ *+*+ *
-*+         *+*+                    *
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` varchar(10) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL,
-  `t` text
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-create table t2 like t1;
-show create table t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `v` varchar(10) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL,
-  `t` text
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-create table t3 select * from t1;
-show create table t3;
-Table	Create Table
-t3	CREATE TABLE `t3` (
-  `v` varchar(10) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL,
-  `t` text
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-alter table t1 modify c varchar(10);
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` varchar(10) DEFAULT NULL,
-  `c` varchar(10) DEFAULT NULL,
-  `t` text
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-alter table t1 modify v char(10);
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` char(10) DEFAULT NULL,
-  `c` varchar(10) DEFAULT NULL,
-  `t` text
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-alter table t1 modify t varchar(10);
-Warnings:
-Note	1265	Data truncated for column 't' at row 2
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` char(10) DEFAULT NULL,
-  `c` varchar(10) DEFAULT NULL,
-  `t` varchar(10) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-select concat('*',v,'*',c,'*',t,'*') from t1;
-concat('*',v,'*',c,'*',t,'*')
-*+*+*+ *
-*+*+*+         *
-drop table t1,t2,t3;
-create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` varchar(10) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL,
-  `t` text,
-  KEY `v` (`v`),
-  KEY `c` (`c`),
-  KEY `t` (`t`(10))
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-select count(*) from t1;
-count(*)
-270
-insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
-select count(*) from t1 where v='a';
-count(*)
-10
-select count(*) from t1 where c='a';
-count(*)
-10
-select count(*) from t1 where t='a';
-count(*)
-10
-select count(*) from t1 where v='a  ';
-count(*)
-10
-select count(*) from t1 where c='a  ';
-count(*)
-10
-select count(*) from t1 where t='a  ';
-count(*)
-10
-select count(*) from t1 where v between 'a' and 'a ';
-count(*)
-10
-select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
-count(*)
-10
-select count(*) from t1 where v like 'a%';
-count(*)
-11
-select count(*) from t1 where c like 'a%';
-count(*)
-11
-select count(*) from t1 where t like 'a%';
-count(*)
-11
-select count(*) from t1 where v like 'a %';
-count(*)
-9
-explain select count(*) from t1 where v='a  ';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	13	const	#	Using where; Using index
-explain select count(*) from t1 where c='a  ';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	c	c	11	const	#	Using where; Using index
-explain select count(*) from t1 where t='a  ';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	t	t	13	const	#	Using where
-explain select count(*) from t1 where v like 'a%';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	13	NULL	#	Using where; Using index
-explain select count(*) from t1 where v between 'a' and 'a ';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	13	const	#	Using where; Using index
-explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	13	const	#	Using where; Using index
-alter table t1 add unique(v);
-ERROR 23000: Duplicate entry '{ ' for key 'v_2'
-alter table t1 add key(v);
-select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
-qq
-*a*a*a*
-*a *a*a *
-*a  *a*a  *
-*a   *a*a   *
-*a    *a*a    *
-*a     *a*a     *
-*a      *a*a      *
-*a       *a*a       *
-*a        *a*a        *
-*a         *a*a         *
-explain select * from t1 where v='a';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v,v_2	#	13	const	#	Using where
-select v,count(*) from t1 group by v limit 10;
-v	count(*)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select v,count(t) from t1 group by v limit 10;
-v	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select v,count(c) from t1 group by v limit 10;
-v	count(c)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select sql_big_result v,count(t) from t1 group by v limit 10;
-v	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select sql_big_result v,count(c) from t1 group by v limit 10;
-v	count(c)
-a	1
-a 	10
-b     	10
-c    	10
-d   	10
-e  	10
-f     	10
-g    	10
-h	10
-i     	10
-select c,count(*) from t1 group by c limit 10;
-c	count(*)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select c,count(t) from t1 group by c limit 10;
-c	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select sql_big_result c,count(t) from t1 group by c limit 10;
-c	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select t,count(*) from t1 group by t limit 10;
-t	count(*)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select t,count(t) from t1 group by t limit 10;
-t	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select sql_big_result t,count(t) from t1 group by t limit 10;
-t	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` varchar(300) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL,
-  `t` text,
-  KEY `c` (`c`),
-  KEY `t` (`t`(10)),
-  KEY `v` (`v`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-select count(*) from t1 where v='a';
-count(*)
-10
-select count(*) from t1 where v='a  ';
-count(*)
-10
-select count(*) from t1 where v between 'a' and 'a ';
-count(*)
-10
-select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
-count(*)
-10
-select count(*) from t1 where v like 'a%';
-count(*)
-11
-select count(*) from t1 where v like 'a %';
-count(*)
-9
-explain select count(*) from t1 where v='a  ';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	303	const	#	Using where; Using index
-explain select count(*) from t1 where v like 'a%';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	303	NULL	#	Using where; Using index
-explain select count(*) from t1 where v between 'a' and 'a ';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	303	const	#	Using where; Using index
-explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	303	const	#	Using where; Using index
-explain select * from t1 where v='a';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	303	const	#	Using where
-select v,count(*) from t1 group by v limit 10;
-v	count(*)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select v,count(t) from t1 group by v limit 10;
-v	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select sql_big_result v,count(t) from t1 group by v limit 10;
-v	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-alter table t1 drop key v, add key v (v(30));
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` varchar(300) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL,
-  `t` text,
-  KEY `c` (`c`),
-  KEY `t` (`t`(10)),
-  KEY `v` (`v`(30))
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-select count(*) from t1 where v='a';
-count(*)
-10
-select count(*) from t1 where v='a  ';
-count(*)
-10
-select count(*) from t1 where v between 'a' and 'a ';
-count(*)
-10
-select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
-count(*)
-10
-select count(*) from t1 where v like 'a%';
-count(*)
-11
-select count(*) from t1 where v like 'a %';
-count(*)
-9
-explain select count(*) from t1 where v='a  ';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	33	const	#	Using where
-explain select count(*) from t1 where v like 'a%';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	33	NULL	#	Using where
-explain select count(*) from t1 where v between 'a' and 'a ';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	33	const	#	Using where
-explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	33	const	#	Using where
-explain select * from t1 where v='a';
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	33	const	#	Using where
-select v,count(*) from t1 group by v limit 10;
-v	count(*)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select v,count(t) from t1 group by v limit 10;
-v	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select sql_big_result v,count(t) from t1 group by v limit 10;
-v	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-alter table t1 modify v varchar(600), drop key v, add key v (v);
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` varchar(600) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL,
-  `t` text,
-  KEY `c` (`c`),
-  KEY `t` (`t`(10)),
-  KEY `v` (`v`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-select v,count(*) from t1 group by v limit 10;
-v	count(*)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select v,count(t) from t1 group by v limit 10;
-v	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-select sql_big_result v,count(t) from t1 group by v limit 10;
-v	count(t)
-a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
-h	10
-i	10
-drop table t1;
-create table t1 (a char(10), unique (a));
-insert into t1 values ('a   ');
-insert into t1 values ('a ');
-ERROR 23000: Duplicate entry 'a' for key 'a'
-alter table t1 modify a varchar(10);
-insert into t1 values ('a '),('a  '),('a   '),('a         ');
-ERROR 23000: Duplicate entry 'a ' for key 'a'
-insert into t1 values ('a     ');
-ERROR 23000: Duplicate entry 'a     ' for key 'a'
-insert into t1 values ('a          ');
-ERROR 23000: Duplicate entry 'a         ' for key 'a'
-insert into t1 values ('a ');
-ERROR 23000: Duplicate entry 'a ' for key 'a'
-update t1 set a='a  ' where a like 'a%';
-select concat(a,'.') from t1;
-concat(a,'.')
-a  .
-update t1 set a='abc    ' where a like 'a ';
-select concat(a,'.') from t1;
-concat(a,'.')
-a  .
-update t1 set a='a      ' where a like 'a %';
-select concat(a,'.') from t1;
-concat(a,'.')
-a      .
-update t1 set a='a  ' where a like 'a      ';
-select concat(a,'.') from t1;
-concat(a,'.')
-a  .
-drop table t1;
-create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` varchar(10) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL,
-  `t` text,
-  KEY `v` (`v`(5)),
-  KEY `c` (`c`(5)),
-  KEY `t` (`t`(5))
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t1;
-create table t1 (v char(10) character set utf8);
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` char(10) CHARACTER SET utf8 DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t1;
-create table t1 (v varchar(10), c char(10)) row_format=fixed;
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` varchar(10) DEFAULT NULL,
-  `c` char(10) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
-insert into t1 values('a','a'),('a ','a ');
-select concat('*',v,'*',c,'*') from t1;
-concat('*',v,'*',c,'*')
-*a*a*
-*a *a*
-drop table t1;
-create table t1 (v varchar(65530), key(v(10)));
-insert into t1 values(repeat('a',65530));
-select length(v) from t1 where v=repeat('a',65530);
-length(v)
-65530
-drop table t1;
-create table t1(a int, b varchar(12), key ba(b, a));
-insert into t1 values (1, 'A'), (20, NULL);
-explain select * from t1 where a=20 and b is null;
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	ba	ba	20	const,const	1	Using where; Using index
-select * from t1 where a=20 and b is null;
-a	b
-20	NULL
-drop table t1;
-create table t1 (v varchar(65530), key(v));
-Warnings:
-Warning	1071	Specified key was too long; max key length is 767 bytes
-drop table t1;
-create table t1 (v varchar(65536));
-Warnings:
-Note	1246	Converting column 'v' from VARCHAR to TEXT
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` mediumtext
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t1;
-create table t1 (v varchar(65530) character set utf8);
-Warnings:
-Note	1246	Converting column 'v' from VARCHAR to TEXT
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `v` mediumtext CHARACTER SET utf8
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t1;
-set storage_engine=MyISAM;
-create table t1 (v varchar(16384)) engine=innodb;
-drop table t1;
-create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
-insert into t1 values ('8', '6'), ('4', '7');
-select min(a) from t1;
-min(a)
-4
-select min(b) from t1 where a='8';
-min(b)
-6
-drop table t1;
-CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
-insert into t1 (b) values (1);
-replace into t1 (b) values (2), (1), (3);
-select * from t1;
-a	b
-3	1
-2	2
-4	3
-truncate table t1;
-insert into t1 (b) values (1);
-replace into t1 (b) values (2);
-replace into t1 (b) values (1);
-replace into t1 (b) values (3);
-select * from t1;
-a	b
-3	1
-2	2
-4	3
-drop table t1;
-create table t1 (rowid int not null auto_increment, val int not null,primary
-key (rowid), unique(val)) engine=innodb;
-replace into t1 (val) values ('1'),('2');
-replace into t1 (val) values ('1'),('2');
-insert into t1 (val) values ('1'),('2');
-ERROR 23000: Duplicate entry '1' for key 'val'
-select * from t1;
-rowid	val
-3	1
-4	2
-drop table t1;
-create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
-insert into t1 (val) values (1);
-update t1 set a=2 where a=1;
-insert into t1 (val) values (1);
-ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
-select * from t1;
-a	val
-2	1
-drop table t1;
-CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
-INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
-SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
-GRADE
-252
-SELECT GRADE  FROM t1 WHERE GRADE= 151;
-GRADE
-151
-DROP TABLE t1;
-create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
-create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
-insert into t2 values ('aa','cc');
-insert into t1 values ('aa','bb'),('aa','cc');
-delete t1 from t1,t2 where f1=f3 and f4='cc';
-select * from t1;
-f1	f2
-drop table t1,t2;
-CREATE TABLE t1 (
-id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
-) ENGINE=InnoDB;
-CREATE TABLE t2 (
-id INTEGER NOT NULL,
-FOREIGN KEY (id) REFERENCES t1 (id)
-) ENGINE=InnoDB;
-INSERT INTO t1 (id) VALUES (NULL);
-SELECT * FROM t1;
-id
-1
-TRUNCATE t1;
-INSERT INTO t1 (id) VALUES (NULL);
-SELECT * FROM t1;
-id
-1
-DELETE FROM t1;
-TRUNCATE t1;
-INSERT INTO t1 (id) VALUES (NULL);
-SELECT * FROM t1;
-id
-1
-DROP TABLE t2, t1;
-CREATE TABLE t1
-(
-id INT PRIMARY KEY
-) ENGINE=InnoDB;
-CREATE TEMPORARY TABLE t2
-(
-id INT NOT NULL PRIMARY KEY,
-b INT,
-FOREIGN KEY (b) REFERENCES test.t1(id)
-) ENGINE=InnoDB;
-Got one of the listed errors
-DROP TABLE t1;
-create table t1 (col1 varchar(2000), index (col1(767)))
-character set = latin1 engine = innodb;
-create table t2 (col1 char(255), index (col1))
-character set = latin1 engine = innodb;
-create table t3 (col1 binary(255), index (col1))
-character set = latin1 engine = innodb;
-create table t4 (col1 varchar(767), index (col1))
-character set = latin1 engine = innodb;
-create table t5 (col1 varchar(767) primary key)
-character set = latin1 engine = innodb;
-create table t6 (col1 varbinary(767) primary key)
-character set = latin1 engine = innodb;
-create table t7 (col1 text, index(col1(767)))
-character set = latin1 engine = innodb;
-create table t8 (col1 blob, index(col1(767)))
-character set = latin1 engine = innodb;
-create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
-character set = latin1 engine = innodb;
-show create table t9;
-Table	Create Table
-t9	CREATE TABLE `t9` (
-  `col1` varchar(512) DEFAULT NULL,
-  `col2` varchar(512) DEFAULT NULL,
-  KEY `col1` (`col1`,`col2`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
-create table t1 (col1 varchar(768), index(col1))
-character set = latin1 engine = innodb;
-Warnings:
-Warning	1071	Specified key was too long; max key length is 767 bytes
-create table t2 (col1 varbinary(768), index(col1))
-character set = latin1 engine = innodb;
-Warnings:
-Warning	1071	Specified key was too long; max key length is 767 bytes
-create table t3 (col1 text, index(col1(768)))
-character set = latin1 engine = innodb;
-Warnings:
-Warning	1071	Specified key was too long; max key length is 767 bytes
-create table t4 (col1 blob, index(col1(768)))
-character set = latin1 engine = innodb;
-Warnings:
-Warning	1071	Specified key was too long; max key length is 767 bytes
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `col1` varchar(768) DEFAULT NULL,
-  KEY `col1` (`col1`(767))
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t1, t2, t3, t4;
-create table t1 (col1 varchar(768) primary key)
-character set = latin1 engine = innodb;
-ERROR 42000: Specified key was too long; max key length is 767 bytes
-create table t2 (col1 varbinary(768) primary key)
-character set = latin1 engine = innodb;
-ERROR 42000: Specified key was too long; max key length is 767 bytes
-create table t3 (col1 text, primary key(col1(768)))
-character set = latin1 engine = innodb;
-ERROR 42000: Specified key was too long; max key length is 767 bytes
-create table t4 (col1 blob, primary key(col1(768)))
-character set = latin1 engine = innodb;
-ERROR 42000: Specified key was too long; max key length is 767 bytes
-CREATE TABLE t1
-(
-id INT PRIMARY KEY
-) ENGINE=InnoDB;
-CREATE TABLE t2
-(
-v INT,
-CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
-) ENGINE=InnoDB;
-INSERT INTO t2 VALUES(2);
-ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
-INSERT INTO t1 VALUES(1);
-INSERT INTO t2 VALUES(1);
-DELETE FROM t1 WHERE id = 1;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
-DROP TABLE t1;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
-SET FOREIGN_KEY_CHECKS=0;
-DROP TABLE t1;
-SET FOREIGN_KEY_CHECKS=1;
-INSERT INTO t2 VALUES(3);
-ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
-DROP TABLE t2;
-create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into t1 values (1),(2);
-set autocommit=0;
-checksum table t1;
-Table	Checksum
-test.t1	1531596814
-insert into t1 values(3);
-checksum table t1;
-Table	Checksum
-test.t1	1531596814
-commit;
-checksum table t1;
-Table	Checksum
-test.t1	2050879373
-commit;
-drop table t1;
-create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into t1 values (1),(2);
-set autocommit=1;
-checksum table t1;
-Table	Checksum
-test.t1	1531596814
-set autocommit=1;
-insert into t1 values(3);
-checksum table t1;
-Table	Checksum
-test.t1	2050879373
-drop table t1;
-set foreign_key_checks=0;
-create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
-create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
-ERROR HY000: Can't create table 'test.t1' (errno: 150)
-set foreign_key_checks=1;
-drop table t2;
-set foreign_key_checks=0;
-create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
-create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
-ERROR HY000: Can't create table 'test.t2' (errno: 150)
-set foreign_key_checks=1;
-drop table t1;
-set foreign_key_checks=0;
-create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
-create table t1(a varchar(10) primary key) engine = innodb;
-alter table t1 modify column a int;
-Got one of the listed errors
-set foreign_key_checks=1;
-drop table t2,t1;
-set foreign_key_checks=0;
-create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
-create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
-alter table t1 convert to character set utf8;
-set foreign_key_checks=1;
-drop table t2,t1;
-set foreign_key_checks=0;
-create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
-create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
-rename table t3 to t1;
-ERROR HY000: Error on rename of './test/t3' to './test/t1' (errno: 150)
-set foreign_key_checks=1;
-drop table t2,t3;
-create table t1(a int primary key) row_format=redundant engine=innodb;
-create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
-create table t3(a int primary key) row_format=compact engine=innodb;
-create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
-insert into t1 values(1);
-insert into t3 values(1);
-insert into t2 values(2);
-ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
-insert into t4 values(2);
-ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
-insert into t2 values(1);
-insert into t4 values(1);
-update t1 set a=2;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
-update t2 set a=2;
-ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
-update t3 set a=2;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
-update t4 set a=2;
-ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
-truncate t1;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
-truncate t3;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
-truncate t2;
-truncate t4;
-truncate t1;
-truncate t3;
-drop table t4,t3,t2,t1;
-create table t1 (a varchar(255) character set utf8,
-b varchar(255) character set utf8,
-c varchar(255) character set utf8,
-d varchar(255) character set utf8,
-key (a,b,c,d)) engine=innodb;
-drop table t1;
-create table t1 (a varchar(255) character set utf8,
-b varchar(255) character set utf8,
-c varchar(255) character set utf8,
-d varchar(255) character set utf8,
-e varchar(255) character set utf8,
-key (a,b,c,d,e)) engine=innodb;
-ERROR 42000: Specified key was too long; max key length is 3072 bytes
-create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
-create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
-create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
-create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
-insert into t1 values (0x41),(0x4120),(0x4100);
-insert into t2 values (0x41),(0x4120),(0x4100);
-ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
-insert into t2 values (0x41),(0x4120);
-insert into t3 values (0x41),(0x4120),(0x4100);
-ERROR 23000: Duplicate entry 'A ' for key 'PRIMARY'
-insert into t3 values (0x41),(0x4100);
-insert into t4 values (0x41),(0x4120),(0x4100);
-ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
-insert into t4 values (0x41),(0x4100);
-select hex(s1) from t1;
-hex(s1)
-41
-4100
-4120
-select hex(s1) from t2;
-hex(s1)
-4100
-4120
-select hex(s1) from t3;
-hex(s1)
-4100
-41
-select hex(s1) from t4;
-hex(s1)
-4100
-41
-drop table t1,t2,t3,t4;
-create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
-create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
-insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
-insert into t2 values(0x42);
-ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
-insert into t2 values(0x41);
-select hex(s1) from t2;
-hex(s1)
-4100
-update t1 set s1=0x123456 where a=2;
-select hex(s1) from t2;
-hex(s1)
-4100
-update t1 set s1=0x12 where a=1;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
-update t1 set s1=0x12345678 where a=1;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
-update t1 set s1=0x123457 where a=1;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
-update t1 set s1=0x1220 where a=1;
-select hex(s1) from t2;
-hex(s1)
-1220
-update t1 set s1=0x1200 where a=1;
-select hex(s1) from t2;
-hex(s1)
-1200
-update t1 set s1=0x4200 where a=1;
-select hex(s1) from t2;
-hex(s1)
-4200
-delete from t1 where a=1;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
-delete from t1 where a=2;
-update t2 set s1=0x4120;
-delete from t1;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
-delete from t1 where a!=3;
-select a,hex(s1) from t1;
-a	hex(s1)
-3	4120
-select hex(s1) from t2;
-hex(s1)
-4120
-drop table t2,t1;
-create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
-create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
-insert into t1 values(1,0x4100),(2,0x41);
-insert into t2 values(0x41);
-select hex(s1) from t2;
-hex(s1)
-41
-update t1 set s1=0x1234 where a=1;
-select hex(s1) from t2;
-hex(s1)
-41
-update t1 set s1=0x12 where a=2;
-select hex(s1) from t2;
-hex(s1)
-12
-delete from t1 where a=1;
-delete from t1 where a=2;
-ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
-select a,hex(s1) from t1;
-a	hex(s1)
-2	12
-select hex(s1) from t2;
-hex(s1)
-12
-drop table t2,t1;
-CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
-CREATE TABLE t2(a INT) ENGINE=InnoDB;
-ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
-ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
-ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
-ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
-SHOW CREATE TABLE t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `a` int(11) DEFAULT NULL,
-  KEY `t2_ibfk_0` (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-DROP TABLE t2,t1;
-create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-insert into t1(a) values (1),(2),(3);
-commit;
-set autocommit = 0;
-update t1 set b = 5 where a = 2;
-create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
-set autocommit = 0;
-insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
-(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
-(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
-(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
-(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
-commit;
-commit;
-drop trigger t1t;
-drop table t1;
-create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-insert into t1(a) values (1),(2),(3);
-insert into t2(a) values (1),(2),(3);
-insert into t3(a) values (1),(2),(3);
-insert into t4(a) values (1),(2),(3);
-insert into t3(a) values (5),(7),(8);
-insert into t4(a) values (5),(7),(8);
-insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
-create trigger t1t before insert on t1 for each row begin 
-INSERT INTO t2 SET a = NEW.a;
-end |
-create trigger t2t before insert on t2 for each row begin
-DELETE FROM t3 WHERE a = NEW.a;
-end |
-create trigger t3t before delete on t3 for each row begin  
-UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
-end |
-create trigger t4t before update on t4 for each row begin
-UPDATE t5 SET b = b + 1 where a = NEW.a;
-end |
-commit;
-set autocommit = 0;
-update t1 set b = b + 5 where a = 1;
-update t2 set b = b + 5 where a = 1;
-update t3 set b = b + 5 where a = 1;
-update t4 set b = b + 5 where a = 1;
-insert into t5(a) values(20);
-set autocommit = 0;
-insert into t1(a) values(7);
-insert into t2(a) values(8);
-delete from t2 where a = 3;
-update t4 set b = b + 1 where a = 3;
-commit;
-drop trigger t1t;
-drop trigger t2t;
-drop trigger t3t;
-drop trigger t4t;
-drop table t1, t2, t3, t4, t5;
-CREATE TABLE t1 (
-field1 varchar(8) NOT NULL DEFAULT '',
-field2 varchar(8) NOT NULL DEFAULT '',
-PRIMARY KEY  (field1, field2)
-) ENGINE=InnoDB;
-CREATE TABLE t2 (
-field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
-FOREIGN KEY (field1) REFERENCES t1 (field1)
-ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB;
-INSERT INTO t1 VALUES ('old', 'somevalu');
-INSERT INTO t1 VALUES ('other', 'anyvalue');
-INSERT INTO t2 VALUES ('old');
-INSERT INTO t2 VALUES ('other');
-UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
-ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry
-DROP TABLE t2;
-DROP TABLE t1;
-create table t1 (
-c1 bigint not null,
-c2 bigint not null,
-primary key (c1),
-unique  key (c2)
-) engine=innodb;
-create table t2 (
-c1 bigint not null,
-primary key (c1)
-) engine=innodb;
-alter table t1 add constraint c2_fk foreign key (c2)
-references t2(c1) on delete cascade;
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `c1` bigint(20) NOT NULL,
-  `c2` bigint(20) NOT NULL,
-  PRIMARY KEY (`c1`),
-  UNIQUE KEY `c2` (`c2`),
-  CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-alter table t1 drop foreign key c2_fk;
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `c1` bigint(20) NOT NULL,
-  `c2` bigint(20) NOT NULL,
-  PRIMARY KEY (`c1`),
-  UNIQUE KEY `c2` (`c2`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-drop table t1, t2;
-create table t1(a date) engine=innodb;
-create table t2(a date, key(a)) engine=innodb;
-insert into t1 values('2005-10-01');
-insert into t2 values('2005-10-01');
-select * from t1, t2
-where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
-a	a
-2005-10-01	2005-10-01
-drop table t1, t2;
-create table t1 (id int not null, f_id int not null, f int not null,
-primary key(f_id, id)) engine=innodb;
-create table t2 (id int not null,s_id int not null,s varchar(200),
-primary key(id)) engine=innodb;
-INSERT INTO t1 VALUES (8, 1, 3);
-INSERT INTO t1 VALUES (1, 2, 1);
-INSERT INTO t2 VALUES (1, 0, '');
-INSERT INTO t2 VALUES (8, 1, '');
-commit;
-DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
-WHERE mm.id IS NULL;
-select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
-where mm.id is null lock in share mode;
-id	f_id	f
-drop table t1,t2;
-create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
-commit;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-update t1 set b = 5 where b = 1;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-select * from t1 where a = 7 and b = 3 for update;
-a	b
-7	3
-commit;
-commit;
-drop table t1;
-create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
-commit;
-set autocommit = 0;
-select * from t1 lock in share mode;
-a	b
-1	1
-2	2
-3	1
-4	2
-5	1
-6	2
-update t1 set b = 5 where b = 1;
-set autocommit = 0;
-select * from t1 where a = 2 and b = 2 for update;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-commit;
-commit;
-drop table t1;
-create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values (1,2),(5,3),(4,2);
-create table t2(d int not null, e int, primary key(d)) engine=innodb;
-insert into t2 values (8,6),(12,1),(3,1);
-commit;
-set autocommit = 0;
-select * from t2 for update;
-d	e
-3	1
-8	6
-12	1
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-insert into t1 select * from t2;
-update t1 set b = (select e from t2 where a = d);
-create table t3(d int not null, e int, primary key(d)) engine=innodb
-select * from t2;
-commit;
-commit;
-drop table t1, t2, t3;
-create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values (1,2),(5,3),(4,2);
-create table t2(a int not null, b int, primary key(a)) engine=innodb;
-insert into t2 values (8,6),(12,1),(3,1);
-create table t3(d int not null, b int, primary key(d)) engine=innodb;
-insert into t3 values (8,6),(12,1),(3,1);
-create table t5(a int not null, b int, primary key(a)) engine=innodb;
-insert into t5 values (1,2),(5,3),(4,2);
-create table t6(d int not null, e int, primary key(d)) engine=innodb;
-insert into t6 values (8,6),(12,1),(3,1);
-create table t8(a int not null, b int, primary key(a)) engine=innodb;
-insert into t8 values (1,2),(5,3),(4,2);
-create table t9(d int not null, e int, primary key(d)) engine=innodb;
-insert into t9 values (8,6),(12,1),(3,1);
-commit;
-set autocommit = 0;
-select * from t2 for update;
-a	b
-3	1
-8	6
-12	1
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-insert into t1 select * from t2;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-update t3 set b = (select b from t2 where a = d);
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-insert into t5 (select * from t2 lock in share mode);
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-update t6 set e = (select b from t2 where a = d lock in share mode);
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-insert into t8 (select * from t2 for update);
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-update t9 set e = (select b from t2 where a = d for update);
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-commit;
-drop table t1, t2, t3, t5, t6, t8, t9;
-CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
-ERROR HY000: Can't create table 'test.t1' (errno: -1)
-CREATE TABLE t1 (
-a BIGINT(20) NOT NULL,
-PRIMARY KEY  (a)
-) ENGINE=INNODB DEFAULT CHARSET=UTF8;
-CREATE TABLE t2 (
-a BIGINT(20) NOT NULL,
-b VARCHAR(128) NOT NULL,
-c TEXT NOT NULL,
-PRIMARY KEY  (a,b),
-KEY idx_t2_b_c (b,c(200)),
-CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) 
-ON DELETE CASCADE
-) ENGINE=INNODB DEFAULT CHARSET=UTF8;
-INSERT INTO t1 VALUES (1);
-INSERT INTO t2 VALUES (1, 'bar', 'vbar');
-INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
-INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
-INSERT INTO t2 VALUES (1, 'customer_over', '1');
-SELECT * FROM t2 WHERE b = 'customer_over';
-a	b	c
-1	customer_over	1
-SELECT * FROM t2 WHERE BINARY b = 'customer_over';
-a	b	c
-1	customer_over	1
-SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
-a
-1
-/* Bang: Empty result set, above was expected: */
-SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
-a
-1
-SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
-a
-1
-drop table t2, t1;
-CREATE TABLE t1 ( a int ) ENGINE=innodb;
-BEGIN;
-INSERT INTO t1 VALUES (1);
-OPTIMIZE TABLE t1;
-Table	Op	Msg_type	Msg_text
-test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
-test.t1	optimize	status	OK
-DROP TABLE t1;
-CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
-CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
-CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
-ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
-ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
-DELETE CASCADE ON UPDATE CASCADE;
-SHOW CREATE TABLE t2;
-Table	Create Table
-t2	CREATE TABLE `t2` (
-  `id` int(11) NOT NULL,
-  `f` int(11) NOT NULL,
-  PRIMARY KEY (`id`),
-  KEY `f` (`f`),
-  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-DROP TABLE t2, t1;
-CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
-CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1);
-INSERT INTO t2 VALUES (1);
-ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
-ALTER TABLE t2 MODIFY a INT NOT NULL;
-ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150)
-DELETE FROM t1;
-DROP TABLE t2,t1;
-CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
-ENGINE=InnoDB;
-INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
-DELETE FROM t1;
-INSERT INTO t1 VALUES ('DDD');
-SELECT * FROM t1;
-a
-DDD
-DROP TABLE t1;
-CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
-AUTO_INCREMENT=42;
-INSERT INTO t1 VALUES (0),(347),(0);
-SELECT * FROM t1;
-id
-42
-347
-348
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
-CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t2 VALUES(42),(347),(348);
-ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`id`),
-  CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
-DROP TABLE t1,t2;
-CREATE TABLE t1 (
-c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
-c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
-c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
-c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
-c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
-c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
-c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
-c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
-) ENGINE = InnoDB;
-ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
-DROP TABLE IF EXISTS t1;
-Warnings:
-Note	1051	Unknown table 't1'
-CREATE TABLE t1(
-id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
-) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-10);
-SELECT * FROM t1;
-id
--10
-INSERT INTO t1 VALUES(NULL);
-SELECT * FROM t1;
-id
--10
-1
-DROP TABLE t1;
-SET binlog_format='MIXED';
-SET TX_ISOLATION='read-committed';
-SET AUTOCOMMIT=0;
-DROP TABLE IF EXISTS t1, t2;
-Warnings:
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
-CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
-CREATE TABLE t2 LIKE t1;
-SELECT * FROM t2;
-a
-SET binlog_format='MIXED';
-SET TX_ISOLATION='read-committed';
-SET AUTOCOMMIT=0;
-INSERT INTO t1 VALUES (1);
-COMMIT;
-SELECT * FROM t1 WHERE a=1;
-a
-1
-SET binlog_format='MIXED';
-SET TX_ISOLATION='read-committed';
-SET AUTOCOMMIT=0;
-SELECT * FROM t2;
-a
-SET binlog_format='MIXED';
-SET TX_ISOLATION='read-committed';
-SET AUTOCOMMIT=0;
-INSERT INTO t1 VALUES (2);
-COMMIT;
-SELECT * FROM t1 WHERE a=2;
-a
-2
-SELECT * FROM t1 WHERE a=2;
-a
-2
-DROP TABLE t1;
-DROP TABLE t2;
-create table t1 (i int, j int) engine=innodb;
-insert into t1 (i, j) values (1, 1), (2, 2);
-update t1 set j = 2;
-affected rows: 1
-info: Rows matched: 2  Changed: 1  Warnings: 0
-drop table t1;
-create table t1 (id int) comment='this is a comment' engine=innodb;
-select table_comment, data_free > 0 as data_free_is_set
-from information_schema.tables
-where table_schema='test' and table_name = 't1';
-table_comment	data_free_is_set
-this is a comment	1
-drop table t1;
-CREATE TABLE t1 (
-c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-c2 VARCHAR(128) NOT NULL,
-PRIMARY KEY(c1)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
-CREATE TABLE t2 (
-c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-c2 INT(10) UNSIGNED DEFAULT NULL,
-PRIMARY KEY(c1)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
-SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
-AUTO_INCREMENT
-200
-ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
-SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
-AUTO_INCREMENT
-200
-DROP TABLE t2;
-DROP TABLE t1;
-CREATE TABLE t1 (c1 int default NULL,
-c2 int default NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-TRUNCATE TABLE t1;
-affected rows: 0
-INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
-affected rows: 5
-info: Records: 5  Duplicates: 0  Warnings: 0
-TRUNCATE TABLE t1;
-affected rows: 0
-DROP TABLE t1;
-Variable_name	Value
-Handler_update	0
-Variable_name	Value
-Handler_delete	0
-Variable_name	Value
-Handler_update	1
-Variable_name	Value
-Handler_delete	1

=== added file 'mysql-test/r/innodb_bug34053.result'
--- a/mysql-test/r/innodb_bug34053.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug34053.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1 @@
+SET storage_engine=InnoDB;

=== removed file 'mysql-test/r/innodb_bug34053.result'
--- a/mysql-test/r/innodb_bug34053.result	2008-02-19 16:44:09 +0000
+++ b/mysql-test/r/innodb_bug34053.result	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
-SET storage_engine=InnoDB;

=== added file 'mysql-test/r/innodb_bug34300.result'
--- a/mysql-test/r/innodb_bug34300.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug34300.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,4 @@
+f4	f8
+xxx	zzz
+f4	f8
+xxx	zzz

=== removed file 'mysql-test/r/innodb_bug34300.result'
--- a/mysql-test/r/innodb_bug34300.result	2009-02-19 09:01:25 +0000
+++ b/mysql-test/r/innodb_bug34300.result	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-SELECT f4, f8 FROM bug34300;
-f4	f8
-xxx	zzz
-ALTER TABLE bug34300 ADD COLUMN (f10 INT);
-SELECT f4, f8 FROM bug34300;
-f4	f8
-xxx	zzz
-DROP TABLE bug34300;

=== added file 'mysql-test/r/innodb_bug35220.result'
--- a/mysql-test/r/innodb_bug35220.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug35220.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1 @@
+SET storage_engine=InnoDB;

=== removed file 'mysql-test/r/innodb_bug35220.result'
--- a/mysql-test/r/innodb_bug35220.result	2008-08-08 00:25:24 +0000
+++ b/mysql-test/r/innodb_bug35220.result	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
-SET storage_engine=InnoDB;

=== added file 'mysql-test/r/innodb_bug36169.result'
--- a/mysql-test/r/innodb_bug36169.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug36169.result	2009-06-11 12:53:26 +0000
@@ -0,0 +1,5 @@
+SET @save_innodb_file_format=@@global.innodb_file_format;
+SET @save_innodb_file_format_check=@@global.innodb_file_format_check;
+SET @save_innodb_file_per_table=@@global.innodb_file_per_table;
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;

=== added file 'mysql-test/r/innodb_bug36172.result'
--- a/mysql-test/r/innodb_bug36172.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug36172.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1 @@
+SET storage_engine=InnoDB;

=== added file 'mysql-test/r/innodb_bug40360.result'
--- a/mysql-test/r/innodb_bug40360.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug40360.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,4 @@
+SET TX_ISOLATION='READ-COMMITTED';
+CREATE TABLE bug40360 (a INT) engine=innodb;
+INSERT INTO bug40360 VALUES (1);
+DROP TABLE bug40360;

=== added file 'mysql-test/r/innodb_bug41904.result'
--- a/mysql-test/r/innodb_bug41904.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug41904.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,4 @@
+CREATE TABLE bug41904 (id INT PRIMARY KEY, uniquecol CHAR(15)) ENGINE=InnoDB;
+INSERT INTO bug41904 VALUES (1,NULL), (2,NULL);
+CREATE UNIQUE INDEX ui ON bug41904 (uniquecol);
+DROP TABLE bug41904;

=== added file 'mysql-test/r/innodb_information_schema.result'
--- a/mysql-test/r/innodb_information_schema.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_information_schema.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1,23 @@
+lock_mode	lock_type	lock_table	lock_index	lock_rec	lock_data
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	2	'1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc'''''
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	2	'1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc'''''
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	3	'2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""'
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	3	'2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""'
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	4	'3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\'
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	4	'3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\'
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	5	'4', 'abc', '\0abc', 'abc\0', 'a\0bc', 'a\0bc\0', 'a\0bc\0\0'
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	5	'4', 'abc', '\0abc', 'abc\0', 'a\0bc', 'a\0bc\0', 'a\0bc\0\0'
+X	RECORD	`test`.`t_min`	`PRIMARY`	2	-128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0
+X	RECORD	`test`.`t_min`	`PRIMARY`	2	-128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0
+X	RECORD	`test`.`t_max`	`PRIMARY`	2	127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615
+X	RECORD	`test`.`t_max`	`PRIMARY`	2	127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	1	supremum pseudo-record
+X	RECORD	`test`.```t'\"_str`	`PRIMARY`	1	supremum pseudo-record
+lock_table	COUNT(*)
+`test`.`t_max`	2
+`test`.`t_min`	2
+`test`.```t'\"_str`	10
+lock_table	COUNT(*)
+"test"."t_max"	2
+"test"."t_min"	2
+"test"."`t'\""_str"	10

=== added file 'mysql-test/r/innodb_trx_weight.result'
--- a/mysql-test/r/innodb_trx_weight.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_trx_weight.result	2009-06-09 13:19:13 +0000
@@ -0,0 +1 @@
+SET storage_engine=InnoDB;

=== removed file 'mysql-test/r/innodb_trx_weight.result'
--- a/mysql-test/r/innodb_trx_weight.result	2007-07-10 11:37:43 +0000
+++ b/mysql-test/r/innodb_trx_weight.result	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
-SET storage_engine=InnoDB;

=== added file 'mysql-test/r/innodb_xtradb_bug317074.result'
--- a/mysql-test/r/innodb_xtradb_bug317074.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_xtradb_bug317074.result	2009-06-11 12:53:26 +0000
@@ -0,0 +1,5 @@
+SET @save_innodb_file_format=@@global.innodb_file_format;
+SET @save_innodb_file_format_check=@@global.innodb_file_format_check;
+SET @save_innodb_file_per_table=@@global.innodb_file_per_table;
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;

=== modified file 'mysql-test/r/mysqlbinlog_row_big.result'
--- a/mysql-test/r/mysqlbinlog_row_big.result	2008-12-13 19:42:12 +0000
+++ b/mysql-test/r/mysqlbinlog_row_big.result	2009-06-11 12:53:26 +0000
@@ -1,4 +1,9 @@
 #
+# We need big packets.
+#
+SET @old_global_max_allowed_packet=@@global.max_allowed_packet;
+SET @@global.max_allowed_packet= 1024*1024*1024;
+#
 # Preparatory cleanup.
 #
 DROP TABLE IF EXISTS t1;
@@ -7,10 +12,6 @@ DROP TABLE IF EXISTS t1;
 #
 SET timestamp=1000000000;
 #
-# We need big packets.
-#
-SET @@global.max_allowed_packet= 1024*1024*1024;
-#
 # Delete all existing binary logs.
 #
 RESET MASTER;
@@ -71,4 +72,5 @@ FLUSH LOGS;
 # Cleanup.
 #
 DROP TABLE t1;
+SET @@global.max_allowed_packet=@old_global_max_allowed_packet;
 remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out

=== modified file 'mysql-test/r/row-checksum-old.result'
--- a/mysql-test/r/row-checksum-old.result	2008-06-28 12:45:15 +0000
+++ b/mysql-test/r/row-checksum-old.result	2009-06-09 15:08:46 +0000
@@ -72,6 +72,8 @@ Table	Checksum
 test.t1	4108368782
 drop table if exists t1;
 create table t1 (a int null, v varchar(100)) engine=innodb checksum=0 row_format=fixed;
+Warnings:
+Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
 insert into t1 values(null, null), (1, "hello");
 checksum table t1;
 Table	Checksum

=== modified file 'mysql-test/r/row-checksum.result'
--- a/mysql-test/r/row-checksum.result	2008-06-28 12:45:15 +0000
+++ b/mysql-test/r/row-checksum.result	2009-06-09 15:08:46 +0000
@@ -72,6 +72,8 @@ Table	Checksum
 test.t1	3885665021
 drop table if exists t1;
 create table t1 (a int null, v varchar(100)) engine=innodb checksum=0 row_format=fixed;
+Warnings:
+Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
 insert into t1 values(null, null), (1, "hello");
 checksum table t1;
 Table	Checksum

=== modified file 'mysql-test/r/variables-big.result'
--- a/mysql-test/r/variables-big.result	2008-06-26 05:18:28 +0000
+++ b/mysql-test/r/variables-big.result	2009-06-11 12:53:26 +0000
@@ -1,20 +1,20 @@
 set session transaction_prealloc_size=1024*1024*1024*1;
-show processlist;
-Id	User	Host	db	Command	Time	State	Info
-#	root	localhost	test	Query	0	NULL	show processlist
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
+TRUE
+1
 set session transaction_prealloc_size=1024*1024*1024*2;
-show processlist;
-Id	User	Host	db	Command	Time	State	Info
-#	root	localhost	test	Query	0	NULL	show processlist
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
+TRUE
+1
 set session transaction_prealloc_size=1024*1024*1024*3;
-show processlist;
-Id	User	Host	db	Command	Time	State	Info
-#	root	localhost	test	Query	0	NULL	show processlist
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
+TRUE
+1
 set session transaction_prealloc_size=1024*1024*1024*4;
-show processlist;
-Id	User	Host	db	Command	Time	State	Info
-#	root	localhost	test	Query	0	NULL	show processlist
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
+TRUE
+1
 set session transaction_prealloc_size=1024*1024*1024*5;
-show processlist;
-Id	User	Host	db	Command	Time	State	Info
-#	root	localhost	test	Query	0	NULL	show processlist
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
+TRUE
+1

=== modified file 'mysql-test/t/information_schema.test'
--- a/mysql-test/t/information_schema.test	2009-04-25 10:05:32 +0000
+++ b/mysql-test/t/information_schema.test	2009-06-11 17:49:51 +0000
@@ -47,7 +47,7 @@ create view v1 (c) as
         table_name<>'ndb_binlog_index' AND
         table_name<>'ndb_apply_status' AND
 	NOT (table_schema = 'INFORMATION_SCHEMA' AND table_name LIKE 'PBXT_%');
-select * from v1;
+select * from v1 ORDER BY c COLLATE utf8_bin;
 
 select c,table_name from v1 
 inner join information_schema.TABLES v2 on (v1.c=v2.table_name)

=== added file 'mysql-test/t/innodb-analyze.test'
--- a/mysql-test/t/innodb-analyze.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-analyze.test	2009-06-09 15:08:46 +0000
@@ -0,0 +1,65 @@
+#
+# Test that mysqld does not crash when running ANALYZE TABLE with
+# different values of the parameter innodb_stats_sample_pages.
+#
+
+-- source include/have_innodb.inc
+
+# we care only that the following SQL commands do not produce errors
+# and do not crash the server
+-- disable_query_log
+-- disable_result_log
+-- enable_warnings
+
+SET @save_innodb_stats_sample_pages=@@innodb_stats_sample_pages;
+SET GLOBAL innodb_stats_sample_pages=0;
+
+# check that the value has been adjusted to 1
+-- enable_result_log
+SHOW VARIABLES LIKE 'innodb_stats_sample_pages';
+-- disable_result_log
+
+CREATE TABLE innodb_analyze (
+	a INT,
+	b INT,
+	KEY(a),
+	KEY(b,a)
+) ENGINE=InnoDB;
+
+# test with empty table
+
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=2;
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=4;
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=8;
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=16;
+ANALYZE TABLE innodb_analyze;
+
+INSERT INTO innodb_analyze VALUES
+(1,1), (1,1), (1,2), (1,3), (1,4), (1,5),
+(8,1), (8,8), (8,2), (7,1), (1,4), (3,5);
+
+SET GLOBAL innodb_stats_sample_pages=1;
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=2;
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=4;
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=8;
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=16;
+ANALYZE TABLE innodb_analyze;
+
+SET GLOBAL innodb_stats_sample_pages=@save_innodb_stats_sample_pages;
+DROP TABLE innodb_analyze;

=== added file 'mysql-test/t/innodb-autoinc.test'
--- a/mysql-test/t/innodb-autoinc.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-autoinc.test	2009-06-09 15:08:46 +0000
@@ -0,0 +1,480 @@
+-- source include/have_innodb.inc
+# embedded server ignores 'delayed', so skip this
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Bug #34335
+#
+CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (9223372036854775807, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+#
+## Test AUTOINC overflow
+##
+
+# TINYINT
+CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (127, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (255, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+#
+# SMALLINT
+#
+CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (32767, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (65535, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+#
+# MEDIUMINT
+#
+CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (8388607, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (16777215, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+#
+# INT
+#
+CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (2147483647, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (4294967295, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+#
+# BIGINT
+#
+CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (9223372036854775807, null);
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (18446744073709551615, null);
+-- error ER_AUTOINC_READ_FAILED,1467
+INSERT INTO t1 (c2) VALUES ('innodb');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Bug 37531
+# After truncate, auto_increment behaves incorrectly for InnoDB
+#
+CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT c1 FROM t1;
+SHOW CREATE TABLE t1;
+TRUNCATE TABLE t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT c1 FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
+# Deleting all records should not reset the AUTOINC counter.
+#
+CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT c1 FROM t1;
+SHOW CREATE TABLE t1;
+DELETE FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SELECT c1 FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
+# Bug 38839
+# Reset the last value generated at end of statement
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL, 1);
+DELETE FROM t1 WHERE c1 = 1;
+INSERT INTO t1 VALUES (2,1); 
+INSERT INTO t1 VALUES (NULL,8);
+SELECT * FROM t1;
+DROP TABLE t1;
+# Bug 38839 -- same as above but for multi value insert
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL, 1);
+DELETE FROM t1 WHERE c1 = 1;
+INSERT INTO t1 VALUES (2,1), (NULL, 8);
+INSERT INTO t1 VALUES (NULL,9);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Test changes to AUTOINC next value calculation
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(5),(NULL);
+INSERT INTO t1 VALUES (250),(NULL);
+SELECT * FROM t1;
+INSERT INTO t1 VALUES (1000);
+SET @@INSERT_ID=400;
+INSERT INTO t1 VALUES(NULL),(NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# Test with SIGNED INT column, by inserting a 0 for the first column value
+# 0 is treated in the same was NULL.
+# Reset the AUTOINC session variables
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(0);
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+INSERT INTO t1 VALUES (-1), (NULL),(2),(NULL);
+INSERT INTO t1 VALUES (250),(NULL);
+SELECT * FROM t1;
+SET @@INSERT_ID=400;
+# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 VALUES(NULL),(NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# Test with SIGNED INT column
+# Reset the AUTOINC session variables
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(-1);
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+INSERT INTO t1 VALUES (-2), (NULL),(2),(NULL);
+INSERT INTO t1 VALUES (250),(NULL);
+SELECT * FROM t1;
+INSERT INTO t1 VALUES (1000);
+SET @@INSERT_ID=400;
+INSERT INTO t1 VALUES(NULL),(NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# Test with UNSIGNED INT column, single insert
+# The sign in the value is ignored and a new column value is generated
+# Reset the AUTOINC session variables
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(-1);
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+INSERT INTO t1 VALUES (-2);
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (250);
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+INSERT INTO t1 VALUES (1000);
+SET @@INSERT_ID=400;
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# Test with UNSIGNED INT column, multi-value inserts
+# The sign in the value is ignored and a new column value is generated
+# Reset the AUTOINC session variables
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(-1);
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+INSERT INTO t1 VALUES (-2),(NULL),(2),(NULL);
+INSERT INTO t1 VALUES (250),(NULL);
+SELECT * FROM t1;
+INSERT INTO t1 VALUES (1000);
+SET @@INSERT_ID=400;
+# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t1 VALUES(NULL),(NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Check for overflow handling when increment is > 1
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+# TODO: Fix the autoinc init code
+# We have to do this because of a bug in the AUTOINC init code.
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES (9223372036854775794); #-- 2^63 - 14
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+# This should just fit
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Check for overflow handling when increment and offser are > 1
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+# TODO: Fix the autoinc init code
+# We have to do this because of a bug in the AUTOINC init code.
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
+SHOW VARIABLES LIKE "auto_inc%";
+# This should fail because of overflow but it doesn't, it seems to be
+# a MySQL server bug. It wraps around to 0 for the last value.
+# See MySQL Bug# 39828
+#
+# Instead of wrapping around, it asserts when MySQL is compiled --with-debug
+# (see sql/handler.cc:handler::update_auto_increment()).  Don't test for
+# overflow until Bug #39828 is fixed.
+#
+# Since this asserts when compiled --with-debug, we can't properly test this
+# until Bug #39828 is fixed.  For now, this test is meaningless.
+#if Bug #39828 is fixed
+#INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+#else
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+#endif
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Check for overflow handling when increment and offset are odd numbers
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+# TODO: Fix the autoinc init code
+# We have to do this because of a bug in the AUTOINC init code.
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7;
+SHOW VARIABLES LIKE "auto_inc%";
+# This should fail because of overflow but it doesn't. It fails with
+# a duplicate entry message because of a MySQL server bug, it wraps
+# around.  See MySQL Bug# 39828, once MySQL fix the bug we can replace
+# the ER_DUP_ENTRY, 1062 below with the appropriate error message
+#
+# Since this asserts when compiled --with-debug, we can't properly test this
+# until Bug #39828 is fixed.  For now, this test is meaningless.
+#if Bug #39828 is fixed
+# Still need to fix this error code, error should mention overflow
+#-- error ER_DUP_ENTRY,1062
+#INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
+#else
+INSERT INTO t1 VALUES (NULL),(NULL);
+#endif
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# Check for overflow handling when increment and offset are odd numbers
+# and check for large -ve numbers
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+# TODO: Fix the autoinc init code
+# We have to do this because of a bug in the AUTOINC init code.
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES(-9223372036854775806); #-- -2^63 + 2
+INSERT INTO t1 VALUES(-9223372036854775807); #-- -2^63 + 1
+INSERT INTO t1 VALUES(-9223372036854775808); #-- -2^63
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3;
+SHOW VARIABLES LIKE "auto_inc%";
+INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+#
+# Check for overflow handling when increment and offset are very
+# large numbers 2^60
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
+# TODO: Fix the autoinc init code
+# We have to do this because of a bug in the AUTOINC init code.
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2
+SELECT * FROM t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
+SHOW VARIABLES LIKE "auto_inc%";
+# This should fail because of overflow but it doesn't. It wraps around
+# and the autoinc values look bogus too.
+# See MySQL Bug# 39828, once MySQL fix the bug we can enable the error
+# code expected test.
+# -- error ER_AUTOINC_READ_FAILED,1467
+#
+# Since this asserts when compiled --with-debug, we can't properly test this
+# until Bug #39828 is fixed.  For now, this test is meaningless.
+#if Bug #39828 is fixed
+#-- error ER_AUTOINC_READ_FAILED,1467
+#INSERT INTO t1 VALUES (NULL),(NULL);
+#else
+INSERT INTO t1 VALUES (NULL);
+#endif
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Check for floating point autoinc column handling
+#
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "auto_inc%";
+CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Bug# 42714: AUTOINC column calculated next value not greater than highest
+# value stored in table.
+#
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+  a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+  b INT(10) UNSIGNED NOT NULL,
+  c ENUM('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (a)) ENGINE = InnoDB;
+CREATE TABLE t2 (
+  m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+  n INT(10) UNSIGNED NOT NULL,
+  o enum('FALSE','TRUE') DEFAULT NULL,
+  PRIMARY KEY (m)) ENGINE = InnoDB;
+INSERT INTO t2 (n,o) VALUES
+  (1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
+  (3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
+SHOW CREATE TABLE t2;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# 43203: Overflow from auto incrementing causes server segv
+#
+
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1(
+   c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
+   PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+CREATE TABLE t2(
+    c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
+    PRIMARY KEY) ENGINE=InnoDB;
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t2 SELECT c1 FROM t1;
+-- error ER_DUP_ENTRY,1467
+INSERT INTO t2 SELECT NULL FROM t1;
+DROP TABLE t1;
+DROP TABLE t2;

=== removed file 'mysql-test/t/innodb-autoinc.test'
--- a/mysql-test/t/innodb-autoinc.test	2009-04-25 09:04:38 +0000
+++ b/mysql-test/t/innodb-autoinc.test	1970-01-01 00:00:00 +0000
@@ -1,480 +0,0 @@
--- source include/have_innodb.inc
-# embedded server ignores 'delayed', so skip this
--- source include/not_embedded.inc
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-#
-# Bug #34335
-#
-CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (9223372036854775807, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-## Test AUTOINC overflow
-##
-
-# TINYINT
-CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (127, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (255, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# SMALLINT
-#
-CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (32767, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (65535, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# MEDIUMINT
-#
-CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (8388607, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (16777215, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# INT
-#
-CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (2147483647, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (4294967295, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# BIGINT
-#
-CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (9223372036854775807, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (18446744073709551615, null);
--- error ER_AUTOINC_READ_FAILED,1467
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Bug 37531
-# After truncate, auto_increment behaves incorrectly for InnoDB
-#
-CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-SHOW CREATE TABLE t1;
-TRUNCATE TABLE t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-
-#
-# Deleting all records should not reset the AUTOINC counter.
-#
-CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-SHOW CREATE TABLE t1;
-DELETE FROM t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-
-#
-# Bug 38839
-# Reset the last value generated at end of statement
-#
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL, 1);
-DELETE FROM t1 WHERE c1 = 1;
-INSERT INTO t1 VALUES (2,1); 
-INSERT INTO t1 VALUES (NULL,8);
-SELECT * FROM t1;
-DROP TABLE t1;
-# Bug 38839 -- same as above but for multi value insert
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL, 1);
-DELETE FROM t1 WHERE c1 = 1;
-INSERT INTO t1 VALUES (2,1), (NULL, 8);
-INSERT INTO t1 VALUES (NULL,9);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Test changes to AUTOINC next value calculation
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL),(5),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Test with SIGNED INT column, by inserting a 0 for the first column value
-# 0 is treated in the same was NULL.
-# Reset the AUTOINC session variables
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(0);
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-INSERT INTO t1 VALUES (-1), (NULL),(2),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-SET @@INSERT_ID=400;
-# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Test with SIGNED INT column
-# Reset the AUTOINC session variables
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-INSERT INTO t1 VALUES (-2), (NULL),(2),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Test with UNSIGNED INT column, single insert
-# The sign in the value is ignored and a new column value is generated
-# Reset the AUTOINC session variables
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-INSERT INTO t1 VALUES (-2);
-INSERT INTO t1 VALUES (NULL);
-INSERT INTO t1 VALUES (2);
-INSERT INTO t1 VALUES (NULL);
-INSERT INTO t1 VALUES (250);
-INSERT INTO t1 VALUES (NULL);
-SELECT * FROM t1;
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Test with UNSIGNED INT column, multi-value inserts
-# The sign in the value is ignored and a new column value is generated
-# Reset the AUTOINC session variables
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-INSERT INTO t1 VALUES (-2),(NULL),(2),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Check for overflow handling when increment is > 1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (9223372036854775794); #-- 2^63 - 14
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-# This should just fit
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Check for overflow handling when increment and offser are > 1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-# This should fail because of overflow but it doesn't, it seems to be
-# a MySQL server bug. It wraps around to 0 for the last value.
-# See MySQL Bug# 39828
-#
-# Instead of wrapping around, it asserts when MySQL is compiled --with-debug
-# (see sql/handler.cc:handler::update_auto_increment()).  Don't test for
-# overflow until Bug #39828 is fixed.
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed.  For now, this test is meaningless.
-#if Bug #39828 is fixed
-#INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-#else
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-#endif
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Check for overflow handling when increment and offset are odd numbers
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7;
-SHOW VARIABLES LIKE "auto_inc%";
-# This should fail because of overflow but it doesn't. It fails with
-# a duplicate entry message because of a MySQL server bug, it wraps
-# around.  See MySQL Bug# 39828, once MySQL fix the bug we can replace
-# the ER_DUP_ENTRY, 1062 below with the appropriate error message
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed.  For now, this test is meaningless.
-#if Bug #39828 is fixed
-# Still need to fix this error code, error should mention overflow
-#-- error ER_DUP_ENTRY,1062
-#INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
-#else
-INSERT INTO t1 VALUES (NULL),(NULL);
-#endif
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Check for overflow handling when increment and offset are odd numbers
-# and check for large -ve numbers
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES(-9223372036854775806); #-- -2^63 + 2
-INSERT INTO t1 VALUES(-9223372036854775807); #-- -2^63 + 1
-INSERT INTO t1 VALUES(-9223372036854775808); #-- -2^63
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3;
-SHOW VARIABLES LIKE "auto_inc%";
-INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# Check for overflow handling when increment and offset are very
-# large numbers 2^60
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
-SHOW VARIABLES LIKE "auto_inc%";
-# This should fail because of overflow but it doesn't. It wraps around
-# and the autoinc values look bogus too.
-# See MySQL Bug# 39828, once MySQL fix the bug we can enable the error
-# code expected test.
-# -- error ER_AUTOINC_READ_FAILED,1467
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed.  For now, this test is meaningless.
-#if Bug #39828 is fixed
-#-- error ER_AUTOINC_READ_FAILED,1467
-#INSERT INTO t1 VALUES (NULL),(NULL);
-#else
-INSERT INTO t1 VALUES (NULL);
-#endif
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Check for floating point autoinc column handling
-#
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "%auto_inc%";
-CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL, 1);
-INSERT INTO t1 VALUES(NULL, 2);
-SELECT * FROM t1;
-ALTER TABLE t1 CHANGE c1 c1 SERIAL;
-SELECT * FROM t1;
-INSERT INTO t1 VALUES(NULL, 3);
-INSERT INTO t1 VALUES(NULL, 4);
-SELECT * FROM t1;
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL, 1);
-INSERT INTO t1 VALUES(NULL, 2);
-SELECT * FROM t1;
-ALTER TABLE t1 CHANGE c1 c1 SERIAL;
-SELECT * FROM t1;
-INSERT INTO t1 VALUES(NULL, 3);
-INSERT INTO t1 VALUES(NULL, 4);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Bug# 42714: AUTOINC column calculated next value not greater than highest
-# value stored in table.
-#
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-CREATE TABLE t1 (
-  a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
-  b INT(10) UNSIGNED NOT NULL,
-  c ENUM('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (a)) ENGINE = InnoDB;
-CREATE TABLE t2 (
-  m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
-  n INT(10) UNSIGNED NOT NULL,
-  o enum('FALSE','TRUE') DEFAULT NULL,
-  PRIMARY KEY (m)) ENGINE = InnoDB;
-INSERT INTO t2 (n,o) VALUES
-  (1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
-  (3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
-SHOW CREATE TABLE t2;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-DROP TABLE t2;
-#
-# 43203: Overflow from auto incrementing causes server segv
-#
-
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-CREATE TABLE t1(
-   c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
-   PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-CREATE TABLE t2(
-    c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
-    PRIMARY KEY) ENGINE=InnoDB;
--- error ER_DUP_ENTRY,1062
-INSERT INTO t2 SELECT c1 FROM t1;
--- error ER_DUP_ENTRY,1467
-INSERT INTO t2 SELECT NULL FROM t1;
-DROP TABLE t1;
-DROP TABLE t2;

=== added file 'mysql-test/t/innodb-index.test'
--- a/mysql-test/t/innodb-index.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-index.test	2009-06-11 12:53:26 +0000
@@ -0,0 +1,516 @@
+-- source include/have_innodb.inc
+
+SET @save_innodb_file_format_check=@@global.innodb_file_format_check;
+
+create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb;
+insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak');
+commit;
+--error ER_DUP_KEYNAME
+alter table t1 add index b (b), add index b (b);
+--error ER_DUP_FIELDNAME
+alter table t1 add index (b,b);
+alter table t1 add index d2 (d);
+show create table t1;
+explain select * from t1 force index(d2) order by d;
+select * from t1 force index (d2) order by d;
+--error ER_DUP_ENTRY
+alter table t1 add unique index (b);
+show create table t1;
+alter table t1 add index (b);
+show create table t1;
+
+# Check how existing tables interfere with temporary tables.
+CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB;
+
+call mtr.add_suppression(" table `test`\\.`t1#[12]` already exists in InnoDB internal");
+
+--error 156
+alter table t1 add unique index (c), add index (d);
+rename table `t1#1` to `t1#2`;
+--error 156
+alter table t1 add unique index (c), add index (d);
+drop table `t1#2`;
+
+alter table t1 add unique index (c), add index (d);
+show create table t1;
+explain select * from t1 force index(c) order by c;
+alter table t1 add primary key (a), drop index c;
+show create table t1;
+--error ER_MULTIPLE_PRI_KEY
+alter table t1 add primary key (c);
+--error ER_DUP_ENTRY
+alter table t1 drop primary key, add primary key (b);
+create unique index c on t1 (c);
+show create table t1;
+explain select * from t1 force index(c) order by c;
+select * from t1 force index(c) order by c;
+alter table t1 drop index b, add index (b);
+show create table t1;
+insert into t1 values(6,1,'ggg','ggg');
+select * from t1;
+select * from t1 force index(b) order by b;
+select * from t1 force index(c) order by c;
+select * from t1 force index(d) order by d;
+explain select * from t1 force index(b) order by b;
+explain select * from t1 force index(c) order by c;
+explain select * from t1 force index(d) order by d;
+show create table t1;
+drop table t1;
+
+create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe');
+commit;
+alter table t1 add index (c(2));
+show create table t1;
+alter table t1 add unique index (d(10));
+show create table t1;
+insert into t1 values(5,1,'ggg','ggg');
+select * from t1;
+select * from t1 force index(c) order by c;
+select * from t1 force index(d) order by d;
+explain select * from t1 order by b;
+explain select * from t1 force index(c) order by c;
+explain select * from t1 force index(d) order by d;
+show create table t1;
+alter table t1 drop index d;
+insert into t1 values(8,9,'fff','fff');
+select * from t1;
+select * from t1 force index(c) order by c;
+explain select * from t1 order by b;
+explain select * from t1 force index(c) order by c;
+explain select * from t1 order by d;
+show create table t1;
+drop table t1;
+
+create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
+commit;
+alter table t1 add unique index (b,c);
+insert into t1 values(8,9,'fff','fff');
+select * from t1;
+select * from t1 force index(b) order by b;
+explain select * from t1 force index(b) order by b;
+show create table t1;
+alter table t1 add index (b,c);
+insert into t1 values(11,11,'kkk','kkk');
+select * from t1;
+select * from t1 force index(b) order by b;
+explain select * from t1 force index(b) order by b;
+show create table t1;
+alter table t1 add unique index (c,d);
+insert into t1 values(13,13,'yyy','aaa');
+select * from t1;
+select * from t1 force index(b) order by b;
+select * from t1 force index(c) order by c;
+explain select * from t1 force index(b) order by b;
+explain select * from t1 force index(c) order by c;
+show create table t1;
+drop table t1;
+
+create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb;
+create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb;
+create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb;
+create table t2(a int not null, b int not null, c int not null, d int not null, e int,
+foreign key (b) references t1(b) on delete cascade,
+foreign key (c) references t3(c), foreign key (d) references t4(d))
+engine = innodb;
+--error ER_DROP_INDEX_FK
+alter table t1 drop index b;
+--error ER_DROP_INDEX_FK
+alter table t3 drop index c;
+--error ER_DROP_INDEX_FK
+alter table t4 drop index d;
+--error ER_DROP_INDEX_FK
+alter table t2 drop index b;
+--error ER_DROP_INDEX_FK
+alter table t2 drop index b, drop index c, drop index d;
+# Apparently, the following makes mysql_alter_table() drop index d.
+create unique index dc on t2 (d,c);
+create index dc on t1 (b,c);
+# This should preserve the foreign key constraints.
+alter table t2 add primary key (a);
+insert into t1 values (1,1,1);
+insert into t3 values (1,1,1);
+insert into t4 values (1,1,1);
+insert into t2 values (1,1,1,1,1);
+commit;
+alter table t4 add constraint dc foreign key (a) references t1(a);
+show create table t4;
+--replace_regex /'test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+# a foreign key 'test/dc' already exists
+--error ER_CANT_CREATE_TABLE
+alter table t3 add constraint dc foreign key (a) references t1(a);
+show create table t3;
+alter table t2 drop index b, add index (b);
+show create table t2;
+--error ER_ROW_IS_REFERENCED_2
+delete from t1;
+--error ER_CANT_DROP_FIELD_OR_KEY
+drop index dc on t4;
+# there is no foreign key dc on t3
+--replace_regex /'\.\/test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/
+--error ER_ERROR_ON_RENAME
+alter table t3 drop foreign key dc;
+alter table t4 drop foreign key dc;
+select * from t2;
+delete from t1;
+select * from t2;
+
+drop table t2,t4,t3,t1;
+
+-- let charset = utf8
+-- source include/innodb-index.inc
+
+create table t1(a int not null, b int) engine = innodb;
+insert into t1 values (1,1),(1,1),(1,1),(1,1);
+--error ER_DUP_ENTRY
+alter table t1 add unique index (a);
+--error ER_DUP_ENTRY
+alter table t1 add unique index (b);
+--error ER_DUP_ENTRY
+alter table t1 add unique index (a), add unique index(b);
+show create table t1;
+drop table t1;
+
+create table t1(a int not null, c int not null,b int, primary key(a), unique key(c), key(b)) engine = innodb;
+alter table t1 drop index c, drop index b;
+show create table t1;
+drop table t1;
+
+create table t1(a int not null, b int, primary key(a)) engine = innodb;
+alter table t1 add index (b);
+show create table t1;
+drop table t1;
+
+create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
+insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ac','ac'),(4,4,'afe','afe'),(5,4,'affe','affe');
+--error ER_DUP_ENTRY
+alter table t1 add unique index (b), add unique index (c), add unique index (d);
+--error ER_DUP_ENTRY
+alter table t1 add unique index (c), add unique index (b), add index (d);
+show create table t1;
+drop table t1;
+
+create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb;
+insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1);
+alter table t1 add unique index (b);
+insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17);
+show create table t1;
+check table t1;
+explain select * from t1 force index(c) order by c;
+explain select * from t1 order by a;
+explain select * from t1 force index(b) order by b;
+select * from t1 order by a;
+select * from t1 force index(b) order by b;
+select * from t1 force index(c) order by c;
+drop table t1;
+
+create table t1(a int not null, b int not null) engine=innodb;
+insert into t1 values (1,1);
+alter table t1 add primary key(b);
+insert into t1 values (2,2);
+show create table t1;
+check table t1;
+select * from t1;
+explain select * from t1;
+explain select * from t1 order by a;
+explain select * from t1 order by b;
+checksum table t1;
+drop table t1;
+
+create table t1(a int not null) engine=innodb;
+insert into t1 values (1);
+alter table t1 add primary key(a);
+insert into t1 values (2);
+show create table t1;
+check table t1;
+commit;
+select * from t1;
+explain select * from t1;
+explain select * from t1 order by a;
+drop table t1;
+
+create table t2(d varchar(17) primary key) engine=innodb default charset=utf8;
+create table t3(a int primary key) engine=innodb;
+
+insert into t3 values(22),(44),(33),(55),(66);
+
+insert into t2 values ('jejdkrun87'),('adfd72nh9k'),
+('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik');
+
+create table t1(a int, b blob, c text, d text not null)
+engine=innodb default charset = utf8;
+
+# r2667 The following test is disabled because MySQL behavior changed.
+# r2667 The test was added with this comment:
+# r2667 
+# r2667 ------------------------------------------------------------------------
+# r2667 r1699 | marko | 2007-08-10 19:53:19 +0300 (Fri, 10 Aug 2007) | 5 lines
+# r2667 
+# r2667 branches/zip: Add changes that accidentally omitted from r1698:
+# r2667 
+# r2667 innodb-index.test, innodb-index.result: Add a test for creating
+# r2667 a PRIMARY KEY on a column that contains a NULL value.
+# r2667 ------------------------------------------------------------------------
+# r2667 
+# r2667 but in BZR-r2667:
+# r2667 http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.1/revision/davi%40mysql.com-20080617141221-8yre8ys9j4uw3xx5?start_revid=joerg%40mysql.com-20080630105418-7qoe5ehomgrcdb89
+# r2667 MySQL changed the behavior to do full table copy when creating PRIMARY INDEX
+# r2667 on a non-NULL column instead of calling ::add_index() which would fail (and
+# r2667 this is what we were testing here). Before r2667 the code execution path was
+# r2667 like this (when adding PRIMARY INDEX on a non-NULL column with ALTER TABLE):
+# r2667 
+# r2667 mysql_alter_table()
+# r2667   compare_tables()  // would return ALTER_TABLE_INDEX_CHANGED
+# r2667   ::add_index()  // would fail with "primary index cannot contain NULL"
+# r2667 
+# r2667 after r2667 the code execution path is the following:
+# r2667 
+# r2667 mysql_alter_table()
+# r2667   compare_tables()  // returns ALTER_TABLE_DATA_CHANGED
+# r2667   full copy is done, without calling ::add_index()
+# r2667 
+# r2667 To enable, remove "# r2667: " below.
+# r2667 
+# r2667: insert into t1 values (null,null,null,'null');
+insert into t1
+select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3;
+drop table t2, t3;
+select count(*) from t1 where a=44;
+select a,
+length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
+# r2667: --error ER_PRIMARY_CANT_HAVE_NULL
+# r2667: alter table t1 add primary key (a), add key (b(20));
+# r2667: delete from t1 where d='null';
+--error ER_DUP_ENTRY
+alter table t1 add primary key (a), add key (b(20));
+delete from t1 where a%2;
+check table t1;
+alter table t1 add primary key (a,b(255),c(255)), add key (b(767));
+select count(*) from t1 where a=44;
+select a,
+length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
+show create table t1;
+check table t1;
+explain select * from t1 where b like 'adfd%';
+
+#
+# Test locking
+#
+
+create table t2(a int, b varchar(255), primary key(a,b)) engine=innodb;
+insert into t2 select a,left(b,255) from t1;
+drop table t1;
+rename table t2 to t1;
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+set innodb_lock_wait_timeout=1;
+begin;
+# Obtain an IX lock on the table
+select a from t1 limit 1 for update;
+connection b;
+set innodb_lock_wait_timeout=1;
+# This would require an S lock on the table, conflicting with the IX lock.
+--error ER_LOCK_WAIT_TIMEOUT
+create index t1ba on t1 (b,a);
+connection a;
+commit;
+begin;
+# Obtain an IS lock on the table
+select a from t1 limit 1 lock in share mode;
+connection b;
+# This will require an S lock on the table.  No conflict with the IS lock.
+create index t1ba on t1 (b,a);
+# This would require an X lock on the table, conflicting with the IS lock.
+--error ER_LOCK_WAIT_TIMEOUT
+drop index t1ba on t1;
+connection a;
+commit;
+explain select a from t1 order by b;
+--send
+select a,sleep(2+a/100) from t1 order by b limit 3;
+
+# The following DROP INDEX will succeed, altough the SELECT above has
+# opened a read view.  However, during the execution of the SELECT,
+# MySQL should hold a table lock that should block the execution
+# of the DROP INDEX below.
+
+connection b;
+select sleep(1);
+drop index t1ba on t1;
+
+# After the index was dropped, subsequent SELECTs will use the same
+# read view, but they should not be accessing the dropped index any more.
+
+connection a;
+reap;
+explain select a from t1 order by b;
+select a from t1 order by b limit 3;
+commit;
+
+connection default;
+disconnect a;
+disconnect b;
+
+drop table t1;
+
+let $per_table=`select @@innodb_file_per_table`;
+let $format=`select @@innodb_file_format`;
+set global innodb_file_per_table=on;
+set global innodb_file_format='Barracuda';
+# Test creating a table that could lead to undo log overflow.
+# In the undo log, we write a 768-byte prefix (REC_MAX_INDEX_COL_LEN)
+# of each externally stored column that appears as a column prefix in an index.
+# For this test case, it would suffice to write 1 byte, though.
+create table t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob,
+		i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob,
+		q blob,r blob,s blob,t blob,u blob)
+	engine=innodb row_format=dynamic;
+create index t1a on t1 (a(1));
+create index t1b on t1 (b(1));
+create index t1c on t1 (c(1));
+create index t1d on t1 (d(1));
+create index t1e on t1 (e(1));
+create index t1f on t1 (f(1));
+create index t1g on t1 (g(1));
+create index t1h on t1 (h(1));
+create index t1i on t1 (i(1));
+create index t1j on t1 (j(1));
+create index t1k on t1 (k(1));
+create index t1l on t1 (l(1));
+create index t1m on t1 (m(1));
+create index t1n on t1 (n(1));
+create index t1o on t1 (o(1));
+create index t1p on t1 (p(1));
+create index t1q on t1 (q(1));
+create index t1r on t1 (r(1));
+create index t1s on t1 (s(1));
+create index t1t on t1 (t(1));
+--error 139
+create index t1u on t1 (u(1));
+--error 139
+create index t1ut on t1 (u(1), t(1));
+create index t1st on t1 (s(1), t(1));
+show create table t1;
+--error 139
+create index t1u on t1 (u(1));
+alter table t1 row_format=compact;
+create index t1u on t1 (u(1));
+
+drop table t1;
+eval set global innodb_file_per_table=$per_table;
+eval set global innodb_file_format=$format;
+
+#
+# Test to check whether CREATE INDEX handles implicit foreign key
+# constraint modifications (Issue #70, Bug #38786)
+#
+SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
+SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
+
+CREATE TABLE t1(
+  c1	BIGINT(12) NOT NULL,
+  PRIMARY KEY (c1)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE t2(
+  c1	BIGINT(16) NOT NULL,
+  c2	BIGINT(12) NOT NULL,
+  c3	BIGINT(12) NOT NULL,
+  PRIMARY KEY (c1)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+ FOREIGN KEY (c3) REFERENCES t1(c1);
+
+SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
+SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
+
+SHOW CREATE TABLE t2;
+
+CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
+
+SHOW CREATE TABLE t2;
+
+SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
+SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
+
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO t2 VALUES(0,0,0);
+INSERT INTO t1 VALUES(0);
+INSERT INTO t2 VALUES(0,0,0);
+
+DROP TABLE t2;
+
+CREATE TABLE t2(
+  c1	BIGINT(16) NOT NULL,
+  c2	BIGINT(12) NOT NULL,
+  c3	BIGINT(12) NOT NULL,
+  PRIMARY KEY (c1,c2,c3)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+ FOREIGN KEY (c3) REFERENCES t1(c1);
+
+SHOW CREATE TABLE t2;
+
+CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
+
+SHOW CREATE TABLE t2;
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO t2 VALUES(0,0,1);
+INSERT INTO t2 VALUES(0,0,0);
+--error ER_ROW_IS_REFERENCED_2
+DELETE FROM t1;
+DELETE FROM t2;
+
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1(
+  c1	BIGINT(12) NOT NULL,
+  c2	INT(4) NOT NULL,
+  PRIMARY KEY (c2,c1)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE t2(
+  c1	BIGINT(16) NOT NULL,
+  c2	BIGINT(12) NOT NULL,
+  c3	BIGINT(12) NOT NULL,
+  PRIMARY KEY (c1)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+ FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1);
+--replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+ FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2);
+--replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+ FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1);
+ALTER TABLE t1 MODIFY COLUMN c2 BIGINT(12) NOT NULL;
+--replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+ FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2);
+
+ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
+ FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1);
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+CREATE INDEX i_t2_c2_c1 ON t2(c2, c1);
+SHOW CREATE TABLE t2;
+CREATE INDEX i_t2_c3_c1_c2 ON t2(c3, c1, c2);
+SHOW CREATE TABLE t2;
+CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
+SHOW CREATE TABLE t2;
+
+DROP TABLE t2;
+DROP TABLE t1;
+SET GLOBAL innodb_file_format_check=@save_innodb_file_format_check;

=== added file 'mysql-test/t/innodb-index_ucs2.test'
--- a/mysql-test/t/innodb-index_ucs2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-index_ucs2.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,5 @@
+-- source include/have_innodb.inc
+-- source include/have_ucs2.inc
+
+-- let charset = ucs2
+-- source include/innodb-index.inc

=== added file 'mysql-test/t/innodb-lock.test'
--- a/mysql-test/t/innodb-lock.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-lock.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,102 @@
+-- source include/have_innodb.inc
+
+#
+# Check and select innodb lock type
+#
+
+set global innodb_table_locks=1;
+
+select @@innodb_table_locks;
+
+#
+# Testing of explicit table locks with enforced table locks
+#
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Testing of explicit table locks with enforced table locks
+#
+
+set @@innodb_table_locks=1;
+
+connection con1;
+create table t1 (id integer, x integer) engine=INNODB;
+insert into t1 values(0, 0);
+set autocommit=0;
+SELECT * from t1 where id = 0 FOR UPDATE;
+
+connection con2;
+set autocommit=0;
+
+# The following statement should hang because con1 is locking the page
+--send
+lock table t1 write;
+--sleep 2
+
+connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+update t1 set x=2 where id = 0;
+commit;
+unlock tables;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1;
+
+#
+# Try with old lock method (where LOCK TABLE is ignored by InnoDB)
+#
+
+set @@innodb_table_locks=0;
+
+create table t1 (id integer primary key, x integer) engine=INNODB;
+insert into t1 values(0, 0),(1,1),(2,2);
+commit;
+SELECT * from t1 where id = 0 FOR UPDATE;
+
+connection con2;
+set autocommit=0;
+set @@innodb_table_locks=0;
+
+# The following statement should work becase innodb doesn't check table locks
+lock table t1 write;
+
+connection con1;
+
+# This will be locked by MySQL
+--send
+update t1 set x=10 where id = 2;
+--sleep 2
+
+connection con2;
+
+# Note that we will get a deadlock if we try to select any rows marked
+# for update by con1 !
+
+SELECT * from t1 where id = 2;
+UPDATE t1 set x=3 where id = 2;
+commit;
+SELECT * from t1;
+commit;
+unlock tables;
+
+connection con1;
+reap;
+commit;
+select * from t1;
+drop table t1;
+
+# End of 4.1 tests

=== removed file 'mysql-test/t/innodb-lock.test'
--- a/mysql-test/t/innodb-lock.test	2006-11-19 18:26:36 +0000
+++ b/mysql-test/t/innodb-lock.test	1970-01-01 00:00:00 +0000
@@ -1,102 +0,0 @@
--- source include/have_innodb.inc
-
-#
-# Check and select innodb lock type
-#
-
-set global innodb_table_locks=1;
-
-select @@innodb_table_locks;
-
-#
-# Testing of explicit table locks with enforced table locks
-#
-
-connect (con1,localhost,root,,);
-connect (con2,localhost,root,,);
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-#
-# Testing of explicit table locks with enforced table locks
-#
-
-set @@innodb_table_locks=1;
-
-connection con1;
-create table t1 (id integer, x integer) engine=INNODB;
-insert into t1 values(0, 0);
-set autocommit=0;
-SELECT * from t1 where id = 0 FOR UPDATE;
-
-connection con2;
-set autocommit=0;
-
-# The following statement should hang because con1 is locking the page
---send
-lock table t1 write;
---sleep 2
-
-connection con1;
-update t1 set x=1 where id = 0;
-select * from t1;
-commit;
-
-connection con2;
-reap;
-update t1 set x=2 where id = 0;
-commit;
-unlock tables;
-
-connection con1;
-select * from t1;
-commit;
-
-drop table t1;
-
-#
-# Try with old lock method (where LOCK TABLE is ignored by InnoDB)
-#
-
-set @@innodb_table_locks=0;
-
-create table t1 (id integer primary key, x integer) engine=INNODB;
-insert into t1 values(0, 0),(1,1),(2,2);
-commit;
-SELECT * from t1 where id = 0 FOR UPDATE;
-
-connection con2;
-set autocommit=0;
-set @@innodb_table_locks=0;
-
-# The following statement should work becase innodb doesn't check table locks
-lock table t1 write;
-
-connection con1;
-
-# This will be locked by MySQL
---send
-update t1 set x=10 where id = 2;
---sleep 2
-
-connection con2;
-
-# Note that we will get a deadlock if we try to select any rows marked
-# for update by con1 !
-
-SELECT * from t1 where id = 2;
-UPDATE t1 set x=3 where id = 2;
-commit;
-SELECT * from t1;
-commit;
-unlock tables;
-
-connection con1;
-reap;
-commit;
-select * from t1;
-drop table t1;
-
-# End of 4.1 tests

=== added file 'mysql-test/t/innodb-master.opt'
--- a/mysql-test/t/innodb-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-master.opt	2009-06-09 13:19:13 +0000
@@ -0,0 +1 @@
+--binlog_cache_size=32768 --innodb_lock_wait_timeout=1

=== removed file 'mysql-test/t/innodb-master.opt'
--- a/mysql-test/t/innodb-master.opt	2006-04-23 08:48:31 +0000
+++ b/mysql-test/t/innodb-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---binlog_cache_size=32768 --innodb_lock_wait_timeout=1

=== added file 'mysql-test/t/innodb-replace.test'
--- a/mysql-test/t/innodb-replace.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-replace.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,22 @@
+-- source include/have_innodb.inc
+# embedded server ignores 'delayed', so skip this
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Bug #1078
+#
+create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb;
+select * from t1;
+--error ER_DELAYED_NOT_SUPPORTED
+replace delayed into t1 (c1, c2)  values ( "text1","11");
+select * from t1;
+--error ER_DELAYED_NOT_SUPPORTED
+replace delayed into t1 (c1, c2)  values ( "text1","12");
+select * from t1;
+drop table t1;
+
+# End of 4.1 tests

=== removed file 'mysql-test/t/innodb-replace.test'
--- a/mysql-test/t/innodb-replace.test	2008-06-03 11:25:41 +0000
+++ b/mysql-test/t/innodb-replace.test	1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
--- source include/have_innodb.inc
-# embedded server ignores 'delayed', so skip this
--- source include/not_embedded.inc
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-#
-# Bug #1078
-#
-create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb;
-select * from t1;
---error ER_DELAYED_NOT_SUPPORTED
-replace delayed into t1 (c1, c2)  values ( "text1","11");
-select * from t1;
---error ER_DELAYED_NOT_SUPPORTED
-replace delayed into t1 (c1, c2)  values ( "text1","12");
-select * from t1;
-drop table t1;
-
-# End of 4.1 tests

=== added file 'mysql-test/t/innodb-semi-consistent-master.opt'
--- a/mysql-test/t/innodb-semi-consistent-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-semi-consistent-master.opt	2009-06-09 13:19:13 +0000
@@ -0,0 +1 @@
+--innodb_lock_wait_timeout=2

=== removed file 'mysql-test/t/innodb-semi-consistent-master.opt'
--- a/mysql-test/t/innodb-semi-consistent-master.opt	2009-01-13 14:14:11 +0000
+++ b/mysql-test/t/innodb-semi-consistent-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---innodb_lock_wait_timeout=2

=== added file 'mysql-test/t/innodb-semi-consistent.test'
--- a/mysql-test/t/innodb-semi-consistent.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-semi-consistent.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,55 @@
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+# basic tests of semi-consistent reads
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+set binlog_format=mixed;
+set session transaction isolation level repeatable read;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+set autocommit=0;
+# this should lock the entire table
+select * from t1 where a=3 lock in share mode;
+connection b;
+set binlog_format=mixed;
+set session transaction isolation level repeatable read;
+set autocommit=0;
+-- error ER_LOCK_WAIT_TIMEOUT
+update t1 set a=10 where a=5;
+connection a;
+commit;
+connection b;
+# perform a semi-consisent read (and unlock non-matching rows)
+set session transaction isolation level read committed;
+update t1 set a=10 where a=5;
+connection a;
+-- error ER_LOCK_WAIT_TIMEOUT
+select * from t1 where a=2 for update;
+# this should lock the records (1),(2)
+select * from t1 where a=2 limit 1 for update;
+connection b;
+# semi-consistent read will skip non-matching locked rows a=1, a=2
+update t1 set a=11 where a=6;
+-- error ER_LOCK_WAIT_TIMEOUT
+update t1 set a=12 where a=2;
+-- error ER_LOCK_WAIT_TIMEOUT
+update t1 set a=13 where a=1;
+connection a;
+commit;
+connection b;
+update t1 set a=14 where a=1;
+commit;
+connection a;
+select * from t1;
+drop table t1;
+
+connection default;
+disconnect a;
+disconnect b;

=== removed file 'mysql-test/t/innodb-semi-consistent.test'
--- a/mysql-test/t/innodb-semi-consistent.test	2009-01-13 14:14:11 +0000
+++ b/mysql-test/t/innodb-semi-consistent.test	1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
--- source include/not_embedded.inc
--- source include/have_innodb.inc
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-# basic tests of semi-consistent reads
-
-connect (a,localhost,root,,);
-connect (b,localhost,root,,);
-connection a;
-set binlog_format=mixed;
-set session transaction isolation level repeatable read;
-create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into t1 values (1),(2),(3),(4),(5),(6),(7);
-set autocommit=0;
-# this should lock the entire table
-select * from t1 where a=3 lock in share mode;
-connection b;
-set binlog_format=mixed;
-set session transaction isolation level repeatable read;
-set autocommit=0;
--- error ER_LOCK_WAIT_TIMEOUT
-update t1 set a=10 where a=5;
-connection a;
-commit;
-connection b;
-# perform a semi-consisent read (and unlock non-matching rows)
-set session transaction isolation level read committed;
-update t1 set a=10 where a=5;
-connection a;
--- error ER_LOCK_WAIT_TIMEOUT
-select * from t1 where a=2 for update;
-# this should lock the records (1),(2)
-select * from t1 where a=2 limit 1 for update;
-connection b;
-# semi-consistent read will skip non-matching locked rows a=1, a=2
-update t1 set a=11 where a=6;
--- error ER_LOCK_WAIT_TIMEOUT
-update t1 set a=12 where a=2;
--- error ER_LOCK_WAIT_TIMEOUT
-update t1 set a=13 where a=1;
-connection a;
-commit;
-connection b;
-update t1 set a=14 where a=1;
-commit;
-connection a;
-select * from t1;
-drop table t1;
-
-connection default;
-disconnect a;
-disconnect b;

=== added file 'mysql-test/t/innodb-timeout.test'
--- a/mysql-test/t/innodb-timeout.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-timeout.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,64 @@
+-- source include/have_innodb.inc
+
+let $timeout=`select @@innodb_lock_wait_timeout`;
+set global innodb_lock_wait_timeout=42;
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+
+connection a;
+select @@innodb_lock_wait_timeout;
+set innodb_lock_wait_timeout=1;
+select @@innodb_lock_wait_timeout;
+
+connection b;
+select @@innodb_lock_wait_timeout;
+set global innodb_lock_wait_timeout=347;
+select @@innodb_lock_wait_timeout;
+set innodb_lock_wait_timeout=1;
+select @@innodb_lock_wait_timeout;
+
+connect (c,localhost,root,,);
+connection c;
+select @@innodb_lock_wait_timeout;
+connection default;
+disconnect c;
+
+connection a;
+create table t1(a int primary key)engine=innodb;
+begin;
+insert into t1 values(1),(2),(3);
+
+connection b;
+--send
+select * from t1 for update;
+
+connection a;
+commit;
+
+connection b;
+reap;
+
+connection a;
+begin;
+insert into t1 values(4);
+
+connection b;
+--send
+select * from t1 for update;
+
+connection a;
+sleep 2;
+commit;
+
+connection b;
+--error ER_LOCK_WAIT_TIMEOUT
+reap;
+drop table t1;
+
+connection default;
+
+disconnect a;
+disconnect b;
+
+eval set global innodb_lock_wait_timeout=$timeout;

=== added file 'mysql-test/t/innodb-use-sys-malloc-master.opt'
--- a/mysql-test/t/innodb-use-sys-malloc-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-use-sys-malloc-master.opt	2009-06-09 13:19:13 +0000
@@ -0,0 +1,2 @@
+--innodb-use-sys-malloc=true
+--innodb-use-sys-malloc=true

=== added file 'mysql-test/t/innodb-use-sys-malloc.test'
--- a/mysql-test/t/innodb-use-sys-malloc.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-use-sys-malloc.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,48 @@
+--source include/have_innodb.inc
+
+#display current value of innodb_use_sys_malloc
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+--echo 1 Expected
+
+#try changing it. Should fail.
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@GLOBAL.innodb_use_sys_malloc=0;
+--echo Expected error 'Read only variable'
+
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+--echo 1 Expected
+
+
+#do some stuff to see if it works.
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+select * from t1;
+drop table t1;
+--source include/have_innodb.inc
+
+#display current value of innodb_use_sys_malloc
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+--echo 1 Expected
+
+#try changing it. Should fail.
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@GLOBAL.innodb_use_sys_malloc=0;
+--echo Expected error 'Read only variable'
+
+SELECT @@GLOBAL.innodb_use_sys_malloc;
+--echo 1 Expected
+
+
+#do some stuff to see if it works.
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+select * from t1;
+drop table t1;

=== added file 'mysql-test/t/innodb-zip.test'
--- a/mysql-test/t/innodb-zip.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb-zip.test	2009-06-09 15:08:46 +0000
@@ -0,0 +1,347 @@
+-- source include/have_innodb.inc
+
+let $per_table=`select @@innodb_file_per_table`;
+let $format=`select @@innodb_file_format`;
+let $innodb_file_format_check_orig=`select @@innodb_file_format_check`;
+set global innodb_file_per_table=off;
+set global innodb_file_format=`0`;
+
+create table t0(a int primary key) engine=innodb row_format=compressed;
+create table t00(a int primary key) engine=innodb
+key_block_size=4 row_format=compressed;
+create table t1(a int primary key) engine=innodb row_format=dynamic;
+create table t2(a int primary key) engine=innodb row_format=redundant;
+create table t3(a int primary key) engine=innodb row_format=compact;
+create table t4(a int primary key) engine=innodb key_block_size=9;
+create table t5(a int primary key) engine=innodb
+key_block_size=1 row_format=redundant;
+
+set global innodb_file_per_table=on;
+create table t6(a int primary key) engine=innodb
+key_block_size=1 row_format=redundant;
+set global innodb_file_format=`1`;
+create table t7(a int primary key) engine=innodb
+key_block_size=1 row_format=redundant;
+create table t8(a int primary key) engine=innodb
+key_block_size=1 row_format=fixed;
+create table t9(a int primary key) engine=innodb
+key_block_size=1 row_format=compact;
+create table t10(a int primary key) engine=innodb
+key_block_size=1 row_format=dynamic;
+create table t11(a int primary key) engine=innodb
+key_block_size=1 row_format=compressed;
+create table t12(a int primary key) engine=innodb
+key_block_size=1;
+create table t13(a int primary key) engine=innodb
+row_format=compressed;
+create table t14(a int primary key) engine=innodb key_block_size=9;
+
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+
+drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
+alter table t1 key_block_size=0;
+alter table t1 row_format=dynamic;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+alter table t1 row_format=compact;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+alter table t1 row_format=redundant;
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+drop table t1;
+
+create table t1(a int not null, b text, index(b(10))) engine=innodb
+key_block_size=1;
+
+create table t2(b text)engine=innodb;
+insert into t2 values(concat('1abcdefghijklmnopqrstuvwxyz', repeat('A',5000)));
+
+insert into t1 select 1, b from t2;
+commit;
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+
+connection a;
+begin;
+update t1 set b=repeat('B',100);
+
+connection b;
+select a,left(b,40) from t1 natural join t2;
+
+connection a;
+rollback;
+
+connection b;
+select a,left(b,40) from t1 natural join t2;
+
+connection default;
+disconnect a;
+disconnect b;
+
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+drop table t1,t2;
+
+# The following should fail even in non-strict mode.
+SET SESSION innodb_strict_mode = off;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE t1(
+	c TEXT NOT NULL, d TEXT NOT NULL,
+	PRIMARY KEY (c(767),d(767)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE t1(
+	c TEXT NOT NULL, d TEXT NOT NULL,
+	PRIMARY KEY (c(767),d(767)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 CHARSET=ASCII;
+CREATE TABLE t1(
+	c TEXT NOT NULL, d TEXT NOT NULL,
+	PRIMARY KEY (c(767),d(767)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 CHARSET=ASCII;
+drop table t1;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE t1(c TEXT, PRIMARY KEY (c(440)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
+# The maximum key size for a compressed row actually depends on the
+# version of libz used, as account must be taken for the maximum
+# compressed size of a key, and this differs between libz
+# versions. Some libz versions allow a size of 439, some only 438.
+CREATE TABLE t1(c TEXT, PRIMARY KEY (c(438)))
+ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
+INSERT INTO t1 VALUES(REPEAT('A',512)),(REPEAT('B',512));
+DROP TABLE t1;
+
+#
+# Test blob column inheritance (mantis issue#36)
+#
+
+create table t1( c1 int not null, c2 blob, c3 blob, c4 blob,
+		primary key(c1, c2(22), c3(22)))
+		engine = innodb row_format = dynamic;
+begin;
+insert into t1 values(1, repeat('A', 20000), repeat('B', 20000),
+			repeat('C', 20000));
+
+update t1 set c3 = repeat('D', 20000) where c1 = 1;
+commit;
+
+# one blob column which is unchanged in update and part of PK
+# one blob column which is changed and part of of PK
+# one blob column which is not part of PK and is unchanged
+select count(*) from t1 where c2 = repeat('A', 20000);
+select count(*) from t1 where c3 = repeat('D', 20000);
+select count(*) from t1 where c4 = repeat('C', 20000);
+
+update t1 set c3 = repeat('E', 20000) where c1 = 1;
+drop table t1;
+
+#
+#
+# Test innodb_file_format
+#
+set global innodb_file_format=`0`;
+select @@innodb_file_format;
+set global innodb_file_format=`1`;
+select @@innodb_file_format;
+-- error ER_WRONG_ARGUMENTS
+set global innodb_file_format=`2`;
+-- error ER_WRONG_ARGUMENTS
+set global innodb_file_format=`-1`;
+set global innodb_file_format=`Antelope`;
+set global innodb_file_format=`Barracuda`;
+-- error ER_WRONG_ARGUMENTS
+set global innodb_file_format=`Cheetah`;
+-- error ER_WRONG_ARGUMENTS
+set global innodb_file_format=`abc`;
+-- error ER_WRONG_ARGUMENTS
+set global innodb_file_format=`1a`;
+-- error ER_WRONG_ARGUMENTS
+set global innodb_file_format=``;
+
+#test strict mode.
+# this does not work anymore, has been removed from mysqltest
+# -- enable_errors
+set global innodb_file_per_table = on;
+set global innodb_file_format = `1`;
+
+set innodb_strict_mode = off;
+create table t1 (id int primary key) engine = innodb key_block_size = 0;
+drop table t1;
+
+#set strict_mode
+set innodb_strict_mode = on;
+
+#Test different values of KEY_BLOCK_SIZE
+
+--error ER_CANT_CREATE_TABLE
+create table t1 (id int primary key) engine = innodb key_block_size = 0;
+show errors;
+
+--error ER_CANT_CREATE_TABLE
+create table t2 (id int primary key) engine = innodb key_block_size = 9;
+show errors;
+
+
+create table t3 (id int primary key) engine = innodb key_block_size = 1;
+create table t4 (id int primary key) engine = innodb key_block_size = 2;
+create table t5 (id int primary key) engine = innodb key_block_size = 4;
+create table t6 (id int primary key) engine = innodb key_block_size = 8;
+create table t7 (id int primary key) engine = innodb key_block_size = 16;
+
+#check various ROW_FORMAT values.
+create table t8 (id int primary key) engine = innodb row_format = compressed;
+create table t9 (id int primary key) engine = innodb row_format = dynamic;
+create table t10(id int primary key) engine = innodb row_format = compact;
+create table t11(id int primary key) engine = innodb row_format = redundant;
+
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+drop table t3, t4, t5, t6, t7, t8, t9, t10, t11;
+
+#test different values of ROW_FORMAT with KEY_BLOCK_SIZE
+create table t1 (id int primary key) engine = innodb
+key_block_size = 8 row_format = compressed;
+
+--error ER_CANT_CREATE_TABLE
+create table t2 (id int primary key) engine = innodb
+key_block_size = 8 row_format = redundant;
+show errors;
+
+--error ER_CANT_CREATE_TABLE
+create table t3 (id int primary key) engine = innodb
+key_block_size = 8 row_format = compact;
+show errors;
+
+--error ER_CANT_CREATE_TABLE
+create table t4 (id int primary key) engine = innodb
+key_block_size = 8 row_format = dynamic;
+show errors;
+
+--error ER_CANT_CREATE_TABLE
+create table t5 (id int primary key) engine = innodb
+key_block_size = 8 row_format = default;
+show errors;
+
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+drop table t1;
+
+#test multiple errors
+--error ER_CANT_CREATE_TABLE
+create table t1 (id int primary key) engine = innodb
+key_block_size = 9 row_format = redundant;
+show errors;
+
+--error ER_CANT_CREATE_TABLE
+create table t2 (id int primary key) engine = innodb
+key_block_size = 9 row_format = compact;
+show errors;
+
+--error ER_CANT_CREATE_TABLE
+create table t2 (id int primary key) engine = innodb
+key_block_size = 9 row_format = dynamic;
+show errors;
+
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+
+#test valid values with innodb_file_per_table unset
+set global innodb_file_per_table = off;
+
+--error ER_CANT_CREATE_TABLE
+create table t1 (id int primary key) engine = innodb key_block_size = 1;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t2 (id int primary key) engine = innodb key_block_size = 2;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t3 (id int primary key) engine = innodb key_block_size = 4;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t4 (id int primary key) engine = innodb key_block_size = 8;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t5 (id int primary key) engine = innodb key_block_size = 16;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t6 (id int primary key) engine = innodb row_format = compressed;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t7 (id int primary key) engine = innodb row_format = dynamic;
+show errors;
+create table t8 (id int primary key) engine = innodb row_format = compact;
+create table t9 (id int primary key) engine = innodb row_format = redundant;
+
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+drop table t8, t9;
+
+#test valid values with innodb_file_format unset
+set global innodb_file_per_table = on;
+set global innodb_file_format = `0`; 
+
+--error ER_CANT_CREATE_TABLE
+create table t1 (id int primary key) engine = innodb key_block_size = 1;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t2 (id int primary key) engine = innodb key_block_size = 2;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t3 (id int primary key) engine = innodb key_block_size = 4;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t4 (id int primary key) engine = innodb key_block_size = 8;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t5 (id int primary key) engine = innodb key_block_size = 16;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t6 (id int primary key) engine = innodb row_format = compressed;
+show errors;
+--error ER_CANT_CREATE_TABLE
+create table t7 (id int primary key) engine = innodb row_format = dynamic;
+show errors;
+create table t8 (id int primary key) engine = innodb row_format = compact;
+create table t9 (id int primary key) engine = innodb row_format = redundant;
+
+SELECT table_schema, table_name, row_format
+FROM information_schema.tables WHERE engine='innodb';
+drop table t8, t9;
+
+eval set global innodb_file_per_table=$per_table;
+eval set global innodb_file_format=$format;
+#
+# Testing of tablespace tagging
+#
+-- disable_info
+set global innodb_file_per_table=on;
+set global innodb_file_format=`Barracuda`;
+set global innodb_file_format_check=`Antelope`;
+create table normal_table (
+  c1 int
+) engine = innodb;
+select @@innodb_file_format_check;
+create table zip_table (
+  c1 int
+) engine = innodb key_block_size = 8;
+select @@innodb_file_format_check;
+set global innodb_file_format_check=`Antelope`;
+select @@innodb_file_format_check;
+-- disable_result_log
+show table status;
+-- enable_result_log
+select @@innodb_file_format_check;
+drop table normal_table, zip_table;
+-- disable_result_log
+
+#
+# restore environment to the state it was before this test execution
+#
+
+-- disable_query_log
+eval set global innodb_file_format=$format;
+eval set global innodb_file_per_table=$per_table;
+eval set global innodb_file_format_check=$innodb_file_format_check_orig;

=== added file 'mysql-test/t/innodb.test'
--- a/mysql-test/t/innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb.test	2009-06-09 15:08:46 +0000
@@ -0,0 +1,2540 @@
+#######################################################################
+#                                                                     #
+# Please, DO NOT TOUCH this file as well as the innodb.result file.   #
+# These files are to be modified ONLY BY INNOBASE guys.               #
+#                                                                     #
+# Use innodb_mysql.[test|result] files instead.                       #
+#                                                                     #
+# If nevertheless you need to make some changes here, please, forward #
+# your commit message To: dev@xxxxxxxxxx Cc: dev-innodb@xxxxxxxxx     #
+# (otherwise your changes may be erased).                             #
+#                                                                     #
+#######################################################################
+
+-- source include/have_innodb.inc
+
+#
+# Small basic test with ignore
+#
+
+--disable_warnings
+drop table if exists t1,t2,t3,t4;
+drop database if exists mysqltest;
+--enable_warnings
+
+create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
+
+insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
+select id, code, name from t1 order by id;
+
+update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
+select id, code, name from t1 order by id;
+update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
+select id, code, name from t1 order by id;
+
+drop table t1;
+
+#
+# A bit bigger test
+# The 'replace_column' statements are needed because the cardinality calculated
+# by innodb is not always the same between runs
+#
+
+CREATE TABLE t1 (
+  id int(11) NOT NULL auto_increment,
+  parent_id int(11) DEFAULT '0' NOT NULL,
+  level tinyint(4) DEFAULT '0' NOT NULL,
+  PRIMARY KEY (id),
+  KEY parent_id (parent_id),
+  KEY level (level)
+) engine=innodb;
+INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
+update t1 set parent_id=parent_id+100;
+select * from t1 where parent_id=102;
+update t1 set id=id+1000;
+-- error ER_DUP_ENTRY,1022
+update t1 set id=1024 where id=1009; 
+select * from t1;
+update ignore t1 set id=id+1; # This will change all rows
+select * from t1;
+update ignore t1 set id=1023 where id=1010;
+select * from t1 where parent_id=102;
+--replace_column 9 #
+explain select level from t1 where level=1;
+--replace_column 9 #
+explain select level,id from t1 where level=1;
+--replace_column 9 #
+explain select level,id,parent_id from t1 where level=1;
+select level,id from t1 where level=1;
+select level,id,parent_id from t1 where level=1;
+optimize table t1;
+--replace_column 7 #
+show keys from t1;
+drop table t1;
+
+#
+# Test replace
+#
+
+CREATE TABLE t1 (
+  gesuchnr int(11) DEFAULT '0' NOT NULL,
+  benutzer_id int(11) DEFAULT '0' NOT NULL,
+  PRIMARY KEY (gesuchnr,benutzer_id)
+) engine=innodb;
+
+replace into t1 (gesuchnr,benutzer_id) values (2,1);
+replace into t1 (gesuchnr,benutzer_id) values (1,1);
+replace into t1 (gesuchnr,benutzer_id) values (1,1);
+select * from t1;
+drop table t1;
+
+#
+# test delete using hidden_primary_key
+#
+
+create table t1 (a int) engine=innodb;
+insert into t1 values (1), (2);
+optimize table t1;
+delete from t1 where a = 1;
+select * from t1;
+check table t1;
+drop table t1;
+
+create table t1 (a int,b varchar(20)) engine=innodb;
+insert into t1 values (1,""), (2,"testing");
+delete from t1 where a = 1;
+select * from t1;
+create index skr on t1 (a);
+insert into t1 values (3,""), (4,"testing");
+analyze table t1;
+--replace_column 7 #
+show keys from t1;
+drop table t1;
+
+
+# Test of reading on secondary key with may be null
+
+create table t1 (a int,b varchar(20),key(a)) engine=innodb;
+insert into t1 values (1,""), (2,"testing");
+select * from t1 where a = 1;
+drop table t1;
+
+#
+# Test rollback
+#
+
+create table t1 (n int not null primary key) engine=innodb;
+set autocommit=0;
+insert into t1 values (4);
+rollback;
+select n, "after rollback" from t1;
+insert into t1 values (4);
+commit;
+select n, "after commit" from t1;
+commit;
+insert into t1 values (5);
+-- error ER_DUP_ENTRY
+insert into t1 values (4);
+commit;
+select n, "after commit" from t1;
+set autocommit=1;
+insert into t1 values (6);
+-- error ER_DUP_ENTRY
+insert into t1 values (4);
+select n from t1;
+set autocommit=0;
+#
+# savepoints
+#
+begin;
+savepoint `my_savepoint`;
+insert into t1 values (7);
+savepoint `savept2`;
+insert into t1 values (3);
+select n from t1;
+savepoint savept3;
+rollback to savepoint savept2;
+--error 1305
+rollback to savepoint savept3;
+rollback to savepoint savept2;
+release savepoint `my_savepoint`;
+select n from t1;
+-- error 1305
+rollback to savepoint `my_savepoint`;
+--error 1305
+rollback to savepoint savept2;
+insert into t1 values (8);
+savepoint sv;
+commit;
+savepoint sv;
+set autocommit=1;
+# nop
+rollback;
+drop table t1;
+
+#
+# Test for commit and FLUSH TABLES WITH READ LOCK
+#
+
+create table t1 (n int not null primary key) engine=innodb;
+start transaction;
+insert into t1 values (4);
+flush tables with read lock;
+#
+# Current code can't handle a read lock in middle of transaction
+#--error 1223;
+commit;
+unlock tables;
+commit;
+select * from t1;
+drop table t1;
+
+#
+# Testing transactions
+#
+
+create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb;
+begin;
+insert into t1 values(1,'hamdouni');
+select id as afterbegin_id,nom as afterbegin_nom from t1;
+rollback;
+select id as afterrollback_id,nom as afterrollback_nom from t1;
+set autocommit=0;
+insert into t1 values(2,'mysql');
+select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
+rollback;
+select id as afterrollback_id,nom as afterrollback_nom from t1;
+set autocommit=1;
+drop table t1;
+
+#
+# Simple not autocommit test
+# 
+
+CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb;
+insert into t1 values ('pippo', 12);
+-- error ER_DUP_ENTRY
+insert into t1 values ('pippo', 12); # Gives error
+delete from t1;
+delete from t1 where id = 'pippo';
+select * from t1;
+
+insert into t1 values ('pippo', 12);
+set autocommit=0;
+delete from t1;
+rollback;
+select * from t1;
+delete from t1;
+commit;
+select * from t1;
+drop table t1;
+
+#
+# Test of active transactions
+#
+
+create table t1 (a integer) engine=innodb;
+start transaction;
+rename table t1 to t2;
+create table t1 (b integer) engine=innodb;
+insert into t1 values (1);
+rollback;
+drop table t1;
+rename table t2 to t1;
+drop table t1;
+set autocommit=1;
+
+#
+# The following simple tests failed at some point
+#
+
+CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb;
+INSERT INTO t1 VALUES (1, 'Jochen');
+select * from t1;
+drop table t1;
+
+CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb;
+set autocommit=0;
+INSERT INTO t1  SET _userid='marc@xxxxxxxxxxxxx';
+COMMIT;
+SELECT * FROM t1;
+SELECT _userid FROM t1 WHERE _userid='marc@xxxxxxxxxxxxx';
+drop table t1;
+set autocommit=1;
+
+#
+# Test when reading on part of unique key
+#
+CREATE TABLE t1 (
+  user_id int(10) DEFAULT '0' NOT NULL,
+  name varchar(100),
+  phone varchar(100),
+  ref_email varchar(100) DEFAULT '' NOT NULL,
+  detail varchar(200),
+  PRIMARY KEY (user_id,ref_email)
+)engine=innodb;
+
+INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@xxxxxxxxxxx','xxx'),(10292,'shirish','2333604','shirish@xxxxxxxxx','ddsds'),(10292,'sonali','323232','sonali@xxxxxxxxx','filmstar');
+select * from t1 where user_id=10292;
+INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@xxxxxxxxxxx','xxx'),(10293,'shirish','2333604','shirish@xxxxxxxxx','ddsds');
+select * from t1 where user_id=10292;
+select * from t1 where user_id>=10292;
+select * from t1 where user_id>10292;
+select * from t1 where user_id<10292;
+drop table t1;
+
+#
+# Test that keys are created in right order
+#
+
+CREATE TABLE t1 (a int not null, b int not null,c int not null,
+key(a),primary key(a,b), unique(c),key(a),unique(b));
+--replace_column 7 #
+show index from t1;
+drop table t1;
+
+#
+# Test of ALTER TABLE and innodb tables
+#
+
+create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
+alter table t1 engine=innodb;
+insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
+select * from t1;
+update t1 set col2='7' where col1='4';
+select * from t1;
+alter table t1 add co3 int not null;
+select * from t1;
+update t1 set col2='9' where col1='2';
+select * from t1;
+drop table t1;
+
+#
+# INSERT INTO innodb tables
+#
+
+create table t1 (a int not null , b int, primary key (a)) engine = innodb;
+create table t2 (a int not null , b int, primary key (a)) engine = myisam;
+insert into t1 VALUES (1,3) , (2,3), (3,3);
+select * from t1;
+insert into t2 select * from t1;
+select * from t2;
+delete from t1 where b = 3;
+select * from t1;
+insert into t1 select * from t2;
+select * from t1;
+select * from t2;
+drop table t1,t2;
+
+#
+# ORDER BY on not primary key
+#
+
+CREATE TABLE t1 (
+  user_name varchar(12),
+  password text,
+  subscribed char(1),
+  user_id int(11) DEFAULT '0' NOT NULL,
+  quota bigint(20),
+  weight double,
+  access_date date,
+  access_time time,
+  approved datetime,
+  dummy_primary_key int(11) NOT NULL auto_increment,
+  PRIMARY KEY (dummy_primary_key)
+) ENGINE=innodb;
+INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
+INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
+INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
+INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
+INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
+select  user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
+drop table t1;
+
+#
+# Testing of tables without primary keys
+#
+
+CREATE TABLE t1 (
+  id int(11) NOT NULL auto_increment,
+  parent_id int(11) DEFAULT '0' NOT NULL,
+  level tinyint(4) DEFAULT '0' NOT NULL,
+  KEY (id),
+  KEY parent_id (parent_id),
+  KEY level (level)
+) engine=innodb;
+INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
+INSERT INTO t1 values (179,5,2);
+update t1 set parent_id=parent_id+100;
+select * from t1 where parent_id=102;
+update t1 set id=id+1000;
+update t1 set id=1024 where id=1009; 
+select * from t1;
+update ignore t1 set id=id+1; # This will change all rows
+select * from t1;
+update ignore t1 set id=1023 where id=1010;
+select * from t1 where parent_id=102;
+--replace_column 9 #
+explain select level from t1 where level=1;
+select level,id from t1 where level=1;
+select level,id,parent_id from t1 where level=1;
+select level,id from t1 where level=1 order by id;
+delete from t1 where level=1;
+select * from t1;
+drop table t1;
+
+#
+# Test of index only reads
+#
+CREATE TABLE t1 (
+   sca_code char(6) NOT NULL,
+   cat_code char(6) NOT NULL,
+   sca_desc varchar(50),
+   lan_code char(2) NOT NULL,
+   sca_pic varchar(100),
+   sca_sdesc varchar(50),
+   sca_sch_desc varchar(16),
+   PRIMARY KEY (sca_code, cat_code, lan_code),
+   INDEX sca_pic (sca_pic)
+) engine = innodb ;
+
+INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
+select count(*) from t1 where sca_code = 'PD';
+select count(*) from t1 where sca_code <= 'PD';
+select count(*) from t1 where sca_pic is null;
+alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
+select count(*) from t1 where sca_code='PD' and sca_pic is null;
+select count(*) from t1 where cat_code='E';
+
+alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
+select count(*) from t1 where sca_code='PD' and sca_pic is null;
+select count(*) from t1 where sca_pic >= 'n';
+select sca_pic from t1 where sca_pic is null;
+update t1 set sca_pic="test" where sca_pic is null;
+delete from t1 where sca_code='pd';
+drop table t1;
+
+#
+# Test of opening table twice and timestamps
+#
+set @a:=now();
+CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
+insert into t1 (a) values(1),(2),(3);
+select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
+select a from t1 natural join t1 as t2 where b >= @a order by a;
+update t1 set a=5 where a=1;
+select a from t1;
+drop table t1;
+
+#
+# Test with variable length primary key
+#
+create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb;
+insert into t1 values("hello",1),("world",2);
+select * from t1 order by b desc;
+optimize table t1;
+--replace_column 7 #
+show keys from t1;
+drop table t1;
+
+#
+# Test of create index with NULL columns
+#
+create table t1 (i int, j int ) ENGINE=innodb;
+insert into t1 values (1,2);
+select * from t1 where i=1 and j=2;
+create index ax1 on t1 (i,j);
+select * from t1 where i=1 and j=2;
+drop table t1;
+
+#
+# Test min-max optimization
+#
+
+CREATE TABLE t1 (
+  a int3 unsigned NOT NULL,
+  b int1 unsigned NOT NULL,
+  UNIQUE (a, b)
+) ENGINE = innodb;
+ 
+INSERT INTO t1 VALUES (1, 1);
+SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
+drop table t1;
+
+#
+# Test INSERT DELAYED
+#
+
+CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb;
+# Can't test this in 3.23
+# INSERT DELAYED INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+#
+# Crash when using many tables (Test case by Jeremy D Zawodny)
+#
+
+create table t1 (a int  primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb;
+insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
+--replace_column 9 #
+explain select * from t1 where a > 0 and a < 50;
+drop table t1;
+
+#
+# Test lock tables
+#
+
+create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
+insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
+LOCK TABLES t1 WRITE;
+--error ER_DUP_ENTRY
+insert into t1 values (99,1,2,'D'),(1,1,2,'D');
+select id from t1;
+select id from t1;
+UNLOCK TABLES;
+DROP TABLE t1;
+
+create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
+insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
+LOCK TABLES t1 WRITE;
+begin;
+--error ER_DUP_ENTRY
+insert into t1 values (99,1,2,'D'),(1,1,2,'D');
+select id from t1;
+insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
+commit;
+select id,id3 from t1;
+UNLOCK TABLES;
+DROP TABLE t1;
+
+#
+# Test prefix key
+#
+create table t1 (a char(20), unique (a(5))) engine=innodb;
+drop table t1;
+create table t1 (a char(20), index (a(5))) engine=innodb;
+show create table t1;
+drop table t1;
+
+#
+# Test using temporary table and auto_increment
+#
+
+create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;
+insert into t1 values (NULL),(NULL),(NULL);
+delete from t1 where a=3;
+insert into t1 values (NULL);
+select * from t1;
+alter table t1 add b int;
+select * from t1;
+drop table t1;
+
+#Slashdot bug
+create table t1
+ (
+  id int auto_increment primary key,
+  name varchar(32) not null,
+  value text not null,
+  uid int not null,
+  unique key(name,uid)
+ ) engine=innodb;
+insert into t1 values (1,'one','one value',101),
+ (2,'two','two value',102),(3,'three','three value',103);
+set insert_id=5;
+replace into t1 (value,name,uid) values ('other value','two',102);
+delete from t1 where uid=102;
+set insert_id=5;
+replace into t1 (value,name,uid) values ('other value','two',102);
+set insert_id=6;
+replace into t1 (value,name,uid) values ('other value','two',102);
+select * from t1;
+drop table t1;
+
+#
+# Test DROP DATABASE
+#
+
+create database mysqltest;
+create table mysqltest.t1 (a int not null) engine= innodb;
+insert into mysqltest.t1 values(1);
+create table mysqltest.t2 (a int not null) engine= myisam;
+insert into mysqltest.t2 values(1);
+create table mysqltest.t3 (a int not null) engine= heap;
+insert into mysqltest.t3 values(1);
+commit;
+drop database mysqltest;
+# Don't check error message
+--error 1049
+show tables from mysqltest;
+
+#
+# Test truncate table with and without auto_commit
+#
+
+set autocommit=0;
+create table t1 (a int not null) engine= innodb;
+insert into t1 values(1),(2);
+truncate table t1;
+commit;
+truncate table t1;
+truncate table t1;
+select * from t1;
+insert into t1 values(1),(2);
+delete from t1;
+select * from t1;
+commit;
+drop table t1;
+set autocommit=1;
+
+create table t1 (a int not null) engine= innodb;
+insert into t1 values(1),(2);
+truncate table t1;
+insert into t1 values(1),(2);
+select * from t1;
+truncate table t1;
+insert into t1 values(1),(2);
+delete from t1;
+select * from t1;
+drop table t1;
+
+#
+# Test of how ORDER BY works when doing it on the whole table
+#
+
+create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb;
+insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
+--replace_column 9 #
+explain select * from t1 order by a;
+--replace_column 9 #
+explain select * from t1 order by b;
+--replace_column 9 #
+explain select * from t1 order by c;
+--replace_column 9 #
+explain select a from t1 order by a;
+--replace_column 9 #
+explain select b from t1 order by b;
+--replace_column 9 #
+explain select a,b from t1 order by b;
+--replace_column 9 #
+explain select a,b from t1;
+--replace_column 9 #
+explain select a,b,c from t1;
+drop table t1;
+
+#
+# Check describe
+#
+
+create table t1 (t int not null default 1, key (t)) engine=innodb;
+desc t1;
+drop table t1;
+
+#
+# Test of multi-table-delete
+#
+
+CREATE TABLE t1 (
+  number bigint(20) NOT NULL default '0',
+  cname char(15) NOT NULL default '',
+  carrier_id smallint(6) NOT NULL default '0',
+  privacy tinyint(4) NOT NULL default '0',
+  last_mod_date timestamp NOT NULL,
+  last_mod_id smallint(6) NOT NULL default '0',
+  last_app_date timestamp NOT NULL,
+  last_app_id smallint(6) default '-1',
+  version smallint(6) NOT NULL default '0',
+  assigned_scps int(11) default '0',
+  status tinyint(4) default '0'
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
+INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
+INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
+INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
+INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
+INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
+CREATE TABLE t2 (
+  number bigint(20) NOT NULL default '0',
+  cname char(15) NOT NULL default '',
+  carrier_id smallint(6) NOT NULL default '0',
+  privacy tinyint(4) NOT NULL default '0',
+  last_mod_date timestamp NOT NULL,
+  last_mod_id smallint(6) NOT NULL default '0',
+  last_app_date timestamp NOT NULL,
+  last_app_id smallint(6) default '-1',
+  version smallint(6) NOT NULL default '0',
+  assigned_scps int(11) default '0',
+  status tinyint(4) default '0'
+) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
+INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
+INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
+INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
+select * from t1;
+select * from t2;
+delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);
+select * from t1;
+select * from t2; 
+select * from t2;
+drop table t1,t2;
+
+#
+# A simple test with some isolation levels
+# TODO: Make this into a test using replication to really test how
+# this works.
+#
+
+create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+SELECT @@tx_isolation,@@global.tx_isolation;
+insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
+select id, code, name from t1 order by id;
+COMMIT;
+
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
+select id, code, name from t1 order by id;
+COMMIT;
+
+SET binlog_format='MIXED';
+BEGIN;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
+select id, code, name from t1 order by id;
+COMMIT;
+DROP TABLE t1;
+
+#
+# Test of multi-table-update
+#
+create table t1 (n int(10), d int(10)) engine=innodb;
+create table t2 (n int(10), d int(10)) engine=innodb;
+insert into t1 values(1,1),(1,2);
+insert into t2 values(1,10),(2,20);
+UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
+select * from t1;
+select * from t2;
+drop table t1,t2;
+
+#
+# Bug #29136  	erred multi-delete on trans table does not rollback 
+#
+
+# prepare
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+CREATE TABLE t1 (a int, PRIMARY KEY (a));
+CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
+create trigger trg_del_t2 after  delete on t2 for each row
+       insert into t1 values (1);
+insert into t1 values (1);
+insert into t2 values (1),(2);
+
+
+# exec cases A, B - see multi_update.test
+
+# A. send_error() w/o send_eof() branch
+
+--error ER_DUP_ENTRY
+delete t2 from t2;
+
+# check
+
+select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
+
+# cleanup bug#29136
+
+drop table t1, t2;
+
+
+#
+# Bug #29136  	erred multi-delete on trans table does not rollback 
+#
+
+# prepare
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+CREATE TABLE t1 (a int, PRIMARY KEY (a));
+CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
+create trigger trg_del_t2 after  delete on t2 for each row
+       insert into t1 values (1);
+insert into t1 values (1);
+insert into t2 values (1),(2);
+
+
+# exec cases A, B - see multi_update.test
+
+# A. send_error() w/o send_eof() branch
+
+--error ER_DUP_ENTRY
+delete t2 from t2;
+
+# check
+
+select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
+
+# cleanup bug#29136
+
+drop table t1, t2;
+
+
+#
+# Testing of IFNULL
+#
+create table t1 (a int, b int) engine=innodb;
+insert into t1 values(20,null);
+select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
+t2.b=t3.a;
+select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
+t2.b=t3.a order by 1;
+insert into t1 values(10,null);
+select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
+t2.b=t3.a order by 1;
+drop table t1;
+
+#
+# Test of read_through not existing const_table
+#
+
+create table t1 (a varchar(10) not null) engine=myisam;
+create table t2 (b varchar(10) not null unique) engine=innodb;
+select t1.a from t1,t2 where t1.a=t2.b;
+drop table t1,t2;
+create table t1 (a int not null, b int, primary key (a)) engine = innodb;
+create table t2 (a int not null, b int, primary key (a)) engine = innodb;
+insert into t1 values (10, 20);
+insert into t2 values (10, 20);
+update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
+drop table t1,t2;
+
+#
+# Test of multi-table-delete with foreign key constraints
+#
+
+CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
+CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id)  ON DELETE CASCADE ) ENGINE=INNODB;
+insert into t1 set id=1;
+insert into t2 set id=1, t1_id=1;
+delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
+select * from t1;
+select * from t2;
+drop table t2,t1;
+CREATE TABLE t1(id INT NOT NULL,  PRIMARY KEY (id)) ENGINE=INNODB;
+CREATE TABLE t2(id  INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id)  ) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2 VALUES(1, 1);
+SELECT * from t1;
+UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
+SELECT * from t1;
+UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
+SELECT * from t1;
+DROP TABLE t1,t2;
+
+#
+# Test of range_optimizer
+#
+
+set autocommit=0;
+
+CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
+
+CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
+
+CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB;
+
+INSERT INTO t3 VALUES("my-test-1", "my-test-2");
+COMMIT;
+
+INSERT INTO t1 VALUES("this-key", "will disappear");
+INSERT INTO t2 VALUES("this-key", "will also disappear");
+DELETE FROM t3 WHERE id1="my-test-1";
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+ROLLBACK;
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE;
+COMMIT;
+set autocommit=1;
+DROP TABLE t1,t2,t3;
+
+#
+# Check update with conflicting key
+#
+
+CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb;
+INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
+# We need the a < 1000 test here to quard against the halloween problems
+UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
+SELECT * from t1;
+drop table t1;
+
+#
+# Test multi update with different join methods
+#
+
+CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb;
+CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb;
+INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
+INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
+
+# Full join, without key
+update t1,t2 set t1.a=t1.a+100;
+select * from t1;
+
+# unique key
+update t1,t2 set t1.a=t1.a+100 where t1.a=101;
+select * from t1;
+
+# ref key
+update t1,t2 set t1.b=t1.b+10 where t1.b=2;
+select * from t1;
+
+# Range key (in t1)
+update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
+select * from t1;
+select * from t2;
+
+drop table t1,t2;
+CREATE TABLE t2 (   NEXT_T         BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
+CREATE TABLE t1 (  B_ID           INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
+SET AUTOCOMMIT=0;
+INSERT INTO t1 ( B_ID ) VALUES ( 1 );
+INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
+ROLLBACK;
+SELECT * FROM t1;
+drop table  t1,t2;
+create table t1  ( pk         int primary key,    parent     int not null,    child      int not null,       index (parent)  ) engine = innodb;
+insert into t1 values   (1,0,4),  (2,1,3),  (3,2,1),  (4,1,2);
+select distinct  parent,child   from t1   order by parent;
+drop table t1;
+
+#
+# Test that MySQL priorities clustered indexes
+#
+create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
+create table t2 (a int not null auto_increment primary key, b int);
+insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
+insert into t2 (a) select b from t1;
+insert into t1 (b) select b from t2;
+insert into t2 (a) select b from t1;
+insert into t1 (a) select b from t2;
+insert into t2 (a) select b from t1;
+insert into t1 (a) select b from t2;
+insert into t2 (a) select b from t1;
+insert into t1 (a) select b from t2;
+insert into t2 (a) select b from t1;
+insert into t1 (a) select b from t2;
+select count(*) from t1;
+--replace_column 9 #
+explain select * from t1 where c between 1 and 2500;
+update t1 set c=a;
+--replace_column 9 #
+explain select * from t1 where c between 1 and 2500;
+drop table t1,t2;
+
+#
+# Test of UPDATE ... ORDER BY
+#
+
+create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb;
+
+insert into t1 (id) values (null),(null),(null),(null),(null);
+update t1 set fk=69 where fk is null order by id limit 1;
+SELECT * from t1;
+drop table t1;
+
+create table t1 (a int not null, b int not null, key (a));
+insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
+SET @tmp=0;
+update t1 set b=(@tmp:=@tmp+1) order by a;
+update t1 set b=99 where a=1 order by b asc limit 1;
+update t1 set b=100 where a=1 order by b desc limit 2;
+update t1 set a=a+10+b where a=1 order by b;
+select * from t1 order by a,b;
+drop table t1;
+
+#
+# Test of multi-table-updates (bug #1980).
+#
+
+create table t1 ( c char(8) not null ) engine=innodb;
+insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
+insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
+
+alter table t1 add b char(8) not null;
+alter table t1 add a char(8) not null;
+alter table t1 add primary key (a,b,c);
+update t1 set a=c, b=c;
+
+create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
+insert into t2 select * from t1;
+
+delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
+drop table t1,t2;
+
+#
+# test autoincrement with TRUNCATE
+#
+
+SET AUTOCOMMIT=1;
+create table t1 (a integer auto_increment primary key) engine=innodb;
+insert into t1 (a) values (NULL),(NULL);
+truncate table t1;
+insert into t1 (a) values (NULL),(NULL);
+SELECT * from t1;
+drop table t1;
+
+#
+# Test dictionary handling with spaceand quoting
+#
+
+CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB;
+CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`)  ON DELETE CASCADE ) ENGINE=INNODB;
+#show create table t2;
+drop table t2,t1;
+
+#
+# Test of multi updated and foreign keys
+#
+
+create table `t1` (`id` int( 11 ) not null  ,primary key ( `id` )) engine = innodb;
+insert into `t1`values ( 1 ) ;
+create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
+insert into `t2`values ( 1 ) ;
+create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
+insert into `t3`values ( 1 ) ;
+--error 1451
+delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
+--error 1451
+update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
+--error 1054
+update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
+drop table t3,t2,t1;
+
+#
+# test for recursion depth limit
+#
+create table t1(
+	id int primary key,
+	pid int,
+	index(pid),
+	foreign key(pid) references t1(id) on delete cascade) engine=innodb;
+insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
+	(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
+-- error 1451
+delete from t1 where id=0;
+delete from t1 where id=15;
+delete from t1 where id=0;
+
+drop table t1;
+
+#
+# Test timestamps
+#
+
+CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
+CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
+(stamp))ENGINE=InnoDB;
+insert into t1 values (1),(2),(3);
+# Note that timestamp 3 is wrong
+insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
+'20020204120000' GROUP BY col1;
+drop table t1,t2;
+
+#
+# Test by Francois MASUREL
+#
+
+CREATE TABLE t1 (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `id_object` int(10) unsigned default '0',
+  `id_version` int(10) unsigned NOT NULL default '1',
+  `label` varchar(100) NOT NULL default '',
+  `description` text,
+  PRIMARY KEY  (`id`),
+  KEY `id_object` (`id_object`),
+  KEY `id_version` (`id_version`)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
+
+CREATE TABLE t2 (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `id_version` int(10) unsigned NOT NULL default '1',
+  PRIMARY KEY  (`id`),
+  KEY `id_version` (`id_version`)
+) ENGINE=InnoDB;
+
+INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
+
+SELECT t2.id, t1.`label` FROM t2 INNER JOIN
+(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl 
+ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
+drop table t1,t2;
+
+create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
+create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
+create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
+insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
+insert t2 select * from t1;
+insert t3 select * from t1;
+checksum table t1, t2, t3, t4 quick;
+checksum table t1, t2, t3, t4;
+checksum table t1, t2, t3, t4 extended;
+#show table status;
+drop table t1,t2,t3;
+
+#
+# Test problem with refering to different fields in same table in UNION
+# (Bug #2552)
+#
+create table t1 (id int,  name char(10) not null,  name2 char(10) not null) engine=innodb;
+insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
+select trim(name2) from t1  union all  select trim(name) from t1 union all select trim(id) from t1;
+drop table t1;
+
+#
+# Bug2160
+#
+create table t1 (a int) engine=innodb;
+create table t2 like t1;
+drop table t1,t2;
+
+#
+# Test of automaticly created foreign keys
+#
+
+create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb;
+create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb;
+show create table t1;
+show create table t2;
+create index id on t2 (id);
+show create table t2;
+create index id2 on t2 (id);
+show create table t2;
+drop index id2 on t2;
+--error ER_DROP_INDEX_FK
+drop index id on t2;
+show create table t2;
+drop table t2;
+
+create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
+show create table t2;
+create unique index id on t2 (id,id2);
+show create table t2;
+drop table t2;
+
+# Check foreign key columns created in different order than key columns
+create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
+show create table t2;
+drop table t2;
+
+create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
+show create table t2;
+drop table t2;
+
+create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
+show create table t2;
+drop table t2;
+
+create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
+show create table t2;
+drop table t2;
+
+create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
+show create table t2;
+alter table t2 add index id_test (id), add index id_test2 (id,id2);
+show create table t2;
+drop table t2;
+
+# Test error handling
+
+# Embedded server doesn't chdir to data directory
+--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
+--error ER_WRONG_FK_DEF
+create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
+
+# bug#3749
+
+create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
+show create table t2;
+drop table t2;
+create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb;
+show create table t2;
+drop table t2, t1;
+
+
+#
+# Bug #6126: Duplicate columns in keys gives misleading error message
+#
+--error 1060
+create table t1 (c char(10), index (c,c)) engine=innodb;
+--error 1060
+create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
+--error 1060
+create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
+--error 1060
+create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
+create table t1 (c1 char(10), c2 char(10)) engine=innodb;
+--error 1060
+alter table t1 add key (c1,c1);
+--error 1060
+alter table t1 add key (c2,c1,c1);
+--error 1060
+alter table t1 add key (c1,c2,c1);
+--error 1060
+alter table t1 add key (c1,c1,c2);
+drop table t1;
+
+#
+# Bug #4082: integer truncation
+#
+
+create table t1(a int(1) , b int(1)) engine=innodb;
+insert into t1 values ('1111', '3333');
+select distinct concat(a, b) from t1;
+drop table t1;
+
+#
+# BUG#7709 test case - Boolean fulltext query against unsupported 
+#                      engines does not fail
+#
+
+CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
+--error 1214
+SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
+DROP TABLE t1;
+
+#
+# check null values #1
+#
+
+--disable_warnings
+CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY  (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES (1),(2),(3);
+CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY  (b_id), KEY  (b_a), 
+                CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+--enable_warnings
+INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
+SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
+DROP TABLE t2;
+DROP TABLE t1;
+
+#
+# Bug#11816 - Truncate table doesn't work with temporary innodb tables
+# This is not an innodb bug, but we test it using innodb.
+#
+create temporary table t1 (a int) engine=innodb;
+insert into t1 values (4711);
+truncate t1;
+insert into t1 values (42);
+select * from t1;
+drop table t1;
+# Show that it works with permanent tables too.
+create table t1 (a int) engine=innodb;
+insert into t1 values (4711);
+truncate t1;
+insert into t1 values (42);
+select * from t1;
+drop table t1;
+
+#
+# Bug #13025  Server crash during filesort	
+#
+
+create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb;
+insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
+select * from t1 order by a,b,c,d;
+explain select * from t1 order by a,b,c,d;
+drop table t1;
+
+#
+# BUG#11039,#13218 Wrong key length in min()
+#
+
+create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
+insert into t1 values ('8', '6'), ('4', '7');
+select min(a) from t1;
+select min(b) from t1 where a='8';
+drop table t1;
+
+# End of 4.1 tests
+
+#
+# range optimizer problem
+#
+
+create table t1 (x bigint unsigned not null primary key) engine=innodb;
+insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
+select * from t1;
+select count(*) from t1 where x>0;
+select count(*) from t1 where x=0;
+select count(*) from t1 where x<0;
+select count(*) from t1 where x < -16;
+select count(*) from t1 where x = -16;
+explain select count(*) from t1 where x > -16;
+select count(*) from t1 where x > -16;
+select * from t1 where x > -16;
+select count(*) from t1 where x = 18446744073709551601;
+drop table t1;
+
+
+# Test for testable InnoDB status variables. This test
+# uses previous ones(pages_created, rows_deleted, ...).
+--replace_result 512 511
+show status like "Innodb_buffer_pool_pages_total";
+show status like "Innodb_page_size";
+show status like "Innodb_rows_deleted";
+show status like "Innodb_rows_inserted";
+show status like "Innodb_rows_updated";
+
+# Test for row locks InnoDB status variables.
+show status like "Innodb_row_lock_waits";
+show status like "Innodb_row_lock_current_waits";
+show status like "Innodb_row_lock_time";
+show status like "Innodb_row_lock_time_max";
+show status like "Innodb_row_lock_time_avg";
+
+# Test for innodb_sync_spin_loops variable
+show variables like "innodb_sync_spin_loops";
+set global innodb_sync_spin_loops=1000;
+show variables like "innodb_sync_spin_loops";
+set global innodb_sync_spin_loops=0;
+show variables like "innodb_sync_spin_loops";
+set global innodb_sync_spin_loops=20;
+show variables like "innodb_sync_spin_loops";
+
+# Test for innodb_thread_concurrency variable
+SET @old_innodb_thread_concurrency= @@global.innodb_thread_concurrency;
+show variables like "innodb_thread_concurrency";
+set global innodb_thread_concurrency=1001;
+show variables like "innodb_thread_concurrency";
+set global innodb_thread_concurrency=0;
+show variables like "innodb_thread_concurrency";
+set global innodb_thread_concurrency=16;
+show variables like "innodb_thread_concurrency";
+SET @@global.innodb_thread_concurrency= @old_innodb_thread_concurrency;
+
+# Test for innodb_concurrency_tickets variable
+show variables like "innodb_concurrency_tickets";
+set global innodb_concurrency_tickets=1000;
+show variables like "innodb_concurrency_tickets";
+set global innodb_concurrency_tickets=0;
+show variables like "innodb_concurrency_tickets";
+set global innodb_concurrency_tickets=500;
+show variables like "innodb_concurrency_tickets";
+
+# Test for innodb_thread_sleep_delay variable
+show variables like "innodb_thread_sleep_delay";
+set global innodb_thread_sleep_delay=100000;
+show variables like "innodb_thread_sleep_delay";
+set global innodb_thread_sleep_delay=0;
+show variables like "innodb_thread_sleep_delay";
+set global innodb_thread_sleep_delay=10000;
+show variables like "innodb_thread_sleep_delay";
+
+#
+# Test varchar
+#
+
+let $default=`select @@storage_engine`;
+set storage_engine=INNODB;
+source include/varchar.inc;
+
+#
+# Some errors/warnings on create
+#
+
+# Embedded server doesn't chdir to data directory
+--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
+create table t1 (v varchar(65530), key(v));
+drop table t1;
+create table t1 (v varchar(65536));
+show create table t1;
+drop table t1;
+create table t1 (v varchar(65530) character set utf8);
+show create table t1;
+drop table t1;
+
+eval set storage_engine=$default;
+
+# InnoDB specific varchar tests
+create table t1 (v varchar(16384)) engine=innodb;
+drop table t1;
+
+#
+# BUG#11039 Wrong key length in min()
+#
+
+create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
+insert into t1 values ('8', '6'), ('4', '7');
+select min(a) from t1;
+select min(b) from t1 where a='8';
+drop table t1;
+
+#
+# Bug #11080 & #11005  Multi-row REPLACE fails on a duplicate key error
+#
+
+CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
+insert into t1 (b) values (1);
+replace into t1 (b) values (2), (1), (3);
+select * from t1;
+truncate table t1;
+insert into t1 (b) values (1);
+replace into t1 (b) values (2);
+replace into t1 (b) values (1);
+replace into t1 (b) values (3);
+select * from t1;
+drop table t1;
+
+create table t1 (rowid int not null auto_increment, val int not null,primary
+key (rowid), unique(val)) engine=innodb;
+replace into t1 (val) values ('1'),('2');
+replace into t1 (val) values ('1'),('2');
+--error ER_DUP_ENTRY
+insert into t1 (val) values ('1'),('2');
+select * from t1;
+drop table t1;
+
+#
+# Test that update does not change internal auto-increment value
+#
+
+create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
+insert into t1 (val) values (1);
+update t1 set a=2 where a=1;
+# We should get the following error because InnoDB does not update the counter
+--error ER_DUP_ENTRY
+insert into t1 (val) values (1);
+select * from t1;
+drop table t1;
+#
+# Bug #10465
+#
+
+--disable_warnings
+CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
+--enable_warnings
+INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
+SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
+SELECT GRADE  FROM t1 WHERE GRADE= 151;
+DROP TABLE t1;
+
+#
+# Bug #12340 multitable delete deletes only one record
+#
+create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
+create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
+insert into t2 values ('aa','cc');
+insert into t1 values ('aa','bb'),('aa','cc');
+delete t1 from t1,t2 where f1=f3 and f4='cc';
+select * from t1;
+drop table t1,t2;
+
+#
+# Test that the slow TRUNCATE implementation resets autoincrement columns
+# (bug #11946)
+#
+
+CREATE TABLE t1 (
+id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
+) ENGINE=InnoDB;
+
+CREATE TABLE t2 (
+id INTEGER NOT NULL,
+FOREIGN KEY (id) REFERENCES t1 (id)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 (id) VALUES (NULL);
+SELECT * FROM t1;
+TRUNCATE t1;
+INSERT INTO t1 (id) VALUES (NULL);
+SELECT * FROM t1;
+
+# continued from above; test that doing a slow TRUNCATE on a table with 0
+# rows resets autoincrement columns
+DELETE FROM t1;
+TRUNCATE t1;
+INSERT INTO t1 (id) VALUES (NULL);
+SELECT * FROM t1;
+DROP TABLE t2, t1;
+
+# Test that foreign keys in temporary tables are not accepted (bug #12084)
+CREATE TABLE t1
+(
+ id INT PRIMARY KEY
+) ENGINE=InnoDB;
+
+--error 1005,1005
+CREATE TEMPORARY TABLE t2
+(
+ id INT NOT NULL PRIMARY KEY,
+ b INT,
+ FOREIGN KEY (b) REFERENCES test.t1(id)
+) ENGINE=InnoDB;
+DROP TABLE t1;
+
+#
+# Test that index column max sizes are honored (bug #13315)
+#
+
+# prefix index
+create table t1 (col1 varchar(2000), index (col1(767)))
+ character set = latin1 engine = innodb;
+
+# normal indexes
+create table t2 (col1 char(255), index (col1))
+ character set = latin1 engine = innodb;
+create table t3 (col1 binary(255), index (col1))
+ character set = latin1 engine = innodb;
+create table t4 (col1 varchar(767), index (col1))
+ character set = latin1 engine = innodb;
+create table t5 (col1 varchar(767) primary key)
+ character set = latin1 engine = innodb;
+create table t6 (col1 varbinary(767) primary key)
+ character set = latin1 engine = innodb;
+create table t7 (col1 text, index(col1(767)))
+ character set = latin1 engine = innodb;
+create table t8 (col1 blob, index(col1(767)))
+ character set = latin1 engine = innodb;
+
+# multi-column indexes are allowed to be longer
+create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
+ character set = latin1 engine = innodb;
+
+show create table t9;
+
+drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
+
+# these should have their index length trimmed
+create table t1 (col1 varchar(768), index(col1))
+ character set = latin1 engine = innodb;
+create table t2 (col1 varbinary(768), index(col1))
+ character set = latin1 engine = innodb;
+create table t3 (col1 text, index(col1(768)))
+ character set = latin1 engine = innodb;
+create table t4 (col1 blob, index(col1(768)))
+ character set = latin1 engine = innodb;
+
+show create table t1;
+
+drop table t1, t2, t3, t4;
+
+# these should be refused
+--error 1071
+create table t1 (col1 varchar(768) primary key)
+ character set = latin1 engine = innodb;
+--error 1071
+create table t2 (col1 varbinary(768) primary key)
+ character set = latin1 engine = innodb;
+--error 1071
+create table t3 (col1 text, primary key(col1(768)))
+ character set = latin1 engine = innodb;
+--error 1071
+create table t4 (col1 blob, primary key(col1(768)))
+ character set = latin1 engine = innodb;
+
+#
+# Test improved foreign key error messages (bug #3443)
+#
+
+CREATE TABLE t1
+(
+ id INT PRIMARY KEY
+) ENGINE=InnoDB;
+
+CREATE TABLE t2
+(
+ v INT,
+ CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
+) ENGINE=InnoDB;
+
+--error 1452
+INSERT INTO t2 VALUES(2);
+
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2 VALUES(1);
+
+--error 1451
+DELETE FROM t1 WHERE id = 1;
+
+--error 1217
+DROP TABLE t1;
+
+SET FOREIGN_KEY_CHECKS=0;
+DROP TABLE t1;
+SET FOREIGN_KEY_CHECKS=1;
+
+--error 1452
+INSERT INTO t2 VALUES(3);
+
+DROP TABLE t2;
+#
+# Test that checksum table uses a consistent read Bug #12669
+#
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2);
+set autocommit=0;
+checksum table t1;
+connection b;
+insert into t1 values(3);
+connection a;
+#
+# Here checksum should not see insert
+#
+checksum table t1;
+connection a;
+commit;
+checksum table t1;
+commit;
+drop table t1;
+#
+# autocommit = 1
+#
+connection a;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2);
+set autocommit=1;
+checksum table t1;
+connection b;
+set autocommit=1;
+insert into t1 values(3);
+connection a;
+#
+# Here checksum sees insert
+#
+checksum table t1;
+drop table t1;
+
+connection default;
+disconnect a;
+disconnect b;
+
+# tests for bugs #9802 and #13778
+
+# test that FKs between invalid types are not accepted
+
+set foreign_key_checks=0;
+create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
+# Embedded server doesn't chdir to data directory
+--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
+-- error 1005
+create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
+set foreign_key_checks=1;
+drop table t2;
+
+# test that FKs between different charsets are not accepted in CREATE even
+# when f_k_c is 0
+
+set foreign_key_checks=0;
+create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
+# Embedded server doesn't chdir to data directory
+--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
+-- error 1005
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
+set foreign_key_checks=1;
+drop table t1;
+
+# test that invalid datatype conversions with ALTER are not allowed
+
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
+create table t1(a varchar(10) primary key) engine = innodb;
+-- error 1025,1025
+alter table t1 modify column a int;
+set foreign_key_checks=1;
+drop table t2,t1;
+
+# test that charset conversions with ALTER are allowed when f_k_c is 0
+
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
+create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
+alter table t1 convert to character set utf8;
+set foreign_key_checks=1;
+drop table t2,t1;
+
+# test that RENAME does not allow invalid charsets when f_k_c is 0
+
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
+create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
+# Embedded server doesn't chdir to data directory
+--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
+-- error 1025
+rename table t3 to t1;
+set foreign_key_checks=1;
+drop table t2,t3;
+
+# test that foreign key errors are reported correctly (Bug #15550)
+
+create table t1(a int primary key) row_format=redundant engine=innodb;
+create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
+create table t3(a int primary key) row_format=compact engine=innodb;
+create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
+
+insert into t1 values(1);
+insert into t3 values(1);
+-- error 1452
+insert into t2 values(2);
+-- error 1452
+insert into t4 values(2);
+insert into t2 values(1);
+insert into t4 values(1);
+-- error 1451
+update t1 set a=2;
+-- error 1452
+update t2 set a=2;
+-- error 1451
+update t3 set a=2;
+-- error 1452
+update t4 set a=2;
+-- error 1451
+truncate t1;
+-- error 1451
+truncate t3;
+truncate t2;
+truncate t4;
+truncate t1;
+truncate t3;
+
+drop table t4,t3,t2,t1;
+
+
+#
+# Test that we can create a large (>1K) key
+#
+create table t1 (a varchar(255) character set utf8,
+                 b varchar(255) character set utf8,
+                 c varchar(255) character set utf8,
+                 d varchar(255) character set utf8,
+                 key (a,b,c,d)) engine=innodb;
+drop table t1;
+--error ER_TOO_LONG_KEY
+create table t1 (a varchar(255) character set utf8,
+                 b varchar(255) character set utf8,
+                 c varchar(255) character set utf8,
+                 d varchar(255) character set utf8,
+                 e varchar(255) character set utf8,
+                 key (a,b,c,d,e)) engine=innodb;
+
+
+# test the padding of BINARY types and collations (Bug #14189)
+
+create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
+create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
+create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
+create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
+
+insert into t1 values (0x41),(0x4120),(0x4100);
+-- error ER_DUP_ENTRY
+insert into t2 values (0x41),(0x4120),(0x4100);
+insert into t2 values (0x41),(0x4120);
+-- error ER_DUP_ENTRY
+insert into t3 values (0x41),(0x4120),(0x4100);
+insert into t3 values (0x41),(0x4100);
+-- error ER_DUP_ENTRY
+insert into t4 values (0x41),(0x4120),(0x4100);
+insert into t4 values (0x41),(0x4100);
+select hex(s1) from t1;
+select hex(s1) from t2;
+select hex(s1) from t3;
+select hex(s1) from t4;
+drop table t1,t2,t3,t4;
+
+create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
+create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
+
+insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
+-- error 1452
+insert into t2 values(0x42);
+insert into t2 values(0x41);
+select hex(s1) from t2;
+update t1 set s1=0x123456 where a=2;
+select hex(s1) from t2;
+-- error 1451
+update t1 set s1=0x12 where a=1;
+-- error 1451
+update t1 set s1=0x12345678 where a=1;
+-- error 1451
+update t1 set s1=0x123457 where a=1;
+update t1 set s1=0x1220 where a=1;
+select hex(s1) from t2;
+update t1 set s1=0x1200 where a=1;
+select hex(s1) from t2;
+update t1 set s1=0x4200 where a=1;
+select hex(s1) from t2;
+-- error 1451
+delete from t1 where a=1;
+delete from t1 where a=2;
+update t2 set s1=0x4120;
+-- error 1451
+delete from t1;
+delete from t1 where a!=3;
+select a,hex(s1) from t1;
+select hex(s1) from t2;
+
+drop table t2,t1;
+
+create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
+create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
+
+insert into t1 values(1,0x4100),(2,0x41);
+insert into t2 values(0x41);
+select hex(s1) from t2;
+update t1 set s1=0x1234 where a=1;
+select hex(s1) from t2;
+update t1 set s1=0x12 where a=2;
+select hex(s1) from t2;
+delete from t1 where a=1;
+-- error 1451
+delete from t1 where a=2;
+select a,hex(s1) from t1;
+select hex(s1) from t2;
+
+drop table t2,t1;
+# Ensure that <tablename>_ibfk_0 is not mistreated as a
+# generated foreign key identifier.  (Bug #16387)
+
+CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
+CREATE TABLE t2(a INT) ENGINE=InnoDB;
+ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
+ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
+SHOW CREATE TABLE t2;
+DROP TABLE t2,t1;
+
+#
+# Test case for bug #16229: MySQL/InnoDB uses full explicit table locks in trigger processing
+#
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+insert into t1(a) values (1),(2),(3);
+commit;
+connection b;
+set autocommit = 0;
+update t1 set b = 5 where a = 2;
+connection a;
+delimiter |;
+create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
+delimiter ;|
+set autocommit = 0;
+connection a;
+insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
+(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
+(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
+(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
+(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
+connection b;
+commit;
+connection a;
+commit;
+drop trigger t1t;
+drop table t1;
+disconnect a;
+disconnect b;
+#
+# Another trigger test
+#
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+insert into t1(a) values (1),(2),(3);
+insert into t2(a) values (1),(2),(3);
+insert into t3(a) values (1),(2),(3);
+insert into t4(a) values (1),(2),(3);
+insert into t3(a) values (5),(7),(8);
+insert into t4(a) values (5),(7),(8);
+insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
+
+delimiter |;
+create trigger t1t before insert on t1 for each row begin 
+    INSERT INTO t2 SET a = NEW.a;
+end |
+
+create trigger t2t before insert on t2 for each row begin
+    DELETE FROM t3 WHERE a = NEW.a;
+end |
+
+create trigger t3t before delete on t3 for each row begin  
+    UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
+end |
+
+create trigger t4t before update on t4 for each row begin
+    UPDATE t5 SET b = b + 1 where a = NEW.a;
+end |
+delimiter ;|
+commit;
+set autocommit = 0;
+update t1 set b = b + 5 where a = 1;
+update t2 set b = b + 5 where a = 1;
+update t3 set b = b + 5 where a = 1;
+update t4 set b = b + 5 where a = 1;
+insert into t5(a) values(20);
+connection b;
+set autocommit = 0;
+insert into t1(a) values(7);
+insert into t2(a) values(8);
+delete from t2 where a = 3;
+update t4 set b = b + 1 where a = 3;
+commit;
+drop trigger t1t;
+drop trigger t2t;
+drop trigger t3t;
+drop trigger t4t;
+drop table t1, t2, t3, t4, t5;
+connection default;
+disconnect a;
+disconnect b;
+
+#
+# Test that cascading updates leading to duplicate keys give the correct
+# error message (bug #9680)
+#
+
+CREATE TABLE t1 (
+  field1 varchar(8) NOT NULL DEFAULT '',
+  field2 varchar(8) NOT NULL DEFAULT '',
+  PRIMARY KEY  (field1, field2)
+) ENGINE=InnoDB;
+
+CREATE TABLE t2 (
+  field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
+  FOREIGN KEY (field1) REFERENCES t1 (field1)
+    ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES ('old', 'somevalu');
+INSERT INTO t1 VALUES ('other', 'anyvalue');
+
+INSERT INTO t2 VALUES ('old');
+INSERT INTO t2 VALUES ('other');
+
+--error ER_FOREIGN_DUPLICATE_KEY
+UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
+
+DROP TABLE t2;
+DROP TABLE t1;
+
+#
+# Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE
+#
+create table t1 (
+  c1 bigint not null,
+  c2 bigint not null,
+  primary key (c1),
+  unique  key (c2)
+) engine=innodb;
+#
+create table t2 (
+  c1 bigint not null,
+  primary key (c1)
+) engine=innodb;
+#
+alter table t1 add constraint c2_fk foreign key (c2)
+  references t2(c1) on delete cascade;
+show create table t1;
+#
+alter table t1 drop foreign key c2_fk;
+show create table t1;
+#
+drop table t1, t2;
+
+#
+# Bug #14360: problem with intervals
+#
+
+create table t1(a date) engine=innodb;
+create table t2(a date, key(a)) engine=innodb;
+insert into t1 values('2005-10-01');
+insert into t2 values('2005-10-01');
+select * from t1, t2
+  where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
+drop table t1, t2;
+
+create table t1 (id int not null, f_id int not null, f int not null,
+primary key(f_id, id)) engine=innodb;
+create table t2 (id int not null,s_id int not null,s varchar(200),
+primary key(id)) engine=innodb;
+INSERT INTO t1 VALUES (8, 1, 3);
+INSERT INTO t1 VALUES (1, 2, 1);
+INSERT INTO t2 VALUES (1, 0, '');
+INSERT INTO t2 VALUES (8, 1, '');
+commit;
+DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
+WHERE mm.id IS NULL;
+select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
+where mm.id is null lock in share mode;
+drop table t1,t2;
+
+#
+# Test case where X-locks on unused rows should be released in a
+# update (because READ COMMITTED isolation level)
+#
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
+commit;
+SET binlog_format='MIXED';
+set autocommit = 0; 
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+update t1 set b = 5 where b = 1;
+connection b;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+#
+# X-lock to record (7,3) should be released in a update 
+#
+select * from t1 where a = 7 and b = 3 for update;
+connection a;
+commit;
+connection b;
+commit;
+drop table t1;
+connection default;
+disconnect a;
+disconnect b;
+
+#
+# Test case where no locks should be released (because we are not
+# using READ COMMITTED isolation level)
+#
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
+commit;
+set autocommit = 0; 
+select * from t1 lock in share mode;
+update t1 set b = 5 where b = 1;
+connection b;
+set autocommit = 0;
+#
+# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
+#
+--error 1205
+select * from t1 where a = 2 and b = 2 for update;
+#
+# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
+#
+--error 1205
+connection a;
+commit;
+connection b;
+commit;
+connection default;
+disconnect a;
+disconnect b;
+drop table t1;
+
+#
+# Consistent read should be used in following selects
+#
+# 1) INSERT INTO ... SELECT
+# 2) UPDATE ... = ( SELECT ...)
+# 3) CREATE ... SELECT
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values (1,2),(5,3),(4,2);
+create table t2(d int not null, e int, primary key(d)) engine=innodb;
+insert into t2 values (8,6),(12,1),(3,1);
+commit;
+set autocommit = 0;
+select * from t2 for update;
+connection b;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+insert into t1 select * from t2;
+update t1 set b = (select e from t2 where a = d);
+create table t3(d int not null, e int, primary key(d)) engine=innodb
+select * from t2;
+commit;
+connection a;
+commit;
+connection default;
+disconnect a;
+disconnect b;
+drop table t1, t2, t3;
+
+#
+# Consistent read should not be used if 
+#
+# (a) isolation level is serializable OR
+# (b) select ... lock in share mode OR
+# (c) select ... for update
+#
+# in following queries:
+#
+# 1) INSERT INTO ... SELECT
+# 2) UPDATE ... = ( SELECT ...)
+# 3) CREATE ... SELECT
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connect (c,localhost,root,,);
+connect (d,localhost,root,,);
+connect (e,localhost,root,,);
+connect (f,localhost,root,,);
+connect (g,localhost,root,,);
+connect (h,localhost,root,,);
+connect (i,localhost,root,,);
+connect (j,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values (1,2),(5,3),(4,2);
+create table t2(a int not null, b int, primary key(a)) engine=innodb;
+insert into t2 values (8,6),(12,1),(3,1);
+create table t3(d int not null, b int, primary key(d)) engine=innodb;
+insert into t3 values (8,6),(12,1),(3,1);
+create table t5(a int not null, b int, primary key(a)) engine=innodb;
+insert into t5 values (1,2),(5,3),(4,2);
+create table t6(d int not null, e int, primary key(d)) engine=innodb;
+insert into t6 values (8,6),(12,1),(3,1);
+create table t8(a int not null, b int, primary key(a)) engine=innodb;
+insert into t8 values (1,2),(5,3),(4,2);
+create table t9(d int not null, e int, primary key(d)) engine=innodb;
+insert into t9 values (8,6),(12,1),(3,1);
+commit;
+set autocommit = 0;
+select * from t2 for update;
+connection b;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+insert into t1 select * from t2;
+connection c;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+update t3 set b = (select b from t2 where a = d);
+connection d;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
+connection e;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+insert into t5 (select * from t2 lock in share mode);
+connection f;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+update t6 set e = (select b from t2 where a = d lock in share mode);
+connection g;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
+connection h;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+insert into t8 (select * from t2 for update);
+connection i;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+update t9 set e = (select b from t2 where a = d for update);
+connection j;
+SET binlog_format='MIXED';
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
+
+connection b;
+--error 1205
+reap;
+
+connection c;
+--error 1205
+reap;
+
+connection d;
+--error 1205
+reap;
+
+connection e;
+--error 1205
+reap;
+
+connection f;
+--error 1205
+reap;
+
+connection g;
+--error 1205
+reap;
+
+connection h;
+--error 1205
+reap;
+
+connection i;
+--error 1205
+reap;
+
+connection j;
+--error 1205
+reap;
+
+connection a;
+commit;
+
+connection default;
+disconnect a;
+disconnect b;
+disconnect c;
+disconnect d;
+disconnect e;
+disconnect f;
+disconnect g;
+disconnect h;
+disconnect i;
+disconnect j;
+drop table t1, t2, t3, t5, t6, t8, t9;
+
+# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
+--error 1005
+CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
+
+#
+# Bug #17152: Wrong result with BINARY comparison on aliased column
+#
+
+CREATE TABLE t1 (
+   a BIGINT(20) NOT NULL,
+    PRIMARY KEY  (a)
+ ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
+
+CREATE TABLE t2 (
+  a BIGINT(20) NOT NULL,
+  b VARCHAR(128) NOT NULL,
+  c TEXT NOT NULL,
+  PRIMARY KEY  (a,b),
+  KEY idx_t2_b_c (b,c(200)),
+  CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) 
+   ON DELETE CASCADE
+ ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1, 'bar', 'vbar');
+INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
+INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
+INSERT INTO t2 VALUES (1, 'customer_over', '1');
+
+SELECT * FROM t2 WHERE b = 'customer_over';
+SELECT * FROM t2 WHERE BINARY b = 'customer_over';
+SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
+/* Bang: Empty result set, above was expected: */
+SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
+SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
+
+drop table t2, t1;
+
+#
+# Test optimize on table with open transaction
+#
+
+CREATE TABLE t1 ( a int ) ENGINE=innodb;
+BEGIN;
+INSERT INTO t1 VALUES (1);
+OPTIMIZE TABLE t1;
+DROP TABLE t1;
+
+#
+# Bug #24741 (existing cascade clauses disappear when adding foreign keys)
+#
+
+CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
+
+CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
+  CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
+  ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
+
+ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
+DELETE CASCADE ON UPDATE CASCADE;
+
+SHOW CREATE TABLE t2;
+DROP TABLE t2, t1;
+
+#
+# Bug #25927: Prevent ALTER TABLE ... MODIFY ... NOT NULL on columns
+# for which there is a foreign key constraint ON ... SET NULL.
+#
+
+CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
+# mysqltest first does replace_regex, then replace_result
+--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
+# Embedded server doesn't chdir to data directory
+--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
+--error 1025
+ALTER TABLE t2 MODIFY a INT NOT NULL;
+DELETE FROM t1;
+DROP TABLE t2,t1;
+
+#
+# Bug #26835: table corruption after delete+insert
+#
+
+CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
+DELETE FROM t1;
+INSERT INTO t1 VALUES ('DDD');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Bug #23313 (AUTO_INCREMENT=# not reported back for InnoDB tables)
+# Bug #21404 (AUTO_INCREMENT value reset when Adding FKEY (or ALTER?))
+#
+
+CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
+AUTO_INCREMENT=42;
+
+INSERT INTO t1 VALUES (0),(347),(0);
+SELECT * FROM t1;
+
+SHOW CREATE TABLE t1;
+
+CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t2 VALUES(42),(347),(348);
+ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1,t2;
+
+#
+# Bug #21101 (Prints wrong error message if max row size is too large)
+#
+set innodb_strict_mode=on;
+--error 1118
+CREATE TABLE t1 (
+	c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
+	c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
+	c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
+	c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
+	c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
+	c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
+	c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
+	c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
+	) ENGINE = InnoDB;
+
+#
+# Bug #31860 InnoDB assumes AUTOINC values can only be positive.
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(
+	id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
+	) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(-10);
+SELECT * FROM t1;
+#
+# NOTE: The server really needs to be restarted at this point
+# for the test to be useful.  
+#
+# Without the fix InnoDB would trip over an assertion here.
+INSERT INTO t1 VALUES(NULL);
+# The next value should be 1 and not -9 or a -ve number
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# 
+# Bug #21409 Incorrect result returned when in READ-COMMITTED with
+# query_cache ON
+#
+CONNECT (c1,localhost,root,,);
+CONNECT (c2,localhost,root,,);
+CONNECTION c1;
+SET binlog_format='MIXED';
+SET TX_ISOLATION='read-committed';
+SET AUTOCOMMIT=0;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
+CREATE TABLE t2 LIKE t1;
+SELECT * FROM t2;
+CONNECTION c2;
+SET binlog_format='MIXED';
+SET TX_ISOLATION='read-committed';
+SET AUTOCOMMIT=0;
+INSERT INTO t1 VALUES (1);
+COMMIT;
+CONNECTION c1;
+SELECT * FROM t1 WHERE a=1;
+DISCONNECT c1;
+DISCONNECT c2;
+CONNECT (c1,localhost,root,,);
+CONNECT (c2,localhost,root,,);
+CONNECTION c1;
+SET binlog_format='MIXED';
+SET TX_ISOLATION='read-committed';
+SET AUTOCOMMIT=0;
+SELECT * FROM t2;
+CONNECTION c2;
+SET binlog_format='MIXED';
+SET TX_ISOLATION='read-committed';
+SET AUTOCOMMIT=0;
+INSERT INTO t1 VALUES (2);
+COMMIT;
+CONNECTION c1;
+# The result set below should be the same for both selects
+SELECT * FROM t1 WHERE a=2;
+SELECT * FROM t1 WHERE a=2;
+DROP TABLE t1;
+DROP TABLE t2;
+DISCONNECT c1;
+DISCONNECT c2;
+CONNECTION default;
+
+#
+# Bug #29157 UPDATE, changed rows incorrect
+#
+create table t1 (i int, j int) engine=innodb;
+insert into t1 (i, j) values (1, 1), (2, 2);
+--enable_info
+update t1 set j = 2;
+--disable_info
+drop table t1;
+
+#
+# Bug #32440 InnoDB free space info does not appear in SHOW TABLE STATUS or
+# I_S
+#
+create table t1 (id int) comment='this is a comment' engine=innodb;
+select table_comment, data_free > 0 as data_free_is_set
+  from information_schema.tables
+  where table_schema='test' and table_name = 't1';
+drop table t1;
+
+#
+# Bug 34920 test
+#
+CONNECTION default;
+CREATE TABLE t1 (
+	c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+	c2 VARCHAR(128) NOT NULL,
+	PRIMARY KEY(c1)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
+
+CREATE TABLE t2 (
+	c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+	c2 INT(10) UNSIGNED DEFAULT NULL,
+	PRIMARY KEY(c1)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
+
+SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
+ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
+SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
+DROP TABLE t2;
+DROP TABLE t1;
+# End 34920 test
+#
+# Bug #29507 TRUNCATE shows to many rows effected
+#
+CONNECTION default;
+CREATE TABLE t1 (c1 int default NULL,
+		 c2 int default NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--enable_info
+TRUNCATE TABLE t1;
+
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+TRUNCATE TABLE t1;
+
+--disable_info
+DROP TABLE t1;
+#
+# Bug#35537 Innodb doesn't increment handler_update and handler_delete.
+#
+-- disable_query_log
+-- disable_result_log
+
+CONNECT (c1,localhost,root,,);
+
+DROP TABLE IF EXISTS bug35537;
+CREATE TABLE bug35537 (
+  c1 int
+) ENGINE=InnoDB;
+
+INSERT INTO bug35537 VALUES (1);
+
+-- enable_result_log
+
+SHOW SESSION STATUS LIKE 'Handler_update%';
+SHOW SESSION STATUS LIKE 'Handler_delete%';
+
+UPDATE bug35537 SET c1 = 2 WHERE c1 = 1;
+DELETE FROM bug35537 WHERE c1 = 2;
+
+SHOW SESSION STATUS LIKE 'Handler_update%';
+SHOW SESSION STATUS LIKE 'Handler_delete%';
+
+DROP TABLE bug35537;
+
+DISCONNECT c1;
+CONNECTION default;
+
+#######################################################################
+#                                                                     #
+# Please, DO NOT TOUCH this file as well as the innodb.result file.   #
+# These files are to be modified ONLY BY INNOBASE guys.               #
+#                                                                     #
+# Use innodb_mysql.[test|result] files instead.                       #
+#                                                                     #
+# If nevertheless you need to make some changes here, please, forward #
+# your commit message To: dev@xxxxxxxxxx Cc: dev-innodb@xxxxxxxxx     #
+# (otherwise your changes may be erased).                             #
+#                                                                     #
+#######################################################################

=== removed file 'mysql-test/t/innodb.test'
--- a/mysql-test/t/innodb.test	2009-01-23 12:22:05 +0000
+++ b/mysql-test/t/innodb.test	1970-01-01 00:00:00 +0000
@@ -1,2538 +0,0 @@
-#######################################################################
-#                                                                     #
-# Please, DO NOT TOUCH this file as well as the innodb.result file.   #
-# These files are to be modified ONLY BY INNOBASE guys.               #
-#                                                                     #
-# Use innodb_mysql.[test|result] files instead.                       #
-#                                                                     #
-# If nevertheless you need to make some changes here, please, forward #
-# your commit message To: dev@xxxxxxxxxx Cc: dev-innodb@xxxxxxxxx     #
-# (otherwise your changes may be erased).                             #
-#                                                                     #
-#######################################################################
-
--- source include/have_innodb.inc
-
-#
-# Small basic test with ignore
-#
-
---disable_warnings
-drop table if exists t1,t2,t3,t4;
-drop database if exists mysqltest;
---enable_warnings
-
-create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
-
-insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
-select id, code, name from t1 order by id;
-
-update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
-select id, code, name from t1 order by id;
-update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
-select id, code, name from t1 order by id;
-
-drop table t1;
-
-#
-# A bit bigger test
-# The 'replace_column' statements are needed because the cardinality calculated
-# by innodb is not always the same between runs
-#
-
-CREATE TABLE t1 (
-  id int(11) NOT NULL auto_increment,
-  parent_id int(11) DEFAULT '0' NOT NULL,
-  level tinyint(4) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (id),
-  KEY parent_id (parent_id),
-  KEY level (level)
-) engine=innodb;
-INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
-update t1 set parent_id=parent_id+100;
-select * from t1 where parent_id=102;
-update t1 set id=id+1000;
--- error ER_DUP_ENTRY,1022
-update t1 set id=1024 where id=1009; 
-select * from t1;
-update ignore t1 set id=id+1; # This will change all rows
-select * from t1;
-update ignore t1 set id=1023 where id=1010;
-select * from t1 where parent_id=102;
---replace_column 9 #
-explain select level from t1 where level=1;
---replace_column 9 #
-explain select level,id from t1 where level=1;
---replace_column 9 #
-explain select level,id,parent_id from t1 where level=1;
-select level,id from t1 where level=1;
-select level,id,parent_id from t1 where level=1;
-optimize table t1;
---replace_column 7 #
-show keys from t1;
-drop table t1;
-
-#
-# Test replace
-#
-
-CREATE TABLE t1 (
-  gesuchnr int(11) DEFAULT '0' NOT NULL,
-  benutzer_id int(11) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (gesuchnr,benutzer_id)
-) engine=innodb;
-
-replace into t1 (gesuchnr,benutzer_id) values (2,1);
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-select * from t1;
-drop table t1;
-
-#
-# test delete using hidden_primary_key
-#
-
-create table t1 (a int) engine=innodb;
-insert into t1 values (1), (2);
-optimize table t1;
-delete from t1 where a = 1;
-select * from t1;
-check table t1;
-drop table t1;
-
-create table t1 (a int,b varchar(20)) engine=innodb;
-insert into t1 values (1,""), (2,"testing");
-delete from t1 where a = 1;
-select * from t1;
-create index skr on t1 (a);
-insert into t1 values (3,""), (4,"testing");
-analyze table t1;
---replace_column 7 #
-show keys from t1;
-drop table t1;
-
-
-# Test of reading on secondary key with may be null
-
-create table t1 (a int,b varchar(20),key(a)) engine=innodb;
-insert into t1 values (1,""), (2,"testing");
-select * from t1 where a = 1;
-drop table t1;
-
-#
-# Test rollback
-#
-
-create table t1 (n int not null primary key) engine=innodb;
-set autocommit=0;
-insert into t1 values (4);
-rollback;
-select n, "after rollback" from t1;
-insert into t1 values (4);
-commit;
-select n, "after commit" from t1;
-commit;
-insert into t1 values (5);
--- error ER_DUP_ENTRY
-insert into t1 values (4);
-commit;
-select n, "after commit" from t1;
-set autocommit=1;
-insert into t1 values (6);
--- error ER_DUP_ENTRY
-insert into t1 values (4);
-select n from t1;
-set autocommit=0;
-#
-# savepoints
-#
-begin;
-savepoint `my_savepoint`;
-insert into t1 values (7);
-savepoint `savept2`;
-insert into t1 values (3);
-select n from t1;
-savepoint savept3;
-rollback to savepoint savept2;
---error 1305
-rollback to savepoint savept3;
-rollback to savepoint savept2;
-release savepoint `my_savepoint`;
-select n from t1;
--- error 1305
-rollback to savepoint `my_savepoint`;
---error 1305
-rollback to savepoint savept2;
-insert into t1 values (8);
-savepoint sv;
-commit;
-savepoint sv;
-set autocommit=1;
-# nop
-rollback;
-drop table t1;
-
-#
-# Test for commit and FLUSH TABLES WITH READ LOCK
-#
-
-create table t1 (n int not null primary key) engine=innodb;
-start transaction;
-insert into t1 values (4);
-flush tables with read lock;
-#
-# Current code can't handle a read lock in middle of transaction
-#--error 1223;
-commit;
-unlock tables;
-commit;
-select * from t1;
-drop table t1;
-
-#
-# Testing transactions
-#
-
-create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb;
-begin;
-insert into t1 values(1,'hamdouni');
-select id as afterbegin_id,nom as afterbegin_nom from t1;
-rollback;
-select id as afterrollback_id,nom as afterrollback_nom from t1;
-set autocommit=0;
-insert into t1 values(2,'mysql');
-select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
-rollback;
-select id as afterrollback_id,nom as afterrollback_nom from t1;
-set autocommit=1;
-drop table t1;
-
-#
-# Simple not autocommit test
-# 
-
-CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb;
-insert into t1 values ('pippo', 12);
--- error ER_DUP_ENTRY
-insert into t1 values ('pippo', 12); # Gives error
-delete from t1;
-delete from t1 where id = 'pippo';
-select * from t1;
-
-insert into t1 values ('pippo', 12);
-set autocommit=0;
-delete from t1;
-rollback;
-select * from t1;
-delete from t1;
-commit;
-select * from t1;
-drop table t1;
-
-#
-# Test of active transactions
-#
-
-create table t1 (a integer) engine=innodb;
-start transaction;
-rename table t1 to t2;
-create table t1 (b integer) engine=innodb;
-insert into t1 values (1);
-rollback;
-drop table t1;
-rename table t2 to t1;
-drop table t1;
-set autocommit=1;
-
-#
-# The following simple tests failed at some point
-#
-
-CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb;
-INSERT INTO t1 VALUES (1, 'Jochen');
-select * from t1;
-drop table t1;
-
-CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb;
-set autocommit=0;
-INSERT INTO t1  SET _userid='marc@xxxxxxxxxxxxx';
-COMMIT;
-SELECT * FROM t1;
-SELECT _userid FROM t1 WHERE _userid='marc@xxxxxxxxxxxxx';
-drop table t1;
-set autocommit=1;
-
-#
-# Test when reading on part of unique key
-#
-CREATE TABLE t1 (
-  user_id int(10) DEFAULT '0' NOT NULL,
-  name varchar(100),
-  phone varchar(100),
-  ref_email varchar(100) DEFAULT '' NOT NULL,
-  detail varchar(200),
-  PRIMARY KEY (user_id,ref_email)
-)engine=innodb;
-
-INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@xxxxxxxxxxx','xxx'),(10292,'shirish','2333604','shirish@xxxxxxxxx','ddsds'),(10292,'sonali','323232','sonali@xxxxxxxxx','filmstar');
-select * from t1 where user_id=10292;
-INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@xxxxxxxxxxx','xxx'),(10293,'shirish','2333604','shirish@xxxxxxxxx','ddsds');
-select * from t1 where user_id=10292;
-select * from t1 where user_id>=10292;
-select * from t1 where user_id>10292;
-select * from t1 where user_id<10292;
-drop table t1;
-
-#
-# Test that keys are created in right order
-#
-
-CREATE TABLE t1 (a int not null, b int not null,c int not null,
-key(a),primary key(a,b), unique(c),key(a),unique(b));
---replace_column 7 #
-show index from t1;
-drop table t1;
-
-#
-# Test of ALTER TABLE and innodb tables
-#
-
-create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
-alter table t1 engine=innodb;
-insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
-select * from t1;
-update t1 set col2='7' where col1='4';
-select * from t1;
-alter table t1 add co3 int not null;
-select * from t1;
-update t1 set col2='9' where col1='2';
-select * from t1;
-drop table t1;
-
-#
-# INSERT INTO innodb tables
-#
-
-create table t1 (a int not null , b int, primary key (a)) engine = innodb;
-create table t2 (a int not null , b int, primary key (a)) engine = myisam;
-insert into t1 VALUES (1,3) , (2,3), (3,3);
-select * from t1;
-insert into t2 select * from t1;
-select * from t2;
-delete from t1 where b = 3;
-select * from t1;
-insert into t1 select * from t2;
-select * from t1;
-select * from t2;
-drop table t1,t2;
-
-#
-# ORDER BY on not primary key
-#
-
-CREATE TABLE t1 (
-  user_name varchar(12),
-  password text,
-  subscribed char(1),
-  user_id int(11) DEFAULT '0' NOT NULL,
-  quota bigint(20),
-  weight double,
-  access_date date,
-  access_time time,
-  approved datetime,
-  dummy_primary_key int(11) NOT NULL auto_increment,
-  PRIMARY KEY (dummy_primary_key)
-) ENGINE=innodb;
-INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
-INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
-INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
-INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
-INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
-select  user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
-drop table t1;
-
-#
-# Testing of tables without primary keys
-#
-
-CREATE TABLE t1 (
-  id int(11) NOT NULL auto_increment,
-  parent_id int(11) DEFAULT '0' NOT NULL,
-  level tinyint(4) DEFAULT '0' NOT NULL,
-  KEY (id),
-  KEY parent_id (parent_id),
-  KEY level (level)
-) engine=innodb;
-INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
-INSERT INTO t1 values (179,5,2);
-update t1 set parent_id=parent_id+100;
-select * from t1 where parent_id=102;
-update t1 set id=id+1000;
-update t1 set id=1024 where id=1009; 
-select * from t1;
-update ignore t1 set id=id+1; # This will change all rows
-select * from t1;
-update ignore t1 set id=1023 where id=1010;
-select * from t1 where parent_id=102;
---replace_column 9 #
-explain select level from t1 where level=1;
-select level,id from t1 where level=1;
-select level,id,parent_id from t1 where level=1;
-select level,id from t1 where level=1 order by id;
-delete from t1 where level=1;
-select * from t1;
-drop table t1;
-
-#
-# Test of index only reads
-#
-CREATE TABLE t1 (
-   sca_code char(6) NOT NULL,
-   cat_code char(6) NOT NULL,
-   sca_desc varchar(50),
-   lan_code char(2) NOT NULL,
-   sca_pic varchar(100),
-   sca_sdesc varchar(50),
-   sca_sch_desc varchar(16),
-   PRIMARY KEY (sca_code, cat_code, lan_code),
-   INDEX sca_pic (sca_pic)
-) engine = innodb ;
-
-INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
-select count(*) from t1 where sca_code = 'PD';
-select count(*) from t1 where sca_code <= 'PD';
-select count(*) from t1 where sca_pic is null;
-alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
-select count(*) from t1 where sca_code='PD' and sca_pic is null;
-select count(*) from t1 where cat_code='E';
-
-alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
-select count(*) from t1 where sca_code='PD' and sca_pic is null;
-select count(*) from t1 where sca_pic >= 'n';
-select sca_pic from t1 where sca_pic is null;
-update t1 set sca_pic="test" where sca_pic is null;
-delete from t1 where sca_code='pd';
-drop table t1;
-
-#
-# Test of opening table twice and timestamps
-#
-set @a:=now();
-CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
-insert into t1 (a) values(1),(2),(3);
-select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
-select a from t1 natural join t1 as t2 where b >= @a order by a;
-update t1 set a=5 where a=1;
-select a from t1;
-drop table t1;
-
-#
-# Test with variable length primary key
-#
-create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb;
-insert into t1 values("hello",1),("world",2);
-select * from t1 order by b desc;
-optimize table t1;
---replace_column 7 #
-show keys from t1;
-drop table t1;
-
-#
-# Test of create index with NULL columns
-#
-create table t1 (i int, j int ) ENGINE=innodb;
-insert into t1 values (1,2);
-select * from t1 where i=1 and j=2;
-create index ax1 on t1 (i,j);
-select * from t1 where i=1 and j=2;
-drop table t1;
-
-#
-# Test min-max optimization
-#
-
-CREATE TABLE t1 (
-  a int3 unsigned NOT NULL,
-  b int1 unsigned NOT NULL,
-  UNIQUE (a, b)
-) ENGINE = innodb;
- 
-INSERT INTO t1 VALUES (1, 1);
-SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
-drop table t1;
-
-#
-# Test INSERT DELAYED
-#
-
-CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb;
-# Can't test this in 3.23
-# INSERT DELAYED INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-
-#
-# Crash when using many tables (Test case by Jeremy D Zawodny)
-#
-
-create table t1 (a int  primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb;
-insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
---replace_column 9 #
-explain select * from t1 where a > 0 and a < 50;
-drop table t1;
-
-#
-# Test lock tables
-#
-
-create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
-insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
-LOCK TABLES t1 WRITE;
---error ER_DUP_ENTRY
-insert into t1 values (99,1,2,'D'),(1,1,2,'D');
-select id from t1;
-select id from t1;
-UNLOCK TABLES;
-DROP TABLE t1;
-
-create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
-insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
-LOCK TABLES t1 WRITE;
-begin;
---error ER_DUP_ENTRY
-insert into t1 values (99,1,2,'D'),(1,1,2,'D');
-select id from t1;
-insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
-commit;
-select id,id3 from t1;
-UNLOCK TABLES;
-DROP TABLE t1;
-
-#
-# Test prefix key
-#
-create table t1 (a char(20), unique (a(5))) engine=innodb;
-drop table t1;
-create table t1 (a char(20), index (a(5))) engine=innodb;
-show create table t1;
-drop table t1;
-
-#
-# Test using temporary table and auto_increment
-#
-
-create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;
-insert into t1 values (NULL),(NULL),(NULL);
-delete from t1 where a=3;
-insert into t1 values (NULL);
-select * from t1;
-alter table t1 add b int;
-select * from t1;
-drop table t1;
-
-#Slashdot bug
-create table t1
- (
-  id int auto_increment primary key,
-  name varchar(32) not null,
-  value text not null,
-  uid int not null,
-  unique key(name,uid)
- ) engine=innodb;
-insert into t1 values (1,'one','one value',101),
- (2,'two','two value',102),(3,'three','three value',103);
-set insert_id=5;
-replace into t1 (value,name,uid) values ('other value','two',102);
-delete from t1 where uid=102;
-set insert_id=5;
-replace into t1 (value,name,uid) values ('other value','two',102);
-set insert_id=6;
-replace into t1 (value,name,uid) values ('other value','two',102);
-select * from t1;
-drop table t1;
-
-#
-# Test DROP DATABASE
-#
-
-create database mysqltest;
-create table mysqltest.t1 (a int not null) engine= innodb;
-insert into mysqltest.t1 values(1);
-create table mysqltest.t2 (a int not null) engine= myisam;
-insert into mysqltest.t2 values(1);
-create table mysqltest.t3 (a int not null) engine= heap;
-insert into mysqltest.t3 values(1);
-commit;
-drop database mysqltest;
-# Don't check error message
---error 1049
-show tables from mysqltest;
-
-#
-# Test truncate table with and without auto_commit
-#
-
-set autocommit=0;
-create table t1 (a int not null) engine= innodb;
-insert into t1 values(1),(2);
-truncate table t1;
-commit;
-truncate table t1;
-truncate table t1;
-select * from t1;
-insert into t1 values(1),(2);
-delete from t1;
-select * from t1;
-commit;
-drop table t1;
-set autocommit=1;
-
-create table t1 (a int not null) engine= innodb;
-insert into t1 values(1),(2);
-truncate table t1;
-insert into t1 values(1),(2);
-select * from t1;
-truncate table t1;
-insert into t1 values(1),(2);
-delete from t1;
-select * from t1;
-drop table t1;
-
-#
-# Test of how ORDER BY works when doing it on the whole table
-#
-
-create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb;
-insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
---replace_column 9 #
-explain select * from t1 order by a;
---replace_column 9 #
-explain select * from t1 order by b;
---replace_column 9 #
-explain select * from t1 order by c;
---replace_column 9 #
-explain select a from t1 order by a;
---replace_column 9 #
-explain select b from t1 order by b;
---replace_column 9 #
-explain select a,b from t1 order by b;
---replace_column 9 #
-explain select a,b from t1;
---replace_column 9 #
-explain select a,b,c from t1;
-drop table t1;
-
-#
-# Check describe
-#
-
-create table t1 (t int not null default 1, key (t)) engine=innodb;
-desc t1;
-drop table t1;
-
-#
-# Test of multi-table-delete
-#
-
-CREATE TABLE t1 (
-  number bigint(20) NOT NULL default '0',
-  cname char(15) NOT NULL default '',
-  carrier_id smallint(6) NOT NULL default '0',
-  privacy tinyint(4) NOT NULL default '0',
-  last_mod_date timestamp NOT NULL,
-  last_mod_id smallint(6) NOT NULL default '0',
-  last_app_date timestamp NOT NULL,
-  last_app_id smallint(6) default '-1',
-  version smallint(6) NOT NULL default '0',
-  assigned_scps int(11) default '0',
-  status tinyint(4) default '0'
-) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
-INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
-INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
-INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
-INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
-INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
-CREATE TABLE t2 (
-  number bigint(20) NOT NULL default '0',
-  cname char(15) NOT NULL default '',
-  carrier_id smallint(6) NOT NULL default '0',
-  privacy tinyint(4) NOT NULL default '0',
-  last_mod_date timestamp NOT NULL,
-  last_mod_id smallint(6) NOT NULL default '0',
-  last_app_date timestamp NOT NULL,
-  last_app_id smallint(6) default '-1',
-  version smallint(6) NOT NULL default '0',
-  assigned_scps int(11) default '0',
-  status tinyint(4) default '0'
-) ENGINE=InnoDB;
-INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
-INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
-INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
-INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
-select * from t1;
-select * from t2;
-delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);
-select * from t1;
-select * from t2; 
-select * from t2;
-drop table t1,t2;
-
-#
-# A simple test with some isolation levels
-# TODO: Make this into a test using replication to really test how
-# this works.
-#
-
-create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
-
-BEGIN;
-SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-SELECT @@tx_isolation,@@global.tx_isolation;
-insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
-select id, code, name from t1 order by id;
-COMMIT;
-
-BEGIN;
-SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
-insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
-select id, code, name from t1 order by id;
-COMMIT;
-
-SET binlog_format='MIXED';
-BEGIN;
-SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
-insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
-select id, code, name from t1 order by id;
-COMMIT;
-DROP TABLE t1;
-
-#
-# Test of multi-table-update
-#
-create table t1 (n int(10), d int(10)) engine=innodb;
-create table t2 (n int(10), d int(10)) engine=innodb;
-insert into t1 values(1,1),(1,2);
-insert into t2 values(1,10),(2,20);
-UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
-select * from t1;
-select * from t2;
-drop table t1,t2;
-
-#
-# Bug #29136  	erred multi-delete on trans table does not rollback 
-#
-
-# prepare
---disable_warnings
-drop table if exists t1, t2;
---enable_warnings
-CREATE TABLE t1 (a int, PRIMARY KEY (a));
-CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
-create trigger trg_del_t2 after  delete on t2 for each row
-       insert into t1 values (1);
-insert into t1 values (1);
-insert into t2 values (1),(2);
-
-
-# exec cases A, B - see multi_update.test
-
-# A. send_error() w/o send_eof() branch
-
---error ER_DUP_ENTRY
-delete t2 from t2;
-
-# check
-
-select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
-
-# cleanup bug#29136
-
-drop table t1, t2;
-
-
-#
-# Bug #29136  	erred multi-delete on trans table does not rollback 
-#
-
-# prepare
---disable_warnings
-drop table if exists t1, t2;
---enable_warnings
-CREATE TABLE t1 (a int, PRIMARY KEY (a));
-CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
-create trigger trg_del_t2 after  delete on t2 for each row
-       insert into t1 values (1);
-insert into t1 values (1);
-insert into t2 values (1),(2);
-
-
-# exec cases A, B - see multi_update.test
-
-# A. send_error() w/o send_eof() branch
-
---error ER_DUP_ENTRY
-delete t2 from t2;
-
-# check
-
-select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
-
-# cleanup bug#29136
-
-drop table t1, t2;
-
-
-#
-# Testing of IFNULL
-#
-create table t1 (a int, b int) engine=innodb;
-insert into t1 values(20,null);
-select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
-t2.b=t3.a;
-select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
-t2.b=t3.a order by 1;
-insert into t1 values(10,null);
-select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
-t2.b=t3.a order by 1;
-drop table t1;
-
-#
-# Test of read_through not existing const_table
-#
-
-create table t1 (a varchar(10) not null) engine=myisam;
-create table t2 (b varchar(10) not null unique) engine=innodb;
-select t1.a from t1,t2 where t1.a=t2.b;
-drop table t1,t2;
-create table t1 (a int not null, b int, primary key (a)) engine = innodb;
-create table t2 (a int not null, b int, primary key (a)) engine = innodb;
-insert into t1 values (10, 20);
-insert into t2 values (10, 20);
-update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
-drop table t1,t2;
-
-#
-# Test of multi-table-delete with foreign key constraints
-#
-
-CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
-CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id)  ON DELETE CASCADE ) ENGINE=INNODB;
-insert into t1 set id=1;
-insert into t2 set id=1, t1_id=1;
-delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
-select * from t1;
-select * from t2;
-drop table t2,t1;
-CREATE TABLE t1(id INT NOT NULL,  PRIMARY KEY (id)) ENGINE=INNODB;
-CREATE TABLE t2(id  INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id)  ) ENGINE=INNODB;
-INSERT INTO t1 VALUES(1);
-INSERT INTO t2 VALUES(1, 1);
-SELECT * from t1;
-UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
-SELECT * from t1;
-UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
-SELECT * from t1;
-DROP TABLE t1,t2;
-
-#
-# Test of range_optimizer
-#
-
-set autocommit=0;
-
-CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
-
-CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
-
-CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB;
-
-INSERT INTO t3 VALUES("my-test-1", "my-test-2");
-COMMIT;
-
-INSERT INTO t1 VALUES("this-key", "will disappear");
-INSERT INTO t2 VALUES("this-key", "will also disappear");
-DELETE FROM t3 WHERE id1="my-test-1";
-
-SELECT * FROM t1;
-SELECT * FROM t2;
-SELECT * FROM t3;
-ROLLBACK;
-
-SELECT * FROM t1;
-SELECT * FROM t2;
-SELECT * FROM t3;
-SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE;
-COMMIT;
-set autocommit=1;
-DROP TABLE t1,t2,t3;
-
-#
-# Check update with conflicting key
-#
-
-CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb;
-INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
-# We need the a < 1000 test here to quard against the halloween problems
-UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
-SELECT * from t1;
-drop table t1;
-
-#
-# Test multi update with different join methods
-#
-
-CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb;
-CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb;
-INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
-INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
-
-# Full join, without key
-update t1,t2 set t1.a=t1.a+100;
-select * from t1;
-
-# unique key
-update t1,t2 set t1.a=t1.a+100 where t1.a=101;
-select * from t1;
-
-# ref key
-update t1,t2 set t1.b=t1.b+10 where t1.b=2;
-select * from t1;
-
-# Range key (in t1)
-update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
-select * from t1;
-select * from t2;
-
-drop table t1,t2;
-CREATE TABLE t2 (   NEXT_T         BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
-CREATE TABLE t1 (  B_ID           INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
-SET AUTOCOMMIT=0;
-INSERT INTO t1 ( B_ID ) VALUES ( 1 );
-INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
-ROLLBACK;
-SELECT * FROM t1;
-drop table  t1,t2;
-create table t1  ( pk         int primary key,    parent     int not null,    child      int not null,       index (parent)  ) engine = innodb;
-insert into t1 values   (1,0,4),  (2,1,3),  (3,2,1),  (4,1,2);
-select distinct  parent,child   from t1   order by parent;
-drop table t1;
-
-#
-# Test that MySQL priorities clustered indexes
-#
-create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
-create table t2 (a int not null auto_increment primary key, b int);
-insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
-insert into t2 (a) select b from t1;
-insert into t1 (b) select b from t2;
-insert into t2 (a) select b from t1;
-insert into t1 (a) select b from t2;
-insert into t2 (a) select b from t1;
-insert into t1 (a) select b from t2;
-insert into t2 (a) select b from t1;
-insert into t1 (a) select b from t2;
-insert into t2 (a) select b from t1;
-insert into t1 (a) select b from t2;
-select count(*) from t1;
---replace_column 9 #
-explain select * from t1 where c between 1 and 2500;
-update t1 set c=a;
---replace_column 9 #
-explain select * from t1 where c between 1 and 2500;
-drop table t1,t2;
-
-#
-# Test of UPDATE ... ORDER BY
-#
-
-create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb;
-
-insert into t1 (id) values (null),(null),(null),(null),(null);
-update t1 set fk=69 where fk is null order by id limit 1;
-SELECT * from t1;
-drop table t1;
-
-create table t1 (a int not null, b int not null, key (a));
-insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
-SET @tmp=0;
-update t1 set b=(@tmp:=@tmp+1) order by a;
-update t1 set b=99 where a=1 order by b asc limit 1;
-update t1 set b=100 where a=1 order by b desc limit 2;
-update t1 set a=a+10+b where a=1 order by b;
-select * from t1 order by a,b;
-drop table t1;
-
-#
-# Test of multi-table-updates (bug #1980).
-#
-
-create table t1 ( c char(8) not null ) engine=innodb;
-insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
-insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
-
-alter table t1 add b char(8) not null;
-alter table t1 add a char(8) not null;
-alter table t1 add primary key (a,b,c);
-update t1 set a=c, b=c;
-
-create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
-insert into t2 select * from t1;
-
-delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
-drop table t1,t2;
-
-#
-# test autoincrement with TRUNCATE
-#
-
-SET AUTOCOMMIT=1;
-create table t1 (a integer auto_increment primary key) engine=innodb;
-insert into t1 (a) values (NULL),(NULL);
-truncate table t1;
-insert into t1 (a) values (NULL),(NULL);
-SELECT * from t1;
-drop table t1;
-
-#
-# Test dictionary handling with spaceand quoting
-#
-
-CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB;
-CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`)  ON DELETE CASCADE ) ENGINE=INNODB;
-#show create table t2;
-drop table t2,t1;
-
-#
-# Test of multi updated and foreign keys
-#
-
-create table `t1` (`id` int( 11 ) not null  ,primary key ( `id` )) engine = innodb;
-insert into `t1`values ( 1 ) ;
-create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
-insert into `t2`values ( 1 ) ;
-create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
-insert into `t3`values ( 1 ) ;
---error 1451
-delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
---error 1451
-update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
---error 1054
-update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
-drop table t3,t2,t1;
-
-#
-# test for recursion depth limit
-#
-create table t1(
-	id int primary key,
-	pid int,
-	index(pid),
-	foreign key(pid) references t1(id) on delete cascade) engine=innodb;
-insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
-	(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
--- error 1451
-delete from t1 where id=0;
-delete from t1 where id=15;
-delete from t1 where id=0;
-
-drop table t1;
-
-#
-# Test timestamps
-#
-
-CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
-CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
-(stamp))ENGINE=InnoDB;
-insert into t1 values (1),(2),(3);
-# Note that timestamp 3 is wrong
-insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
-SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
-'20020204120000' GROUP BY col1;
-drop table t1,t2;
-
-#
-# Test by Francois MASUREL
-#
-
-CREATE TABLE t1 (
-  `id` int(10) unsigned NOT NULL auto_increment,
-  `id_object` int(10) unsigned default '0',
-  `id_version` int(10) unsigned NOT NULL default '1',
-  `label` varchar(100) NOT NULL default '',
-  `description` text,
-  PRIMARY KEY  (`id`),
-  KEY `id_object` (`id_object`),
-  KEY `id_version` (`id_version`)
-) ENGINE=InnoDB;
-
-INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
-
-CREATE TABLE t2 (
-  `id` int(10) unsigned NOT NULL auto_increment,
-  `id_version` int(10) unsigned NOT NULL default '1',
-  PRIMARY KEY  (`id`),
-  KEY `id_version` (`id_version`)
-) ENGINE=InnoDB;
-
-INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
-
-SELECT t2.id, t1.`label` FROM t2 INNER JOIN
-(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl 
-ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
-drop table t1,t2;
-
-create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
-create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
-create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
-insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
-insert t2 select * from t1;
-insert t3 select * from t1;
-checksum table t1, t2, t3, t4 quick;
-checksum table t1, t2, t3, t4;
-checksum table t1, t2, t3, t4 extended;
-#show table status;
-drop table t1,t2,t3;
-
-#
-# Test problem with refering to different fields in same table in UNION
-# (Bug #2552)
-#
-create table t1 (id int,  name char(10) not null,  name2 char(10) not null) engine=innodb;
-insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
-select trim(name2) from t1  union all  select trim(name) from t1 union all select trim(id) from t1;
-drop table t1;
-
-#
-# Bug2160
-#
-create table t1 (a int) engine=innodb;
-create table t2 like t1;
-drop table t1,t2;
-
-#
-# Test of automaticly created foreign keys
-#
-
-create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb;
-create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb;
-show create table t1;
-show create table t2;
-create index id on t2 (id);
-show create table t2;
-create index id2 on t2 (id);
-show create table t2;
-drop index id2 on t2;
---error 1025,1025
-drop index id on t2;
-show create table t2;
-drop table t2;
-
-create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
-show create table t2;
-create unique index id on t2 (id,id2);
-show create table t2;
-drop table t2;
-
-# Check foreign key columns created in different order than key columns
-create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
-show create table t2;
-drop table t2;
-
-create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
-show create table t2;
-drop table t2;
-
-create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
-show create table t2;
-drop table t2;
-
-create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
-show create table t2;
-drop table t2;
-
-create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
-show create table t2;
-alter table t2 add index id_test (id), add index id_test2 (id,id2);
-show create table t2;
-drop table t2;
-
-# Test error handling
-
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
---error ER_WRONG_FK_DEF
-create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
-
-# bug#3749
-
-create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
-show create table t2;
-drop table t2;
-create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb;
-show create table t2;
-drop table t2, t1;
-
-
-#
-# Bug #6126: Duplicate columns in keys gives misleading error message
-#
---error 1060
-create table t1 (c char(10), index (c,c)) engine=innodb;
---error 1060
-create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
---error 1060
-create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
---error 1060
-create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
-create table t1 (c1 char(10), c2 char(10)) engine=innodb;
---error 1060
-alter table t1 add key (c1,c1);
---error 1060
-alter table t1 add key (c2,c1,c1);
---error 1060
-alter table t1 add key (c1,c2,c1);
---error 1060
-alter table t1 add key (c1,c1,c2);
-drop table t1;
-
-#
-# Bug #4082: integer truncation
-#
-
-create table t1(a int(1) , b int(1)) engine=innodb;
-insert into t1 values ('1111', '3333');
-select distinct concat(a, b) from t1;
-drop table t1;
-
-#
-# BUG#7709 test case - Boolean fulltext query against unsupported 
-#                      engines does not fail
-#
-
-CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
---error 1214
-SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
-DROP TABLE t1;
-
-#
-# check null values #1
-#
-
---disable_warnings
-CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY  (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-INSERT INTO t1 VALUES (1),(2),(3);
-CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY  (b_id), KEY  (b_a), 
-                CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
---enable_warnings
-INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
-SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
-DROP TABLE t2;
-DROP TABLE t1;
-
-#
-# Bug#11816 - Truncate table doesn't work with temporary innodb tables
-# This is not an innodb bug, but we test it using innodb.
-#
-create temporary table t1 (a int) engine=innodb;
-insert into t1 values (4711);
-truncate t1;
-insert into t1 values (42);
-select * from t1;
-drop table t1;
-# Show that it works with permanent tables too.
-create table t1 (a int) engine=innodb;
-insert into t1 values (4711);
-truncate t1;
-insert into t1 values (42);
-select * from t1;
-drop table t1;
-
-#
-# Bug #13025  Server crash during filesort	
-#
-
-create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb;
-insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
-select * from t1 order by a,b,c,d;
-explain select * from t1 order by a,b,c,d;
-drop table t1;
-
-#
-# BUG#11039,#13218 Wrong key length in min()
-#
-
-create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
-insert into t1 values ('8', '6'), ('4', '7');
-select min(a) from t1;
-select min(b) from t1 where a='8';
-drop table t1;
-
-# End of 4.1 tests
-
-#
-# range optimizer problem
-#
-
-create table t1 (x bigint unsigned not null primary key) engine=innodb;
-insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
-select * from t1;
-select count(*) from t1 where x>0;
-select count(*) from t1 where x=0;
-select count(*) from t1 where x<0;
-select count(*) from t1 where x < -16;
-select count(*) from t1 where x = -16;
-explain select count(*) from t1 where x > -16;
-select count(*) from t1 where x > -16;
-select * from t1 where x > -16;
-select count(*) from t1 where x = 18446744073709551601;
-drop table t1;
-
-
-# Test for testable InnoDB status variables. This test
-# uses previous ones(pages_created, rows_deleted, ...).
-show status like "Innodb_buffer_pool_pages_total";
-show status like "Innodb_page_size";
-show status like "Innodb_rows_deleted";
-show status like "Innodb_rows_inserted";
-show status like "Innodb_rows_updated";
-
-# Test for row locks InnoDB status variables.
-show status like "Innodb_row_lock_waits";
-show status like "Innodb_row_lock_current_waits";
-show status like "Innodb_row_lock_time";
-show status like "Innodb_row_lock_time_max";
-show status like "Innodb_row_lock_time_avg";
-
-# Test for innodb_sync_spin_loops variable
-show variables like "innodb_sync_spin_loops";
-set global innodb_sync_spin_loops=1000;
-show variables like "innodb_sync_spin_loops";
-set global innodb_sync_spin_loops=0;
-show variables like "innodb_sync_spin_loops";
-set global innodb_sync_spin_loops=20;
-show variables like "innodb_sync_spin_loops";
-
-# Test for innodb_thread_concurrency variable
-SET @old_innodb_thread_concurrency= @@global.innodb_thread_concurrency;
-show variables like "innodb_thread_concurrency";
-set global innodb_thread_concurrency=1001;
-show variables like "innodb_thread_concurrency";
-set global innodb_thread_concurrency=0;
-show variables like "innodb_thread_concurrency";
-set global innodb_thread_concurrency=16;
-show variables like "innodb_thread_concurrency";
-SET @@global.innodb_thread_concurrency= @old_innodb_thread_concurrency;
-
-# Test for innodb_concurrency_tickets variable
-show variables like "innodb_concurrency_tickets";
-set global innodb_concurrency_tickets=1000;
-show variables like "innodb_concurrency_tickets";
-set global innodb_concurrency_tickets=0;
-show variables like "innodb_concurrency_tickets";
-set global innodb_concurrency_tickets=500;
-show variables like "innodb_concurrency_tickets";
-
-# Test for innodb_thread_sleep_delay variable
-show variables like "innodb_thread_sleep_delay";
-set global innodb_thread_sleep_delay=100000;
-show variables like "innodb_thread_sleep_delay";
-set global innodb_thread_sleep_delay=0;
-show variables like "innodb_thread_sleep_delay";
-set global innodb_thread_sleep_delay=10000;
-show variables like "innodb_thread_sleep_delay";
-
-#
-# Test varchar
-#
-
-let $default=`select @@storage_engine`;
-set storage_engine=INNODB;
-source include/varchar.inc;
-
-#
-# Some errors/warnings on create
-#
-
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
-create table t1 (v varchar(65530), key(v));
-drop table t1;
-create table t1 (v varchar(65536));
-show create table t1;
-drop table t1;
-create table t1 (v varchar(65530) character set utf8);
-show create table t1;
-drop table t1;
-
-eval set storage_engine=$default;
-
-# InnoDB specific varchar tests
-create table t1 (v varchar(16384)) engine=innodb;
-drop table t1;
-
-#
-# BUG#11039 Wrong key length in min()
-#
-
-create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
-insert into t1 values ('8', '6'), ('4', '7');
-select min(a) from t1;
-select min(b) from t1 where a='8';
-drop table t1;
-
-#
-# Bug #11080 & #11005  Multi-row REPLACE fails on a duplicate key error
-#
-
-CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
-insert into t1 (b) values (1);
-replace into t1 (b) values (2), (1), (3);
-select * from t1;
-truncate table t1;
-insert into t1 (b) values (1);
-replace into t1 (b) values (2);
-replace into t1 (b) values (1);
-replace into t1 (b) values (3);
-select * from t1;
-drop table t1;
-
-create table t1 (rowid int not null auto_increment, val int not null,primary
-key (rowid), unique(val)) engine=innodb;
-replace into t1 (val) values ('1'),('2');
-replace into t1 (val) values ('1'),('2');
---error ER_DUP_ENTRY
-insert into t1 (val) values ('1'),('2');
-select * from t1;
-drop table t1;
-
-#
-# Test that update does not change internal auto-increment value
-#
-
-create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
-insert into t1 (val) values (1);
-update t1 set a=2 where a=1;
-# We should get the following error because InnoDB does not update the counter
---error ER_DUP_ENTRY
-insert into t1 (val) values (1);
-select * from t1;
-drop table t1;
-#
-# Bug #10465
-#
-
---disable_warnings
-CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
---enable_warnings
-INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
-SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
-SELECT GRADE  FROM t1 WHERE GRADE= 151;
-DROP TABLE t1;
-
-#
-# Bug #12340 multitable delete deletes only one record
-#
-create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
-create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
-insert into t2 values ('aa','cc');
-insert into t1 values ('aa','bb'),('aa','cc');
-delete t1 from t1,t2 where f1=f3 and f4='cc';
-select * from t1;
-drop table t1,t2;
-
-#
-# Test that the slow TRUNCATE implementation resets autoincrement columns
-# (bug #11946)
-#
-
-CREATE TABLE t1 (
-id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
-) ENGINE=InnoDB;
-
-CREATE TABLE t2 (
-id INTEGER NOT NULL,
-FOREIGN KEY (id) REFERENCES t1 (id)
-) ENGINE=InnoDB;
-
-INSERT INTO t1 (id) VALUES (NULL);
-SELECT * FROM t1;
-TRUNCATE t1;
-INSERT INTO t1 (id) VALUES (NULL);
-SELECT * FROM t1;
-
-# continued from above; test that doing a slow TRUNCATE on a table with 0
-# rows resets autoincrement columns
-DELETE FROM t1;
-TRUNCATE t1;
-INSERT INTO t1 (id) VALUES (NULL);
-SELECT * FROM t1;
-DROP TABLE t2, t1;
-
-# Test that foreign keys in temporary tables are not accepted (bug #12084)
-CREATE TABLE t1
-(
- id INT PRIMARY KEY
-) ENGINE=InnoDB;
-
---error 1005,1005
-CREATE TEMPORARY TABLE t2
-(
- id INT NOT NULL PRIMARY KEY,
- b INT,
- FOREIGN KEY (b) REFERENCES test.t1(id)
-) ENGINE=InnoDB;
-DROP TABLE t1;
-
-#
-# Test that index column max sizes are honored (bug #13315)
-#
-
-# prefix index
-create table t1 (col1 varchar(2000), index (col1(767)))
- character set = latin1 engine = innodb;
-
-# normal indexes
-create table t2 (col1 char(255), index (col1))
- character set = latin1 engine = innodb;
-create table t3 (col1 binary(255), index (col1))
- character set = latin1 engine = innodb;
-create table t4 (col1 varchar(767), index (col1))
- character set = latin1 engine = innodb;
-create table t5 (col1 varchar(767) primary key)
- character set = latin1 engine = innodb;
-create table t6 (col1 varbinary(767) primary key)
- character set = latin1 engine = innodb;
-create table t7 (col1 text, index(col1(767)))
- character set = latin1 engine = innodb;
-create table t8 (col1 blob, index(col1(767)))
- character set = latin1 engine = innodb;
-
-# multi-column indexes are allowed to be longer
-create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
- character set = latin1 engine = innodb;
-
-show create table t9;
-
-drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
-
-# these should have their index length trimmed
-create table t1 (col1 varchar(768), index(col1))
- character set = latin1 engine = innodb;
-create table t2 (col1 varbinary(768), index(col1))
- character set = latin1 engine = innodb;
-create table t3 (col1 text, index(col1(768)))
- character set = latin1 engine = innodb;
-create table t4 (col1 blob, index(col1(768)))
- character set = latin1 engine = innodb;
-
-show create table t1;
-
-drop table t1, t2, t3, t4;
-
-# these should be refused
---error 1071
-create table t1 (col1 varchar(768) primary key)
- character set = latin1 engine = innodb;
---error 1071
-create table t2 (col1 varbinary(768) primary key)
- character set = latin1 engine = innodb;
---error 1071
-create table t3 (col1 text, primary key(col1(768)))
- character set = latin1 engine = innodb;
---error 1071
-create table t4 (col1 blob, primary key(col1(768)))
- character set = latin1 engine = innodb;
-
-#
-# Test improved foreign key error messages (bug #3443)
-#
-
-CREATE TABLE t1
-(
- id INT PRIMARY KEY
-) ENGINE=InnoDB;
-
-CREATE TABLE t2
-(
- v INT,
- CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
-) ENGINE=InnoDB;
-
---error 1452
-INSERT INTO t2 VALUES(2);
-
-INSERT INTO t1 VALUES(1);
-INSERT INTO t2 VALUES(1);
-
---error 1451
-DELETE FROM t1 WHERE id = 1;
-
---error 1217
-DROP TABLE t1;
-
-SET FOREIGN_KEY_CHECKS=0;
-DROP TABLE t1;
-SET FOREIGN_KEY_CHECKS=1;
-
---error 1452
-INSERT INTO t2 VALUES(3);
-
-DROP TABLE t2;
-#
-# Test that checksum table uses a consistent read Bug #12669
-#
-connect (a,localhost,root,,);
-connect (b,localhost,root,,);
-connection a;
-create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into t1 values (1),(2);
-set autocommit=0;
-checksum table t1;
-connection b;
-insert into t1 values(3);
-connection a;
-#
-# Here checksum should not see insert
-#
-checksum table t1;
-connection a;
-commit;
-checksum table t1;
-commit;
-drop table t1;
-#
-# autocommit = 1
-#
-connection a;
-create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into t1 values (1),(2);
-set autocommit=1;
-checksum table t1;
-connection b;
-set autocommit=1;
-insert into t1 values(3);
-connection a;
-#
-# Here checksum sees insert
-#
-checksum table t1;
-drop table t1;
-
-connection default;
-disconnect a;
-disconnect b;
-
-# tests for bugs #9802 and #13778
-
-# test that FKs between invalid types are not accepted
-
-set foreign_key_checks=0;
-create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
--- error 1005
-create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
-set foreign_key_checks=1;
-drop table t2;
-
-# test that FKs between different charsets are not accepted in CREATE even
-# when f_k_c is 0
-
-set foreign_key_checks=0;
-create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
--- error 1005
-create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
-set foreign_key_checks=1;
-drop table t1;
-
-# test that invalid datatype conversions with ALTER are not allowed
-
-set foreign_key_checks=0;
-create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
-create table t1(a varchar(10) primary key) engine = innodb;
--- error 1025,1025
-alter table t1 modify column a int;
-set foreign_key_checks=1;
-drop table t2,t1;
-
-# test that charset conversions with ALTER are allowed when f_k_c is 0
-
-set foreign_key_checks=0;
-create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
-create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
-alter table t1 convert to character set utf8;
-set foreign_key_checks=1;
-drop table t2,t1;
-
-# test that RENAME does not allow invalid charsets when f_k_c is 0
-
-set foreign_key_checks=0;
-create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
-create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
--- error 1025
-rename table t3 to t1;
-set foreign_key_checks=1;
-drop table t2,t3;
-
-# test that foreign key errors are reported correctly (Bug #15550)
-
-create table t1(a int primary key) row_format=redundant engine=innodb;
-create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
-create table t3(a int primary key) row_format=compact engine=innodb;
-create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
-
-insert into t1 values(1);
-insert into t3 values(1);
--- error 1452
-insert into t2 values(2);
--- error 1452
-insert into t4 values(2);
-insert into t2 values(1);
-insert into t4 values(1);
--- error 1451
-update t1 set a=2;
--- error 1452
-update t2 set a=2;
--- error 1451
-update t3 set a=2;
--- error 1452
-update t4 set a=2;
--- error 1451
-truncate t1;
--- error 1451
-truncate t3;
-truncate t2;
-truncate t4;
-truncate t1;
-truncate t3;
-
-drop table t4,t3,t2,t1;
-
-
-#
-# Test that we can create a large (>1K) key
-#
-create table t1 (a varchar(255) character set utf8,
-                 b varchar(255) character set utf8,
-                 c varchar(255) character set utf8,
-                 d varchar(255) character set utf8,
-                 key (a,b,c,d)) engine=innodb;
-drop table t1;
---error ER_TOO_LONG_KEY
-create table t1 (a varchar(255) character set utf8,
-                 b varchar(255) character set utf8,
-                 c varchar(255) character set utf8,
-                 d varchar(255) character set utf8,
-                 e varchar(255) character set utf8,
-                 key (a,b,c,d,e)) engine=innodb;
-
-
-# test the padding of BINARY types and collations (Bug #14189)
-
-create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
-create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
-create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
-create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
-
-insert into t1 values (0x41),(0x4120),(0x4100);
--- error ER_DUP_ENTRY
-insert into t2 values (0x41),(0x4120),(0x4100);
-insert into t2 values (0x41),(0x4120);
--- error ER_DUP_ENTRY
-insert into t3 values (0x41),(0x4120),(0x4100);
-insert into t3 values (0x41),(0x4100);
--- error ER_DUP_ENTRY
-insert into t4 values (0x41),(0x4120),(0x4100);
-insert into t4 values (0x41),(0x4100);
-select hex(s1) from t1;
-select hex(s1) from t2;
-select hex(s1) from t3;
-select hex(s1) from t4;
-drop table t1,t2,t3,t4;
-
-create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
-create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
-
-insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
--- error 1452
-insert into t2 values(0x42);
-insert into t2 values(0x41);
-select hex(s1) from t2;
-update t1 set s1=0x123456 where a=2;
-select hex(s1) from t2;
--- error 1451
-update t1 set s1=0x12 where a=1;
--- error 1451
-update t1 set s1=0x12345678 where a=1;
--- error 1451
-update t1 set s1=0x123457 where a=1;
-update t1 set s1=0x1220 where a=1;
-select hex(s1) from t2;
-update t1 set s1=0x1200 where a=1;
-select hex(s1) from t2;
-update t1 set s1=0x4200 where a=1;
-select hex(s1) from t2;
--- error 1451
-delete from t1 where a=1;
-delete from t1 where a=2;
-update t2 set s1=0x4120;
--- error 1451
-delete from t1;
-delete from t1 where a!=3;
-select a,hex(s1) from t1;
-select hex(s1) from t2;
-
-drop table t2,t1;
-
-create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
-create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
-
-insert into t1 values(1,0x4100),(2,0x41);
-insert into t2 values(0x41);
-select hex(s1) from t2;
-update t1 set s1=0x1234 where a=1;
-select hex(s1) from t2;
-update t1 set s1=0x12 where a=2;
-select hex(s1) from t2;
-delete from t1 where a=1;
--- error 1451
-delete from t1 where a=2;
-select a,hex(s1) from t1;
-select hex(s1) from t2;
-
-drop table t2,t1;
-# Ensure that <tablename>_ibfk_0 is not mistreated as a
-# generated foreign key identifier.  (Bug #16387)
-
-CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
-CREATE TABLE t2(a INT) ENGINE=InnoDB;
-ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
-ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
-ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
-ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
-SHOW CREATE TABLE t2;
-DROP TABLE t2,t1;
-
-#
-# Test case for bug #16229: MySQL/InnoDB uses full explicit table locks in trigger processing
-#
-
-connect (a,localhost,root,,);
-connect (b,localhost,root,,);
-connection a;
-create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-insert into t1(a) values (1),(2),(3);
-commit;
-connection b;
-set autocommit = 0;
-update t1 set b = 5 where a = 2;
-connection a;
-delimiter |;
-create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
-delimiter ;|
-set autocommit = 0;
-connection a;
-insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
-(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
-(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
-(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
-(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
-connection b;
-commit;
-connection a;
-commit;
-drop trigger t1t;
-drop table t1;
-disconnect a;
-disconnect b;
-#
-# Another trigger test
-#
-connect (a,localhost,root,,);
-connect (b,localhost,root,,);
-connection a;
-create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
-insert into t1(a) values (1),(2),(3);
-insert into t2(a) values (1),(2),(3);
-insert into t3(a) values (1),(2),(3);
-insert into t4(a) values (1),(2),(3);
-insert into t3(a) values (5),(7),(8);
-insert into t4(a) values (5),(7),(8);
-insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
-
-delimiter |;
-create trigger t1t before insert on t1 for each row begin 
-    INSERT INTO t2 SET a = NEW.a;
-end |
-
-create trigger t2t before insert on t2 for each row begin
-    DELETE FROM t3 WHERE a = NEW.a;
-end |
-
-create trigger t3t before delete on t3 for each row begin  
-    UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
-end |
-
-create trigger t4t before update on t4 for each row begin
-    UPDATE t5 SET b = b + 1 where a = NEW.a;
-end |
-delimiter ;|
-commit;
-set autocommit = 0;
-update t1 set b = b + 5 where a = 1;
-update t2 set b = b + 5 where a = 1;
-update t3 set b = b + 5 where a = 1;
-update t4 set b = b + 5 where a = 1;
-insert into t5(a) values(20);
-connection b;
-set autocommit = 0;
-insert into t1(a) values(7);
-insert into t2(a) values(8);
-delete from t2 where a = 3;
-update t4 set b = b + 1 where a = 3;
-commit;
-drop trigger t1t;
-drop trigger t2t;
-drop trigger t3t;
-drop trigger t4t;
-drop table t1, t2, t3, t4, t5;
-connection default;
-disconnect a;
-disconnect b;
-
-#
-# Test that cascading updates leading to duplicate keys give the correct
-# error message (bug #9680)
-#
-
-CREATE TABLE t1 (
-  field1 varchar(8) NOT NULL DEFAULT '',
-  field2 varchar(8) NOT NULL DEFAULT '',
-  PRIMARY KEY  (field1, field2)
-) ENGINE=InnoDB;
-
-CREATE TABLE t2 (
-  field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
-  FOREIGN KEY (field1) REFERENCES t1 (field1)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB;
-
-INSERT INTO t1 VALUES ('old', 'somevalu');
-INSERT INTO t1 VALUES ('other', 'anyvalue');
-
-INSERT INTO t2 VALUES ('old');
-INSERT INTO t2 VALUES ('other');
-
---error ER_FOREIGN_DUPLICATE_KEY
-UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
-
-DROP TABLE t2;
-DROP TABLE t1;
-
-#
-# Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE
-#
-create table t1 (
-  c1 bigint not null,
-  c2 bigint not null,
-  primary key (c1),
-  unique  key (c2)
-) engine=innodb;
-#
-create table t2 (
-  c1 bigint not null,
-  primary key (c1)
-) engine=innodb;
-#
-alter table t1 add constraint c2_fk foreign key (c2)
-  references t2(c1) on delete cascade;
-show create table t1;
-#
-alter table t1 drop foreign key c2_fk;
-show create table t1;
-#
-drop table t1, t2;
-
-#
-# Bug #14360: problem with intervals
-#
-
-create table t1(a date) engine=innodb;
-create table t2(a date, key(a)) engine=innodb;
-insert into t1 values('2005-10-01');
-insert into t2 values('2005-10-01');
-select * from t1, t2
-  where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
-drop table t1, t2;
-
-create table t1 (id int not null, f_id int not null, f int not null,
-primary key(f_id, id)) engine=innodb;
-create table t2 (id int not null,s_id int not null,s varchar(200),
-primary key(id)) engine=innodb;
-INSERT INTO t1 VALUES (8, 1, 3);
-INSERT INTO t1 VALUES (1, 2, 1);
-INSERT INTO t2 VALUES (1, 0, '');
-INSERT INTO t2 VALUES (8, 1, '');
-commit;
-DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
-WHERE mm.id IS NULL;
-select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
-where mm.id is null lock in share mode;
-drop table t1,t2;
-
-#
-# Test case where X-locks on unused rows should be released in a
-# update (because READ COMMITTED isolation level)
-#
-
-connect (a,localhost,root,,);
-connect (b,localhost,root,,);
-connection a;
-create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
-commit;
-SET binlog_format='MIXED';
-set autocommit = 0; 
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-update t1 set b = 5 where b = 1;
-connection b;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-#
-# X-lock to record (7,3) should be released in a update 
-#
-select * from t1 where a = 7 and b = 3 for update;
-connection a;
-commit;
-connection b;
-commit;
-drop table t1;
-connection default;
-disconnect a;
-disconnect b;
-
-#
-# Test case where no locks should be released (because we are not
-# using READ COMMITTED isolation level)
-#
-
-connect (a,localhost,root,,);
-connect (b,localhost,root,,);
-connection a;
-create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
-commit;
-set autocommit = 0; 
-select * from t1 lock in share mode;
-update t1 set b = 5 where b = 1;
-connection b;
-set autocommit = 0;
-#
-# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
-#
---error 1205
-select * from t1 where a = 2 and b = 2 for update;
-#
-# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
-#
---error 1205
-connection a;
-commit;
-connection b;
-commit;
-connection default;
-disconnect a;
-disconnect b;
-drop table t1;
-
-#
-# Consistent read should be used in following selects
-#
-# 1) INSERT INTO ... SELECT
-# 2) UPDATE ... = ( SELECT ...)
-# 3) CREATE ... SELECT
-
-connect (a,localhost,root,,);
-connect (b,localhost,root,,);
-connection a;
-create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values (1,2),(5,3),(4,2);
-create table t2(d int not null, e int, primary key(d)) engine=innodb;
-insert into t2 values (8,6),(12,1),(3,1);
-commit;
-set autocommit = 0;
-select * from t2 for update;
-connection b;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-insert into t1 select * from t2;
-update t1 set b = (select e from t2 where a = d);
-create table t3(d int not null, e int, primary key(d)) engine=innodb
-select * from t2;
-commit;
-connection a;
-commit;
-connection default;
-disconnect a;
-disconnect b;
-drop table t1, t2, t3;
-
-#
-# Consistent read should not be used if 
-#
-# (a) isolation level is serializable OR
-# (b) select ... lock in share mode OR
-# (c) select ... for update
-#
-# in following queries:
-#
-# 1) INSERT INTO ... SELECT
-# 2) UPDATE ... = ( SELECT ...)
-# 3) CREATE ... SELECT
-
-connect (a,localhost,root,,);
-connect (b,localhost,root,,);
-connect (c,localhost,root,,);
-connect (d,localhost,root,,);
-connect (e,localhost,root,,);
-connect (f,localhost,root,,);
-connect (g,localhost,root,,);
-connect (h,localhost,root,,);
-connect (i,localhost,root,,);
-connect (j,localhost,root,,);
-connection a;
-create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values (1,2),(5,3),(4,2);
-create table t2(a int not null, b int, primary key(a)) engine=innodb;
-insert into t2 values (8,6),(12,1),(3,1);
-create table t3(d int not null, b int, primary key(d)) engine=innodb;
-insert into t3 values (8,6),(12,1),(3,1);
-create table t5(a int not null, b int, primary key(a)) engine=innodb;
-insert into t5 values (1,2),(5,3),(4,2);
-create table t6(d int not null, e int, primary key(d)) engine=innodb;
-insert into t6 values (8,6),(12,1),(3,1);
-create table t8(a int not null, b int, primary key(a)) engine=innodb;
-insert into t8 values (1,2),(5,3),(4,2);
-create table t9(d int not null, e int, primary key(d)) engine=innodb;
-insert into t9 values (8,6),(12,1),(3,1);
-commit;
-set autocommit = 0;
-select * from t2 for update;
-connection b;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
---send
-insert into t1 select * from t2;
-connection c;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
---send
-update t3 set b = (select b from t2 where a = d);
-connection d;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
---send
-create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
-connection e;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
---send
-insert into t5 (select * from t2 lock in share mode);
-connection f;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
---send
-update t6 set e = (select b from t2 where a = d lock in share mode);
-connection g;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
---send
-create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
-connection h;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
---send
-insert into t8 (select * from t2 for update);
-connection i;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
---send
-update t9 set e = (select b from t2 where a = d for update);
-connection j;
-SET binlog_format='MIXED';
-set autocommit = 0;
-SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
---send
-create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
-
-connection b;
---error 1205
-reap;
-
-connection c;
---error 1205
-reap;
-
-connection d;
---error 1205
-reap;
-
-connection e;
---error 1205
-reap;
-
-connection f;
---error 1205
-reap;
-
-connection g;
---error 1205
-reap;
-
-connection h;
---error 1205
-reap;
-
-connection i;
---error 1205
-reap;
-
-connection j;
---error 1205
-reap;
-
-connection a;
-commit;
-
-connection default;
-disconnect a;
-disconnect b;
-disconnect c;
-disconnect d;
-disconnect e;
-disconnect f;
-disconnect g;
-disconnect h;
-disconnect i;
-disconnect j;
-drop table t1, t2, t3, t5, t6, t8, t9;
-
-# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
---error 1005
-CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
-
-#
-# Bug #17152: Wrong result with BINARY comparison on aliased column
-#
-
-CREATE TABLE t1 (
-   a BIGINT(20) NOT NULL,
-    PRIMARY KEY  (a)
- ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
-
-CREATE TABLE t2 (
-  a BIGINT(20) NOT NULL,
-  b VARCHAR(128) NOT NULL,
-  c TEXT NOT NULL,
-  PRIMARY KEY  (a,b),
-  KEY idx_t2_b_c (b,c(200)),
-  CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) 
-   ON DELETE CASCADE
- ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
-
-INSERT INTO t1 VALUES (1);
-INSERT INTO t2 VALUES (1, 'bar', 'vbar');
-INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
-INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
-INSERT INTO t2 VALUES (1, 'customer_over', '1');
-
-SELECT * FROM t2 WHERE b = 'customer_over';
-SELECT * FROM t2 WHERE BINARY b = 'customer_over';
-SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
-/* Bang: Empty result set, above was expected: */
-SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
-SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
-
-drop table t2, t1;
-
-#
-# Test optimize on table with open transaction
-#
-
-CREATE TABLE t1 ( a int ) ENGINE=innodb;
-BEGIN;
-INSERT INTO t1 VALUES (1);
-OPTIMIZE TABLE t1;
-DROP TABLE t1;
-
-#
-# Bug #24741 (existing cascade clauses disappear when adding foreign keys)
-#
-
-CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
-
-CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
-  CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
-  ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
-
-ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
-DELETE CASCADE ON UPDATE CASCADE;
-
-SHOW CREATE TABLE t2;
-DROP TABLE t2, t1;
-
-#
-# Bug #25927: Prevent ALTER TABLE ... MODIFY ... NOT NULL on columns
-# for which there is a foreign key constraint ON ... SET NULL.
-#
-
-CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
-CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1);
-INSERT INTO t2 VALUES (1);
-ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
-# mysqltest first does replace_regex, then replace_result
---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
---error 1025
-ALTER TABLE t2 MODIFY a INT NOT NULL;
-DELETE FROM t1;
-DROP TABLE t2,t1;
-
-#
-# Bug #26835: table corruption after delete+insert
-#
-
-CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
-ENGINE=InnoDB;
-INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
-DELETE FROM t1;
-INSERT INTO t1 VALUES ('DDD');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Bug #23313 (AUTO_INCREMENT=# not reported back for InnoDB tables)
-# Bug #21404 (AUTO_INCREMENT value reset when Adding FKEY (or ALTER?))
-#
-
-CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
-AUTO_INCREMENT=42;
-
-INSERT INTO t1 VALUES (0),(347),(0);
-SELECT * FROM t1;
-
-SHOW CREATE TABLE t1;
-
-CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t2 VALUES(42),(347),(348);
-ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
-SHOW CREATE TABLE t1;
-
-DROP TABLE t1,t2;
-
-#
-# Bug #21101 (Prints wrong error message if max row size is too large)
-#
---error 1118
-CREATE TABLE t1 (
-	c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
-	c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
-	c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
-	c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
-	c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
-	c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
-	c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
-	c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
-	) ENGINE = InnoDB;
-
-#
-# Bug #31860 InnoDB assumes AUTOINC values can only be positive.
-#
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1(
-	id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
-	) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-10);
-SELECT * FROM t1;
-#
-# NOTE: The server really needs to be restarted at this point
-# for the test to be useful.  
-#
-# Without the fix InnoDB would trip over an assertion here.
-INSERT INTO t1 VALUES(NULL);
-# The next value should be 1 and not -9 or a -ve number
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# 
-# Bug #21409 Incorrect result returned when in READ-COMMITTED with
-# query_cache ON
-#
-CONNECT (c1,localhost,root,,);
-CONNECT (c2,localhost,root,,);
-CONNECTION c1;
-SET binlog_format='MIXED';
-SET TX_ISOLATION='read-committed';
-SET AUTOCOMMIT=0;
-DROP TABLE IF EXISTS t1, t2;
-CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
-CREATE TABLE t2 LIKE t1;
-SELECT * FROM t2;
-CONNECTION c2;
-SET binlog_format='MIXED';
-SET TX_ISOLATION='read-committed';
-SET AUTOCOMMIT=0;
-INSERT INTO t1 VALUES (1);
-COMMIT;
-CONNECTION c1;
-SELECT * FROM t1 WHERE a=1;
-DISCONNECT c1;
-DISCONNECT c2;
-CONNECT (c1,localhost,root,,);
-CONNECT (c2,localhost,root,,);
-CONNECTION c1;
-SET binlog_format='MIXED';
-SET TX_ISOLATION='read-committed';
-SET AUTOCOMMIT=0;
-SELECT * FROM t2;
-CONNECTION c2;
-SET binlog_format='MIXED';
-SET TX_ISOLATION='read-committed';
-SET AUTOCOMMIT=0;
-INSERT INTO t1 VALUES (2);
-COMMIT;
-CONNECTION c1;
-# The result set below should be the same for both selects
-SELECT * FROM t1 WHERE a=2;
-SELECT * FROM t1 WHERE a=2;
-DROP TABLE t1;
-DROP TABLE t2;
-DISCONNECT c1;
-DISCONNECT c2;
-CONNECTION default;
-
-#
-# Bug #29157 UPDATE, changed rows incorrect
-#
-create table t1 (i int, j int) engine=innodb;
-insert into t1 (i, j) values (1, 1), (2, 2);
---enable_info
-update t1 set j = 2;
---disable_info
-drop table t1;
-
-#
-# Bug #32440 InnoDB free space info does not appear in SHOW TABLE STATUS or
-# I_S
-#
-create table t1 (id int) comment='this is a comment' engine=innodb;
-select table_comment, data_free > 0 as data_free_is_set
-  from information_schema.tables
-  where table_schema='test' and table_name = 't1';
-drop table t1;
-
-#
-# Bug 34920 test
-#
-CONNECTION default;
-CREATE TABLE t1 (
-	c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-	c2 VARCHAR(128) NOT NULL,
-	PRIMARY KEY(c1)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
-
-CREATE TABLE t2 (
-	c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-	c2 INT(10) UNSIGNED DEFAULT NULL,
-	PRIMARY KEY(c1)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
-
-SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
-ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
-SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
-DROP TABLE t2;
-DROP TABLE t1;
-# End 34920 test
-#
-# Bug #29507 TRUNCATE shows to many rows effected
-#
-CONNECTION default;
-CREATE TABLE t1 (c1 int default NULL,
-		 c2 int default NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
---enable_info
-TRUNCATE TABLE t1;
-
-INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
-TRUNCATE TABLE t1;
-
---disable_info
-DROP TABLE t1;
-#
-# Bug#35537 Innodb doesn't increment handler_update and handler_delete.
-#
--- disable_query_log
--- disable_result_log
-
-CONNECT (c1,localhost,root,,);
-
-DROP TABLE IF EXISTS bug35537;
-CREATE TABLE bug35537 (
-  c1 int
-) ENGINE=InnoDB;
-
-INSERT INTO bug35537 VALUES (1);
-
--- enable_result_log
-
-SHOW SESSION STATUS LIKE 'Handler_update%';
-SHOW SESSION STATUS LIKE 'Handler_delete%';
-
-UPDATE bug35537 SET c1 = 2 WHERE c1 = 1;
-DELETE FROM bug35537 WHERE c1 = 2;
-
-SHOW SESSION STATUS LIKE 'Handler_update%';
-SHOW SESSION STATUS LIKE 'Handler_delete%';
-
-DROP TABLE bug35537;
-
-DISCONNECT c1;
-CONNECTION default;
-
-#######################################################################
-#                                                                     #
-# Please, DO NOT TOUCH this file as well as the innodb.result file.   #
-# These files are to be modified ONLY BY INNOBASE guys.               #
-#                                                                     #
-# Use innodb_mysql.[test|result] files instead.                       #
-#                                                                     #
-# If nevertheless you need to make some changes here, please, forward #
-# your commit message To: dev@xxxxxxxxxx Cc: dev-innodb@xxxxxxxxx     #
-# (otherwise your changes may be erased).                             #
-#                                                                     #
-#######################################################################

=== added file 'mysql-test/t/innodb_bug34053.test'
--- a/mysql-test/t/innodb_bug34053.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug34053.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,50 @@
+#
+# Make sure http://bugs.mysql.com/34053 remains fixed.
+#
+
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+SET storage_engine=InnoDB;
+
+# we do not really care about what gets printed, we are only
+# interested in getting success or failure according to our
+# expectations
+-- disable_query_log
+-- disable_result_log
+
+GRANT USAGE ON *.* TO 'shane'@'localhost' IDENTIFIED BY '12345';
+FLUSH PRIVILEGES;
+
+-- connect (con1,localhost,shane,12345,)
+
+-- connection con1
+-- error ER_SPECIFIC_ACCESS_DENIED_ERROR
+CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB;
+-- error ER_SPECIFIC_ACCESS_DENIED_ERROR
+CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB;
+CREATE TABLE innodb_monitorx (a INT) ENGINE=INNODB;
+DROP TABLE innodb_monitorx;
+CREATE TABLE innodb_monito (a INT) ENGINE=INNODB;
+DROP TABLE innodb_monito;
+CREATE TABLE xinnodb_monitor (a INT) ENGINE=INNODB;
+DROP TABLE xinnodb_monitor;
+CREATE TABLE nnodb_monitor (a INT) ENGINE=INNODB;
+DROP TABLE nnodb_monitor;
+
+-- connection default
+CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB;
+CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB;
+
+-- connection con1
+-- error ER_SPECIFIC_ACCESS_DENIED_ERROR
+DROP TABLE innodb_monitor;
+-- error ER_SPECIFIC_ACCESS_DENIED_ERROR
+DROP TABLE innodb_mem_validate;
+
+-- connection default
+DROP TABLE innodb_monitor;
+DROP TABLE innodb_mem_validate;
+DROP USER 'shane'@'localhost';
+
+-- disconnect con1

=== removed file 'mysql-test/t/innodb_bug34053.test'
--- a/mysql-test/t/innodb_bug34053.test	2008-02-22 23:56:34 +0000
+++ b/mysql-test/t/innodb_bug34053.test	1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
-#
-# Make sure http://bugs.mysql.com/34053 remains fixed.
-#
-
--- source include/not_embedded.inc
--- source include/have_innodb.inc
-
-SET storage_engine=InnoDB;
-
-# we do not really care about what gets printed, we are only
-# interested in getting success or failure according to our
-# expectations
--- disable_query_log
--- disable_result_log
-
-GRANT USAGE ON *.* TO 'shane'@'localhost' IDENTIFIED BY '12345';
-FLUSH PRIVILEGES;
-
--- connect (con1,localhost,shane,12345,)
-
--- connection con1
--- error ER_SPECIFIC_ACCESS_DENIED_ERROR
-CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB;
--- error ER_SPECIFIC_ACCESS_DENIED_ERROR
-CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB;
-CREATE TABLE innodb_monitorx (a INT) ENGINE=INNODB;
-DROP TABLE innodb_monitorx;
-CREATE TABLE innodb_monito (a INT) ENGINE=INNODB;
-DROP TABLE innodb_monito;
-CREATE TABLE xinnodb_monitor (a INT) ENGINE=INNODB;
-DROP TABLE xinnodb_monitor;
-CREATE TABLE nnodb_monitor (a INT) ENGINE=INNODB;
-DROP TABLE nnodb_monitor;
-
--- connection default
-CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB;
-CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB;
-
--- connection con1
--- error ER_SPECIFIC_ACCESS_DENIED_ERROR
-DROP TABLE innodb_monitor;
--- error ER_SPECIFIC_ACCESS_DENIED_ERROR
-DROP TABLE innodb_mem_validate;
-
--- connection default
-DROP TABLE innodb_monitor;
-DROP TABLE innodb_mem_validate;
-DROP USER 'shane'@'localhost';
-
--- disconnect con1

=== added file 'mysql-test/t/innodb_bug34300.test'
--- a/mysql-test/t/innodb_bug34300.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug34300.test	2009-06-11 12:53:26 +0000
@@ -0,0 +1,36 @@
+#
+# Bug#34300 Tinyblob & tinytext fields currupted after export/import and alter in 5.1
+# http://bugs.mysql.com/34300
+#
+
+-- source include/have_innodb.inc
+
+-- disable_query_log
+-- disable_result_log
+
+# set packet size and reconnect 
+SET @save_max_allowed_packet=@@global.max_allowed_packet;
+SET @@global.max_allowed_packet=16777216;
+--connect (newconn, localhost, root,,)
+
+DROP TABLE IF EXISTS bug34300;
+CREATE TABLE bug34300 (
+  f4 TINYTEXT,
+  f6 MEDIUMTEXT,
+  f8 TINYBLOB
+) ENGINE=InnoDB;
+
+INSERT INTO bug34300 VALUES ('xxx', repeat('a', 8459264), 'zzz');
+
+-- enable_result_log
+
+SELECT f4, f8 FROM bug34300;
+
+ALTER TABLE bug34300 ADD COLUMN (f10 INT);
+
+SELECT f4, f8 FROM bug34300;
+
+DROP TABLE bug34300;
+disconnect newconn;
+connection default;
+SET @@global.max_allowed_packet=@save_max_allowed_packet;

=== removed file 'mysql-test/t/innodb_bug34300.test'
--- a/mysql-test/t/innodb_bug34300.test	2009-02-19 09:01:25 +0000
+++ b/mysql-test/t/innodb_bug34300.test	1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
-#
-# Bug#34300 Tinyblob & tinytext fields currupted after export/import and alter in 5.1
-# http://bugs.mysql.com/34300
-#
-
--- source include/have_innodb.inc
-
--- disable_query_log
--- disable_result_log
-
-# set packet size and reconnect 
-SET @@global.max_allowed_packet=16777216;
---connect (newconn, localhost, root,,)
-
-DROP TABLE IF EXISTS bug34300;
-CREATE TABLE bug34300 (
-  f4 TINYTEXT,
-  f6 MEDIUMTEXT,
-  f8 TINYBLOB
-) ENGINE=InnoDB;
-
-INSERT INTO bug34300 VALUES ('xxx', repeat('a', 8459264), 'zzz');
-
--- enable_query_log
--- enable_result_log
-
-SELECT f4, f8 FROM bug34300;
-
-ALTER TABLE bug34300 ADD COLUMN (f10 INT);
-
-SELECT f4, f8 FROM bug34300;
-
-DROP TABLE bug34300;
-
-disconnect newconn;
-connection default;
---disable_result_log
---disable_query_log
-SET @@global.max_allowed_packet=default;
---enable_result_log
---enable_query_log

=== added file 'mysql-test/t/innodb_bug35220.test'
--- a/mysql-test/t/innodb_bug35220.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug35220.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,16 @@
+#
+# Bug#35220 ALTER TABLE too picky on reserved word "foreign"
+# http://bugs.mysql.com/35220
+#
+
+-- source include/have_innodb.inc
+
+SET storage_engine=InnoDB;
+
+# we care only that the following SQL commands do not produce errors
+-- disable_query_log
+-- disable_result_log
+
+CREATE TABLE bug35220 (foreign_col INT, dummy_cant_delete_all_columns INT);
+ALTER TABLE bug35220 DROP foreign_col;
+DROP TABLE bug35220;

=== removed file 'mysql-test/t/innodb_bug35220.test'
--- a/mysql-test/t/innodb_bug35220.test	2008-08-08 00:25:24 +0000
+++ b/mysql-test/t/innodb_bug35220.test	1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
-#
-# Bug#35220 ALTER TABLE too picky on reserved word "foreign"
-# http://bugs.mysql.com/35220
-#
-
--- source include/have_innodb.inc
-
-SET storage_engine=InnoDB;
-
-# we care only that the following SQL commands do not produce errors
--- disable_query_log
--- disable_result_log
-
-CREATE TABLE bug35220 (foreign_col INT, dummy_cant_delete_all_columns INT);
-ALTER TABLE bug35220 DROP foreign_col;
-DROP TABLE bug35220;

=== added file 'mysql-test/t/innodb_bug36169.test'
--- a/mysql-test/t/innodb_bug36169.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug36169.test	2009-06-11 12:53:26 +0000
@@ -0,0 +1,1162 @@
+#
+# Bug#36169 create innodb compressed table with too large row size crashed
+# http://bugs.mysql.com/36169
+#
+
+-- source include/have_innodb.inc
+
+SET @save_innodb_file_format=@@global.innodb_file_format;
+SET @save_innodb_file_format_check=@@global.innodb_file_format_check;
+SET @save_innodb_file_per_table=@@global.innodb_file_per_table;
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;
+
+#
+# The following is copied from http://bugs.mysql.com/36169
+# (http://bugs.mysql.com/file.php?id=9121)
+# Probably it can be simplified but that is not obvious.
+#
+
+# we care only that the following SQL commands do produce errors
+# as expected and do not crash the server
+-- disable_query_log
+-- disable_result_log
+
+# Generating 10 tables
+# Creating a table with 94 columns and 24 indexes
+DROP TABLE IF EXISTS `table0`;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE IF NOT EXISTS `table0`
+(`col0` BOOL,
+`col1` BOOL,
+`col2` TINYINT,
+`col3` DATE,
+`col4` TIME,
+`col5` SET ('test1','test2','test3'),
+`col6` TIME,
+`col7` TEXT,
+`col8` DECIMAL,
+`col9` SET ('test1','test2','test3'),
+`col10` FLOAT,
+`col11` DOUBLE PRECISION,
+`col12` ENUM ('test1','test2','test3'),
+`col13` TINYBLOB,
+`col14` YEAR,
+`col15` SET ('test1','test2','test3'),
+`col16` NUMERIC,
+`col17` NUMERIC,
+`col18` BLOB,
+`col19` DATETIME,
+`col20` DOUBLE PRECISION,
+`col21` DECIMAL,
+`col22` DATETIME,
+`col23` NUMERIC,
+`col24` NUMERIC,
+`col25` LONGTEXT,
+`col26` TINYBLOB,
+`col27` TIME,
+`col28` TINYBLOB,
+`col29` ENUM ('test1','test2','test3'),
+`col30` SMALLINT,
+`col31` REAL,
+`col32` FLOAT,
+`col33` CHAR (175),
+`col34` TINYTEXT,
+`col35` TINYTEXT,
+`col36` TINYBLOB,
+`col37` TINYBLOB,
+`col38` TINYTEXT,
+`col39` MEDIUMBLOB,
+`col40` TIMESTAMP,
+`col41` DOUBLE,
+`col42` SMALLINT,
+`col43` LONGBLOB,
+`col44` VARCHAR (80),
+`col45` MEDIUMTEXT,
+`col46` NUMERIC,
+`col47` BIGINT,
+`col48` DATE,
+`col49` TINYBLOB,
+`col50` DATE,
+`col51` BOOL,
+`col52` MEDIUMINT,
+`col53` FLOAT,
+`col54` TINYBLOB,
+`col55` LONGTEXT,
+`col56` SMALLINT,
+`col57` ENUM ('test1','test2','test3'),
+`col58` DATETIME,
+`col59` MEDIUMTEXT,
+`col60` VARCHAR (232),
+`col61` NUMERIC,
+`col62` YEAR,
+`col63` SMALLINT,
+`col64` TIMESTAMP,
+`col65` BLOB,
+`col66` LONGBLOB,
+`col67` INT,
+`col68` LONGTEXT,
+`col69` ENUM ('test1','test2','test3'),
+`col70` INT,
+`col71` TIME,
+`col72` TIMESTAMP,
+`col73` TIMESTAMP,
+`col74` VARCHAR (170),
+`col75` SET ('test1','test2','test3'),
+`col76` TINYBLOB,
+`col77` BIGINT,
+`col78` NUMERIC,
+`col79` DATETIME,
+`col80` YEAR,
+`col81` NUMERIC,
+`col82` LONGBLOB,
+`col83` TEXT,
+`col84` CHAR (83),
+`col85` DECIMAL,
+`col86` FLOAT,
+`col87` INT,
+`col88` VARCHAR (145),
+`col89` DATE,
+`col90` DECIMAL,
+`col91` DECIMAL,
+`col92` MEDIUMBLOB,
+`col93` TIME,
+KEY `idx0` (`col69`,`col90`,`col8`),
+KEY `idx1` (`col60`),
+KEY `idx2` (`col60`,`col70`,`col74`),
+KEY `idx3` (`col22`,`col32`,`col72`,`col30`),
+KEY `idx4` (`col29`),
+KEY `idx5` (`col19`,`col45`(143)),
+KEY `idx6` (`col46`,`col48`,`col5`,`col39`(118)),
+KEY `idx7` (`col48`,`col61`),
+KEY `idx8` (`col93`),
+KEY `idx9` (`col31`),
+KEY `idx10` (`col30`,`col21`),
+KEY `idx11` (`col67`),
+KEY `idx12` (`col44`,`col6`,`col8`,`col38`(226)),
+KEY `idx13` (`col71`,`col41`,`col15`,`col49`(88)),
+KEY `idx14` (`col78`),
+KEY `idx15` (`col63`,`col67`,`col64`),
+KEY `idx16` (`col17`,`col86`),
+KEY `idx17` (`col77`,`col56`,`col10`,`col55`(24)),
+KEY `idx18` (`col62`),
+KEY `idx19` (`col31`,`col57`,`col56`,`col53`),
+KEY `idx20` (`col46`),
+KEY `idx21` (`col83`(54)),
+KEY `idx22` (`col51`,`col7`(120)),
+KEY `idx23` (`col7`(163),`col31`,`col71`,`col14`)
+)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
+
+# Creating a table with 10 columns and 32 indexes
+DROP TABLE IF EXISTS `table1`;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE IF NOT EXISTS `table1`
+(`col0` CHAR (113),
+`col1` FLOAT,
+`col2` BIGINT,
+`col3` DECIMAL,
+`col4` BLOB,
+`col5` LONGTEXT,
+`col6` SET ('test1','test2','test3'),
+`col7` BIGINT,
+`col8` BIGINT,
+`col9` TINYBLOB,
+KEY `idx0` (`col5`(101),`col7`,`col8`),
+KEY `idx1` (`col8`),
+KEY `idx2` (`col4`(177),`col9`(126),`col6`,`col3`),
+KEY `idx3` (`col5`(160)),
+KEY `idx4` (`col9`(242)),
+KEY `idx5` (`col4`(139),`col2`,`col3`),
+KEY `idx6` (`col7`),
+KEY `idx7` (`col6`,`col2`,`col0`,`col3`),
+KEY `idx8` (`col9`(66)),
+KEY `idx9` (`col5`(253)),
+KEY `idx10` (`col1`,`col7`,`col2`),
+KEY `idx11` (`col9`(242),`col0`,`col8`,`col5`(163)),
+KEY `idx12` (`col8`),
+KEY `idx13` (`col0`,`col9`(37)),
+KEY `idx14` (`col0`),
+KEY `idx15` (`col5`(111)),
+KEY `idx16` (`col8`,`col0`,`col5`(13)),
+KEY `idx17` (`col4`(139)),
+KEY `idx18` (`col5`(189),`col2`,`col3`,`col9`(136)),
+KEY `idx19` (`col0`,`col3`,`col1`,`col8`),
+KEY `idx20` (`col8`),
+KEY `idx21` (`col0`,`col7`,`col9`(227),`col3`),
+KEY `idx22` (`col0`),
+KEY `idx23` (`col2`),
+KEY `idx24` (`col3`),
+KEY `idx25` (`col2`,`col3`),
+KEY `idx26` (`col0`),
+KEY `idx27` (`col5`(254)),
+KEY `idx28` (`col3`),
+KEY `idx29` (`col3`),
+KEY `idx30` (`col7`,`col3`,`col0`,`col4`(220)),
+KEY `idx31` (`col4`(1),`col0`)
+)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
+
+# Creating a table with 141 columns and 18 indexes
+DROP TABLE IF EXISTS `table2`;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE IF NOT EXISTS `table2`
+(`col0` BOOL,
+`col1` MEDIUMINT,
+`col2` VARCHAR (209),
+`col3` MEDIUMBLOB,
+`col4` CHAR (13),
+`col5` DOUBLE,
+`col6` TINYTEXT,
+`col7` REAL,
+`col8` SMALLINT,
+`col9` BLOB,
+`col10` TINYINT,
+`col11` DECIMAL,
+`col12` BLOB,
+`col13` DECIMAL,
+`col14` LONGBLOB,
+`col15` SMALLINT,
+`col16` LONGBLOB,
+`col17` TINYTEXT,
+`col18` FLOAT,
+`col19` CHAR (78),
+`col20` MEDIUMTEXT,
+`col21` SET ('test1','test2','test3'),
+`col22` MEDIUMINT,
+`col23` INT,
+`col24` MEDIUMBLOB,
+`col25` ENUM ('test1','test2','test3'),
+`col26` TINYBLOB,
+`col27` VARCHAR (116),
+`col28` TIMESTAMP,
+`col29` BLOB,
+`col30` SMALLINT,
+`col31` DOUBLE PRECISION,
+`col32` DECIMAL,
+`col33` DECIMAL,
+`col34` TEXT,
+`col35` MEDIUMINT,
+`col36` MEDIUMINT,
+`col37` BIGINT,
+`col38` VARCHAR (253),
+`col39` TINYBLOB,
+`col40` MEDIUMBLOB,
+`col41` BIGINT,
+`col42` DOUBLE,
+`col43` TEXT,
+`col44` BLOB,
+`col45` TIME,
+`col46` MEDIUMINT,
+`col47` DOUBLE PRECISION,
+`col48` SET ('test1','test2','test3'),
+`col49` DOUBLE PRECISION,
+`col50` VARCHAR (97),
+`col51` TEXT,
+`col52` NUMERIC,
+`col53` ENUM ('test1','test2','test3'),
+`col54` MEDIUMTEXT,
+`col55` MEDIUMINT,
+`col56` DATETIME,
+`col57` DATETIME,
+`col58` MEDIUMTEXT,
+`col59` CHAR (244),
+`col60` LONGBLOB,
+`col61` MEDIUMBLOB,
+`col62` DOUBLE,
+`col63` SMALLINT,
+`col64` BOOL,
+`col65` SMALLINT,
+`col66` VARCHAR (212),
+`col67` TIME,
+`col68` REAL,
+`col69` BOOL,
+`col70` BIGINT,
+`col71` DATE,
+`col72` TINYINT,
+`col73` ENUM ('test1','test2','test3'),
+`col74` DATE,
+`col75` TIME,
+`col76` DATETIME,
+`col77` BOOL,
+`col78` TINYTEXT,
+`col79` MEDIUMINT,
+`col80` NUMERIC,
+`col81` LONGTEXT,
+`col82` SET ('test1','test2','test3'),
+`col83` DOUBLE PRECISION,
+`col84` NUMERIC,
+`col85` VARCHAR (184),
+`col86` DOUBLE PRECISION,
+`col87` MEDIUMTEXT,
+`col88` MEDIUMBLOB,
+`col89` BOOL,
+`col90` SMALLINT,
+`col91` TINYINT,
+`col92` ENUM ('test1','test2','test3'),
+`col93` BOOL,
+`col94` TIMESTAMP,
+`col95` BOOL,
+`col96` MEDIUMTEXT,
+`col97` DECIMAL,
+`col98` BOOL,
+`col99` DECIMAL,
+`col100` MEDIUMINT,
+`col101` DOUBLE PRECISION,
+`col102` TINYINT,
+`col103` BOOL,
+`col104` MEDIUMINT,
+`col105` DECIMAL,
+`col106` NUMERIC,
+`col107` TIMESTAMP,
+`col108` MEDIUMBLOB,
+`col109` TINYBLOB,
+`col110` SET ('test1','test2','test3'),
+`col111` YEAR,
+`col112` TIMESTAMP,
+`col113` CHAR (201),
+`col114` BOOL,
+`col115` TINYINT,
+`col116` DOUBLE,
+`col117` TINYINT,
+`col118` TIMESTAMP,
+`col119` SET ('test1','test2','test3'),
+`col120` SMALLINT,
+`col121` TINYBLOB,
+`col122` TIMESTAMP,
+`col123` BLOB,
+`col124` DATE,
+`col125` SMALLINT,
+`col126` ENUM ('test1','test2','test3'),
+`col127` MEDIUMBLOB,
+`col128` DOUBLE PRECISION,
+`col129` REAL,
+`col130` VARCHAR (159),
+`col131` MEDIUMBLOB,
+`col132` BIGINT,
+`col133` INT,
+`col134` SET ('test1','test2','test3'),
+`col135` CHAR (198),
+`col136` SET ('test1','test2','test3'),
+`col137` MEDIUMTEXT,
+`col138` SMALLINT,
+`col139` BLOB,
+`col140` LONGBLOB,
+KEY `idx0` (`col14`(139),`col24`(208),`col38`,`col35`),
+KEY `idx1` (`col48`,`col118`,`col29`(131),`col100`),
+KEY `idx2` (`col86`,`col67`,`col43`(175)),
+KEY `idx3` (`col19`),
+KEY `idx4` (`col40`(220),`col67`),
+KEY `idx5` (`col99`,`col56`),
+KEY `idx6` (`col68`,`col28`,`col137`(157)),
+KEY `idx7` (`col51`(160),`col99`,`col45`,`col39`(9)),
+KEY `idx8` (`col15`,`col52`,`col90`,`col94`),
+KEY `idx9` (`col24`(3),`col139`(248),`col108`(118),`col41`),
+KEY `idx10` (`col36`,`col92`,`col114`),
+KEY `idx11` (`col115`,`col9`(116)),
+KEY `idx12` (`col130`,`col93`,`col134`),
+KEY `idx13` (`col123`(65)),
+KEY `idx14` (`col44`(90),`col86`,`col119`),
+KEY `idx15` (`col69`),
+KEY `idx16` (`col132`,`col81`(118),`col18`),
+KEY `idx17` (`col24`(250),`col7`,`col92`,`col45`)
+)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
+
+# Creating a table with 199 columns and 1 indexes
+DROP TABLE IF EXISTS `table3`;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE IF NOT EXISTS `table3`
+(`col0` SMALLINT,
+`col1` SET ('test1','test2','test3'),
+`col2` TINYTEXT,
+`col3` DOUBLE,
+`col4` NUMERIC,
+`col5` DATE,
+`col6` BIGINT,
+`col7` DOUBLE,
+`col8` TEXT,
+`col9` INT,
+`col10` REAL,
+`col11` TINYINT,
+`col12` NUMERIC,
+`col13` NUMERIC,
+`col14` TIME,
+`col15` DOUBLE,
+`col16` REAL,
+`col17` MEDIUMBLOB,
+`col18` YEAR,
+`col19` TINYTEXT,
+`col20` YEAR,
+`col21` CHAR (250),
+`col22` TINYINT,
+`col23` TINYINT,
+`col24` SMALLINT,
+`col25` DATETIME,
+`col26` MEDIUMINT,
+`col27` LONGBLOB,
+`col28` VARCHAR (106),
+`col29` FLOAT,
+`col30` MEDIUMTEXT,
+`col31` TINYBLOB,
+`col32` BIGINT,
+`col33` YEAR,
+`col34` REAL,
+`col35` MEDIUMBLOB,
+`col36` LONGTEXT,
+`col37` LONGBLOB,
+`col38` BIGINT,
+`col39` FLOAT,
+`col40` TIME,
+`col41` DATETIME,
+`col42` BOOL,
+`col43` BIGINT,
+`col44` SMALLINT,
+`col45` TIME,
+`col46` DOUBLE PRECISION,
+`col47` TIME,
+`col48` TINYTEXT,
+`col49` DOUBLE PRECISION,
+`col50` BIGINT,
+`col51` NUMERIC,
+`col52` TINYBLOB,
+`col53` DATE,
+`col54` DECIMAL,
+`col55` SMALLINT,
+`col56` TINYTEXT,
+`col57` ENUM ('test1','test2','test3'),
+`col58` YEAR,
+`col59` TIME,
+`col60` TINYINT,
+`col61` DECIMAL,
+`col62` DOUBLE,
+`col63` DATE,
+`col64` LONGTEXT,
+`col65` DOUBLE,
+`col66` VARCHAR (88),
+`col67` MEDIUMTEXT,
+`col68` DATE,
+`col69` MEDIUMINT,
+`col70` DECIMAL,
+`col71` MEDIUMTEXT,
+`col72` LONGTEXT,
+`col73` REAL,
+`col74` DOUBLE,
+`col75` TIME,
+`col76` DATE,
+`col77` DECIMAL,
+`col78` MEDIUMBLOB,
+`col79` NUMERIC,
+`col80` BIGINT,
+`col81` YEAR,
+`col82` SMALLINT,
+`col83` MEDIUMINT,
+`col84` TINYINT,
+`col85` MEDIUMBLOB,
+`col86` TIME,
+`col87` MEDIUMBLOB,
+`col88` LONGTEXT,
+`col89` BOOL,
+`col90` BLOB,
+`col91` LONGBLOB,
+`col92` YEAR,
+`col93` BLOB,
+`col94` INT,
+`col95` TINYTEXT,
+`col96` TINYINT,
+`col97` DECIMAL,
+`col98` ENUM ('test1','test2','test3'),
+`col99` MEDIUMINT,
+`col100` TINYINT,
+`col101` MEDIUMBLOB,
+`col102` TINYINT,
+`col103` SET ('test1','test2','test3'),
+`col104` TIMESTAMP,
+`col105` TEXT,
+`col106` DATETIME,
+`col107` MEDIUMTEXT,
+`col108` CHAR (220),
+`col109` TIME,
+`col110` VARCHAR (131),
+`col111` DECIMAL,
+`col112` FLOAT,
+`col113` SMALLINT,
+`col114` BIGINT,
+`col115` LONGBLOB,
+`col116` SET ('test1','test2','test3'),
+`col117` ENUM ('test1','test2','test3'),
+`col118` BLOB,
+`col119` MEDIUMTEXT,
+`col120` SET ('test1','test2','test3'),
+`col121` DATETIME,
+`col122` FLOAT,
+`col123` VARCHAR (242),
+`col124` YEAR,
+`col125` MEDIUMBLOB,
+`col126` TIME,
+`col127` BOOL,
+`col128` TINYBLOB,
+`col129` DOUBLE,
+`col130` TINYINT,
+`col131` BIGINT,
+`col132` SMALLINT,
+`col133` INT,
+`col134` DOUBLE PRECISION,
+`col135` MEDIUMBLOB,
+`col136` SET ('test1','test2','test3'),
+`col137` TINYTEXT,
+`col138` DOUBLE PRECISION,
+`col139` NUMERIC,
+`col140` BLOB,
+`col141` SET ('test1','test2','test3'),
+`col142` INT,
+`col143` VARCHAR (26),
+`col144` BLOB,
+`col145` REAL,
+`col146` SET ('test1','test2','test3'),
+`col147` LONGBLOB,
+`col148` TEXT,
+`col149` BLOB,
+`col150` CHAR (189),
+`col151` LONGTEXT,
+`col152` INT,
+`col153` FLOAT,
+`col154` LONGTEXT,
+`col155` DATE,
+`col156` LONGBLOB,
+`col157` TINYBLOB,
+`col158` REAL,
+`col159` DATE,
+`col160` TIME,
+`col161` YEAR,
+`col162` DOUBLE,
+`col163` VARCHAR (90),
+`col164` FLOAT,
+`col165` NUMERIC,
+`col166` ENUM ('test1','test2','test3'),
+`col167` DOUBLE PRECISION,
+`col168` DOUBLE PRECISION,
+`col169` TINYBLOB,
+`col170` TIME,
+`col171` SMALLINT,
+`col172` TINYTEXT,
+`col173` SMALLINT,
+`col174` DOUBLE,
+`col175` VARCHAR (14),
+`col176` VARCHAR (90),
+`col177` REAL,
+`col178` MEDIUMINT,
+`col179` TINYBLOB,
+`col180` FLOAT,
+`col181` TIMESTAMP,
+`col182` REAL,
+`col183` DOUBLE PRECISION,
+`col184` BIGINT,
+`col185` INT,
+`col186` MEDIUMTEXT,
+`col187` TIME,
+`col188` FLOAT,
+`col189` TIME,
+`col190` INT,
+`col191` FLOAT,
+`col192` MEDIUMINT,
+`col193` TINYINT,
+`col194` MEDIUMTEXT,
+`col195` DATE,
+`col196` TIME,
+`col197` YEAR,
+`col198` CHAR (206),
+KEY `idx0` (`col39`,`col23`)
+)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
+
+# Creating a table with 133 columns and 16 indexes
+DROP TABLE IF EXISTS `table4`;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE IF NOT EXISTS `table4`
+(`col0` VARCHAR (60),
+`col1` NUMERIC,
+`col2` LONGTEXT,
+`col3` MEDIUMTEXT,
+`col4` LONGTEXT,
+`col5` LONGBLOB,
+`col6` LONGBLOB,
+`col7` DATETIME,
+`col8` TINYTEXT,
+`col9` BLOB,
+`col10` BOOL,
+`col11` BIGINT,
+`col12` TEXT,
+`col13` VARCHAR (213),
+`col14` TINYBLOB,
+`col15` BOOL,
+`col16` MEDIUMTEXT,
+`col17` DOUBLE,
+`col18` TEXT,
+`col19` BLOB,
+`col20` SET ('test1','test2','test3'),
+`col21` TINYINT,
+`col22` DATETIME,
+`col23` TINYINT,
+`col24` ENUM ('test1','test2','test3'),
+`col25` REAL,
+`col26` BOOL,
+`col27` FLOAT,
+`col28` LONGBLOB,
+`col29` DATETIME,
+`col30` FLOAT,
+`col31` SET ('test1','test2','test3'),
+`col32` LONGBLOB,
+`col33` NUMERIC,
+`col34` YEAR,
+`col35` VARCHAR (146),
+`col36` BIGINT,
+`col37` DATETIME,
+`col38` DATE,
+`col39` SET ('test1','test2','test3'),
+`col40` CHAR (112),
+`col41` FLOAT,
+`col42` YEAR,
+`col43` TIME,
+`col44` DOUBLE,
+`col45` NUMERIC,
+`col46` FLOAT,
+`col47` DECIMAL,
+`col48` BIGINT,
+`col49` DECIMAL,
+`col50` YEAR,
+`col51` MEDIUMTEXT,
+`col52` LONGBLOB,
+`col53` SET ('test1','test2','test3'),
+`col54` BLOB,
+`col55` FLOAT,
+`col56` REAL,
+`col57` REAL,
+`col58` TEXT,
+`col59` MEDIUMBLOB,
+`col60` INT,
+`col61` INT,
+`col62` DATE,
+`col63` TEXT,
+`col64` DATE,
+`col65` ENUM ('test1','test2','test3'),
+`col66` DOUBLE PRECISION,
+`col67` TINYTEXT,
+`col68` TINYBLOB,
+`col69` FLOAT,
+`col70` BLOB,
+`col71` DATETIME,
+`col72` DOUBLE,
+`col73` LONGTEXT,
+`col74` TIME,
+`col75` DATETIME,
+`col76` VARCHAR (122),
+`col77` MEDIUMTEXT,
+`col78` MEDIUMTEXT,
+`col79` BOOL,
+`col80` LONGTEXT,
+`col81` TINYTEXT,
+`col82` NUMERIC,
+`col83` DOUBLE PRECISION,
+`col84` DATE,
+`col85` YEAR,
+`col86` BLOB,
+`col87` TINYTEXT,
+`col88` DOUBLE PRECISION,
+`col89` MEDIUMINT,
+`col90` MEDIUMTEXT,
+`col91` NUMERIC,
+`col92` DATETIME,
+`col93` NUMERIC,
+`col94` SET ('test1','test2','test3'),
+`col95` TINYTEXT,
+`col96` SET ('test1','test2','test3'),
+`col97` YEAR,
+`col98` MEDIUMINT,
+`col99` TEXT,
+`col100` TEXT,
+`col101` TIME,
+`col102` VARCHAR (225),
+`col103` TINYTEXT,
+`col104` TEXT,
+`col105` MEDIUMTEXT,
+`col106` TINYINT,
+`col107` TEXT,
+`col108` LONGBLOB,
+`col109` LONGTEXT,
+`col110` TINYTEXT,
+`col111` CHAR (56),
+`col112` YEAR,
+`col113` ENUM ('test1','test2','test3'),
+`col114` TINYBLOB,
+`col115` DATETIME,
+`col116` DATE,
+`col117` TIME,
+`col118` MEDIUMTEXT,
+`col119` DOUBLE PRECISION,
+`col120` FLOAT,
+`col121` TIMESTAMP,
+`col122` MEDIUMINT,
+`col123` YEAR,
+`col124` DATE,
+`col125` TEXT,
+`col126` FLOAT,
+`col127` TINYTEXT,
+`col128` BOOL,
+`col129` NUMERIC,
+`col130` TIMESTAMP,
+`col131` INT,
+`col132` MEDIUMBLOB,
+KEY `idx0` (`col130`),
+KEY `idx1` (`col30`,`col55`,`col19`(31)),
+KEY `idx2` (`col104`(186)),
+KEY `idx3` (`col131`),
+KEY `idx4` (`col64`,`col93`,`col2`(11)),
+KEY `idx5` (`col34`,`col121`,`col22`),
+KEY `idx6` (`col33`,`col55`,`col83`),
+KEY `idx7` (`col17`,`col87`(245),`col99`(17)),
+KEY `idx8` (`col65`,`col120`),
+KEY `idx9` (`col82`),
+KEY `idx10` (`col9`(72)),
+KEY `idx11` (`col88`),
+KEY `idx12` (`col128`,`col9`(200),`col71`,`col66`),
+KEY `idx13` (`col77`(126)),
+KEY `idx14` (`col105`(26),`col13`,`col117`),
+KEY `idx15` (`col4`(246),`col130`,`col115`,`col3`(141))
+)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
+
+# Creating a table with 176 columns and 13 indexes
+DROP TABLE IF EXISTS `table5`;
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE IF NOT EXISTS `table5`
+(`col0` MEDIUMTEXT,
+`col1` VARCHAR (90),
+`col2` TINYTEXT,
+`col3` TIME,
+`col4` BOOL,
+`col5` TINYTEXT,
+`col6` BOOL,
+`col7` TIMESTAMP,
+`col8` TINYBLOB,
+`col9` TINYINT,
+`col10` YEAR,
+`col11` SET ('test1','test2','test3'),
+`col12` TEXT,
+`col13` CHAR (248),
+`col14` BIGINT,
+`col15` TEXT,
+`col16` TINYINT,
+`col17` NUMERIC,
+`col18` SET ('test1','test2','test3'),
+`col19` LONGBLOB,
+`col20` FLOAT,
+`col21` INT,
+`col22` TEXT,
+`col23` BOOL,
+`col24` DECIMAL,
+`col25` DOUBLE PRECISION,
+`col26` FLOAT,
+`col27` TINYBLOB,
+`col28` NUMERIC,
+`col29` MEDIUMBLOB,
+`col30` DATE,
+`col31` LONGTEXT,
+`col32` DATE,
+`col33` FLOAT,
+`col34` BIGINT,
+`col35` TINYTEXT,
+`col36` MEDIUMTEXT,
+`col37` TIME,
+`col38` INT,
+`col39` TINYINT,
+`col40` SET ('test1','test2','test3'),
+`col41` CHAR (130),
+`col42` SMALLINT,
+`col43` INT,
+`col44` MEDIUMTEXT,
+`col45` VARCHAR (126),
+`col46` INT,
+`col47` DOUBLE PRECISION,
+`col48` BIGINT,
+`col49` MEDIUMTEXT,
+`col50` TINYBLOB,
+`col51` MEDIUMINT,
+`col52` TEXT,
+`col53` VARCHAR (208),
+`col54` VARCHAR (207),
+`col55` NUMERIC,
+`col56` DATETIME,
+`col57` ENUM ('test1','test2','test3'),
+`col58` NUMERIC,
+`col59` TINYBLOB,
+`col60` VARCHAR (73),
+`col61` MEDIUMTEXT,
+`col62` TINYBLOB,
+`col63` DATETIME,
+`col64` NUMERIC,
+`col65` MEDIUMINT,
+`col66` DATETIME,
+`col67` NUMERIC,
+`col68` TINYINT,
+`col69` VARCHAR (58),
+`col70` DECIMAL,
+`col71` MEDIUMTEXT,
+`col72` DATE,
+`col73` TIME,
+`col74` DOUBLE PRECISION,
+`col75` DECIMAL,
+`col76` MEDIUMBLOB,
+`col77` REAL,
+`col78` YEAR,
+`col79` YEAR,
+`col80` LONGBLOB,
+`col81` BLOB,
+`col82` BIGINT,
+`col83` ENUM ('test1','test2','test3'),
+`col84` NUMERIC,
+`col85` SET ('test1','test2','test3'),
+`col86` MEDIUMTEXT,
+`col87` LONGBLOB,
+`col88` TIME,
+`col89` ENUM ('test1','test2','test3'),
+`col90` DECIMAL,
+`col91` FLOAT,
+`col92` DATETIME,
+`col93` TINYTEXT,
+`col94` TIMESTAMP,
+`col95` TIMESTAMP,
+`col96` TEXT,
+`col97` REAL,
+`col98` VARCHAR (198),
+`col99` TIME,
+`col100` TINYINT,
+`col101` BIGINT,
+`col102` LONGBLOB,
+`col103` LONGBLOB,
+`col104` MEDIUMINT,
+`col105` MEDIUMTEXT,
+`col106` TIMESTAMP,
+`col107` SMALLINT,
+`col108` NUMERIC,
+`col109` DECIMAL,
+`col110` FLOAT,
+`col111` DECIMAL,
+`col112` REAL,
+`col113` TINYTEXT,
+`col114` FLOAT,
+`col115` VARCHAR (7),
+`col116` LONGTEXT,
+`col117` DATE,
+`col118` BIGINT,
+`col119` TEXT,
+`col120` BIGINT,
+`col121` BLOB,
+`col122` CHAR (110),
+`col123` NUMERIC,
+`col124` MEDIUMBLOB,
+`col125` NUMERIC,
+`col126` NUMERIC,
+`col127` BOOL,
+`col128` TIME,
+`col129` TINYBLOB,
+`col130` TINYBLOB,
+`col131` DATE,
+`col132` INT,
+`col133` VARCHAR (123),
+`col134` CHAR (238),
+`col135` VARCHAR (225),
+`col136` LONGTEXT,
+`col137` LONGBLOB,
+`col138` REAL,
+`col139` TINYBLOB,
+`col140` DATETIME,
+`col141` TINYTEXT,
+`col142` LONGBLOB,
+`col143` BIGINT,
+`col144` VARCHAR (236),
+`col145` TEXT,
+`col146` YEAR,
+`col147` DECIMAL,
+`col148` TEXT,
+`col149` MEDIUMBLOB,
+`col150` TINYINT,
+`col151` BOOL,
+`col152` VARCHAR (72),
+`col153` INT,
+`col154` VARCHAR (165),
+`col155` TINYINT,
+`col156` MEDIUMTEXT,
+`col157` DOUBLE PRECISION,
+`col158` TIME,
+`col159` MEDIUMBLOB,
+`col160` LONGBLOB,
+`col161` DATETIME,
+`col162` DOUBLE PRECISION,
+`col163` BLOB,
+`col164` ENUM ('test1','test2','test3'),
+`col165` TIMESTAMP,
+`col166` DATE,
+`col167` TINYBLOB,
+`col168` TINYBLOB,
+`col169` LONGBLOB,
+`col170` DATETIME,
+`col171` BIGINT,
+`col172` VARCHAR (30),
+`col173` LONGTEXT,
+`col174` TIME,
+`col175` FLOAT,
+KEY `idx0` (`col16`,`col156`(139),`col97`,`col120`),
+KEY `idx1` (`col24`,`col0`(108)),
+KEY `idx2` (`col117`,`col173`(34),`col132`,`col82`),
+KEY `idx3` (`col2`(86)),
+KEY `idx4` (`col2`(43)),
+KEY `idx5` (`col83`,`col35`(87),`col111`),
+KEY `idx6` (`col6`,`col134`,`col92`),
+KEY `idx7` (`col56`),
+KEY `idx8` (`col30`,`col53`,`col129`(66)),
+KEY `idx9` (`col53`,`col113`(211),`col32`,`col15`(75)),
+KEY `idx10` (`col34`),
+KEY `idx11` (`col126`),
+KEY `idx12` (`col24`)
+)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
+
+# Creating a table with 179 columns and 46 indexes
+DROP TABLE IF EXISTS `table6`;
+-- error ER_TOO_BIG_ROWSIZE
+--error ER_TOO_BIG_ROWSIZE
+CREATE TABLE IF NOT EXISTS `table6`
+(`col0` ENUM ('test1','test2','test3'),
+`col1` MEDIUMBLOB,
+`col2` MEDIUMBLOB,
+`col3` DATETIME,
+`col4` DATE,
+`col5` YEAR,
+`col6` REAL,
+`col7` NUMERIC,
+`col8` MEDIUMBLOB,
+`col9` TEXT,
+`col10` TIMESTAMP,
+`col11` DOUBLE,
+`col12` DOUBLE,
+`col13` SMALLINT,
+`col14` TIMESTAMP,
+`col15` DECIMAL,
+`col16` DATE,
+`col17` TEXT,
+`col18` LONGBLOB,
+`col19` BIGINT,
+`col20` FLOAT,
+`col21` DATETIME,
+`col22` TINYINT,
+`col23` MEDIUMBLOB,
+`col24` SET ('test1','test2','test3'),
+`col25` TIME,
+`col26` TEXT,
+`col27` LONGTEXT,
+`col28` BIGINT,
+`col29` REAL,
+`col30` YEAR,
+`col31` MEDIUMBLOB,
+`col32` MEDIUMINT,
+`col33` FLOAT,
+`col34` TEXT,
+`col35` DATE,
+`col36` TIMESTAMP,
+`col37` REAL,
+`col38` BLOB,
+`col39` BLOB,
+`col40` BLOB,
+`col41` TINYBLOB,
+`col42` INT,
+`col43` TINYINT,
+`col44` REAL,
+`col45` BIGINT,
+`col46` TIMESTAMP,
+`col47` BLOB,
+`col48` ENUM ('test1','test2','test3'),
+`col49` BOOL,
+`col50` CHAR (109),
+`col51` DOUBLE,
+`col52` DOUBLE PRECISION,
+`col53` ENUM ('test1','test2','test3'),
+`col54` FLOAT,
+`col55` DOUBLE PRECISION,
+`col56` CHAR (166),
+`col57` TEXT,
+`col58` TIME,
+`col59` DECIMAL,
+`col60` TEXT,
+`col61` ENUM ('test1','test2','test3'),
+`col62` LONGTEXT,
+`col63` YEAR,
+`col64` DOUBLE,
+`col65` CHAR (87),
+`col66` DATE,
+`col67` BOOL,
+`col68` MEDIUMBLOB,
+`col69` DATETIME,
+`col70` DECIMAL,
+`col71` TIME,
+`col72` REAL,
+`col73` LONGTEXT,
+`col74` BLOB,
+`col75` REAL,
+`col76` INT,
+`col77` INT,
+`col78` FLOAT,
+`col79` DOUBLE,
+`col80` MEDIUMINT,
+`col81` ENUM ('test1','test2','test3'),
+`col82` VARCHAR (221),
+`col83` BIGINT,
+`col84` TINYINT,
+`col85` BIGINT,
+`col86` FLOAT,
+`col87` MEDIUMBLOB,
+`col88` CHAR (126),
+`col89` MEDIUMBLOB,
+`col90` DATETIME,
+`col91` TINYINT,
+`col92` DOUBLE,
+`col93` NUMERIC,
+`col94` DATE,
+`col95` BLOB,
+`col96` DATETIME,
+`col97` TIME,
+`col98` LONGBLOB,
+`col99` INT,
+`col100` SET ('test1','test2','test3'),
+`col101` TINYBLOB,
+`col102` INT,
+`col103` MEDIUMBLOB,
+`col104` MEDIUMTEXT,
+`col105` FLOAT,
+`col106` TINYBLOB,
+`col107` VARCHAR (26),
+`col108` TINYINT,
+`col109` TIME,
+`col110` TINYBLOB,
+`col111` LONGBLOB,
+`col112` TINYTEXT,
+`col113` FLOAT,
+`col114` TINYINT,
+`col115` NUMERIC,
+`col116` TIME,
+`col117` SET ('test1','test2','test3'),
+`col118` DATE,
+`col119` SMALLINT,
+`col120` BLOB,
+`col121` TINYTEXT,
+`col122` REAL,
+`col123` YEAR,
+`col124` REAL,
+`col125` BOOL,
+`col126` BLOB,
+`col127` REAL,
+`col128` MEDIUMBLOB,
+`col129` TIMESTAMP,
+`col130` LONGBLOB,
+`col131` MEDIUMBLOB,
+`col132` YEAR,
+`col133` YEAR,
+`col134` INT,
+`col135` MEDIUMINT,
+`col136` MEDIUMINT,
+`col137` TINYTEXT,
+`col138` TINYBLOB,
+`col139` BLOB,
+`col140` SET ('test1','test2','test3'),
+`col141` ENUM ('test1','test2','test3'),
+`col142` ENUM ('test1','test2','test3'),
+`col143` TINYTEXT,
+`col144` DATETIME,
+`col145` TEXT,
+`col146` DOUBLE PRECISION,
+`col147` DECIMAL,
+`col148` MEDIUMTEXT,
+`col149` TINYTEXT,
+`col150` SET ('test1','test2','test3'),
+`col151` MEDIUMTEXT,
+`col152` CHAR (126),
+`col153` DOUBLE,
+`col154` CHAR (243),
+`col155` SET ('test1','test2','test3'),
+`col156` SET ('test1','test2','test3'),
+`col157` DATETIME,
+`col158` DOUBLE,
+`col159` NUMERIC,
+`col160` DECIMAL,
+`col161` FLOAT,
+`col162` LONGBLOB,
+`col163` LONGTEXT,
+`col164` INT,
+`col165` TIME,
+`col166` CHAR (27),
+`col167` VARCHAR (63),
+`col168` TEXT,
+`col169` TINYBLOB,
+`col170` TINYBLOB,
+`col171` ENUM ('test1','test2','test3'),
+`col172` INT,
+`col173` TIME,
+`col174` DECIMAL,
+`col175` DOUBLE,
+`col176` MEDIUMBLOB,
+`col177` LONGBLOB,
+`col178` CHAR (43),
+KEY `idx0` (`col131`(219)),
+KEY `idx1` (`col67`,`col122`,`col59`,`col87`(33)),
+KEY `idx2` (`col83`,`col42`,`col57`(152)),
+KEY `idx3` (`col106`(124)),
+KEY `idx4` (`col173`,`col80`,`col165`,`col89`(78)),
+KEY `idx5` (`col174`,`col145`(108),`col23`(228),`col141`),
+KEY `idx6` (`col157`,`col140`),
+KEY `idx7` (`col130`(188),`col15`),
+KEY `idx8` (`col52`),
+KEY `idx9` (`col144`),
+KEY `idx10` (`col155`),
+KEY `idx11` (`col62`(230),`col1`(109)),
+KEY `idx12` (`col151`(24),`col95`(85)),
+KEY `idx13` (`col114`),
+KEY `idx14` (`col42`,`col98`(56),`col146`),
+KEY `idx15` (`col147`,`col39`(254),`col35`),
+KEY `idx16` (`col79`),
+KEY `idx17` (`col65`),
+KEY `idx18` (`col149`(165),`col168`(119),`col32`,`col117`),
+KEY `idx19` (`col64`),
+KEY `idx20` (`col93`),
+KEY `idx21` (`col64`,`col113`,`col104`(182)),
+KEY `idx22` (`col52`,`col111`(189)),
+KEY `idx23` (`col45`),
+KEY `idx24` (`col154`,`col107`,`col110`(159)),
+KEY `idx25` (`col149`(1),`col87`(131)),
+KEY `idx26` (`col58`,`col115`,`col63`),
+KEY `idx27` (`col95`(9),`col0`,`col87`(113)),
+KEY `idx28` (`col92`,`col130`(1)),
+KEY `idx29` (`col151`(129),`col137`(254),`col13`),
+KEY `idx30` (`col49`),
+KEY `idx31` (`col28`),
+KEY `idx32` (`col83`,`col146`),
+KEY `idx33` (`col155`,`col90`,`col17`(245)),
+KEY `idx34` (`col174`,`col169`(44),`col107`),
+KEY `idx35` (`col113`),
+KEY `idx36` (`col52`),
+KEY `idx37` (`col16`,`col120`(190)),
+KEY `idx38` (`col28`),
+KEY `idx39` (`col131`(165)),
+KEY `idx40` (`col135`,`col26`(86)),
+KEY `idx41` (`col69`,`col94`),
+KEY `idx42` (`col105`,`col151`(38),`col97`),
+KEY `idx43` (`col88`),
+KEY `idx44` (`col176`(100),`col42`,`col73`(189),`col94`),
+KEY `idx45` (`col2`(27),`col27`(116))
+)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
+
+SET GLOBAL innodb_file_format=@save_innodb_file_format;
+SET GLOBAL innodb_file_format_check=@save_innodb_file_format_check;
+SET GLOBAL innodb_file_per_table=@save_innodb_file_per_table;
+
+DROP TABLE IF EXISTS table0;
+DROP TABLE IF EXISTS table1;
+DROP TABLE IF EXISTS table2;
+DROP TABLE IF EXISTS table3;
+DROP TABLE IF EXISTS table4;
+DROP TABLE IF EXISTS table5;
+DROP TABLE IF EXISTS table6;
+

=== added file 'mysql-test/t/innodb_bug36172.test'
--- a/mysql-test/t/innodb_bug36172.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug36172.test	2009-06-11 12:53:26 +0000
@@ -0,0 +1,33 @@
+#
+# Test case for bug 36172
+#
+
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+SET storage_engine=InnoDB;
+
+# we do not really care about what gets printed, we are only
+# interested in getting success or failure according to our
+# expectations
+
+-- disable_query_log
+-- disable_result_log
+
+SET @save_innodb_file_format=@@global.innodb_file_format;
+SET @save_innodb_file_format_check=@@global.innodb_file_format_check;
+SET @save_innodb_file_per_table=@@global.innodb_file_per_table;
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=on;
+
+DROP TABLE IF EXISTS `table0`;
+CREATE TABLE `table0` (   `col0` tinyint(1) DEFAULT NULL,   `col1` tinyint(1) DEFAULT NULL,   `col2` tinyint(4) DEFAULT NULL,   `col3` date DEFAULT NULL,   `col4` time DEFAULT NULL,   `col5` set('test1','test2','test3') DEFAULT NULL,   `col6` time DEFAULT NULL,   `col7` text,   `col8` decimal(10,0) DEFAULT NULL,   `col9` set('test1','test2','test3') DEFAULT NULL,   `col10` float DEFAULT NULL,   `col11` double DEFAULT NULL,   `col12` enum('test1','test2','test3') DEFAULT NULL,   `col13` tinyblob,   `col14` year(4) DEFAULT NULL,   `col15` set('test1','test2','test3') DEFAULT NULL,   `col16` decimal(10,0) DEFAULT NULL,   `col17` decimal(10,0) DEFAULT NULL,   `col18` blob,   `col19` datetime DEFAULT NULL,   `col20` double DEFAULT NULL,   `col21` decimal(10,0) DEFAULT NULL,   `col22` datetime DEFAULT NULL,   `col23` decimal(10,0) DEFAULT NULL,   `col24` decimal(10,0) DEFAULT NULL,   `col25` longtext,   `col26` tinyblob,   `col27` time DEFAULT NULL,   `col28` tinyblob,   `col29` enum('test1','test2','test3') DEFAULT NULL,   `col30` smallint(6) DEFAULT NULL,   `col31` double DEFAULT NULL,   `col32` float DEFAULT NULL,   `col33` char(175) DEFAULT NULL,   `col34` tinytext,   `col35` tinytext,   `col36` tinyblob,   `col37` tinyblob,   `col38` tinytext,   `col39` mediumblob,   `col40` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,   `col41` double DEFAULT NULL,   `col42` smallint(6) DEFAULT NULL,   `col43` longblob,   `col44` varchar(80) DEFAULT NULL,   `col45` mediumtext,   `col46` decimal(10,0) DEFAULT NULL,   `col47` bigint(20) DEFAULT NULL,   `col48` date DEFAULT NULL,   `col49` tinyblob,   `col50` date DEFAULT NULL,   `col51` tinyint(1) DEFAULT NULL,   `col52` mediumint(9) DEFAULT NULL,   `col53` float DEFAULT NULL,   `col54` tinyblob,   `col55` longtext,   `col56` smallint(6) DEFAULT NULL,   `col57` enum('test1','test2','test3') DEFAULT NULL,   `col58` datetime DEFAULT NULL,   `col59` mediumtext,   `col60` varchar(232) DEFAULT NULL,   `col61` decimal(10,0) DEFAULT NULL,   `col62` year(4) DEFAULT NULL,   `col63` smallint(6) DEFAULT NULL,   `col64` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',   `col65` blob,   `col66` longblob,   `col67` int(11) DEFAULT NULL,   `col68` longtext,   `col69` enum('test1','test2','test3') DEFAULT NULL,   `col70` int(11) DEFAULT NULL,   `col71` time DEFAULT NULL,   `col72` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',   `col73` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',   `col74` varchar(170) DEFAULT NULL,   `col75` set('test1','test2','test3') DEFAULT NULL,   `col76` tinyblob,   `col77` bigint(20) DEFAULT NULL,   `col78` decimal(10,0) DEFAULT NULL,   `col79` datetime DEFAULT NULL,   `col80` year(4) DEFAULT NULL,   `col81` decimal(10,0) DEFAULT NULL,   `col82` longblob,   `col83` text,   `col84` char(83) DEFAULT NULL,   `col85` decimal(10,0) DEFAULT NULL,   `col86` float DEFAULT NULL,   `col87` int(11) DEFAULT NULL,   `col88` varchar(145) DEFAULT NULL,   `col89` date DEFAULT NULL,   `col90` decimal(10,0) DEFAULT NULL,   `col91` decimal(10,0) DEFAULT NULL,   `col92` mediumblob,   `col93` time DEFAULT NULL,   KEY `idx0` (`col69`,`col90`,`col8`),   KEY `idx1` (`col60`),   KEY `idx2` (`col60`,`col70`,`col74`),   KEY `idx3` (`col22`,`col32`,`col72`,`col30`),   KEY `idx4` (`col29`),   KEY `idx5` (`col19`,`col45`(143)),   KEY `idx6` (`col46`,`col48`,`col5`,`col39`(118)),   KEY `idx7` (`col48`,`col61`),   KEY `idx8` (`col93`),   KEY `idx9` (`col31`),   KEY `idx10` (`col30`,`col21`),   KEY `idx11` (`col67`),   KEY `idx12` (`col44`,`col6`,`col8`,`col38`(226)),   KEY `idx13` (`col71`,`col41`,`col15`,`col49`(88)),   KEY `idx14` (`col78`),   KEY `idx15` (`col63`,`col67`,`col64`),   KEY `idx16` (`col17`,`col86`),   KEY `idx17` (`col77`,`col56`,`col10`,`col55`(24)),   KEY `idx18` (`col62`),   KEY `idx19` (`col31`,`col57`,`col56`,`col53`),   KEY `idx20` (`col46`),   KEY `idx21` (`col83`(54)),   KEY `idx22` (`col51`,`col7`(120)),   KEY `idx23` (`col7`(163),`col31`,`col71`,`col14`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2;
+insert ignore into `table0` set  `col23` = 7887371.5084383683, `col24` = 4293854615.6906948000, `col25` = 'vitalist', `col26` = 'widespread', `col27` = '3570490', `col28` = 'habitual', `col30` = -5471, `col31` = 4286985783.6771750000, `col32` = 6354540.9826654866, `col33` = 'defoliation', `col34` = 'logarithms', `col35` = 'tegument\'s', `col36` = 'scouting\'s', `col37` = 'intermittency', `col38` = 'elongates', `col39` = 'prophecies', `col40` = '20560103035939', `col41` = 4292809130.0544143000, `col42` = 22057, `col43` = 'Hess\'s', `col44` = 'bandstand', `col45` = 'phenylketonuria', `col46` = 6338767.4018677324, `col47` = 5310247, `col48` = '12592418', `col49` = 'churchman\'s', `col50` = '32226125', `col51` = -58, `col52` = -6207968, `col53` = 1244839.3255104220, `col54` = 'robotized', `col55` = 'monotonous', `col56` = -26909, `col58` = '20720107023550', `col59` = 'suggestiveness\'s', `col60` = 'gemology', `col61` = 4287800670.2229986000, `col62` = '1944', `col63` = -16827, `col64` = '20700107212324', `col65` = 'Nicolais', `col66` = 'apteryx', `col67` = 6935317, `col68` = 'stroganoff', `col70` = 3316430, `col71` = '3277608', `col72` = '19300511045918', `col73` = '20421201003327', `col74` = 'attenuant', `col75` = '15173', `col76` = 'upstroke\'s', `col77` = 8118987, `col78` = 6791516.2735374002, `col79` = '20780701144624', `col80` = '2134', `col81` = 4290682351.3127537000, `col82` = 'unexplainably', `col83` = 'Storm', `col84` = 'Greyso\'s', `col85` = 4289119212.4306774000, `col86` = 7617575.8796655172, `col87` = -6325335, `col88` = 'fondue\'s', `col89` = '40608940', `col90` = 1659421.8093508712, `col91` = 8346904.6584368423, `col92` = 'reloads', `col93` = '5188366';
+CHECK TABLE table0 EXTENDED;
+INSERT IGNORE INTO `table0` SET `col19` = '19940127002709', `col20` = 2383927.9055146948, `col21` = 4293243420.5621204000, `col22` = '20511211123705', `col23` = 4289899778.6573381000, `col24` = 4293449279.0540481000, `col25` = 'emphysemic', `col26` = 'dentally', `col27` = '2347406', `col28` = 'eruct', `col30` = 1222, `col31` = 4294372994.9941406000, `col32` = 4291385574.1173744000, `col33` = 'borrowing\'s', `col34` = 'septics', `col35` = 'ratter\'s', `col36` = 'Kaye', `col37` = 'Florentia', `col38` = 'allium', `col39` = 'barkeep', `col40` = '19510407003441', `col41` = 4293559200.4215522000, `col42` = 22482, `col43` = 'decussate', `col44` = 'Brom\'s', `col45` = 'violated', `col46` = 4925506.4635456400, `col47` = 930549, `col48` = '51296066', `col49` = 'voluminously', `col50` = '29306676', `col51` = -88, `col52` = -2153690, `col53` = 4290250202.1464887000, `col54` = 'expropriation', `col55` = 'Aberdeen\'s', `col56` = 20343, `col58` = '19640415171532', `col59` = 'extern', `col60` = 'Ubana', `col61` = 4290487961.8539081000, `col62` = '2147', `col63` = -24271, `col64` = '20750801194548', `col65` = 'Cunaxa\'s', `col66` = 'pasticcio', `col67` = 2795817, `col68` = 'Indore\'s', `col70` = 6864127, `col71` = '1817832', `col72` = '20540506114211', `col73` = '20040101012300', `col74` = 'rationalized', `col75` = '45522', `col76` = 'indene', `col77` = -6964559, `col78` = 4247535.5266884370, `col79` = '20720416124357', `col80` = '2143', `col81` = 4292060102.4466386000, `col82` = 'striving', `col83` = 'boneblack\'s', `col84` = 'redolent', `col85` = 6489697.9009369183, `col86` = 4287473465.9731131000, `col87` = 7726015, `col88` = 'perplexed', `col89` = '17153791', `col90` = 5478587.1108127078, `col91` = 4287091404.7004304000, `col92` = 'Boulez\'s', `col93` = '2931278';
+CHECK TABLE table0 EXTENDED;
+
+SET GLOBAL innodb_file_format=@save_innodb_file_format;
+SET GLOBAL innodb_file_format_check=@save_innodb_file_format_check;
+SET GLOBAL innodb_file_per_table=@save_innodb_file_per_table;
+DROP TABLE table0;

=== added file 'mysql-test/t/innodb_bug40360.test'
--- a/mysql-test/t/innodb_bug40360.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug40360.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,16 @@
+#
+# Make sure http://bugs.mysql.com/40360 remains fixed.
+#
+
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+SET TX_ISOLATION='READ-COMMITTED';
+
+# This is the default since MySQL 5.1.29 SET BINLOG_FORMAT='STATEMENT';
+
+CREATE TABLE bug40360 (a INT) engine=innodb;
+
+INSERT INTO bug40360 VALUES (1);
+
+DROP TABLE bug40360;

=== added file 'mysql-test/t/innodb_bug41904.test'
--- a/mysql-test/t/innodb_bug41904.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug41904.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,14 @@
+#
+# Make sure http://bugs.mysql.com/41904 remains fixed.
+#
+
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+CREATE TABLE bug41904 (id INT PRIMARY KEY, uniquecol CHAR(15)) ENGINE=InnoDB;
+
+INSERT INTO bug41904 VALUES (1,NULL), (2,NULL);
+
+CREATE UNIQUE INDEX ui ON bug41904 (uniquecol);
+
+DROP TABLE bug41904;

=== added file 'mysql-test/t/innodb_information_schema.test'
--- a/mysql-test/t/innodb_information_schema.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_information_schema.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,145 @@
+# 
+# Test that user data is correctly "visualized" in
+# INFORMATION_SCHEMA.innodb_locks.lock_data
+#
+
+-- source include/have_innodb.inc
+
+-- disable_query_log
+-- disable_result_log
+
+SET storage_engine=InnoDB;
+
+-- disable_warnings
+DROP TABLE IF EXISTS t_min, t_max;
+-- enable_warnings
+
+let $table_def =
+(
+	c01 TINYINT,
+	c02 TINYINT UNSIGNED,
+	c03 SMALLINT,
+	c04 SMALLINT UNSIGNED,
+	c05 MEDIUMINT,
+	c06 MEDIUMINT UNSIGNED,
+	c07 INT,
+	c08 INT UNSIGNED,
+	c09 BIGINT,
+	c10 BIGINT UNSIGNED,
+	PRIMARY KEY(c01, c02, c03, c04, c05, c06, c07, c08, c09, c10)
+);
+
+-- eval CREATE TABLE t_min $table_def;
+INSERT INTO t_min VALUES
+(-128, 0,
+ -32768, 0,
+ -8388608, 0,
+ -2147483648, 0,
+ -9223372036854775808, 0);
+
+-- eval CREATE TABLE t_max $table_def;
+INSERT INTO t_max VALUES
+(127, 255,
+ 32767, 65535,
+ 8388607, 16777215,
+ 2147483647, 4294967295,
+ 9223372036854775807, 18446744073709551615);
+
+CREATE TABLE ```t'\"_str` (
+	c1 VARCHAR(32),
+	c2 VARCHAR(32),
+	c3 VARCHAR(32),
+	c4 VARCHAR(32),
+	c5 VARCHAR(32),
+	c6 VARCHAR(32),
+	c7 VARCHAR(32),
+	PRIMARY KEY(c1, c2, c3, c4, c5, c6, c7)
+);
+INSERT INTO ```t'\"_str` VALUES
+('1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc''''');
+INSERT INTO ```t'\"_str` VALUES
+('2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""');
+INSERT INTO ```t'\"_str` VALUES
+('3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\');
+INSERT INTO ```t'\"_str` VALUES
+('4', 'abc', 0x00616263, 0x61626300, 0x61006263, 0x6100626300, 0x610062630000);
+
+-- connect (con_lock,localhost,root,,)
+-- connect (con_min_trylock,localhost,root,,)
+-- connect (con_max_trylock,localhost,root,,)
+-- connect (con_str_insert_supremum,localhost,root,,)
+-- connect (con_str_lock_row1,localhost,root,,)
+-- connect (con_str_lock_row2,localhost,root,,)
+-- connect (con_str_lock_row3,localhost,root,,)
+-- connect (con_str_lock_row4,localhost,root,,)
+-- connect (con_verify_innodb_locks,localhost,root,,)
+
+-- connection con_lock
+SET autocommit=0;
+SELECT * FROM t_min FOR UPDATE;
+SELECT * FROM t_max FOR UPDATE;
+SELECT * FROM ```t'\"_str` FOR UPDATE;
+
+-- connection con_min_trylock
+-- send
+SELECT * FROM t_min FOR UPDATE;
+
+-- connection con_max_trylock
+-- send
+SELECT * FROM t_max FOR UPDATE;
+
+-- connection con_str_insert_supremum
+-- send
+INSERT INTO ```t'\"_str` VALUES
+('z', 'z', 'z', 'z', 'z', 'z', 'z');
+
+-- connection con_str_lock_row1
+-- send
+SELECT * FROM ```t'\"_str` WHERE c1 = '1' FOR UPDATE;
+
+-- connection con_str_lock_row2
+-- send
+SELECT * FROM ```t'\"_str` WHERE c1 = '2' FOR UPDATE;
+
+-- connection con_str_lock_row3
+-- send
+SELECT * FROM ```t'\"_str` WHERE c1 = '3' FOR UPDATE;
+
+-- connection con_str_lock_row4
+-- send
+SELECT * FROM ```t'\"_str` WHERE c1 = '4' FOR UPDATE;
+
+# Give time to the above 2 queries to execute before continuing.
+# Without this sleep it sometimes happens that the SELECT from innodb_locks
+# executes before some of them, resulting in less than expected number
+# of rows being selected from innodb_locks.
+-- sleep 0.1
+
+-- enable_result_log
+-- connection con_verify_innodb_locks
+SELECT lock_mode, lock_type, lock_table, lock_index, lock_rec, lock_data
+FROM INFORMATION_SCHEMA.INNODB_LOCKS ORDER BY lock_data;
+
+SELECT lock_table,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
+GROUP BY lock_table;
+
+set @save_sql_mode = @@sql_mode;
+SET SQL_MODE='ANSI_QUOTES';
+SELECT lock_table,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
+GROUP BY lock_table;
+SET @@sql_mode=@save_sql_mode;
+-- disable_result_log
+
+-- connection default
+
+-- disconnect con_lock
+-- disconnect con_min_trylock
+-- disconnect con_max_trylock
+-- disconnect con_str_insert_supremum
+-- disconnect con_str_lock_row1
+-- disconnect con_str_lock_row2
+-- disconnect con_str_lock_row3
+-- disconnect con_str_lock_row4
+-- disconnect con_verify_innodb_locks
+
+DROP TABLE t_min, t_max, ```t'\"_str`;

=== added file 'mysql-test/t/innodb_trx_weight.test'
--- a/mysql-test/t/innodb_trx_weight.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_trx_weight.test	2009-06-09 13:19:13 +0000
@@ -0,0 +1,108 @@
+#
+# Ensure that the number of locks (SELECT FOR UPDATE for example) is
+# added to the number of altered rows when choosing the smallest
+# transaction to kill as a victim when a deadlock is detected.
+# Also transactions what had edited non-transactional tables should
+# be heavier than ones that had not.
+#
+
+-- source include/have_innodb.inc
+
+SET storage_engine=InnoDB;
+
+# we do not really care about what gets printed, we are only
+# interested in getting the deadlock resolved according to our
+# expectations
+-- disable_query_log
+-- disable_result_log
+
+# we want to use "-- eval statement1; statement2" which does not work with
+# prepared statements. Because this test should not behave differently with
+# or without prepared statements we disable them so the test does not fail
+# if someone runs ./mysql-test-run.pl --ps-protocol
+-- disable_ps_protocol
+
+-- disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3, t4, t5_nontrans;
+-- enable_warnings
+
+# we will create a simple deadlock with t1, t2 and two connections
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+
+# auxiliary table with a bulk of rows which will be locked by a
+# transaction to increase its weight
+CREATE TABLE t3 (a INT);
+
+# auxiliary empty table which will be inserted by a
+# transaction to increase its weight
+CREATE TABLE t4 (a INT);
+
+# auxiliary non-transactional table which will be edited by a
+# transaction to tremendously increase its weight
+CREATE TABLE t5_nontrans (a INT) ENGINE=MyISAM;
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+# insert a lot of rows in t3
+INSERT INTO t3 VALUES (1);
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+INSERT INTO t3 SELECT * FROM t3;
+
+# test locking weight
+
+-- let $con1_extra_sql =
+-- let $con1_extra_sql_present = 0
+-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE
+-- let $con2_extra_sql_present = 1
+-- let $con1_should_be_rolledback = 1
+-- source include/innodb_trx_weight.inc
+
+-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1)
+-- let $con1_extra_sql_present = 1
+-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE
+-- let $con2_extra_sql_present = 1
+-- let $con1_should_be_rolledback = 1
+-- source include/innodb_trx_weight.inc
+
+-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1), (1), (1), (1)
+-- let $con1_extra_sql_present = 1
+-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE
+-- let $con2_extra_sql_present = 1
+-- let $con1_should_be_rolledback = 0
+-- source include/innodb_trx_weight.inc
+
+# test weight when non-transactional tables are edited
+
+-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1)
+-- let $con1_extra_sql_present = 1
+-- let $con2_extra_sql =
+-- let $con2_extra_sql_present = 0
+-- let $con1_should_be_rolledback = 0
+-- source include/innodb_trx_weight.inc
+
+-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1)
+-- let $con1_extra_sql_present = 1
+-- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1)
+-- let $con2_extra_sql_present = 1
+-- let $con1_should_be_rolledback = 1
+-- source include/innodb_trx_weight.inc
+
+-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1)
+-- let $con1_extra_sql = $con1_extra_sql; INSERT INTO t5_nontrans VALUES (1)
+-- let $con1_extra_sql_present = 1
+-- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1)
+-- let $con2_extra_sql_present = 1
+-- let $con1_should_be_rolledback = 0
+-- source include/innodb_trx_weight.inc
+
+DROP TABLE t1, t2, t3, t4, t5_nontrans;

=== removed file 'mysql-test/t/innodb_trx_weight.test'
--- a/mysql-test/t/innodb_trx_weight.test	2007-07-10 11:37:43 +0000
+++ b/mysql-test/t/innodb_trx_weight.test	1970-01-01 00:00:00 +0000
@@ -1,108 +0,0 @@
-#
-# Ensure that the number of locks (SELECT FOR UPDATE for example) is
-# added to the number of altered rows when choosing the smallest
-# transaction to kill as a victim when a deadlock is detected.
-# Also transactions what had edited non-transactional tables should
-# be heavier than ones that had not.
-#
-
--- source include/have_innodb.inc
-
-SET storage_engine=InnoDB;
-
-# we do not really care about what gets printed, we are only
-# interested in getting the deadlock resolved according to our
-# expectations
--- disable_query_log
--- disable_result_log
-
-# we want to use "-- eval statement1; statement2" which does not work with
-# prepared statements. Because this test should not behave differently with
-# or without prepared statements we disable them so the test does not fail
-# if someone runs ./mysql-test-run.pl --ps-protocol
--- disable_ps_protocol
-
--- disable_warnings
-DROP TABLE IF EXISTS t1, t2, t3, t4, t5_nontrans;
--- enable_warnings
-
-# we will create a simple deadlock with t1, t2 and two connections
-CREATE TABLE t1 (a INT);
-CREATE TABLE t2 (a INT);
-
-# auxiliary table with a bulk of rows which will be locked by a
-# transaction to increase its weight
-CREATE TABLE t3 (a INT);
-
-# auxiliary empty table which will be inserted by a
-# transaction to increase its weight
-CREATE TABLE t4 (a INT);
-
-# auxiliary non-transactional table which will be edited by a
-# transaction to tremendously increase its weight
-CREATE TABLE t5_nontrans (a INT) ENGINE=MyISAM;
-
-INSERT INTO t1 VALUES (1);
-INSERT INTO t2 VALUES (1);
-# insert a lot of rows in t3
-INSERT INTO t3 VALUES (1);
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-INSERT INTO t3 SELECT * FROM t3;
-
-# test locking weight
-
--- let $con1_extra_sql =
--- let $con1_extra_sql_present = 0
--- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE
--- let $con2_extra_sql_present = 1
--- let $con1_should_be_rolledback = 1
--- source include/innodb_trx_weight.inc
-
--- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1)
--- let $con1_extra_sql_present = 1
--- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE
--- let $con2_extra_sql_present = 1
--- let $con1_should_be_rolledback = 1
--- source include/innodb_trx_weight.inc
-
--- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1), (1), (1), (1)
--- let $con1_extra_sql_present = 1
--- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE
--- let $con2_extra_sql_present = 1
--- let $con1_should_be_rolledback = 0
--- source include/innodb_trx_weight.inc
-
-# test weight when non-transactional tables are edited
-
--- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1)
--- let $con1_extra_sql_present = 1
--- let $con2_extra_sql =
--- let $con2_extra_sql_present = 0
--- let $con1_should_be_rolledback = 0
--- source include/innodb_trx_weight.inc
-
--- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1)
--- let $con1_extra_sql_present = 1
--- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1)
--- let $con2_extra_sql_present = 1
--- let $con1_should_be_rolledback = 1
--- source include/innodb_trx_weight.inc
-
--- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1)
--- let $con1_extra_sql = $con1_extra_sql; INSERT INTO t5_nontrans VALUES (1)
--- let $con1_extra_sql_present = 1
--- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1)
--- let $con2_extra_sql_present = 1
--- let $con1_should_be_rolledback = 0
--- source include/innodb_trx_weight.inc
-
-DROP TABLE t1, t2, t3, t4, t5_nontrans;

=== added file 'mysql-test/t/innodb_xtradb_bug317074.test'
--- a/mysql-test/t/innodb_xtradb_bug317074.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_xtradb_bug317074.test	2009-06-11 12:53:26 +0000
@@ -0,0 +1,45 @@
+-- source include/have_innodb.inc
+
+SET @save_innodb_file_format=@@global.innodb_file_format;
+SET @save_innodb_file_format_check=@@global.innodb_file_format_check;
+SET @save_innodb_file_per_table=@@global.innodb_file_per_table;
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;
+
+-- disable_query_log
+-- disable_result_log
+
+DROP TABLE IF EXISTS `test1`;
+CREATE TABLE IF NOT EXISTS `test1` (
+ `a` int primary key auto_increment,
+ `b` int default 0,
+ `c` char(100) default 'testtest'
+) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+delimiter |;
+CREATE PROCEDURE insert_many(p1 int)
+BEGIN
+SET @x = 0;
+SET @y = 0;
+REPEAT
+  insert into test1 set b=1;
+  SET @x = @x + 1;
+  SET @y = @y + 1;
+  IF @y >= 100 THEN
+    commit;
+    SET @y = 0;
+  END IF;
+UNTIL @x >= p1 END REPEAT;
+END|
+delimiter ;|
+call insert_many(100000);
+DROP PROCEDURE insert_many;
+
+# The bug is hangup at the following statement
+ALTER TABLE test1 ENGINE=MyISAM;
+
+SET GLOBAL innodb_file_format=@save_innodb_file_format;
+SET GLOBAL innodb_file_format_check=@save_innodb_file_format_check;
+SET GLOBAL innodb_file_per_table=@save_innodb_file_per_table;
+
+DROP TABLE test1;

=== modified file 'mysql-test/t/mysqlbinlog_row_big.test'
--- a/mysql-test/t/mysqlbinlog_row_big.test	2008-12-13 19:42:12 +0000
+++ b/mysql-test/t/mysqlbinlog_row_big.test	2009-06-11 12:53:26 +0000
@@ -24,6 +24,16 @@
 --source include/big_test.inc
 
 --echo #
+--echo # We need big packets.
+--echo #
+connect (con1, localhost, root,,);
+connection con1;
+SET @old_global_max_allowed_packet=@@global.max_allowed_packet;
+SET @@global.max_allowed_packet= 1024*1024*1024;
+connect (con2, localhost, root,,);
+connection con2;
+
+--echo #
 --echo # Preparatory cleanup.
 --echo #
 --disable_warnings
@@ -36,11 +46,6 @@ DROP TABLE IF EXISTS t1;
 SET timestamp=1000000000;
 
 --echo #
---echo # We need big packets.
---echo #
-SET @@global.max_allowed_packet= 1024*1024*1024;
-
---echo #
 --echo # Delete all existing binary logs.
 --echo #
 RESET MASTER;
@@ -122,9 +127,14 @@ let $MYSQLD_DATADIR= `select @@datadir`;
 --echo #
 DROP TABLE t1;
 
+connection con1;
+SET @@global.max_allowed_packet=@old_global_max_allowed_packet;
+
 --echo remove_file \$MYSQLTEST_VARDIR/$mysqlbinlog_output
 #
 # NOTE: If you want to see the *huge* mysqlbinlog output, disable next line:
 #
 --remove_file $MYSQLTEST_VARDIR/$mysqlbinlog_output
 
+disconnect con1
+disconnect con2

=== modified file 'mysql-test/t/partition_innodb.test'
--- a/mysql-test/t/partition_innodb.test	2008-11-14 22:51:17 +0000
+++ b/mysql-test/t/partition_innodb.test	2009-06-09 15:08:46 +0000
@@ -27,14 +27,14 @@ UPDATE t1 SET DATA = data*2 WHERE id = 3
 
 # grouping/referencing in replace_regex is very slow on long strings,
 # removing all before/after the interesting row before grouping/referencing
---replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
+--replace_regex /.*LIST OF TRANSACTIONS FOR EACH SESSION:// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
 SHOW ENGINE InnoDB STATUS;
 
 UPDATE t1 SET data = data*2 WHERE data = 2;
 
 # grouping/referencing in replace_regex is very slow on long strings,
 # removing all before/after the interesting row before grouping/referencing
---replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
+--replace_regex /.*LIST OF TRANSACTIONS FOR EACH SESSION:// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
 SHOW ENGINE InnoDB STATUS;
 
 SET @@session.tx_isolation = @old_tx_isolation;

=== modified file 'mysql-test/t/type_bit_innodb.test'
--- a/mysql-test/t/type_bit_innodb.test	2009-03-11 21:03:25 +0000
+++ b/mysql-test/t/type_bit_innodb.test	2009-06-11 17:49:51 +0000
@@ -41,7 +41,7 @@ create table t1 (a bit) engine=innodb;
 insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001');
 select hex(a) from t1;
 # It is not deterministic which duplicate will be seen first
---replace_regex /(.*Duplicate entry )'.*'( for key.*)/\1''\2/
+--replace_regex /entry '(.*)' for/entry '' for/
 --error ER_DUP_ENTRY
 alter table t1 add unique (a);
 drop table t1;

=== modified file 'mysql-test/t/variables-big.test'
--- a/mysql-test/t/variables-big.test	2008-06-26 05:18:28 +0000
+++ b/mysql-test/t/variables-big.test	2009-06-11 12:53:26 +0000
@@ -8,19 +8,20 @@
 # Bug #27322  	failure to allocate transaction_prealloc_size causes crash
 #
 
+set @pid_temp = (select ID from information_schema.processlist);
 set session transaction_prealloc_size=1024*1024*1024*1;
 --replace_column 1 #
-show processlist;
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
 set session transaction_prealloc_size=1024*1024*1024*2;
 --replace_column 1 #
-show processlist;
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
 --replace_column 1 #
 set session transaction_prealloc_size=1024*1024*1024*3;
 --replace_column 1 #
-show processlist;
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
 set session transaction_prealloc_size=1024*1024*1024*4;
 --replace_column 1 #
-show processlist;
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
 set session transaction_prealloc_size=1024*1024*1024*5;
 --replace_column 1 #
-show processlist;
+select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';

=== modified file 'mysys/mf_iocache2.c'
--- a/mysys/mf_iocache2.c	2009-04-25 10:05:32 +0000
+++ b/mysys/mf_iocache2.c	2009-06-11 17:49:51 +0000
@@ -464,3 +464,52 @@ process_flags:
 err:
   return (size_t) -1;
 }
+
+int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
+                          const char *default_val)
+{
+  uint length;
+  DBUG_ENTER("init_strvar_from_file");
+
+  if ((length=my_b_gets(f,var, max_size)))
+  {
+    char* last_p = var + length -1;
+    if (*last_p == '\n')
+      *last_p = 0; /* if we stopped on newline, kill it */
+    else
+    {
+      /*
+        If we truncated a line or stopped on last char, remove all chars
+        up to and including newline.
+      */
+      int c;
+      while (((c=my_b_get(f)) != '\n' && c != my_b_EOF))
+        ;
+    }
+    DBUG_RETURN(0);
+  }
+  else if (default_val)
+  {
+    strmake(var,  default_val, max_size-1);
+    DBUG_RETURN(0);
+  }
+  DBUG_RETURN(1);
+}
+
+int init_intvar_from_file(int* var, IO_CACHE* f, int default_val)
+{
+  char buf[32];
+  DBUG_ENTER("init_intvar_from_file");
+
+  if (my_b_gets(f, buf, sizeof(buf)))
+  {
+    *var = atoi(buf);
+    DBUG_RETURN(0);
+  }
+  else if (default_val)
+  {
+    *var = default_val;
+    DBUG_RETURN(0);
+  }
+  DBUG_RETURN(1);
+}

=== modified file 'mysys/thr_mutex.c'
--- a/mysys/thr_mutex.c	2009-02-19 09:01:25 +0000
+++ b/mysys/thr_mutex.c	2009-06-09 15:08:46 +0000
@@ -149,6 +149,35 @@ static inline void remove_from_active_li
   mp->prev= mp->next= 0;
 }
 
+/*
+  We initialise the hashes for deadlock detection lazily.
+  This greatly helps with performance when lots of mutexes are initiased but
+  only a few of them are actually used (eg. XtraDB).
+*/
+static int safe_mutex_lazy_init_deadlock_detection(safe_mutex_t *mp)
+{
+  if (!my_multi_malloc(MY_FAE | MY_WME,
+                       &mp->locked_mutex, sizeof(*mp->locked_mutex),
+                       &mp->used_mutex, sizeof(*mp->used_mutex), NullS))
+  {
+    return 1;                                   /* Error */
+  }
+
+  pthread_mutex_lock(&THR_LOCK_mutex);
+  mp->id= ++safe_mutex_id;
+  pthread_mutex_unlock(&THR_LOCK_mutex);
+  hash_init(mp->locked_mutex, &my_charset_bin,
+            1000,
+            offsetof(safe_mutex_deadlock_t, id),
+            sizeof(mp->id),
+            0, 0, HASH_UNIQUE);
+  hash_init(mp->used_mutex, &my_charset_bin,
+            1000,
+            offsetof(safe_mutex_t, id),
+            sizeof(mp->id),
+            0, 0, HASH_UNIQUE);
+  return 0;
+}
 
 int safe_mutex_init(safe_mutex_t *mp,
 		    const pthread_mutexattr_t *attr __attribute__((unused)),
@@ -167,35 +196,8 @@ int safe_mutex_init(safe_mutex_t *mp,
   mp->line= line;
   /* Skip the very common '&' prefix from the autogenerated name */
   mp->name= name[0] == '&' ? name + 1 : name;
+  /* Deadlock detection is initialised only lazily, on first use. */
 
-  if (safe_mutex_deadlock_detector && !( my_flags & MYF_NO_DEADLOCK_DETECTION))
-  {
-    if (!my_multi_malloc(MY_FAE | MY_WME,
-                         &mp->locked_mutex, sizeof(*mp->locked_mutex),
-                         &mp->used_mutex, sizeof(*mp->used_mutex), NullS))
-    {
-      /* Disable deadlock handling for this mutex */
-      my_flags|= MYF_NO_DEADLOCK_DETECTION;
-    }
-    else
-    {
-      pthread_mutex_lock(&THR_LOCK_mutex);
-      mp->id= ++safe_mutex_id;
-      pthread_mutex_unlock(&THR_LOCK_mutex);
-      hash_init(mp->locked_mutex, &my_charset_bin,
-                1000,
-                offsetof(safe_mutex_deadlock_t, id),
-                sizeof(mp->id),
-                0, 0, HASH_UNIQUE);
-      hash_init(mp->used_mutex, &my_charset_bin,
-                1000,
-                offsetof(safe_mutex_t, id),
-                sizeof(mp->id),
-                0, 0, HASH_UNIQUE);
-    }
-  }
-  else
-    my_flags|= MYF_NO_DEADLOCK_DETECTION;
   mp->create_flags= my_flags;
 
 #ifdef SAFE_MUTEX_DETECT_DESTROY
@@ -310,7 +312,8 @@ int safe_mutex_lock(safe_mutex_t *mp, my
   /* Deadlock detection */
 
   mp->prev= mp->next= 0;
-  if (!(mp->active_flags & (MYF_TRY_LOCK | MYF_NO_DEADLOCK_DETECTION)))
+  if (!(mp->active_flags & (MYF_TRY_LOCK | MYF_NO_DEADLOCK_DETECTION)) &&
+      (mp->used_mutex != NULL || !safe_mutex_lazy_init_deadlock_detection(mp)))
   {
     safe_mutex_t **mutex_in_use= my_thread_var_mutex_in_use();
 
@@ -643,7 +646,7 @@ int safe_mutex_destroy(safe_mutex_t *mp,
 void safe_mutex_free_deadlock_data(safe_mutex_t *mp)
 {
   /* Free all entries that points to this one */
-  if (!(mp->create_flags & MYF_NO_DEADLOCK_DETECTION))
+  if (!(mp->create_flags & MYF_NO_DEADLOCK_DETECTION) && mp->used_mutex != NULL)
   {
     pthread_mutex_lock(&THR_LOCK_mutex);
     my_hash_iterate(mp->used_mutex,

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2009-05-19 09:28:05 +0000
+++ b/sql/log_event.cc	2009-06-11 17:49:51 +0000
@@ -9313,3 +9313,29 @@ st_print_event_info::st_print_event_info
   open_cached_file(&body_cache, NULL, NULL, 0, flags);
 }
 #endif
+
+#if defined(MYSQL_SERVER)
+/*
+  Access to the current replication position.
+
+  There is a dummy replacement for this in the embedded library that returns
+  FALSE; this is used by XtraDB to allow it to access replication stuff while
+  still being able to use the same plugin in both stand-alone and embedded.
+*/
+bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
+                           const char **group_relay_log_name,
+                           ulonglong *relay_log_pos)
+{
+#if defined(EMBEDDED_LIBRARY) || !defined(HAVE_REPLICATION)
+  return FALSE;
+#else
+  const Relay_log_info *rli= &(active_mi->rli);
+  *log_file_name= rli->group_master_log_name;
+  *log_pos= rli->group_master_log_pos +
+    (rli->future_event_relay_log_pos - rli->group_relay_log_pos);
+  *group_relay_log_name= rli->group_relay_log_name;
+  *relay_log_pos= rli->future_event_relay_log_pos;
+  return TRUE;
+#endif
+}
+#endif

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2009-03-17 20:29:24 +0000
+++ b/sql/log_event.h	2009-06-11 17:49:51 +0000
@@ -3917,6 +3917,10 @@ static inline bool copy_event_cache_to_f
     reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE);
 }
 
+bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
+                           const char **group_relay_log_name,
+                           ulonglong *relay_log_pos);
+
 /**
   @} (end of group Replication)
 */

=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc	2008-12-02 22:02:52 +0000
+++ b/sql/rpl_mi.cc	2009-06-11 12:53:26 +0000
@@ -22,11 +22,6 @@
 #ifdef HAVE_REPLICATION
 
 
-// Defined in slave.cc
-int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
-int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
-			  const char *default_val);
-
 Master_info::Master_info()
   :Slave_reporting_capability("I/O"),
    ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0), inited(0),

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2009-05-19 09:28:05 +0000
+++ b/sql/rpl_rli.cc	2009-06-11 17:49:51 +0000
@@ -23,11 +23,6 @@
 
 static int count_relay_log_space(Relay_log_info* rli);
 
-// Defined in slave.cc
-int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
-int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
-			  const char *default_val);
-
 
 Relay_log_info::Relay_log_info()
   :Slave_reporting_capability("SQL"),

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-05-19 09:28:05 +0000
+++ b/sql/slave.cc	2009-06-11 17:49:51 +0000
@@ -755,57 +755,6 @@ const char *print_slave_db_safe(const ch
   DBUG_RETURN((db ? db : ""));
 }
 
-int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
-                                 const char *default_val)
-{
-  uint length;
-  DBUG_ENTER("init_strvar_from_file");
-
-  if ((length=my_b_gets(f,var, max_size)))
-  {
-    char* last_p = var + length -1;
-    if (*last_p == '\n')
-      *last_p = 0; // if we stopped on newline, kill it
-    else
-    {
-      /*
-        If we truncated a line or stopped on last char, remove all chars
-        up to and including newline.
-      */
-      int c;
-      while (((c=my_b_get(f)) != '\n' && c != my_b_EOF))
-        ;
-    }
-    DBUG_RETURN(0);
-  }
-  else if (default_val)
-  {
-    strmake(var,  default_val, max_size-1);
-    DBUG_RETURN(0);
-  }
-  DBUG_RETURN(1);
-}
-
-
-int init_intvar_from_file(int* var, IO_CACHE* f, int default_val)
-{
-  char buf[32];
-  DBUG_ENTER("init_intvar_from_file");
-
-
-  if (my_b_gets(f, buf, sizeof(buf)))
-  {
-    *var = atoi(buf);
-    DBUG_RETURN(0);
-  }
-  else if (default_val)
-  {
-    *var = default_val;
-    DBUG_RETURN(0);
-  }
-  DBUG_RETURN(1);
-}
-
 /*
   Note that we rely on the master's version (3.23, 4.0.14 etc) instead of
   relying on the binlog's version. This is not perfect: imagine an upgrade

=== renamed file 'storage/innobase/plug.in' => 'storage/innobase/plug.in.disabled'
=== added directory 'storage/xtradb'
=== added file 'storage/xtradb/CMakeLists.txt'
--- a/storage/xtradb/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ b/storage/xtradb/CMakeLists.txt	2009-06-09 12:21:26 +0000
@@ -0,0 +1,97 @@
+# Copyright (C) 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
+# the Free Software Foundation; version 2 of the License.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+ADD_DEFINITIONS(-D_WIN32 -D_LIB)
+
+# Bug 19424 - InnoDB: Possibly a memory overrun of the buffer being freed (64-bit Visual C)
+# Removing Win64 compiler optimizations for all innodb/mem/* files.
+IF(CMAKE_GENERATOR MATCHES "Visual Studio" AND CMAKE_SIZEOF_VOID_P MATCHES 8)
+  SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/storage/xtradb/mem/mem0mem.c
+                              ${CMAKE_SOURCE_DIR}/storage/xtradb/mem/mem0pool.c
+                              PROPERTIES COMPILE_FLAGS -Od)
+ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio" AND CMAKE_SIZEOF_VOID_P MATCHES 8)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
+                    ${CMAKE_SOURCE_DIR}/storage/xtradb/include
+                    ${CMAKE_SOURCE_DIR}/storage/xtradb/handler
+                    ${CMAKE_SOURCE_DIR}/sql
+                    ${CMAKE_SOURCE_DIR}/regex
+                    ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+
+SET(INNOBASE_SOURCES  btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c 
+					 buf/buf0buddy.c buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c 
+					 data/data0data.c data/data0type.c 
+					 dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c dict/dict0load.c dict/dict0mem.c 
+					 dyn/dyn0dyn.c 
+					 eval/eval0eval.c eval/eval0proc.c 
+					 fil/fil0fil.c 
+					 fsp/fsp0fsp.c
+					 fut/fut0fut.c fut/fut0lst.c 
+					 ha/ha0ha.c ha/hash0hash.c ha/ha0storage.c 
+					 ibuf/ibuf0ibuf.c 
+					 pars/lexyy.c pars/pars0grm.c pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c 
+					 lock/lock0lock.c lock/lock0iter.c 
+					 log/log0log.c log/log0recv.c 
+					 mach/mach0data.c 
+					 mem/mem0mem.c mem/mem0pool.c 
+					 mtr/mtr0log.c mtr/mtr0mtr.c 
+					 os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c 
+					 page/page0cur.c page/page0page.c page/page0zip.c 
+					 que/que0que.c 
+					 handler/ha_innodb.cc handler/handler0alter.cc handler/i_s.cc handler/mysql_addons.cc 
+					 read/read0read.c 
+					 rem/rem0cmp.c rem/rem0rec.c
+					 row/row0ext.c row/row0ins.c row/row0merge.c row/row0mysql.c 
+					 row/row0purge.c row/row0row.c row/row0sel.c row/row0uins.c 
+					 row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c 
+					 srv/srv0que.c srv/srv0srv.c srv/srv0start.c 
+					 sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c 
+					 thr/thr0loc.c 
+					 trx/trx0i_s.c trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c 
+					 trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c 
+					 usr/usr0sess.c 
+					 ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c ut/ut0vec.c ut/ut0list.c ut/ut0wqueue.c)
+
+IF(NOT SOURCE_SUBLIBS)
+  ADD_LIBRARY(innobase ${INNOBASE_SOURCES})
+  ADD_DEPENDENCIES(innobase GenError)
+  SET_TARGET_PROPERTIES(innobase PROPERTIES COMPILE_FLAGS "-DMYSQL_SERVER")
+
+  IF(INNODB_DYNAMIC_PLUGIN)
+    # The dynamic plugin requires CMake 2.6.0 or later. Otherwise, the /DELAYLOAD property
+    # will not be set
+    CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
+    ADD_LIBRARY(ha_innodb SHARED ${INNOBASE_SOURCES} ha_innodb.def handler/win_delay_loader.cc)
+    ADD_DEPENDENCIES(ha_innodb GenError mysqld)
+    # If build type is not specified as Release, default to Debug
+    # This is a workaround to a problem in CMake 2.6, which does not
+    # set the path of mysqld.lib correctly
+    IF(CMAKE_BUILD_TYPE MATCHES Release)
+       SET(CMAKE_BUILD_TYPE "Release")
+    ELSE(CMAKE_BUILD_TYPE MATCHES Release)
+       SET(CMAKE_BUILD_TYPE "Debug") 
+    ENDIF(CMAKE_BUILD_TYPE MATCHES Release)
+    TARGET_LINK_LIBRARIES(ha_innodb strings zlib)
+    TARGET_LINK_LIBRARIES(ha_innodb ${CMAKE_SOURCE_DIR}/sql/${CMAKE_BUILD_TYPE}/mysqld.lib)
+    SET_TARGET_PROPERTIES(ha_innodb PROPERTIES OUTPUT_NAME ha_innodb)
+    SET_TARGET_PROPERTIES(ha_innodb PROPERTIES LINK_FLAGS "/MAP /MAPINFO:EXPORTS")
+    SET_TARGET_PROPERTIES(ha_innodb PROPERTIES LINK_FLAGS "/ENTRY:\"_DllMainCRTStartup@12\"")
+    SET_TARGET_PROPERTIES(ha_innodb PROPERTIES COMPILE_FLAGS "-DMYSQL_DYNAMIC_PLUGIN")
+    SET_TARGET_PROPERTIES(ha_innodb PROPERTIES LINK_FLAGS "/DELAYLOAD:mysqld.exe")
+  ENDIF(INNODB_DYNAMIC_PLUGIN)
+
+ENDIF(NOT SOURCE_SUBLIBS)

=== added file 'storage/xtradb/COPYING.Google'
--- a/storage/xtradb/COPYING.Google	1970-01-01 00:00:00 +0000
+++ b/storage/xtradb/COPYING.Google	2009-06-09 11:16:11 +0000
@@ -0,0 +1,30 @@
+Portions of this software contain modifications contributed by Google, Inc.
+These contributions are used with the following license:
+
+Copyright (c) 2008, Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+      * Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+      * Redistributions in binary form must reproduce the above
+        copyright notice, this list of conditions and the following
+        disclaimer in the documentation and/or other materials
+        provided with the distribution.
+      * Neither the name of the Google Inc. nor the names of its
+        contributors may be used to endorse or promote products
+        derived from this software without specific prior written
+        permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=== added file 'storage/xtradb/ChangeLog'
--- a/storage/xtradb/ChangeLog	1970-01-01 00:00:00 +0000
+++ b/storage/xtradb/ChangeLog	2009-06-09 11:16:11 +0000
@@ -0,0 +1,775 @@
+2009-03-05	The InnoDB Team
+
+	* handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
+	mysql-test/innodb-autoinc.test:
+	Fix Bug#43203 Overflow from auto incrementing causes server segv
+
+2009-02-25	The InnoDB Team
+
+	* handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
+	mysql-test/innodb-autoinc.test:
+	Fix Bug#42714 AUTO_INCREMENT errors in 5.1.31
+
+2009-02-23	The InnoDB Team
+
+	* btr/btr0cur.c:
+	Fix Bug#43043 Crash on BLOB delete operation
+
+2009-02-20	The InnoDB Team
+
+	* handler/ha_innodb.cc:
+	Make innodb_use_sys_malloc=ON the default.
+
+2009-02-20	The InnoDB Team
+
+	* handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
+	mysql-test/innodb-autoinc.test:
+	Fix Bug#42400 InnoDB autoinc code can't handle floating-point columns
+
+2009-02-18	The InnoDB Team
+
+	* include/ut0mem.h, os/os0proc.c, ut/ut0mem.c:
+	Protect ut_total_allocated_memory with ut_list_mutex in
+	os_mem_alloc_large() and os_mem_free_large(). The lack of this mutex
+	protection could cause an assertion failure during fast index
+	creation. Also, add UNIV_MEM_ALLOC and UNIV_MEM_FREE instrumentation
+	to os_mem_alloc_large() and os_mem_free_large(), so that Valgrind can
+	detect more errors.
+
+2009-02-11	The InnoDB Team
+
+	* handler/ha_innodb.cc:
+	Make innodb_thread_concurrency=0 the default. The old default value
+	was 8. A non-zero setting may be useful when InnoDB is showing severe
+	scalability problems under multiple concurrent connections.
+
+2009-02-10	The InnoDB Team
+
+	* handler/ha_innodb.cc, handler/ha_innodb.h:
+	Fix Bug#41676 Table names are case insensitive in locking
+
+2009-02-10	The InnoDB Team
+
+	* mem/mem0dbg.c, mem/mem0mem.c, mem/mem0pool.c:
+	When innodb_use_sys_malloc is set, ignore
+	innodb_additional_mem_pool_size, because nothing will be allocated
+	from mem_comm_pool.
+
+2009-02-10	The InnoDB Team
+
+	* ut/ut0mem.c:
+	Map ut_malloc_low(), ut_realloc(), and ut_free() directly to malloc(),
+	realloc(), and free() when innodb_use_sys_malloc is set. As a side
+	effect, ut_total_allocated_memory ("Total memory allocated" in the
+	"BUFFER POOL AND MEMORY" section of SHOW ENGINE INNODB STATUS) will
+	exclude any memory allocated by these functions when
+	innodb_use_sys_malloc is set.
+
+2009-02-10	The InnoDB Team
+
+	* btr/btr0cur.c, btr/btr0sea.c, buf/buf0buf.c, handler/ha_innodb.cc,
+	include/buf0buf.ic, include/os0sync.h, include/srv0srv.h,
+	include/sync0rw.h, include/sync0rw.ic, include/sync0sync.h,
+	include/sync0sync.ic, include/univ.i, row/row0sel.c, srv/srv0srv.c,
+	srv/srv0start.c, sync/sync0arr.c, sync/sync0rw.c, sync/sync0sync.c:
+	On those platforms that support it, implement the synchronization
+	primitives of InnoDB mutexes and read/write locks with GCC atomic
+	builtins instead of Pthreads mutexes and InnoDB mutexes. These changes
+	are based on a patch supplied by Mark Callaghan of Google under a BSD
+	license.
+
+2009-01-30	The InnoDB Team
+
+	* btr/btr0cur.c, btr/btr0sea.c, buf/buf0buf.c, handler/ha_innodb.cc,
+	include/btr0sea.h, include/buf0buf.h, include/sync0sync.h,
+	sync/sync0sync.c:
+	Make the configuration parameter innodb_adaptive_hash_index dynamic,
+	so that it can be changed at runtime.
+
+2009-01-29	The InnoDB Team
+
+	* handler/ha_innodb.cc, ibuf/ibuf0ibuf.c, include/ibuf0ibuf.h,
+	include/ibuf0ibuf.ic:
+	Implement the settable global variable innodb_change_buffering,
+	with the allowed values 'none' and 'inserts'. The default value
+	'inserts' enables the buffering of inserts to non-unique secondary
+	index trees when the B-tree leaf page is not in the buffer pool.
+
+2009-01-27	The InnoDB Team
+
+	* buf/buf0lru.c:
+	Fix a race condition in buf_LRU_invalidate_tablespace(): The
+	compressed page size (zip_size) was read while the block descriptor
+	was no longer protected by a mutex. This could lead to corruption
+	when a table is dropped on a busy system that contains compressed
+	tables.
+
+2009-01-26	The InnoDB Team
+
+	* btr/btr0sea.c, buf/buf0buf.c, include/buf0buf.h, include/buf0buf.ic,
+	include/mtr0log.ic, include/row0upd.ic, mtr/mtr0mtr.c:
+	Implement buf_block_align() with pointer arithmetics, as it is in the
+	built-in InnoDB distributed with MySQL. Do not acquire the buffer pool
+	mutex before buf_block_align(). This removes a scalability bottleneck
+	in the adaptive hash index lookup. In CHECK TABLE, check that
+	buf_pool->page_hash is consistent with buf_block_align().
+
+2009-01-23	The InnoDB Team
+
+	* btr/btr0sea.c:
+	Fix Bug#42279 Race condition in btr_search_drop_page_hash_when_freed()
+
+2009-01-23	The InnoDB Team
+
+	* buf/buf0buf.c, include/buf0buf.h:
+	Remove the unused mode BUF_GET_NOWAIT of buf_page_get_gen()
+
+2009-01-20	The InnoDB Team
+
+	* include/rem0rec.h, include/rem0rec.ic:
+	Fix Bug#41571 MySQL segfaults after innodb recovery
+
+2009-01-20	The InnoDB Team
+
+	* lock/lock0lock.c:
+	Fix Bug#42152 Race condition in lock_is_table_exclusive()
+
+2009-01-14	The InnoDB Team
+
+	* include/trx0roll.h, trx/trx0roll.c, trx/trx0trx.c:
+	Fix Bug#38187 Error 153 when creating savepoints
+
+2009-01-14	The InnoDB Team
+
+	* dict/dict0load.c:
+	Fix Bug#42075 dict_load_indexes failure in dict_load_table will
+	corrupt the dictionary cache
+
+2009-01-13	The InnoDB Team
+
+	* buf/buf0buddy.c, dict/dict0dict.c, dict/dict0mem.c, fil/fil0fil.c,
+	ha/ha0storage.c, handler/ha_innodb.cc, handler/win_delay_loader.cc,
+	include/buf0buf.ic, include/dict0dict.ic, include/hash0hash.h,
+	thr/thr0loc.c, trx/trx0i_s.c:
+	Add the parameter ASSERTION to HASH_SEARCH() macro, and use it for
+	light validation of the traversed items in hash table lookups when
+	UNIV_DEBUG is enabled.
+
+2009-01-09	The InnoDB Team
+
+	* buf/buf0flu.c, include/buf0flu.h, include/buf0flu.ic:
+	Remove unused code from the functions
+	buf_flush_insert_into_flush_list() and
+	buf_flush_insert_sorted_into_flush_list().
+
+2009-01-09	The InnoDB Team
+
+	* buf/buf0flu.c:
+	Simplify the functions buf_flush_try_page() and buf_flush_batch(). Add
+	debug assertions and an explanation to buf_flush_write_block_low().
+
+2009-01-07	The InnoDB Team
+
+	* row/row0merge.c:
+	Fix a bug in recovery when dropping temporary indexes.
+
+2009-01-07	The InnoDB Team
+
+	* handler/ha_innodb.cc, handler/ha_innodb.h, handler/handler0alter.cc:
+	Fix Bug#41680 calls to trx_allocate_for_mysql are not consistent
+
+2009-01-07	The InnoDB Team
+
+	* mysql-test/innodb_bug41904.result, mysql-test/innodb_bug41904.test,
+	row/row0merge.c:
+	Fix Bug#41904 create unique index problem
+
+2009-01-02	The InnoDB Team
+
+	* handler/ha_innodb.cc, include/srv0srv.h, mem/mem0pool.c,
+	mysql-test/innodb-use-sys-malloc-master.opt,
+	mysql-test/innodb-use-sys-malloc.result,
+	mysql-test/innodb-use-sys-malloc.test, srv/srv0srv.c, srv/srv0start.c:
+	Implement the configuration parameter innodb_use_sys_malloc (false by
+	default), for disabling InnoDB's internal memory allocator and using
+	system malloc/free instead. The "BUFFER POOL AND MEMORY" section of
+	SHOW ENGINE INNODB STATUS will report "in additional pool allocated
+	allocated 0" when innodb_use_sys_malloc is set.
+
+2008-12-30	The InnoDB Team
+
+	* btr/btr0btr.c:
+	When setting the PAGE_LEVEL of a compressed B-tree page from or to 0,
+	compress the page at the same time. This is necessary, because the
+	column information stored on the compressed page will differ between
+	leaf and non-leaf pages. Leaf pages are identified by PAGE_LEVEL=0.
+	This bug can make InnoDB crash when all rows of a compressed table are
+	deleted.
+
+2008-12-17	The InnoDB Team
+
+	* include/row0sel.h, include/row0upd.h, pars/pars0pars.c,
+	row/row0mysql.c, row/row0sel.c, row/row0upd.c:
+	Remove update-in-place select from the internal SQL interpreter. It
+	was only used for updating the InnoDB internal data dictionary when
+	renaming or dropping tables. It could have caused deadlocks when
+	acquiring latches on insert buffer bitmap pages.
+
+2008-12-17	The InnoDB Team
+
+	* btr/btr0sea.c, buf/buf0buf.c, buf/buf0lru.c, ha/ha0ha.c,
+	ha/hash0hash.c, include/buf0buf.h, include/ha0ha.h, include/ha0ha.ic,
+	include/hash0hash.h, include/univ.i:
+	Introduce the preprocessor symbol UNIV_AHI_DEBUG for enabling adaptive
+	hash index debugging independently of UNIV_DEBUG.
+
+2008-12-16	The InnoDB Team
+
+	* btr/btr0cur.c:
+	Do not update the free bits in the insert buffer bitmap when inserting
+	or deleting from the insert buffer B-tree. Assert that records in the
+	insert buffer B-tree are never updated.
+
+2008-12-12	The InnoDB Team
+
+	* buf/buf0buf.c, fil/fil0fil.c, fsp/fsp0fsp.c, ibuf/ibuf0ibuf.c,
+	include/fil0fil.h, include/ibuf0ibuf.h, include/ibuf0ibuf.ic,
+	include/ibuf0types.h:
+	Clean up the insert buffer subsystem so that only one insert
+	buffer B-tree exists.
+	Originally, there were provisions in InnoDB for multiple insert
+	buffer B-trees, apparently one for each tablespace.
+	When Heikki Tuuri implemented multiple InnoDB tablespaces in
+	MySQL/InnoDB 4.1, he made the insert buffer live only in the
+	system tablespace (space 0) but left the provisions in the code.
+
+2008-12-11	The InnoDB Team
+
+	* include/srv0srv.h, os/os0proc.c, srv/srv0srv.c:
+	Fix the issue that the InnoDB plugin fails if innodb_buffer_pool_size
+	is defined bigger than 4096M on 64-bit Windows. This bug should not
+	have affected other 64-bit systems.
+
+2008-12-09	The InnoDB Team
+
+	* handler/ha_innodb.cc:
+	Fix Bug#40386 Not flushing query cache after truncate.
+
+2008-12-09	The InnoDB Team
+
+	* handler/ha_innodb.cc, srv/srv0srv.c, trx/trx0trx.c:
+	Fix Bug#40760 "set global innodb_thread_concurrency = 0;" is not safe
+
+2008-12-04	The InnoDB Team
+
+	* handler/ha_innodb.cc, handler/mysql_addons.cc,
+	include/mysql_addons.h, trx/trx0i_s.c, win-plugin/win-plugin.diff:
+	Remove dependencies to MySQL internals (defining MYSQL_SERVER).
+
+2008-12-02	The InnoDB Team
+
+	* page/page0cur.c:
+	When allocating space for a record from the free list of previously
+	purged records, zero out the DB_TRX_ID and DB_ROLL_PTR of the purged
+	record if the new record would not overwrite these fields. This fixes
+	a harmless content mismatch reported by page_zip_validate().
+
+2008-12-02	The InnoDB Team
+
+	* row/row0merge.c:
+	Replace the WHILE 1 with WHILE 1=1 in the SQL procedure, so that the
+	loop will actually be entered and temporary indexes be dropped during
+	crash recovery.
+
+2008-12-01	The InnoDB Team
+
+	InnoDB Plugin 1.0.2 released
+
+2008-10-31	The InnoDB Team
+
+	* dict/dict0mem.c, include/dict0mem.h, include/lock0lock.h,
+	include/row0mysql.h, include/trx0trx.h, include/univ.i,
+	include/ut0vec.h, include/ut0vec.ic, lock/lock0lock.c,
+	row/row0mysql.c, trx/trx0trx.c:
+	Fix Bug#26316 Triggers create duplicate entries on auto-increment
+	columns
+
+2008-10-30	The InnoDB Team
+
+	* handler/ha_innodb.cc, handler/handler0vars.h,
+	handler/win_delay_loader.cc, mysql-test/innodb_bug40360.result,
+	mysql-test/innodb_bug40360.test:
+	Fix Bug#40360 Binlog related errors with binlog off
+
+2008-10-29	The InnoDB Team
+
+	* include/data0type.ic:
+	Fix Bug#40369 dtype_get_sql_null_size() returns 0 or 1, not the size
+
+2008-10-29	The InnoDB Team
+
+	* handler/ha_innodb.cc, include/srv0srv.h, srv/srv0srv.c:
+	Fix Bug#38189 innodb_stats_on_metadata missing
+
+2008-10-28	The InnoDB Team
+
+	* CMakeLists.txt, ha_innodb.def, handler/ha_innodb.cc,
+	handler/handler0alter.cc, handler/handler0vars.h, handler/i_s.cc,
+	handler/win_delay_loader.cc, win-plugin/*:
+	Implemented the delayloading of externals for the plugin on Windows.
+	This makes it possible to build a dynamic plugin (ha_innodb.dll) on
+	Windows.
+
+2008-10-27	The InnoDB Team
+
+	* CMakeLists.txt:
+	Fix Bug#19424 InnoDB: Possibly a memory overrun of the buffer being
+	freed (64-bit Visual C)
+
+2008-10-23	The InnoDB Team
+
+	* ibuf/ibuf0ibuf.c:
+	ibuf_delete_rec(): When the cursor to the insert buffer record
+	cannot be restored, do not complain if the tablespace does not
+	exist, because the insert buffer record may have been discarded by
+	some other thread. This bug has existed in MySQL/InnoDB since
+	version 4.1, when innodb_file_per_table was implemented.
+	This may fix Bug#27276 InnoDB Error: ibuf cursor restoration fails.
+
+2008-10-22	The InnoDB Team
+
+	* dict/dict0dict.c, dict/dict0mem.c, handler/ha_innodb.cc,
+	handler/ha_innodb.h, include/dict0dict.h, include/dict0mem.h,
+	row/row0mysql.c:
+	Fix Bug#39830 Table autoinc value not updated on first insert
+	Fix Bug#35498 Cannot get table test/table1 auto-inccounter value in
+	::info
+	Fix Bug#36411 "Failed to read auto-increment value from storage
+	engine" in 5.1.24 auto-inc
+
+2008-10-22	The InnoDB Team
+
+	* handler/ha_innodb.cc, include/row0mysql.h, row/row0mysql.c:
+	Fix Bug#40224 New AUTOINC changes mask reporting of deadlock/timeout
+	errors
+
+2008-10-16	The InnoDB Team
+
+	* dict/dict0dict.c, mysql-test/innodb-index.result,
+	mysql-test/innodb-index.test:
+	Skip the undo log size check when creating REDUNDANT and COMPACT
+	tables. In ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPRESSED, column
+	prefix indexes require that prefixes of externally stored columns
+	be written to the undo log. This may make the undo log record
+	bigger than the record on the B-tree page. The maximum size of an
+	undo log record is the page size. That must be checked for, in
+	dict_index_add_to_cache(). However, this restriction must not
+	be enforced on REDUNDANT or COMPACT tables.
+
+2008-10-15	The InnoDB Team
+
+	* btr/btr0cur.c, include/btr0cur.h, row/row0ext.c, row/row0sel.c,
+	row/row0upd.c:
+	When the server crashes while freeing an externally stored column
+	of a compressed table, the BTR_EXTERN_LEN field in the BLOB
+	pointer will be written as 0. Tolerate this in the functions that
+	deal with externally stored columns. This fixes problems after
+	crash recovery, in the rollback of incomplete transactions, and in
+	the purge of delete-marked records.
+
+2008-10-15	The InnoDB Team
+
+	* btr/btr0btr.c, include/page0zip.h, page/page0zip.c, include/univ.i:
+	When a B-tree node of a compressed table is split or merged, the
+	compression may fail. In this case, the entire compressed page
+	will be copied and the excess records will be deleted. However,
+	page_zip_copy(), now renamed to page_zip_copy_recs(), copied too
+	many fields in the page header, overwriting PAGE_BTR_SEG_LEAF and
+	PAGE_BTR_SEG_TOP when splitting the B-tree root. This caused
+	corruption of compressed tables. Furthermore, the lock table and
+	the adaptive hash index would be corrupted, because we forgot to
+	update them when invoking page_zip_copy_recs().
+
+	Introduce the symbol UNIV_ZIP_DEBUG for triggering the copying of
+	compressed pages more often, for debugging purposes.
+
+2008-10-10	The InnoDB Team
+
+	* handler/handler0alter.cc, include/row0merge.h, row/row0merge.c,
+	row/row0mysql.c:
+	Fix some locking issues, mainly in fast index creation. The
+	InnoDB data dictionary cache should be latched whenever a
+	transaction is holding locks on any data dictionary tables.
+	Otherwise, lock waits or deadlocks could occur. Furthermore, the
+	data dictionary transaction must be committed (and the locks
+	released) before the data dictionary latch is released.
+
+	ha_innobase::add_index(): Lock the data dictionary before renaming
+	or dropping the created indexes, because neither operation will
+	commit the data dictionary transaction.
+
+	ha_innobase::final_drop_index(): Commit the transactions before
+	unlocking the data dictionary.
+
+2008-10-09	The InnoDB Team
+
+	* buf/buf0lru.c:
+	Fix Bug#39939 DROP TABLE/DISCARD TABLESPACE takes long time in
+	buf_LRU_invalidate_tablespace()
+
+2008-10-08	The InnoDB Team
+
+	* dict/dict0crea.c, trx/trx0roll.c, include/row0mysql.h,
+	row/row0merge.c, row/row0mysql.c:
+	When dropping a table, hold the data dictionary latch until the
+	transaction has been committed. The data dictionary latch is
+	supposed to prevent lock waits and deadlocks in the data
+	dictionary tables. Due to this bug, DROP TABLE could cause a
+	deadlock or hang. Note that because of Bug#33650 and Bug#39833,
+	MySQL may also drop a (temporary) table when executing CREATE INDEX
+	or ALTER TABLE ... ADD INDEX.
+
+2008-10-04	The InnoDB Team
+
+	* handler/ha_innodb.cc, mysql-test/innodb_bug39438-master.opt,
+	mysql-test/innodb_bug39438.result, mysql-test/innodb_bug39438.test:
+	Fix Bug#39438 Testcase for Bug#39436 crashes on 5.1 in
+	fil_space_get_latch
+
+2008-10-04	The InnoDB Team
+
+	* include/lock0lock.h, lock/lock0lock.c,
+	mysql-test/innodb_bug38231.result, mysql-test/innodb_bug38231.test,
+	row/row0mysql.c:
+	Fix Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE +
+	LOCK / UNLOCK
+
+2008-10-04	The InnoDB Team
+
+	* handler/ha_innodb.cc:
+	Fix Bug#35498 Cannot get table test/table1 auto-inccounter value in
+	::info
+
+2008-10-04	The InnoDB Team
+
+	* handler/ha_innodb.cc, handler/ha_innodb.h:
+	Fix Bug#37788 InnoDB Plugin: AUTO_INCREMENT wrong for compressed
+	tables
+
+2008-10-04	The InnoDB Team
+
+	* dict/dict0dict.c, handler/ha_innodb.cc, handler/ha_innodb.h,
+	include/dict0dict.h, include/dict0mem.h, row/row0mysql.c:
+	Fix Bug#39830 Table autoinc value not updated on first insert
+
+2008-10-03	The InnoDB Team
+
+	* mysql-test/innodb-index.test, mysql-test/innodb-index.result,
+	mysql-test/innodb-timeout.test, mysql-test/innodb-timeout.result,
+	srv/srv0srv.c, include/srv0srv.h, handler/ha_innodb.cc,
+	include/ha_prototypes.h:
+	Fix Bug#36285 innodb_lock_wait_timeout is not dynamic, not per session
+
+2008-09-19	The InnoDB Team
+
+	* os/os0proc.c:
+	Fix a memory leak on Windows. The memory leak was due to wrong
+	parameters passed into VirtualFree() call. As the result, the
+	call fails with Windows error 87.
+
+2008-09-17	The InnoDB Team
+
+	* mysql-test/innodb.result, mysql-test/innodb-zip.result,
+	mysql-test/innodb-zip.test, mysql-test/innodb.test, ibuf/ibuf0ibuf.c,
+	dict/dict0crea.c, dict/dict0load.c, dict/dict0boot.c,
+	include/dict0dict.h, include/trx0trx.h, dict/dict0dict.c,
+	trx/trx0trx.c, include/ha_prototypes.h, handler/ha_innodb.cc:
+	When creating an index in innodb_strict_mode, check that the
+	maximum record size will never exceed the B-tree page size limit.
+	For uncompressed tables, there should always be enough space for
+	two records in an empty B-tree page. For compressed tables, there
+	should be enough space for storing two node pointer records or one
+	data record in an empty page in uncompressed format.
+	The purpose of this check is to guarantee that INSERT or UPDATE
+	will never fail due to too big record size.
+
+2008-09-17	The InnoDB Team
+
+	* btr/btr0cur.c, data/data0data.c, include/page0zip.h,
+	include/page0zip.ic, page/page0zip.c, mysql-test/innodb_bug36172.test:
+	Prevent infinite B-tree page splits in compressed tables by
+	ensuring that there will always be enough space for two node
+	pointer records in an empty B-tree page. Also, require that at
+	least one data record will fit in an empty compressed page. This
+	will reduce the maximum size of records in compressed tables.
+
+2008-09-09	The InnoDB Team
+
+	* mysql-test/innodb.result:
+	Fix the failing innodb test by merging changes that MySQL made to
+	that file (r2646.12.1 in MySQL BZR repository)
+
+2008-09-09	The InnoDB Team
+
+	* handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
+	mysql-test/innodb-autoinc.test:
+	Fix Bug#38839 auto increment does not work properly with InnoDB after
+	update
+
+2008-09-09	The InnoDB Team
+
+	* dict/dict0dict.c, handler/handler0alter.cc, include/dict0dict.h,
+	mysql-test/innodb-index.result, mysql-test/innodb-index.test:
+	Fix Bug#38786 InnoDB plugin crashes on drop table/create table with FK
+
+2008-08-21	The InnoDB Team
+
+	* handler/ha_innodb.cc, include/ha_prototypes.h, row/row0sel.c:
+	Fix Bug#37885 row_search_for_mysql may gap lock unnecessarily with SQL
+	comments in query
+
+2008-08-21	The InnoDB Team
+
+	* handler/ha_innodb.cc:
+	Fix Bug#38185 ha_innobase::info can hold locks even when called with
+	HA_STATUS_NO_LOCK
+
+2008-08-18	The InnoDB Team
+
+	* buf/buf0buf.c, buf/buf0lru.c, include/buf0buf.ic, include/univ.i:
+	Introduce UNIV_LRU_DEBUG for debugging the LRU buffer pool cache
+
+2008-08-08	The InnoDB Team
+
+	* buf/buf0lru.c, include/buf0buf.h:
+	Fix two recovery bugs that could lead to a crash in debug builds with
+	small buffer size
+
+2008-08-07	The InnoDB Team
+
+	* btr/btr0cur.c, handler/ha_innodb.cc, include/srv0srv.h,
+	srv/srv0srv.c:
+	Add a parameter innodb_stats_sample_pages to allow users to control
+	the number of index dives when InnoDB estimates the cardinality of
+	an index (ANALYZE TABLE, SHOW TABLE STATUS etc)
+
+2008-08-07	The InnoDB Team
+
+	* trx/trx0i_s.c:
+	Fix a bug that would lead to a crash if a SELECT was issued from the
+	INFORMATION_SCHEMA tables and there are rolling back transactions at
+	the same time
+
+2008-08-06	The InnoDB Team
+
+	* btr/btr0btr.c, btr/btr0cur.c, ibuf/ibuf0ibuf.c, include/btr0cur.h,
+	include/trx0roll.h, include/trx0types.h, row/row0purge.c,
+	row/row0uins.c, row/row0umod.c, trx/trx0roll.c:
+	In the rollback of incomplete transactions after crash recovery,
+	tolerate clustered index records whose externally stored columns
+	have not been written.
+
+2008-07-30	The InnoDB Team
+
+	* trx/trx0trx.c:
+	Fixes a race in recovery where the recovery thread recovering a
+	PREPARED trx and the background rollback thread can both try
+	to free the trx after its status is set to COMMITTED_IN_MEMORY.
+
+2008-07-29	The InnoDB Team
+
+	* include/trx0rec.h, row/row0purge.c, row/row0vers.c, trx/trx0rec.c:
+	Fix a BLOB corruption bug
+
+2008-07-15	The InnoDB Team
+
+	* btr/btr0sea.c, dict/dict0dict.c, include/btr0sea.h:
+	Fixed a timing hole where a thread dropping an index can free the
+	in-memory index struct while another thread is still using that
+	structure to remove entries from adaptive hash index belonging
+	to one of the pages that belongs to the index being dropped.
+
+2008-07-04	The InnoDB Team
+
+	* mysql-test/innodb-index.result:
+	Fix the failing innodb-index test by adjusting the result to a new
+	MySQL behavior (the change occured in BZR-r2667)
+
+2008-07-03	The InnoDB Team
+
+	* mysql-test/innodb-zip.result, mysql-test/innodb-zip.test:
+	Remove the negative test cases that produce warnings
+
+2008-07-02	The InnoDB Team
+
+	* mysql-test/innodb-replace.result, mysql-test/innodb-index.test:
+	Disable part of innodb-index test because MySQL changed its behavior
+	and is not calling ::add_index() anymore when adding primary index on
+	non-NULL column
+
+2008-07-01	The InnoDB Team
+
+	* mysql-test/innodb-replace.result, mysql-test/innodb-replace.test:
+	Fix the failing innodb-replace test by merging changes that MySQL
+	made to that file (r2659 in MySQL BZR repository)
+
+2008-07-01	The InnoDB Team
+
+	* lock/lock0lock.c:
+	Fix Bug#36942 Performance problem in lock_get_n_rec_locks (SHOW INNODB
+	STATUS)
+
+2008-07-01	The InnoDB Team
+
+	* ha/ha0ha.c:
+	Fix Bug#36941 Performance problem in ha_print_info (SHOW INNODB
+	STATUS)
+
+2008-07-01	The InnoDB Team
+
+	* handler/ha_innodb.cc, mysql-test/innodb-autoinc.result,
+	mysql-test/innodb-autoinc.test:
+	Fix Bug#37531 After truncate, auto_increment behaves incorrectly for
+	InnoDB
+
+2008-06-19	The InnoDB Team
+
+	* handler/ha_innodb.cc:
+	Rewrite the function innodb_plugin_init() to support parameters in
+	different order (in static and dynamic InnoDB) and to support more
+	parameters in the static InnoDB
+
+2008-06-19	The InnoDB Team
+
+	* handler/handler0alter.cc:
+	Fix a bug in ::add_index() which set the transaction state to "active"
+	but never restored it to the original value. This bug caused warnings
+	to be printed by the rpl.rpl_ddl mysql-test.
+
+2008-06-19	The InnoDB Team
+
+	* mysql-test/patches:
+	Add a directory which contains patches, which need to be applied to
+	MySQL source in order to get some mysql-tests to succeed. The patches
+	cannot be committed in MySQL repository because they are specific to
+	the InnoDB plugin.
+
+2008-06-19	The InnoDB Team
+
+	* mysql-test/innodb-zip.result, mysql-test/innodb-zip.test,
+	row/row0row.c:
+	Fix an anomaly when updating a record with BLOB prefix
+
+2008-06-18	The InnoDB Team
+
+	* include/trx0sys.h, srv/srv0start.c, trx/trx0sys.c:
+	Fix a bug in recovery which was a side effect of the file_format_check
+	changes
+
+2008-06-09	The InnoDB Team
+
+	* mysql-test/innodb.result:
+	Fix the failing innodb test by merging changes that MySQL made to that
+	file
+
+2008-06-06	The InnoDB Team
+
+	* buf/buf0buf.c, handler/ha_innodb.cc, include/buf0buf.h,
+	include/srv0srv.h, srv/srv0srv.c:
+	Fix Bug#36600 SHOW STATUS takes a lot of CPU in
+	buf_get_latched_pages_number
+
+	* handler/ha_innodb.cc, os/os0file.c:
+	Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
+	link hack
+
+	* include/ut0ut.h, srv/srv0srv.c, ut/ut0ut.c:
+	Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
+
+	* handler/ha_innodb.cc:
+	Fix Bug#35602 Failed to read auto-increment value from storage engine
+
+	* srv/srv0start.c:
+	Fix Bug#36149 Read buffer overflow in srv0start.c found during "make
+	test"
+
+2008-05-08	The InnoDB Team
+
+	* btr/btr0btr.c, mysql-test/innodb_bug36172.result,
+	mysql-test/innodb_bug36172.test:
+	Fix Bug#36172 insert into compressed innodb table crashes
+
+2008-05-08	The InnoDB Team
+
+	InnoDB Plugin 1.0.1 released
+
+2008-05-06	The InnoDB Team
+
+	* handler/ha_innodb.cc, include/srv0srv.h, include/sync0sync.h,
+	include/trx0sys.h, mysql-test/innodb-zip.result,
+	mysql-test/innodb-zip.test, srv/srv0srv.c, srv/srv0start.c,
+	sync/sync0sync.c, trx/trx0sys.c:
+	Implement the system tablespace tagging
+
+	* handler/ha_innodb.cc, handler/i_s.cc, include/univ.i,
+	srv/srv0start.c:
+	Add InnoDB version in INFORMATION_SCHEMA.PLUGINS.PLUGIN_VERSION,
+	in the startup message and in a server variable innodb_version.
+
+	* sync/sync0sync.c:
+	Fix a bug in the sync debug code where a lock with level
+	SYNC_LEVEL_VARYING would cause an assertion failure when a thread
+	tried to release it.
+
+2008-04-30	The InnoDB Team
+
+	* Makefile.am:
+	Fix Bug#36434 ha_innodb.so is installed in the wrong directory
+
+	* handler/ha_innodb.cc:
+	Merge change from MySQL (Fix Bug#35406 5.1-opt crashes on select from
+	I_S.REFERENTIAL_CONSTRAINTS):
+	ChangeSet@1.2563, 2008-03-18 19:42:04+04:00, gluh@xxxxxxxxx +1 -0
+
+	* scripts/install_innodb_plugins.sql:
+	Added
+
+	* mysql-test/innodb.result:
+	Merge change from MySQL (this fixes the failing innodb test):
+	ChangeSet@1.1810.3601.4, 2008-02-07 02:33:21+04:00
+
+	* row/row0sel.c:
+	Fix Bug#35226 RBR event crashes slave
+
+	* handler/ha_innodb.cc:
+	Change the fix for Bug#32440 to show bytes instead of kilobytes in
+	INFORMATION_SCHEMA.TABLES.DATA_FREE
+
+	* handler/ha_innodb.cc, mysql-test/innodb.result,
+	mysql-test/innodb.test:
+	Fix Bug#29507 TRUNCATE shows to many rows effected
+
+	* handler/ha_innodb.cc, mysql-test/innodb.result,
+	mysql-test/innodb.test:
+	Fix Bug#35537 Innodb doesn't increment handler_update and
+	handler_delete
+
+2008-04-29	The InnoDB Team
+
+	* handler/i_s.cc, include/srv0start.h, srv/srv0start.c:
+	Fix Bug#36310 InnoDB plugin crash
+
+2008-04-23	The InnoDB Team
+
+	* mysql-test/innodb_bug36169.result, mysql-test/innodb_bug36169.test,
+	row/row0mysql.c:
+	Fix Bug#36169 create innodb compressed table with too large row size
+	crashed
+
+	* (outside the source tree):
+	Fix Bug#36222 New InnoDB plugin 1.0 has wrong MKDIR_P defined in
+	Makefile.in
+
+2008-04-15	The InnoDB Team
+
+	InnoDB Plugin 1.0.0 released

=== added file 'storage/xtradb/Makefile.am'
--- a/storage/xtradb/Makefile.am	1970-01-01 00:00:00 +0000
+++ b/storage/xtradb/Makefile.am	2009-06-09 12:21:26 +0000
@@ -0,0 +1,195 @@
+# Copyright (C) 2001, 2004, 2006 MySQL AB & Innobase Oy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+# Process this file with automake to create Makefile.in
+
+MYSQLDATAdir=		$(localstatedir)
+MYSQLSHAREdir=		$(pkgdatadir)
+MYSQLBASEdir=		$(prefix)
+MYSQLLIBdir=		$(pkglibdir)
+pkgplugindir=		$(pkglibdir)/plugin
+INCLUDES=		-I$(top_srcdir)/include -I$(top_builddir)/include \
+			-I$(top_srcdir)/regex \
+			-I$(top_srcdir)/storage/xtradb/include \
+			-I$(top_srcdir)/sql \
+			-I$(srcdir)
+
+DEFS=			@DEFS@
+
+
+noinst_HEADERS=		include/btr0btr.h include/btr0btr.ic		\
+			include/btr0cur.h include/btr0cur.ic		\
+			include/btr0pcur.h include/btr0pcur.ic		\
+			include/btr0sea.h include/btr0sea.ic		\
+			include/btr0types.h include/buf0buddy.h		\
+			include/buf0buddy.ic include/buf0buf.h		\
+			include/buf0buf.ic include/buf0flu.h		\
+			include/buf0flu.ic include/buf0lru.h		\
+			include/buf0lru.ic include/buf0rea.h		\
+			include/buf0types.h include/data0data.h		\
+			include/data0data.ic include/data0type.h	\
+			include/data0type.ic include/data0types.h	\
+			include/db0err.h include/dict0boot.h		\
+			include/dict0boot.ic include/dict0crea.h	\
+			include/dict0crea.ic include/dict0dict.h	\
+			include/dict0dict.ic include/dict0load.h	\
+			include/dict0load.ic include/dict0mem.h		\
+			include/dict0mem.ic include/dict0types.h	\
+			include/dyn0dyn.h include/dyn0dyn.ic		\
+			include/eval0eval.h include/eval0eval.ic	\
+			include/eval0proc.h include/eval0proc.ic	\
+			include/fil0fil.h include/fsp0fsp.h		\
+			include/fsp0fsp.ic include/fut0fut.h		\
+			include/fut0fut.ic include/fut0lst.h		\
+			include/fut0lst.ic include/ha0ha.h		\
+			include/ha0ha.ic				\
+			include/ha0storage.h				\
+			include/ha0storage.ic				\
+			include/hash0hash.h				\
+			include/hash0hash.ic include/ibuf0ibuf.h	\
+			include/ibuf0ibuf.ic include/ibuf0types.h	\
+			include/lock0iter.h				\
+			include/lock0lock.h include/lock0lock.ic	\
+			include/lock0priv.h include/lock0priv.ic	\
+			include/lock0types.h include/log0log.h		\
+			include/log0log.ic include/log0recv.h		\
+			include/log0recv.ic include/mach0data.h		\
+			include/mach0data.ic include/mem0dbg.h		\
+			include/mem0dbg.ic mem/mem0dbg.c		\
+			include/mem0mem.h include/mem0mem.ic		\
+			include/mem0pool.h include/mem0pool.ic		\
+			include/mtr0log.h include/mtr0log.ic		\
+			include/mtr0mtr.h include/mtr0mtr.ic		\
+			include/mtr0types.h				\
+			include/mysql_addons.h				\
+			include/os0file.h				\
+			include/os0proc.h include/os0proc.ic		\
+			include/os0sync.h include/os0sync.ic		\
+			include/os0thread.h include/os0thread.ic	\
+			include/page0cur.h include/page0cur.ic		\
+			include/page0page.h include/page0page.ic	\
+			include/page0zip.h include/page0zip.ic		\
+			include/page0types.h include/pars0grm.h		\
+			include/pars0opt.h include/pars0opt.ic		\
+			include/pars0pars.h include/pars0pars.ic	\
+			include/pars0sym.h include/pars0sym.ic		\
+			include/pars0types.h include/que0que.h		\
+			include/que0que.ic include/que0types.h		\
+			include/read0read.h include/read0read.ic	\
+			include/read0types.h include/rem0cmp.h		\
+			include/rem0cmp.ic include/rem0rec.h		\
+			include/rem0rec.ic include/rem0types.h		\
+			include/row0ext.h include/row0ext.ic		\
+			include/row0ins.h include/row0ins.ic		\
+			include/row0merge.h				\
+			include/row0mysql.h include/row0mysql.ic	\
+			include/row0purge.h include/row0purge.ic	\
+			include/row0row.h include/row0row.ic		\
+			include/row0sel.h include/row0sel.ic		\
+			include/row0types.h include/row0uins.h		\
+			include/row0uins.ic include/row0umod.h		\
+			include/row0umod.ic include/row0undo.h		\
+			include/row0undo.ic include/row0upd.h		\
+			include/row0upd.ic include/row0vers.h		\
+			include/row0vers.ic include/srv0que.h		\
+			include/srv0srv.h include/srv0srv.ic		\
+			include/srv0start.h include/sync0arr.h		\
+			include/sync0arr.ic include/sync0rw.h		\
+			include/sync0rw.ic include/sync0sync.h		\
+			include/sync0sync.ic include/sync0types.h	\
+			include/thr0loc.h include/thr0loc.ic		\
+			include/trx0i_s.h				\
+			include/trx0purge.h include/trx0purge.ic	\
+			include/trx0rec.h include/trx0rec.ic		\
+			include/trx0roll.h include/trx0roll.ic		\
+			include/trx0rseg.h include/trx0rseg.ic		\
+			include/trx0sys.h include/trx0sys.ic		\
+			include/trx0trx.h include/trx0trx.ic		\
+			include/trx0types.h include/trx0undo.h		\
+			include/trx0undo.ic include/trx0xa.h		\
+			include/univ.i include/usr0sess.h		\
+			include/usr0sess.ic include/usr0types.h		\
+			include/ut0byte.h include/ut0byte.ic		\
+			include/ut0dbg.h include/ut0lst.h		\
+			include/ut0mem.h include/ut0mem.ic		\
+			include/ut0rnd.h include/ut0rnd.ic		\
+			include/ut0sort.h include/ut0ut.h		\
+			include/ut0ut.ic include/ut0vec.h		\
+			include/ut0vec.ic include/ut0list.h		\
+			include/ut0list.ic include/ut0wqueue.h		\
+			include/ha_prototypes.h handler/ha_innodb.h	\
+			include/handler0alter.h				\
+			handler/i_s.h handler/innodb_patch_info.h
+
+EXTRA_LIBRARIES=	libinnobase.a
+noinst_LIBRARIES=	@plugin_innobase_static_target@
+libinnobase_a_SOURCES=	btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c	\
+			btr/btr0sea.c buf/buf0buddy.c			\
+			buf/buf0buf.c buf/buf0flu.c			\
+			buf/buf0lru.c buf/buf0rea.c data/data0data.c	\
+			data/data0type.c dict/dict0boot.c		\
+			dict/dict0crea.c dict/dict0dict.c		\
+			dict/dict0load.c dict/dict0mem.c dyn/dyn0dyn.c	\
+			eval/eval0eval.c eval/eval0proc.c		\
+			fil/fil0fil.c fsp/fsp0fsp.c fut/fut0fut.c	\
+			fut/fut0lst.c ha/ha0ha.c			\
+			ha/ha0storage.c					\
+			ha/hash0hash.c					\
+			ibuf/ibuf0ibuf.c lock/lock0iter.c		\
+			lock/lock0lock.c				\
+			log/log0log.c log/log0recv.c mach/mach0data.c	\
+			mem/mem0mem.c mem/mem0pool.c mtr/mtr0log.c	\
+			mtr/mtr0mtr.c os/os0file.c os/os0proc.c		\
+			os/os0sync.c os/os0thread.c page/page0cur.c	\
+			page/page0page.c page/page0zip.c		\
+			pars/lexyy.c pars/pars0grm.c			\
+			pars/pars0opt.c pars/pars0pars.c		\
+			pars/pars0sym.c que/que0que.c read/read0read.c	\
+			rem/rem0cmp.c rem/rem0rec.c row/row0ext.c	\
+			row/row0ins.c row/row0merge.c			\
+			row/row0mysql.c row/row0purge.c row/row0row.c	\
+			row/row0sel.c row/row0uins.c row/row0umod.c	\
+			row/row0undo.c row/row0upd.c row/row0vers.c	\
+			srv/srv0que.c srv/srv0srv.c srv/srv0start.c	\
+			sync/sync0arr.c sync/sync0rw.c			\
+			sync/sync0sync.c thr/thr0loc.c			\
+			trx/trx0i_s.c					\
+			trx/trx0purge.c					\
+			trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c	\
+			trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c	\
+			usr/usr0sess.c ut/ut0byte.c ut/ut0dbg.c		\
+			ut/ut0list.c ut/ut0mem.c ut/ut0rnd.c		\
+			ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c		\
+			handler/ha_innodb.cc handler/handler0alter.cc	\
+			handler/i_s.cc					\
+			handler/mysql_addons.cc
+
+libinnobase_a_CXXFLAGS=	$(AM_CFLAGS)
+libinnobase_a_CFLAGS=	$(AM_CFLAGS)
+
+EXTRA_LTLIBRARIES=	ha_innodb.la
+pkgplugin_LTLIBRARIES=	@plugin_innobase_shared_target@
+
+ha_innodb_la_LDFLAGS=	-module -rpath $(pkgplugindir)
+ha_innodb_la_CXXFLAGS=	$(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
+ha_innodb_la_CFLAGS=	$(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
+ha_innodb_la_SOURCES=	$(libinnobase_a_SOURCES)
+
+EXTRA_DIST=		CMakeLists.txt plug.in \
+			pars/make_bison.sh pars/make_flex.sh \
+			pars/pars0grm.y pars/pars0lex.l
+
+# Don't update the files from bitkeeper
+%::SCCS/s.%

=== added directory 'storage/xtradb/btr'
=== added file 'storage/xtradb/btr/btr0btr.c'
--- a/storage/xtradb/btr/btr0btr.c	1970-01-01 00:00:00 +0000
+++ b/storage/xtradb/btr/btr0btr.c	2009-03-26 06:11:11 +0000
@@ -0,0 +1,3656 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/******************************************************
+The B-tree
+
+Created 6/2/1994 Heikki Tuuri
+*******************************************************/
+
+#include "btr0btr.h"
+
+#ifdef UNIV_NONINL
+#include "btr0btr.ic"
+#endif
+
+#include "fsp0fsp.h"
+#include "page0page.h"
+#include "page0zip.h"
+#include "btr0cur.h"
+#include "btr0sea.h"
+#include "btr0pcur.h"
+#include "rem0cmp.h"
+#include "lock0lock.h"
+#include "ibuf0ibuf.h"
+#include "trx0trx.h"
+
+/*
+Latching strategy of the InnoDB B-tree
+--------------------------------------
+A tree latch protects all non-leaf nodes of the tree. Each node of a tree
+also has a latch of its own.
+
+A B-tree operation normally first acquires an S-latch on the tree. It
+searches down the tree and releases the tree latch when it has the
+leaf node latch. To save CPU time we do not acquire any latch on
+non-leaf nodes of the tree during a search, those pages are only bufferfixed.
+
+If an operation needs to restructure the tree, it acquires an X-latch on
+the tree before searching to a leaf node. If it needs, for example, to
+split a leaf,
+(1) InnoDB decides the split point in the leaf,
+(2) allocates a new page,
+(3) inserts the appropriate node pointer to the first non-leaf level,
+(4) releases the tree X-latch,
+(5) and then moves records from the leaf to the new allocated page.
+
+Node pointers
+-------------
+Leaf pages of a B-tree contain the index records stored in the
+tree. On levels n > 0 we store 'node pointers' to pages on level
+n - 1. For each page there is exactly one node pointer stored:
+thus the our tree is an ordinary B-tree, not a B-link tree.
+
+A node pointer contains a prefix P of an index record. The prefix
+is long enough so that it determines an index record uniquely.
+The file page number of the child page is added as the last
+field. To the child page we can store node pointers or index records
+which are >= P in the alphabetical order, but < P1 if there is
+a next node pointer on the level, and P1 is its prefix.
+
+If a node pointer with a prefix P points to a non-leaf child,
+then the leftmost record in the child must have the same
+prefix P. If it points to a leaf node, the child is not required
+to contain any record with a prefix equal to P. The leaf case
+is decided this way to allow arbitrary deletions in a leaf node
+without touching upper levels of the tree.
+
+We have predefined a special minimum record which we
+define as the smallest record in any alphabetical order.
+A minimum record is denoted by setting a bit in the record
+header. A minimum record acts as the prefix of a node pointer
+which points to a leftmost node on any level of the tree.
+
+File page allocation
+--------------------
+In the root node of a B-tree there are two file segment headers.
+The leaf pages of a tree are allocated from one file segment, to
+make them consecutive on disk if possible. From the other file segment
+we allocate pages for the non-leaf levels of the tree.
+*/
+
+#ifdef UNIV_BTR_DEBUG
+/******************************************************************
+Checks a file segment header within a B-tree root page. */
+static
+ibool
+btr_root_fseg_validate(
+/*===================*/
+						/* out: TRUE if valid */
+	const fseg_header_t*	seg_header,	/* in: segment header */
+	ulint			space)		/* in: tablespace identifier */
+{
+	ulint	offset = mach_read_from_2(seg_header + FSEG_HDR_OFFSET);
+
+	ut_a(mach_read_from_4(seg_header + FSEG_HDR_SPACE) == space);
+	ut_a(offset >= FIL_PAGE_DATA);
+	ut_a(offset <= UNIV_PAGE_SIZE - FIL_PAGE_DATA_END);
+	return(TRUE);
+}
+#endif /* UNIV_BTR_DEBUG */
+
+/******************************************************************
+Gets the root node of a tree and x-latches it. */
+static
+buf_block_t*
+btr_root_block_get(
+/*===============*/
+				/* out: root page, x-latched */
+	dict_index_t*	index,	/* in: index tree */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ulint		space;
+	ulint		zip_size;
+	ulint		root_page_no;
+	buf_block_t*	block;
+
+	space = dict_index_get_space(index);
+	zip_size = dict_table_zip_size(index->table);
+	root_page_no = dict_index_get_page(index);
+
+	block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr);
+	ut_a((ibool)!!page_is_comp(buf_block_get_frame(block))
+	     == dict_table_is_comp(index->table));
+#ifdef UNIV_BTR_DEBUG
+	if (!dict_index_is_ibuf(index)) {
+		const page_t*	root = buf_block_get_frame(block);
+
+		ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
+					    + root, space));
+		ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
+					    + root, space));
+	}
+#endif /* UNIV_BTR_DEBUG */
+
+	return(block);
+}
+
+/******************************************************************
+Gets the root node of a tree and x-latches it. */
+UNIV_INTERN
+page_t*
+btr_root_get(
+/*=========*/
+				/* out: root page, x-latched */
+	dict_index_t*	index,	/* in: index tree */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	return(buf_block_get_frame(btr_root_block_get(index, mtr)));
+}
+
+/*****************************************************************
+Gets pointer to the previous user record in the tree. It is assumed that
+the caller has appropriate latches on the page and its neighbor. */
+UNIV_INTERN
+rec_t*
+btr_get_prev_user_rec(
+/*==================*/
+			/* out: previous user record, NULL if there is none */
+	rec_t*	rec,	/* in: record on leaf level */
+	mtr_t*	mtr)	/* in: mtr holding a latch on the page, and if
+			needed, also to the previous page */
+{
+	page_t*	page;
+	page_t*	prev_page;
+	ulint	prev_page_no;
+
+	if (!page_rec_is_infimum(rec)) {
+
+		rec_t*	prev_rec = page_rec_get_prev(rec);
+
+		if (!page_rec_is_infimum(prev_rec)) {
+
+			return(prev_rec);
+		}
+	}
+
+	page = page_align(rec);
+	prev_page_no = btr_page_get_prev(page, mtr);
+
+	if (prev_page_no != FIL_NULL) {
+
+		ulint		space;
+		ulint		zip_size;
+		buf_block_t*	prev_block;
+
+		space = page_get_space_id(page);
+		zip_size = fil_space_get_zip_size(space);
+
+		prev_block = buf_page_get_with_no_latch(space, zip_size,
+							prev_page_no, mtr);
+		prev_page = buf_block_get_frame(prev_block);
+		/* The caller must already have a latch to the brother */
+		ut_ad(mtr_memo_contains(mtr, prev_block,
+					MTR_MEMO_PAGE_S_FIX)
+		      || mtr_memo_contains(mtr, prev_block,
+					   MTR_MEMO_PAGE_X_FIX));
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(prev_page) == page_is_comp(page));
+		ut_a(btr_page_get_next(prev_page, mtr)
+		     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+
+		return(page_rec_get_prev(page_get_supremum_rec(prev_page)));
+	}
+
+	return(NULL);
+}
+
+/*****************************************************************
+Gets pointer to the next user record in the tree. It is assumed that the
+caller has appropriate latches on the page and its neighbor. */
+UNIV_INTERN
+rec_t*
+btr_get_next_user_rec(
+/*==================*/
+			/* out: next user record, NULL if there is none */
+	rec_t*	rec,	/* in: record on leaf level */
+	mtr_t*	mtr)	/* in: mtr holding a latch on the page, and if
+			needed, also to the next page */
+{
+	page_t*	page;
+	page_t*	next_page;
+	ulint	next_page_no;
+
+	if (!page_rec_is_supremum(rec)) {
+
+		rec_t*	next_rec = page_rec_get_next(rec);
+
+		if (!page_rec_is_supremum(next_rec)) {
+
+			return(next_rec);
+		}
+	}
+
+	page = page_align(rec);
+	next_page_no = btr_page_get_next(page, mtr);
+
+	if (next_page_no != FIL_NULL) {
+		ulint		space;
+		ulint		zip_size;
+		buf_block_t*	next_block;
+
+		space = page_get_space_id(page);
+		zip_size = fil_space_get_zip_size(space);
+
+		next_block = buf_page_get_with_no_latch(space, zip_size,
+							next_page_no, mtr);
+		next_page = buf_block_get_frame(next_block);
+		/* The caller must already have a latch to the brother */
+		ut_ad(mtr_memo_contains(mtr, next_block, MTR_MEMO_PAGE_S_FIX)
+		      || mtr_memo_contains(mtr, next_block,
+					   MTR_MEMO_PAGE_X_FIX));
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(next_page) == page_is_comp(page));
+		ut_a(btr_page_get_prev(next_page, mtr)
+		     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+
+		return(page_rec_get_next(page_get_infimum_rec(next_page)));
+	}
+
+	return(NULL);
+}
+
+/******************************************************************
+Creates a new index page (not the root, and also not
+used in page reorganization).  @see btr_page_empty(). */
+static
+void
+btr_page_create(
+/*============*/
+	buf_block_t*	block,	/* in/out: page to be created */
+	page_zip_des_t*	page_zip,/* in/out: compressed page, or NULL */
+	dict_index_t*	index,	/* in: index */
+	ulint		level,	/* in: the B-tree level of the page */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	page_t*		page = buf_block_get_frame(block);
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		page_create_zip(block, index, level, mtr);
+	} else {
+		page_create(block, mtr, dict_table_is_comp(index->table));
+		/* Set the level of the new index page */
+		btr_page_set_level(page, NULL, level, mtr);
+	}
+
+	block->check_index_page_at_flush = TRUE;
+
+	btr_page_set_index_id(page, page_zip, index->id, mtr);
+}
+
+/******************************************************************
+Allocates a new file page to be used in an ibuf tree. Takes the page from
+the free list of the tree, which must contain pages! */
+static
+buf_block_t*
+btr_page_alloc_for_ibuf(
+/*====================*/
+				/* out: new allocated block, x-latched */
+	dict_index_t*	index,	/* in: index tree */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	fil_addr_t	node_addr;
+	page_t*		root;
+	page_t*		new_page;
+	buf_block_t*	new_block;
+
+	root = btr_root_get(index, mtr);
+
+	node_addr = flst_get_first(root + PAGE_HEADER
+				   + PAGE_BTR_IBUF_FREE_LIST, mtr);
+	ut_a(node_addr.page != FIL_NULL);
+
+	new_block = buf_page_get(dict_index_get_space(index),
+				 dict_table_zip_size(index->table),
+				 node_addr.page, RW_X_LATCH, mtr);
+	new_page = buf_block_get_frame(new_block);
+	buf_block_dbg_add_level(new_block, SYNC_TREE_NODE_NEW);
+
+	flst_remove(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
+		    new_page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE,
+		    mtr);
+	ut_ad(flst_validate(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
+			    mtr));
+
+	return(new_block);
+}
+
+/******************************************************************
+Allocates a new file page to be used in an index tree. NOTE: we assume
+that the caller has made the reservation for free extents! */
+UNIV_INTERN
+buf_block_t*
+btr_page_alloc(
+/*===========*/
+					/* out: new allocated block, x-latched;
+					NULL if out of space */
+	dict_index_t*	index,		/* in: index */
+	ulint		hint_page_no,	/* in: hint of a good page */
+	byte		file_direction,	/* in: direction where a possible
+					page split is made */
+	ulint		level,		/* in: level where the page is placed
+					in the tree */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	fseg_header_t*	seg_header;
+	page_t*		root;
+	buf_block_t*	new_block;
+	ulint		new_page_no;
+
+	if (dict_index_is_ibuf(index)) {
+
+		return(btr_page_alloc_for_ibuf(index, mtr));
+	}
+
+	root = btr_root_get(index, mtr);
+
+	if (level == 0) {
+		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
+	} else {
+		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_TOP;
+	}
+
+	/* Parameter TRUE below states that the caller has made the
+	reservation for free extents, and thus we know that a page can
+	be allocated: */
+
+	new_page_no = fseg_alloc_free_page_general(seg_header, hint_page_no,
+						   file_direction, TRUE, mtr);
+	if (new_page_no == FIL_NULL) {
+
+		return(NULL);
+	}
+
+	new_block = buf_page_get(dict_index_get_space(index),
+				 dict_table_zip_size(index->table),
+				 new_page_no, RW_X_LATCH, mtr);
+	buf_block_dbg_add_level(new_block, SYNC_TREE_NODE_NEW);
+
+	return(new_block);
+}
+
+/******************************************************************
+Gets the number of pages in a B-tree. */
+UNIV_INTERN
+ulint
+btr_get_size(
+/*=========*/
+				/* out: number of pages */
+	dict_index_t*	index,	/* in: index */
+	ulint		flag)	/* in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */
+{
+	fseg_header_t*	seg_header;
+	page_t*		root;
+	ulint		n;
+	ulint		dummy;
+	mtr_t		mtr;
+
+	mtr_start(&mtr);
+
+	mtr_s_lock(dict_index_get_lock(index), &mtr);
+
+	root = btr_root_get(index, &mtr);
+
+	if (flag == BTR_N_LEAF_PAGES) {
+		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
+
+		fseg_n_reserved_pages(seg_header, &n, &mtr);
+
+	} else if (flag == BTR_TOTAL_SIZE) {
+		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_TOP;
+
+		n = fseg_n_reserved_pages(seg_header, &dummy, &mtr);
+
+		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
+
+		n += fseg_n_reserved_pages(seg_header, &dummy, &mtr);
+	} else {
+		ut_error;
+	}
+
+	mtr_commit(&mtr);
+
+	return(n);
+}
+
+/******************************************************************
+Frees a page used in an ibuf tree. Puts the page to the free list of the
+ibuf tree. */
+static
+void
+btr_page_free_for_ibuf(
+/*===================*/
+	dict_index_t*	index,	/* in: index tree */
+	buf_block_t*	block,	/* in: block to be freed, x-latched */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	page_t*		root;
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	root = btr_root_get(index, mtr);
+
+	flst_add_first(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
+		       buf_block_get_frame(block)
+		       + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, mtr);
+
+	ut_ad(flst_validate(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
+			    mtr));
+}
+
+/******************************************************************
+Frees a file page used in an index tree. Can be used also to (BLOB)
+external storage pages, because the page level 0 can be given as an
+argument. */
+UNIV_INTERN
+void
+btr_page_free_low(
+/*==============*/
+	dict_index_t*	index,	/* in: index tree */
+	buf_block_t*	block,	/* in: block to be freed, x-latched */
+	ulint		level,	/* in: page level */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	fseg_header_t*	seg_header;
+	page_t*		root;
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	/* The page gets invalid for optimistic searches: increment the frame
+	modify clock */
+
+	buf_block_modify_clock_inc(block);
+
+	if (dict_index_is_ibuf(index)) {
+
+		btr_page_free_for_ibuf(index, block, mtr);
+
+		return;
+	}
+
+	root = btr_root_get(index, mtr);
+
+	if (level == 0) {
+		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
+	} else {
+		seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_TOP;
+	}
+
+	fseg_free_page(seg_header,
+		       buf_block_get_space(block),
+		       buf_block_get_page_no(block), mtr);
+}
+
+/******************************************************************
+Frees a file page used in an index tree. NOTE: cannot free field external
+storage pages because the page must contain info on its level. */
+UNIV_INTERN
+void
+btr_page_free(
+/*==========*/
+	dict_index_t*	index,	/* in: index tree */
+	buf_block_t*	block,	/* in: block to be freed, x-latched */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ulint		level;
+
+	level = btr_page_get_level(buf_block_get_frame(block), mtr);
+
+	btr_page_free_low(index, block, level, mtr);
+}
+
+/******************************************************************
+Sets the child node file address in a node pointer. */
+UNIV_INLINE
+void
+btr_node_ptr_set_child_page_no(
+/*===========================*/
+	rec_t*		rec,	/* in: node pointer record */
+	page_zip_des_t*	page_zip,/* in/out: compressed page whose uncompressed
+				part will be updated, or NULL */
+	const ulint*	offsets,/* in: array returned by rec_get_offsets() */
+	ulint		page_no,/* in: child node address */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	byte*	field;
+	ulint	len;
+
+	ut_ad(rec_offs_validate(rec, NULL, offsets));
+	ut_ad(!page_is_leaf(page_align(rec)));
+	ut_ad(!rec_offs_comp(offsets) || rec_get_node_ptr_flag(rec));
+
+	/* The child address is in the last field */
+	field = rec_get_nth_field(rec, offsets,
+				  rec_offs_n_fields(offsets) - 1, &len);
+
+	ut_ad(len == REC_NODE_PTR_SIZE);
+
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		page_zip_write_node_ptr(page_zip, rec,
+					rec_offs_data_size(offsets),
+					page_no, mtr);
+	} else {
+		mlog_write_ulint(field, page_no, MLOG_4BYTES, mtr);
+	}
+}
+
+/****************************************************************
+Returns the child page of a node pointer and x-latches it. */
+static
+buf_block_t*
+btr_node_ptr_get_child(
+/*===================*/
+				/* out: child page, x-latched */
+	const rec_t*	node_ptr,/* in: node pointer */
+	dict_index_t*	index,	/* in: index */
+	const ulint*	offsets,/* in: array returned by rec_get_offsets() */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ulint	page_no;
+	ulint	space;
+
+	ut_ad(rec_offs_validate(node_ptr, index, offsets));
+	space = page_get_space_id(page_align(node_ptr));
+	page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets);
+
+	return(btr_block_get(space, dict_table_zip_size(index->table),
+			     page_no, RW_X_LATCH, mtr));
+}
+
+/****************************************************************
+Returns the upper level node pointer to a page. It is assumed that mtr holds
+an x-latch on the tree. */
+static
+ulint*
+btr_page_get_father_node_ptr(
+/*=========================*/
+				/* out: rec_get_offsets() of the
+				node pointer record */
+	ulint*		offsets,/* in: work area for the return value */
+	mem_heap_t*	heap,	/* in: memory heap to use */
+	btr_cur_t*	cursor,	/* in: cursor pointing to user record,
+				out: cursor on node pointer record,
+				its page x-latched */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	dtuple_t*	tuple;
+	rec_t*		user_rec;
+	rec_t*		node_ptr;
+	ulint		level;
+	ulint		page_no;
+	dict_index_t*	index;
+
+	page_no = buf_block_get_page_no(btr_cur_get_block(cursor));
+	index = btr_cur_get_index(cursor);
+
+	ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
+				MTR_MEMO_X_LOCK));
+
+	ut_ad(dict_index_get_page(index) != page_no);
+
+	level = btr_page_get_level(btr_cur_get_page(cursor), mtr);
+	user_rec = btr_cur_get_rec(cursor);
+	ut_a(page_rec_is_user_rec(user_rec));
+	tuple = dict_index_build_node_ptr(index, user_rec, 0, heap, level);
+
+	btr_cur_search_to_nth_level(index, level + 1, tuple, PAGE_CUR_LE,
+				    BTR_CONT_MODIFY_TREE, cursor, 0, mtr);
+
+	node_ptr = btr_cur_get_rec(cursor);
+	ut_ad(!page_rec_is_comp(node_ptr)
+	      || rec_get_status(node_ptr) == REC_STATUS_NODE_PTR);
+	offsets = rec_get_offsets(node_ptr, index, offsets,
+				  ULINT_UNDEFINED, &heap);
+
+	if (UNIV_UNLIKELY(btr_node_ptr_get_child_page_no(node_ptr, offsets)
+			  != page_no)) {
+		rec_t*	print_rec;
+		fputs("InnoDB: Dump of the child page:\n", stderr);
+		buf_page_print(page_align(user_rec), 0);
+		fputs("InnoDB: Dump of the parent page:\n", stderr);
+		buf_page_print(page_align(node_ptr), 0);
+
+		fputs("InnoDB: Corruption of an index tree: table ", stderr);
+		ut_print_name(stderr, NULL, TRUE, index->table_name);
+		fputs(", index ", stderr);
+		ut_print_name(stderr, NULL, FALSE, index->name);
+		fprintf(stderr, ",\n"
+			"InnoDB: father ptr page no %lu, child page no %lu\n",
+			(ulong)
+			btr_node_ptr_get_child_page_no(node_ptr, offsets),
+			(ulong) page_no);
+		print_rec = page_rec_get_next(
+			page_get_infimum_rec(page_align(user_rec)));
+		offsets = rec_get_offsets(print_rec, index,
+					  offsets, ULINT_UNDEFINED, &heap);
+		page_rec_print(print_rec, offsets);
+		offsets = rec_get_offsets(node_ptr, index, offsets,
+					  ULINT_UNDEFINED, &heap);
+		page_rec_print(node_ptr, offsets);
+
+		fputs("InnoDB: You should dump + drop + reimport the table"
+		      " to fix the\n"
+		      "InnoDB: corruption. If the crash happens at "
+		      "the database startup, see\n"
+		      "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/";
+		      "forcing-recovery.html about\n"
+		      "InnoDB: forcing recovery. "
+		      "Then dump + drop + reimport.\n", stderr);
+
+		ut_error;
+	}
+
+	return(offsets);
+}
+
+/****************************************************************
+Returns the upper level node pointer to a page. It is assumed that mtr holds
+an x-latch on the tree. */
+static
+ulint*
+btr_page_get_father_block(
+/*======================*/
+				/* out: rec_get_offsets() of the
+				node pointer record */
+	ulint*		offsets,/* in: work area for the return value */
+	mem_heap_t*	heap,	/* in: memory heap to use */
+	dict_index_t*	index,	/* in: b-tree index */
+	buf_block_t*	block,	/* in: child page in the index */
+	mtr_t*		mtr,	/* in: mtr */
+	btr_cur_t*	cursor)	/* out: cursor on node pointer record,
+				its page x-latched */
+{
+	rec_t*	rec
+		= page_rec_get_next(page_get_infimum_rec(buf_block_get_frame(
+								 block)));
+	btr_cur_position(index, rec, block, cursor);
+	return(btr_page_get_father_node_ptr(offsets, heap, cursor, mtr));
+}
+
+/****************************************************************
+Seeks to the upper level node pointer to a page.
+It is assumed that mtr holds an x-latch on the tree. */
+static
+void
+btr_page_get_father(
+/*================*/
+	dict_index_t*	index,	/* in: b-tree index */
+	buf_block_t*	block,	/* in: child page in the index */
+	mtr_t*		mtr,	/* in: mtr */
+	btr_cur_t*	cursor)	/* out: cursor on node pointer record,
+				its page x-latched */
+{
+	mem_heap_t*	heap;
+	rec_t*		rec
+		= page_rec_get_next(page_get_infimum_rec(buf_block_get_frame(
+								 block)));
+	btr_cur_position(index, rec, block, cursor);
+
+	heap = mem_heap_create(100);
+	btr_page_get_father_node_ptr(NULL, heap, cursor, mtr);
+	mem_heap_free(heap);
+}
+
+/****************************************************************
+Creates the root node for a new index tree. */
+UNIV_INTERN
+ulint
+btr_create(
+/*=======*/
+				/* out: page number of the created root,
+				FIL_NULL if did not succeed */
+	ulint		type,	/* in: type of the index */
+	ulint		space,	/* in: space where created */
+	ulint		zip_size,/* in: compressed page size in bytes
+				or 0 for uncompressed pages */
+	dulint		index_id,/* in: index id */
+	dict_index_t*	index,	/* in: index */
+	mtr_t*		mtr)	/* in: mini-transaction handle */
+{
+	ulint		page_no;
+	buf_block_t*	block;
+	buf_frame_t*	frame;
+	page_t*		page;
+	page_zip_des_t*	page_zip;
+
+	/* Create the two new segments (one, in the case of an ibuf tree) for
+	the index tree; the segment headers are put on the allocated root page
+	(for an ibuf tree, not in the root, but on a separate ibuf header
+	page) */
+
+	if (type & DICT_IBUF) {
+		/* Allocate first the ibuf header page */
+		buf_block_t*	ibuf_hdr_block = fseg_create(
+			space, 0,
+			IBUF_HEADER + IBUF_TREE_SEG_HEADER, mtr);
+
+		buf_block_dbg_add_level(ibuf_hdr_block, SYNC_TREE_NODE_NEW);
+
+		ut_ad(buf_block_get_page_no(ibuf_hdr_block)
+		      == IBUF_HEADER_PAGE_NO);
+		/* Allocate then the next page to the segment: it will be the
+		tree root page */
+
+		page_no = fseg_alloc_free_page(buf_block_get_frame(
+						       ibuf_hdr_block)
+					       + IBUF_HEADER
+					       + IBUF_TREE_SEG_HEADER,
+					       IBUF_TREE_ROOT_PAGE_NO,
+					       FSP_UP, mtr);
+		ut_ad(page_no == IBUF_TREE_ROOT_PAGE_NO);
+
+		block = buf_page_get(space, zip_size, page_no,
+				     RW_X_LATCH, mtr);
+	} else {
+		block = fseg_create(space, 0,
+				    PAGE_HEADER + PAGE_BTR_SEG_TOP, mtr);
+	}
+
+	if (block == NULL) {
+
+		return(FIL_NULL);
+	}
+
+	page_no = buf_block_get_page_no(block);
+	frame = buf_block_get_frame(block);
+
+	buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
+
+	if (type & DICT_IBUF) {
+		/* It is an insert buffer tree: initialize the free list */
+
+		ut_ad(page_no == IBUF_TREE_ROOT_PAGE_NO);
+
+		flst_init(frame + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, mtr);
+	} else {
+		/* It is a non-ibuf tree: create a file segment for leaf
+		pages */
+		fseg_create(space, page_no,
+			    PAGE_HEADER + PAGE_BTR_SEG_LEAF, mtr);
+		/* The fseg create acquires a second latch on the page,
+		therefore we must declare it: */
+		buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
+	}
+
+	/* Create a new index page on the the allocated segment page */
+	page_zip = buf_block_get_page_zip(block);
+
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		page = page_create_zip(block, index, 0, mtr);
+	} else {
+		page = page_create(block, mtr,
+				   dict_table_is_comp(index->table));
+		/* Set the level of the new index page */
+		btr_page_set_level(page, NULL, 0, mtr);
+	}
+
+	block->check_index_page_at_flush = TRUE;
+
+	/* Set the index id of the page */
+	btr_page_set_index_id(page, page_zip, index_id, mtr);
+
+	/* Set the next node and previous node fields */
+	btr_page_set_next(page, page_zip, FIL_NULL, mtr);
+	btr_page_set_prev(page, page_zip, FIL_NULL, mtr);
+
+	/* We reset the free bits for the page to allow creation of several
+	trees in the same mtr, otherwise the latch on a bitmap page would
+	prevent it because of the latching order */
+
+	if (!(type & DICT_CLUSTERED)) {
+		ibuf_reset_free_bits(block);
+	}
+
+	/* In the following assertion we test that two records of maximum
+	allowed size fit on the root page: this fact is needed to ensure
+	correctness of split algorithms */
+
+	ut_ad(page_get_max_insert_size(page, 2) > 2 * BTR_PAGE_MAX_REC_SIZE);
+
+	return(page_no);
+}
+
+/****************************************************************
+Frees a B-tree except the root page, which MUST be freed after this
+by calling btr_free_root. */
+UNIV_INTERN
+void
+btr_free_but_not_root(
+/*==================*/
+	ulint	space,		/* in: space where created */
+	ulint	zip_size,	/* in: compressed page size in bytes
+				or 0 for uncompressed pages */
+	ulint	root_page_no)	/* in: root page number */
+{
+	ibool	finished;
+	page_t*	root;
+	mtr_t	mtr;
+
+leaf_loop:
+	mtr_start(&mtr);
+
+	root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, &mtr);
+#ifdef UNIV_BTR_DEBUG
+	ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
+				    + root, space));
+	ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
+				    + root, space));
+#endif /* UNIV_BTR_DEBUG */
+
+	/* NOTE: page hash indexes are dropped when a page is freed inside
+	fsp0fsp. */
+
+	finished = fseg_free_step(root + PAGE_HEADER + PAGE_BTR_SEG_LEAF,
+				  &mtr);
+	mtr_commit(&mtr);
+
+	if (!finished) {
+
+		goto leaf_loop;
+	}
+top_loop:
+	mtr_start(&mtr);
+
+	root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, &mtr);
+#ifdef UNIV_BTR_DEBUG
+	ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
+				    + root, space));
+#endif /* UNIV_BTR_DEBUG */
+
+	finished = fseg_free_step_not_header(
+		root + PAGE_HEADER + PAGE_BTR_SEG_TOP, &mtr);
+	mtr_commit(&mtr);
+
+	if (!finished) {
+
+		goto top_loop;
+	}
+}
+
+/****************************************************************
+Frees the B-tree root page. Other tree MUST already have been freed. */
+UNIV_INTERN
+void
+btr_free_root(
+/*==========*/
+	ulint	space,		/* in: space where created */
+	ulint	zip_size,	/* in: compressed page size in bytes
+				or 0 for uncompressed pages */
+	ulint	root_page_no,	/* in: root page number */
+	mtr_t*	mtr)		/* in: a mini-transaction which has already
+				been started */
+{
+	buf_block_t*	block;
+	fseg_header_t*	header;
+
+	block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr);
+
+	btr_search_drop_page_hash_index(block);
+
+	header = buf_block_get_frame(block) + PAGE_HEADER + PAGE_BTR_SEG_TOP;
+#ifdef UNIV_BTR_DEBUG
+	ut_a(btr_root_fseg_validate(header, space));
+#endif /* UNIV_BTR_DEBUG */
+
+	while (!fseg_free_step(header, mtr));
+}
+
+/*****************************************************************
+Reorganizes an index page. */
+static
+ibool
+btr_page_reorganize_low(
+/*====================*/
+	ibool		recovery,/* in: TRUE if called in recovery:
+				locks should not be updated, i.e.,
+				there cannot exist locks on the
+				page, and a hash index should not be
+				dropped: it cannot exist */
+	buf_block_t*	block,	/* in: page to be reorganized */
+	dict_index_t*	index,	/* in: record descriptor */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	page_t*		page		= buf_block_get_frame(block);
+	page_zip_des_t*	page_zip	= buf_block_get_page_zip(block);
+	buf_block_t*	temp_block;
+	page_t*		temp_page;
+	ulint		log_mode;
+	ulint		data_size1;
+	ulint		data_size2;
+	ulint		max_ins_size1;
+	ulint		max_ins_size2;
+	ibool		success		= FALSE;
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+	data_size1 = page_get_data_size(page);
+	max_ins_size1 = page_get_max_insert_size_after_reorganize(page, 1);
+
+	/* Write the log record */
+	mlog_open_and_write_index(mtr, page, index, page_is_comp(page)
+				  ? MLOG_COMP_PAGE_REORGANIZE
+				  : MLOG_PAGE_REORGANIZE, 0);
+
+	/* Turn logging off */
+	log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
+
+	temp_block = buf_block_alloc(0);
+	temp_page = temp_block->frame;
+
+	/* Copy the old page to temporary space */
+	buf_frame_copy(temp_page, page);
+
+	if (UNIV_LIKELY(!recovery)) {
+		btr_search_drop_page_hash_index(block);
+	}
+
+	/* Recreate the page: note that global data on page (possible
+	segment headers, next page-field, etc.) is preserved intact */
+
+	page_create(block, mtr, dict_table_is_comp(index->table));
+	block->check_index_page_at_flush = TRUE;
+
+	/* Copy the records from the temporary space to the recreated page;
+	do not copy the lock bits yet */
+
+	page_copy_rec_list_end_no_locks(block, temp_block,
+					page_get_infimum_rec(temp_page),
+					index, mtr);
+	/* Copy max trx id to recreated page */
+	page_set_max_trx_id(block, NULL, page_get_max_trx_id(temp_page));
+
+	if (UNIV_LIKELY_NULL(page_zip)
+	    && UNIV_UNLIKELY
+	    (!page_zip_compress(page_zip, page, index, NULL))) {
+
+		/* Restore the old page and exit. */
+		buf_frame_copy(page, temp_page);
+
+		goto func_exit;
+	}
+
+	if (UNIV_LIKELY(!recovery)) {
+		/* Update the record lock bitmaps */
+		lock_move_reorganize_page(block, temp_block);
+	}
+
+	data_size2 = page_get_data_size(page);
+	max_ins_size2 = page_get_max_insert_size_after_reorganize(page, 1);
+
+	if (UNIV_UNLIKELY(data_size1 != data_size2)
+	    || UNIV_UNLIKELY(max_ins_size1 != max_ins_size2)) {
+		buf_page_print(page, 0);
+		buf_page_print(temp_page, 0);
+		fprintf(stderr,
+			"InnoDB: Error: page old data size %lu"
+			" new data size %lu\n"
+			"InnoDB: Error: page old max ins size %lu"
+			" new max ins size %lu\n"
+			"InnoDB: Submit a detailed bug report"
+			" to http://bugs.mysql.com\n";,
+			(unsigned long) data_size1, (unsigned long) data_size2,
+			(unsigned long) max_ins_size1,
+			(unsigned long) max_ins_size2);
+	} else {
+		success = TRUE;
+	}
+
+func_exit:
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+	buf_block_free(temp_block);
+
+	/* Restore logging mode */
+	mtr_set_log_mode(mtr, log_mode);
+
+	return(success);
+}
+
+/*****************************************************************
+Reorganizes an index page.
+IMPORTANT: if btr_page_reorganize() is invoked on a compressed leaf
+page of a non-clustered index, the caller must update the insert
+buffer free bits in the same mini-transaction in such a way that the
+modification will be redo-logged. */
+UNIV_INTERN
+ibool
+btr_page_reorganize(
+/*================*/
+				/* out: TRUE on success, FALSE on failure */
+	buf_block_t*	block,	/* in: page to be reorganized */
+	dict_index_t*	index,	/* in: record descriptor */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	return(btr_page_reorganize_low(FALSE, block, index, mtr));
+}
+
+/***************************************************************
+Parses a redo log record of reorganizing a page. */
+UNIV_INTERN
+byte*
+btr_parse_page_reorganize(
+/*======================*/
+				/* out: end of log record or NULL */
+	byte*		ptr,	/* in: buffer */
+	byte*		end_ptr __attribute__((unused)),
+				/* in: buffer end */
+	dict_index_t*	index,	/* in: record descriptor */
+	buf_block_t*	block,	/* in: page to be reorganized, or NULL */
+	mtr_t*		mtr)	/* in: mtr or NULL */
+{
+	ut_ad(ptr && end_ptr);
+
+	/* The record is empty, except for the record initial part */
+
+	if (UNIV_LIKELY(block != NULL)) {
+		btr_page_reorganize_low(TRUE, block, index, mtr);
+	}
+
+	return(ptr);
+}
+
+/*****************************************************************
+Empties an index page.  @see btr_page_create().*/
+static
+void
+btr_page_empty(
+/*===========*/
+	buf_block_t*	block,	/* in: page to be emptied */
+	page_zip_des_t*	page_zip,/* out: compressed page, or NULL */
+	dict_index_t*	index,	/* in: index of the page */
+	ulint		level,	/* in: the B-tree level of the page */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	page_t*	page = buf_block_get_frame(block);
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	ut_ad(page_zip == buf_block_get_page_zip(block));
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+
+	btr_search_drop_page_hash_index(block);
+
+	/* Recreate the page: note that global data on page (possible
+	segment headers, next page-field, etc.) is preserved intact */
+
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		page_create_zip(block, index, level, mtr);
+	} else {
+		page_create(block, mtr, dict_table_is_comp(index->table));
+		btr_page_set_level(page, NULL, level, mtr);
+	}
+
+	block->check_index_page_at_flush = TRUE;
+}
+
+/*****************************************************************
+Makes tree one level higher by splitting the root, and inserts
+the tuple. It is assumed that mtr contains an x-latch on the tree.
+NOTE that the operation of this function must always succeed,
+we cannot reverse it: therefore enough free disk space must be
+guaranteed to be available before this function is called. */
+UNIV_INTERN
+rec_t*
+btr_root_raise_and_insert(
+/*======================*/
+				/* out: inserted record */
+	btr_cur_t*	cursor,	/* in: cursor at which to insert: must be
+				on the root page; when the function returns,
+				the cursor is positioned on the predecessor
+				of the inserted record */
+	const dtuple_t*	tuple,	/* in: tuple to insert */
+	ulint		n_ext,	/* in: number of externally stored columns */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	dict_index_t*	index;
+	page_t*		root;
+	page_t*		new_page;
+	ulint		new_page_no;
+	rec_t*		rec;
+	mem_heap_t*	heap;
+	dtuple_t*	node_ptr;
+	ulint		level;
+	rec_t*		node_ptr_rec;
+	page_cur_t*	page_cursor;
+	page_zip_des_t*	root_page_zip;
+	page_zip_des_t*	new_page_zip;
+	buf_block_t*	root_block;
+	buf_block_t*	new_block;
+
+	root = btr_cur_get_page(cursor);
+	root_block = btr_cur_get_block(cursor);
+	root_page_zip = buf_block_get_page_zip(root_block);
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!root_page_zip || page_zip_validate(root_page_zip, root));
+#endif /* UNIV_ZIP_DEBUG */
+	index = btr_cur_get_index(cursor);
+#ifdef UNIV_BTR_DEBUG
+	if (!dict_index_is_ibuf(index)) {
+		ulint	space = dict_index_get_space(index);
+
+		ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
+					    + root, space));
+		ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
+					    + root, space));
+	}
+
+	ut_a(dict_index_get_page(index) == page_get_page_no(root));
+#endif /* UNIV_BTR_DEBUG */
+	ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
+				MTR_MEMO_X_LOCK));
+	ut_ad(mtr_memo_contains(mtr, root_block, MTR_MEMO_PAGE_X_FIX));
+
+	/* Allocate a new page to the tree. Root splitting is done by first
+	moving the root records to the new page, emptying the root, putting
+	a node pointer to the new page, and then splitting the new page. */
+
+	level = btr_page_get_level(root, mtr);
+
+	new_block = btr_page_alloc(index, 0, FSP_NO_DIR, level, mtr);
+	new_page = buf_block_get_frame(new_block);
+	new_page_zip = buf_block_get_page_zip(new_block);
+	ut_a(!new_page_zip == !root_page_zip);
+	ut_a(!new_page_zip
+	     || page_zip_get_size(new_page_zip)
+	     == page_zip_get_size(root_page_zip));
+
+	btr_page_create(new_block, new_page_zip, index, level, mtr);
+
+	/* Set the next node and previous node fields of new page */
+	btr_page_set_next(new_page, new_page_zip, FIL_NULL, mtr);
+	btr_page_set_prev(new_page, new_page_zip, FIL_NULL, mtr);
+
+	/* Copy the records from root to the new page one by one. */
+
+	if (0
+#ifdef UNIV_ZIP_COPY
+	    || new_page_zip
+#endif /* UNIV_ZIP_COPY */
+	    || UNIV_UNLIKELY
+	    (!page_copy_rec_list_end(new_block, root_block,
+				     page_get_infimum_rec(root),
+				     index, mtr))) {
+		ut_a(new_page_zip);
+
+		/* Copy the page byte for byte. */
+		page_zip_copy_recs(new_page_zip, new_page,
+				   root_page_zip, root, index, mtr);
+
+		/* Update the lock table and possible hash index. */
+
+		lock_move_rec_list_end(new_block, root_block,
+				       page_get_infimum_rec(root));
+
+		btr_search_move_or_delete_hash_entries(new_block, root_block,
+						       index);
+	}
+
+	/* If this is a pessimistic insert which is actually done to
+	perform a pessimistic update then we have stored the lock
+	information of the record to be inserted on the infimum of the
+	root page: we cannot discard the lock structs on the root page */
+
+	lock_update_root_raise(new_block, root_block);
+
+	/* Create a memory heap where the node pointer is stored */
+	heap = mem_heap_create(100);
+
+	rec = page_rec_get_next(page_get_infimum_rec(new_page));
+	new_page_no = buf_block_get_page_no(new_block);
+
+	/* Build the node pointer (= node key and page address) for the
+	child */
+
+	node_ptr = dict_index_build_node_ptr(index, rec, new_page_no, heap,
+					     level);
+	/* The node pointer must be marked as the predefined minimum record,
+	as there is no lower alphabetical limit to records in the leftmost
+	node of a level: */
+	dtuple_set_info_bits(node_ptr,
+			     dtuple_get_info_bits(node_ptr)
+			     | REC_INFO_MIN_REC_FLAG);
+
+	/* Rebuild the root page to get free space */
+	btr_page_empty(root_block, root_page_zip, index, level + 1, mtr);
+
+	/* Set the next node and previous node fields, although
+	they should already have been set.  The previous node field
+	must be FIL_NULL if root_page_zip != NULL, because the
+	REC_INFO_MIN_REC_FLAG (of the first user record) will be
+	set if and only if btr_page_get_prev() == FIL_NULL. */
+	btr_page_set_next(root, root_page_zip, FIL_NULL, mtr);
+	btr_page_set_prev(root, root_page_zip, FIL_NULL, mtr);
+
+	page_cursor = btr_cur_get_page_cur(cursor);
+
+	/* Insert node pointer to the root */
+
+	page_cur_set_before_first(root_block, page_cursor);
+
+	node_ptr_rec = page_cur_tuple_insert(page_cursor, node_ptr,
+					     index, 0, mtr);
+
+	/* The root page should only contain the node pointer
+	to new_page at this point.  Thus, the data should fit. */
+	ut_a(node_ptr_rec);
+
+	/* Free the memory heap */
+	mem_heap_free(heap);
+
+	/* We play safe and reset the free bits for the new page */
+
+#if 0
+	fprintf(stderr, "Root raise new page no %lu\n", new_page_no);
+#endif
+
+	if (!dict_index_is_clust(index)) {
+		ibuf_reset_free_bits(new_block);
+	}
+
+	/* Reposition the cursor to the child node */
+	page_cur_search(new_block, index, tuple,
+			PAGE_CUR_LE, page_cursor);
+
+	/* Split the child and insert tuple */
+	return(btr_page_split_and_insert(cursor, tuple, n_ext, mtr));
+}
+
+/*****************************************************************
+Decides if the page should be split at the convergence point of inserts
+converging to the left. */
+UNIV_INTERN
+ibool
+btr_page_get_split_rec_to_left(
+/*===========================*/
+				/* out: TRUE if split recommended */
+	btr_cur_t*	cursor,	/* in: cursor at which to insert */
+	rec_t**		split_rec) /* out: if split recommended,
+				the first record on upper half page,
+				or NULL if tuple to be inserted should
+				be first */
+{
+	page_t*	page;
+	rec_t*	insert_point;
+	rec_t*	infimum;
+
+	page = btr_cur_get_page(cursor);
+	insert_point = btr_cur_get_rec(cursor);
+
+	if (page_header_get_ptr(page, PAGE_LAST_INSERT)
+	    == page_rec_get_next(insert_point)) {
+
+		infimum = page_get_infimum_rec(page);
+
+		/* If the convergence is in the middle of a page, include also
+		the record immediately before the new insert to the upper
+		page. Otherwise, we could repeatedly move from page to page
+		lots of records smaller than the convergence point. */
+
+		if (infimum != insert_point
+		    && page_rec_get_next(infimum) != insert_point) {
+
+			*split_rec = insert_point;
+		} else {
+			*split_rec = page_rec_get_next(insert_point);
+		}
+
+		return(TRUE);
+	}
+
+	return(FALSE);
+}
+
+/*****************************************************************
+Decides if the page should be split at the convergence point of inserts
+converging to the right. */
+UNIV_INTERN
+ibool
+btr_page_get_split_rec_to_right(
+/*============================*/
+				/* out: TRUE if split recommended */
+	btr_cur_t*	cursor,	/* in: cursor at which to insert */
+	rec_t**		split_rec) /* out: if split recommended,
+				the first record on upper half page,
+				or NULL if tuple to be inserted should
+				be first */
+{
+	page_t*	page;
+	rec_t*	insert_point;
+
+	page = btr_cur_get_page(cursor);
+	insert_point = btr_cur_get_rec(cursor);
+
+	/* We use eager heuristics: if the new insert would be right after
+	the previous insert on the same page, we assume that there is a
+	pattern of sequential inserts here. */
+
+	if (UNIV_LIKELY(page_header_get_ptr(page, PAGE_LAST_INSERT)
+			== insert_point)) {
+
+		rec_t*	next_rec;
+
+		next_rec = page_rec_get_next(insert_point);
+
+		if (page_rec_is_supremum(next_rec)) {
+split_at_new:
+			/* Split at the new record to insert */
+			*split_rec = NULL;
+		} else {
+			rec_t*	next_next_rec = page_rec_get_next(next_rec);
+			if (page_rec_is_supremum(next_next_rec)) {
+
+				goto split_at_new;
+			}
+
+			/* If there are >= 2 user records up from the insert
+			point, split all but 1 off. We want to keep one because
+			then sequential inserts can use the adaptive hash
+			index, as they can do the necessary checks of the right
+			search position just by looking at the records on this
+			page. */
+
+			*split_rec = next_next_rec;
+		}
+
+		return(TRUE);
+	}
+
+	return(FALSE);
+}
+
+/*****************************************************************
+Calculates a split record such that the tuple will certainly fit on
+its half-page when the split is performed. We assume in this function
+only that the cursor page has at least one user record. */
+static
+rec_t*
+btr_page_get_sure_split_rec(
+/*========================*/
+				/* out: split record, or NULL if tuple
+				will be the first record on upper half-page */
+	btr_cur_t*	cursor,	/* in: cursor at which insert should be made */
+	const dtuple_t*	tuple,	/* in: tuple to insert */
+	ulint		n_ext)	/* in: number of externally stored columns */
+{
+	page_t*		page;
+	page_zip_des_t*	page_zip;
+	ulint		insert_size;
+	ulint		free_space;
+	ulint		total_data;
+	ulint		total_n_recs;
+	ulint		total_space;
+	ulint		incl_data;
+	rec_t*		ins_rec;
+	rec_t*		rec;
+	rec_t*		next_rec;
+	ulint		n;
+	mem_heap_t*	heap;
+	ulint*		offsets;
+
+	page = btr_cur_get_page(cursor);
+
+	insert_size = rec_get_converted_size(cursor->index, tuple, n_ext);
+	free_space  = page_get_free_space_of_empty(page_is_comp(page));
+
+	page_zip = btr_cur_get_page_zip(cursor);
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		/* Estimate the free space of an empty compressed page. */
+		ulint	free_space_zip = page_zip_empty_size(
+			cursor->index->n_fields,
+			page_zip_get_size(page_zip));
+
+		if (UNIV_LIKELY(free_space > (ulint) free_space_zip)) {
+			free_space = (ulint) free_space_zip;
+		}
+	}
+
+	/* free_space is now the free space of a created new page */
+
+	total_data   = page_get_data_size(page) + insert_size;
+	total_n_recs = page_get_n_recs(page) + 1;
+	ut_ad(total_n_recs >= 2);
+	total_space  = total_data + page_dir_calc_reserved_space(total_n_recs);
+
+	n = 0;
+	incl_data = 0;
+	ins_rec = btr_cur_get_rec(cursor);
+	rec = page_get_infimum_rec(page);
+
+	heap = NULL;
+	offsets = NULL;
+
+	/* We start to include records to the left half, and when the
+	space reserved by them exceeds half of total_space, then if
+	the included records fit on the left page, they will be put there
+	if something was left over also for the right page,
+	otherwise the last included record will be the first on the right
+	half page */
+
+	do {
+		/* Decide the next record to include */
+		if (rec == ins_rec) {
+			rec = NULL;	/* NULL denotes that tuple is
+					now included */
+		} else if (rec == NULL) {
+			rec = page_rec_get_next(ins_rec);
+		} else {
+			rec = page_rec_get_next(rec);
+		}
+
+		if (rec == NULL) {
+			/* Include tuple */
+			incl_data += insert_size;
+		} else {
+			offsets = rec_get_offsets(rec, cursor->index,
+						  offsets, ULINT_UNDEFINED,
+						  &heap);
+			incl_data += rec_offs_size(offsets);
+		}
+
+		n++;
+	} while (incl_data + page_dir_calc_reserved_space(n)
+		 < total_space / 2);
+
+	if (incl_data + page_dir_calc_reserved_space(n) <= free_space) {
+		/* The next record will be the first on
+		the right half page if it is not the
+		supremum record of page */
+
+		if (rec == ins_rec) {
+			rec = NULL;
+
+			goto func_exit;
+		} else if (rec == NULL) {
+			next_rec = page_rec_get_next(ins_rec);
+		} else {
+			next_rec = page_rec_get_next(rec);
+		}
+		ut_ad(next_rec);
+		if (!page_rec_is_supremum(next_rec)) {
+			rec = next_rec;
+		}
+	}
+
+func_exit:
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+	return(rec);
+}
+
+/*****************************************************************
+Returns TRUE if the insert fits on the appropriate half-page with the
+chosen split_rec. */
+static
+ibool
+btr_page_insert_fits(
+/*=================*/
+				/* out: TRUE if fits */
+	btr_cur_t*	cursor,	/* in: cursor at which insert
+				should be made */
+	const rec_t*	split_rec,/* in: suggestion for first record
+				on upper half-page, or NULL if
+				tuple to be inserted should be first */
+	const ulint*	offsets,/* in: rec_get_offsets(
+				split_rec, cursor->index) */
+	const dtuple_t*	tuple,	/* in: tuple to insert */
+	ulint		n_ext,	/* in: number of externally stored columns */
+	mem_heap_t*	heap)	/* in: temporary memory heap */
+{
+	page_t*		page;
+	ulint		insert_size;
+	ulint		free_space;
+	ulint		total_data;
+	ulint		total_n_recs;
+	const rec_t*	rec;
+	const rec_t*	end_rec;
+	ulint*		offs;
+
+	page = btr_cur_get_page(cursor);
+
+	ut_ad(!split_rec == !offsets);
+	ut_ad(!offsets
+	      || !page_is_comp(page) == !rec_offs_comp(offsets));
+	ut_ad(!offsets
+	      || rec_offs_validate(split_rec, cursor->index, offsets));
+
+	insert_size = rec_get_converted_size(cursor->index, tuple, n_ext);
+	free_space  = page_get_free_space_of_empty(page_is_comp(page));
+
+	/* free_space is now the free space of a created new page */
+
+	total_data   = page_get_data_size(page) + insert_size;
+	total_n_recs = page_get_n_recs(page) + 1;
+
+	/* We determine which records (from rec to end_rec, not including
+	end_rec) will end up on the other half page from tuple when it is
+	inserted. */
+
+	if (split_rec == NULL) {
+		rec = page_rec_get_next(page_get_infimum_rec(page));
+		end_rec = page_rec_get_next(btr_cur_get_rec(cursor));
+
+	} else if (cmp_dtuple_rec(tuple, split_rec, offsets) >= 0) {
+
+		rec = page_rec_get_next(page_get_infimum_rec(page));
+		end_rec = split_rec;
+	} else {
+		rec = split_rec;
+		end_rec = page_get_supremum_rec(page);
+	}
+
+	if (total_data + page_dir_calc_reserved_space(total_n_recs)
+	    <= free_space) {
+
+		/* Ok, there will be enough available space on the
+		half page where the tuple is inserted */
+
+		return(TRUE);
+	}
+
+	offs = NULL;
+
+	while (rec != end_rec) {
+		/* In this loop we calculate the amount of reserved
+		space after rec is removed from page. */
+
+		offs = rec_get_offsets(rec, cursor->index, offs,
+				       ULINT_UNDEFINED, &heap);
+
+		total_data -= rec_offs_size(offs);
+		total_n_recs--;
+
+		if (total_data + page_dir_calc_reserved_space(total_n_recs)
+		    <= free_space) {
+
+			/* Ok, there will be enough available space on the
+			half page where the tuple is inserted */
+
+			return(TRUE);
+		}
+
+		rec = page_rec_get_next_const(rec);
+	}
+
+	return(FALSE);
+}
+
+/***********************************************************
+Inserts a data tuple to a tree on a non-leaf level. It is assumed
+that mtr holds an x-latch on the tree. */
+UNIV_INTERN
+void
+btr_insert_on_non_leaf_level(
+/*=========================*/
+	dict_index_t*	index,	/* in: index */
+	ulint		level,	/* in: level, must be > 0 */
+	dtuple_t*	tuple,	/* in: the record to be inserted */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	big_rec_t*	dummy_big_rec;
+	btr_cur_t	cursor;
+	ulint		err;
+	rec_t*		rec;
+
+	ut_ad(level > 0);
+
+	btr_cur_search_to_nth_level(index, level, tuple, PAGE_CUR_LE,
+				    BTR_CONT_MODIFY_TREE,
+				    &cursor, 0, mtr);
+
+	err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG
+					 | BTR_KEEP_SYS_FLAG
+					 | BTR_NO_UNDO_LOG_FLAG,
+					 &cursor, tuple, &rec,
+					 &dummy_big_rec, 0, NULL, mtr);
+	ut_a(err == DB_SUCCESS);
+}
+
+/******************************************************************
+Attaches the halves of an index page on the appropriate level in an
+index tree. */
+static
+void
+btr_attach_half_pages(
+/*==================*/
+	dict_index_t*	index,		/* in: the index tree */
+	buf_block_t*	block,		/* in/out: page to be split */
+	rec_t*		split_rec,	/* in: first record on upper
+					half page */
+	buf_block_t*	new_block,	/* in/out: the new half page */
+	ulint		direction,	/* in: FSP_UP or FSP_DOWN */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	ulint		space;
+	ulint		zip_size;
+	ulint		prev_page_no;
+	ulint		next_page_no;
+	ulint		level;
+	page_t*		page		= buf_block_get_frame(block);
+	page_t*		lower_page;
+	page_t*		upper_page;
+	ulint		lower_page_no;
+	ulint		upper_page_no;
+	page_zip_des_t*	lower_page_zip;
+	page_zip_des_t*	upper_page_zip;
+	dtuple_t*	node_ptr_upper;
+	mem_heap_t*	heap;
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	ut_ad(mtr_memo_contains(mtr, new_block, MTR_MEMO_PAGE_X_FIX));
+
+	/* Create a memory heap where the data tuple is stored */
+	heap = mem_heap_create(1024);
+
+	/* Based on split direction, decide upper and lower pages */
+	if (direction == FSP_DOWN) {
+
+		btr_cur_t	cursor;
+		ulint*		offsets;
+
+		lower_page = buf_block_get_frame(new_block);
+		lower_page_no = buf_block_get_page_no(new_block);
+		lower_page_zip = buf_block_get_page_zip(new_block);
+		upper_page = buf_block_get_frame(block);
+		upper_page_no = buf_block_get_page_no(block);
+		upper_page_zip = buf_block_get_page_zip(block);
+
+		/* Look up the index for the node pointer to page */
+		offsets = btr_page_get_father_block(NULL, heap, index,
+						    block, mtr, &cursor);
+
+		/* Replace the address of the old child node (= page) with the
+		address of the new lower half */
+
+		btr_node_ptr_set_child_page_no(
+			btr_cur_get_rec(&cursor),
+			btr_cur_get_page_zip(&cursor),
+			offsets, lower_page_no, mtr);
+		mem_heap_empty(heap);
+	} else {
+		lower_page = buf_block_get_frame(block);
+		lower_page_no = buf_block_get_page_no(block);
+		lower_page_zip = buf_block_get_page_zip(block);
+		upper_page = buf_block_get_frame(new_block);
+		upper_page_no = buf_block_get_page_no(new_block);
+		upper_page_zip = buf_block_get_page_zip(new_block);
+	}
+
+	/* Get the level of the split pages */
+	level = btr_page_get_level(buf_block_get_frame(block), mtr);
+	ut_ad(level
+	      == btr_page_get_level(buf_block_get_frame(new_block), mtr));
+
+	/* Build the node pointer (= node key and page address) for the upper
+	half */
+
+	node_ptr_upper = dict_index_build_node_ptr(index, split_rec,
+						   upper_page_no, heap, level);
+
+	/* Insert it next to the pointer to the lower half. Note that this
+	may generate recursion leading to a split on the higher level. */
+
+	btr_insert_on_non_leaf_level(index, level + 1, node_ptr_upper, mtr);
+
+	/* Free the memory heap */
+	mem_heap_free(heap);
+
+	/* Get the previous and next pages of page */
+
+	prev_page_no = btr_page_get_prev(page, mtr);
+	next_page_no = btr_page_get_next(page, mtr);
+	space = buf_block_get_space(block);
+	zip_size = buf_block_get_zip_size(block);
+
+	/* Update page links of the level */
+
+	if (prev_page_no != FIL_NULL) {
+		buf_block_t*	prev_block = btr_block_get(space, zip_size,
+							   prev_page_no,
+							   RW_X_LATCH, mtr);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(prev_block->frame) == page_is_comp(page));
+		ut_a(btr_page_get_next(prev_block->frame, mtr)
+		     == buf_block_get_page_no(block));
+#endif /* UNIV_BTR_DEBUG */
+
+		btr_page_set_next(buf_block_get_frame(prev_block),
+				  buf_block_get_page_zip(prev_block),
+				  lower_page_no, mtr);
+	}
+
+	if (next_page_no != FIL_NULL) {
+		buf_block_t*	next_block = btr_block_get(space, zip_size,
+							   next_page_no,
+							   RW_X_LATCH, mtr);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(next_block->frame) == page_is_comp(page));
+		ut_a(btr_page_get_prev(next_block->frame, mtr)
+		     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+
+		btr_page_set_prev(buf_block_get_frame(next_block),
+				  buf_block_get_page_zip(next_block),
+				  upper_page_no, mtr);
+	}
+
+	btr_page_set_prev(lower_page, lower_page_zip, prev_page_no, mtr);
+	btr_page_set_next(lower_page, lower_page_zip, upper_page_no, mtr);
+
+	btr_page_set_prev(upper_page, upper_page_zip, lower_page_no, mtr);
+	btr_page_set_next(upper_page, upper_page_zip, next_page_no, mtr);
+}
+
+/*****************************************************************
+Splits an index page to halves and inserts the tuple. It is assumed
+that mtr holds an x-latch to the index tree. NOTE: the tree x-latch
+is released within this function! NOTE that the operation of this
+function must always succeed, we cannot reverse it: therefore
+enough free disk space must be guaranteed to be available before
+this function is called. */
+UNIV_INTERN
+rec_t*
+btr_page_split_and_insert(
+/*======================*/
+				/* out: inserted record; NOTE: the tree
+				x-latch is released! NOTE: 2 free disk
+				pages must be available! */
+	btr_cur_t*	cursor,	/* in: cursor at which to insert; when the
+				function returns, the cursor is positioned
+				on the predecessor of the inserted record */
+	const dtuple_t*	tuple,	/* in: tuple to insert */
+	ulint		n_ext,	/* in: number of externally stored columns */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	buf_block_t*	block;
+	page_t*		page;
+	page_zip_des_t*	page_zip;
+	ulint		page_no;
+	byte		direction;
+	ulint		hint_page_no;
+	buf_block_t*	new_block;
+	page_t*		new_page;
+	page_zip_des_t*	new_page_zip;
+	rec_t*		split_rec;
+	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 */
+	rec_t*		move_limit;
+	ibool		insert_will_fit;
+	ibool		insert_left;
+	ulint		n_iterations = 0;
+	rec_t*		rec;
+	mem_heap_t*	heap;
+	ulint		n_uniq;
+	ulint*		offsets;
+
+	heap = mem_heap_create(1024);
+	n_uniq = dict_index_get_n_unique_in_tree(cursor->index);
+func_start:
+	mem_heap_empty(heap);
+	offsets = NULL;
+
+	ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(cursor->index),
+				MTR_MEMO_X_LOCK));
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(rw_lock_own(dict_index_get_lock(cursor->index), RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	block = btr_cur_get_block(cursor);
+	page = buf_block_get_frame(block);
+	page_zip = buf_block_get_page_zip(block);
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	ut_ad(page_get_n_recs(page) >= 1);
+
+	page_no = buf_block_get_page_no(block);
+
+	/* 1. Decide the split record; split_rec == NULL means that the
+	tuple to be inserted should be the first record on the upper
+	half-page */
+
+	if (n_iterations > 0) {
+		direction = FSP_UP;
+		hint_page_no = page_no + 1;
+		split_rec = btr_page_get_sure_split_rec(cursor, tuple, n_ext);
+
+	} else if (btr_page_get_split_rec_to_right(cursor, &split_rec)) {
+		direction = FSP_UP;
+		hint_page_no = page_no + 1;
+
+	} else if (btr_page_get_split_rec_to_left(cursor, &split_rec)) {
+		direction = FSP_DOWN;
+		hint_page_no = page_no - 1;
+	} else {
+		direction = FSP_UP;
+		hint_page_no = page_no + 1;
+
+		if (page_get_n_recs(page) == 1) {
+			page_cur_t	pcur;
+
+			/* There is only one record in the index page
+			therefore we can't split the node in the middle
+			by default. We need to determine whether the
+			new record will be inserted to the left or right. */
+
+			/* Read the first (and only) record in the page. */
+			page_cur_set_before_first(block, &pcur);
+			page_cur_move_to_next(&pcur);
+			first_rec = page_cur_get_rec(&pcur);
+
+			offsets = rec_get_offsets(
+				first_rec, cursor->index, offsets,
+				n_uniq, &heap);
+
+			/* If the new record is less than the existing record
+			the the split in the middle will copy the existing
+			record to the new node. */
+			if (cmp_dtuple_rec(tuple, first_rec, offsets) < 0) {
+				split_rec = page_get_middle_rec(page);
+			} else {
+				split_rec = NULL;
+			}
+		} else {
+			split_rec = page_get_middle_rec(page);
+		}
+	}
+
+	/* 2. Allocate a new page to the index */
+	new_block = btr_page_alloc(cursor->index, hint_page_no, direction,
+				   btr_page_get_level(page, mtr), mtr);
+	new_page = buf_block_get_frame(new_block);
+	new_page_zip = buf_block_get_page_zip(new_block);
+	btr_page_create(new_block, new_page_zip, cursor->index,
+			btr_page_get_level(page, mtr), mtr);
+
+	/* 3. Calculate the first record on the upper half-page, and the
+	first record (move_limit) on original page which ends up on the
+	upper half */
+
+	if (split_rec) {
+		first_rec = move_limit = split_rec;
+
+		offsets = rec_get_offsets(split_rec, cursor->index, offsets,
+					  n_uniq, &heap);
+
+		insert_left = cmp_dtuple_rec(tuple, split_rec, offsets) < 0;
+
+		if (UNIV_UNLIKELY(!insert_left && new_page_zip
+				  && n_iterations > 0)) {
+			/* If a compressed page has already been split,
+			avoid further splits by inserting the record
+			to an empty page. */
+			split_rec = NULL;
+			goto insert_right;
+		}
+	} else {
+insert_right:
+		insert_left = FALSE;
+		buf = mem_alloc(rec_get_converted_size(cursor->index,
+						       tuple, n_ext));
+
+		first_rec = rec_convert_dtuple_to_rec(buf, cursor->index,
+						      tuple, n_ext);
+		move_limit = page_rec_get_next(btr_cur_get_rec(cursor));
+	}
+
+	/* 4. Do first the modifications in the tree structure */
+
+	btr_attach_half_pages(cursor->index, block,
+			      first_rec, new_block, direction, mtr);
+
+	/* If the split is made on the leaf level and the insert will fit
+	on the appropriate half-page, we may release the tree x-latch.
+	We can then move the records after releasing the tree latch,
+	thus reducing the tree latch contention. */
+
+	if (split_rec) {
+		insert_will_fit = !new_page_zip
+			&& btr_page_insert_fits(cursor, split_rec,
+						offsets, tuple, n_ext, heap);
+	} else {
+		mem_free(buf);
+		insert_will_fit = !new_page_zip
+			&& btr_page_insert_fits(cursor, NULL,
+						NULL, tuple, n_ext, heap);
+	}
+
+	if (insert_will_fit && page_is_leaf(page)) {
+
+		mtr_memo_release(mtr, dict_index_get_lock(cursor->index),
+				 MTR_MEMO_X_LOCK);
+	}
+
+	/* 5. Move then the records to the new page */
+	if (direction == FSP_DOWN) {
+		/*		fputs("Split left\n", stderr); */
+
+		if (0
+#ifdef UNIV_ZIP_COPY
+		    || page_zip
+#endif /* UNIV_ZIP_COPY */
+		    || UNIV_UNLIKELY
+		    (!page_move_rec_list_start(new_block, block, move_limit,
+					       cursor->index, mtr))) {
+			/* For some reason, compressing new_page failed,
+			even though it should contain fewer records than
+			the original page.  Copy the page byte for byte
+			and then delete the records from both pages
+			as appropriate.  Deleting will always succeed. */
+			ut_a(new_page_zip);
+
+			page_zip_copy_recs(new_page_zip, new_page,
+					   page_zip, page, cursor->index, mtr);
+			page_delete_rec_list_end(move_limit - page + new_page,
+						 new_block, cursor->index,
+						 ULINT_UNDEFINED,
+						 ULINT_UNDEFINED, mtr);
+
+			/* Update the lock table and possible hash index. */
+
+			lock_move_rec_list_start(
+				new_block, block, move_limit,
+				new_page + PAGE_NEW_INFIMUM);
+
+			btr_search_move_or_delete_hash_entries(
+				new_block, block, cursor->index);
+
+			/* Delete the records from the source page. */
+
+			page_delete_rec_list_start(move_limit, block,
+						   cursor->index, mtr);
+		}
+
+		left_block = new_block;
+		right_block = block;
+
+		lock_update_split_left(right_block, left_block);
+	} else {
+		/*		fputs("Split right\n", stderr); */
+
+		if (0
+#ifdef UNIV_ZIP_COPY
+		    || page_zip
+#endif /* UNIV_ZIP_COPY */
+		    || UNIV_UNLIKELY
+		    (!page_move_rec_list_end(new_block, block, move_limit,
+					     cursor->index, mtr))) {
+			/* For some reason, compressing new_page failed,
+			even though it should contain fewer records than
+			the original page.  Copy the page byte for byte
+			and then delete the records from both pages
+			as appropriate.  Deleting will always succeed. */
+			ut_a(new_page_zip);
+
+			page_zip_copy_recs(new_page_zip, new_page,
+					   page_zip, page, cursor->index, mtr);
+			page_delete_rec_list_start(move_limit - page
+						   + new_page, new_block,
+						   cursor->index, mtr);
+
+			/* Update the lock table and possible hash index. */
+
+			lock_move_rec_list_end(new_block, block, move_limit);
+
+			btr_search_move_or_delete_hash_entries(
+				new_block, block, cursor->index);
+
+			/* Delete the records from the source page. */
+
+			page_delete_rec_list_end(move_limit, block,
+						 cursor->index,
+						 ULINT_UNDEFINED,
+						 ULINT_UNDEFINED, mtr);
+		}
+
+		left_block = block;
+		right_block = new_block;
+
+		lock_update_split_right(right_block, left_block);
+	}
+
+#ifdef UNIV_ZIP_DEBUG
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		ut_a(page_zip_validate(page_zip, page));
+		ut_a(page_zip_validate(new_page_zip, new_page));
+	}
+#endif /* UNIV_ZIP_DEBUG */
+
+	/* At this point, split_rec, move_limit and first_rec may point
+	to garbage on the old page. */
+
+	/* 6. The split and the tree modification is now completed. Decide the
+	page where the tuple should be inserted */
+
+	if (insert_left) {
+		insert_block = left_block;
+	} else {
+		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);
+
+	page_cur_search(insert_block, cursor->index, tuple,
+			PAGE_CUR_LE, page_cursor);
+
+	rec = page_cur_tuple_insert(page_cursor, tuple,
+				    cursor->index, n_ext, mtr);
+
+#ifdef UNIV_ZIP_DEBUG
+	{
+		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));
+	}
+#endif /* UNIV_ZIP_DEBUG */
+
+	if (UNIV_LIKELY(rec != NULL)) {
+
+		goto func_exit;
+	}
+
+	/* 8. If insert did not fit, try page reorganization */
+
+	if (UNIV_UNLIKELY
+	    (!btr_page_reorganize(insert_block, cursor->index, mtr))) {
+
+		goto insert_failed;
+	}
+
+	page_cur_search(insert_block, cursor->index, tuple,
+			PAGE_CUR_LE, page_cursor);
+	rec = page_cur_tuple_insert(page_cursor, tuple, cursor->index,
+				    n_ext, mtr);
+
+	if (UNIV_UNLIKELY(rec == NULL)) {
+		/* The insert did not fit on the page: loop back to the
+		start of the function for a new split */
+insert_failed:
+		/* We play safe and reset the free bits for new_page */
+		if (!dict_index_is_clust(cursor->index)) {
+			ibuf_reset_free_bits(new_block);
+		}
+
+		/* fprintf(stderr, "Split second round %lu\n",
+		page_get_page_no(page)); */
+		n_iterations++;
+		ut_ad(n_iterations < 2
+		      || buf_block_get_page_zip(insert_block));
+		ut_ad(!insert_will_fit);
+
+		goto func_start;
+	}
+
+func_exit:
+	/* Insert fit on the page: update the free bits for the
+	left and right pages in the same mtr */
+
+	if (!dict_index_is_clust(cursor->index) && page_is_leaf(page)) {
+		ibuf_update_free_bits_for_two_pages_low(
+			buf_block_get_zip_size(left_block),
+			left_block, right_block, mtr);
+	}
+
+#if 0
+	fprintf(stderr, "Split and insert done %lu %lu\n",
+		buf_block_get_page_no(left_block),
+		buf_block_get_page_no(right_block));
+#endif
+
+	ut_ad(page_validate(buf_block_get_frame(left_block), cursor->index));
+	ut_ad(page_validate(buf_block_get_frame(right_block), cursor->index));
+
+	mem_heap_free(heap);
+	return(rec);
+}
+
+/*****************************************************************
+Removes a page from the level list of pages. */
+static
+void
+btr_level_list_remove(
+/*==================*/
+	ulint		space,	/* in: space where removed */
+	ulint		zip_size,/* in: compressed page size in bytes
+				or 0 for uncompressed pages */
+	page_t*		page,	/* in: page to remove */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ulint	prev_page_no;
+	ulint	next_page_no;
+
+	ut_ad(page && mtr);
+	ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
+	ut_ad(space == page_get_space_id(page));
+	/* Get the previous and next page numbers of page */
+
+	prev_page_no = btr_page_get_prev(page, mtr);
+	next_page_no = btr_page_get_next(page, mtr);
+
+	/* Update page links of the level */
+
+	if (prev_page_no != FIL_NULL) {
+		buf_block_t*	prev_block
+			= btr_block_get(space, zip_size, prev_page_no,
+					RW_X_LATCH, mtr);
+		page_t*		prev_page
+			= buf_block_get_frame(prev_block);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(prev_page) == page_is_comp(page));
+		ut_a(btr_page_get_next(prev_page, mtr)
+		     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+
+		btr_page_set_next(prev_page,
+				  buf_block_get_page_zip(prev_block),
+				  next_page_no, mtr);
+	}
+
+	if (next_page_no != FIL_NULL) {
+		buf_block_t*	next_block
+			= btr_block_get(space, zip_size, next_page_no,
+					RW_X_LATCH, mtr);
+		page_t*		next_page
+			= buf_block_get_frame(next_block);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(next_page) == page_is_comp(page));
+		ut_a(btr_page_get_prev(next_page, mtr)
+		     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+
+		btr_page_set_prev(next_page,
+				  buf_block_get_page_zip(next_block),
+				  prev_page_no, mtr);
+	}
+}
+
+/********************************************************************
+Writes the redo log record for setting an index record as the predefined
+minimum record. */
+UNIV_INLINE
+void
+btr_set_min_rec_mark_log(
+/*=====================*/
+	rec_t*	rec,	/* in: record */
+	byte	type,	/* in: MLOG_COMP_REC_MIN_MARK or MLOG_REC_MIN_MARK */
+	mtr_t*	mtr)	/* in: mtr */
+{
+	mlog_write_initial_log_record(rec, type, mtr);
+
+	/* Write rec offset as a 2-byte ulint */
+	mlog_catenate_ulint(mtr, page_offset(rec), MLOG_2BYTES);
+}
+
+/********************************************************************
+Parses the redo log record for setting an index record as the predefined
+minimum record. */
+UNIV_INTERN
+byte*
+btr_parse_set_min_rec_mark(
+/*=======================*/
+			/* out: end of log record or NULL */
+	byte*	ptr,	/* in: buffer */
+	byte*	end_ptr,/* in: buffer end */
+	ulint	comp,	/* in: nonzero=compact page format */
+	page_t*	page,	/* in: page or NULL */
+	mtr_t*	mtr)	/* in: mtr or NULL */
+{
+	rec_t*	rec;
+
+	if (end_ptr < ptr + 2) {
+
+		return(NULL);
+	}
+
+	if (page) {
+		ut_a(!page_is_comp(page) == !comp);
+
+		rec = page + mach_read_from_2(ptr);
+
+		btr_set_min_rec_mark(rec, mtr);
+	}
+
+	return(ptr + 2);
+}
+
+/********************************************************************
+Sets a record as the predefined minimum record. */
+UNIV_INTERN
+void
+btr_set_min_rec_mark(
+/*=================*/
+	rec_t*	rec,	/* in: record */
+	mtr_t*	mtr)	/* in: mtr */
+{
+	ulint	info_bits;
+
+	if (UNIV_LIKELY(page_rec_is_comp(rec))) {
+		info_bits = rec_get_info_bits(rec, TRUE);
+
+		rec_set_info_bits_new(rec, info_bits | REC_INFO_MIN_REC_FLAG);
+
+		btr_set_min_rec_mark_log(rec, MLOG_COMP_REC_MIN_MARK, mtr);
+	} else {
+		info_bits = rec_get_info_bits(rec, FALSE);
+
+		rec_set_info_bits_old(rec, info_bits | REC_INFO_MIN_REC_FLAG);
+
+		btr_set_min_rec_mark_log(rec, MLOG_REC_MIN_MARK, mtr);
+	}
+}
+
+/*****************************************************************
+Deletes on the upper level the node pointer to a page. */
+UNIV_INTERN
+void
+btr_node_ptr_delete(
+/*================*/
+	dict_index_t*	index,	/* in: index tree */
+	buf_block_t*	block,	/* in: page whose node pointer is deleted */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	btr_cur_t	cursor;
+	ibool		compressed;
+	ulint		err;
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+
+	/* Delete node pointer on father page */
+	btr_page_get_father(index, block, mtr, &cursor);
+
+	compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, RB_NONE,
+						mtr);
+	ut_a(err == DB_SUCCESS);
+
+	if (!compressed) {
+		btr_cur_compress_if_useful(&cursor, mtr);
+	}
+}
+
+/*****************************************************************
+If page is the only on its level, this function moves its records to the
+father page, thus reducing the tree height. */
+static
+void
+btr_lift_page_up(
+/*=============*/
+	dict_index_t*	index,	/* in: index tree */
+	buf_block_t*	block,	/* in: page which is the only on its level;
+				must not be empty: use
+				btr_discard_only_page_on_level if the last
+				record from the page should be removed */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	buf_block_t*	father_block;
+	page_t*		father_page;
+	ulint		page_level;
+	page_zip_des_t*	father_page_zip;
+	page_t*		page		= buf_block_get_frame(block);
+	ulint		root_page_no;
+	buf_block_t*	blocks[BTR_MAX_LEVELS];
+	ulint		n_blocks;	/* last used index in blocks[] */
+	ulint		i;
+
+	ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL);
+	ut_ad(btr_page_get_next(page, mtr) == FIL_NULL);
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+
+	page_level = btr_page_get_level(page, mtr);
+	root_page_no = dict_index_get_page(index);
+
+	{
+		btr_cur_t	cursor;
+		mem_heap_t*	heap	= mem_heap_create(100);
+		ulint*		offsets;
+		buf_block_t*	b;
+
+		offsets = btr_page_get_father_block(NULL, heap, index,
+						    block, mtr, &cursor);
+		father_block = btr_cur_get_block(&cursor);
+		father_page_zip = buf_block_get_page_zip(father_block);
+		father_page = buf_block_get_frame(father_block);
+
+		n_blocks = 0;
+
+		/* Store all ancestor pages so we can reset their
+		levels later on.  We have to do all the searches on
+		the tree now because later on, after we've replaced
+		the first level, the tree is in an inconsistent state
+		and can not be searched. */
+		for (b = father_block;
+		     buf_block_get_page_no(b) != root_page_no; ) {
+			ut_a(n_blocks < BTR_MAX_LEVELS);
+
+			offsets = btr_page_get_father_block(offsets, heap,
+							    index, b,
+							    mtr, &cursor);
+
+			blocks[n_blocks++] = b = btr_cur_get_block(&cursor);
+		}
+
+		mem_heap_free(heap);
+	}
+
+	btr_search_drop_page_hash_index(block);
+
+	/* Make the father empty */
+	btr_page_empty(father_block, father_page_zip, index, page_level, mtr);
+
+	/* Copy the records to the father page one by one. */
+	if (0
+#ifdef UNIV_ZIP_COPY
+	    || father_page_zip
+#endif /* UNIV_ZIP_COPY */
+	    || UNIV_UNLIKELY
+	    (!page_copy_rec_list_end(father_block, block,
+				     page_get_infimum_rec(page),
+				     index, mtr))) {
+		const page_zip_des_t*	page_zip
+			= buf_block_get_page_zip(block);
+		ut_a(father_page_zip);
+		ut_a(page_zip);
+
+		/* Copy the page byte for byte. */
+		page_zip_copy_recs(father_page_zip, father_page,
+				   page_zip, page, index, mtr);
+
+		/* Update the lock table and possible hash index. */
+
+		lock_move_rec_list_end(father_block, block,
+				       page_get_infimum_rec(page));
+
+		btr_search_move_or_delete_hash_entries(father_block, block,
+						       index);
+	}
+
+	lock_update_copy_and_discard(father_block, block);
+
+	/* Go upward to root page, decrementing levels by one. */
+	for (i = 0; i < n_blocks; i++, page_level++) {
+		page_t*		page	= buf_block_get_frame(blocks[i]);
+		page_zip_des_t*	page_zip= buf_block_get_page_zip(blocks[i]);
+
+		ut_ad(btr_page_get_level(page, mtr) == page_level + 1);
+
+		btr_page_set_level(page, page_zip, page_level, mtr);
+#ifdef UNIV_ZIP_DEBUG
+		ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+	}
+
+	/* Free the file page */
+	btr_page_free(index, block, mtr);
+
+	/* We play it safe and reset the free bits for the father */
+	if (!dict_index_is_clust(index)) {
+		ibuf_reset_free_bits(father_block);
+	}
+	ut_ad(page_validate(father_page, index));
+	ut_ad(btr_check_node_ptr(index, father_block, mtr));
+}
+
+/*****************************************************************
+Tries to merge the page first to the left immediate brother if such a
+brother exists, and the node pointers to the current page and to the brother
+reside on the same page. If the left brother does not satisfy these
+conditions, looks at the right brother. If the page is the only one on that
+level lifts the records of the page to the father page, thus reducing the
+tree height. It is assumed that mtr holds an x-latch on the tree and on the
+page. If cursor is on the leaf level, mtr must also hold x-latches to the
+brothers, if they exist. */
+UNIV_INTERN
+ibool
+btr_compress(
+/*=========*/
+				/* out: TRUE on success */
+	btr_cur_t*	cursor,	/* in: cursor on the page to merge or lift;
+				the page must not be empty: in record delete
+				use btr_discard_page if the page would become
+				empty */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	dict_index_t*	index;
+	ulint		space;
+	ulint		zip_size;
+	ulint		left_page_no;
+	ulint		right_page_no;
+	buf_block_t*	merge_block;
+	page_t*		merge_page;
+	page_zip_des_t*	merge_page_zip;
+	ibool		is_left;
+	buf_block_t*	block;
+	page_t*		page;
+	btr_cur_t	father_cursor;
+	mem_heap_t*	heap;
+	ulint*		offsets;
+	ulint		data_size;
+	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);
+	index = btr_cur_get_index(cursor);
+	ut_a((ibool) !!page_is_comp(page) == dict_table_is_comp(index->table));
+
+	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);
+
+	left_page_no = btr_page_get_prev(page, mtr);
+	right_page_no = btr_page_get_next(page, mtr);
+
+#if 0
+	fprintf(stderr, "Merge left page %lu right %lu \n",
+		left_page_no, right_page_no);
+#endif
+
+	heap = mem_heap_create(100);
+	offsets = btr_page_get_father_block(NULL, heap, index, block, mtr,
+					    &father_cursor);
+
+	/* Decide the page to which we try to merge and which will inherit
+	the locks */
+
+	is_left = left_page_no != FIL_NULL;
+
+	if (is_left) {
+
+		merge_block = btr_block_get(space, zip_size, left_page_no,
+					    RW_X_LATCH, mtr);
+		merge_page = buf_block_get_frame(merge_block);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(btr_page_get_next(merge_page, mtr)
+		     == buf_block_get_page_no(block));
+#endif /* UNIV_BTR_DEBUG */
+	} else if (right_page_no != FIL_NULL) {
+
+		merge_block = btr_block_get(space, zip_size, right_page_no,
+					    RW_X_LATCH, mtr);
+		merge_page = buf_block_get_frame(merge_block);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(btr_page_get_prev(merge_page, mtr)
+		     == buf_block_get_page_no(block));
+#endif /* UNIV_BTR_DEBUG */
+	} else {
+		/* The page is the only one on the level, lift the records
+		to the father */
+		btr_lift_page_up(index, block, mtr);
+		mem_heap_free(heap);
+		return(TRUE);
+	}
+
+	n_recs = page_get_n_recs(page);
+	data_size = page_get_data_size(page);
+#ifdef UNIV_BTR_DEBUG
+	ut_a(page_is_comp(merge_page) == page_is_comp(page));
+#endif /* UNIV_BTR_DEBUG */
+
+	max_ins_size_reorg = page_get_max_insert_size_after_reorganize(
+		merge_page, n_recs);
+	if (data_size > max_ins_size_reorg) {
+
+		/* No space for merge */
+err_exit:
+		/* We play it safe and reset the free bits. */
+		if (zip_size
+		    && page_is_leaf(merge_page)
+		    && !dict_index_is_clust(index)) {
+			ibuf_reset_free_bits(merge_block);
+		}
+
+		mem_heap_free(heap);
+		return(FALSE);
+	}
+
+	ut_ad(page_validate(merge_page, index));
+
+	max_ins_size = page_get_max_insert_size(merge_page, n_recs);
+
+	if (UNIV_UNLIKELY(data_size > max_ins_size)) {
+
+		/* We have to reorganize merge_page */
+
+		if (UNIV_UNLIKELY(!btr_page_reorganize(merge_block,
+						       index, mtr))) {
+
+			goto err_exit;
+		}
+
+		max_ins_size = page_get_max_insert_size(merge_page, n_recs);
+
+		ut_ad(page_validate(merge_page, index));
+		ut_ad(max_ins_size == max_ins_size_reorg);
+
+		if (UNIV_UNLIKELY(data_size > max_ins_size)) {
+
+			/* Add fault tolerance, though this should
+			never happen */
+
+			goto err_exit;
+		}
+	}
+
+	merge_page_zip = buf_block_get_page_zip(merge_block);
+#ifdef UNIV_ZIP_DEBUG
+	if (UNIV_LIKELY_NULL(merge_page_zip)) {
+		const page_zip_des_t*	page_zip
+			= buf_block_get_page_zip(block);
+		ut_a(page_zip);
+		ut_a(page_zip_validate(merge_page_zip, merge_page));
+		ut_a(page_zip_validate(page_zip, page));
+	}
+#endif /* UNIV_ZIP_DEBUG */
+
+	/* Move records to the merge page */
+	if (is_left) {
+		rec_t*	orig_pred = page_copy_rec_list_start(
+			merge_block, block, page_get_supremum_rec(page),
+			index, mtr);
+
+		if (UNIV_UNLIKELY(!orig_pred)) {
+			goto err_exit;
+		}
+
+		btr_search_drop_page_hash_index(block);
+
+		/* Remove the page from the level list */
+		btr_level_list_remove(space, zip_size, page, mtr);
+
+		btr_node_ptr_delete(index, block, mtr);
+		lock_update_merge_left(merge_block, orig_pred, block);
+	} else {
+		rec_t*		orig_succ;
+#ifdef UNIV_BTR_DEBUG
+		byte		fil_page_prev[4];
+#endif /* UNIV_BTR_DEBUG */
+
+		if (UNIV_LIKELY_NULL(merge_page_zip)) {
+			/* The function page_zip_compress(), which will be
+			invoked by page_copy_rec_list_end() below,
+			requires that FIL_PAGE_PREV be FIL_NULL.
+			Clear the field, but prepare to restore it. */
+#ifdef UNIV_BTR_DEBUG
+			memcpy(fil_page_prev, merge_page + FIL_PAGE_PREV, 4);
+#endif /* UNIV_BTR_DEBUG */
+#if FIL_NULL != 0xffffffff
+# error "FIL_NULL != 0xffffffff"
+#endif
+			memset(merge_page + FIL_PAGE_PREV, 0xff, 4);
+		}
+
+		orig_succ = page_copy_rec_list_end(merge_block, block,
+						   page_get_infimum_rec(page),
+						   cursor->index, mtr);
+
+		if (UNIV_UNLIKELY(!orig_succ)) {
+			ut_a(merge_page_zip);
+#ifdef UNIV_BTR_DEBUG
+			/* FIL_PAGE_PREV was restored from merge_page_zip. */
+			ut_a(!memcmp(fil_page_prev,
+				     merge_page + FIL_PAGE_PREV, 4));
+#endif /* UNIV_BTR_DEBUG */
+			goto err_exit;
+		}
+
+		btr_search_drop_page_hash_index(block);
+
+#ifdef UNIV_BTR_DEBUG
+		if (UNIV_LIKELY_NULL(merge_page_zip)) {
+			/* Restore FIL_PAGE_PREV in order to avoid an assertion
+			failure in btr_level_list_remove(), which will set
+			the field again to FIL_NULL.  Even though this makes
+			merge_page and merge_page_zip inconsistent for a
+			split second, it is harmless, because the pages
+			are X-latched. */
+			memcpy(merge_page + FIL_PAGE_PREV, fil_page_prev, 4);
+		}
+#endif /* UNIV_BTR_DEBUG */
+
+		/* Remove the page from the level list */
+		btr_level_list_remove(space, zip_size, page, mtr);
+
+		/* Replace the address of the old child node (= page) with the
+		address of the merge page to the right */
+
+		btr_node_ptr_set_child_page_no(
+			btr_cur_get_rec(&father_cursor),
+			btr_cur_get_page_zip(&father_cursor),
+			offsets, right_page_no, mtr);
+		btr_node_ptr_delete(index, merge_block, mtr);
+
+		lock_update_merge_right(merge_block, orig_succ, block);
+	}
+
+	mem_heap_free(heap);
+
+	if (!dict_index_is_clust(index) && page_is_leaf(merge_page)) {
+		/* Update the free bits of the B-tree page in the
+		insert buffer bitmap.  This has to be done in a
+		separate mini-transaction that is committed before the
+		main mini-transaction.  We cannot update the insert
+		buffer bitmap in this mini-transaction, because
+		btr_compress() can be invoked recursively without
+		committing the mini-transaction in between.  Since
+		insert buffer bitmap pages have a lower rank than
+		B-tree pages, we must not access other pages in the
+		same mini-transaction after accessing an insert buffer
+		bitmap page. */
+
+		/* The free bits in the insert buffer bitmap must
+		never exceed the free space on a page.  It is safe to
+		decrement or reset the bits in the bitmap in a
+		mini-transaction that is committed before the
+		mini-transaction that affects the free space. */
+
+		/* It is unsafe to increment the bits in a separately
+		committed mini-transaction, because in crash recovery,
+		the free bits could momentarily be set too high. */
+
+		if (zip_size) {
+			/* Because the free bits may be incremented
+			and we cannot update the insert buffer bitmap
+			in the same mini-transaction, the only safe
+			thing we can do here is the pessimistic
+			approach: reset the free bits. */
+			ibuf_reset_free_bits(merge_block);
+		} else {
+			/* On uncompressed pages, the free bits will
+			never increase here.  Thus, it is safe to
+			write the bits accurately in a separate
+			mini-transaction. */
+			ibuf_update_free_bits_if_full(merge_block,
+						      UNIV_PAGE_SIZE,
+						      ULINT_UNDEFINED);
+		}
+	}
+
+	ut_ad(page_validate(merge_page, index));
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!merge_page_zip || page_zip_validate(merge_page_zip, merge_page));
+#endif /* UNIV_ZIP_DEBUG */
+
+	/* Free the file page */
+	btr_page_free(index, block, mtr);
+
+	ut_ad(btr_check_node_ptr(index, merge_block, mtr));
+	return(TRUE);
+}
+
+/*****************************************************************
+Discards a page that is the only page on its level.  This will empty
+the whole B-tree, leaving just an empty root page.  This function
+should never be reached, because btr_compress(), which is invoked in
+delete operations, calls btr_lift_page_up() to flatten the B-tree. */
+static
+void
+btr_discard_only_page_on_level(
+/*===========================*/
+	dict_index_t*	index,	/* in: index tree */
+	buf_block_t*	block,	/* in: page which is the only on its level */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ulint	page_level = 0;
+
+	while (buf_block_get_page_no(block) != dict_index_get_page(index)) {
+		btr_cur_t	cursor;
+		buf_block_t*	father;
+		const page_t*	page	= buf_block_get_frame(block);
+
+		ut_a(page_get_n_recs(page) == 1);
+		ut_a(page_level == btr_page_get_level(page, mtr));
+		ut_a(btr_page_get_prev(page, mtr) == FIL_NULL);
+		ut_a(btr_page_get_next(page, mtr) == FIL_NULL);
+
+		ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+		btr_search_drop_page_hash_index(block);
+
+		btr_page_get_father(index, block, mtr, &cursor);
+		father = btr_cur_get_block(&cursor);
+
+		lock_update_discard(father, PAGE_HEAP_NO_SUPREMUM, block);
+
+		/* Free the file page */
+		btr_page_free(index, block, mtr);
+
+		block = father;
+		page_level++;
+	}
+
+	/* block is the root page, which must be empty, except
+	for the node pointer to the (now discarded) block(s). */
+
+#ifdef UNIV_BTR_DEBUG
+	if (!dict_index_is_ibuf(index)) {
+		const page_t*	root	= buf_block_get_frame(block);
+		const ulint	space	= dict_index_get_space(index);
+		ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
+					    + root, space));
+		ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
+					    + root, space));
+	}
+#endif /* UNIV_BTR_DEBUG */
+
+	btr_page_empty(block, buf_block_get_page_zip(block), index, 0, mtr);
+
+	/* We play it safe and reset the free bits for the root */
+	if (!dict_index_is_clust(index)) {
+		ibuf_reset_free_bits(block);
+	}
+}
+
+/*****************************************************************
+Discards a page from a B-tree. This is used to remove the last record from
+a B-tree page: the whole page must be removed at the same time. This cannot
+be used for the root page, which is allowed to be empty. */
+UNIV_INTERN
+void
+btr_discard_page(
+/*=============*/
+	btr_cur_t*	cursor,	/* in: cursor on the page to discard: not on
+				the root page */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	dict_index_t*	index;
+	ulint		space;
+	ulint		zip_size;
+	ulint		left_page_no;
+	ulint		right_page_no;
+	buf_block_t*	merge_block;
+	page_t*		merge_page;
+	buf_block_t*	block;
+	page_t*		page;
+	rec_t*		node_ptr;
+
+	block = btr_cur_get_block(cursor);
+	index = btr_cur_get_index(cursor);
+
+	ut_ad(dict_index_get_page(index) != buf_block_get_page_no(block));
+	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));
+	space = dict_index_get_space(index);
+	zip_size = dict_table_zip_size(index->table);
+
+	/* Decide the page which will inherit the locks */
+
+	left_page_no = btr_page_get_prev(buf_block_get_frame(block), mtr);
+	right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr);
+
+	if (left_page_no != FIL_NULL) {
+		merge_block = btr_block_get(space, zip_size, left_page_no,
+					    RW_X_LATCH, mtr);
+		merge_page = buf_block_get_frame(merge_block);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(btr_page_get_next(merge_page, mtr)
+		     == buf_block_get_page_no(block));
+#endif /* UNIV_BTR_DEBUG */
+	} else if (right_page_no != FIL_NULL) {
+		merge_block = btr_block_get(space, zip_size, right_page_no,
+					    RW_X_LATCH, mtr);
+		merge_page = buf_block_get_frame(merge_block);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(btr_page_get_prev(merge_page, mtr)
+		     == buf_block_get_page_no(block));
+#endif /* UNIV_BTR_DEBUG */
+	} else {
+		btr_discard_only_page_on_level(index, block, mtr);
+
+		return;
+	}
+
+	page = buf_block_get_frame(block);
+	ut_a(page_is_comp(merge_page) == page_is_comp(page));
+	btr_search_drop_page_hash_index(block);
+
+	if (left_page_no == FIL_NULL && !page_is_leaf(page)) {
+
+		/* We have to mark the leftmost node pointer on the right
+		side page as the predefined minimum record */
+		node_ptr = page_rec_get_next(page_get_infimum_rec(merge_page));
+
+		ut_ad(page_rec_is_user_rec(node_ptr));
+
+		/* This will make page_zip_validate() fail on merge_page
+		until btr_level_list_remove() completes.  This is harmless,
+		because everything will take place within a single
+		mini-transaction and because writing to the redo log
+		is an atomic operation (performed by mtr_commit()). */
+		btr_set_min_rec_mark(node_ptr, mtr);
+	}
+
+	btr_node_ptr_delete(index, block, mtr);
+
+	/* Remove the page from the level list */
+	btr_level_list_remove(space, zip_size, page, mtr);
+#ifdef UNIV_ZIP_DEBUG
+	{
+		page_zip_des_t*	merge_page_zip
+			= buf_block_get_page_zip(merge_block);
+		ut_a(!merge_page_zip
+		     || page_zip_validate(merge_page_zip, merge_page));
+	}
+#endif /* UNIV_ZIP_DEBUG */
+
+	if (left_page_no != FIL_NULL) {
+		lock_update_discard(merge_block, PAGE_HEAP_NO_SUPREMUM,
+				    block);
+	} else {
+		lock_update_discard(merge_block,
+				    lock_get_min_heap_no(merge_block),
+				    block);
+	}
+
+	/* Free the file page */
+	btr_page_free(index, block, mtr);
+
+	ut_ad(btr_check_node_ptr(index, merge_block, mtr));
+}
+
+#ifdef UNIV_BTR_PRINT
+/*****************************************************************
+Prints size info of a B-tree. */
+UNIV_INTERN
+void
+btr_print_size(
+/*===========*/
+	dict_index_t*	index)	/* in: index tree */
+{
+	page_t*		root;
+	fseg_header_t*	seg;
+	mtr_t		mtr;
+
+	if (dict_index_is_ibuf(index)) {
+		fputs("Sorry, cannot print info of an ibuf tree:"
+		      " use ibuf functions\n", stderr);
+
+		return;
+	}
+
+	mtr_start(&mtr);
+
+	root = btr_root_get(index, &mtr);
+
+	seg = root + PAGE_HEADER + PAGE_BTR_SEG_TOP;
+
+	fputs("INFO OF THE NON-LEAF PAGE SEGMENT\n", stderr);
+	fseg_print(seg, &mtr);
+
+	if (!(index->type & DICT_UNIVERSAL)) {
+
+		seg = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
+
+		fputs("INFO OF THE LEAF PAGE SEGMENT\n", stderr);
+		fseg_print(seg, &mtr);
+	}
+
+	mtr_commit(&mtr);
+}
+
+/****************************************************************
+Prints recursively index tree pages. */
+static
+void
+btr_print_recursive(
+/*================*/
+	dict_index_t*	index,	/* in: index tree */
+	buf_block_t*	block,	/* in: index page */
+	ulint		width,	/* in: print this many entries from start
+				and end */
+	mem_heap_t**	heap,	/* in/out: heap for rec_get_offsets() */
+	ulint**		offsets,/* in/out: buffer for rec_get_offsets() */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	const page_t*	page	= buf_block_get_frame(block);
+	page_cur_t	cursor;
+	ulint		n_recs;
+	ulint		i	= 0;
+	mtr_t		mtr2;
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	fprintf(stderr, "NODE ON LEVEL %lu page number %lu\n",
+		(ulong) btr_page_get_level(page, mtr),
+		(ulong) buf_block_get_page_no(block));
+
+	page_print(block, index, width, width);
+
+	n_recs = page_get_n_recs(page);
+
+	page_cur_set_before_first(block, &cursor);
+	page_cur_move_to_next(&cursor);
+
+	while (!page_cur_is_after_last(&cursor)) {
+
+		if (page_is_leaf(page)) {
+
+			/* If this is the leaf level, do nothing */
+
+		} else if ((i <= width) || (i >= n_recs - width)) {
+
+			const rec_t*	node_ptr;
+
+			mtr_start(&mtr2);
+
+			node_ptr = page_cur_get_rec(&cursor);
+
+			*offsets = rec_get_offsets(node_ptr, index, *offsets,
+						   ULINT_UNDEFINED, heap);
+			btr_print_recursive(index,
+					    btr_node_ptr_get_child(node_ptr,
+								   index,
+								   *offsets,
+								   &mtr2),
+					    width, heap, offsets, &mtr2);
+			mtr_commit(&mtr2);
+		}
+
+		page_cur_move_to_next(&cursor);
+		i++;
+	}
+}
+
+/******************************************************************
+Prints directories and other info of all nodes in the tree. */
+UNIV_INTERN
+void
+btr_print_index(
+/*============*/
+	dict_index_t*	index,	/* in: index */
+	ulint		width)	/* in: print this many entries from start
+				and end */
+{
+	mtr_t		mtr;
+	buf_block_t*	root;
+	mem_heap_t*	heap	= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets	= offsets_;
+	rec_offs_init(offsets_);
+
+	fputs("--------------------------\n"
+	      "INDEX TREE PRINT\n", stderr);
+
+	mtr_start(&mtr);
+
+	root = btr_root_block_get(index, &mtr);
+
+	btr_print_recursive(index, root, width, &heap, &offsets, &mtr);
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+
+	mtr_commit(&mtr);
+
+	btr_validate_index(index, NULL);
+}
+#endif /* UNIV_BTR_PRINT */
+
+#ifdef UNIV_DEBUG
+/****************************************************************
+Checks that the node pointer to a page is appropriate. */
+UNIV_INTERN
+ibool
+btr_check_node_ptr(
+/*===============*/
+				/* out: TRUE */
+	dict_index_t*	index,	/* in: index tree */
+	buf_block_t*	block,	/* in: index page */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	mem_heap_t*	heap;
+	dtuple_t*	tuple;
+	ulint*		offsets;
+	btr_cur_t	cursor;
+	page_t*		page = buf_block_get_frame(block);
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	if (dict_index_get_page(index) == buf_block_get_page_no(block)) {
+
+		return(TRUE);
+	}
+
+	heap = mem_heap_create(256);
+	offsets = btr_page_get_father_block(NULL, heap, index, block, mtr,
+					    &cursor);
+
+	if (page_is_leaf(page)) {
+
+		goto func_exit;
+	}
+
+	tuple = dict_index_build_node_ptr(
+		index, page_rec_get_next(page_get_infimum_rec(page)), 0, heap,
+		btr_page_get_level(page, mtr));
+
+	ut_a(!cmp_dtuple_rec(tuple, btr_cur_get_rec(&cursor), offsets));
+func_exit:
+	mem_heap_free(heap);
+
+	return(TRUE);
+}
+#endif /* UNIV_DEBUG */
+
+/****************************************************************
+Display identification information for a record. */
+static
+void
+btr_index_rec_validate_report(
+/*==========================*/
+	const page_t*		page,	/* in: index page */
+	const rec_t*		rec,	/* in: index record */
+	const dict_index_t*	index)	/* in: index */
+{
+	fputs("InnoDB: Record in ", stderr);
+	dict_index_name_print(stderr, NULL, index);
+	fprintf(stderr, ", page %lu, at offset %lu\n",
+		page_get_page_no(page), (ulint) page_offset(rec));
+}
+
+/****************************************************************
+Checks the size and number of fields in a record based on the definition of
+the index. */
+UNIV_INTERN
+ibool
+btr_index_rec_validate(
+/*===================*/
+						/* out: TRUE if ok */
+	const rec_t*		rec,		/* in: index record */
+	const dict_index_t*	index,		/* in: index */
+	ibool			dump_on_error)	/* in: TRUE if the function
+						should print hex dump of record
+						and page on error */
+{
+	ulint		len;
+	ulint		n;
+	ulint		i;
+	const page_t*	page;
+	mem_heap_t*	heap	= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets	= offsets_;
+	rec_offs_init(offsets_);
+
+	page = page_align(rec);
+
+	if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
+		/* The insert buffer index tree can contain records from any
+		other index: we cannot check the number of fields or
+		their length */
+
+		return(TRUE);
+	}
+
+	if (UNIV_UNLIKELY((ibool)!!page_is_comp(page)
+			  != dict_table_is_comp(index->table))) {
+		btr_index_rec_validate_report(page, rec, index);
+		fprintf(stderr, "InnoDB: compact flag=%lu, should be %lu\n",
+			(ulong) !!page_is_comp(page),
+			(ulong) dict_table_is_comp(index->table));
+
+		return(FALSE);
+	}
+
+	n = dict_index_get_n_fields(index);
+
+	if (!page_is_comp(page)
+	    && UNIV_UNLIKELY(rec_get_n_fields_old(rec) != n)) {
+		btr_index_rec_validate_report(page, rec, index);
+		fprintf(stderr, "InnoDB: has %lu fields, should have %lu\n",
+			(ulong) rec_get_n_fields_old(rec), (ulong) n);
+
+		if (dump_on_error) {
+			buf_page_print(page, 0);
+
+			fputs("InnoDB: corrupt record ", stderr);
+			rec_print_old(stderr, rec);
+			putc('\n', stderr);
+		}
+		return(FALSE);
+	}
+
+	offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
+
+	for (i = 0; i < n; i++) {
+		ulint	fixed_size = dict_col_get_fixed_size(
+			dict_index_get_nth_col(index, i));
+
+		rec_get_nth_field_offs(offsets, i, &len);
+
+		/* Note that if fixed_size != 0, it equals the
+		length of a fixed-size column in the clustered index.
+		A prefix index of the column is of fixed, but different
+		length.  When fixed_size == 0, prefix_len is the maximum
+		length of the prefix index column. */
+
+		if ((dict_index_get_nth_field(index, i)->prefix_len == 0
+		     && len != UNIV_SQL_NULL && fixed_size
+		     && len != fixed_size)
+		    || (dict_index_get_nth_field(index, i)->prefix_len > 0
+			&& len != UNIV_SQL_NULL
+			&& len
+			> dict_index_get_nth_field(index, i)->prefix_len)) {
+
+			btr_index_rec_validate_report(page, rec, index);
+			fprintf(stderr,
+				"InnoDB: field %lu len is %lu,"
+				" should be %lu\n",
+				(ulong) i, (ulong) len, (ulong) fixed_size);
+
+			if (dump_on_error) {
+				buf_page_print(page, 0);
+
+				fputs("InnoDB: corrupt record ", stderr);
+				rec_print_new(stderr, rec, offsets);
+				putc('\n', stderr);
+			}
+			if (UNIV_LIKELY_NULL(heap)) {
+				mem_heap_free(heap);
+			}
+			return(FALSE);
+		}
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+	return(TRUE);
+}
+
+/****************************************************************
+Checks the size and number of fields in records based on the definition of
+the index. */
+static
+ibool
+btr_index_page_validate(
+/*====================*/
+				/* out: TRUE if ok */
+	buf_block_t*	block,	/* in: index page */
+	dict_index_t*	index)	/* in: index */
+{
+	page_cur_t	cur;
+	ibool		ret	= TRUE;
+
+	page_cur_set_before_first(block, &cur);
+	page_cur_move_to_next(&cur);
+
+	for (;;) {
+		if (page_cur_is_after_last(&cur)) {
+
+			break;
+		}
+
+		if (!btr_index_rec_validate(cur.rec, index, TRUE)) {
+
+			return(FALSE);
+		}
+
+		page_cur_move_to_next(&cur);
+	}
+
+	return(ret);
+}
+
+/****************************************************************
+Report an error on one page of an index tree. */
+static
+void
+btr_validate_report1(
+/*=================*/
+					/* out: TRUE if ok */
+	dict_index_t*		index,	/* in: index */
+	ulint			level,	/* in: B-tree level */
+	const buf_block_t*	block)	/* in: index page */
+{
+	fprintf(stderr, "InnoDB: Error in page %lu of ",
+		buf_block_get_page_no(block));
+	dict_index_name_print(stderr, NULL, index);
+	if (level) {
+		fprintf(stderr, ", index tree level %lu", level);
+	}
+	putc('\n', stderr);
+}
+
+/****************************************************************
+Report an error on two pages of an index tree. */
+static
+void
+btr_validate_report2(
+/*=================*/
+					/* out: TRUE if ok */
+	const dict_index_t*	index,	/* in: index */
+	ulint			level,	/* in: B-tree level */
+	const buf_block_t*	block1,	/* in: first index page */
+	const buf_block_t*	block2)	/* in: second index page */
+{
+	fprintf(stderr, "InnoDB: Error in pages %lu and %lu of ",
+		buf_block_get_page_no(block1),
+		buf_block_get_page_no(block2));
+	dict_index_name_print(stderr, NULL, index);
+	if (level) {
+		fprintf(stderr, ", index tree level %lu", level);
+	}
+	putc('\n', stderr);
+}
+
+/****************************************************************
+Validates index tree level. */
+static
+ibool
+btr_validate_level(
+/*===============*/
+				/* out: TRUE if ok */
+	dict_index_t*	index,	/* in: index tree */
+	trx_t*		trx,	/* in: transaction or NULL */
+	ulint		level)	/* in: level number */
+{
+	ulint		space;
+	ulint		zip_size;
+	buf_block_t*	block;
+	page_t*		page;
+	buf_block_t*	right_block = 0; /* remove warning */
+	page_t*		right_page = 0; /* remove warning */
+	page_t*		father_page;
+	btr_cur_t	node_cur;
+	btr_cur_t	right_node_cur;
+	rec_t*		rec;
+	ulint		right_page_no;
+	ulint		left_page_no;
+	page_cur_t	cursor;
+	dtuple_t*	node_ptr_tuple;
+	ibool		ret	= TRUE;
+	mtr_t		mtr;
+	mem_heap_t*	heap	= mem_heap_create(256);
+	ulint*		offsets	= NULL;
+	ulint*		offsets2= NULL;
+#ifdef UNIV_ZIP_DEBUG
+	page_zip_des_t*	page_zip;
+#endif /* UNIV_ZIP_DEBUG */
+
+	mtr_start(&mtr);
+
+	mtr_x_lock(dict_index_get_lock(index), &mtr);
+
+	block = btr_root_block_get(index, &mtr);
+	page = buf_block_get_frame(block);
+
+	space = dict_index_get_space(index);
+	zip_size = dict_table_zip_size(index->table);
+
+	while (level != btr_page_get_level(page, &mtr)) {
+		const rec_t*	node_ptr;
+
+		ut_a(space == buf_block_get_space(block));
+		ut_a(space == page_get_space_id(page));
+#ifdef UNIV_ZIP_DEBUG
+		page_zip = buf_block_get_page_zip(block);
+		ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+		ut_a(!page_is_leaf(page));
+
+		page_cur_set_before_first(block, &cursor);
+		page_cur_move_to_next(&cursor);
+
+		node_ptr = page_cur_get_rec(&cursor);
+		offsets = rec_get_offsets(node_ptr, index, offsets,
+					  ULINT_UNDEFINED, &heap);
+		block = btr_node_ptr_get_child(node_ptr, index, offsets, &mtr);
+		page = buf_block_get_frame(block);
+	}
+
+	/* Now we are on the desired level. Loop through the pages on that
+	level. */
+loop:
+	if (trx_is_interrupted(trx)) {
+		mtr_commit(&mtr);
+		mem_heap_free(heap);
+		return(ret);
+	}
+	mem_heap_empty(heap);
+	offsets = offsets2 = NULL;
+	mtr_x_lock(dict_index_get_lock(index), &mtr);
+
+#ifdef UNIV_ZIP_DEBUG
+	page_zip = buf_block_get_page_zip(block);
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+
+	/* Check ordering etc. of records */
+
+	if (!page_validate(page, index)) {
+		btr_validate_report1(index, level, block);
+
+		ret = FALSE;
+	} else if (level == 0) {
+		/* We are on level 0. Check that the records have the right
+		number of fields, and field lengths are right. */
+
+		if (!btr_index_page_validate(block, index)) {
+
+			ret = FALSE;
+		}
+	}
+
+	ut_a(btr_page_get_level(page, &mtr) == level);
+
+	right_page_no = btr_page_get_next(page, &mtr);
+	left_page_no = btr_page_get_prev(page, &mtr);
+
+	ut_a(page_get_n_recs(page) > 0 || (level == 0
+					   && page_get_page_no(page)
+					   == dict_index_get_page(index)));
+
+	if (right_page_no != FIL_NULL) {
+		const rec_t*	right_rec;
+		right_block = btr_block_get(space, zip_size, right_page_no,
+					    RW_X_LATCH, &mtr);
+		right_page = buf_block_get_frame(right_block);
+		if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr)
+				  != page_get_page_no(page))) {
+			btr_validate_report2(index, level, block, right_block);
+			fputs("InnoDB: broken FIL_PAGE_NEXT"
+			      " or FIL_PAGE_PREV links\n", stderr);
+			buf_page_print(page, 0);
+			buf_page_print(right_page, 0);
+
+			ret = FALSE;
+		}
+
+		if (UNIV_UNLIKELY(page_is_comp(right_page)
+				  != page_is_comp(page))) {
+			btr_validate_report2(index, level, block, right_block);
+			fputs("InnoDB: 'compact' flag mismatch\n", stderr);
+			buf_page_print(page, 0);
+			buf_page_print(right_page, 0);
+
+			ret = FALSE;
+
+			goto node_ptr_fails;
+		}
+
+		rec = page_rec_get_prev(page_get_supremum_rec(page));
+		right_rec = page_rec_get_next(page_get_infimum_rec(
+						      right_page));
+		offsets = rec_get_offsets(rec, index,
+					  offsets, ULINT_UNDEFINED, &heap);
+		offsets2 = rec_get_offsets(right_rec, index,
+					   offsets2, ULINT_UNDEFINED, &heap);
+		if (UNIV_UNLIKELY(cmp_rec_rec(rec, right_rec,
+					      offsets, offsets2,
+					      index) >= 0)) {
+
+			btr_validate_report2(index, level, block, right_block);
+
+			fputs("InnoDB: records in wrong order"
+			      " on adjacent pages\n", stderr);
+
+			buf_page_print(page, 0);
+			buf_page_print(right_page, 0);
+
+			fputs("InnoDB: record ", stderr);
+			rec = page_rec_get_prev(page_get_supremum_rec(page));
+			rec_print(stderr, rec, index);
+			putc('\n', stderr);
+			fputs("InnoDB: record ", stderr);
+			rec = page_rec_get_next(
+				page_get_infimum_rec(right_page));
+			rec_print(stderr, rec, index);
+			putc('\n', stderr);
+
+			ret = FALSE;
+		}
+	}
+
+	if (level > 0 && left_page_no == FIL_NULL) {
+		ut_a(REC_INFO_MIN_REC_FLAG & rec_get_info_bits(
+			     page_rec_get_next(page_get_infimum_rec(page)),
+			     page_is_comp(page)));
+	}
+
+	if (buf_block_get_page_no(block) != dict_index_get_page(index)) {
+
+		/* Check father node pointers */
+
+		rec_t*	node_ptr;
+
+		offsets = btr_page_get_father_block(offsets, heap, index,
+						    block, &mtr, &node_cur);
+		father_page = btr_cur_get_page(&node_cur);
+		node_ptr = btr_cur_get_rec(&node_cur);
+
+		btr_cur_position(
+			index, page_rec_get_prev(page_get_supremum_rec(page)),
+			block, &node_cur);
+		offsets = btr_page_get_father_node_ptr(offsets, heap,
+						       &node_cur, &mtr);
+
+		if (UNIV_UNLIKELY(node_ptr != btr_cur_get_rec(&node_cur))
+		    || UNIV_UNLIKELY(btr_node_ptr_get_child_page_no(node_ptr,
+								    offsets)
+				     != buf_block_get_page_no(block))) {
+
+			btr_validate_report1(index, level, block);
+
+			fputs("InnoDB: node pointer to the page is wrong\n",
+			      stderr);
+
+			buf_page_print(father_page, 0);
+			buf_page_print(page, 0);
+
+			fputs("InnoDB: node ptr ", stderr);
+			rec_print(stderr, node_ptr, index);
+
+			rec = btr_cur_get_rec(&node_cur);
+			fprintf(stderr, "\n"
+				"InnoDB: node ptr child page n:o %lu\n",
+				(ulong) btr_node_ptr_get_child_page_no(
+					rec, offsets));
+
+			fputs("InnoDB: record on page ", stderr);
+			rec_print_new(stderr, rec, offsets);
+			putc('\n', stderr);
+			ret = FALSE;
+
+			goto node_ptr_fails;
+		}
+
+		if (!page_is_leaf(page)) {
+			node_ptr_tuple = dict_index_build_node_ptr(
+				index,
+				page_rec_get_next(page_get_infimum_rec(page)),
+				0, heap, btr_page_get_level(page, &mtr));
+
+			if (cmp_dtuple_rec(node_ptr_tuple, node_ptr,
+					   offsets)) {
+				const rec_t* first_rec = page_rec_get_next(
+					page_get_infimum_rec(page));
+
+				btr_validate_report1(index, level, block);
+
+				buf_page_print(father_page, 0);
+				buf_page_print(page, 0);
+
+				fputs("InnoDB: Error: node ptrs differ"
+				      " on levels > 0\n"
+				      "InnoDB: node ptr ", stderr);
+				rec_print_new(stderr, node_ptr, offsets);
+				fputs("InnoDB: first rec ", stderr);
+				rec_print(stderr, first_rec, index);
+				putc('\n', stderr);
+				ret = FALSE;
+
+				goto node_ptr_fails;
+			}
+		}
+
+		if (left_page_no == FIL_NULL) {
+			ut_a(node_ptr == page_rec_get_next(
+				     page_get_infimum_rec(father_page)));
+			ut_a(btr_page_get_prev(father_page, &mtr) == FIL_NULL);
+		}
+
+		if (right_page_no == FIL_NULL) {
+			ut_a(node_ptr == page_rec_get_prev(
+				     page_get_supremum_rec(father_page)));
+			ut_a(btr_page_get_next(father_page, &mtr) == FIL_NULL);
+		} else {
+			const rec_t*	right_node_ptr
+				= page_rec_get_next(node_ptr);
+
+			offsets = btr_page_get_father_block(
+				offsets, heap, index, right_block,
+				&mtr, &right_node_cur);
+			if (right_node_ptr
+			    != page_get_supremum_rec(father_page)) {
+
+				if (btr_cur_get_rec(&right_node_cur)
+				    != right_node_ptr) {
+					ret = FALSE;
+					fputs("InnoDB: node pointer to"
+					      " the right page is wrong\n",
+					      stderr);
+
+					btr_validate_report1(index, level,
+							     block);
+
+					buf_page_print(father_page, 0);
+					buf_page_print(page, 0);
+					buf_page_print(right_page, 0);
+				}
+			} else {
+				page_t*	right_father_page
+					= btr_cur_get_page(&right_node_cur);
+
+				if (btr_cur_get_rec(&right_node_cur)
+				    != page_rec_get_next(
+					    page_get_infimum_rec(
+						    right_father_page))) {
+					ret = FALSE;
+					fputs("InnoDB: node pointer 2 to"
+					      " the right page is wrong\n",
+					      stderr);
+
+					btr_validate_report1(index, level,
+							     block);
+
+					buf_page_print(father_page, 0);
+					buf_page_print(right_father_page, 0);
+					buf_page_print(page, 0);
+					buf_page_print(right_page, 0);
+				}
+
+				if (page_get_page_no(right_father_page)
+				    != btr_page_get_next(father_page, &mtr)) {
+
+					ret = FALSE;
+					fputs("InnoDB: node pointer 3 to"
+					      " the right page is wrong\n",
+					      stderr);
+
+					btr_validate_report1(index, level,
+							     block);
+
+					buf_page_print(father_page, 0);
+					buf_page_print(right_father_page, 0);
+					buf_page_print(page, 0);
+					buf_page_print(right_page, 0);
+				}
+			}
+		}
+	}
+
+node_ptr_fails:
+	/* Commit the mini-transaction to release the latch on 'page'.
+	Re-acquire the latch on right_page, which will become 'page'
+	on the next loop.  The page has already been checked. */
+	mtr_commit(&mtr);
+
+	if (right_page_no != FIL_NULL) {
+		mtr_start(&mtr);
+
+		block = btr_block_get(space, zip_size, right_page_no,
+				      RW_X_LATCH, &mtr);
+		page = buf_block_get_frame(block);
+
+		goto loop;
+	}
+
+	mem_heap_free(heap);
+	return(ret);
+}
+
+/******************************************************************
+Checks the consistency of an index tree. */
+UNIV_INTERN
+ibool
+btr_validate_index(
+/*===============*/
+				/* out: TRUE if ok */
+	dict_index_t*	index,	/* in: index */
+	trx_t*		trx)	/* in: transaction or NULL */
+{
+	mtr_t	mtr;
+	page_t*	root;
+	ulint	i;
+	ulint	n;
+
+	mtr_start(&mtr);
+	mtr_x_lock(dict_index_get_lock(index), &mtr);
+
+	root = btr_root_get(index, &mtr);
+	n = btr_page_get_level(root, &mtr);
+
+	for (i = 0; i <= n && !trx_is_interrupted(trx); i++) {
+		if (!btr_validate_level(index, trx, n - i)) {
+
+			mtr_commit(&mtr);
+
+			return(FALSE);
+		}
+	}
+
+	mtr_commit(&mtr);
+
+	return(TRUE);
+}

=== added file 'storage/xtradb/btr/btr0cur.c'
--- a/storage/xtradb/btr/btr0cur.c	1970-01-01 00:00:00 +0000
+++ b/storage/xtradb/btr/btr0cur.c	2009-05-04 02:45:47 +0000
@@ -0,0 +1,4809 @@
+/*****************************************************************************
+
+Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/******************************************************
+The index tree cursor
+
+All changes that row operations make to a B-tree or the records
+there must go through this module! Undo log records are written here
+of every modify or insert of a clustered index record.
+
+			NOTE!!!
+To make sure we do not run out of disk space during a pessimistic
+insert or update, we have to reserve 2 x the height of the index tree
+many pages in the tablespace before we start the operation, because
+if leaf splitting has been started, it is difficult to undo, except
+by crashing the database and doing a roll-forward.
+
+Created 10/16/1994 Heikki Tuuri
+*******************************************************/
+
+#include "btr0cur.h"
+
+#ifdef UNIV_NONINL
+#include "btr0cur.ic"
+#endif
+
+#include "page0page.h"
+#include "page0zip.h"
+#include "rem0rec.h"
+#include "rem0cmp.h"
+#include "buf0lru.h"
+#include "btr0btr.h"
+#include "btr0sea.h"
+#include "row0upd.h"
+#include "trx0rec.h"
+#include "trx0roll.h" /* trx_is_recv() */
+#include "que0que.h"
+#include "row0row.h"
+#include "srv0srv.h"
+#include "ibuf0ibuf.h"
+#include "lock0lock.h"
+#include "zlib.h"
+
+#ifdef UNIV_DEBUG
+/* If the following is set to TRUE, this module prints a lot of
+trace information of individual record operations */
+UNIV_INTERN ibool	btr_cur_print_record_ops = FALSE;
+#endif /* UNIV_DEBUG */
+
+UNIV_INTERN ulint	btr_cur_n_non_sea	= 0;
+UNIV_INTERN ulint	btr_cur_n_sea		= 0;
+UNIV_INTERN ulint	btr_cur_n_non_sea_old	= 0;
+UNIV_INTERN ulint	btr_cur_n_sea_old	= 0;
+
+/* In the optimistic insert, if the insert does not fit, but this much space
+can be released by page reorganize, then it is reorganized */
+
+#define BTR_CUR_PAGE_REORGANIZE_LIMIT	(UNIV_PAGE_SIZE / 32)
+
+/* The structure of a BLOB part header */
+/*--------------------------------------*/
+#define BTR_BLOB_HDR_PART_LEN		0	/* BLOB part len on this
+						page */
+#define BTR_BLOB_HDR_NEXT_PAGE_NO	4	/* next BLOB part page no,
+						FIL_NULL if none */
+/*--------------------------------------*/
+#define BTR_BLOB_HDR_SIZE		8
+
+/* A BLOB field reference full of zero, for use in assertions and tests.
+Initially, BLOB field references are set to zero, in
+dtuple_convert_big_rec(). */
+UNIV_INTERN const byte field_ref_zero[BTR_EXTERN_FIELD_REF_SIZE];
+
+/***********************************************************************
+Marks all extern fields in a record as owned by the record. This function
+should be called if the delete mark of a record is removed: a not delete
+marked record always owns all its extern fields. */
+static
+void
+btr_cur_unmark_extern_fields(
+/*=========================*/
+	page_zip_des_t*	page_zip,/* in/out: compressed page whose uncompressed
+				part will be updated, or NULL */
+	rec_t*		rec,	/* in/out: record in a clustered index */
+	dict_index_t*	index,	/* in: index of the page */
+	const ulint*	offsets,/* in: array returned by rec_get_offsets() */
+	mtr_t*		mtr);	/* in: mtr, or NULL if not logged */
+/***********************************************************************
+Adds path information to the cursor for the current page, for which
+the binary search has been performed. */
+static
+void
+btr_cur_add_path_info(
+/*==================*/
+	btr_cur_t*	cursor,		/* in: cursor positioned on a page */
+	ulint		height,		/* in: height of the page in tree;
+					0 means leaf node */
+	ulint		root_height);	/* in: root node height in tree */
+/***************************************************************
+Frees the externally stored fields for a record, if the field is mentioned
+in the update vector. */
+static
+void
+btr_rec_free_updated_extern_fields(
+/*===============================*/
+	dict_index_t*	index,	/* in: index of rec; the index tree MUST be
+				X-latched */
+	rec_t*		rec,	/* in: record */
+	page_zip_des_t*	page_zip,/* in: compressed page whose uncompressed
+				part will be updated, or NULL */
+	const ulint*	offsets,/* in: rec_get_offsets(rec, index) */
+	const upd_t*	update,	/* in: update vector */
+	enum trx_rb_ctx	rb_ctx,	/* in: rollback context */
+	mtr_t*		mtr);	/* in: mini-transaction handle which contains
+				an X-latch to record page and to the tree */
+/***************************************************************
+Frees the externally stored fields for a record. */
+static
+void
+btr_rec_free_externally_stored_fields(
+/*==================================*/
+	dict_index_t*	index,	/* in: index of the data, the index
+				tree MUST be X-latched */
+	rec_t*		rec,	/* in: record */
+	const ulint*	offsets,/* in: rec_get_offsets(rec, index) */
+	page_zip_des_t*	page_zip,/* in: compressed page whose uncompressed
+				part will be updated, or NULL */
+	enum trx_rb_ctx	rb_ctx,	/* in: rollback context */
+	mtr_t*		mtr);	/* in: mini-transaction handle which contains
+				an X-latch to record page and to the index
+				tree */
+/***************************************************************
+Gets the externally stored size of a record, in units of a database page. */
+static
+ulint
+btr_rec_get_externally_stored_len(
+/*==============================*/
+				/* out: externally stored part,
+				in units of a database page */
+	rec_t*		rec,	/* in: record */
+	const ulint*	offsets);/* in: array returned by rec_get_offsets() */
+
+/**********************************************************
+The following function is used to set the deleted bit of a record. */
+UNIV_INLINE
+void
+btr_rec_set_deleted_flag(
+/*=====================*/
+				/* out: TRUE on success;
+				FALSE on page_zip overflow */
+	rec_t*		rec,	/* in/out: physical record */
+	page_zip_des_t*	page_zip,/* in/out: compressed page (or NULL) */
+	ulint		flag)	/* in: nonzero if delete marked */
+{
+	if (page_rec_is_comp(rec)) {
+		rec_set_deleted_flag_new(rec, page_zip, flag);
+	} else {
+		ut_ad(!page_zip);
+		rec_set_deleted_flag_old(rec, flag);
+	}
+}
+
+/*==================== B-TREE SEARCH =========================*/
+
+/************************************************************************
+Latches the leaf page or pages requested. */
+static
+void
+btr_cur_latch_leaves(
+/*=================*/
+	page_t*		page,		/* in: leaf page where the search
+					converged */
+	ulint		space,		/* in: space id */
+	ulint		zip_size,	/* in: compressed page size in bytes
+					or 0 for uncompressed pages */
+	ulint		page_no,	/* in: page number of the leaf */
+	ulint		latch_mode,	/* in: BTR_SEARCH_LEAF, ... */
+	btr_cur_t*	cursor,		/* in: cursor */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	ulint		mode;
+	ulint		left_page_no;
+	ulint		right_page_no;
+	buf_block_t*	get_block;
+
+	ut_ad(page && mtr);
+
+	switch (latch_mode) {
+	case BTR_SEARCH_LEAF:
+	case BTR_MODIFY_LEAF:
+		mode = latch_mode == BTR_SEARCH_LEAF ? RW_S_LATCH : RW_X_LATCH;
+		get_block = btr_block_get(space, zip_size, page_no, mode, mtr);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
+#endif /* UNIV_BTR_DEBUG */
+		get_block->check_index_page_at_flush = TRUE;
+		return;
+	case BTR_MODIFY_TREE:
+		/* x-latch also brothers from left to right */
+		left_page_no = btr_page_get_prev(page, mtr);
+
+		if (left_page_no != FIL_NULL) {
+			get_block = btr_block_get(space, zip_size,
+						  left_page_no,
+						  RW_X_LATCH, mtr);
+#ifdef UNIV_BTR_DEBUG
+			ut_a(page_is_comp(get_block->frame)
+			     == page_is_comp(page));
+			ut_a(btr_page_get_next(get_block->frame, mtr)
+			     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+			get_block->check_index_page_at_flush = TRUE;
+		}
+
+		get_block = btr_block_get(space, zip_size, page_no,
+					  RW_X_LATCH, mtr);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
+#endif /* UNIV_BTR_DEBUG */
+		get_block->check_index_page_at_flush = TRUE;
+
+		right_page_no = btr_page_get_next(page, mtr);
+
+		if (right_page_no != FIL_NULL) {
+			get_block = btr_block_get(space, zip_size,
+						  right_page_no,
+						  RW_X_LATCH, mtr);
+#ifdef UNIV_BTR_DEBUG
+			ut_a(page_is_comp(get_block->frame)
+			     == page_is_comp(page));
+			ut_a(btr_page_get_prev(get_block->frame, mtr)
+			     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+			get_block->check_index_page_at_flush = TRUE;
+		}
+
+		return;
+
+	case BTR_SEARCH_PREV:
+	case BTR_MODIFY_PREV:
+		mode = latch_mode == BTR_SEARCH_PREV ? RW_S_LATCH : RW_X_LATCH;
+		/* latch also left brother */
+		left_page_no = btr_page_get_prev(page, mtr);
+
+		if (left_page_no != FIL_NULL) {
+			get_block = btr_block_get(space, zip_size,
+						  left_page_no, mode, mtr);
+			cursor->left_block = get_block;
+#ifdef UNIV_BTR_DEBUG
+			ut_a(page_is_comp(get_block->frame)
+			     == page_is_comp(page));
+			ut_a(btr_page_get_next(get_block->frame, mtr)
+			     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+			get_block->check_index_page_at_flush = TRUE;
+		}
+
+		get_block = btr_block_get(space, zip_size, page_no, mode, mtr);
+#ifdef UNIV_BTR_DEBUG
+		ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
+#endif /* UNIV_BTR_DEBUG */
+		get_block->check_index_page_at_flush = TRUE;
+		return;
+	}
+
+	ut_error;
+}
+
+/************************************************************************
+Searches an index tree and positions a tree cursor on a given level.
+NOTE: n_fields_cmp in tuple must be set so that it cannot be compared
+to node pointer page number fields on the upper levels of the tree!
+Note that if mode is PAGE_CUR_LE, which is used in inserts, then
+cursor->up_match and cursor->low_match both will have sensible values.
+If mode is PAGE_CUR_GE, then up_match will a have a sensible value.
+
+If mode is PAGE_CUR_LE , cursor is left at the place where an insert of the
+search tuple should be performed in the B-tree. InnoDB does an insert
+immediately after the cursor. Thus, the cursor may end up on a user record,
+or on a page infimum record. */
+UNIV_INTERN
+void
+btr_cur_search_to_nth_level(
+/*========================*/
+	dict_index_t*	index,	/* in: index */
+	ulint		level,	/* in: the tree level of search */
+	const dtuple_t*	tuple,	/* in: data tuple; NOTE: n_fields_cmp in
+				tuple must be set so that it cannot get
+				compared to the node ptr page number field! */
+	ulint		mode,	/* in: PAGE_CUR_L, ...;
+				Inserts should always be made using
+				PAGE_CUR_LE to search the position! */
+	ulint		latch_mode, /* in: BTR_SEARCH_LEAF, ..., ORed with
+				BTR_INSERT and BTR_ESTIMATE;
+				cursor->left_block is used to store a pointer
+				to the left neighbor page, in the cases
+				BTR_SEARCH_PREV and BTR_MODIFY_PREV;
+				NOTE that if has_search_latch
+				is != 0, we maybe do not have a latch set
+				on the cursor page, we assume
+				the caller uses his search latch
+				to protect the record! */
+	btr_cur_t*	cursor, /* in/out: tree cursor; the cursor page is
+				s- or x-latched, but see also above! */
+	ulint		has_search_latch,/* in: info on the latch mode the
+				caller currently has on btr_search_latch:
+				RW_S_LATCH, or 0 */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	page_cur_t*	page_cursor;
+	page_t*		page;
+	buf_block_t*	guess;
+	rec_t*		node_ptr;
+	ulint		page_no;
+	ulint		space;
+	ulint		up_match;
+	ulint		up_bytes;
+	ulint		low_match;
+	ulint		low_bytes;
+	ulint		height;
+	ulint		savepoint;
+	ulint		page_mode;
+	ulint		insert_planned;
+	ulint		estimate;
+	ulint		ignore_sec_unique;
+	ulint		root_height = 0; /* remove warning */
+#ifdef BTR_CUR_ADAPT
+	btr_search_t*	info;
+#endif
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	rec_offs_init(offsets_);
+	/* Currently, PAGE_CUR_LE is the only search mode used for searches
+	ending to upper levels */
+
+	ut_ad(level == 0 || mode == PAGE_CUR_LE);
+	ut_ad(dict_index_check_search_tuple(index, tuple));
+	ut_ad(!dict_index_is_ibuf(index) || ibuf_inside());
+	ut_ad(dtuple_check_typed(tuple));
+
+#ifdef UNIV_DEBUG
+	cursor->up_match = ULINT_UNDEFINED;
+	cursor->low_match = ULINT_UNDEFINED;
+#endif
+	insert_planned = latch_mode & BTR_INSERT;
+	estimate = latch_mode & BTR_ESTIMATE;
+	ignore_sec_unique = latch_mode & BTR_IGNORE_SEC_UNIQUE;
+	latch_mode = latch_mode & ~(BTR_INSERT | BTR_ESTIMATE
+				    | BTR_IGNORE_SEC_UNIQUE);
+
+	ut_ad(!insert_planned || (mode == PAGE_CUR_LE));
+
+	cursor->flag = BTR_CUR_BINARY;
+	cursor->index = index;
+
+#ifndef BTR_CUR_ADAPT
+	guess = NULL;
+#else
+	info = btr_search_get_info(index);
+
+	guess = info->root_guess;
+
+#ifdef BTR_CUR_HASH_ADAPT
+
+#ifdef UNIV_SEARCH_PERF_STAT
+	info->n_searches++;
+#endif
+	if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_NOT_LOCKED
+	    && latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ
+	    && !estimate
+#ifdef PAGE_CUR_LE_OR_EXTENDS
+	    && mode != PAGE_CUR_LE_OR_EXTENDS
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
+	    /* If !has_search_latch, we do a dirty read of
+	    btr_search_enabled below, and btr_search_guess_on_hash()
+	    will have to check it again. */
+	    && UNIV_LIKELY(btr_search_enabled)
+	    && btr_search_guess_on_hash(index, info, tuple, mode,
+					latch_mode, cursor,
+					has_search_latch, mtr)) {
+
+		/* Search using the hash index succeeded */
+
+		ut_ad(cursor->up_match != ULINT_UNDEFINED
+		      || mode != PAGE_CUR_GE);
+		ut_ad(cursor->up_match != ULINT_UNDEFINED
+		      || mode != PAGE_CUR_LE);
+		ut_ad(cursor->low_match != ULINT_UNDEFINED
+		      || mode != PAGE_CUR_LE);
+		btr_cur_n_sea++;
+
+		return;
+	}
+#endif /* BTR_CUR_HASH_ADAPT */
+#endif /* BTR_CUR_ADAPT */
+	btr_cur_n_non_sea++;
+
+	/* If the hash search did not succeed, do binary search down the
+	tree */
+
+	if (has_search_latch) {
+		/* Release possible search latch to obey latching order */
+		rw_lock_s_unlock(&btr_search_latch);
+	}
+
+	/* Store the position of the tree latch we push to mtr so that we
+	know how to release it when we have latched leaf node(s) */
+
+	savepoint = mtr_set_savepoint(mtr);
+
+	if (latch_mode == BTR_MODIFY_TREE) {
+		mtr_x_lock(dict_index_get_lock(index), mtr);
+
+	} else if (latch_mode == BTR_CONT_MODIFY_TREE) {
+		/* Do nothing */
+		ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
+					MTR_MEMO_X_LOCK));
+	} else {
+		mtr_s_lock(dict_index_get_lock(index), mtr);
+	}
+
+	page_cursor = btr_cur_get_page_cur(cursor);
+
+	space = dict_index_get_space(index);
+	page_no = dict_index_get_page(index);
+
+	up_match = 0;
+	up_bytes = 0;
+	low_match = 0;
+	low_bytes = 0;
+
+	height = ULINT_UNDEFINED;
+
+	/* We use these modified search modes on non-leaf levels of the
+	B-tree. These let us end up in the right B-tree leaf. In that leaf
+	we use the original search mode. */
+
+	switch (mode) {
+	case PAGE_CUR_GE:
+		page_mode = PAGE_CUR_L;
+		break;
+	case PAGE_CUR_G:
+		page_mode = PAGE_CUR_LE;
+		break;
+	default:
+#ifdef PAGE_CUR_LE_OR_EXTENDS
+		ut_ad(mode == PAGE_CUR_L || mode == PAGE_CUR_LE
+		      || mode == PAGE_CUR_LE_OR_EXTENDS);
+#else /* PAGE_CUR_LE_OR_EXTENDS */
+		ut_ad(mode == PAGE_CUR_L || mode == PAGE_CUR_LE);
+#endif /* PAGE_CUR_LE_OR_EXTENDS */
+		page_mode = mode;
+		break;
+	}
+
+	/* Loop and search until we arrive at the desired level */
+
+	for (;;) {
+		ulint		zip_size;
+		buf_block_t*	block;
+		ulint		rw_latch;
+		ulint		buf_mode;
+
+		zip_size = dict_table_zip_size(index->table);
+		rw_latch = RW_NO_LATCH;
+		buf_mode = BUF_GET;
+
+		if (height == 0 && latch_mode <= BTR_MODIFY_LEAF) {
+
+			rw_latch = latch_mode;
+
+			if (insert_planned
+			    && ibuf_should_try(index, ignore_sec_unique)) {
+
+				/* Try insert to the insert buffer if the
+				page is not in the buffer pool */
+
+				buf_mode = BUF_GET_IF_IN_POOL;
+			}
+		}
+
+retry_page_get:
+		block = buf_page_get_gen(space, zip_size, page_no,
+					 rw_latch, guess, buf_mode,
+					 __FILE__, __LINE__, mtr);
+		if (block == NULL) {
+			/* This must be a search to perform an insert;
+			try insert to the insert buffer */
+
+			ut_ad(buf_mode == BUF_GET_IF_IN_POOL);
+			ut_ad(insert_planned);
+			ut_ad(cursor->thr);
+
+			if (ibuf_insert(tuple, index, space, zip_size,
+					page_no, cursor->thr)) {
+				/* Insertion to the insert buffer succeeded */
+				cursor->flag = BTR_CUR_INSERT_TO_IBUF;
+				if (UNIV_LIKELY_NULL(heap)) {
+					mem_heap_free(heap);
+				}
+				goto func_exit;
+			}
+
+			/* Insert to the insert buffer did not succeed:
+			retry page get */
+
+			buf_mode = BUF_GET;
+
+			goto retry_page_get;
+		}
+
+		page = buf_block_get_frame(block);
+
+		block->check_index_page_at_flush = TRUE;
+
+		if (rw_latch != RW_NO_LATCH) {
+#ifdef UNIV_ZIP_DEBUG
+			const page_zip_des_t*	page_zip
+				= buf_block_get_page_zip(block);
+			ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+
+			buf_block_dbg_add_level(block, SYNC_TREE_NODE);
+		}
+
+		ut_ad(0 == ut_dulint_cmp(index->id,
+					 btr_page_get_index_id(page)));
+
+		if (UNIV_UNLIKELY(height == ULINT_UNDEFINED)) {
+			/* We are in the root node */
+
+			height = btr_page_get_level(page, mtr);
+			root_height = height;
+			cursor->tree_height = root_height + 1;
+#ifdef BTR_CUR_ADAPT
+			if (block != guess) {
+				info->root_guess = block;
+			}
+#endif
+		}
+
+		if (height == 0) {
+			if (rw_latch == RW_NO_LATCH) {
+
+				btr_cur_latch_leaves(page, space, zip_size,
+						     page_no, latch_mode,
+						     cursor, mtr);
+			}
+
+			if ((latch_mode != BTR_MODIFY_TREE)
+			    && (latch_mode != BTR_CONT_MODIFY_TREE)) {
+
+				/* Release the tree s-latch */
+
+				mtr_release_s_latch_at_savepoint(
+					mtr, savepoint,
+					dict_index_get_lock(index));
+			}
+
+			page_mode = mode;
+		}
+
+		page_cur_search_with_match(block, index, tuple, page_mode,
+					   &up_match, &up_bytes,
+					   &low_match, &low_bytes,
+					   page_cursor);
+
+		if (estimate) {
+			btr_cur_add_path_info(cursor, height, root_height);
+		}
+
+		/* If this is the desired level, leave the loop */
+
+		ut_ad(height == btr_page_get_level(
+			      page_cur_get_page(page_cursor), mtr));
+
+		if (level == height) {
+
+			if (level > 0) {
+				/* x-latch the page */
+				page = btr_page_get(space, zip_size,
+						    page_no, RW_X_LATCH, mtr);
+				ut_a((ibool)!!page_is_comp(page)
+				     == dict_table_is_comp(index->table));
+			}
+
+			break;
+		}
+
+		ut_ad(height > 0);
+
+		height--;
+
+		guess = NULL;
+
+		node_ptr = page_cur_get_rec(page_cursor);
+		offsets = rec_get_offsets(node_ptr, cursor->index, offsets,
+					  ULINT_UNDEFINED, &heap);
+		/* Go to the child node */
+		page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets);
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+
+	if (level == 0) {
+		cursor->low_match = low_match;
+		cursor->low_bytes = low_bytes;
+		cursor->up_match = up_match;
+		cursor->up_bytes = up_bytes;
+
+#ifdef BTR_CUR_ADAPT
+		/* We do a dirty read of btr_search_enabled here.  We
+		will properly check btr_search_enabled again in
+		btr_search_build_page_hash_index() before building a
+		page hash index, while holding btr_search_latch. */
+		if (UNIV_LIKELY(btr_search_enabled)) {
+
+			btr_search_info_update(index, cursor);
+		}
+#endif
+		ut_ad(cursor->up_match != ULINT_UNDEFINED
+		      || mode != PAGE_CUR_GE);
+		ut_ad(cursor->up_match != ULINT_UNDEFINED
+		      || mode != PAGE_CUR_LE);
+		ut_ad(cursor->low_match != ULINT_UNDEFINED
+		      || mode != PAGE_CUR_LE);
+	}
+
+func_exit:
+	if (has_search_latch) {
+
+		rw_lock_s_lock(&btr_search_latch);
+	}
+}
+
+/*********************************************************************
+Opens a cursor at either end of an index. */
+UNIV_INTERN
+void
+btr_cur_open_at_index_side(
+/*=======================*/
+	ibool		from_left,	/* in: TRUE if open to the low end,
+					FALSE if to the high end */
+	dict_index_t*	index,		/* in: index */
+	ulint		latch_mode,	/* in: latch mode */
+	btr_cur_t*	cursor,		/* in: cursor */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	page_cur_t*	page_cursor;
+	ulint		page_no;
+	ulint		space;
+	ulint		zip_size;
+	ulint		height;
+	ulint		root_height = 0; /* remove warning */
+	rec_t*		node_ptr;
+	ulint		estimate;
+	ulint		savepoint;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	rec_offs_init(offsets_);
+
+	estimate = latch_mode & BTR_ESTIMATE;
+	latch_mode = latch_mode & ~BTR_ESTIMATE;
+
+	/* Store the position of the tree latch we push to mtr so that we
+	know how to release it when we have latched the leaf node */
+
+	savepoint = mtr_set_savepoint(mtr);
+
+	if (latch_mode == BTR_MODIFY_TREE) {
+		mtr_x_lock(dict_index_get_lock(index), mtr);
+	} else {
+		mtr_s_lock(dict_index_get_lock(index), mtr);
+	}
+
+	page_cursor = btr_cur_get_page_cur(cursor);
+	cursor->index = index;
+
+	space = dict_index_get_space(index);
+	zip_size = dict_table_zip_size(index->table);
+	page_no = dict_index_get_page(index);
+
+	height = ULINT_UNDEFINED;
+
+	for (;;) {
+		buf_block_t*	block;
+		page_t*		page;
+		block = buf_page_get_gen(space, zip_size, page_no,
+					 RW_NO_LATCH, NULL, BUF_GET,
+					 __FILE__, __LINE__, mtr);
+		page = buf_block_get_frame(block);
+		ut_ad(0 == ut_dulint_cmp(index->id,
+					 btr_page_get_index_id(page)));
+
+		block->check_index_page_at_flush = TRUE;
+
+		if (height == ULINT_UNDEFINED) {
+			/* We are in the root node */
+
+			height = btr_page_get_level(page, mtr);
+			root_height = height;
+		}
+
+		if (height == 0) {
+			btr_cur_latch_leaves(page, space, zip_size, page_no,
+					     latch_mode, cursor, mtr);
+
+			/* In versions <= 3.23.52 we had forgotten to
+			release the tree latch here. If in an index scan
+			we had to scan far to find a record visible to the
+			current transaction, that could starve others
+			waiting for the tree latch. */
+
+			if ((latch_mode != BTR_MODIFY_TREE)
+			    && (latch_mode != BTR_CONT_MODIFY_TREE)) {
+
+				/* Release the tree s-latch */
+
+				mtr_release_s_latch_at_savepoint(
+					mtr, savepoint,
+					dict_index_get_lock(index));
+			}
+		}
+
+		if (from_left) {
+			page_cur_set_before_first(block, page_cursor);
+		} else {
+			page_cur_set_after_last(block, page_cursor);
+		}
+
+		if (height == 0) {
+			if (estimate) {
+				btr_cur_add_path_info(cursor, height,
+						      root_height);
+			}
+
+			break;
+		}
+
+		ut_ad(height > 0);
+
+		if (from_left) {
+			page_cur_move_to_next(page_cursor);
+		} else {
+			page_cur_move_to_prev(page_cursor);
+		}
+
+		if (estimate) {
+			btr_cur_add_path_info(cursor, height, root_height);
+		}
+
+		height--;
+
+		node_ptr = page_cur_get_rec(page_cursor);
+		offsets = rec_get_offsets(node_ptr, cursor->index, offsets,
+					  ULINT_UNDEFINED, &heap);
+		/* Go to the child node */
+		page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets);
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+}
+
+/**************************************************************************
+Positions a cursor at a randomly chosen position within a B-tree. */
+UNIV_INTERN
+void
+btr_cur_open_at_rnd_pos(
+/*====================*/
+	dict_index_t*	index,		/* in: index */
+	ulint		latch_mode,	/* in: BTR_SEARCH_LEAF, ... */
+	btr_cur_t*	cursor,		/* in/out: B-tree cursor */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	page_cur_t*	page_cursor;
+	ulint		page_no;
+	ulint		space;
+	ulint		zip_size;
+	ulint		height;
+	rec_t*		node_ptr;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	rec_offs_init(offsets_);
+
+	if (latch_mode == BTR_MODIFY_TREE) {
+		mtr_x_lock(dict_index_get_lock(index), mtr);
+	} else {
+		mtr_s_lock(dict_index_get_lock(index), mtr);
+	}
+
+	page_cursor = btr_cur_get_page_cur(cursor);
+	cursor->index = index;
+
+	space = dict_index_get_space(index);
+	zip_size = dict_table_zip_size(index->table);
+	page_no = dict_index_get_page(index);
+
+	height = ULINT_UNDEFINED;
+
+	for (;;) {
+		buf_block_t*	block;
+		page_t*		page;
+
+		block = buf_page_get_gen(space, zip_size, page_no,
+					 RW_NO_LATCH, NULL, BUF_GET,
+					 __FILE__, __LINE__, mtr);
+		page = buf_block_get_frame(block);
+		ut_ad(0 == ut_dulint_cmp(index->id,
+					 btr_page_get_index_id(page)));
+
+		if (height == ULINT_UNDEFINED) {
+			/* We are in the root node */
+
+			height = btr_page_get_level(page, mtr);
+		}
+
+		if (height == 0) {
+			btr_cur_latch_leaves(page, space, zip_size, page_no,
+					     latch_mode, cursor, mtr);
+		}
+
+		page_cur_open_on_rnd_user_rec(block, page_cursor);
+
+		if (height == 0) {
+
+			break;
+		}
+
+		ut_ad(height > 0);
+
+		height--;
+
+		node_ptr = page_cur_get_rec(page_cursor);
+		offsets = rec_get_offsets(node_ptr, cursor->index, offsets,
+					  ULINT_UNDEFINED, &heap);
+		/* Go to the child node */
+		page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets);
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+}
+
+/*==================== B-TREE INSERT =========================*/
+
+/*****************************************************************
+Inserts a record if there is enough space, or if enough space can
+be freed by reorganizing. Differs from btr_cur_optimistic_insert because
+no heuristics is applied to whether it pays to use CPU time for
+reorganizing the page or not. */
+static
+rec_t*
+btr_cur_insert_if_possible(
+/*=======================*/
+				/* out: pointer to inserted record if succeed,
+				else NULL */
+	btr_cur_t*	cursor,	/* in: cursor on page after which to insert;
+				cursor stays valid */
+	const dtuple_t*	tuple,	/* in: tuple to insert; the size info need not
+				have been stored to tuple */
+	ulint		n_ext,	/* in: number of externally stored columns */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	page_cur_t*	page_cursor;
+	buf_block_t*	block;
+	rec_t*		rec;
+
+	ut_ad(dtuple_check_typed(tuple));
+
+	block = btr_cur_get_block(cursor);
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	page_cursor = btr_cur_get_page_cur(cursor);
+
+	/* Now, try the insert */
+	rec = page_cur_tuple_insert(page_cursor, tuple,
+				    cursor->index, n_ext, mtr);
+
+	if (UNIV_UNLIKELY(!rec)) {
+		/* If record did not fit, reorganize */
+
+		if (btr_page_reorganize(block, cursor->index, mtr)) {
+
+			page_cur_search(block, cursor->index, tuple,
+					PAGE_CUR_LE, page_cursor);
+
+			rec = page_cur_tuple_insert(page_cursor, tuple,
+						    cursor->index, n_ext, mtr);
+		}
+	}
+
+	return(rec);
+}
+
+/*****************************************************************
+For an insert, checks the locks and does the undo logging if desired. */
+UNIV_INLINE
+ulint
+btr_cur_ins_lock_and_undo(
+/*======================*/
+				/* out: DB_SUCCESS, DB_WAIT_LOCK,
+				DB_FAIL, or error number */
+	ulint		flags,	/* in: undo logging and locking flags: if
+				not zero, the parameters index and thr
+				should be specified */
+	btr_cur_t*	cursor,	/* in: cursor on page after which to insert */
+	const dtuple_t*	entry,	/* in: entry to insert */
+	que_thr_t*	thr,	/* in: query thread or NULL */
+	ibool*		inherit)/* out: TRUE if the inserted new record maybe
+				should inherit LOCK_GAP type locks from the
+				successor record */
+{
+	dict_index_t*	index;
+	ulint		err;
+	rec_t*		rec;
+	dulint		roll_ptr;
+
+	/* Check if we have to wait for a lock: enqueue an explicit lock
+	request if yes */
+
+	rec = btr_cur_get_rec(cursor);
+	index = cursor->index;
+
+	err = lock_rec_insert_check_and_lock(flags, rec,
+					     btr_cur_get_block(cursor),
+					     index, thr, inherit);
+
+	if (err != DB_SUCCESS) {
+
+		return(err);
+	}
+
+	if (dict_index_is_clust(index) && !dict_index_is_ibuf(index)) {
+
+		err = trx_undo_report_row_operation(flags, TRX_UNDO_INSERT_OP,
+						    thr, index, entry,
+						    NULL, 0, NULL,
+						    &roll_ptr);
+		if (err != DB_SUCCESS) {
+
+			return(err);
+		}
+
+		/* Now we can fill in the roll ptr field in entry */
+
+		if (!(flags & BTR_KEEP_SYS_FLAG)) {
+
+			row_upd_index_entry_sys_field(entry, index,
+						      DATA_ROLL_PTR, roll_ptr);
+		}
+	}
+
+	return(DB_SUCCESS);
+}
+
+#ifdef UNIV_DEBUG
+/*****************************************************************
+Report information about a transaction. */
+static
+void
+btr_cur_trx_report(
+/*===============*/
+	trx_t*			trx,	/* in: transaction */
+	const dict_index_t*	index,	/* in: index */
+	const char*		op)	/* in: operation */
+{
+	fprintf(stderr, "Trx with id " TRX_ID_FMT " going to ",
+		TRX_ID_PREP_PRINTF(trx->id));
+	fputs(op, stderr);
+	dict_index_name_print(stderr, trx, index);
+	putc('\n', stderr);
+}
+#endif /* UNIV_DEBUG */
+
+/*****************************************************************
+Tries to perform an insert to a page in an index tree, next to cursor.
+It is assumed that mtr holds an x-latch on the page. The operation does
+not succeed if there is too little space on the page. If there is just
+one record on the page, the insert will always succeed; this is to
+prevent trying to split a page with just one record. */
+UNIV_INTERN
+ulint
+btr_cur_optimistic_insert(
+/*======================*/
+				/* out: DB_SUCCESS, DB_WAIT_LOCK,
+				DB_FAIL, or error number */
+	ulint		flags,	/* in: undo logging and locking flags: if not
+				zero, the parameters index and thr should be
+				specified */
+	btr_cur_t*	cursor,	/* in: cursor on page after which to insert;
+				cursor stays valid */
+	dtuple_t*	entry,	/* in/out: entry to insert */
+	rec_t**		rec,	/* out: pointer to inserted record if
+				succeed */
+	big_rec_t**	big_rec,/* out: big rec vector whose fields have to
+				be stored externally by the caller, or
+				NULL */
+	ulint		n_ext,	/* in: number of externally stored columns */
+	que_thr_t*	thr,	/* in: query thread or NULL */
+	mtr_t*		mtr)	/* in: mtr; if this function returns
+				DB_SUCCESS on a leaf page of a secondary
+				index in a compressed tablespace, the
+				mtr must be committed before latching
+				any further pages */
+{
+	big_rec_t*	big_rec_vec	= NULL;
+	dict_index_t*	index;
+	page_cur_t*	page_cursor;
+	buf_block_t*	block;
+	page_t*		page;
+	ulint		max_size;
+	rec_t*		dummy_rec;
+	ibool		leaf;
+	ibool		reorg;
+	ibool		inherit;
+	ulint		zip_size;
+	ulint		rec_size;
+	mem_heap_t*	heap		= NULL;
+	ulint		err;
+
+	*big_rec = NULL;
+
+	block = btr_cur_get_block(cursor);
+	page = buf_block_get_frame(block);
+	index = cursor->index;
+	zip_size = buf_block_get_zip_size(block);
+#ifdef UNIV_DEBUG_VALGRIND
+	if (zip_size) {
+		UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE);
+		UNIV_MEM_ASSERT_RW(block->page.zip.data, zip_size);
+	}
+#endif /* UNIV_DEBUG_VALGRIND */
+
+	if (!dtuple_check_typed_no_assert(entry)) {
+		fputs("InnoDB: Error in a tuple to insert into ", stderr);
+		dict_index_name_print(stderr, thr_get_trx(thr), index);
+	}
+#ifdef UNIV_DEBUG
+	if (btr_cur_print_record_ops && thr) {
+		btr_cur_trx_report(thr_get_trx(thr), index, "insert into ");
+		dtuple_print(stderr, entry);
+	}
+#endif /* UNIV_DEBUG */
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	max_size = page_get_max_insert_size_after_reorganize(page, 1);
+	leaf = page_is_leaf(page);
+
+	/* Calculate the record size when entry is converted to a record */
+	rec_size = rec_get_converted_size(index, entry, n_ext);
+
+	if (page_zip_rec_needs_ext(rec_size, page_is_comp(page),
+				   dtuple_get_n_fields(entry), zip_size)) {
+
+		/* The record is so big that we have to store some fields
+		externally on separate database pages */
+		big_rec_vec = dtuple_convert_big_rec(index, entry, &n_ext);
+
+		if (UNIV_UNLIKELY(big_rec_vec == NULL)) {
+
+			return(DB_TOO_BIG_RECORD);
+		}
+
+		rec_size = rec_get_converted_size(index, entry, n_ext);
+	}
+
+	if (UNIV_UNLIKELY(zip_size)) {
+		/* Estimate the free space of an empty compressed page.
+		Subtract one byte for the encoded heap_no in the
+		modification log. */
+		ulint	free_space_zip = page_zip_empty_size(
+			cursor->index->n_fields, zip_size) - 1;
+		ulint	n_uniq = dict_index_get_n_unique_in_tree(index);
+
+		ut_ad(dict_table_is_comp(index->table));
+
+		/* There should be enough room for two node pointer
+		records on an empty non-leaf page.  This prevents
+		infinite page splits. */
+
+		if (UNIV_LIKELY(entry->n_fields >= n_uniq)
+		    && UNIV_UNLIKELY(REC_NODE_PTR_SIZE
+				     + rec_get_converted_size_comp_prefix(
+					     index, entry->fields, n_uniq,
+					     NULL)
+				     /* On a compressed page, there is
+				     a two-byte entry in the dense
+				     page directory for every record.
+				     But there is no record header. */
+				     - (REC_N_NEW_EXTRA_BYTES - 2)
+				     > free_space_zip / 2)) {
+
+			if (big_rec_vec) {
+				dtuple_convert_back_big_rec(
+					index, entry, big_rec_vec);
+			}
+
+			if (heap) {
+				mem_heap_free(heap);
+			}
+
+			return(DB_TOO_BIG_RECORD);
+		}
+	}
+
+	/* If there have been many consecutive inserts, and we are on the leaf
+	level, check if we have to split the page to reserve enough free space
+	for future updates of records. */
+
+	if (dict_index_is_clust(index)
+	    && (page_get_n_recs(page) >= 2)
+	    && UNIV_LIKELY(leaf)
+	    && (dict_index_get_space_reserve() + rec_size > max_size)
+	    && (btr_page_get_split_rec_to_right(cursor, &dummy_rec)
+		|| btr_page_get_split_rec_to_left(cursor, &dummy_rec))) {
+fail:
+		err = DB_FAIL;
+fail_err:
+
+		if (big_rec_vec) {
+			dtuple_convert_back_big_rec(index, entry, big_rec_vec);
+		}
+
+		if (UNIV_LIKELY_NULL(heap)) {
+			mem_heap_free(heap);
+		}
+
+		return(err);
+	}
+
+	if (UNIV_UNLIKELY(max_size < BTR_CUR_PAGE_REORGANIZE_LIMIT
+	     || max_size < rec_size)
+	    && UNIV_LIKELY(page_get_n_recs(page) > 1)
+	    && page_get_max_insert_size(page, 1) < rec_size) {
+
+		goto fail;
+	}
+
+	/* Check locks and write to the undo log, if specified */
+	err = btr_cur_ins_lock_and_undo(flags, cursor, entry, thr, &inherit);
+
+	if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
+
+		goto fail_err;
+	}
+
+	page_cursor = btr_cur_get_page_cur(cursor);
+
+	/* Now, try the insert */
+
+	{
+		const rec_t* page_cursor_rec = page_cur_get_rec(page_cursor);
+		*rec = page_cur_tuple_insert(page_cursor, entry, index,
+					     n_ext, mtr);
+		reorg = page_cursor_rec != page_cur_get_rec(page_cursor);
+
+		if (UNIV_UNLIKELY(reorg)) {
+			ut_a(zip_size);
+			ut_a(*rec);
+		}
+	}
+
+	if (UNIV_UNLIKELY(!*rec) && UNIV_LIKELY(!reorg)) {
+		/* If the record did not fit, reorganize */
+		if (UNIV_UNLIKELY(!btr_page_reorganize(block, index, mtr))) {
+			ut_a(zip_size);
+
+			goto fail;
+		}
+
+		ut_ad(zip_size
+		      || page_get_max_insert_size(page, 1) == max_size);
+
+		reorg = TRUE;
+
+		page_cur_search(block, index, entry, PAGE_CUR_LE, page_cursor);
+
+		*rec = page_cur_tuple_insert(page_cursor, entry, index,
+					     n_ext, mtr);
+
+		if (UNIV_UNLIKELY(!*rec)) {
+			if (UNIV_LIKELY(zip_size != 0)) {
+
+				goto fail;
+			}
+
+			fputs("InnoDB: Error: cannot insert tuple ", stderr);
+			dtuple_print(stderr, entry);
+			fputs(" into ", stderr);
+			dict_index_name_print(stderr, thr_get_trx(thr), index);
+			fprintf(stderr, "\nInnoDB: max insert size %lu\n",
+				(ulong) max_size);
+			ut_error;
+		}
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+
+#ifdef BTR_CUR_HASH_ADAPT
+	if (!reorg && leaf && (cursor->flag == BTR_CUR_HASH)) {
+		btr_search_update_hash_node_on_insert(cursor);
+	} else {
+		btr_search_update_hash_on_insert(cursor);
+	}
+#endif
+
+	if (!(flags & BTR_NO_LOCKING_FLAG) && inherit) {
+
+		lock_update_insert(block, *rec);
+	}
+
+#if 0
+	fprintf(stderr, "Insert into page %lu, max ins size %lu,"
+		" rec %lu ind type %lu\n",
+		buf_block_get_page_no(block), max_size,
+		rec_size + PAGE_DIR_SLOT_SIZE, index->type);
+#endif
+	if (leaf
+	    && !dict_index_is_clust(index)
+	    && !dict_index_is_ibuf(index)) {
+		/* Update the free bits of the B-tree page in the
+		insert buffer bitmap. */
+
+		/* The free bits in the insert buffer bitmap must
+		never exceed the free space on a page.  It is safe to
+		decrement or reset the bits in the bitmap in a
+		mini-transaction that is committed before the
+		mini-transaction that affects the free space. */
+
+		/* It is unsafe to increment the bits in a separately
+		committed mini-transaction, because in crash recovery,
+		the free bits could momentarily be set too high. */
+
+		if (zip_size) {
+			/* Update the bits in the same mini-transaction. */
+			ibuf_update_free_bits_zip(block, mtr);
+		} else {
+			/* Decrement the bits in a separate
+			mini-transaction. */
+			ibuf_update_free_bits_if_full(
+				block, max_size,
+				rec_size + PAGE_DIR_SLOT_SIZE);
+		}
+	}
+
+	*big_rec = big_rec_vec;
+
+	return(DB_SUCCESS);
+}
+
+/*****************************************************************
+Performs an insert on a page of an index tree. It is assumed that mtr
+holds an x-latch on the tree and on the cursor page. If the insert is
+made on the leaf level, to avoid deadlocks, mtr must also own x-latches
+to brothers of page, if those brothers exist. */
+UNIV_INTERN
+ulint
+btr_cur_pessimistic_insert(
+/*=======================*/
+				/* out: DB_SUCCESS or error number */
+	ulint		flags,	/* in: undo logging and locking flags: if not
+				zero, the parameter thr should be
+				specified; if no undo logging is specified,
+				then the caller must have reserved enough
+				free extents in the file space so that the
+				insertion will certainly succeed */
+	btr_cur_t*	cursor,	/* in: cursor after which to insert;
+				cursor stays valid */
+	dtuple_t*	entry,	/* in/out: entry to insert */
+	rec_t**		rec,	/* out: pointer to inserted record if
+				succeed */
+	big_rec_t**	big_rec,/* out: big rec vector whose fields have to
+				be stored externally by the caller, or
+				NULL */
+	ulint		n_ext,	/* in: number of externally stored columns */
+	que_thr_t*	thr,	/* in: query thread or NULL */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	dict_index_t*	index		= cursor->index;
+	ulint		zip_size	= dict_table_zip_size(index->table);
+	big_rec_t*	big_rec_vec	= NULL;
+	mem_heap_t*	heap		= NULL;
+	ulint		err;
+	ibool		dummy_inh;
+	ibool		success;
+	ulint		n_extents	= 0;
+	ulint		n_reserved;
+
+	ut_ad(dtuple_check_typed(entry));
+
+	*big_rec = NULL;
+
+	ut_ad(mtr_memo_contains(mtr,
+				dict_index_get_lock(btr_cur_get_index(cursor)),
+				MTR_MEMO_X_LOCK));
+	ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
+				MTR_MEMO_PAGE_X_FIX));
+
+	/* Try first an optimistic insert; reset the cursor flag: we do not
+	assume anything of how it was positioned */
+
+	cursor->flag = BTR_CUR_BINARY;
+
+	err = btr_cur_optimistic_insert(flags, cursor, entry, rec,
+					big_rec, n_ext, thr, mtr);
+	if (err != DB_FAIL) {
+
+		return(err);
+	}
+
+	/* Retry with a pessimistic insert. Check locks and write to undo log,
+	if specified */
+
+	err = btr_cur_ins_lock_and_undo(flags, cursor, entry, thr, &dummy_inh);
+
+	if (err != DB_SUCCESS) {
+
+		return(err);
+	}
+
+	if (!(flags & BTR_NO_UNDO_LOG_FLAG)) {
+		/* First reserve enough free space for the file segments
+		of the index tree, so that the insert will not fail because
+		of lack of space */
+
+		n_extents = cursor->tree_height / 16 + 3;
+
+		success = fsp_reserve_free_extents(&n_reserved, index->space,
+						   n_extents, FSP_NORMAL, mtr);
+		if (!success) {
+			return(DB_OUT_OF_FILE_SPACE);
+		}
+	}
+
+	if (page_zip_rec_needs_ext(rec_get_converted_size(index, entry, n_ext),
+				   dict_table_is_comp(index->table),
+				   dict_index_get_n_fields(index),
+				   zip_size)) {
+		/* The record is so big that we have to store some fields
+		externally on separate database pages */
+
+		if (UNIV_LIKELY_NULL(big_rec_vec)) {
+			/* This should never happen, but we handle
+			the situation in a robust manner. */
+			ut_ad(0);
+			dtuple_convert_back_big_rec(index, entry, big_rec_vec);
+		}
+
+		big_rec_vec = dtuple_convert_big_rec(index, entry, &n_ext);
+
+		if (big_rec_vec == NULL) {
+
+			if (n_extents > 0) {
+				fil_space_release_free_extents(index->space,
+							       n_reserved);
+			}
+			return(DB_TOO_BIG_RECORD);
+		}
+	}
+
+	if (dict_index_get_page(index)
+	    == buf_block_get_page_no(btr_cur_get_block(cursor))) {
+
+		/* The page is the root page */
+		*rec = btr_root_raise_and_insert(cursor, entry, n_ext, mtr);
+	} else {
+		*rec = btr_page_split_and_insert(cursor, entry, n_ext, mtr);
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+
+	ut_ad(page_rec_get_next(btr_cur_get_rec(cursor)) == *rec);
+
+#ifdef BTR_CUR_ADAPT
+	btr_search_update_hash_on_insert(cursor);
+#endif
+	if (!(flags & BTR_NO_LOCKING_FLAG)) {
+
+		lock_update_insert(btr_cur_get_block(cursor), *rec);
+	}
+
+	if (n_extents > 0) {
+		fil_space_release_free_extents(index->space, n_reserved);
+	}
+
+	*big_rec = big_rec_vec;
+
+	return(DB_SUCCESS);
+}
+
+/*==================== B-TREE UPDATE =========================*/
+
+/*****************************************************************
+For an update, checks the locks and does the undo logging. */
+UNIV_INLINE
+ulint
+btr_cur_upd_lock_and_undo(
+/*======================*/
+				/* out: DB_SUCCESS, DB_WAIT_LOCK, or error
+				number */
+	ulint		flags,	/* in: undo logging and locking flags */
+	btr_cur_t*	cursor,	/* in: cursor on record to update */
+	const upd_t*	update,	/* in: update vector */
+	ulint		cmpl_info,/* in: compiler info on secondary index
+				updates */
+	que_thr_t*	thr,	/* in: query thread */
+	dulint*		roll_ptr)/* out: roll pointer */
+{
+	dict_index_t*	index;
+	rec_t*		rec;
+	ulint		err;
+
+	ut_ad(cursor && update && thr && roll_ptr);
+
+	rec = btr_cur_get_rec(cursor);
+	index = cursor->index;
+
+	if (!dict_index_is_clust(index)) {
+		/* We do undo logging only when we update a clustered index
+		record */
+		return(lock_sec_rec_modify_check_and_lock(
+			       flags, btr_cur_get_block(cursor), rec,
+			       index, thr));
+	}
+
+	/* Check if we have to wait for a lock: enqueue an explicit lock
+	request if yes */
+
+	err = DB_SUCCESS;
+
+	if (!(flags & BTR_NO_LOCKING_FLAG)) {
+		mem_heap_t*	heap		= NULL;
+		ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+		rec_offs_init(offsets_);
+
+		err = lock_clust_rec_modify_check_and_lock(
+			flags, btr_cur_get_block(cursor), rec, index,
+			rec_get_offsets(rec, index, offsets_,
+					ULINT_UNDEFINED, &heap), thr);
+		if (UNIV_LIKELY_NULL(heap)) {
+			mem_heap_free(heap);
+		}
+		if (err != DB_SUCCESS) {
+
+			return(err);
+		}
+	}
+
+	/* Append the info about the update in the undo log */
+
+	err = trx_undo_report_row_operation(flags, TRX_UNDO_MODIFY_OP, thr,
+					    index, NULL, update,
+					    cmpl_info, rec, roll_ptr);
+	return(err);
+}
+
+/***************************************************************
+Writes a redo log record of updating a record in-place. */
+UNIV_INLINE
+void
+btr_cur_update_in_place_log(
+/*========================*/
+	ulint		flags,		/* in: flags */
+	rec_t*		rec,		/* in: record */
+	dict_index_t*	index,		/* in: index where cursor positioned */
+	const upd_t*	update,		/* in: update vector */
+	trx_t*		trx,		/* in: transaction */
+	dulint		roll_ptr,	/* in: roll ptr */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	byte*	log_ptr;
+	page_t*	page	= page_align(rec);
+	ut_ad(flags < 256);
+	ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
+
+	log_ptr = mlog_open_and_write_index(mtr, rec, index, page_is_comp(page)
+					    ? MLOG_COMP_REC_UPDATE_IN_PLACE
+					    : MLOG_REC_UPDATE_IN_PLACE,
+					    1 + DATA_ROLL_PTR_LEN + 14 + 2
+					    + MLOG_BUF_MARGIN);
+
+	if (!log_ptr) {
+		/* Logging in mtr is switched off during crash recovery */
+		return;
+	}
+
+	/* The code below assumes index is a clustered index: change index to
+	the clustered index if we are updating a secondary index record (or we
+	could as well skip writing the sys col values to the log in this case
+	because they are not needed for a secondary index record update) */
+
+	index = dict_table_get_first_index(index->table);
+
+	mach_write_to_1(log_ptr, flags);
+	log_ptr++;
+
+	log_ptr = row_upd_write_sys_vals_to_log(index, trx, roll_ptr, log_ptr,
+						mtr);
+	mach_write_to_2(log_ptr, page_offset(rec));
+	log_ptr += 2;
+
+	row_upd_index_write_log(update, log_ptr, mtr);
+}
+
+/***************************************************************
+Parses a redo log record of updating a record in-place. */
+UNIV_INTERN
+byte*
+btr_cur_parse_update_in_place(
+/*==========================*/
+				/* out: end of log record or NULL */
+	byte*		ptr,	/* in: buffer */
+	byte*		end_ptr,/* in: buffer end */
+	page_t*		page,	/* in/out: page or NULL */
+	page_zip_des_t*	page_zip,/* in/out: compressed page, or NULL */
+	dict_index_t*	index)	/* in: index corresponding to page */
+{
+	ulint	flags;
+	rec_t*	rec;
+	upd_t*	update;
+	ulint	pos;
+	dulint	trx_id;
+	dulint	roll_ptr;
+	ulint	rec_offset;
+	mem_heap_t* heap;
+	ulint*	offsets;
+
+	if (end_ptr < ptr + 1) {
+
+		return(NULL);
+	}
+
+	flags = mach_read_from_1(ptr);
+	ptr++;
+
+	ptr = row_upd_parse_sys_vals(ptr, end_ptr, &pos, &trx_id, &roll_ptr);
+
+	if (ptr == NULL) {
+
+		return(NULL);
+	}
+
+	if (end_ptr < ptr + 2) {
+
+		return(NULL);
+	}
+
+	rec_offset = mach_read_from_2(ptr);
+	ptr += 2;
+
+	ut_a(rec_offset <= UNIV_PAGE_SIZE);
+
+	heap = mem_heap_create(256);
+
+	ptr = row_upd_index_parse(ptr, end_ptr, heap, &update);
+
+	if (!ptr || !page) {
+
+		goto func_exit;
+	}
+
+	ut_a((ibool)!!page_is_comp(page) == dict_table_is_comp(index->table));
+	rec = page + rec_offset;
+
+	/* We do not need to reserve btr_search_latch, as the page is only
+	being recovered, and there cannot be a hash index to it. */
+
+	offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
+
+	if (!(flags & BTR_KEEP_SYS_FLAG)) {
+		row_upd_rec_sys_fields_in_recovery(rec, page_zip, offsets,
+						   pos, trx_id, roll_ptr);
+	}
+
+	row_upd_rec_in_place(rec, index, offsets, update, page_zip);
+
+func_exit:
+	mem_heap_free(heap);
+
+	return(ptr);
+}
+
+/*****************************************************************
+See if there is enough place in the page modification log to log
+an update-in-place. */
+static
+ibool
+btr_cur_update_alloc_zip(
+/*=====================*/
+				/* out: TRUE if enough place */
+	page_zip_des_t*	page_zip,/* in/out: compressed page */
+	buf_block_t*	block,	/* in/out: buffer page */
+	dict_index_t*	index,	/* in: the index corresponding to the block */
+	ulint		length,	/* in: size needed */
+	mtr_t*		mtr)	/* in: mini-transaction */
+{
+	ut_a(page_zip == buf_block_get_page_zip(block));
+	ut_ad(page_zip);
+	ut_ad(!dict_index_is_ibuf(index));
+
+	if (page_zip_available(page_zip, dict_index_is_clust(index),
+			       length, 0)) {
+		return(TRUE);
+	}
+
+	if (!page_zip->m_nonempty) {
+		/* The page has been freshly compressed, so
+		recompressing it will not help. */
+		return(FALSE);
+	}
+
+	if (!page_zip_compress(page_zip, buf_block_get_frame(block),
+			       index, mtr)) {
+		/* Unable to compress the page */
+		return(FALSE);
+	}
+
+	/* After recompressing a page, we must make sure that the free
+	bits in the insert buffer bitmap will not exceed the free
+	space on the page.  Because this function will not attempt
+	recompression unless page_zip_available() fails above, it is
+	safe to reset the free bits if page_zip_available() fails
+	again, below.  The free bits can safely be reset in a separate
+	mini-transaction.  If page_zip_available() succeeds below, we
+	can be sure that the page_zip_compress() above did not reduce
+	the free space available on the page. */
+
+	if (!page_zip_available(page_zip, dict_index_is_clust(index),
+				length, 0)) {
+		/* Out of space: reset the free bits. */
+		if (!dict_index_is_clust(index)
+		    && page_is_leaf(buf_block_get_frame(block))) {
+			ibuf_reset_free_bits(block);
+		}
+		return(FALSE);
+	}
+
+	return(TRUE);
+}
+
+/*****************************************************************
+Updates a record when the update causes no size changes in its fields.
+We assume here that the ordering fields of the record do not change. */
+UNIV_INTERN
+ulint
+btr_cur_update_in_place(
+/*====================*/
+				/* out: DB_SUCCESS or error number */
+	ulint		flags,	/* in: undo logging and locking flags */
+	btr_cur_t*	cursor,	/* in: cursor on the record to update;
+				cursor stays valid and positioned on the
+				same record */
+	const upd_t*	update,	/* in: update vector */
+	ulint		cmpl_info,/* in: compiler info on secondary index
+				updates */
+	que_thr_t*	thr,	/* in: query thread */
+	mtr_t*		mtr)	/* in: mtr; must be committed before
+				latching any further pages */
+{
+	dict_index_t*	index;
+	buf_block_t*	block;
+	page_zip_des_t*	page_zip;
+	ulint		err;
+	rec_t*		rec;
+	dulint		roll_ptr	= ut_dulint_zero;
+	trx_t*		trx;
+	ulint		was_delete_marked;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	rec_offs_init(offsets_);
+
+	rec = btr_cur_get_rec(cursor);
+	index = cursor->index;
+	ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
+	/* The insert buffer tree should never be updated in place. */
+	ut_ad(!dict_index_is_ibuf(index));
+
+	trx = thr_get_trx(thr);
+	offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
+#ifdef UNIV_DEBUG
+	if (btr_cur_print_record_ops && thr) {
+		btr_cur_trx_report(trx, index, "update ");
+		rec_print_new(stderr, rec, offsets);
+	}
+#endif /* UNIV_DEBUG */
+
+	block = btr_cur_get_block(cursor);
+	page_zip = buf_block_get_page_zip(block);
+
+	/* Check that enough space is available on the compressed page. */
+	if (UNIV_LIKELY_NULL(page_zip)
+	    && !btr_cur_update_alloc_zip(page_zip, block, index,
+					 rec_offs_size(offsets), mtr)) {
+		return(DB_ZIP_OVERFLOW);
+	}
+
+	/* Do lock checking and undo logging */
+	err = btr_cur_upd_lock_and_undo(flags, cursor, update, cmpl_info,
+					thr, &roll_ptr);
+	if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
+
+		if (UNIV_LIKELY_NULL(heap)) {
+			mem_heap_free(heap);
+		}
+		return(err);
+	}
+
+	if (block->is_hashed) {
+		/* The function row_upd_changes_ord_field_binary works only
+		if the update vector was built for a clustered index, we must
+		NOT call it if index is secondary */
+
+		if (!dict_index_is_clust(index)
+		    || row_upd_changes_ord_field_binary(NULL, index, update)) {
+
+			/* Remove possible hash index pointer to this record */
+			btr_search_update_hash_on_delete(cursor);
+		}
+
+		rw_lock_x_lock(&btr_search_latch);
+	}
+
+	if (!(flags & BTR_KEEP_SYS_FLAG)) {
+		row_upd_rec_sys_fields(rec, NULL,
+				       index, offsets, trx, roll_ptr);
+	}
+
+	was_delete_marked = rec_get_deleted_flag(
+		rec, page_is_comp(buf_block_get_frame(block)));
+
+	row_upd_rec_in_place(rec, index, offsets, update, page_zip);
+
+	if (block->is_hashed) {
+		rw_lock_x_unlock(&btr_search_latch);
+	}
+
+	if (page_zip && !dict_index_is_clust(index)
+	    && page_is_leaf(buf_block_get_frame(block))) {
+		/* Update the free bits in the insert buffer. */
+		ibuf_update_free_bits_zip(block, mtr);
+	}
+
+	btr_cur_update_in_place_log(flags, rec, index, update,
+				    trx, roll_ptr, mtr);
+
+	if (was_delete_marked
+	    && !rec_get_deleted_flag(rec, page_is_comp(
+					     buf_block_get_frame(block)))) {
+		/* The new updated record owns its possible externally
+		stored fields */
+
+		btr_cur_unmark_extern_fields(page_zip,
+					     rec, index, offsets, mtr);
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+	return(DB_SUCCESS);
+}
+
+/*****************************************************************
+Tries to update a record on a page in an index tree. It is assumed that mtr
+holds an x-latch on the page. The operation does not succeed if there is too
+little space on the page or if the update would result in too empty a page,
+so that tree compression is recommended. We assume here that the ordering
+fields of the record do not change. */
+UNIV_INTERN
+ulint
+btr_cur_optimistic_update(
+/*======================*/
+				/* out: DB_SUCCESS, or DB_OVERFLOW if the
+				updated record does not fit, DB_UNDERFLOW
+				if the page would become too empty, or
+				DB_ZIP_OVERFLOW if there is not enough
+				space left on the compressed page */
+	ulint		flags,	/* in: undo logging and locking flags */
+	btr_cur_t*	cursor,	/* in: cursor on the record to update;
+				cursor stays valid and positioned on the
+				same record */
+	const upd_t*	update,	/* in: update vector; this must also
+				contain trx id and roll ptr fields */
+	ulint		cmpl_info,/* in: compiler info on secondary index
+				updates */
+	que_thr_t*	thr,	/* in: query thread */
+	mtr_t*		mtr)	/* in: mtr; must be committed before
+				latching any further pages */
+{
+	dict_index_t*	index;
+	page_cur_t*	page_cursor;
+	ulint		err;
+	buf_block_t*	block;
+	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;
+	dtuple_t*	new_entry;
+	dulint		roll_ptr;
+	trx_t*		trx;
+	mem_heap_t*	heap;
+	ulint		i;
+	ulint		n_ext;
+	ulint*		offsets;
+
+	block = btr_cur_get_block(cursor);
+	page = buf_block_get_frame(block);
+	orig_rec = 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));
+	/* The insert buffer tree should never be updated in place. */
+	ut_ad(!dict_index_is_ibuf(index));
+
+	heap = mem_heap_create(1024);
+	offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
+
+#ifdef UNIV_DEBUG
+	if (btr_cur_print_record_ops && thr) {
+		btr_cur_trx_report(thr_get_trx(thr), index, "update ");
+		rec_print_new(stderr, rec, offsets);
+	}
+#endif /* UNIV_DEBUG */
+
+	if (!row_upd_changes_field_size_or_external(index, offsets, update)) {
+
+		/* The simplest and the most common case: the update does not
+		change the size of any field and none of the updated fields is
+		externally stored in rec or update, and there is enough space
+		on the compressed page to log the update. */
+
+		mem_heap_free(heap);
+		return(btr_cur_update_in_place(flags, cursor, update,
+					       cmpl_info, thr, mtr));
+	}
+
+	if (rec_offs_any_extern(offsets)) {
+any_extern:
+		/* Externally stored fields are treated in pessimistic
+		update */
+
+		mem_heap_free(heap);
+		return(DB_OVERFLOW);
+	}
+
+	for (i = 0; i < upd_get_n_fields(update); i++) {
+		if (dfield_is_ext(&upd_get_nth_field(update, i)->new_val)) {
+
+			goto any_extern;
+		}
+	}
+
+	page_cursor = btr_cur_get_page_cur(cursor);
+
+	new_entry = row_rec_to_index_entry(ROW_COPY_DATA, rec, index, offsets,
+					   &n_ext, heap);
+	/* We checked above that there are no externally stored fields. */
+	ut_a(!n_ext);
+
+	/* The page containing the clustered index record
+	corresponding to new_entry is latched in mtr.
+	Thus the following call is safe. */
+	row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update,
+						     FALSE, heap);
+	old_rec_size = rec_offs_size(offsets);
+	new_rec_size = rec_get_converted_size(index, new_entry, 0);
+
+	page_zip = buf_block_get_page_zip(block);
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+
+	if (UNIV_LIKELY_NULL(page_zip)
+	    && !btr_cur_update_alloc_zip(page_zip, block, index,
+					 new_rec_size, mtr)) {
+		err = DB_ZIP_OVERFLOW;
+		goto err_exit;
+	}
+
+	if (UNIV_UNLIKELY(new_rec_size
+			  >= (page_get_free_space_of_empty(page_is_comp(page))
+			      / 2))) {
+
+		err = DB_OVERFLOW;
+		goto err_exit;
+	}
+
+	if (UNIV_UNLIKELY(page_get_data_size(page)
+			  - old_rec_size + new_rec_size
+			  < BTR_CUR_PAGE_COMPRESS_LIMIT)) {
+
+		/* The page would become too empty */
+
+		err = DB_UNDERFLOW;
+		goto err_exit;
+	}
+
+	max_size = old_rec_size
+		+ page_get_max_insert_size_after_reorganize(page, 1);
+
+	if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)
+	       && (max_size >= new_rec_size))
+	      || (page_get_n_recs(page) <= 1))) {
+
+		/* There was not enough space, or it did not pay to
+		reorganize: for simplicity, we decide what to do assuming a
+		reorganization is needed, though it might not be necessary */
+
+		err = DB_OVERFLOW;
+		goto err_exit;
+	}
+
+	/* Do lock checking and undo logging */
+	err = btr_cur_upd_lock_and_undo(flags, cursor, update, cmpl_info, thr,
+					&roll_ptr);
+	if (err != DB_SUCCESS) {
+err_exit:
+		mem_heap_free(heap);
+		return(err);
+	}
+
+	/* Ok, we may do the replacement. Store on the page infimum the
+	explicit locks on rec, before deleting rec (see the comment in
+	btr_cur_pessimistic_update). */
+
+	lock_rec_store_on_page_infimum(block, rec);
+
+	btr_search_update_hash_on_delete(cursor);
+
+	/* The call to row_rec_to_index_entry(ROW_COPY_DATA, ...) above
+	invokes rec_offs_make_valid() to point to the copied record that
+	the fields of new_entry point to.  We have to undo it here. */
+	ut_ad(rec_offs_validate(NULL, index, offsets));
+	rec_offs_make_valid(page_cur_get_rec(page_cursor), index, offsets);
+
+	page_cur_delete_rec(page_cursor, index, offsets, mtr);
+
+	page_cur_move_to_prev(page_cursor);
+
+	trx = thr_get_trx(thr);
+
+	if (!(flags & BTR_KEEP_SYS_FLAG)) {
+		row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
+					      roll_ptr);
+		row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID,
+					      trx->id);
+	}
+
+	/* There are no externally stored columns in new_entry */
+	rec = btr_cur_insert_if_possible(cursor, new_entry, 0/*n_ext*/, mtr);
+	ut_a(rec); /* <- We calculated above the insert would fit */
+
+	if (page_zip && !dict_index_is_clust(index)
+	    && page_is_leaf(page)) {
+		/* Update the free bits in the insert buffer. */
+		ibuf_update_free_bits_zip(block, mtr);
+	}
+
+	/* Restore the old explicit lock state on the record */
+
+	lock_rec_restore_from_page_infimum(block, rec, block);
+
+	page_cur_move_to_next(page_cursor);
+
+	mem_heap_free(heap);
+
+	return(DB_SUCCESS);
+}
+
+/*****************************************************************
+If, in a split, a new supremum record was created as the predecessor of the
+updated record, the supremum record must inherit exactly the locks on the
+updated record. In the split it may have inherited locks from the successor
+of the updated record, which is not correct. This function restores the
+right locks for the new supremum. */
+static
+void
+btr_cur_pess_upd_restore_supremum(
+/*==============================*/
+	buf_block_t*	block,	/* in: buffer block of rec */
+	const rec_t*	rec,	/* in: updated record */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	page_t*		page;
+	buf_block_t*	prev_block;
+	ulint		space;
+	ulint		zip_size;
+	ulint		prev_page_no;
+
+	page = buf_block_get_frame(block);
+
+	if (page_rec_get_next(page_get_infimum_rec(page)) != rec) {
+		/* Updated record is not the first user record on its page */
+
+		return;
+	}
+
+	space = buf_block_get_space(block);
+	zip_size = buf_block_get_zip_size(block);
+	prev_page_no = btr_page_get_prev(page, mtr);
+
+	ut_ad(prev_page_no != FIL_NULL);
+	prev_block = buf_page_get_with_no_latch(space, zip_size,
+						prev_page_no, mtr);
+#ifdef UNIV_BTR_DEBUG
+	ut_a(btr_page_get_next(prev_block->frame, mtr)
+	     == page_get_page_no(page));
+#endif /* UNIV_BTR_DEBUG */
+
+	/* We must already have an x-latch on prev_block! */
+	ut_ad(mtr_memo_contains(mtr, prev_block, MTR_MEMO_PAGE_X_FIX));
+
+	lock_rec_reset_and_inherit_gap_locks(prev_block, block,
+					     PAGE_HEAP_NO_SUPREMUM,
+					     page_rec_get_heap_no(rec));
+}
+
+/*****************************************************************
+Performs an update of a record on a page of a tree. It is assumed
+that mtr holds an x-latch on the tree and on the cursor page. If the
+update is made on the leaf level, to avoid deadlocks, mtr must also
+own x-latches to brothers of page, if those brothers exist. We assume
+here that the ordering fields of the record do not change. */
+UNIV_INTERN
+ulint
+btr_cur_pessimistic_update(
+/*=======================*/
+				/* out: DB_SUCCESS or error code */
+	ulint		flags,	/* in: undo logging, locking, and rollback
+				flags */
+	btr_cur_t*	cursor,	/* in: cursor on the record to update */
+	mem_heap_t**	heap,	/* in/out: pointer to memory heap, or NULL */
+	big_rec_t**	big_rec,/* out: big rec vector whose fields have to
+				be stored externally by the caller, or NULL */
+	const upd_t*	update,	/* in: update vector; this is allowed also
+				contain trx id and roll ptr fields, but
+				the values in update vector have no effect */
+	ulint		cmpl_info,/* in: compiler info on secondary index
+				updates */
+	que_thr_t*	thr,	/* in: query thread */
+	mtr_t*		mtr)	/* in: mtr; must be committed before
+				latching any further pages */
+{
+	big_rec_t*	big_rec_vec	= NULL;
+	big_rec_t*	dummy_big_rec;
+	dict_index_t*	index;
+	buf_block_t*	block;
+	page_t*		page;
+	page_zip_des_t*	page_zip;
+	rec_t*		rec;
+	page_cur_t*	page_cursor;
+	dtuple_t*	new_entry;
+	ulint		err;
+	ulint		optim_err;
+	dulint		roll_ptr;
+	trx_t*		trx;
+	ibool		was_first;
+	ulint		n_extents	= 0;
+	ulint		n_reserved;
+	ulint		n_ext;
+	ulint*		offsets		= NULL;
+
+	*big_rec = NULL;
+
+	block = btr_cur_get_block(cursor);
+	page = buf_block_get_frame(block);
+	page_zip = buf_block_get_page_zip(block);
+	rec = btr_cur_get_rec(cursor);
+	index = cursor->index;
+
+	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));
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+	/* The insert buffer tree should never be updated in place. */
+	ut_ad(!dict_index_is_ibuf(index));
+
+	optim_err = btr_cur_optimistic_update(flags, cursor, update,
+					      cmpl_info, thr, mtr);
+
+	switch (optim_err) {
+	case DB_UNDERFLOW:
+	case DB_OVERFLOW:
+	case DB_ZIP_OVERFLOW:
+		break;
+	default:
+		return(optim_err);
+	}
+
+	/* Do lock checking and undo logging */
+	err = btr_cur_upd_lock_and_undo(flags, cursor, update, cmpl_info,
+					thr, &roll_ptr);
+	if (err != DB_SUCCESS) {
+
+		return(err);
+	}
+
+	if (optim_err == DB_OVERFLOW) {
+		ulint	reserve_flag;
+
+		/* First reserve enough free space for the file segments
+		of the index tree, so that the update will not fail because
+		of lack of space */
+
+		n_extents = cursor->tree_height / 16 + 3;
+
+		if (flags & BTR_NO_UNDO_LOG_FLAG) {
+			reserve_flag = FSP_CLEANING;
+		} else {
+			reserve_flag = FSP_NORMAL;
+		}
+
+		if (!fsp_reserve_free_extents(&n_reserved, index->space,
+					      n_extents, reserve_flag, mtr)) {
+			return(DB_OUT_OF_FILE_SPACE);
+		}
+	}
+
+	if (!*heap) {
+		*heap = mem_heap_create(1024);
+	}
+	offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, heap);
+
+	trx = thr_get_trx(thr);
+
+	new_entry = row_rec_to_index_entry(ROW_COPY_DATA, rec, index, offsets,
+					   &n_ext, *heap);
+	/* The call to row_rec_to_index_entry(ROW_COPY_DATA, ...) above
+	invokes rec_offs_make_valid() to point to the copied record that
+	the fields of new_entry point to.  We have to undo it here. */
+	ut_ad(rec_offs_validate(NULL, index, offsets));
+	rec_offs_make_valid(rec, index, offsets);
+
+	/* The page containing the clustered index record
+	corresponding to new_entry is latched in mtr.  If the
+	clustered index record is delete-marked, then its externally
+	stored fields cannot have been purged yet, because then the
+	purge would also have removed the clustered index record
+	itself.  Thus the following call is safe. */
+	row_upd_index_replace_new_col_vals_index_pos(new_entry, index, update,
+						     FALSE, *heap);
+	if (!(flags & BTR_KEEP_SYS_FLAG)) {
+		row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
+					      roll_ptr);
+		row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID,
+					      trx->id);
+	}
+
+	if ((flags & BTR_NO_UNDO_LOG_FLAG) && rec_offs_any_extern(offsets)) {
+		/* We are in a transaction rollback undoing a row
+		update: we must free possible externally stored fields
+		which got new values in the update, if they are not
+		inherited values. They can be inherited if we have
+		updated the primary key to another value, and then
+		update it back again. */
+
+		ut_ad(big_rec_vec == NULL);
+
+		btr_rec_free_updated_extern_fields(
+			index, rec, page_zip, offsets, update,
+			trx_is_recv(trx) ? RB_RECOVERY : RB_NORMAL, mtr);
+	}
+
+	/* We have to set appropriate extern storage bits in the new
+	record to be inserted: we have to remember which fields were such */
+
+	ut_ad(!page_is_comp(page) || !rec_get_node_ptr_flag(rec));
+	offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, heap);
+	n_ext += btr_push_update_extern_fields(new_entry, update, *heap);
+
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		ut_ad(page_is_comp(page));
+		if (page_zip_rec_needs_ext(
+			    rec_get_converted_size(index, new_entry, n_ext),
+			    TRUE,
+			    dict_index_get_n_fields(index),
+			    page_zip_get_size(page_zip))) {
+
+			goto make_external;
+		}
+	} else if (page_zip_rec_needs_ext(
+			   rec_get_converted_size(index, new_entry, n_ext),
+			   page_is_comp(page), 0, 0)) {
+make_external:
+		big_rec_vec = dtuple_convert_big_rec(index, new_entry, &n_ext);
+		if (UNIV_UNLIKELY(big_rec_vec == NULL)) {
+
+			err = DB_TOO_BIG_RECORD;
+			goto return_after_reservations;
+		}
+	}
+
+	/* Store state of explicit locks on rec on the page infimum record,
+	before deleting rec. The page infimum acts as a dummy carrier of the
+	locks, taking care also of lock releases, before we can move the locks
+	back on the actual record. There is a special case: if we are
+	inserting on the root page and the insert causes a call of
+	btr_root_raise_and_insert. Therefore we cannot in the lock system
+	delete the lock structs set on the root page even if the root
+	page carries just node pointers. */
+
+	lock_rec_store_on_page_infimum(block, rec);
+
+	btr_search_update_hash_on_delete(cursor);
+
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+	page_cursor = btr_cur_get_page_cur(cursor);
+
+	page_cur_delete_rec(page_cursor, index, offsets, mtr);
+
+	page_cur_move_to_prev(page_cursor);
+
+	rec = btr_cur_insert_if_possible(cursor, new_entry, n_ext, mtr);
+
+	if (rec) {
+		lock_rec_restore_from_page_infimum(btr_cur_get_block(cursor),
+						   rec, block);
+
+		offsets = rec_get_offsets(rec, index, offsets,
+					  ULINT_UNDEFINED, heap);
+
+		if (!rec_get_deleted_flag(rec, rec_offs_comp(offsets))) {
+			/* The new inserted record owns its possible externally
+			stored fields */
+			btr_cur_unmark_extern_fields(page_zip,
+						     rec, index, offsets, mtr);
+		}
+
+		btr_cur_compress_if_useful(cursor, mtr);
+
+		if (page_zip && !dict_index_is_clust(index)
+		    && page_is_leaf(page)) {
+			/* Update the free bits in the insert buffer. */
+			ibuf_update_free_bits_zip(block, mtr);
+		}
+
+		err = DB_SUCCESS;
+		goto return_after_reservations;
+	} else {
+		ut_a(optim_err != DB_UNDERFLOW);
+
+		/* Out of space: reset the free bits. */
+		if (!dict_index_is_clust(index)
+		    && page_is_leaf(page)) {
+			ibuf_reset_free_bits(block);
+		}
+	}
+
+	/* Was the record to be updated positioned as the first user
+	record on its page? */
+	was_first = page_cur_is_before_first(page_cursor);
+
+	/* The first parameter means that no lock checking and undo logging
+	is made in the insert */
+
+	err = btr_cur_pessimistic_insert(BTR_NO_UNDO_LOG_FLAG
+					 | BTR_NO_LOCKING_FLAG
+					 | BTR_KEEP_SYS_FLAG,
+					 cursor, new_entry, &rec,
+					 &dummy_big_rec, n_ext, NULL, mtr);
+	ut_a(rec);
+	ut_a(err == DB_SUCCESS);
+	ut_a(dummy_big_rec == NULL);
+
+	if (!rec_get_deleted_flag(rec, rec_offs_comp(offsets))) {
+		/* The new inserted record owns its possible externally
+		stored fields */
+		buf_block_t*	rec_block = btr_cur_get_block(cursor);
+
+#ifdef UNIV_ZIP_DEBUG
+		ut_a(!page_zip || page_zip_validate(page_zip, page));
+		page = buf_block_get_frame(rec_block);
+#endif /* UNIV_ZIP_DEBUG */
+		page_zip = buf_block_get_page_zip(rec_block);
+
+		offsets = rec_get_offsets(rec, index, offsets,
+					  ULINT_UNDEFINED, heap);
+		btr_cur_unmark_extern_fields(page_zip,
+					     rec, index, offsets, mtr);
+	}
+
+	lock_rec_restore_from_page_infimum(btr_cur_get_block(cursor),
+					   rec, block);
+
+	/* If necessary, restore also the correct lock state for a new,
+	preceding supremum record created in a page split. While the old
+	record was nonexistent, the supremum might have inherited its locks
+	from a wrong record. */
+
+	if (!was_first) {
+		btr_cur_pess_upd_restore_supremum(btr_cur_get_block(cursor),
+						  rec, mtr);
+	}
+
+return_after_reservations:
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+
+	if (n_extents > 0) {
+		fil_space_release_free_extents(index->space, n_reserved);
+	}
+
+	*big_rec = big_rec_vec;
+
+	return(err);
+}
+
+/*==================== B-TREE DELETE MARK AND UNMARK ===============*/
+
+/********************************************************************
+Writes the redo log record for delete marking or unmarking of an index
+record. */
+UNIV_INLINE
+void
+btr_cur_del_mark_set_clust_rec_log(
+/*===============================*/
+	ulint		flags,	/* in: flags */
+	rec_t*		rec,	/* in: record */
+	dict_index_t*	index,	/* in: index of the record */
+	ibool		val,	/* in: value to set */
+	trx_t*		trx,	/* in: deleting transaction */
+	dulint		roll_ptr,/* in: roll ptr to the undo log record */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	byte*	log_ptr;
+	ut_ad(flags < 256);
+	ut_ad(val <= 1);
+
+	ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
+
+	log_ptr = mlog_open_and_write_index(mtr, rec, index,
+					    page_rec_is_comp(rec)
+					    ? MLOG_COMP_REC_CLUST_DELETE_MARK
+					    : MLOG_REC_CLUST_DELETE_MARK,
+					    1 + 1 + DATA_ROLL_PTR_LEN
+					    + 14 + 2);
+
+	if (!log_ptr) {
+		/* Logging in mtr is switched off during crash recovery */
+		return;
+	}
+
+	mach_write_to_1(log_ptr, flags);
+	log_ptr++;
+	mach_write_to_1(log_ptr, val);
+	log_ptr++;
+
+	log_ptr = row_upd_write_sys_vals_to_log(index, trx, roll_ptr, log_ptr,
+						mtr);
+	mach_write_to_2(log_ptr, page_offset(rec));
+	log_ptr += 2;
+
+	mlog_close(mtr, log_ptr);
+}
+
+/********************************************************************
+Parses the redo log record for delete marking or unmarking of a clustered
+index record. */
+UNIV_INTERN
+byte*
+btr_cur_parse_del_mark_set_clust_rec(
+/*=================================*/
+				/* out: end of log record or NULL */
+	byte*		ptr,	/* in: buffer */
+	byte*		end_ptr,/* in: buffer end */
+	page_t*		page,	/* in/out: page or NULL */
+	page_zip_des_t*	page_zip,/* in/out: compressed page, or NULL */
+	dict_index_t*	index)	/* in: index corresponding to page */
+{
+	ulint	flags;
+	ulint	val;
+	ulint	pos;
+	dulint	trx_id;
+	dulint	roll_ptr;
+	ulint	offset;
+	rec_t*	rec;
+
+	ut_ad(!page
+	      || !!page_is_comp(page) == dict_table_is_comp(index->table));
+
+	if (end_ptr < ptr + 2) {
+
+		return(NULL);
+	}
+
+	flags = mach_read_from_1(ptr);
+	ptr++;
+	val = mach_read_from_1(ptr);
+	ptr++;
+
+	ptr = row_upd_parse_sys_vals(ptr, end_ptr, &pos, &trx_id, &roll_ptr);
+
+	if (ptr == NULL) {
+
+		return(NULL);
+	}
+
+	if (end_ptr < ptr + 2) {
+
+		return(NULL);
+	}
+
+	offset = mach_read_from_2(ptr);
+	ptr += 2;
+
+	ut_a(offset <= UNIV_PAGE_SIZE);
+
+	if (page) {
+		rec = page + offset;
+
+		/* We do not need to reserve btr_search_latch, as the page
+		is only being recovered, and there cannot be a hash index to
+		it. */
+
+		btr_rec_set_deleted_flag(rec, page_zip, val);
+
+		if (!(flags & BTR_KEEP_SYS_FLAG)) {
+			mem_heap_t*	heap		= NULL;
+			ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+			rec_offs_init(offsets_);
+
+			row_upd_rec_sys_fields_in_recovery(
+				rec, page_zip,
+				rec_get_offsets(rec, index, offsets_,
+						ULINT_UNDEFINED, &heap),
+				pos, trx_id, roll_ptr);
+			if (UNIV_LIKELY_NULL(heap)) {
+				mem_heap_free(heap);
+			}
+		}
+	}
+
+	return(ptr);
+}
+
+/***************************************************************
+Marks a clustered index record deleted. Writes an undo log record to
+undo log on this delete marking. Writes in the trx id field the id
+of the deleting transaction, and in the roll ptr field pointer to the
+undo log record created. */
+UNIV_INTERN
+ulint
+btr_cur_del_mark_set_clust_rec(
+/*===========================*/
+				/* out: DB_SUCCESS, DB_LOCK_WAIT, or error
+				number */
+	ulint		flags,	/* in: undo logging and locking flags */
+	btr_cur_t*	cursor,	/* in: cursor */
+	ibool		val,	/* in: value to set */
+	que_thr_t*	thr,	/* in: query thread */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	dict_index_t*	index;
+	buf_block_t*	block;
+	dulint		roll_ptr;
+	ulint		err;
+	rec_t*		rec;
+	page_zip_des_t*	page_zip;
+	trx_t*		trx;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	rec_offs_init(offsets_);
+
+	rec = btr_cur_get_rec(cursor);
+	index = cursor->index;
+	ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
+	offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
+
+#ifdef UNIV_DEBUG
+	if (btr_cur_print_record_ops && thr) {
+		btr_cur_trx_report(thr_get_trx(thr), index, "del mark ");
+		rec_print_new(stderr, rec, offsets);
+	}
+#endif /* UNIV_DEBUG */
+
+	ut_ad(dict_index_is_clust(index));
+	ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
+
+	err = lock_clust_rec_modify_check_and_lock(flags,
+						   btr_cur_get_block(cursor),
+						   rec, index, offsets, thr);
+
+	if (err != DB_SUCCESS) {
+
+		goto func_exit;
+	}
+
+	err = trx_undo_report_row_operation(flags, TRX_UNDO_MODIFY_OP, thr,
+					    index, NULL, NULL, 0, rec,
+					    &roll_ptr);
+	if (err != DB_SUCCESS) {
+
+		goto func_exit;
+	}
+
+	block = btr_cur_get_block(cursor);
+
+	if (block->is_hashed) {
+		rw_lock_x_lock(&btr_search_latch);
+	}
+
+	page_zip = buf_block_get_page_zip(block);
+
+	btr_rec_set_deleted_flag(rec, page_zip, val);
+
+	trx = thr_get_trx(thr);
+
+	if (!(flags & BTR_KEEP_SYS_FLAG)) {
+		row_upd_rec_sys_fields(rec, page_zip,
+				       index, offsets, trx, roll_ptr);
+	}
+
+	if (block->is_hashed) {
+		rw_lock_x_unlock(&btr_search_latch);
+	}
+
+	btr_cur_del_mark_set_clust_rec_log(flags, rec, index, val, trx,
+					   roll_ptr, mtr);
+
+func_exit:
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+	return(err);
+}
+
+/********************************************************************
+Writes the redo log record for a delete mark setting of a secondary
+index record. */
+UNIV_INLINE
+void
+btr_cur_del_mark_set_sec_rec_log(
+/*=============================*/
+	rec_t*		rec,	/* in: record */
+	ibool		val,	/* in: value to set */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	byte*	log_ptr;
+	ut_ad(val <= 1);
+
+	log_ptr = mlog_open(mtr, 11 + 1 + 2);
+
+	if (!log_ptr) {
+		/* Logging in mtr is switched off during crash recovery:
+		in that case mlog_open returns NULL */
+		return;
+	}
+
+	log_ptr = mlog_write_initial_log_record_fast(
+		rec, MLOG_REC_SEC_DELETE_MARK, log_ptr, mtr);
+	mach_write_to_1(log_ptr, val);
+	log_ptr++;
+
+	mach_write_to_2(log_ptr, page_offset(rec));
+	log_ptr += 2;
+
+	mlog_close(mtr, log_ptr);
+}
+
+/********************************************************************
+Parses the redo log record for delete marking or unmarking of a secondary
+index record. */
+UNIV_INTERN
+byte*
+btr_cur_parse_del_mark_set_sec_rec(
+/*===============================*/
+				/* out: end of log record or NULL */
+	byte*		ptr,	/* in: buffer */
+	byte*		end_ptr,/* in: buffer end */
+	page_t*		page,	/* in/out: page or NULL */
+	page_zip_des_t*	page_zip)/* in/out: compressed page, or NULL */
+{
+	ulint	val;
+	ulint	offset;
+	rec_t*	rec;
+
+	if (end_ptr < ptr + 3) {
+
+		return(NULL);
+	}
+
+	val = mach_read_from_1(ptr);
+	ptr++;
+
+	offset = mach_read_from_2(ptr);
+	ptr += 2;
+
+	ut_a(offset <= UNIV_PAGE_SIZE);
+
+	if (page) {
+		rec = page + offset;
+
+		/* We do not need to reserve btr_search_latch, as the page
+		is only being recovered, and there cannot be a hash index to
+		it. */
+
+		btr_rec_set_deleted_flag(rec, page_zip, val);
+	}
+
+	return(ptr);
+}
+
+/***************************************************************
+Sets a secondary index record delete mark to TRUE or FALSE. */
+UNIV_INTERN
+ulint
+btr_cur_del_mark_set_sec_rec(
+/*=========================*/
+				/* out: DB_SUCCESS, DB_LOCK_WAIT, or error
+				number */
+	ulint		flags,	/* in: locking flag */
+	btr_cur_t*	cursor,	/* in: cursor */
+	ibool		val,	/* in: value to set */
+	que_thr_t*	thr,	/* in: query thread */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	buf_block_t*	block;
+	rec_t*		rec;
+	ulint		err;
+
+	block = btr_cur_get_block(cursor);
+	rec = btr_cur_get_rec(cursor);
+
+#ifdef UNIV_DEBUG
+	if (btr_cur_print_record_ops && thr) {
+		btr_cur_trx_report(thr_get_trx(thr), cursor->index,
+				   "del mark ");
+		rec_print(stderr, rec, cursor->index);
+	}
+#endif /* UNIV_DEBUG */
+
+	err = lock_sec_rec_modify_check_and_lock(flags,
+						 btr_cur_get_block(cursor),
+						 rec, cursor->index, thr);
+	if (err != DB_SUCCESS) {
+
+		return(err);
+	}
+
+	ut_ad(!!page_rec_is_comp(rec)
+	      == dict_table_is_comp(cursor->index->table));
+
+	if (block->is_hashed) {
+		rw_lock_x_lock(&btr_search_latch);
+	}
+
+	btr_rec_set_deleted_flag(rec, buf_block_get_page_zip(block), val);
+
+	if (block->is_hashed) {
+		rw_lock_x_unlock(&btr_search_latch);
+	}
+
+	btr_cur_del_mark_set_sec_rec_log(rec, val, mtr);
+
+	return(DB_SUCCESS);
+}
+
+/***************************************************************
+Clear a secondary index record's delete mark.  This function is only
+used by the insert buffer insert merge mechanism. */
+UNIV_INTERN
+void
+btr_cur_del_unmark_for_ibuf(
+/*========================*/
+	rec_t*		rec,		/* in/out: record to delete unmark */
+	page_zip_des_t*	page_zip,	/* in/out: compressed page
+					corresponding to rec, or NULL
+					when the tablespace is
+					uncompressed */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	/* We do not need to reserve btr_search_latch, as the page has just
+	been read to the buffer pool and there cannot be a hash index to it. */
+
+	btr_rec_set_deleted_flag(rec, page_zip, FALSE);
+
+	btr_cur_del_mark_set_sec_rec_log(rec, FALSE, mtr);
+}
+
+/*==================== B-TREE RECORD REMOVE =========================*/
+
+/*****************************************************************
+Tries to compress a page of the tree if it seems useful. It is assumed
+that mtr holds an x-latch on the tree and on the cursor page. To avoid
+deadlocks, mtr must also own x-latches to brothers of page, if those
+brothers exist. NOTE: it is assumed that the caller has reserved enough
+free extents so that the compression will always succeed if done! */
+UNIV_INTERN
+ibool
+btr_cur_compress_if_useful(
+/*=======================*/
+				/* out: TRUE if compression occurred */
+	btr_cur_t*	cursor,	/* in: cursor on the page to compress;
+				cursor does not stay valid if compression
+				occurs */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ut_ad(mtr_memo_contains(mtr,
+				dict_index_get_lock(btr_cur_get_index(cursor)),
+				MTR_MEMO_X_LOCK));
+	ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
+				MTR_MEMO_PAGE_X_FIX));
+
+	return(btr_cur_compress_recommendation(cursor, mtr)
+	       && btr_compress(cursor, mtr));
+}
+
+/***********************************************************
+Removes the record on which the tree cursor is positioned on a leaf page.
+It is assumed that the mtr has an x-latch on the page where the cursor is
+positioned, but no latch on the whole tree. */
+UNIV_INTERN
+ibool
+btr_cur_optimistic_delete(
+/*======================*/
+				/* out: TRUE if success, i.e., the page
+				did not become too empty */
+	btr_cur_t*	cursor,	/* in: cursor on leaf page, on the record to
+				delete; cursor stays valid: if deletion
+				succeeds, on function exit it points to the
+				successor of the deleted record */
+	mtr_t*		mtr)	/* in: mtr; if this function returns
+				TRUE on a leaf page of a secondary
+				index, the mtr must be committed
+				before latching any further pages */
+{
+	buf_block_t*	block;
+	rec_t*		rec;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	ibool		no_compress_needed;
+	rec_offs_init(offsets_);
+
+	ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
+				MTR_MEMO_PAGE_X_FIX));
+	/* This is intended only for leaf page deletions */
+
+	block = btr_cur_get_block(cursor);
+
+	ut_ad(page_is_leaf(buf_block_get_frame(block)));
+
+	rec = btr_cur_get_rec(cursor);
+	offsets = rec_get_offsets(rec, cursor->index, offsets,
+				  ULINT_UNDEFINED, &heap);
+
+	no_compress_needed = !rec_offs_any_extern(offsets)
+		&& btr_cur_can_delete_without_compress(
+			cursor, rec_offs_size(offsets), mtr);
+
+	if (no_compress_needed) {
+
+		page_t*		page	= buf_block_get_frame(block);
+		page_zip_des_t*	page_zip= buf_block_get_page_zip(block);
+		ulint		max_ins	= 0;
+
+		lock_update_delete(block, rec);
+
+		btr_search_update_hash_on_delete(cursor);
+
+		if (!page_zip) {
+			max_ins = page_get_max_insert_size_after_reorganize(
+				page, 1);
+		}
+#ifdef UNIV_ZIP_DEBUG
+		ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+		page_cur_delete_rec(btr_cur_get_page_cur(cursor),
+				    cursor->index, offsets, mtr);
+#ifdef UNIV_ZIP_DEBUG
+		ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+
+		if (dict_index_is_clust(cursor->index)
+		    || dict_index_is_ibuf(cursor->index)
+		    || !page_is_leaf(page)) {
+			/* The insert buffer does not handle
+			inserts to clustered indexes, to
+			non-leaf pages of secondary index B-trees,
+			or to the insert buffer. */
+		} else if (page_zip) {
+			ibuf_update_free_bits_zip(block, mtr);
+		} else {
+			ibuf_update_free_bits_low(block, max_ins, mtr);
+		}
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+
+	return(no_compress_needed);
+}
+
+/*****************************************************************
+Removes the record on which the tree cursor is positioned. Tries
+to compress the page if its fillfactor drops below a threshold
+or if it is the only page on the level. It is assumed that mtr holds
+an x-latch on the tree and on the cursor page. To avoid deadlocks,
+mtr must also own x-latches to brothers of page, if those brothers
+exist. */
+UNIV_INTERN
+ibool
+btr_cur_pessimistic_delete(
+/*=======================*/
+				/* out: TRUE if compression occurred */
+	ulint*		err,	/* out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE;
+				the latter may occur because we may have
+				to update node pointers on upper levels,
+				and in the case of variable length keys
+				these may actually grow in size */
+	ibool		has_reserved_extents, /* in: TRUE if the
+				caller has already reserved enough free
+				extents so that he knows that the operation
+				will succeed */
+	btr_cur_t*	cursor,	/* in: cursor on the record to delete;
+				if compression does not occur, the cursor
+				stays valid: it points to successor of
+				deleted record on function exit */
+	enum trx_rb_ctx	rb_ctx,	/* in: rollback context */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	buf_block_t*	block;
+	page_t*		page;
+	page_zip_des_t*	page_zip;
+	dict_index_t*	index;
+	rec_t*		rec;
+	dtuple_t*	node_ptr;
+	ulint		n_extents	= 0;
+	ulint		n_reserved;
+	ibool		success;
+	ibool		ret		= FALSE;
+	ulint		level;
+	mem_heap_t*	heap;
+	ulint*		offsets;
+
+	block = btr_cur_get_block(cursor);
+	page = buf_block_get_frame(block);
+	index = btr_cur_get_index(cursor);
+
+	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));
+	if (!has_reserved_extents) {
+		/* First reserve enough free space for the file segments
+		of the index tree, so that the node pointer updates will
+		not fail because of lack of space */
+
+		n_extents = cursor->tree_height / 32 + 1;
+
+		success = fsp_reserve_free_extents(&n_reserved,
+						   index->space,
+						   n_extents,
+						   FSP_CLEANING, mtr);
+		if (!success) {
+			*err = DB_OUT_OF_FILE_SPACE;
+
+			return(FALSE);
+		}
+	}
+
+	heap = mem_heap_create(1024);
+	rec = btr_cur_get_rec(cursor);
+	page_zip = buf_block_get_page_zip(block);
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+
+	offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
+
+	if (rec_offs_any_extern(offsets)) {
+		btr_rec_free_externally_stored_fields(index,
+						      rec, offsets, page_zip,
+						      rb_ctx, mtr);
+#ifdef UNIV_ZIP_DEBUG
+		ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+	}
+
+	if (UNIV_UNLIKELY(page_get_n_recs(page) < 2)
+	    && UNIV_UNLIKELY(dict_index_get_page(index)
+			     != buf_block_get_page_no(block))) {
+
+		/* If there is only one record, drop the whole page in
+		btr_discard_page, if this is not the root page */
+
+		btr_discard_page(cursor, mtr);
+
+		*err = DB_SUCCESS;
+		ret = TRUE;
+
+		goto return_after_reservations;
+	}
+
+	lock_update_delete(block, rec);
+	level = btr_page_get_level(page, mtr);
+
+	if (level > 0
+	    && UNIV_UNLIKELY(rec == page_rec_get_next(
+				     page_get_infimum_rec(page)))) {
+
+		rec_t*	next_rec = page_rec_get_next(rec);
+
+		if (btr_page_get_prev(page, mtr) == FIL_NULL) {
+
+			/* If we delete the leftmost node pointer on a
+			non-leaf level, we must mark the new leftmost node
+			pointer as the predefined minimum record */
+
+			/* This will make page_zip_validate() fail until
+			page_cur_delete_rec() completes.  This is harmless,
+			because everything will take place within a single
+			mini-transaction and because writing to the redo log
+			is an atomic operation (performed by mtr_commit()). */
+			btr_set_min_rec_mark(next_rec, mtr);
+		} else {
+			/* Otherwise, if we delete the leftmost node pointer
+			on a page, we have to change the father node pointer
+			so that it is equal to the new leftmost node pointer
+			on the page */
+
+			btr_node_ptr_delete(index, block, mtr);
+
+			node_ptr = dict_index_build_node_ptr(
+				index, next_rec, buf_block_get_page_no(block),
+				heap, level);
+
+			btr_insert_on_non_leaf_level(index,
+						     level + 1, node_ptr, mtr);
+		}
+	}
+
+	btr_search_update_hash_on_delete(cursor);
+
+	page_cur_delete_rec(btr_cur_get_page_cur(cursor), index, offsets, mtr);
+#ifdef UNIV_ZIP_DEBUG
+	ut_a(!page_zip || page_zip_validate(page_zip, page));
+#endif /* UNIV_ZIP_DEBUG */
+
+	ut_ad(btr_check_node_ptr(index, block, mtr));
+
+	*err = DB_SUCCESS;
+
+return_after_reservations:
+	mem_heap_free(heap);
+
+	if (ret == FALSE) {
+		ret = btr_cur_compress_if_useful(cursor, mtr);
+	}
+
+	if (n_extents > 0) {
+		fil_space_release_free_extents(index->space, n_reserved);
+	}
+
+	return(ret);
+}
+
+/***********************************************************************
+Adds path information to the cursor for the current page, for which
+the binary search has been performed. */
+static
+void
+btr_cur_add_path_info(
+/*==================*/
+	btr_cur_t*	cursor,		/* in: cursor positioned on a page */
+	ulint		height,		/* in: height of the page in tree;
+					0 means leaf node */
+	ulint		root_height)	/* in: root node height in tree */
+{
+	btr_path_t*	slot;
+	rec_t*		rec;
+
+	ut_a(cursor->path_arr);
+
+	if (root_height >= BTR_PATH_ARRAY_N_SLOTS - 1) {
+		/* Do nothing; return empty path */
+
+		slot = cursor->path_arr;
+		slot->nth_rec = ULINT_UNDEFINED;
+
+		return;
+	}
+
+	if (height == 0) {
+		/* Mark end of slots for path */
+		slot = cursor->path_arr + root_height + 1;
+		slot->nth_rec = ULINT_UNDEFINED;
+	}
+
+	rec = btr_cur_get_rec(cursor);
+
+	slot = cursor->path_arr + (root_height - height);
+
+	slot->nth_rec = page_rec_get_n_recs_before(rec);
+	slot->n_recs = page_get_n_recs(page_align(rec));
+}
+
+/***********************************************************************
+Estimates the number of rows in a given index range. */
+UNIV_INTERN
+ib_int64_t
+btr_estimate_n_rows_in_range(
+/*=========================*/
+				/* out: estimated number of rows */
+	dict_index_t*	index,	/* in: index */
+	const dtuple_t*	tuple1,	/* in: range start, may also be empty tuple */
+	ulint		mode1,	/* in: search mode for range start */
+	const dtuple_t*	tuple2,	/* in: range end, may also be empty tuple */
+	ulint		mode2)	/* in: search mode for range end */
+{
+	btr_path_t	path1[BTR_PATH_ARRAY_N_SLOTS];
+	btr_path_t	path2[BTR_PATH_ARRAY_N_SLOTS];
+	btr_cur_t	cursor;
+	btr_path_t*	slot1;
+	btr_path_t*	slot2;
+	ibool		diverged;
+	ibool		diverged_lot;
+	ulint		divergence_level;
+	ib_int64_t	n_rows;
+	ulint		i;
+	mtr_t		mtr;
+
+	mtr_start(&mtr);
+
+	cursor.path_arr = path1;
+
+	if (dtuple_get_n_fields(tuple1) > 0) {
+
+		btr_cur_search_to_nth_level(index, 0, tuple1, mode1,
+					    BTR_SEARCH_LEAF | BTR_ESTIMATE,
+					    &cursor, 0, &mtr);
+	} else {
+		btr_cur_open_at_index_side(TRUE, index,
+					   BTR_SEARCH_LEAF | BTR_ESTIMATE,
+					   &cursor, &mtr);
+	}
+
+	mtr_commit(&mtr);
+
+	mtr_start(&mtr);
+
+	cursor.path_arr = path2;
+
+	if (dtuple_get_n_fields(tuple2) > 0) {
+
+		btr_cur_search_to_nth_level(index, 0, tuple2, mode2,
+					    BTR_SEARCH_LEAF | BTR_ESTIMATE,
+					    &cursor, 0, &mtr);
+	} else {
+		btr_cur_open_at_index_side(FALSE, index,
+					   BTR_SEARCH_LEAF | BTR_ESTIMATE,
+					   &cursor, &mtr);
+	}
+
+	mtr_commit(&mtr);
+
+	/* We have the path information for the range in path1 and path2 */
+
+	n_rows = 1;
+	diverged = FALSE;	    /* This becomes true when the path is not
+				    the same any more */
+	diverged_lot = FALSE;	    /* This becomes true when the paths are
+				    not the same or adjacent any more */
+	divergence_level = 1000000; /* This is the level where paths diverged
+				    a lot */
+	for (i = 0; ; i++) {
+		ut_ad(i < BTR_PATH_ARRAY_N_SLOTS);
+
+		slot1 = path1 + i;
+		slot2 = path2 + i;
+
+		if (slot1->nth_rec == ULINT_UNDEFINED
+		    || slot2->nth_rec == ULINT_UNDEFINED) {
+
+			if (i > divergence_level + 1) {
+				/* In trees whose height is > 1 our algorithm
+				tends to underestimate: multiply the estimate
+				by 2: */
+
+				n_rows = n_rows * 2;
+			}
+
+			/* Do not estimate the number of rows in the range
+			to over 1 / 2 of the estimated rows in the whole
+			table */
+
+			if (n_rows > index->table->stat_n_rows / 2) {
+				n_rows = index->table->stat_n_rows / 2;
+
+				/* If there are just 0 or 1 rows in the table,
+				then we estimate all rows are in the range */
+
+				if (n_rows == 0) {
+					n_rows = index->table->stat_n_rows;
+				}
+			}
+
+			return(n_rows);
+		}
+
+		if (!diverged && slot1->nth_rec != slot2->nth_rec) {
+
+			diverged = TRUE;
+
+			if (slot1->nth_rec < slot2->nth_rec) {
+				n_rows = slot2->nth_rec - slot1->nth_rec;
+
+				if (n_rows > 1) {
+					diverged_lot = TRUE;
+					divergence_level = i;
+				}
+			} else {
+				/* Maybe the tree has changed between
+				searches */
+
+				return(10);
+			}
+
+		} else if (diverged && !diverged_lot) {
+
+			if (slot1->nth_rec < slot1->n_recs
+			    || slot2->nth_rec > 1) {
+
+				diverged_lot = TRUE;
+				divergence_level = i;
+
+				n_rows = 0;
+
+				if (slot1->nth_rec < slot1->n_recs) {
+					n_rows += slot1->n_recs
+						- slot1->nth_rec;
+				}
+
+				if (slot2->nth_rec > 1) {
+					n_rows += slot2->nth_rec - 1;
+				}
+			}
+		} else if (diverged_lot) {
+
+			n_rows = (n_rows * (slot1->n_recs + slot2->n_recs))
+				/ 2;
+		}
+	}
+}
+
+/***********************************************************************
+Estimates the number of different key values in a given index, for
+each n-column prefix of the index where n <= dict_index_get_n_unique(index).
+The estimates are stored in the array index->stat_n_diff_key_vals. */
+UNIV_INTERN
+void
+btr_estimate_number_of_different_key_vals(
+/*======================================*/
+	dict_index_t*	index)	/* in: index */
+{
+	btr_cur_t	cursor;
+	page_t*		page;
+	rec_t*		rec;
+	ulint		n_cols;
+	ulint		matched_fields;
+	ulint		matched_bytes;
+	ib_int64_t*	n_diff;
+	ullint		n_sample_pages; /* number of pages to sample */
+	ulint		not_empty_flag	= 0;
+	ulint		total_external_size = 0;
+	ulint		i;
+	ulint		j;
+	ullint		add_on;
+	mtr_t		mtr;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_rec_[REC_OFFS_NORMAL_SIZE];
+	ulint		offsets_next_rec_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets_rec	= offsets_rec_;
+	ulint*		offsets_next_rec= offsets_next_rec_;
+	rec_offs_init(offsets_rec_);
+	rec_offs_init(offsets_next_rec_);
+
+	n_cols = dict_index_get_n_unique(index);
+
+	n_diff = mem_zalloc((n_cols + 1) * sizeof(ib_int64_t));
+
+	/* It makes no sense to test more pages than are contained
+	in the index, thus we lower the number if it is too high */
+	if (srv_stats_sample_pages > index->stat_index_size) {
+		if (index->stat_index_size > 0) {
+			n_sample_pages = index->stat_index_size;
+		} else {
+			n_sample_pages = 1;
+		}
+	} else {
+		n_sample_pages = srv_stats_sample_pages;
+	}
+
+	/* We sample some pages in the index to get an estimate */
+
+	for (i = 0; i < n_sample_pages; i++) {
+		rec_t*	supremum;
+		mtr_start(&mtr);
+
+		btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, &cursor, &mtr);
+
+		/* Count the number of different key values for each prefix of
+		the key on this index page. If the prefix does not determine
+		the index record uniquely in the B-tree, then we subtract one
+		because otherwise our algorithm would give a wrong estimate
+		for an index where there is just one key value. */
+
+		page = btr_cur_get_page(&cursor);
+
+		supremum = page_get_supremum_rec(page);
+		rec = page_rec_get_next(page_get_infimum_rec(page));
+
+		if (rec != supremum) {
+			not_empty_flag = 1;
+			offsets_rec = rec_get_offsets(rec, index, offsets_rec,
+						      ULINT_UNDEFINED, &heap);
+		}
+
+		while (rec != supremum) {
+			rec_t*	next_rec = page_rec_get_next(rec);
+			if (next_rec == supremum) {
+				break;
+			}
+
+			matched_fields = 0;
+			matched_bytes = 0;
+			offsets_next_rec = rec_get_offsets(next_rec, index,
+							   offsets_next_rec,
+							   n_cols, &heap);
+
+			cmp_rec_rec_with_match(rec, next_rec,
+					       offsets_rec, offsets_next_rec,
+					       index, &matched_fields,
+					       &matched_bytes);
+
+			for (j = matched_fields + 1; j <= n_cols; j++) {
+				/* We add one if this index record has
+				a different prefix from the previous */
+
+				n_diff[j]++;
+			}
+
+			total_external_size
+				+= btr_rec_get_externally_stored_len(
+					rec, offsets_rec);
+
+			rec = next_rec;
+			/* Initialize offsets_rec for the next round
+			and assign the old offsets_rec buffer to
+			offsets_next_rec. */
+			{
+				ulint*	offsets_tmp = offsets_rec;
+				offsets_rec = offsets_next_rec;
+				offsets_next_rec = offsets_tmp;
+			}
+		}
+
+
+		if (n_cols == dict_index_get_n_unique_in_tree(index)) {
+
+			/* If there is more than one leaf page in the tree,
+			we add one because we know that the first record
+			on the page certainly had a different prefix than the
+			last record on the previous index page in the
+			alphabetical order. Before this fix, if there was
+			just one big record on each clustered index page, the
+			algorithm grossly underestimated the number of rows
+			in the table. */
+
+			if (btr_page_get_prev(page, &mtr) != FIL_NULL
+			    || btr_page_get_next(page, &mtr) != FIL_NULL) {
+
+				n_diff[n_cols]++;
+			}
+		}
+
+		offsets_rec = rec_get_offsets(rec, index, offsets_rec,
+					      ULINT_UNDEFINED, &heap);
+		total_external_size += btr_rec_get_externally_stored_len(
+			rec, offsets_rec);
+		mtr_commit(&mtr);
+	}
+
+	/* If we saw k borders between different key values on
+	n_sample_pages leaf pages, we can estimate how many
+	there will be in index->stat_n_leaf_pages */
+
+	/* We must take into account that our sample actually represents
+	also the pages used for external storage of fields (those pages are
+	included in index->stat_n_leaf_pages) */
+
+	for (j = 0; j <= n_cols; j++) {
+		index->stat_n_diff_key_vals[j]
+			= ((n_diff[j]
+			    * (ib_int64_t)index->stat_n_leaf_pages
+			    + n_sample_pages - 1
+			    + total_external_size
+			    + not_empty_flag)
+			   / (n_sample_pages
+			      + total_external_size));
+
+		/* If the tree is small, smaller than
+		10 * n_sample_pages + total_external_size, then
+		the above estimate is ok. For bigger trees it is common that we
+		do not see any borders between key values in the few pages
+		we pick. But still there may be n_sample_pages
+		different key values, or even more. Let us try to approximate
+		that: */
+
+		add_on = index->stat_n_leaf_pages
+			/ (10 * (n_sample_pages
+				 + total_external_size));
+
+		if (add_on > n_sample_pages) {
+			add_on = n_sample_pages;
+		}
+
+		index->stat_n_diff_key_vals[j] += add_on;
+	}
+
+	mem_free(n_diff);
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+}
+
+/*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/
+
+/***************************************************************
+Gets the externally stored size of a record, in units of a database page. */
+static
+ulint
+btr_rec_get_externally_stored_len(
+/*==============================*/
+				/* out: externally stored part,
+				in units of a database page */
+	rec_t*		rec,	/* in: record */
+	const ulint*	offsets)/* in: array returned by rec_get_offsets() */
+{
+	ulint	n_fields;
+	byte*	data;
+	ulint	local_len;
+	ulint	extern_len;
+	ulint	total_extern_len = 0;
+	ulint	i;
+
+	ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec));
+	n_fields = rec_offs_n_fields(offsets);
+
+	for (i = 0; i < n_fields; i++) {
+		if (rec_offs_nth_extern(offsets, i)) {
+
+			data = rec_get_nth_field(rec, offsets, i, &local_len);
+
+			local_len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+			extern_len = mach_read_from_4(data + local_len
+						      + BTR_EXTERN_LEN + 4);
+
+			total_extern_len += ut_calc_align(extern_len,
+							  UNIV_PAGE_SIZE);
+		}
+	}
+
+	return(total_extern_len / UNIV_PAGE_SIZE);
+}
+
+/***********************************************************************
+Sets the ownership bit of an externally stored field in a record. */
+static
+void
+btr_cur_set_ownership_of_extern_field(
+/*==================================*/
+	page_zip_des_t*	page_zip,/* in/out: compressed page whose uncompressed
+				part will be updated, or NULL */
+	rec_t*		rec,	/* in/out: clustered index record */
+	dict_index_t*	index,	/* in: index of the page */
+	const ulint*	offsets,/* in: array returned by rec_get_offsets() */
+	ulint		i,	/* in: field number */
+	ibool		val,	/* in: value to set */
+	mtr_t*		mtr)	/* in: mtr, or NULL if not logged */
+{
+	byte*	data;
+	ulint	local_len;
+	ulint	byte_val;
+
+	data = rec_get_nth_field(rec, offsets, i, &local_len);
+
+	ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+	local_len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+	byte_val = mach_read_from_1(data + local_len + BTR_EXTERN_LEN);
+
+	if (val) {
+		byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG);
+	} else {
+		byte_val = byte_val | BTR_EXTERN_OWNER_FLAG;
+	}
+
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		mach_write_to_1(data + local_len + BTR_EXTERN_LEN, byte_val);
+		page_zip_write_blob_ptr(page_zip, rec, index, offsets, i, mtr);
+	} else if (UNIV_LIKELY(mtr != NULL)) {
+
+		mlog_write_ulint(data + local_len + BTR_EXTERN_LEN, byte_val,
+				 MLOG_1BYTE, mtr);
+	} else {
+		mach_write_to_1(data + local_len + BTR_EXTERN_LEN, byte_val);
+	}
+}
+
+/***********************************************************************
+Marks not updated extern fields as not-owned by this record. The ownership
+is transferred to the updated record which is inserted elsewhere in the
+index tree. In purge only the owner of externally stored field is allowed
+to free the field. */
+UNIV_INTERN
+void
+btr_cur_mark_extern_inherited_fields(
+/*=================================*/
+	page_zip_des_t*	page_zip,/* in/out: compressed page whose uncompressed
+				part will be updated, or NULL */
+	rec_t*		rec,	/* in/out: record in a clustered index */
+	dict_index_t*	index,	/* in: index of the page */
+	const ulint*	offsets,/* in: array returned by rec_get_offsets() */
+	const upd_t*	update,	/* in: update vector */
+	mtr_t*		mtr)	/* in: mtr, or NULL if not logged */
+{
+	ulint	n;
+	ulint	j;
+	ulint	i;
+
+	ut_ad(rec_offs_validate(rec, NULL, offsets));
+	ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec));
+
+	if (!rec_offs_any_extern(offsets)) {
+
+		return;
+	}
+
+	n = rec_offs_n_fields(offsets);
+
+	for (i = 0; i < n; i++) {
+		if (rec_offs_nth_extern(offsets, i)) {
+
+			/* Check it is not in updated fields */
+
+			if (update) {
+				for (j = 0; j < upd_get_n_fields(update);
+				     j++) {
+					if (upd_get_nth_field(update, j)
+					    ->field_no == i) {
+
+						goto updated;
+					}
+				}
+			}
+
+			btr_cur_set_ownership_of_extern_field(
+				page_zip, rec, index, offsets, i, FALSE, mtr);
+updated:
+			;
+		}
+	}
+}
+
+/***********************************************************************
+The complement of the previous function: in an update entry may inherit
+some externally stored fields from a record. We must mark them as inherited
+in entry, so that they are not freed in a rollback. */
+UNIV_INTERN
+void
+btr_cur_mark_dtuple_inherited_extern(
+/*=================================*/
+	dtuple_t*	entry,		/* in/out: updated entry to be
+					inserted to clustered index */
+	const upd_t*	update)		/* in: update vector */
+{
+	ulint		i;
+
+	for (i = 0; i < dtuple_get_n_fields(entry); i++) {
+
+		dfield_t*	dfield = dtuple_get_nth_field(entry, i);
+		byte*		data;
+		ulint		len;
+		ulint		j;
+
+		if (!dfield_is_ext(dfield)) {
+			continue;
+		}
+
+		/* Check if it is in updated fields */
+
+		for (j = 0; j < upd_get_n_fields(update); j++) {
+			if (upd_get_nth_field(update, j)->field_no == i) {
+
+				goto is_updated;
+			}
+		}
+
+		data = dfield_get_data(dfield);
+		len = dfield_get_len(dfield);
+		data[len - BTR_EXTERN_FIELD_REF_SIZE + BTR_EXTERN_LEN]
+			|= BTR_EXTERN_INHERITED_FLAG;
+
+is_updated:
+		;
+	}
+}
+
+/***********************************************************************
+Marks all extern fields in a record as owned by the record. This function
+should be called if the delete mark of a record is removed: a not delete
+marked record always owns all its extern fields. */
+static
+void
+btr_cur_unmark_extern_fields(
+/*=========================*/
+	page_zip_des_t*	page_zip,/* in/out: compressed page whose uncompressed
+				part will be updated, or NULL */
+	rec_t*		rec,	/* in/out: record in a clustered index */
+	dict_index_t*	index,	/* in: index of the page */
+	const ulint*	offsets,/* in: array returned by rec_get_offsets() */
+	mtr_t*		mtr)	/* in: mtr, or NULL if not logged */
+{
+	ulint	n;
+	ulint	i;
+
+	ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec));
+	n = rec_offs_n_fields(offsets);
+
+	if (!rec_offs_any_extern(offsets)) {
+
+		return;
+	}
+
+	for (i = 0; i < n; i++) {
+		if (rec_offs_nth_extern(offsets, i)) {
+
+			btr_cur_set_ownership_of_extern_field(
+				page_zip, rec, index, offsets, i, TRUE, mtr);
+		}
+	}
+}
+
+/***********************************************************************
+Marks all extern fields in a dtuple as owned by the record. */
+UNIV_INTERN
+void
+btr_cur_unmark_dtuple_extern_fields(
+/*================================*/
+	dtuple_t*	entry)		/* in/out: clustered index entry */
+{
+	ulint	i;
+
+	for (i = 0; i < dtuple_get_n_fields(entry); i++) {
+		dfield_t* dfield = dtuple_get_nth_field(entry, i);
+
+		if (dfield_is_ext(dfield)) {
+			byte*	data = dfield_get_data(dfield);
+			ulint	len = dfield_get_len(dfield);
+
+			data[len - BTR_EXTERN_FIELD_REF_SIZE + BTR_EXTERN_LEN]
+				&= ~BTR_EXTERN_OWNER_FLAG;
+		}
+	}
+}
+
+/***********************************************************************
+Flags the data tuple fields that are marked as extern storage in the
+update vector.  We use this function to remember which fields we must
+mark as extern storage in a record inserted for an update. */
+UNIV_INTERN
+ulint
+btr_push_update_extern_fields(
+/*==========================*/
+				/* out: number of flagged external columns */
+	dtuple_t*	tuple,	/* in/out: data tuple */
+	const upd_t*	update,	/* in: update vector */
+	mem_heap_t*	heap)	/* in: memory heap */
+{
+	ulint			n_pushed	= 0;
+	ulint			n;
+	const upd_field_t*	uf;
+
+	ut_ad(tuple);
+	ut_ad(update);
+
+	uf = update->fields;
+	n = upd_get_n_fields(update);
+
+	for (; n--; uf++) {
+		if (dfield_is_ext(&uf->new_val)) {
+			dfield_t*	field
+				= dtuple_get_nth_field(tuple, uf->field_no);
+
+			if (!dfield_is_ext(field)) {
+				dfield_set_ext(field);
+				n_pushed++;
+			}
+
+			switch (uf->orig_len) {
+				byte*	data;
+				ulint	len;
+				byte*	buf;
+			case 0:
+				break;
+			case BTR_EXTERN_FIELD_REF_SIZE:
+				/* Restore the original locally stored
+				part of the column.  In the undo log,
+				InnoDB writes a longer prefix of externally
+				stored columns, so that column prefixes
+				in secondary indexes can be reconstructed. */
+				dfield_set_data(field, (byte*) dfield_get_data(field)
+						+ dfield_get_len(field)
+						- BTR_EXTERN_FIELD_REF_SIZE,
+						BTR_EXTERN_FIELD_REF_SIZE);
+				dfield_set_ext(field);
+				break;
+			default:
+				/* Reconstruct the original locally
+				stored part of the column.  The data
+				will have to be copied. */
+				ut_a(uf->orig_len > BTR_EXTERN_FIELD_REF_SIZE);
+
+				data = dfield_get_data(field);
+				len = dfield_get_len(field);
+
+				buf = mem_heap_alloc(heap, uf->orig_len);
+				/* Copy the locally stored prefix. */
+				memcpy(buf, data,
+				       uf->orig_len
+				       - BTR_EXTERN_FIELD_REF_SIZE);
+				/* Copy the BLOB pointer. */
+				memcpy(buf + uf->orig_len
+				       - BTR_EXTERN_FIELD_REF_SIZE,
+				       data + len - BTR_EXTERN_FIELD_REF_SIZE,
+				       BTR_EXTERN_FIELD_REF_SIZE);
+
+				dfield_set_data(field, buf, uf->orig_len);
+				dfield_set_ext(field);
+			}
+		}
+	}
+
+	return(n_pushed);
+}
+
+/***********************************************************************
+Returns the length of a BLOB part stored on the header page. */
+static
+ulint
+btr_blob_get_part_len(
+/*==================*/
+					/* out: part length */
+	const byte*	blob_header)	/* in: blob header */
+{
+	return(mach_read_from_4(blob_header + BTR_BLOB_HDR_PART_LEN));
+}
+
+/***********************************************************************
+Returns the page number where the next BLOB part is stored. */
+static
+ulint
+btr_blob_get_next_page_no(
+/*======================*/
+					/* out: page number or FIL_NULL if
+					no more pages */
+	const byte*	blob_header)	/* in: blob header */
+{
+	return(mach_read_from_4(blob_header + BTR_BLOB_HDR_NEXT_PAGE_NO));
+}
+
+/***********************************************************************
+Deallocate a buffer block that was reserved for a BLOB part. */
+static
+void
+btr_blob_free(
+/*==========*/
+	buf_block_t*	block,	/* in: buffer block */
+	ibool		all,	/* in: TRUE=remove also the compressed page
+				if there is one */
+	mtr_t*		mtr)	/* in: mini-transaction to commit */
+{
+	ulint	space	= buf_block_get_space(block);
+	ulint	page_no	= buf_block_get_page_no(block);
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+
+	mtr_commit(mtr);
+
+	buf_pool_mutex_enter();
+	mutex_enter(&block->mutex);
+
+	/* Only free the block if it is still allocated to
+	the same file page. */
+
+	if (buf_block_get_state(block)
+	    == BUF_BLOCK_FILE_PAGE
+	    && buf_block_get_space(block) == space
+	    && buf_block_get_page_no(block) == page_no) {
+
+		if (buf_LRU_free_block(&block->page, all, NULL)
+		    != BUF_LRU_FREED
+		    && all && block->page.zip.data) {
+			/* Attempt to deallocate the uncompressed page
+			if the whole block cannot be deallocted. */
+
+			buf_LRU_free_block(&block->page, FALSE, NULL);
+		}
+	}
+
+	buf_pool_mutex_exit();
+	mutex_exit(&block->mutex);
+}
+
+/***********************************************************************
+Stores the fields in big_rec_vec to the tablespace and puts pointers to
+them in rec.  The extern flags in rec will have to be set beforehand.
+The fields are stored on pages allocated from leaf node
+file segment of the index tree. */
+UNIV_INTERN
+ulint
+btr_store_big_rec_extern_fields(
+/*============================*/
+					/* out: DB_SUCCESS or error */
+	dict_index_t*	index,		/* in: index of rec; the index tree
+					MUST be X-latched */
+	buf_block_t*	rec_block,	/* in/out: block containing rec */
+	rec_t*		rec,		/* in/out: record */
+	const ulint*	offsets,	/* in: rec_get_offsets(rec, index);
+					the "external storage" flags in offsets
+					will not correspond to rec when
+					this function returns */
+	big_rec_t*	big_rec_vec,	/* in: vector containing fields
+					to be stored externally */
+	mtr_t*		local_mtr __attribute__((unused))) /* in: mtr
+					containing the latch to rec and to the
+					tree */
+{
+	ulint	rec_page_no;
+	byte*	field_ref;
+	ulint	extern_len;
+	ulint	store_len;
+	ulint	page_no;
+	ulint	space_id;
+	ulint	zip_size;
+	ulint	prev_page_no;
+	ulint	hint_page_no;
+	ulint	i;
+	mtr_t	mtr;
+	mem_heap_t* heap = NULL;
+	page_zip_des_t*	page_zip;
+	z_stream c_stream;
+
+	ut_ad(rec_offs_validate(rec, index, offsets));
+	ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
+				MTR_MEMO_X_LOCK));
+	ut_ad(mtr_memo_contains(local_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
+	ut_ad(buf_block_get_frame(rec_block) == page_align(rec));
+	ut_a(dict_index_is_clust(index));
+
+	page_zip = buf_block_get_page_zip(rec_block);
+	ut_a(dict_table_zip_size(index->table)
+	     == buf_block_get_zip_size(rec_block));
+
+	space_id = buf_block_get_space(rec_block);
+	zip_size = buf_block_get_zip_size(rec_block);
+	rec_page_no = buf_block_get_page_no(rec_block);
+	ut_a(fil_page_get_type(page_align(rec)) == FIL_PAGE_INDEX);
+
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		int	err;
+
+		/* Zlib deflate needs 128 kilobytes for the default
+		window size, plus 512 << memLevel, plus a few
+		kilobytes for small objects.  We use reduced memLevel
+		to limit the memory consumption, and preallocate the
+		heap, hoping to avoid memory fragmentation. */
+		heap = mem_heap_create(250000);
+		page_zip_set_alloc(&c_stream, heap);
+
+		err = deflateInit2(&c_stream, Z_DEFAULT_COMPRESSION,
+				   Z_DEFLATED, 15, 7, Z_DEFAULT_STRATEGY);
+		ut_a(err == Z_OK);
+	}
+
+	/* We have to create a file segment to the tablespace
+	for each field and put the pointer to the field in rec */
+
+	for (i = 0; i < big_rec_vec->n_fields; i++) {
+		ut_ad(rec_offs_nth_extern(offsets,
+					  big_rec_vec->fields[i].field_no));
+		{
+			ulint	local_len;
+			field_ref = rec_get_nth_field(
+				rec, offsets, big_rec_vec->fields[i].field_no,
+				&local_len);
+			ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+			local_len -= BTR_EXTERN_FIELD_REF_SIZE;
+			field_ref += local_len;
+		}
+		extern_len = big_rec_vec->fields[i].len;
+
+		ut_a(extern_len > 0);
+
+		prev_page_no = FIL_NULL;
+
+		if (UNIV_LIKELY_NULL(page_zip)) {
+			int	err = deflateReset(&c_stream);
+			ut_a(err == Z_OK);
+
+			c_stream.next_in = (void*) big_rec_vec->fields[i].data;
+			c_stream.avail_in = extern_len;
+		}
+
+		for (;;) {
+			buf_block_t*	block;
+			page_t*		page;
+
+			mtr_start(&mtr);
+
+			if (prev_page_no == FIL_NULL) {
+				hint_page_no = 1 + rec_page_no;
+			} else {
+				hint_page_no = prev_page_no + 1;
+			}
+
+			block = btr_page_alloc(index, hint_page_no,
+					       FSP_NO_DIR, 0, &mtr);
+			if (UNIV_UNLIKELY(block == NULL)) {
+
+				mtr_commit(&mtr);
+
+				if (UNIV_LIKELY_NULL(page_zip)) {
+					deflateEnd(&c_stream);
+					mem_heap_free(heap);
+				}
+
+				return(DB_OUT_OF_FILE_SPACE);
+			}
+
+			page_no = buf_block_get_page_no(block);
+			page = buf_block_get_frame(block);
+
+			if (prev_page_no != FIL_NULL) {
+				buf_block_t*	prev_block;
+				page_t*		prev_page;
+
+				prev_block = buf_page_get(space_id, zip_size,
+							  prev_page_no,
+							  RW_X_LATCH, &mtr);
+				buf_block_dbg_add_level(prev_block,
+							SYNC_EXTERN_STORAGE);
+				prev_page = buf_block_get_frame(prev_block);
+
+				if (UNIV_LIKELY_NULL(page_zip)) {
+					mlog_write_ulint(
+						prev_page + FIL_PAGE_NEXT,
+						page_no, MLOG_4BYTES, &mtr);
+					memcpy(buf_block_get_page_zip(
+						       prev_block)
+					       ->data + FIL_PAGE_NEXT,
+					       prev_page + FIL_PAGE_NEXT, 4);
+				} else {
+					mlog_write_ulint(
+						prev_page + FIL_PAGE_DATA
+						+ BTR_BLOB_HDR_NEXT_PAGE_NO,
+						page_no, MLOG_4BYTES, &mtr);
+				}
+
+			}
+
+			if (UNIV_LIKELY_NULL(page_zip)) {
+				int		err;
+				page_zip_des_t*	blob_page_zip;
+
+				mach_write_to_2(page + FIL_PAGE_TYPE,
+						prev_page_no == FIL_NULL
+						? FIL_PAGE_TYPE_ZBLOB
+						: FIL_PAGE_TYPE_ZBLOB2);
+
+				c_stream.next_out = page
+					+ FIL_PAGE_DATA;
+				c_stream.avail_out
+					= page_zip_get_size(page_zip)
+					- FIL_PAGE_DATA;
+
+				err = deflate(&c_stream, Z_FINISH);
+				ut_a(err == Z_OK || err == Z_STREAM_END);
+				ut_a(err == Z_STREAM_END
+				     || c_stream.avail_out == 0);
+
+				/* Write the "next BLOB page" pointer */
+				mlog_write_ulint(page + FIL_PAGE_NEXT,
+						 FIL_NULL, MLOG_4BYTES, &mtr);
+				/* Initialize the unused "prev page" pointer */
+				mlog_write_ulint(page + FIL_PAGE_PREV,
+						 FIL_NULL, MLOG_4BYTES, &mtr);
+				/* Write a back pointer to the record
+				into the otherwise unused area.  This
+				information could be useful in
+				debugging.  Later, we might want to
+				implement the possibility to relocate
+				BLOB pages.  Then, we would need to be
+				able to adjust the BLOB pointer in the
+				record.  We do not store the heap
+				number of the record, because it can
+				change in page_zip_reorganize() or
+				btr_page_reorganize().  However, also
+				the page number of the record may
+				change when B-tree nodes are split or
+				merged. */
+				mlog_write_ulint(page
+						 + FIL_PAGE_FILE_FLUSH_LSN,
+						 space_id,
+						 MLOG_4BYTES, &mtr);
+				mlog_write_ulint(page
+						 + FIL_PAGE_FILE_FLUSH_LSN + 4,
+						 rec_page_no,
+						 MLOG_4BYTES, &mtr);
+
+				/* Zero out the unused part of the page. */
+				memset(page + page_zip_get_size(page_zip)
+				       - c_stream.avail_out,
+				       0, c_stream.avail_out);
+				mlog_log_string(page + FIL_PAGE_TYPE,
+						page_zip_get_size(page_zip)
+						- FIL_PAGE_TYPE,
+						&mtr);
+				/* Copy the page to compressed storage,
+				because it will be flushed to disk
+				from there. */
+				blob_page_zip = buf_block_get_page_zip(block);
+				ut_ad(blob_page_zip);
+				ut_ad(page_zip_get_size(blob_page_zip)
+				      == page_zip_get_size(page_zip));
+				memcpy(blob_page_zip->data, page,
+				       page_zip_get_size(page_zip));
+
+				if (err == Z_OK && prev_page_no != FIL_NULL) {
+
+					goto next_zip_page;
+				}
+
+				rec_block = buf_page_get(space_id, zip_size,
+							 rec_page_no,
+							 RW_X_LATCH, &mtr);
+				buf_block_dbg_add_level(rec_block,
+							SYNC_NO_ORDER_CHECK);
+
+				if (err == Z_STREAM_END) {
+					mach_write_to_4(field_ref
+							+ BTR_EXTERN_LEN, 0);
+					mach_write_to_4(field_ref
+							+ BTR_EXTERN_LEN + 4,
+							c_stream.total_in);
+				} else {
+					memset(field_ref + BTR_EXTERN_LEN,
+					       0, 8);
+				}
+
+				if (prev_page_no == FIL_NULL) {
+					mach_write_to_4(field_ref
+							+ BTR_EXTERN_SPACE_ID,
+							space_id);
+
+					mach_write_to_4(field_ref
+							+ BTR_EXTERN_PAGE_NO,
+							page_no);
+
+					mach_write_to_4(field_ref
+							+ BTR_EXTERN_OFFSET,
+							FIL_PAGE_NEXT);
+				}
+
+				page_zip_write_blob_ptr(
+					page_zip, rec, index, offsets,
+					big_rec_vec->fields[i].field_no, &mtr);
+
+next_zip_page:
+				prev_page_no = page_no;
+
+				/* Commit mtr and release the
+				uncompressed page frame to save memory. */
+				btr_blob_free(block, FALSE, &mtr);
+
+				if (err == Z_STREAM_END) {
+					break;
+				}
+			} else {
+				mlog_write_ulint(page + FIL_PAGE_TYPE,
+						 FIL_PAGE_TYPE_BLOB,
+						 MLOG_2BYTES, &mtr);
+
+				if (extern_len > (UNIV_PAGE_SIZE
+						  - FIL_PAGE_DATA
+						  - BTR_BLOB_HDR_SIZE
+						  - FIL_PAGE_DATA_END)) {
+					store_len = UNIV_PAGE_SIZE
+						- FIL_PAGE_DATA
+						- BTR_BLOB_HDR_SIZE
+						- FIL_PAGE_DATA_END;
+				} else {
+					store_len = extern_len;
+				}
+
+				mlog_write_string(page + FIL_PAGE_DATA
+						  + BTR_BLOB_HDR_SIZE,
+						  (const byte*)
+						  big_rec_vec->fields[i].data
+						  + big_rec_vec->fields[i].len
+						  - extern_len,
+						  store_len, &mtr);
+				mlog_write_ulint(page + FIL_PAGE_DATA
+						 + BTR_BLOB_HDR_PART_LEN,
+						 store_len, MLOG_4BYTES, &mtr);
+				mlog_write_ulint(page + FIL_PAGE_DATA
+						 + BTR_BLOB_HDR_NEXT_PAGE_NO,
+						 FIL_NULL, MLOG_4BYTES, &mtr);
+
+				extern_len -= store_len;
+
+				rec_block = buf_page_get(space_id, zip_size,
+							 rec_page_no,
+							 RW_X_LATCH, &mtr);
+				buf_block_dbg_add_level(rec_block,
+							SYNC_NO_ORDER_CHECK);
+
+				mlog_write_ulint(field_ref + BTR_EXTERN_LEN, 0,
+						 MLOG_4BYTES, &mtr);
+				mlog_write_ulint(field_ref
+						 + BTR_EXTERN_LEN + 4,
+						 big_rec_vec->fields[i].len
+						 - extern_len,
+						 MLOG_4BYTES, &mtr);
+
+				if (prev_page_no == FIL_NULL) {
+					mlog_write_ulint(field_ref
+							 + BTR_EXTERN_SPACE_ID,
+							 space_id,
+							 MLOG_4BYTES, &mtr);
+
+					mlog_write_ulint(field_ref
+							 + BTR_EXTERN_PAGE_NO,
+							 page_no,
+							 MLOG_4BYTES, &mtr);
+
+					mlog_write_ulint(field_ref
+							 + BTR_EXTERN_OFFSET,
+							 FIL_PAGE_DATA,
+							 MLOG_4BYTES, &mtr);
+				}
+
+				prev_page_no = page_no;
+
+				mtr_commit(&mtr);
+
+				if (extern_len == 0) {
+					break;
+				}
+			}
+		}
+	}
+
+	if (UNIV_LIKELY_NULL(page_zip)) {
+		deflateEnd(&c_stream);
+		mem_heap_free(heap);
+	}
+
+	return(DB_SUCCESS);
+}
+
+/***********************************************************************
+Check the FIL_PAGE_TYPE on an uncompressed BLOB page. */
+static
+void
+btr_check_blob_fil_page_type(
+/*=========================*/
+	ulint		space_id,	/* in: space id */
+	ulint		page_no,	/* in: page number */
+	const page_t*	page,		/* in: page */
+	ibool		read)		/* in: TRUE=read, FALSE=purge */
+{
+	ulint	type = fil_page_get_type(page);
+
+	ut_a(space_id == page_get_space_id(page));
+	ut_a(page_no == page_get_page_no(page));
+
+	if (UNIV_UNLIKELY(type != FIL_PAGE_TYPE_BLOB)) {
+		ulint	flags = fil_space_get_flags(space_id);
+
+		if (UNIV_LIKELY
+		    ((flags & DICT_TF_FORMAT_MASK) == DICT_TF_FORMAT_51)) {
+			/* Old versions of InnoDB did not initialize
+			FIL_PAGE_TYPE on BLOB pages.  Do not print
+			anything about the type mismatch when reading
+			a BLOB page that is in Antelope format.*/
+			return;
+		}
+
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			"  InnoDB: FIL_PAGE_TYPE=%lu"
+			" on BLOB %s space %lu page %lu flags %lx\n",
+			(ulong) type, read ? "read" : "purge",
+			(ulong) space_id, (ulong) page_no, (ulong) flags);
+		ut_error;
+	}
+}
+
+/***********************************************************************
+Frees the space in an externally stored field to the file space
+management if the field in data is owned by the externally stored field,
+in a rollback we may have the additional condition that the field must
+not be inherited. */
+UNIV_INTERN
+void
+btr_free_externally_stored_field(
+/*=============================*/
+	dict_index_t*	index,		/* in: index of the data, the index
+					tree MUST be X-latched; if the tree
+					height is 1, then also the root page
+					must be X-latched! (this is relevant
+					in the case this function is called
+					from purge where 'data' is located on
+					an undo log page, not an index
+					page) */
+	byte*		field_ref,	/* in/out: field reference */
+	const rec_t*	rec,		/* in: record containing field_ref, for
+					page_zip_write_blob_ptr(), or NULL */
+	const ulint*	offsets,	/* in: rec_get_offsets(rec, index),
+					or NULL */
+	page_zip_des_t*	page_zip,	/* in: compressed page corresponding
+					to rec, or NULL if rec == NULL */
+	ulint		i,		/* in: field number of field_ref;
+					ignored if rec == NULL */
+	enum trx_rb_ctx	rb_ctx,		/* in: rollback context */
+	mtr_t*		local_mtr __attribute__((unused))) /* in: mtr
+					containing the latch to data an an
+					X-latch to the index tree */
+{
+	page_t*		page;
+	ulint		space_id;
+	ulint		rec_zip_size = dict_table_zip_size(index->table);
+	ulint		ext_zip_size;
+	ulint		page_no;
+	ulint		next_page_no;
+	mtr_t		mtr;
+#ifdef UNIV_DEBUG
+	ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
+				MTR_MEMO_X_LOCK));
+	ut_ad(mtr_memo_contains_page(local_mtr, field_ref,
+				     MTR_MEMO_PAGE_X_FIX));
+	ut_ad(!rec || rec_offs_validate(rec, index, offsets));
+
+	if (rec) {
+		ulint	local_len;
+		const byte*	f = rec_get_nth_field(rec, offsets,
+						      i, &local_len);
+		ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+		local_len -= BTR_EXTERN_FIELD_REF_SIZE;
+		f += local_len;
+		ut_ad(f == field_ref);
+	}
+#endif /* UNIV_DEBUG */
+
+	if (UNIV_UNLIKELY(!memcmp(field_ref, field_ref_zero,
+				  BTR_EXTERN_FIELD_REF_SIZE))) {
+		/* In the rollback of uncommitted transactions, we may
+		encounter a clustered index record whose BLOBs have
+		not been written.  There is nothing to free then. */
+		ut_a(rb_ctx == RB_RECOVERY);
+		return;
+	}
+
+	space_id = mach_read_from_4(field_ref + BTR_EXTERN_SPACE_ID);
+
+	if (UNIV_UNLIKELY(space_id != dict_index_get_space(index))) {
+		ext_zip_size = fil_space_get_zip_size(space_id);
+		/* This must be an undo log record in the system tablespace,
+		that is, in row_purge_upd_exist_or_extern().
+		Currently, externally stored records are stored in the
+		same tablespace as the referring records. */
+		ut_ad(!page_get_space_id(page_align(field_ref)));
+		ut_ad(!rec);
+		ut_ad(!page_zip);
+	} else {
+		ext_zip_size = rec_zip_size;
+	}
+
+	if (!rec) {
+		/* This is a call from row_purge_upd_exist_or_extern(). */
+		ut_ad(!page_zip);
+		rec_zip_size = 0;
+	}
+
+	for (;;) {
+		buf_block_t*	rec_block;
+		buf_block_t*	ext_block;
+
+		mtr_start(&mtr);
+
+		rec_block = buf_page_get(page_get_space_id(
+						 page_align(field_ref)),
+					 rec_zip_size,
+					 page_get_page_no(
+						 page_align(field_ref)),
+					 RW_X_LATCH, &mtr);
+		buf_block_dbg_add_level(rec_block, SYNC_NO_ORDER_CHECK);
+		page_no = mach_read_from_4(field_ref + BTR_EXTERN_PAGE_NO);
+
+		if (/* There is no external storage data */
+		    page_no == FIL_NULL
+		    /* This field does not own the externally stored field */
+		    || (mach_read_from_1(field_ref + BTR_EXTERN_LEN)
+			& BTR_EXTERN_OWNER_FLAG)
+		    /* Rollback and inherited field */
+		    || (rb_ctx != RB_NONE
+			&& (mach_read_from_1(field_ref + BTR_EXTERN_LEN)
+			    & BTR_EXTERN_INHERITED_FLAG))) {
+
+			/* Do not free */
+			mtr_commit(&mtr);
+
+			return;
+		}
+
+		ext_block = buf_page_get(space_id, ext_zip_size, page_no,
+					 RW_X_LATCH, &mtr);
+		buf_block_dbg_add_level(ext_block, SYNC_EXTERN_STORAGE);
+		page = buf_block_get_frame(ext_block);
+
+		if (ext_zip_size) {
+			/* Note that page_zip will be NULL
+			in row_purge_upd_exist_or_extern(). */
+			switch (fil_page_get_type(page)) {
+			case FIL_PAGE_TYPE_ZBLOB:
+			case FIL_PAGE_TYPE_ZBLOB2:
+				break;
+			default:
+				ut_error;
+			}
+			next_page_no = mach_read_from_4(page + FIL_PAGE_NEXT);
+
+			btr_page_free_low(index, ext_block, 0, &mtr);
+
+			if (UNIV_LIKELY(page_zip != NULL)) {
+				mach_write_to_4(field_ref + BTR_EXTERN_PAGE_NO,
+						next_page_no);
+				mach_write_to_4(field_ref + BTR_EXTERN_LEN + 4,
+						0);
+				page_zip_write_blob_ptr(page_zip, rec, index,
+							offsets, i, &mtr);
+			} else {
+				mlog_write_ulint(field_ref
+						 + BTR_EXTERN_PAGE_NO,
+						 next_page_no,
+						 MLOG_4BYTES, &mtr);
+				mlog_write_ulint(field_ref
+						 + BTR_EXTERN_LEN + 4, 0,
+						 MLOG_4BYTES, &mtr);
+			}
+		} else {
+			ut_a(!page_zip);
+			btr_check_blob_fil_page_type(space_id, page_no, page,
+						     FALSE);
+
+			next_page_no = mach_read_from_4(
+				page + FIL_PAGE_DATA
+				+ BTR_BLOB_HDR_NEXT_PAGE_NO);
+
+			/* We must supply the page level (= 0) as an argument
+			because we did not store it on the page (we save the
+			space overhead from an index page header. */
+
+			btr_page_free_low(index, ext_block, 0, &mtr);
+
+			mlog_write_ulint(field_ref + BTR_EXTERN_PAGE_NO,
+					 next_page_no,
+					 MLOG_4BYTES, &mtr);
+			/* Zero out the BLOB length.  If the server
+			crashes during the execution of this function,
+			trx_rollback_or_clean_all_recovered() could
+			dereference the half-deleted BLOB, fetching a
+			wrong prefix for the BLOB. */
+			mlog_write_ulint(field_ref + BTR_EXTERN_LEN + 4,
+					 0,
+					 MLOG_4BYTES, &mtr);
+		}
+
+		/* Commit mtr and release the BLOB block to save memory. */
+		btr_blob_free(ext_block, TRUE, &mtr);
+	}
+}
+
+/***************************************************************
+Frees the externally stored fields for a record. */
+static
+void
+btr_rec_free_externally_stored_fields(
+/*==================================*/
+	dict_index_t*	index,	/* in: index of the data, the index
+				tree MUST be X-latched */
+	rec_t*		rec,	/* in/out: record */
+	const ulint*	offsets,/* in: rec_get_offsets(rec, index) */
+	page_zip_des_t*	page_zip,/* in: compressed page whose uncompressed
+				part will be updated, or NULL */
+	enum trx_rb_ctx	rb_ctx,	/* in: rollback context */
+	mtr_t*		mtr)	/* in: mini-transaction handle which contains
+				an X-latch to record page and to the index
+				tree */
+{
+	ulint	n_fields;
+	ulint	i;
+
+	ut_ad(rec_offs_validate(rec, index, offsets));
+	ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX));
+	/* Free possible externally stored fields in the record */
+
+	ut_ad(dict_table_is_comp(index->table) == !!rec_offs_comp(offsets));
+	n_fields = rec_offs_n_fields(offsets);
+
+	for (i = 0; i < n_fields; i++) {
+		if (rec_offs_nth_extern(offsets, i)) {
+			ulint	len;
+			byte*	data
+				= rec_get_nth_field(rec, offsets, i, &len);
+			ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+			btr_free_externally_stored_field(
+				index, data + len - BTR_EXTERN_FIELD_REF_SIZE,
+				rec, offsets, page_zip, i, rb_ctx, mtr);
+		}
+	}
+}
+
+/***************************************************************
+Frees the externally stored fields for a record, if the field is mentioned
+in the update vector. */
+static
+void
+btr_rec_free_updated_extern_fields(
+/*===============================*/
+	dict_index_t*	index,	/* in: index of rec; the index tree MUST be
+				X-latched */
+	rec_t*		rec,	/* in/out: record */
+	page_zip_des_t*	page_zip,/* in: compressed page whose uncompressed
+				part will be updated, or NULL */
+	const ulint*	offsets,/* in: rec_get_offsets(rec, index) */
+	const upd_t*	update,	/* in: update vector */
+	enum trx_rb_ctx	rb_ctx,	/* in: rollback context */
+	mtr_t*		mtr)	/* in: mini-transaction handle which contains
+				an X-latch to record page and to the tree */
+{
+	ulint	n_fields;
+	ulint	i;
+
+	ut_ad(rec_offs_validate(rec, index, offsets));
+	ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX));
+
+	/* Free possible externally stored fields in the record */
+
+	n_fields = upd_get_n_fields(update);
+
+	for (i = 0; i < n_fields; i++) {
+		const upd_field_t* ufield = upd_get_nth_field(update, i);
+
+		if (rec_offs_nth_extern(offsets, ufield->field_no)) {
+			ulint	len;
+			byte*	data = rec_get_nth_field(
+				rec, offsets, ufield->field_no, &len);
+			ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+			btr_free_externally_stored_field(
+				index, data + len - BTR_EXTERN_FIELD_REF_SIZE,
+				rec, offsets, page_zip,
+				ufield->field_no, rb_ctx, mtr);
+		}
+	}
+}
+
+/***********************************************************************
+Copies the prefix of an uncompressed BLOB.  The clustered index record
+that points to this BLOB must be protected by a lock or a page latch. */
+static
+ulint
+btr_copy_blob_prefix(
+/*=================*/
+				/* out: number of bytes written to buf */
+	byte*		buf,	/* out: the externally stored part of
+				the field, or a prefix of it */
+	ulint		len,	/* in: length of buf, in bytes */
+	ulint		space_id,/* in: space id of the BLOB pages */
+	ulint		page_no,/* in: page number of the first BLOB page */
+	ulint		offset)	/* in: offset on the first BLOB page */
+{
+	ulint	copied_len	= 0;
+
+	for (;;) {
+		mtr_t		mtr;
+		buf_block_t*	block;
+		const page_t*	page;
+		const byte*	blob_header;
+		ulint		part_len;
+		ulint		copy_len;
+
+		mtr_start(&mtr);
+
+		block = buf_page_get(space_id, 0, page_no, RW_S_LATCH, &mtr);
+		buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
+		page = buf_block_get_frame(block);
+
+		btr_check_blob_fil_page_type(space_id, page_no, page, TRUE);
+
+		blob_header = page + offset;
+		part_len = btr_blob_get_part_len(blob_header);
+		copy_len = ut_min(part_len, len - copied_len);
+
+		memcpy(buf + copied_len,
+		       blob_header + BTR_BLOB_HDR_SIZE, copy_len);
+		copied_len += copy_len;
+
+		page_no = btr_blob_get_next_page_no(blob_header);
+
+		mtr_commit(&mtr);
+
+		if (page_no == FIL_NULL || copy_len != part_len) {
+			return(copied_len);
+		}
+
+		/* On other BLOB pages except the first the BLOB header
+		always is at the page data start: */
+
+		offset = FIL_PAGE_DATA;
+
+		ut_ad(copied_len <= len);
+	}
+}
+
+/***********************************************************************
+Copies the prefix of a compressed BLOB.  The clustered index record
+that points to this BLOB must be protected by a lock or a page latch. */
+static
+void
+btr_copy_zblob_prefix(
+/*==================*/
+	z_stream*	d_stream,/* in/out: the decompressing stream */
+	ulint		zip_size,/* in: compressed BLOB page size */
+	ulint		space_id,/* in: space id of the BLOB pages */
+	ulint		page_no,/* in: page number of the first BLOB page */
+	ulint		offset)	/* in: offset on the first BLOB page */
+{
+	ulint	page_type = FIL_PAGE_TYPE_ZBLOB;
+
+	ut_ad(ut_is_2pow(zip_size));
+	ut_ad(zip_size >= PAGE_ZIP_MIN_SIZE);
+	ut_ad(zip_size <= UNIV_PAGE_SIZE);
+	ut_ad(space_id);
+
+	for (;;) {
+		buf_page_t*	bpage;
+		int		err;
+		ulint		next_page_no;
+
+		/* There is no latch on bpage directly.  Instead,
+		bpage is protected by the B-tree page latch that
+		is being held on the clustered index record, or,
+		in row_merge_copy_blobs(), by an exclusive table lock. */
+		bpage = buf_page_get_zip(space_id, zip_size, page_no);
+
+		if (UNIV_UNLIKELY(!bpage)) {
+			ut_print_timestamp(stderr);
+			fprintf(stderr,
+				"  InnoDB: Cannot load"
+				" compressed BLOB"
+				" page %lu space %lu\n",
+				(ulong) page_no, (ulong) space_id);
+			return;
+		}
+
+		if (UNIV_UNLIKELY
+		    (fil_page_get_type(bpage->zip.data) != page_type)) {
+			ut_print_timestamp(stderr);
+			fprintf(stderr,
+				"  InnoDB: Unexpected type %lu of"
+				" compressed BLOB"
+				" page %lu space %lu\n",
+				(ulong) fil_page_get_type(bpage->zip.data),
+				(ulong) page_no, (ulong) space_id);
+			goto end_of_blob;
+		}
+
+		next_page_no = mach_read_from_4(bpage->zip.data + offset);
+
+		if (UNIV_LIKELY(offset == FIL_PAGE_NEXT)) {
+			/* When the BLOB begins at page header,
+			the compressed data payload does not
+			immediately follow the next page pointer. */
+			offset = FIL_PAGE_DATA;
+		} else {
+			offset += 4;
+		}
+
+		d_stream->next_in = bpage->zip.data + offset;
+		d_stream->avail_in = zip_size - offset;
+
+		err = inflate(d_stream, Z_NO_FLUSH);
+		switch (err) {
+		case Z_OK:
+			if (!d_stream->avail_out) {
+				goto end_of_blob;
+			}
+			break;
+		case Z_STREAM_END:
+			if (next_page_no == FIL_NULL) {
+				goto end_of_blob;
+			}
+			/* fall through */
+		default:
+inflate_error:
+			ut_print_timestamp(stderr);
+			fprintf(stderr,
+				"  InnoDB: inflate() of"
+				" compressed BLOB"
+				" page %lu space %lu returned %d (%s)\n",
+				(ulong) page_no, (ulong) space_id,
+				err, d_stream->msg);
+		case Z_BUF_ERROR:
+			goto end_of_blob;
+		}
+
+		if (next_page_no == FIL_NULL) {
+			if (!d_stream->avail_in) {
+				ut_print_timestamp(stderr);
+				fprintf(stderr,
+					"  InnoDB: unexpected end of"
+					" compressed BLOB"
+					" page %lu space %lu\n",
+					(ulong) page_no,
+					(ulong) space_id);
+			} else {
+				err = inflate(d_stream, Z_FINISH);
+				switch (err) {
+				case Z_STREAM_END:
+				case Z_BUF_ERROR:
+					break;
+				default:
+					goto inflate_error;
+				}
+			}
+
+end_of_blob:
+			buf_page_release_zip(bpage);
+			return;
+		}
+
+		buf_page_release_zip(bpage);
+
+		/* On other BLOB pages except the first
+		the BLOB header always is at the page header: */
+
+		page_no = next_page_no;
+		offset = FIL_PAGE_NEXT;
+		page_type = FIL_PAGE_TYPE_ZBLOB2;
+	}
+}
+
+/***********************************************************************
+Copies the prefix of an externally stored field of a record.  The
+clustered index record that points to this BLOB must be protected by a
+lock or a page latch. */
+static
+ulint
+btr_copy_externally_stored_field_prefix_low(
+/*========================================*/
+				/* out: number of bytes written to buf */
+	byte*		buf,	/* out: the externally stored part of
+				the field, or a prefix of it */
+	ulint		len,	/* in: length of buf, in bytes */
+	ulint		zip_size,/* in: nonzero=compressed BLOB page size,
+				zero for uncompressed BLOBs */
+	ulint		space_id,/* in: space id of the first BLOB page */
+	ulint		page_no,/* in: page number of the first BLOB page */
+	ulint		offset)	/* in: offset on the first BLOB page */
+{
+	if (UNIV_UNLIKELY(len == 0)) {
+		return(0);
+	}
+
+	if (UNIV_UNLIKELY(zip_size)) {
+		int		err;
+		z_stream	d_stream;
+		mem_heap_t*	heap;
+
+		/* Zlib inflate needs 32 kilobytes for the default
+		window size, plus a few kilobytes for small objects. */
+		heap = mem_heap_create(40000);
+		page_zip_set_alloc(&d_stream, heap);
+
+		err = inflateInit(&d_stream);
+		ut_a(err == Z_OK);
+
+		d_stream.next_out = buf;
+		d_stream.avail_out = len;
+		d_stream.avail_in = 0;
+
+		btr_copy_zblob_prefix(&d_stream, zip_size,
+				      space_id, page_no, offset);
+		inflateEnd(&d_stream);
+		mem_heap_free(heap);
+		return(d_stream.total_out);
+	} else {
+		return(btr_copy_blob_prefix(buf, len, space_id,
+					    page_no, offset));
+	}
+}
+
+/***********************************************************************
+Copies the prefix of an externally stored field of a record.  The
+clustered index record must be protected by a lock or a page latch. */
+UNIV_INTERN
+ulint
+btr_copy_externally_stored_field_prefix(
+/*====================================*/
+				/* out: the length of the copied field,
+				or 0 if the column was being or has been
+				deleted */
+	byte*		buf,	/* out: the field, or a prefix of it */
+	ulint		len,	/* in: length of buf, in bytes */
+	ulint		zip_size,/* in: nonzero=compressed BLOB page size,
+				zero for uncompressed BLOBs */
+	const byte*	data,	/* in: 'internally' stored part of the
+				field containing also the reference to
+				the external part; must be protected by
+				a lock or a page latch */
+	ulint		local_len)/* in: length of data, in bytes */
+{
+	ulint	space_id;
+	ulint	page_no;
+	ulint	offset;
+
+	ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+	local_len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+	if (UNIV_UNLIKELY(local_len >= len)) {
+		memcpy(buf, data, len);
+		return(len);
+	}
+
+	memcpy(buf, data, local_len);
+	data += local_len;
+
+	ut_a(memcmp(data, field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE));
+
+	if (!mach_read_from_4(data + BTR_EXTERN_LEN + 4)) {
+		/* The externally stored part of the column has been
+		(partially) deleted.  Signal the half-deleted BLOB
+		to the caller. */
+
+		return(0);
+	}
+
+	space_id = mach_read_from_4(data + BTR_EXTERN_SPACE_ID);
+
+	page_no = mach_read_from_4(data + BTR_EXTERN_PAGE_NO);
+
+	offset = mach_read_from_4(data + BTR_EXTERN_OFFSET);
+
+	return(local_len
+	       + btr_copy_externally_stored_field_prefix_low(buf + local_len,
+							     len - local_len,
+							     zip_size,
+							     space_id, page_no,
+							     offset));
+}
+
+/***********************************************************************
+Copies an externally stored field of a record to mem heap.  The
+clustered index record must be protected by a lock or a page latch. */
+static
+byte*
+btr_copy_externally_stored_field(
+/*=============================*/
+				/* out: the whole field copied to heap */
+	ulint*		len,	/* out: length of the whole field */
+	const byte*	data,	/* in: 'internally' stored part of the
+				field containing also the reference to
+				the external part; must be protected by
+				a lock or a page latch */
+	ulint		zip_size,/* in: nonzero=compressed BLOB page size,
+				zero for uncompressed BLOBs */
+	ulint		local_len,/* in: length of data */
+	mem_heap_t*	heap)	/* in: mem heap */
+{
+	ulint	space_id;
+	ulint	page_no;
+	ulint	offset;
+	ulint	extern_len;
+	byte*	buf;
+
+	ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+	local_len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+	space_id = mach_read_from_4(data + local_len + BTR_EXTERN_SPACE_ID);
+
+	page_no = mach_read_from_4(data + local_len + BTR_EXTERN_PAGE_NO);
+
+	offset = mach_read_from_4(data + local_len + BTR_EXTERN_OFFSET);
+
+	/* Currently a BLOB cannot be bigger than 4 GB; we
+	leave the 4 upper bytes in the length field unused */
+
+	extern_len = mach_read_from_4(data + local_len + BTR_EXTERN_LEN + 4);
+
+	buf = mem_heap_alloc(heap, local_len + extern_len);
+
+	memcpy(buf, data, local_len);
+	*len = local_len
+		+ btr_copy_externally_stored_field_prefix_low(buf + local_len,
+							      extern_len,
+							      zip_size,
+							      space_id,
+							      page_no, offset);
+
+	return(buf);
+}
+
+/***********************************************************************
+Copies an externally stored field of a record to mem heap. */
+UNIV_INTERN
+byte*
+btr_rec_copy_externally_stored_field(
+/*=================================*/
+				/* out: the field copied to heap */
+	const rec_t*	rec,	/* in: record in a clustered index;
+				must be protected by a lock or a page latch */
+	const ulint*	offsets,/* in: array returned by rec_get_offsets() */
+	ulint		zip_size,/* in: nonzero=compressed BLOB page size,
+				zero for uncompressed BLOBs */
+	ulint		no,	/* in: field number */
+	ulint*		len,	/* out: length of the field */
+	mem_heap_t*	heap)	/* in: mem heap */
+{
+	ulint		local_len;
+	const byte*	data;
+
+	ut_a(rec_offs_nth_extern(offsets, no));
+
+	/* An externally stored field can contain some initial
+	data from the field, and in the last 20 bytes it has the
+	space id, page number, and offset where the rest of the
+	field data is stored, and the data length in addition to
+	the data stored locally. We may need to store some data
+	locally to get the local record length above the 128 byte
+	limit so that field offsets are stored in two bytes, and
+	the extern bit is available in those two bytes. */
+
+	data = rec_get_nth_field(rec, offsets, no, &local_len);
+
+	return(btr_copy_externally_stored_field(len, data,
+						zip_size, local_len, heap));
+}

=== added file 'storage/xtradb/btr/btr0pcur.c'
--- a/storage/xtradb/btr/btr0pcur.c	1970-01-01 00:00:00 +0000
+++ b/storage/xtradb/btr/btr0pcur.c	2009-03-26 06:11:11 +0000
@@ -0,0 +1,584 @@
+/*****************************************************************************
+
+Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/******************************************************
+The index tree persistent cursor
+
+Created 2/23/1996 Heikki Tuuri
+*******************************************************/
+
+#include "btr0pcur.h"
+
+#ifdef UNIV_NONINL
+#include "btr0pcur.ic"
+#endif
+
+#include "ut0byte.h"
+#include "rem0cmp.h"
+#include "trx0trx.h"
+
+/******************************************************************
+Allocates memory for a persistent cursor object and initializes the cursor. */
+UNIV_INTERN
+btr_pcur_t*
+btr_pcur_create_for_mysql(void)
+/*============================*/
+				/* out, own: persistent cursor */
+{
+	btr_pcur_t*	pcur;
+
+	pcur = mem_alloc(sizeof(btr_pcur_t));
+
+	pcur->btr_cur.index = NULL;
+	btr_pcur_init(pcur);
+
+	return(pcur);
+}
+
+/******************************************************************
+Frees the memory for a persistent cursor object. */
+UNIV_INTERN
+void
+btr_pcur_free_for_mysql(
+/*====================*/
+	btr_pcur_t*	cursor)	/* in, own: persistent cursor */
+{
+	if (cursor->old_rec_buf != NULL) {
+
+		mem_free(cursor->old_rec_buf);
+
+		cursor->old_rec_buf = NULL;
+	}
+
+	cursor->btr_cur.page_cur.rec = NULL;
+	cursor->old_rec = NULL;
+	cursor->old_n_fields = 0;
+	cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
+
+	cursor->latch_mode = BTR_NO_LATCHES;
+	cursor->pos_state = BTR_PCUR_NOT_POSITIONED;
+
+	mem_free(cursor);
+}
+
+/******************************************************************
+The position of the cursor is stored by taking an initial segment of the
+record the cursor is positioned on, before, or after, and copying it to the
+cursor data structure, or just setting a flag if the cursor id before the
+first in an EMPTY tree, or after the last in an EMPTY tree. NOTE that the
+page where the cursor is positioned must not be empty if the index tree is
+not totally empty! */
+UNIV_INTERN
+void
+btr_pcur_store_position(
+/*====================*/
+	btr_pcur_t*	cursor, /* in: persistent cursor */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	page_cur_t*	page_cursor;
+	buf_block_t*	block;
+	rec_t*		rec;
+	dict_index_t*	index;
+	page_t*		page;
+	ulint		offs;
+
+	ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
+	ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
+
+	block = btr_pcur_get_block(cursor);
+	index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
+
+	page_cursor = btr_pcur_get_page_cur(cursor);
+
+	rec = page_cur_get_rec(page_cursor);
+	page = page_align(rec);
+	offs = page_offset(rec);
+
+	ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_S_FIX)
+	      || mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+	ut_a(cursor->latch_mode != BTR_NO_LATCHES);
+
+	if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) {
+		/* It must be an empty index tree; NOTE that in this case
+		we do not store the modify_clock, but always do a search
+		if we restore the cursor position */
+
+		ut_a(btr_page_get_next(page, mtr) == FIL_NULL);
+		ut_a(btr_page_get_prev(page, mtr) == FIL_NULL);
+
+		cursor->old_stored = BTR_PCUR_OLD_STORED;
+
+		if (page_rec_is_supremum_low(offs)) {
+
+			cursor->rel_pos = BTR_PCUR_AFTER_LAST_IN_TREE;
+		} else {
+			cursor->rel_pos = BTR_PCUR_BEFORE_FIRST_IN_TREE;
+		}
+
+		return;
+	}
+
+	if (page_rec_is_supremum_low(offs)) {
+
+		rec = page_rec_get_prev(rec);
+
+		cursor->rel_pos = BTR_PCUR_AFTER;
+
+	} else if (page_rec_is_infimum_low(offs)) {
+
+		rec = page_rec_get_next(rec);
+
+		cursor->rel_pos = BTR_PCUR_BEFORE;
+	} else {
+		cursor->rel_pos = BTR_PCUR_ON;
+	}
+
+	cursor->old_stored = BTR_PCUR_OLD_STORED;
+	cursor->old_rec = dict_index_copy_rec_order_prefix(
+		index, rec, &cursor->old_n_fields,
+		&cursor->old_rec_buf, &cursor->buf_size);
+
+	cursor->block_when_stored = block;
+	cursor->modify_clock = buf_block_get_modify_clock(block);
+}
+
+/******************************************************************
+Copies the stored position of a pcur to another pcur. */
+UNIV_INTERN
+void
+btr_pcur_copy_stored_position(
+/*==========================*/
+	btr_pcur_t*	pcur_receive,	/* in: pcur which will receive the
+					position info */
+	btr_pcur_t*	pcur_donate)	/* in: pcur from which the info is
+					copied */
+{
+	if (pcur_receive->old_rec_buf) {
+		mem_free(pcur_receive->old_rec_buf);
+	}
+
+	ut_memcpy(pcur_receive, pcur_donate, sizeof(btr_pcur_t));
+
+	if (pcur_donate->old_rec_buf) {
+
+		pcur_receive->old_rec_buf = mem_alloc(pcur_donate->buf_size);
+
+		ut_memcpy(pcur_receive->old_rec_buf, pcur_donate->old_rec_buf,
+			  pcur_donate->buf_size);
+		pcur_receive->old_rec = pcur_receive->old_rec_buf
+			+ (pcur_donate->old_rec - pcur_donate->old_rec_buf);
+	}
+
+	pcur_receive->old_n_fields = pcur_donate->old_n_fields;
+}
+
+/******************************************************************
+Restores the stored position of a persistent cursor bufferfixing the page and
+obtaining the specified latches. If the cursor position was saved when the
+(1) cursor was positioned on a user record: this function restores the position
+to the last record LESS OR EQUAL to the stored record;
+(2) cursor was positioned on a page infimum record: restores the position to
+the last record LESS than the user record which was the successor of the page
+infimum;
+(3) cursor was positioned on the page supremum: restores to the first record
+GREATER than the user record which was the predecessor of the supremum.
+(4) cursor was positioned before the first or after the last in an empty tree:
+restores to before first or after the last in the tree. */
+UNIV_INTERN
+ibool
+btr_pcur_restore_position(
+/*======================*/
+					/* out: TRUE if the cursor position
+					was stored when it was on a user record
+					and it can be restored on a user record
+					whose ordering fields are identical to
+					the ones of the original user record */
+	ulint		latch_mode,	/* in: BTR_SEARCH_LEAF, ... */
+	btr_pcur_t*	cursor,		/* in: detached persistent cursor */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	dict_index_t*	index;
+	dtuple_t*	tuple;
+	ulint		mode;
+	ulint		old_mode;
+	mem_heap_t*	heap;
+
+	index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
+
+	if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED)
+	    || UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED
+			     && cursor->pos_state != BTR_PCUR_IS_POSITIONED)) {
+		ut_print_buf(stderr, cursor, sizeof(btr_pcur_t));
+		putc('\n', stderr);
+		if (cursor->trx_if_known) {
+			trx_print(stderr, cursor->trx_if_known, 0);
+		}
+
+		ut_error;
+	}
+
+	if (UNIV_UNLIKELY
+	    (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
+	     || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) {
+
+		/* In these cases we do not try an optimistic restoration,
+		but always do a search */
+
+		btr_cur_open_at_index_side(
+			cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
+			index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr);
+
+		cursor->block_when_stored = btr_pcur_get_block(cursor);
+
+		return(FALSE);
+	}
+
+	ut_a(cursor->old_rec);
+	ut_a(cursor->old_n_fields);
+
+	if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF)
+	    || UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) {
+		/* Try optimistic restoration */
+
+		if (UNIV_LIKELY(buf_page_optimistic_get(
+					latch_mode,
+					cursor->block_when_stored,
+					cursor->modify_clock, mtr))) {
+			cursor->pos_state = BTR_PCUR_IS_POSITIONED;
+
+			buf_block_dbg_add_level(btr_pcur_get_block(cursor),
+						SYNC_TREE_NODE);
+
+			if (cursor->rel_pos == BTR_PCUR_ON) {
+#ifdef UNIV_DEBUG
+				const rec_t*	rec;
+				const ulint*	offsets1;
+				const ulint*	offsets2;
+#endif /* UNIV_DEBUG */
+				cursor->latch_mode = latch_mode;
+#ifdef UNIV_DEBUG
+				rec = btr_pcur_get_rec(cursor);
+
+				heap = mem_heap_create(256);
+				offsets1 = rec_get_offsets(
+					cursor->old_rec, index, NULL,
+					cursor->old_n_fields, &heap);
+				offsets2 = rec_get_offsets(
+					rec, index, NULL,
+					cursor->old_n_fields, &heap);
+
+				ut_ad(!cmp_rec_rec(cursor->old_rec,
+						   rec, offsets1, offsets2,
+						   index));
+				mem_heap_free(heap);
+#endif /* UNIV_DEBUG */
+				return(TRUE);
+			}
+
+			return(FALSE);
+		}
+	}
+
+	/* If optimistic restoration did not succeed, open the cursor anew */
+
+	heap = mem_heap_create(256);
+
+	tuple = dict_index_build_data_tuple(index, cursor->old_rec,
+					    cursor->old_n_fields, heap);
+
+	/* Save the old search mode of the cursor */
+	old_mode = cursor->search_mode;
+
+	if (UNIV_LIKELY(cursor->rel_pos == BTR_PCUR_ON)) {
+		mode = PAGE_CUR_LE;
+	} else if (cursor->rel_pos == BTR_PCUR_AFTER) {
+		mode = PAGE_CUR_G;
+	} else {
+		ut_ad(cursor->rel_pos == BTR_PCUR_BEFORE);
+		mode = PAGE_CUR_L;
+	}
+
+	btr_pcur_open_with_no_init(index, tuple, mode, latch_mode,
+				   cursor, 0, mtr);
+
+	/* Restore the old search mode */
+	cursor->search_mode = old_mode;
+
+	if (cursor->rel_pos == BTR_PCUR_ON
+	    && btr_pcur_is_on_user_rec(cursor)
+	    && 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor),
+				   rec_get_offsets(
+					   btr_pcur_get_rec(cursor), index,
+					   NULL, ULINT_UNDEFINED, &heap))) {
+
+		/* We have to store the NEW value for the modify clock, since
+		the cursor can now be on a different page! But we can retain
+		the value of old_rec */
+
+		cursor->block_when_stored = btr_pcur_get_block(cursor);
+		cursor->modify_clock = buf_block_get_modify_clock(
+			cursor->block_when_stored);
+		cursor->old_stored = BTR_PCUR_OLD_STORED;
+
+		mem_heap_free(heap);
+
+		return(TRUE);
+	}
+
+	mem_heap_free(heap);
+
+	/* We have to store new position information, modify_clock etc.,
+	to the cursor because it can now be on a different page, the record
+	under it may have been removed, etc. */
+
+	btr_pcur_store_position(cursor, mtr);
+
+	return(FALSE);
+}
+
+/******************************************************************
+If the latch mode of the cursor is BTR_LEAF_SEARCH or BTR_LEAF_MODIFY,
+releases the page latch and bufferfix reserved by the cursor.
+NOTE! In the case of BTR_LEAF_MODIFY, there should not exist changes
+made by the current mini-transaction to the data protected by the
+cursor latch, as then the latch must not be released until mtr_commit. */
+UNIV_INTERN
+void
+btr_pcur_release_leaf(
+/*==================*/
+	btr_pcur_t*	cursor, /* in: persistent cursor */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	buf_block_t*	block;
+
+	ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
+	ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
+
+	block = btr_pcur_get_block(cursor);
+
+	btr_leaf_page_release(block, cursor->latch_mode, mtr);
+
+	cursor->latch_mode = BTR_NO_LATCHES;
+
+	cursor->pos_state = BTR_PCUR_WAS_POSITIONED;
+}
+
+/*************************************************************
+Moves the persistent cursor to the first record on the next page. Releases the
+latch on the current page, and bufferunfixes it. Note that there must not be
+modifications on the current page, as then the x-latch can be released only in
+mtr_commit. */
+UNIV_INTERN
+void
+btr_pcur_move_to_next_page(
+/*=======================*/
+	btr_pcur_t*	cursor,	/* in: persistent cursor; must be on the
+				last record of the current page */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ulint		next_page_no;
+	ulint		space;
+	ulint		zip_size;
+	page_t*		page;
+	buf_block_t*	next_block;
+	page_t*		next_page;
+
+	ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
+	ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
+	ut_ad(btr_pcur_is_after_last_on_page(cursor));
+
+	cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
+
+	page = btr_pcur_get_page(cursor);
+	next_page_no = btr_page_get_next(page, mtr);
+	space = buf_block_get_space(btr_pcur_get_block(cursor));
+	zip_size = buf_block_get_zip_size(btr_pcur_get_block(cursor));
+
+	ut_ad(next_page_no != FIL_NULL);
+
+	next_block = btr_block_get(space, zip_size, next_page_no,
+				   cursor->latch_mode, mtr);
+	next_page = buf_block_get_frame(next_block);
+#ifdef UNIV_BTR_DEBUG
+	ut_a(page_is_comp(next_page) == page_is_comp(page));
+	ut_a(btr_page_get_prev(next_page, mtr)
+	     == buf_block_get_page_no(btr_pcur_get_block(cursor)));
+#endif /* UNIV_BTR_DEBUG */
+	next_block->check_index_page_at_flush = TRUE;
+
+	btr_leaf_page_release(btr_pcur_get_block(cursor),
+			      cursor->latch_mode, mtr);
+
+	page_cur_set_before_first(next_block, btr_pcur_get_page_cur(cursor));
+
+	page_check_dir(next_page);
+}
+
+/*************************************************************
+Moves the persistent cursor backward if it is on the first record of the page.
+Commits mtr. Note that to prevent a possible deadlock, the operation
+first stores the position of the cursor, commits mtr, acquires the necessary
+latches and restores the cursor position again before returning. The
+alphabetical position of the cursor is guaranteed to be sensible on
+return, but it may happen that the cursor is not positioned on the last
+record of any page, because the structure of the tree may have changed
+during the time when the cursor had no latches. */
+UNIV_INTERN
+void
+btr_pcur_move_backward_from_page(
+/*=============================*/
+	btr_pcur_t*	cursor,	/* in: persistent cursor, must be on the first
+				record of the current page */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ulint		prev_page_no;
+	ulint		space;
+	page_t*		page;
+	buf_block_t*	prev_block;
+	ulint		latch_mode;
+	ulint		latch_mode2;
+
+	ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
+	ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
+	ut_ad(btr_pcur_is_before_first_on_page(cursor));
+	ut_ad(!btr_pcur_is_before_first_in_tree(cursor, mtr));
+
+	latch_mode = cursor->latch_mode;
+
+	if (latch_mode == BTR_SEARCH_LEAF) {
+
+		latch_mode2 = BTR_SEARCH_PREV;
+
+	} else if (latch_mode == BTR_MODIFY_LEAF) {
+
+		latch_mode2 = BTR_MODIFY_PREV;
+	} else {
+		latch_mode2 = 0; /* To eliminate compiler warning */
+		ut_error;
+	}
+
+	btr_pcur_store_position(cursor, mtr);
+
+	mtr_commit(mtr);
+
+	mtr_start(mtr);
+
+	btr_pcur_restore_position(latch_mode2, cursor, mtr);
+
+	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)) {
+
+		prev_block = btr_pcur_get_btr_cur(cursor)->left_block;
+
+		btr_leaf_page_release(btr_pcur_get_block(cursor),
+				      latch_mode, mtr);
+
+		page_cur_set_after_last(prev_block,
+					btr_pcur_get_page_cur(cursor));
+	} else {
+
+		/* The repositioned cursor did not end on an infimum record on
+		a page. Cursor repositioning acquired a latch also on the
+		previous page, but we do not need the latch: release it. */
+
+		prev_block = btr_pcur_get_btr_cur(cursor)->left_block;
+
+		btr_leaf_page_release(prev_block, latch_mode, mtr);
+	}
+
+	cursor->latch_mode = latch_mode;
+
+	cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
+}
+
+/*************************************************************
+Moves the persistent cursor to the previous record in the tree. If no records
+are left, the cursor stays 'before first in tree'. */
+UNIV_INTERN
+ibool
+btr_pcur_move_to_prev(
+/*==================*/
+				/* out: TRUE if the cursor was not before first
+				in tree */
+	btr_pcur_t*	cursor,	/* in: persistent cursor; NOTE that the
+				function may release the page latch */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
+	ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
+
+	cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
+
+	if (btr_pcur_is_before_first_on_page(cursor)) {
+
+		if (btr_pcur_is_before_first_in_tree(cursor, mtr)) {
+
+			return(FALSE);
+		}
+
+		btr_pcur_move_backward_from_page(cursor, mtr);
+
+		return(TRUE);
+	}
+
+	btr_pcur_move_to_prev_on_page(cursor);
+
+	return(TRUE);
+}
+
+/******************************************************************
+If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first
+user record satisfying the search condition, in the case PAGE_CUR_L or
+PAGE_CUR_LE, on the last user record. If no such user record exists, then
+in the first case sets the cursor after last in tree, and in the latter case
+before first in tree. The latching mode must be BTR_SEARCH_LEAF or
+BTR_MODIFY_LEAF. */
+UNIV_INTERN
+void
+btr_pcur_open_on_user_rec(
+/*======================*/
+	dict_index_t*	index,		/* in: index */
+	const dtuple_t*	tuple,		/* in: tuple on which search done */
+	ulint		mode,		/* in: PAGE_CUR_L, ... */
+	ulint		latch_mode,	/* in: BTR_SEARCH_LEAF or
+					BTR_MODIFY_LEAF */
+	btr_pcur_t*	cursor,		/* in: memory buffer for persistent
+					cursor */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	btr_pcur_open(index, tuple, mode, latch_mode, cursor, mtr);
+
+	if ((mode == PAGE_CUR_GE) || (mode == PAGE_CUR_G)) {
+
+		if (btr_pcur_is_after_last_on_page(cursor)) {
+
+			btr_pcur_move_to_next_user_rec(cursor, mtr);
+		}
+	} else {
+		ut_ad((mode == PAGE_CUR_LE) || (mode == PAGE_CUR_L));
+
+		/* Not implemented yet */
+
+		ut_error;
+	}
+}

=== added file 'storage/xtradb/btr/btr0sea.c'
--- a/storage/xtradb/btr/btr0sea.c	1970-01-01 00:00:00 +0000
+++ b/storage/xtradb/btr/btr0sea.c	2009-05-04 02:45:47 +0000
@@ -0,0 +1,1872 @@
+/*****************************************************************************
+
+Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 2008, Google Inc.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/************************************************************************
+The index tree adaptive search
+
+Created 2/17/1996 Heikki Tuuri
+*************************************************************************/
+
+#include "btr0sea.h"
+#ifdef UNIV_NONINL
+#include "btr0sea.ic"
+#endif
+
+#include "buf0buf.h"
+#include "page0page.h"
+#include "page0cur.h"
+#include "btr0cur.h"
+#include "btr0pcur.h"
+#include "btr0btr.h"
+#include "ha0ha.h"
+
+/* Flag: has the search system been enabled?
+Protected by btr_search_latch and btr_search_enabled_mutex. */
+UNIV_INTERN char		btr_search_enabled	= TRUE;
+
+static mutex_t			btr_search_enabled_mutex;
+
+/* A dummy variable to fool the compiler */
+UNIV_INTERN ulint		btr_search_this_is_zero = 0;
+
+#ifdef UNIV_SEARCH_PERF_STAT
+UNIV_INTERN ulint		btr_search_n_succ	= 0;
+UNIV_INTERN ulint		btr_search_n_hash_fail	= 0;
+#endif /* UNIV_SEARCH_PERF_STAT */
+
+/* padding to prevent other memory update
+hotspots from residing on the same memory
+cache line as btr_search_latch */
+UNIV_INTERN byte		btr_sea_pad1[64];
+
+/* The latch protecting the adaptive search system: this latch protects the
+(1) positions of records on those pages where a hash index has been built.
+NOTE: It does not protect values of non-ordering fields within a record from
+being updated in-place! We can use fact (1) to perform unique searches to
+indexes. */
+
+/* We will allocate the latch from dynamic memory to get it to the
+same DRAM page as other hotspot semaphores */
+UNIV_INTERN rw_lock_t*		btr_search_latch_temp;
+
+/* padding to prevent other memory update hotspots from residing on
+the same memory cache line */
+UNIV_INTERN byte		btr_sea_pad2[64];
+
+UNIV_INTERN btr_search_sys_t*	btr_search_sys;
+
+/* If the number of records on the page divided by this parameter
+would have been successfully accessed using a hash index, the index
+is then built on the page, assuming the global limit has been reached */
+
+#define BTR_SEARCH_PAGE_BUILD_LIMIT	16
+
+/* The global limit for consecutive potentially successful hash searches,
+before hash index building is started */
+
+#define BTR_SEARCH_BUILD_LIMIT		100
+
+/************************************************************************
+Builds a hash index on a page with the given parameters. If the page already
+has a hash index with different parameters, the old hash index is removed.
+If index is non-NULL, this function checks if n_fields and n_bytes are
+sensible values, and does not build a hash index if not. */
+static
+void
+btr_search_build_page_hash_index(
+/*=============================*/
+	dict_index_t*	index,	/* in: index for which to build, or NULL if
+				not known */
+	buf_block_t*	block,	/* in: index page, s- or x-latched */
+	ulint		n_fields,/* in: hash this many full fields */
+	ulint		n_bytes,/* in: hash this many bytes from the next
+				field */
+	ibool		left_side);/* in: hash for searches from left side? */
+
+/*********************************************************************
+This function should be called before reserving any btr search mutex, if
+the intended operation might add nodes to the search system hash table.
+Because of the latching order, once we have reserved the btr search system
+latch, we cannot allocate a free frame from the buffer pool. Checks that
+there is a free buffer frame allocated for hash table heap in the btr search
+system. If not, allocates a free frames for the heap. This check makes it
+probable that, when have reserved the btr search system latch and we need to
+allocate a new node to the hash table, it will succeed. However, the check
+will not guarantee success. */
+static
+void
+btr_search_check_free_space_in_heap(void)
+/*=====================================*/
+{
+	hash_table_t*	table;
+	mem_heap_t*	heap;
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	table = btr_search_sys->hash_index;
+
+	heap = table->heap;
+
+	/* Note that we peek the value of heap->free_block without reserving
+	the latch: this is ok, because we will not guarantee that there will
+	be enough free space in the hash table. */
+
+	if (heap->free_block == NULL) {
+		buf_block_t*	block = buf_block_alloc(0);
+
+		rw_lock_x_lock(&btr_search_latch);
+
+		if (heap->free_block == NULL) {
+			heap->free_block = block;
+		} else {
+			buf_block_free(block);
+		}
+
+		rw_lock_x_unlock(&btr_search_latch);
+	}
+}
+
+/*********************************************************************
+Creates and initializes the adaptive search system at a database start. */
+UNIV_INTERN
+void
+btr_search_sys_create(
+/*==================*/
+	ulint	hash_size)	/* in: hash index hash table size */
+{
+	/* We allocate the search latch from dynamic memory:
+	see above at the global variable definition */
+
+	btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t));
+
+	rw_lock_create(&btr_search_latch, SYNC_SEARCH_SYS);
+	mutex_create(&btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF);
+
+	btr_search_sys = mem_alloc(sizeof(btr_search_sys_t));
+
+	btr_search_sys->hash_index = ha_create(hash_size, 0, 0);
+}
+
+/************************************************************************
+Disable the adaptive hash search system and empty the index. */
+UNIV_INTERN
+void
+btr_search_disable(void)
+/*====================*/
+{
+	mutex_enter(&btr_search_enabled_mutex);
+	rw_lock_x_lock(&btr_search_latch);
+
+	btr_search_enabled = FALSE;
+
+	/* Clear all block->is_hashed flags and remove all entries
+	from btr_search_sys->hash_index. */
+	buf_pool_drop_hash_index();
+
+	/* btr_search_enabled_mutex should guarantee this. */
+	ut_ad(!btr_search_enabled);
+
+	rw_lock_x_unlock(&btr_search_latch);
+	mutex_exit(&btr_search_enabled_mutex);
+}
+
+/************************************************************************
+Enable the adaptive hash search system. */
+UNIV_INTERN
+void
+btr_search_enable(void)
+/*====================*/
+{
+	mutex_enter(&btr_search_enabled_mutex);
+	rw_lock_x_lock(&btr_search_latch);
+
+	btr_search_enabled = TRUE;
+
+	rw_lock_x_unlock(&btr_search_latch);
+	mutex_exit(&btr_search_enabled_mutex);
+}
+
+/*********************************************************************
+Creates and initializes a search info struct. */
+UNIV_INTERN
+btr_search_t*
+btr_search_info_create(
+/*===================*/
+				/* out, own: search info struct */
+	mem_heap_t*	heap)	/* in: heap where created */
+{
+	btr_search_t*	info;
+
+	info = mem_heap_alloc(heap, sizeof(btr_search_t));
+
+#ifdef UNIV_DEBUG
+	info->magic_n = BTR_SEARCH_MAGIC_N;
+#endif /* UNIV_DEBUG */
+
+	info->ref_count = 0;
+	info->root_guess = NULL;
+
+	info->hash_analysis = 0;
+	info->n_hash_potential = 0;
+
+	info->last_hash_succ = FALSE;
+
+#ifdef UNIV_SEARCH_PERF_STAT
+	info->n_hash_succ = 0;
+	info->n_hash_fail = 0;
+	info->n_patt_succ = 0;
+	info->n_searches = 0;
+#endif /* UNIV_SEARCH_PERF_STAT */
+
+	/* Set some sensible values */
+	info->n_fields = 1;
+	info->n_bytes = 0;
+
+	info->left_side = TRUE;
+
+	return(info);
+}
+
+/*********************************************************************
+Returns the value of ref_count. The value is protected by
+btr_search_latch. */
+UNIV_INTERN
+ulint
+btr_search_info_get_ref_count(
+/*==========================*/
+				/* out: ref_count value. */
+	btr_search_t*   info)	/* in: search info. */
+{
+	ulint ret;
+
+	ut_ad(info);
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	rw_lock_s_lock(&btr_search_latch);
+	ret = info->ref_count;
+	rw_lock_s_unlock(&btr_search_latch);
+
+	return(ret);
+}
+
+/*************************************************************************
+Updates the search info of an index about hash successes. NOTE that info
+is NOT protected by any semaphore, to save CPU time! Do not assume its fields
+are consistent. */
+static
+void
+btr_search_info_update_hash(
+/*========================*/
+	btr_search_t*	info,	/* in/out: search info */
+	btr_cur_t*	cursor)	/* in: cursor which was just positioned */
+{
+	dict_index_t*	index;
+	ulint		n_unique;
+	int		cmp;
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	index = cursor->index;
+
+	if (dict_index_is_ibuf(index)) {
+		/* So many deletes are performed on an insert buffer tree
+		that we do not consider a hash index useful on it: */
+
+		return;
+	}
+
+	n_unique = dict_index_get_n_unique_in_tree(index);
+
+	if (info->n_hash_potential == 0) {
+
+		goto set_new_recomm;
+	}
+
+	/* Test if the search would have succeeded using the recommended
+	hash prefix */
+
+	if (info->n_fields >= n_unique && cursor->up_match >= n_unique) {
+increment_potential:
+		info->n_hash_potential++;
+
+		return;
+	}
+
+	cmp = ut_pair_cmp(info->n_fields, info->n_bytes,
+			  cursor->low_match, cursor->low_bytes);
+
+	if (info->left_side ? cmp <= 0 : cmp > 0) {
+
+		goto set_new_recomm;
+	}
+
+	cmp = ut_pair_cmp(info->n_fields, info->n_bytes,
+			  cursor->up_match, cursor->up_bytes);
+
+	if (info->left_side ? cmp <= 0 : cmp > 0) {
+
+		goto increment_potential;
+	}
+
+set_new_recomm:
+	/* We have to set a new recommendation; skip the hash analysis
+	for a while to avoid unnecessary CPU time usage when there is no
+	chance for success */
+
+	info->hash_analysis = 0;
+
+	cmp = ut_pair_cmp(cursor->up_match, cursor->up_bytes,
+			  cursor->low_match, cursor->low_bytes);
+	if (cmp == 0) {
+		info->n_hash_potential = 0;
+
+		/* For extra safety, we set some sensible values here */
+
+		info->n_fields = 1;
+		info->n_bytes = 0;
+
+		info->left_side = TRUE;
+
+	} else if (cmp > 0) {
+		info->n_hash_potential = 1;
+
+		if (cursor->up_match >= n_unique) {
+
+			info->n_fields = n_unique;
+			info->n_bytes = 0;
+
+		} else if (cursor->low_match < cursor->up_match) {
+
+			info->n_fields = cursor->low_match + 1;
+			info->n_bytes = 0;
+		} else {
+			info->n_fields = cursor->low_match;
+			info->n_bytes = cursor->low_bytes + 1;
+		}
+
+		info->left_side = TRUE;
+	} else {
+		info->n_hash_potential = 1;
+
+		if (cursor->low_match >= n_unique) {
+
+			info->n_fields = n_unique;
+			info->n_bytes = 0;
+
+		} else if (cursor->low_match > cursor->up_match) {
+
+			info->n_fields = cursor->up_match + 1;
+			info->n_bytes = 0;
+		} else {
+			info->n_fields = cursor->up_match;
+			info->n_bytes = cursor->up_bytes + 1;
+		}
+
+		info->left_side = FALSE;
+	}
+}
+
+/*************************************************************************
+Updates the block search info on hash successes. NOTE that info and
+block->n_hash_helps, n_fields, n_bytes, side are NOT protected by any
+semaphore, to save CPU time! Do not assume the fields are consistent. */
+static
+ibool
+btr_search_update_block_hash_info(
+/*==============================*/
+				/* out: TRUE if building a (new) hash index on
+				the block is recommended */
+	btr_search_t*	info,	/* in: search info */
+	buf_block_t*	block,	/* in: buffer block */
+	btr_cur_t*	cursor __attribute__((unused)))
+				/* in: cursor */
+{
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+	ut_ad(rw_lock_own(&block->lock, RW_LOCK_SHARED)
+	      || rw_lock_own(&block->lock, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(cursor);
+
+	info->last_hash_succ = FALSE;
+
+	ut_a(buf_block_state_valid(block));
+	ut_ad(info->magic_n == BTR_SEARCH_MAGIC_N);
+
+	if ((block->n_hash_helps > 0)
+	    && (info->n_hash_potential > 0)
+	    && (block->n_fields == info->n_fields)
+	    && (block->n_bytes == info->n_bytes)
+	    && (block->left_side == info->left_side)) {
+
+		if ((block->is_hashed)
+		    && (block->curr_n_fields == info->n_fields)
+		    && (block->curr_n_bytes == info->n_bytes)
+		    && (block->curr_left_side == info->left_side)) {
+
+			/* The search would presumably have succeeded using
+			the hash index */
+
+			info->last_hash_succ = TRUE;
+		}
+
+		block->n_hash_helps++;
+	} else {
+		block->n_hash_helps = 1;
+		block->n_fields = info->n_fields;
+		block->n_bytes = info->n_bytes;
+		block->left_side = info->left_side;
+	}
+
+#ifdef UNIV_DEBUG
+	if (cursor->index->table->does_not_fit_in_memory) {
+		block->n_hash_helps = 0;
+	}
+#endif /* UNIV_DEBUG */
+
+	if ((block->n_hash_helps > page_get_n_recs(block->frame)
+	     / BTR_SEARCH_PAGE_BUILD_LIMIT)
+	    && (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) {
+
+		if ((!block->is_hashed)
+		    || (block->n_hash_helps
+			> 2 * page_get_n_recs(block->frame))
+		    || (block->n_fields != block->curr_n_fields)
+		    || (block->n_bytes != block->curr_n_bytes)
+		    || (block->left_side != block->curr_left_side)) {
+
+			/* Build a new hash index on the page */
+
+			return(TRUE);
+		}
+	}
+
+	return(FALSE);
+}
+
+/*************************************************************************
+Updates a hash node reference when it has been unsuccessfully used in a
+search which could have succeeded with the used hash parameters. This can
+happen because when building a hash index for a page, we do not check
+what happens at page boundaries, and therefore there can be misleading
+hash nodes. Also, collisions in the fold value can lead to misleading
+references. This function lazily fixes these imperfections in the hash
+index. */
+static
+void
+btr_search_update_hash_ref(
+/*=======================*/
+	btr_search_t*	info,	/* in: search info */
+	buf_block_t*	block,	/* in: buffer block where cursor positioned */
+	btr_cur_t*	cursor)	/* in: cursor */
+{
+	ulint	fold;
+	rec_t*	rec;
+	dulint	index_id;
+
+	ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+	ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
+	      || rw_lock_own(&(block->lock), RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+	ut_ad(page_align(btr_cur_get_rec(cursor))
+	      == buf_block_get_frame(block));
+
+	if (!block->is_hashed) {
+
+		return;
+	}
+
+	ut_a(block->index == cursor->index);
+	ut_a(!dict_index_is_ibuf(cursor->index));
+
+	if ((info->n_hash_potential > 0)
+	    && (block->curr_n_fields == info->n_fields)
+	    && (block->curr_n_bytes == info->n_bytes)
+	    && (block->curr_left_side == info->left_side)) {
+		mem_heap_t*	heap		= NULL;
+		ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+		rec_offs_init(offsets_);
+
+		rec = btr_cur_get_rec(cursor);
+
+		if (!page_rec_is_user_rec(rec)) {
+
+			return;
+		}
+
+		index_id = cursor->index->id;
+		fold = rec_fold(rec,
+				rec_get_offsets(rec, cursor->index, offsets_,
+						ULINT_UNDEFINED, &heap),
+				block->curr_n_fields,
+				block->curr_n_bytes, index_id);
+		if (UNIV_LIKELY_NULL(heap)) {
+			mem_heap_free(heap);
+		}
+#ifdef UNIV_SYNC_DEBUG
+		ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+		ha_insert_for_fold(btr_search_sys->hash_index, fold,
+				   block, rec);
+	}
+}
+
+/*************************************************************************
+Updates the search info. */
+UNIV_INTERN
+void
+btr_search_info_update_slow(
+/*========================*/
+	btr_search_t*	info,	/* in/out: search info */
+	btr_cur_t*	cursor)	/* in: cursor which was just positioned */
+{
+	buf_block_t*	block;
+	ibool		build_index;
+	ulint*		params;
+	ulint*		params2;
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	block = btr_cur_get_block(cursor);
+
+	/* NOTE that the following two function calls do NOT protect
+	info or block->n_fields etc. with any semaphore, to save CPU time!
+	We cannot assume the fields are consistent when we return from
+	those functions! */
+
+	btr_search_info_update_hash(info, cursor);
+
+	build_index = btr_search_update_block_hash_info(info, block, cursor);
+
+	if (build_index || (cursor->flag == BTR_CUR_HASH_FAIL)) {
+
+		btr_search_check_free_space_in_heap();
+	}
+
+	if (cursor->flag == BTR_CUR_HASH_FAIL) {
+		/* Update the hash node reference, if appropriate */
+
+#ifdef UNIV_SEARCH_PERF_STAT
+		btr_search_n_hash_fail++;
+#endif /* UNIV_SEARCH_PERF_STAT */
+
+		rw_lock_x_lock(&btr_search_latch);
+
+		btr_search_update_hash_ref(info, block, cursor);
+
+		rw_lock_x_unlock(&btr_search_latch);
+	}
+
+	if (build_index) {
+		/* Note that since we did not protect block->n_fields etc.
+		with any semaphore, the values can be inconsistent. We have
+		to check inside the function call that they make sense. We
+		also malloc an array and store the values there to make sure
+		the compiler does not let the function call parameters change
+		inside the called function. It might be that the compiler
+		would optimize the call just to pass pointers to block. */
+
+		params = mem_alloc(3 * sizeof(ulint));
+		params[0] = block->n_fields;
+		params[1] = block->n_bytes;
+		params[2] = block->left_side;
+
+		/* Make sure the compiler cannot deduce the values and do
+		optimizations */
+
+		params2 = params + btr_search_this_is_zero;
+
+		btr_search_build_page_hash_index(cursor->index,
+						 block,
+						 params2[0],
+						 params2[1],
+						 params2[2]);
+		mem_free(params);
+	}
+}
+
+/**********************************************************************
+Checks if a guessed position for a tree cursor is right. Note that if
+mode is PAGE_CUR_LE, which is used in inserts, and the function returns
+TRUE, then cursor->up_match and cursor->low_match both have sensible values. */
+static
+ibool
+btr_search_check_guess(
+/*===================*/
+				/* out: TRUE if success */
+	btr_cur_t*	cursor,	/* in: guessed cursor position */
+	ibool		can_only_compare_to_cursor_rec,
+				/* in: if we do not have a latch on the page
+				of cursor, but only a latch on
+				btr_search_latch, then ONLY the columns
+				of the record UNDER the cursor are
+				protected, not the next or previous record
+				in the chain: we cannot look at the next or
+				previous record to check our guess! */
+	const dtuple_t*	tuple,	/* in: data tuple */
+	ulint		mode,	/* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
+				or PAGE_CUR_GE */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	rec_t*		rec;
+	ulint		n_unique;
+	ulint		match;
+	ulint		bytes;
+	int		cmp;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	ibool		success		= FALSE;
+	rec_offs_init(offsets_);
+
+	n_unique = dict_index_get_n_unique_in_tree(cursor->index);
+
+	rec = btr_cur_get_rec(cursor);
+
+	ut_ad(page_rec_is_user_rec(rec));
+
+	match = 0;
+	bytes = 0;
+
+	offsets = rec_get_offsets(rec, cursor->index, offsets,
+				  n_unique, &heap);
+	cmp = page_cmp_dtuple_rec_with_match(tuple, rec,
+					     offsets, &match, &bytes);
+
+	if (mode == PAGE_CUR_GE) {
+		if (cmp == 1) {
+			goto exit_func;
+		}
+
+		cursor->up_match = match;
+
+		if (match >= n_unique) {
+			success = TRUE;
+			goto exit_func;
+		}
+	} else if (mode == PAGE_CUR_LE) {
+		if (cmp == -1) {
+			goto exit_func;
+		}
+
+		cursor->low_match = match;
+
+	} else if (mode == PAGE_CUR_G) {
+		if (cmp != -1) {
+			goto exit_func;
+		}
+	} else if (mode == PAGE_CUR_L) {
+		if (cmp != 1) {
+			goto exit_func;
+		}
+	}
+
+	if (can_only_compare_to_cursor_rec) {
+		/* Since we could not determine if our guess is right just by
+		looking at the record under the cursor, return FALSE */
+		goto exit_func;
+	}
+
+	match = 0;
+	bytes = 0;
+
+	if ((mode == PAGE_CUR_G) || (mode == PAGE_CUR_GE)) {
+		rec_t*	prev_rec;
+
+		ut_ad(!page_rec_is_infimum(rec));
+
+		prev_rec = page_rec_get_prev(rec);
+
+		if (page_rec_is_infimum(prev_rec)) {
+			success = btr_page_get_prev(page_align(prev_rec), mtr)
+				== FIL_NULL;
+
+			goto exit_func;
+		}
+
+		offsets = rec_get_offsets(prev_rec, cursor->index, offsets,
+					  n_unique, &heap);
+		cmp = page_cmp_dtuple_rec_with_match(tuple, prev_rec,
+						     offsets, &match, &bytes);
+		if (mode == PAGE_CUR_GE) {
+			success = cmp == 1;
+		} else {
+			success = cmp != -1;
+		}
+
+		goto exit_func;
+	} else {
+		rec_t*	next_rec;
+
+		ut_ad(!page_rec_is_supremum(rec));
+
+		next_rec = page_rec_get_next(rec);
+
+		if (page_rec_is_supremum(next_rec)) {
+			if (btr_page_get_next(page_align(next_rec), mtr)
+			    == FIL_NULL) {
+
+				cursor->up_match = 0;
+				success = TRUE;
+			}
+
+			goto exit_func;
+		}
+
+		offsets = rec_get_offsets(next_rec, cursor->index, offsets,
+					  n_unique, &heap);
+		cmp = page_cmp_dtuple_rec_with_match(tuple, next_rec,
+						     offsets, &match, &bytes);
+		if (mode == PAGE_CUR_LE) {
+			success = cmp == -1;
+			cursor->up_match = match;
+		} else {
+			success = cmp != 1;
+		}
+	}
+exit_func:
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+	return(success);
+}
+
+/**********************************************************************
+Tries to guess the right search position based on the hash search info
+of the index. Note that if mode is PAGE_CUR_LE, which is used in inserts,
+and the function returns TRUE, then cursor->up_match and cursor->low_match
+both have sensible values. */
+UNIV_INTERN
+ibool
+btr_search_guess_on_hash(
+/*=====================*/
+					/* out: TRUE if succeeded */
+	dict_index_t*	index,		/* in: index */
+	btr_search_t*	info,		/* in: index search info */
+	const dtuple_t*	tuple,		/* in: logical record */
+	ulint		mode,		/* in: PAGE_CUR_L, ... */
+	ulint		latch_mode,	/* in: BTR_SEARCH_LEAF, ...;
+					NOTE that only if has_search_latch
+					is 0, we will have a latch set on
+					the cursor page, otherwise we assume
+					the caller uses his search latch
+					to protect the record! */
+	btr_cur_t*	cursor,		/* out: tree cursor */
+	ulint		has_search_latch,/* in: latch mode the caller
+					currently has on btr_search_latch:
+					RW_S_LATCH, RW_X_LATCH, or 0 */
+	mtr_t*		mtr)		/* in: mtr */
+{
+	buf_block_t*	block;
+	rec_t*		rec;
+	ulint		fold;
+	dulint		index_id;
+#ifdef notdefined
+	btr_cur_t	cursor2;
+	btr_pcur_t	pcur;
+#endif
+	ut_ad(index && info && tuple && cursor && mtr);
+	ut_ad((latch_mode == BTR_SEARCH_LEAF)
+	      || (latch_mode == BTR_MODIFY_LEAF));
+
+	/* Note that, for efficiency, the struct info may not be protected by
+	any latch here! */
+
+	if (UNIV_UNLIKELY(info->n_hash_potential == 0)) {
+
+		return(FALSE);
+	}
+
+	cursor->n_fields = info->n_fields;
+	cursor->n_bytes = info->n_bytes;
+
+	if (UNIV_UNLIKELY(dtuple_get_n_fields(tuple)
+			  < cursor->n_fields + (cursor->n_bytes > 0))) {
+
+		return(FALSE);
+	}
+
+	index_id = index->id;
+
+#ifdef UNIV_SEARCH_PERF_STAT
+	info->n_hash_succ++;
+#endif
+	fold = dtuple_fold(tuple, cursor->n_fields, cursor->n_bytes, index_id);
+
+	cursor->fold = fold;
+	cursor->flag = BTR_CUR_HASH;
+
+	if (UNIV_LIKELY(!has_search_latch)) {
+		rw_lock_s_lock(&btr_search_latch);
+
+		if (UNIV_UNLIKELY(!btr_search_enabled)) {
+			goto failure_unlock;
+		}
+	}
+
+	ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX);
+	ut_ad(rw_lock_get_reader_count(&btr_search_latch) > 0);
+
+	rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
+
+	if (UNIV_UNLIKELY(!rec)) {
+		goto failure_unlock;
+	}
+
+	block = buf_block_align(rec);
+
+	if (UNIV_LIKELY(!has_search_latch)) {
+
+		if (UNIV_UNLIKELY(
+			    !buf_page_get_known_nowait(latch_mode, block,
+						       BUF_MAKE_YOUNG,
+						       __FILE__, __LINE__,
+						       mtr))) {
+			goto failure_unlock;
+		}
+
+		rw_lock_s_unlock(&btr_search_latch);
+
+		buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
+	}
+
+	if (UNIV_UNLIKELY(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE)) {
+		ut_ad(buf_block_get_state(block) == BUF_BLOCK_REMOVE_HASH);
+
+		if (UNIV_LIKELY(!has_search_latch)) {
+
+			btr_leaf_page_release(block, latch_mode, mtr);
+		}
+
+		goto failure;
+	}
+
+	ut_ad(page_rec_is_user_rec(rec));
+
+	btr_cur_position(index, rec, block, cursor);
+
+	/* Check the validity of the guess within the page */
+
+	/* If we only have the latch on btr_search_latch, not on the
+	page, it only protects the columns of the record the cursor
+	is positioned on. We cannot look at the next of the previous
+	record to determine if our guess for the cursor position is
+	right. */
+	if (UNIV_EXPECT
+	    (ut_dulint_cmp(index_id, btr_page_get_index_id(block->frame)), 0)
+	    || !btr_search_check_guess(cursor,
+				       has_search_latch,
+				       tuple, mode, mtr)) {
+		if (UNIV_LIKELY(!has_search_latch)) {
+			btr_leaf_page_release(block, latch_mode, mtr);
+		}
+
+		goto failure;
+	}
+
+	if (UNIV_LIKELY(info->n_hash_potential < BTR_SEARCH_BUILD_LIMIT + 5)) {
+
+		info->n_hash_potential++;
+	}
+
+#ifdef notdefined
+	/* These lines of code can be used in a debug version to check
+	the correctness of the searched cursor position: */
+
+	info->last_hash_succ = FALSE;
+
+	/* Currently, does not work if the following fails: */
+	ut_ad(!has_search_latch);
+
+	btr_leaf_page_release(block, latch_mode, mtr);
+
+	btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode,
+				    &cursor2, 0, mtr);
+	if (mode == PAGE_CUR_GE
+	    && page_rec_is_supremum(btr_cur_get_rec(&cursor2))) {
+
+		/* If mode is PAGE_CUR_GE, then the binary search
+		in the index tree may actually take us to the supremum
+		of the previous page */
+
+		info->last_hash_succ = FALSE;
+
+		btr_pcur_open_on_user_rec(index, tuple, mode, latch_mode,
+					  &pcur, mtr);
+		ut_ad(btr_pcur_get_rec(&pcur) == btr_cur_get_rec(cursor));
+	} else {
+		ut_ad(btr_cur_get_rec(&cursor2) == btr_cur_get_rec(cursor));
+	}
+
+	/* NOTE that it is theoretically possible that the above assertions
+	fail if the page of the cursor gets removed from the buffer pool
+	meanwhile! Thus it might not be a bug. */
+#endif
+	info->last_hash_succ = TRUE;
+
+#ifdef UNIV_SEARCH_PERF_STAT
+	btr_search_n_succ++;
+#endif
+	if (UNIV_LIKELY(!has_search_latch)
+	    && buf_page_peek_if_too_old(&block->page)) {
+
+		buf_page_make_young(&block->page);
+	}
+
+	/* Increment the page get statistics though we did not really
+	fix the page: for user info only */
+
+	buf_pool->n_page_gets++;
+
+	return(TRUE);
+
+	/*-------------------------------------------*/
+failure_unlock:
+	if (UNIV_LIKELY(!has_search_latch)) {
+		rw_lock_s_unlock(&btr_search_latch);
+	}
+failure:
+	cursor->flag = BTR_CUR_HASH_FAIL;
+
+#ifdef UNIV_SEARCH_PERF_STAT
+	info->n_hash_fail++;
+
+	if (info->n_hash_succ > 0) {
+		info->n_hash_succ--;
+	}
+#endif
+	info->last_hash_succ = FALSE;
+
+	return(FALSE);
+}
+
+/************************************************************************
+Drops a page hash index. */
+UNIV_INTERN
+void
+btr_search_drop_page_hash_index(
+/*============================*/
+	buf_block_t*	block)	/* in: block containing index page,
+				s- or x-latched, or an index page
+				for which we know that
+				block->buf_fix_count == 0 */
+{
+	hash_table_t*		table;
+	ulint			n_fields;
+	ulint			n_bytes;
+	const page_t*		page;
+	const rec_t*		rec;
+	ulint			fold;
+	ulint			prev_fold;
+	dulint			index_id;
+	ulint			n_cached;
+	ulint			n_recs;
+	ulint*			folds;
+	ulint			i;
+	mem_heap_t*		heap;
+	const dict_index_t*	index;
+	ulint*			offsets;
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+retry:
+	rw_lock_s_lock(&btr_search_latch);
+	page = block->frame;
+
+	if (UNIV_LIKELY(!block->is_hashed)) {
+
+		rw_lock_s_unlock(&btr_search_latch);
+
+		return;
+	}
+
+	table = btr_search_sys->hash_index;
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
+	      || rw_lock_own(&(block->lock), RW_LOCK_EX)
+	      || (block->page.buf_fix_count == 0));
+#endif /* UNIV_SYNC_DEBUG */
+
+	n_fields = block->curr_n_fields;
+	n_bytes = block->curr_n_bytes;
+	index = block->index;
+	ut_a(!dict_index_is_ibuf(index));
+
+	/* NOTE: The fields of block must not be accessed after
+	releasing btr_search_latch, as the index page might only
+	be s-latched! */
+
+	rw_lock_s_unlock(&btr_search_latch);
+
+	ut_a(n_fields + n_bytes > 0);
+
+	n_recs = page_get_n_recs(page);
+
+	/* Calculate and cache fold values into an array for fast deletion
+	from the hash index */
+
+	folds = mem_alloc(n_recs * sizeof(ulint));
+
+	n_cached = 0;
+
+	rec = page_get_infimum_rec(page);
+	rec = page_rec_get_next_low(rec, page_is_comp(page));
+
+	index_id = btr_page_get_index_id(page);
+
+	ut_a(0 == ut_dulint_cmp(index_id, index->id));
+
+	prev_fold = 0;
+
+	heap = NULL;
+	offsets = NULL;
+
+	while (!page_rec_is_supremum(rec)) {
+		offsets = rec_get_offsets(rec, index, offsets,
+					  n_fields + (n_bytes > 0), &heap);
+		ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
+		fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
+
+		if (fold == prev_fold && prev_fold != 0) {
+
+			goto next_rec;
+		}
+
+		/* Remove all hash nodes pointing to this page from the
+		hash chain */
+
+		folds[n_cached] = fold;
+		n_cached++;
+next_rec:
+		rec = page_rec_get_next_low(rec, page_rec_is_comp(rec));
+		prev_fold = fold;
+	}
+
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+
+	rw_lock_x_lock(&btr_search_latch);
+
+	if (UNIV_UNLIKELY(!block->is_hashed)) {
+		/* Someone else has meanwhile dropped the hash index */
+
+		goto cleanup;
+	}
+
+	ut_a(block->index == index);
+
+	if (UNIV_UNLIKELY(block->curr_n_fields != n_fields)
+	    || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) {
+
+		/* Someone else has meanwhile built a new hash index on the
+		page, with different parameters */
+
+		rw_lock_x_unlock(&btr_search_latch);
+
+		mem_free(folds);
+		goto retry;
+	}
+
+	for (i = 0; i < n_cached; i++) {
+
+		ha_remove_all_nodes_to_page(table, folds[i], page);
+	}
+
+	ut_a(index->search_info->ref_count > 0);
+	index->search_info->ref_count--;
+
+	block->is_hashed = FALSE;
+	block->index = NULL;
+	
+cleanup:
+#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
+	if (UNIV_UNLIKELY(block->n_pointers)) {
+		/* Corruption */
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			"  InnoDB: Corruption of adaptive hash index."
+			" After dropping\n"
+			"InnoDB: the hash index to a page of %s,"
+			" still %lu hash nodes remain.\n",
+			index->name, (ulong) block->n_pointers);
+		rw_lock_x_unlock(&btr_search_latch);
+
+		btr_search_validate();
+	} else {
+		rw_lock_x_unlock(&btr_search_latch);
+	}
+#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+	rw_lock_x_unlock(&btr_search_latch);
+#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+
+	mem_free(folds);
+}
+
+/************************************************************************
+Drops a page hash index when a page is freed from a fseg to the file system.
+Drops possible hash index if the page happens to be in the buffer pool. */
+UNIV_INTERN
+void
+btr_search_drop_page_hash_when_freed(
+/*=================================*/
+	ulint	space,		/* in: space id */
+	ulint	zip_size,	/* in: compressed page size in bytes
+				or 0 for uncompressed pages */
+	ulint	page_no)	/* in: page number */
+{
+	buf_block_t*	block;
+	mtr_t		mtr;
+
+	if (!buf_page_peek_if_search_hashed(space, page_no)) {
+
+		return;
+	}
+
+	mtr_start(&mtr);
+
+	/* We assume that if the caller has a latch on the page, then the
+	caller has already dropped the hash index for the page, and we never
+	get here. Therefore we can acquire the s-latch to the page without
+	having to fear a deadlock. */
+
+	block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL,
+				BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
+				&mtr);
+	/* Because the buffer pool mutex was released by
+	buf_page_peek_if_search_hashed(), it is possible that the
+	block was removed from the buffer pool by another thread
+	before buf_page_get_gen() got a chance to acquire the buffer
+	pool mutex again.  Thus, we must check for a NULL return. */
+
+	if (UNIV_LIKELY(block != NULL)) {
+
+		buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
+
+		btr_search_drop_page_hash_index(block);
+	}
+
+	mtr_commit(&mtr);
+}
+
+/************************************************************************
+Builds a hash index on a page with the given parameters. If the page already
+has a hash index with different parameters, the old hash index is removed.
+If index is non-NULL, this function checks if n_fields and n_bytes are
+sensible values, and does not build a hash index if not. */
+static
+void
+btr_search_build_page_hash_index(
+/*=============================*/
+	dict_index_t*	index,	/* in: index for which to build */
+	buf_block_t*	block,	/* in: index page, s- or x-latched */
+	ulint		n_fields,/* in: hash this many full fields */
+	ulint		n_bytes,/* in: hash this many bytes from the next
+				field */
+	ibool		left_side)/* in: hash for searches from left side? */
+{
+	hash_table_t*	table;
+	page_t*		page;
+	rec_t*		rec;
+	rec_t*		next_rec;
+	ulint		fold;
+	ulint		next_fold;
+	dulint		index_id;
+	ulint		n_cached;
+	ulint		n_recs;
+	ulint*		folds;
+	rec_t**		recs;
+	ulint		i;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	rec_offs_init(offsets_);
+
+	ut_ad(index);
+	ut_a(!dict_index_is_ibuf(index));
+
+	table = btr_search_sys->hash_index;
+	page = buf_block_get_frame(block);
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
+	ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
+	      || rw_lock_own(&(block->lock), RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	rw_lock_s_lock(&btr_search_latch);
+
+	if (block->is_hashed && ((block->curr_n_fields != n_fields)
+				 || (block->curr_n_bytes != n_bytes)
+				 || (block->curr_left_side != left_side))) {
+
+		rw_lock_s_unlock(&btr_search_latch);
+
+		btr_search_drop_page_hash_index(block);
+	} else {
+		rw_lock_s_unlock(&btr_search_latch);
+	}
+
+	n_recs = page_get_n_recs(page);
+
+	if (n_recs == 0) {
+
+		return;
+	}
+
+	/* Check that the values for hash index build are sensible */
+
+	if (n_fields + n_bytes == 0) {
+
+		return;
+	}
+
+	if (dict_index_get_n_unique_in_tree(index) < n_fields
+	    || (dict_index_get_n_unique_in_tree(index) == n_fields
+		&& n_bytes > 0)) {
+		return;
+	}
+
+	/* Calculate and cache fold values and corresponding records into
+	an array for fast insertion to the hash index */
+
+	folds = mem_alloc(n_recs * sizeof(ulint));
+	recs = mem_alloc(n_recs * sizeof(rec_t*));
+
+	n_cached = 0;
+
+	index_id = btr_page_get_index_id(page);
+
+	rec = page_rec_get_next(page_get_infimum_rec(page));
+
+	offsets = rec_get_offsets(rec, index, offsets,
+				  n_fields + (n_bytes > 0), &heap);
+
+	if (!page_rec_is_supremum(rec)) {
+		ut_a(n_fields <= rec_offs_n_fields(offsets));
+
+		if (n_bytes > 0) {
+			ut_a(n_fields < rec_offs_n_fields(offsets));
+		}
+	}
+
+	fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
+
+	if (left_side) {
+
+		folds[n_cached] = fold;
+		recs[n_cached] = rec;
+		n_cached++;
+	}
+
+	for (;;) {
+		next_rec = page_rec_get_next(rec);
+
+		if (page_rec_is_supremum(next_rec)) {
+
+			if (!left_side) {
+
+				folds[n_cached] = fold;
+				recs[n_cached] = rec;
+				n_cached++;
+			}
+
+			break;
+		}
+
+		offsets = rec_get_offsets(next_rec, index, offsets,
+					  n_fields + (n_bytes > 0), &heap);
+		next_fold = rec_fold(next_rec, offsets, n_fields,
+				     n_bytes, index_id);
+
+		if (fold != next_fold) {
+			/* Insert an entry into the hash index */
+
+			if (left_side) {
+
+				folds[n_cached] = next_fold;
+				recs[n_cached] = next_rec;
+				n_cached++;
+			} else {
+				folds[n_cached] = fold;
+				recs[n_cached] = rec;
+				n_cached++;
+			}
+		}
+
+		rec = next_rec;
+		fold = next_fold;
+	}
+
+	btr_search_check_free_space_in_heap();
+
+	rw_lock_x_lock(&btr_search_latch);
+
+	if (UNIV_UNLIKELY(!btr_search_enabled)) {
+		goto exit_func;
+	}
+
+	if (block->is_hashed && ((block->curr_n_fields != n_fields)
+				 || (block->curr_n_bytes != n_bytes)
+				 || (block->curr_left_side != left_side))) {
+		goto exit_func;
+	}
+
+	/* This counter is decremented every time we drop page
+	hash index entries and is incremented here. Since we can
+	rebuild hash index for a page that is already hashed, we
+	have to take care not to increment the counter in that
+	case. */
+	if (!block->is_hashed) {
+		index->search_info->ref_count++;
+	}
+
+	block->is_hashed = TRUE;
+	block->n_hash_helps = 0;
+
+	block->curr_n_fields = n_fields;
+	block->curr_n_bytes = n_bytes;
+	block->curr_left_side = left_side;
+	block->index = index;
+
+	for (i = 0; i < n_cached; i++) {
+
+		ha_insert_for_fold(table, folds[i], block, recs[i]);
+	}
+
+exit_func:
+	rw_lock_x_unlock(&btr_search_latch);
+
+	mem_free(folds);
+	mem_free(recs);
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+}
+
+/************************************************************************
+Moves or deletes hash entries for moved records. If new_page is already hashed,
+then the hash index for page, if any, is dropped. If new_page is not hashed,
+and page is hashed, then a new hash index is built to new_page with the same
+parameters as page (this often happens when a page is split). */
+UNIV_INTERN
+void
+btr_search_move_or_delete_hash_entries(
+/*===================================*/
+	buf_block_t*	new_block,	/* in: records are copied
+					to this page */
+	buf_block_t*	block,		/* in: index page from which
+					records were copied, and the
+					copied records will be deleted
+					from this page */
+	dict_index_t*	index)		/* in: record descriptor */
+{
+	ulint	n_fields;
+	ulint	n_bytes;
+	ibool	left_side;
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
+	ut_ad(rw_lock_own(&(new_block->lock), RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+	ut_a(!new_block->is_hashed || new_block->index == index);
+	ut_a(!block->is_hashed || block->index == index);
+	ut_a(!(new_block->is_hashed || block->is_hashed)
+	     || !dict_index_is_ibuf(index));
+
+	rw_lock_s_lock(&btr_search_latch);
+
+	if (new_block->is_hashed) {
+
+		rw_lock_s_unlock(&btr_search_latch);
+
+		btr_search_drop_page_hash_index(block);
+
+		return;
+	}
+
+	if (block->is_hashed) {
+
+		n_fields = block->curr_n_fields;
+		n_bytes = block->curr_n_bytes;
+		left_side = block->curr_left_side;
+
+		new_block->n_fields = block->curr_n_fields;
+		new_block->n_bytes = block->curr_n_bytes;
+		new_block->left_side = left_side;
+
+		rw_lock_s_unlock(&btr_search_latch);
+
+		ut_a(n_fields + n_bytes > 0);
+
+		btr_search_build_page_hash_index(index, new_block, n_fields,
+						 n_bytes, left_side);
+		ut_ad(n_fields == block->curr_n_fields);
+		ut_ad(n_bytes == block->curr_n_bytes);
+		ut_ad(left_side == block->curr_left_side);
+		return;
+	}
+
+	rw_lock_s_unlock(&btr_search_latch);
+}
+
+/************************************************************************
+Updates the page hash index when a single record is deleted from a page. */
+UNIV_INTERN
+void
+btr_search_update_hash_on_delete(
+/*=============================*/
+	btr_cur_t*	cursor)	/* in: cursor which was positioned on the
+				record to delete using btr_cur_search_...,
+				the record is not yet deleted */
+{
+	hash_table_t*	table;
+	buf_block_t*	block;
+	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_);
+
+	rec = btr_cur_get_rec(cursor);
+
+	block = btr_cur_get_block(cursor);
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	if (!block->is_hashed) {
+
+		return;
+	}
+
+	ut_a(block->index == cursor->index);
+	ut_a(block->curr_n_fields + block->curr_n_bytes > 0);
+	ut_a(!dict_index_is_ibuf(cursor->index));
+
+	table = btr_search_sys->hash_index;
+
+	index_id = cursor->index->id;
+	fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_,
+					     ULINT_UNDEFINED, &heap),
+			block->curr_n_fields, block->curr_n_bytes, index_id);
+	if (UNIV_LIKELY_NULL(heap)) {
+		mem_heap_free(heap);
+	}
+	rw_lock_x_lock(&btr_search_latch);
+
+	found = ha_search_and_delete_if_found(table, fold, rec);
+
+	rw_lock_x_unlock(&btr_search_latch);
+}
+
+/************************************************************************
+Updates the page hash index when a single record is inserted on a page. */
+UNIV_INTERN
+void
+btr_search_update_hash_node_on_insert(
+/*==================================*/
+	btr_cur_t*	cursor)	/* in: cursor which was positioned to the
+				place to insert using btr_cur_search_...,
+				and the new record has been inserted next
+				to the cursor */
+{
+	hash_table_t*	table;
+	buf_block_t*	block;
+	rec_t*		rec;
+
+	rec = btr_cur_get_rec(cursor);
+
+	block = btr_cur_get_block(cursor);
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	if (!block->is_hashed) {
+
+		return;
+	}
+
+	ut_a(block->index == cursor->index);
+	ut_a(!dict_index_is_ibuf(cursor->index));
+
+	rw_lock_x_lock(&btr_search_latch);
+
+	if ((cursor->flag == BTR_CUR_HASH)
+	    && (cursor->n_fields == block->curr_n_fields)
+	    && (cursor->n_bytes == block->curr_n_bytes)
+	    && !block->curr_left_side) {
+
+		table = btr_search_sys->hash_index;
+
+		ha_search_and_update_if_found(table, cursor->fold, rec,
+					      block, page_rec_get_next(rec));
+
+		rw_lock_x_unlock(&btr_search_latch);
+	} else {
+		rw_lock_x_unlock(&btr_search_latch);
+
+		btr_search_update_hash_on_insert(cursor);
+	}
+}
+
+/************************************************************************
+Updates the page hash index when a single record is inserted on a page. */
+UNIV_INTERN
+void
+btr_search_update_hash_on_insert(
+/*=============================*/
+	btr_cur_t*	cursor)	/* in: cursor which was positioned to the
+				place to insert using btr_cur_search_...,
+				and the new record has been inserted next
+				to the cursor */
+{
+	hash_table_t*	table;
+	buf_block_t*	block;
+	rec_t*		rec;
+	rec_t*		ins_rec;
+	rec_t*		next_rec;
+	dulint		index_id;
+	ulint		fold;
+	ulint		ins_fold;
+	ulint		next_fold = 0; /* remove warning (??? bug ???) */
+	ulint		n_fields;
+	ulint		n_bytes;
+	ibool		left_side;
+	ibool		locked		= FALSE;
+	mem_heap_t*	heap		= NULL;
+	ulint		offsets_[REC_OFFS_NORMAL_SIZE];
+	ulint*		offsets		= offsets_;
+	rec_offs_init(offsets_);
+
+	table = btr_search_sys->hash_index;
+
+	btr_search_check_free_space_in_heap();
+
+	rec = btr_cur_get_rec(cursor);
+
+	block = btr_cur_get_block(cursor);
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	if (!block->is_hashed) {
+
+		return;
+	}
+
+	ut_a(block->index == cursor->index);
+	ut_a(!dict_index_is_ibuf(cursor->index));
+
+	index_id = cursor->index->id;
+
+	n_fields = block->curr_n_fields;
+	n_bytes = block->curr_n_bytes;
+	left_side = block->curr_left_side;
+
+	ins_rec = page_rec_get_next(rec);
+	next_rec = page_rec_get_next(ins_rec);
+
+	offsets = rec_get_offsets(ins_rec, cursor->index, offsets,
+				  ULINT_UNDEFINED, &heap);
+	ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, index_id);
+
+	if (!page_rec_is_supremum(next_rec)) {
+		offsets = rec_get_offsets(next_rec, cursor->index, offsets,
+					  n_fields + (n_bytes > 0), &heap);
+		next_fold = rec_fold(next_rec, offsets, n_fields,
+				     n_bytes, index_id);
+	}
+
+	if (!page_rec_is_infimum(rec)) {
+		offsets = rec_get_offsets(rec, cursor->index, offsets,
+					  n_fields + (n_bytes > 0), &heap);
+		fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
+	} else {
+		if (left_side) {
+
+			rw_lock_x_lock(&btr_search_latch);
+
+			locked = TRUE;
+
+			ha_insert_for_fold(table, ins_fold, block, ins_rec);
+		}
+
+		goto check_next_rec;
+	}
+
+	if (fold != ins_fold) {
+
+		if (!locked) {
+
+			rw_lock_x_lock(&btr_search_latch);
+
+			locked = TRUE;
+		}
+
+		if (!left_side) {
+			ha_insert_for_fold(table, fold, block, rec);
+		} else {
+			ha_insert_for_fold(table, ins_fold, block, ins_rec);
+		}
+	}
+
+check_next_rec:
+	if (page_rec_is_supremum(next_rec)) {
+
+		if (!left_side) {
+
+			if (!locked) {
+				rw_lock_x_lock(&btr_search_latch);
+
+				locked = TRUE;
+			}
+
+			ha_insert_for_fold(t