[Commits] Rev 2904: Merge in file:///home/igor/maria/maria-5.2-wl21/

Igor Babaev igor at askmonty.org
Sun Jan 23 08:22:09 EET 2011


At file:///home/igor/maria/maria-5.2-wl21/

------------------------------------------------------------
revno: 2904 [merge]
revision-id: igor at askmonty.org-20110123062204-hty0togiqrh4nmy7
parent: igor at askmonty.org-20101228194428-dg1kij4xpbol0luw
parent: sergii at pisem.net-20110120120046-b2s0ijw06f1ztn2f
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.2-wl21
timestamp: Sat 2011-01-22 22:22:04 -0800
message:
  Merge
added:
  mysql-test/include/have_xtradb.opt have_xtradb.opt-20101231091121-mqb91xvsy225jnaj-1
  mysql-test/include/long_test.inc long_test.inc-20101219230618-yw5bqqlbx3mltyvf-1
  mysql-test/r/mysqlbinlog-innodb.result mysqlbinloginnodb.re-20110113122817-3ronhbvs2cc6pf64-1
  mysql-test/suite/handler/      handler-20110110195753-v0ut2q32diiciq0l-1
  mysql-test/suite/handler/aria.result aria.result-20110110202255-0y5taa9x847d6os7-1
  mysql-test/suite/handler/aria.test aria.test-20110110202255-0y5taa9x847d6os7-2
  mysql-test/suite/handler/init.inc init.inc-20110110202255-0y5taa9x847d6os7-3
  mysql-test/suite/handler/interface.result interface.result-20110110202255-0y5taa9x847d6os7-4
  mysql-test/suite/handler/interface.test interface.test-20110110202306-yvttuyjos57x7jcm-1
  mysql-test/t/mysqlbinlog-innodb.test mysqlbinloginnodb.te-20110113122817-3ronhbvs2cc6pf64-2
renamed:
  mysql-test/include/handler.inc => mysql-test/suite/handler/handler.inc sp1f-handler.test-20010406221832-gfvg6n4rp4py6lunazzembziuu5qxvi5
  mysql-test/r/handler_innodb.result => mysql-test/suite/handler/innodb.result sp1f-innodb_handler.resul-20020821205505-jopsqbjuqwwxb5hvf3r2wn37vobunxru
  mysql-test/r/handler_myisam.result => mysql-test/suite/handler/myisam.result sp1f-handler.result-20010406221832-ybo3cgjo6qapqc6776ivjpdngwmk6plu
  mysql-test/t/handler_innodb.test => mysql-test/suite/handler/innodb.test sp1f-innodb_handler.test-20020821205505-gwqk7yb24jcfxay37a2svxwwoqq4ybdr
  mysql-test/t/handler_myisam.test => mysql-test/suite/handler/myisam.test sp1f-handler_myisam.test-20060816103641-ckpb4przkqjb63gycdafwpu6hkuus3rj
modified:
  BUILD/compile-pentium64        sp1f-compilepentium64-20060606172132-mo2kjf2iqzallfjpxv2rsxpwwiazofrr
  client/mysqlbinlog.cc          sp1f-mysqlbinlog.cc-19700101030959-b3vgyo47ljent5mhbyj6ik33bi4bukad
  configure.in                   sp1f-configure.in-19700101030959-mgdpoxtnh2ewmvusvfpkreuhwvffkcjw
  mysql-test/Makefile.am         sp1f-makefile.am-20001206082022-36vvdlhec52v4kcxab5ees7yomxvj4dl
  mysql-test/README              sp1f-readme-20001214012355-7qlz4k6bbi6gjhbnoehotrwdrmx5ncsm
  mysql-test/extra/rpl_tests/rpl_stop_slave.test rpl_stop_slave.test-20100921035747-b3ebrop80vldnkjw-1
  mysql-test/include/have_xtradb.inc have_xtradb.inc-20100803210901-rs1f342hr3r004e4-2
  mysql-test/lib/mtr_cases.pm    sp1f-mtr_cases.pl-20050203205008-rrteoawyobvgq6u7zeyce4tmuu334ayg
  mysql-test/mysql-test-run.pl   sp1f-mysqltestrun.pl-20041230152716-xjnn5ndv4rr4by6ijmj5a4ysubxc7qh3
  mysql-test/r/lock_multi.result sp1f-lock_multi.result-20011008015806-j56mw7cxenwk7wmwzgciunzotxn2oopp
  mysql-test/r/log_tables.result sp1f-log_tables.result-20060119025601-mp6o7xc6ybvlt3zc6j5kvlfvs6upl7aj
  mysql-test/r/plugin.result     sp1f-plugin.result-20061214230953-dljmjo3wuacc3eox3gwroufqmk3hlne7
  mysql-test/r/subselect.result  sp1f-subselect.result-20020512204640-zgegcsgavnfd7t7eyrf7ibuqomsw7uzo
  mysql-test/r/table_elim.result table_elim.result-20090603125022-nge13y0ohk1g2tt2-1
  mysql-test/r/table_options.result create_options.resul-20100408115745-s7sely6ivm7kfn40-1
  mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result binlog_row_mysqlbinl-20091016142045-b5fpf9tpydkmwy0i-2
  mysql-test/suite/federated/federated_debug.test federated_debug.test-20090930202805-kt19apxdz61tx0ln-1
  mysql-test/suite/innodb/r/innodb_mysql.result sp1f-innodb_mysql.result-20060426055153-bychbbfnqtvmvrwccwhn24i6yi46uqjv
  mysql-test/suite/innodb/t/innodb_mysql.test sp1f-innodb_mysql.test-20060816102624-6ymo37d3nyhvbqyzqn5ohsfuydwo426k
  mysql-test/suite/maria/r/maria.result sp1f-maria.result-20060411134403-xrrw2657ctr6et4vhmohpoev5ze42pti
  mysql-test/suite/maria/r/maria3.result maria3.result-20080701120735-95p69v855sl5nh1m-1
  mysql-test/suite/maria/t/maria-recovery-rtree-ft.test sp1f-mariarecoveryrtreeft-20080424152247-kenhqndeoiwuzg35ndwmgx3zhd3wguil
  mysql-test/suite/maria/t/maria.test sp1f-maria.test-20060411134404-s3la6iju5f4ypzjqoye6y5fnapridjtq
  mysql-test/suite/parts/t/partition_alter2_1_myisam.test sp1f-partition_alter2_myi-20070206122238-yz7u7rjz5kz6n4vjdn7s5t7kxnzkkamf
  mysql-test/suite/parts/t/partition_alter2_2_myisam.test partition_alter2_2_m-20080908140941-884mge0s10lxgki2-4
  mysql-test/suite/parts/t/partition_basic_innodb.test sp1f-partition_basic_inno-20070206122238-6o7mtftdh7bsyo3up576z5ng45jkkhed
  mysql-test/suite/parts/t/partition_decimal_myisam.test sp1f-partition_decimal_my-20070206122238-u4p66skn2bvpxlkcvxmg7nq3w3hesgap
  mysql-test/suite/parts/t/partition_float_myisam.test sp1f-partition_float_myis-20070206122238-y3756gr72yqmc3jk7kqz3sipo26xed63
  mysql-test/suite/parts/t/partition_int_myisam.test sp1f-partition_int_myisam-20070206122239-ybsivbmjemswkndkftgb42dramazlg5f
  mysql-test/suite/rpl/r/rpl_stop_slave.result rpl_stop_slave.resul-20100921035830-x9f98ow0rvuwnqi8-1
  mysql-test/suite/rpl/t/rpl_deadlock_innodb.test sp1f-rpl_deadlock_innodb.-20051222053459-5n5zbfansl5g5627c4w6kans2ximuoz7
  mysql-test/suite/rpl/t/rpl_row_sp003.test sp1f-rpl_row_sp003.test-20051222053504-gptfueg42ucmbkoo2ktvmf3molhsaop4
  mysql-test/suite/vcol/inc/vcol_unsupported_storage_engines.inc vcol_unsupported_sto-20091016212105-1lx2muao9vwbl1c1-19
  mysql-test/suite/vcol/r/vcol_archive.result vcol_archive.result-20091016212105-1lx2muao9vwbl1c1-22
  mysql-test/suite/vcol/r/vcol_blackhole.result vcol_blackhole.resul-20091016212105-1lx2muao9vwbl1c1-23
  mysql-test/suite/vcol/r/vcol_csv.result vcol_csv.result-20091016212105-1lx2muao9vwbl1c1-28
  mysql-test/suite/vcol/r/vcol_memory.result vcol_memory.result-20091016212105-1lx2muao9vwbl1c1-35
  mysql-test/suite/vcol/r/vcol_merge.result vcol_merge.result-20091016212105-1lx2muao9vwbl1c1-36
  mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result vcol_non_stored_colu-20091016212105-1lx2muao9vwbl1c1-37
  mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result vcol_non_stored_colu-20091016212105-1lx2muao9vwbl1c1-38
  mysql-test/suite/vcol/t/rpl_vcol.test rpl_vcol.test-20091016212105-1lx2muao9vwbl1c1-50
  mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test vcol_blocked_sql_fun-20091016212105-1lx2muao9vwbl1c1-53
  mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test vcol_column_def_opti-20091016212105-1lx2muao9vwbl1c1-55
  mysql-test/suite/vcol/t/vcol_csv.test vcol_csv.test-20091016212105-1lx2muao9vwbl1c1-57
  mysql-test/suite/vcol/t/vcol_handler_innodb.test vcol_handler_innodb.-20091016212105-1lx2muao9vwbl1c1-58
  mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test vcol_ins_upd_innodb.-20091016212105-1lx2muao9vwbl1c1-60
  mysql-test/suite/vcol/t/vcol_keys_innodb.test vcol_keys_innodb.tes-20091016212105-1lx2muao9vwbl1c1-62
  mysql-test/suite/vcol/t/vcol_merge.test vcol_merge.test-20091016212105-1lx2muao9vwbl1c1-65
  mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test vcol_non_stored_colu-20091016212105-1lx2muao9vwbl1c1-66
  mysql-test/suite/vcol/t/vcol_partition_innodb.test vcol_partition_innod-20091016212105-1lx2muao9vwbl1c1-68
  mysql-test/suite/vcol/t/vcol_select_innodb.test vcol_select_innodb.t-20091016212105-1lx2muao9vwbl1c1-70
  mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test vcol_supported_sql_f-20091016212105-1lx2muao9vwbl1c1-72
  mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test vcol_trigger_sp_inno-20091016212105-1lx2muao9vwbl1c1-75
  mysql-test/suite/vcol/t/vcol_view_innodb.test vcol_view_innodb.tes-20091016212105-1lx2muao9vwbl1c1-77
  mysql-test/t/join_outer.test   sp1f-join_outer.test-20001228015636-himrcptylaquy6l5d7pl7pawom3ytmtw
  mysql-test/t/lock_multi.test   sp1f-lock_multi.test-20011008015806-67rpwlsigaymaevma2l42r5edbtot3fp
  mysql-test/t/multi_update2.test multi_update2.test-20081119180936-l9ebanulh7kc1g8x-1
  mysql-test/t/pool_of_threads.test pool_of_threads.test-20090312215933-z80y68rnuw8o21yg-5
  mysql-test/t/query_cache.test  sp1f-query_cache.test-20011205230530-yfwho76ujeasygr3magwlmssnvwsukio
  mysql-test/t/subselect.test    sp1f-subselect.test-20020512204640-lyqrayx6uwsn7zih6y7kerkenuitzbvr
  mysql-test/t/table_elim.test   table_elim.test-20090603125018-ka3vcfrm07bsldz8-1
  mysql-test/valgrind.supp       sp1f-valgrind.supp-20050406142216-yg7xhezklqhgqlc3inx36vbghodhbovy
  mysys/tree.c                   sp1f-tree.c-19700101030959-febyd36tcwqmhiyrrcuaqate66xykgg3
  plugin/auth/dialog.c           dialog.c-20100213233925-2o1gpjsv01qognaq-4
  scripts/mysql_convert_table_format.sh sp1f-mysql_convert_table_-19700101030959-zspxf5zlxepnb55bflai7zse73yph2zh
  sql-common/client.c            sp1f-client.c-20030502160736-oraaciqy6jkfwygs6tqfoaxgjbi65yo7
  sql-common/client_plugin.c     client_plugin.c-20100213115856-ly45979t7c2voue1-1
  sql/ha_partition.h             sp1f-ha_partition.h-20050718113038-4xxwqkuu2xgxqtrwfbc43zgfyfcwzjsq
  sql/handler.cc                 sp1f-handler.cc-19700101030959-ta6zfrlbxzucylciyro3musjsdpocrdh
  sql/handler.h                  sp1f-handler.h-19700101030959-mumq2hpilkpgxuf22ftyv5kbilysnzvn
  sql/item.h                     sp1f-item.h-19700101030959-rrkb43htudd62batmoteashkebcwykpa
  sql/item_func.cc               sp1f-item_func.cc-19700101030959-3wmsx76yvc25sroqpfrx2n77kqdxxn3y
  sql/item_func.h                sp1f-item_func.h-19700101030959-fbjcbwkg66qubbzptqwh5w5evhnpukze
  sql/share/errmsg.txt           sp1f-errmsg.txt-20041213212820-do5w642w224ja7ctyqhyl6iihdmpkzv5
  sql/sql_handler.cc             sp1f-sql_handler.cc-20010406221833-l4tsiortoyipmoyajcoz2tcdppvyeltl
  sql/sql_parse.cc               sp1f-sql_parse.cc-19700101030959-ehcre3rwhv5l3mlxqhaxg36ujenxnrcd
  sql/sql_plugin_services.h      sql_plugin_services.-20100228160908-qfuxjw8mp0bdlmzs-6
  sql/sql_select.cc              sp1f-sql_select.cc-19700101030959-egb7whpkh76zzvikycs5nsnuviu4fdlb
  sql/sql_table.cc               sp1f-sql_table.cc-19700101030959-tzdkvgigezpuaxnldqh3fx2h7h2ggslu
  sql/table.cc                   sp1f-table.cc-19700101030959-nsxtem2adyqzwe6nz4cgrpcmts3o54v7
  sql/table.h                    sp1f-table.h-19700101030959-dv72bajftxj5fbdjuajquappanuv2ija
  storage/federated/ha_federated.cc sp1f-ha_federated.cc-20041211200120-gu52ex5sicbua5vtoocuki3ltllsvm2c
  storage/ibmdb2i/db2i_ioBuffers.h db2i_iobuffers.h-20090215021022-15ov21fvravqaicb-21
  storage/innodb_plugin/trx/trx0sys.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0sys.c
  storage/maria/ha_maria.cc      sp1f-ha_maria.cc-20060411134405-dmngb4v5x5fxlxhff527ud3etiutxuxk
  storage/maria/ha_maria.h       sp1f-ha_maria.h-20060411134405-vvsjodaugfqw4mekr3sxxnj26gukxxuo
  storage/maria/ma_bitmap.c      sp1f-ma_bitmap.c-20070118193810-dcdqg6iu32wkt3pqyio4lqdqmaff2m7g
  storage/maria/ma_blockrec.c    sp1f-ma_blockrec.c-20070118193810-5wtbfa4irhu4voa3diiuus5km2j6jvlv
  storage/maria/ma_blockrec.h    sp1f-ma_blockrec.h-20070118193810-dmnsyug4lezfuzknreqy4jntnozdnvsc
  storage/maria/ma_check.c       sp1f-ma_check.c-20060411134408-m5d5jao4sr32xsjjkig2uhdndqm5cgba
  storage/maria/ma_extra.c       sp1f-ma_extra.c-20060411134414-odsjlm2dvwmrpwdcyu3eqmkilaatl3gb
  storage/maria/ma_ft_boolean_search.c sp1f-ma_ft_boolean_search-20060411134414-l4bscelblvehls4cor5iwq3lbxkj4zwx
  storage/maria/ma_open.c        sp1f-ma_open.c-20060411134425-47m3424sotlyyl5b3k5brotxm23ryffh
  storage/maria/ma_pagecache.c   sp1f-mf_pagecache.c-20060706081022-sq6xnd367a2snwk4dup6yokn4paw7b5e
  storage/maria/ma_pagecache.h   sp1f-pagecache.h-20060706081022-qkrqzcpklayjj5pf4xbv25i3fdarqo7p
  storage/maria/ma_recovery.c    sp1f-recovery.c-20060427140636-kkuwrxyvjp42wmupdfbxuaro456oprrg
  storage/maria/ma_recovery.h    sp1f-recovery.h-20060427140637-qji2pf6o4vllizukyjcssv763llfizkq
  storage/maria/ma_recovery_util.c sp1f-ma_recovery_util.c-20080117225930-xitisuaixezgpz2gpxlech7l6d7ydtql
  storage/maria/ma_rkey.c        sp1f-ma_rkey.c-20060411134430-uvwfeqz5doebhdmjmb2yvcactm5q4qyx
  storage/maria/ma_rnext.c       sp1f-ma_rnext.c-20060411134431-nu574hnvixegeil36xyonerkkcosethq
  storage/maria/ma_rsame.c       sp1f-ma_rsame.c-20060411134434-mo64l7qb4fg2vgayeyu4l55vate2w6lk
  storage/maria/ma_rt_index.c    sp1f-ma_rt_index.c-20060411134435-knxi5ehzzeww7thlm3ppvtx6v3cppiao
  storage/maria/ma_search.c      sp1f-ma_search.c-20060411134442-haqjkc7jzp7zkt3fejfz4bdvhobo734v
  storage/maria/ma_sort.c        sp1f-ma_sort.c-20060411134442-cgxklkm2tqazbdc57w5xhs3qxbdcjpmh
  storage/maria/ma_unique.c      sp1f-ma_unique.c-20060411134448-en4xsk2ceozgyrrgoqlw4hk26hkxgofc
  storage/maria/maria_def.h      sp1f-maria_def.h-20060411134454-urdx4joxwcwzxbmltpzejn53y2rgjs44
  storage/maria/maria_read_log.c sp1f-maria_read_log.c-20070626144920-3n32phkjk3xrsid3ksgnuicghunwwfzt
  storage/myisam/ha_myisam.cc    sp1f-ha_myisam.cc-19700101030959-7xzssylbn7zfz3nupnsw43wws6xlltsu
  storage/myisam/ha_myisam.h     sp1f-ha_myisam.h-19700101030959-6vqsvuthz3pkfqplhfwzqrdryoixszpn
  storage/myisammrg/ha_myisammrg.cc sp1f-ha_myisammrg.cc-19700101030959-7fis6yttnmseasvj7uuicb6o6kghtqxf
  storage/ndb/include/ndbapi/NdbError.hpp sp1f-ndberror.hpp-20040414082357-ytnshjqhcfdetdtvkzeet5yuvu676ep5
  storage/ndb/include/util/File.hpp sp1f-file.hpp-20040414082357-imtd7kue6bgiujjd6fmsrnx63u3pgu7p
  storage/xtradb/handler/ha_innodb.cc ha_innodb.cc-20081201061010-zymrrwrczns2vrex-70
  storage/xtradb/handler/ha_innodb.h ha_innodb.h-20081201061010-zymrrwrczns2vrex-71
  storage/xtradb/trx/trx0sys.c   trx0sys.c-20081201061010-zymrrwrczns2vrex-358
  mysql-test/suite/handler/handler.inc sp1f-handler.test-20010406221832-gfvg6n4rp4py6lunazzembziuu5qxvi5
  mysql-test/suite/handler/innodb.result sp1f-innodb_handler.resul-20020821205505-jopsqbjuqwwxb5hvf3r2wn37vobunxru
  mysql-test/suite/handler/myisam.result sp1f-handler.result-20010406221832-ybo3cgjo6qapqc6776ivjpdngwmk6plu
  mysql-test/suite/handler/innodb.test sp1f-innodb_handler.test-20020821205505-gwqk7yb24jcfxay37a2svxwwoqq4ybdr
  mysql-test/suite/handler/myisam.test sp1f-handler_myisam.test-20060816103641-ckpb4przkqjb63gycdafwpu6hkuus3rj
-------------- next part --------------
=== modified file 'BUILD/compile-pentium64'
--- a/BUILD/compile-pentium64	2007-04-11 12:12:00 +0000
+++ b/BUILD/compile-pentium64	2010-12-21 17:22:20 +0000
@@ -4,7 +4,10 @@
 . "$path/SETUP.sh"
 
 extra_flags="$pentium64_cflags $fast_cflags"
-extra_configs="$pentium_configs $static_link"
+# On CentOS/Fedora Core 10 amd64, there is system libz.so but not
+# libz.a, so need to use bundled zlib when building static
+# binary. Hence we use --with-zlib-dir=bundled
+extra_configs="$pentium_configs $static_link --with-zlib-dir=bundled"
 CC="$CC --pipe"
 strip=yes
 

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2010-09-11 18:43:48 +0000
+++ b/client/mysqlbinlog.cc	2011-01-13 12:28:36 +0000
@@ -636,11 +636,16 @@
   producing USE statements by corresponding log event print-functions.
 */
 
-void print_use_stmt(PRINT_EVENT_INFO* pinfo, const char* db, size_t db_len)
+static void
+print_use_stmt(PRINT_EVENT_INFO* pinfo, const Query_log_event *ev)
 {
+  const char* db= ev->db;
+  const size_t db_len= ev->db_len;
+
   // pinfo->db is the current db.
   // If current db is the same as required db, do nothing.
-  if (!db || !memcmp(pinfo->db, db, db_len + 1))
+  if ((ev->flags & LOG_EVENT_SUPPRESS_USE_F) || !db ||
+      !memcmp(pinfo->db, db, db_len + 1))
     return;
 
   // Current db and required db are different.
@@ -779,7 +784,7 @@
       Query_log_event *qe= (Query_log_event*)ev;
       if (!qe->is_trans_keyword() && shall_skip_database(qe->db))
         goto end;
-      print_use_stmt(print_event_info, qe->db, qe->db_len);
+      print_use_stmt(print_event_info, qe);
       if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
       {
         if ((retval= write_event_header_and_base64(ev, result_file,
@@ -912,7 +917,7 @@
 
       if (!shall_skip_database(exlq->db))
       {
-        print_use_stmt(print_event_info, exlq->db, exlq->db_len);
+        print_use_stmt(print_event_info, exlq);
         if (fname)
         {
           convert_path_to_forward_slashes(fname);
@@ -1491,7 +1496,7 @@
 */
 static Exit_status safe_connect()
 {
-  /* Close and old connections to MySQL */
+  /* Close any old connections to MySQL */
   if (mysql)
     mysql_close(mysql);
 

=== modified file 'configure.in'
--- a/configure.in	2010-12-13 13:51:47 +0000
+++ b/configure.in	2011-01-05 14:03:58 +0000
@@ -12,6 +12,7 @@
 dnl When changing the major version number please also check the switch
 dnl statement in mysqlbinlog::check_master_version().  You may also need
 dnl to update version.c in ndb.
+
 AC_INIT([MariaDB Server], [5.2.5-MariaDB], [], [mysql])
 
 AC_CONFIG_SRCDIR([sql/mysqld.cc])

=== modified file 'mysql-test/Makefile.am'
--- a/mysql-test/Makefile.am	2010-09-12 12:33:04 +0000
+++ b/mysql-test/Makefile.am	2011-01-10 21:42:47 +0000
@@ -109,6 +109,7 @@
 	suite/innodb suite/innodb/t suite/innodb/r suite/innodb/include \
 	suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r \
 	suite/innodb_plugin/include \
+	suite/handler \
 	suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \
 	suite/engines/funcs/r suite/engines/funcs/t suite/engines/iuds/r \
 	suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \

=== modified file 'mysql-test/README'
--- a/mysql-test/README	2010-08-18 07:52:57 +0000
+++ b/mysql-test/README	2011-01-04 13:47:21 +0000
@@ -4,13 +4,14 @@
 
 Note that you do not have to have to do "make install", and you could
 actually have a co-existing MySQL installation. The tests will not
-conflict with it.
+conflict with it. To run the test suite in a source directory, you
+must do make first.
 
 All tests must pass. If one or more of them fail on your system, please
 read the following manual section for instructions on how to report the
 problem:
 
-http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html
+http://kb.askmonty.org/v/reporting-bugs
 
 If you want to use an already running MySQL server for specific tests,
 use the --extern option to mysql-test-run. Please note that in this mode,
@@ -27,7 +28,6 @@
 to the normal "non-extern" behavior. The reason for this is that some
 tests cannot run with an external server.
 
-
 You can create your own test cases. To create a test case, create a new
 file in the t subdirectory using a text editor. The file should have a .test
 extension. For example:
@@ -67,7 +67,12 @@
    edit the test result to the correct results so that we can verify
    that the bug is corrected in future releases.
 
-To submit your test case, put your .test file and .result file(s) into
-a tar.gz archive, add a README that explains the problem, ftp the 
-archive to ftp://support.mysql.com/pub/mysql/secret/ and send a mail
-to bugs at lists.mysql.com
+If you want to submit your test case you can send it 
+to maria-developers at lists.launchpad.com or attach it to a bug report on
+https://bugs.launchpad.net/maria/.
+
+If the test case is really big or if it contains 'not public' data,
+then put your .test file and .result file(s) into a tar.gz archive,
+add a README that explains the problem, ftp the archive to
+ftp://ftp.askmonty.org/private and send a mail to
+https://bugs.launchpad.net/maria/ about it.

=== modified file 'mysql-test/extra/rpl_tests/rpl_stop_slave.test'
--- a/mysql-test/extra/rpl_tests/rpl_stop_slave.test	2010-10-16 12:03:44 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_stop_slave.test	2011-01-03 14:33:39 +0000
@@ -42,6 +42,7 @@
 connection slave1;
 --echo # To resume slave SQL thread
 SET DEBUG_SYNC= 'now SIGNAL signal.continue';
+SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
 SET DEBUG_SYNC= 'RESET';
 
 --echo

=== modified file 'mysql-test/include/have_xtradb.inc'
--- a/mysql-test/include/have_xtradb.inc	2010-08-03 21:26:17 +0000
+++ b/mysql-test/include/have_xtradb.inc	2010-12-31 09:39:14 +0000
@@ -1,4 +1,5 @@
-disable_query_log;
---require r/true.require
-SELECT (plugin_description LIKE '%xtradb%') AS `TRUE` FROM information_schema.plugins WHERE LOWER(plugin_name) = 'innodb' AND LOWER(plugin_status) = 'active';
-enable_query_log;
+if (!`SELECT count(*) FROM information_schema.plugins WHERE
+      plugin_name = 'innodb' AND plugin_status = 'active' AND
+      plugin_description LIKE '%xtradb%'`){
+  skip Need XtraDB engine;
+}

=== added file 'mysql-test/include/have_xtradb.opt'
--- a/mysql-test/include/have_xtradb.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/have_xtradb.opt	2010-12-31 09:39:14 +0000
@@ -0,0 +1,2 @@
+--loose-innodb
+--plugin-load=$HA_XTRADB_SO

=== added file 'mysql-test/include/long_test.inc'
--- a/mysql-test/include/long_test.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/long_test.inc	2011-01-03 14:33:39 +0000
@@ -0,0 +1,4 @@
+# We use this --source include to mark a test as taking long to run.
+# We can use this to schedule such test early (to not be left with
+# only one or two long tests running, and rests of works idle), or to
+# run a quick test skipping long-running test cases.

=== modified file 'mysql-test/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm	2010-11-30 21:11:03 +0000
+++ b/mysql-test/lib/mtr_cases.pm	2011-01-05 14:03:58 +0000
@@ -89,6 +89,20 @@
 }
 
 
+sub testcase_sort_order {
+  my ($a, $b, $sort_criteria)= @_;
+  my $a_sort_criteria= $sort_criteria->{$a->fullname()};
+  my $b_sort_criteria= $sort_criteria->{$b->fullname()};
+  my $res= $a_sort_criteria cmp $b_sort_criteria;
+  return $res if $res;
+  # Run slow tests first, trying to avoid getting stuck at the end
+  # with a slow test in one worker and the other workers idle.
+  return -1 if $a->{'long_test'} && !$b->{'long_test'};
+  return 1 if !$a->{'long_test'} && $b->{'long_test'};
+
+  return $a->fullname() cmp $b->fullname();
+}
+
 ##############################################################################
 #
 #  Collect information about test cases to be run
@@ -177,9 +191,7 @@
       $sort_criteria{$tinfo->fullname()} = join(" ", @criteria);
     }
 
-    @$cases = sort {
-      $sort_criteria{$a->fullname()} . $a->fullname() cmp
-	$sort_criteria{$b->fullname()} . $b->fullname() } @$cases;
+    @$cases = sort { testcase_sort_order($a, $b, \%sort_criteria) } @$cases;
 
     # For debugging the sort-order
     # foreach my $tinfo (@$cases)
@@ -1065,6 +1077,7 @@
  ["include/have_example_plugin.inc", "example_plugin_test", 1],
  ["include/have_oqgraph_engine.inc", "oqgraph_test", 1],
  ["include/have_ssl.inc", "need_ssl", 1],
+ ["include/long_test.inc", "long_test", 1],
 );
 
 

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2010-12-04 21:18:46 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-01-10 21:42:47 +0000
@@ -142,7 +142,7 @@
 # executables will be used by the test suite.
 our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
 
-my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,parts,innodb,innodb_plugin,percona,ndb,vcol,oqgraph,sphinx";
+my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,handler,parts,innodb,innodb_plugin,percona,ndb,vcol,oqgraph,sphinx";
 my $opt_suites;
 
 our $opt_verbose= 0;  # Verbose output, enable with --verbose
@@ -729,9 +729,11 @@
 	    last;
 	  }
 
-	  # Second best choice is the first that does not fulfill
-	  # any of the above conditions
-	  if (!defined $second_best){
+	  # From secondary choices, we prefer to pick a 'long-running' test if
+          # possible; this helps avoid getting stuck with a few of those at the
+          # end of high --parallel runs, with most workers being idle.
+	  if (!defined $second_best ||
+              ($t->{'long_test'} && !($tests->[$second_best]{'long_test'}))){
 	    #mtr_report("Setting second_best to $i");
 	    $second_best= $i;
 	  }

=== modified file 'mysql-test/r/lock_multi.result'
--- a/mysql-test/r/lock_multi.result	2009-07-10 23:12:13 +0000
+++ b/mysql-test/r/lock_multi.result	2011-01-10 21:22:40 +0000
@@ -162,13 +162,6 @@
 unlock tables;
 drop table t1;
 drop table if exists t1;
-create table t1 (a int) ENGINE=MEMORY;
---> client 2
-handler t1 open;
-ERROR HY000: Table storage engine for 't1' doesn't have this option
---> client 1
-drop table t1;
-drop table if exists t1;
 create table t1 (i int);
 connection: default
 lock tables t1 write;

=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	2009-03-11 20:30:56 +0000
+++ b/mysql-test/r/log_tables.result	2010-12-31 09:39:14 +0000
@@ -248,13 +248,13 @@
 set @save_storage_engine= @@session.storage_engine;
 set storage_engine= MEMORY;
 alter table mysql.slow_log engine=ndb;
-ERROR HY000: This storage engine cannot be used for log tables"
+ERROR HY000: This storage engine cannot be used for log tables
 alter table mysql.slow_log engine=innodb;
-ERROR HY000: This storage engine cannot be used for log tables"
+ERROR HY000: This storage engine cannot be used for log tables
 alter table mysql.slow_log engine=archive;
-ERROR HY000: This storage engine cannot be used for log tables"
+ERROR HY000: This storage engine cannot be used for log tables
 alter table mysql.slow_log engine=blackhole;
-ERROR HY000: This storage engine cannot be used for log tables"
+ERROR HY000: This storage engine cannot be used for log tables
 set storage_engine= @save_storage_engine;
 drop table mysql.slow_log;
 drop table mysql.general_log;

=== added file 'mysql-test/r/mysqlbinlog-innodb.result'
--- a/mysql-test/r/mysqlbinlog-innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/mysqlbinlog-innodb.result	2011-01-13 12:28:36 +0000
@@ -0,0 +1,85 @@
+SET TIMESTAMP=1000000000;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
+CREATE DATABASE test2;
+RESET MASTER;
+USE test2;
+BEGIN;
+USE test;
+INSERT INTO t1 VALUES (1);
+USE test2;
+COMMIT;
+BEGIN;
+USE test;
+INSERT INTO t1 VALUES (2);
+USE test2;
+COMMIT;
+USE test;
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+FLUSH LOGS;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+BEGIN
+/*!*/;
+use test/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+INSERT INTO t1 VALUES (1)
+/*!*/;
+COMMIT/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+INSERT INTO t1 VALUES (2)
+/*!*/;
+COMMIT/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+BEGIN
+/*!*/;
+use foo/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+INSERT INTO t1 VALUES (1)
+/*!*/;
+COMMIT/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+INSERT INTO t1 VALUES (2)
+/*!*/;
+COMMIT/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+DROP DATABASE test2;
+DROP TABLE t1;

=== modified file 'mysql-test/r/plugin.result'
--- a/mysql-test/r/plugin.result	2010-10-24 18:47:01 +0000
+++ b/mysql-test/r/plugin.result	2010-12-31 09:39:14 +0000
@@ -75,9 +75,9 @@
 #illegal value fixed
 CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS;
 Warnings:
-Warning	1652	Incorrect value '10000000000000000000' for option 'ULL'
-Warning	1652	Incorrect value 'ttt' for option 'one_or_two'
-Warning	1652	Incorrect value 'SSS' for option 'YESNO'
+Warning	1653	Incorrect value '10000000000000000000' for option 'ULL'
+Warning	1653	Incorrect value 'ttt' for option 'one_or_two'
+Warning	1653	Incorrect value 'SSS' for option 'YESNO'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2010-12-10 05:55:14 +0000
+++ b/mysql-test/r/subselect.result	2011-01-23 06:22:04 +0000
@@ -4745,4 +4745,15 @@
 1	3
 deallocate prepare stmt1;
 drop table t1,t2;
+#
+# Bug LP#693935/#58727: Assertion failure with 
+# a single row subquery returning more than one row
+#
+create table t1 (a char(1) charset utf8);
+insert into t1 values ('a'), ('b');
+create table t2 (a binary(1));
+insert into t2 values ('x'), ('y');
+select * from t2 where a=(select a from t1) and a='x';
+ERROR 21000: Subquery returns more than 1 row
+drop table t1,t2;
 End of 5.1 tests

=== modified file 'mysql-test/r/table_elim.result'
--- a/mysql-test/r/table_elim.result	2010-09-11 15:20:35 +0000
+++ b/mysql-test/r/table_elim.result	2011-01-11 10:42:16 +0000
@@ -535,3 +535,34 @@
 field4 != 6;
 field1	field2	field3	field4	field5	field6
 drop table t0,t1,t2,t3,t4,t5,t6;
+#
+# BUG#675118: Elimination of a table results in an invalid execution plan
+#
+CREATE TABLE t1 (f1 int(11), PRIMARY KEY (f1)) ;
+CREATE TABLE t2 (f4 varchar(1024), KEY (f4)) ;
+Warnings:
+Warning	1071	Specified key was too long; max key length is 1000 bytes
+INSERT IGNORE INTO t2 VALUES ('xcddwntkbxyorzdv'),
+('cnxxcddwntkbxyor'),('r'),('r'), ('did'),('I'),('when'),
+('hczkfqjeggivdvac'),('e'),('okay'),('up');
+CREATE TABLE t3 (f4 varchar(1024), f1 int(11), f2 int(11)) ;
+INSERT IGNORE INTO t3 VALUES ('f','4','0'),('n','5','-996540416');
+CREATE TABLE t4 (f1 int(11), f3 varchar(10)) ;
+INSERT IGNORE INTO t4 VALUES ('8','n'),('9','nwzcerzsgx'),('10','c');
+CREATE TABLE t5 (f5 int(11), KEY (f5)) ;
+EXPLAIN 
+SELECT t3.f2
+FROM t2
+LEFT JOIN t3
+LEFT JOIN t4
+LEFT JOIN t1 ON t4.f1 = t1.f1
+JOIN t5 ON t4.f3 ON t3.f1 = t5.f5 ON t2.f4 = t3.f4
+WHERE t3.f2 ;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t5	ref	f5	f5	5	test.t3.f1	2	Using index
+1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	3	
+1	SIMPLE	t2	ALL	f4	NULL	NULL	NULL	11	Using where; Using join buffer
+# ^^ The above must not produce a QEP of t3,t5,t2,t4
+#    as that violates the "no interleaving of outer join nests" rule.
+DROP TABLE t1,t2,t3,t4,t5;

=== modified file 'mysql-test/r/table_options.result'
--- a/mysql-test/r/table_options.result	2010-07-13 14:34:14 +0000
+++ b/mysql-test/r/table_options.result	2010-12-31 09:39:14 +0000
@@ -3,9 +3,9 @@
 SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
 create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1';
 Warnings:
-Warning	1651	Unknown option 'fkey'
-Warning	1651	Unknown option 'dff'
-Warning	1651	Unknown option 'tkey1'
+Warning	1652	Unknown option 'fkey'
+Warning	1652	Unknown option 'dff'
+Warning	1652	Unknown option 'tkey1'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -16,10 +16,10 @@
 #reassiginig options in the same line
 create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1 TKEY1=DEFAULT tkey1=1v2 tkey2=2v1;
 Warnings:
-Warning	1651	Unknown option 'fkey'
-Warning	1651	Unknown option 'dff'
-Warning	1651	Unknown option 'tkey1'
-Warning	1651	Unknown option 'tkey2'
+Warning	1652	Unknown option 'fkey'
+Warning	1652	Unknown option 'dff'
+Warning	1652	Unknown option 'tkey1'
+Warning	1652	Unknown option 'tkey2'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -29,7 +29,7 @@
 #add option
 alter table t1 tkey4=4v1;
 Warnings:
-Warning	1651	Unknown option 'tkey4'
+Warning	1652	Unknown option 'tkey4'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -39,8 +39,8 @@
 #remove options 
 alter table t1 tkey3=DEFAULT tkey4=DEFAULT;
 Warnings:
-Warning	1651	Unknown option 'tkey3'
-Warning	1651	Unknown option 'tkey4'
+Warning	1652	Unknown option 'tkey3'
+Warning	1652	Unknown option 'tkey4'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -50,11 +50,11 @@
 drop table t1;
 create table t1 (a int fkey1=v1, key akey (a) kkey1=v1) tkey1=1v1 tkey1=1v2 TKEY1=DEFAULT tkey2=2v1 tkey3=3v1;
 Warnings:
-Warning	1651	Unknown option 'fkey1'
-Warning	1651	Unknown option 'kkey1'
-Warning	1651	Unknown option 'TKEY1'
-Warning	1651	Unknown option 'tkey2'
-Warning	1651	Unknown option 'tkey3'
+Warning	1652	Unknown option 'fkey1'
+Warning	1652	Unknown option 'kkey1'
+Warning	1652	Unknown option 'TKEY1'
+Warning	1652	Unknown option 'tkey2'
+Warning	1652	Unknown option 'tkey3'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -64,7 +64,7 @@
 #change field with option with the same value
 alter table t1 change a a int `FKEY1`='v1';
 Warnings:
-Warning	1651	Unknown option 'FKEY1'
+Warning	1652	Unknown option 'FKEY1'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -74,7 +74,7 @@
 #change field with option with a different value
 alter table t1 change a a int fkey1=v2;
 Warnings:
-Warning	1651	Unknown option 'fkey1'
+Warning	1652	Unknown option 'fkey1'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -93,7 +93,7 @@
 #new key with options
 alter table t1 add key bkey (b) kkey2=v1;
 Warnings:
-Warning	1651	Unknown option 'kkey2'
+Warning	1652	Unknown option 'kkey2'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -105,8 +105,8 @@
 #new column with options
 alter table t1 add column c int fkey1=v1 fkey2=v2;
 Warnings:
-Warning	1651	Unknown option 'fkey1'
-Warning	1651	Unknown option 'fkey2'
+Warning	1652	Unknown option 'fkey1'
+Warning	1652	Unknown option 'fkey2'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -141,7 +141,7 @@
 #add column with options after delete
 alter table t1 add column b int fkey2=v1;
 Warnings:
-Warning	1651	Unknown option 'fkey2'
+Warning	1652	Unknown option 'fkey2'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -154,7 +154,7 @@
 #add key 
 alter table t1 add key bkey (b) kkey2=v2;
 Warnings:
-Warning	1651	Unknown option 'kkey2'
+Warning	1652	Unknown option 'kkey2'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -168,7 +168,7 @@
 drop table t1;
 create table t1 (a int) tkey1=100;
 Warnings:
-Warning	1651	Unknown option 'tkey1'
+Warning	1652	Unknown option 'tkey1'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result'
--- a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result	2009-10-27 13:42:47 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result	2011-01-13 12:28:36 +0000
@@ -159,7 +159,6 @@
 COMMIT
 /*!*/;
 # at #
-use new_test1/*!*/;
 #010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
 SET TIMESTAMP=1000000000/*!*/;
 BEGIN
@@ -354,7 +353,6 @@
 COMMIT
 /*!*/;
 # at #
-use new_test1/*!*/;
 #010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
 SET TIMESTAMP=1000000000/*!*/;
 BEGIN

=== modified file 'mysql-test/suite/federated/federated_debug.test'
--- a/mysql-test/suite/federated/federated_debug.test	2009-09-30 22:25:06 +0000
+++ b/mysql-test/suite/federated/federated_debug.test	2011-01-03 14:33:39 +0000
@@ -1,4 +1,5 @@
 --source include/have_debug.inc
+--source include/long_test.inc
 --source federated.inc
 
 --echo #

=== added directory 'mysql-test/suite/handler'
=== added file 'mysql-test/suite/handler/aria.result'
--- a/mysql-test/suite/handler/aria.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/handler/aria.result	2011-01-10 21:22:40 +0000
@@ -0,0 +1,671 @@
+SET SESSION STORAGE_ENGINE = Aria;
+drop table if exists t1,t3,t4,t5;
+create table t1 (a int, b char(10), key a  (a), key b  (a,b));
+insert into t1 values
+(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
+(14,"aaa"),(16,"ccc"),(16,"xxx"),
+(20,"ggg"),(21,"hhh"),(22,"iii");
+handler t1 open as t2;
+handler t2 read a first;
+a	b
+14	aaa
+handler t2 read a next;
+a	b
+16	ccc
+handler t2 read a next;
+a	b
+16	xxx
+handler t2 read a prev;
+a	b
+16	ccc
+handler t2 read a last;
+a	b
+22	iii
+handler t2 read a prev;
+a	b
+21	hhh
+handler t2 read a prev;
+a	b
+20	ggg
+handler t2 read a first;
+a	b
+14	aaa
+handler t2 read a prev;
+a	b
+handler t2 read a last;
+a	b
+22	iii
+handler t2 read a prev;
+a	b
+21	hhh
+handler t2 read a next;
+a	b
+22	iii
+handler t2 read a next;
+a	b
+handler t2 read a=(15);
+a	b
+handler t2 read a=(16);
+a	b
+16	ccc
+handler t2 read a=(19,"fff");
+ERROR 42000: Too many key parts specified; max 1 parts allowed
+handler t2 read b=(19,"fff");
+a	b
+19	fff
+handler t2 read b=(19,"yyy");
+a	b
+19	yyy
+handler t2 read b=(19);
+a	b
+19	fff
+handler t1 read a last;
+ERROR 42S02: Unknown table 't1' in HANDLER
+handler t2 read a=(11);
+a	b
+handler t2 read a>=(11);
+a	b
+14	aaa
+handler t2 read a=(18);
+a	b
+18	eee
+handler t2 read a>=(18);
+a	b
+18	eee
+handler t2 read a>(18);
+a	b
+19	fff
+handler t2 read a<=(18);
+a	b
+18	eee
+handler t2 read a<(18);
+a	b
+17	ddd
+handler t2 read a=(15);
+a	b
+handler t2 read a>=(15);
+a	b
+16	ccc
+handler t2 read a>(15);
+a	b
+16	ccc
+handler t2 read a<=(15);
+a	b
+14	aaa
+handler t2 read a<(15);
+a	b
+14	aaa
+handler t2 read a=(54);
+a	b
+handler t2 read a>=(54);
+a	b
+handler t2 read a>(54);
+a	b
+handler t2 read a<=(54);
+a	b
+22	iii
+handler t2 read a<(54);
+a	b
+22	iii
+handler t2 read a=(1);
+a	b
+handler t2 read a>=(1);
+a	b
+14	aaa
+handler t2 read a>(1);
+a	b
+14	aaa
+handler t2 read a<=(1);
+a	b
+handler t2 read a<(1);
+a	b
+handler t2 read a first limit 5;
+a	b
+14	aaa
+16	ccc
+16	xxx
+17	ddd
+18	eee
+handler t2 read a next  limit 3;
+a	b
+19	fff
+19	yyy
+20	ggg
+handler t2 read a prev  limit 10;
+a	b
+19	yyy
+19	fff
+18	eee
+17	ddd
+16	xxx
+16	ccc
+14	aaa
+handler t2 read a>=(16) limit 4;
+a	b
+16	ccc
+16	xxx
+17	ddd
+18	eee
+handler t2 read a>=(16) limit 2,2;
+a	b
+17	ddd
+18	eee
+handler t2 read a last  limit 3;
+a	b
+22	iii
+21	hhh
+20	ggg
+handler t2 read a=(19);
+a	b
+19	fff
+handler t2 read a=(19) where b="yyy";
+a	b
+19	yyy
+handler t2 read first;
+a	b
+17	ddd
+handler t2 read next;
+a	b
+18	eee
+handler t2 read next;
+a	b
+19	fff
+handler t2 close;
+handler t1 open;
+handler t1 read a next;
+a	b
+14	aaa
+handler t1 read a next;
+a	b
+16	ccc
+handler t1 close;
+handler t1 open;
+handler t1 read a prev;
+a	b
+22	iii
+handler t1 read a prev;
+a	b
+21	hhh
+handler t1 close;
+handler t1 open as t2;
+handler t2 read first;
+a	b
+17	ddd
+alter table t1 engine = Aria;
+handler t2 read first;
+ERROR 42S02: Unknown table 't2' in HANDLER
+handler t1 open as t2;
+drop table t1;
+create table t1 (a int not null);
+insert into t1 values (17);
+handler t2 read first;
+ERROR 42S02: Unknown table 't2' in HANDLER
+handler t1 open as t2;
+alter table t1 engine=CSV;
+handler t2 read first;
+ERROR 42S02: Unknown table 't2' in HANDLER
+drop table t1;
+create table t1 (a int);
+insert into t1 values (1),(2),(3),(4),(5),(6);
+delete from t1 limit 2;
+handler t1 open;
+handler t1 read first;
+a
+3
+handler t1 read first limit 1,1;
+a
+4
+handler t1 read first limit 2,2;
+a
+5
+6
+delete from t1 limit 3;
+handler t1 read first;
+a
+6
+drop table t1;
+create table t1(a int, index  (a));
+insert into t1 values (1), (2), (3);
+handler t1 open;
+handler t1 read a=(W);
+ERROR 42S22: Unknown column 'W' in 'field list'
+handler t1 read a=(a);
+ERROR HY000: Incorrect arguments to HANDLER ... READ
+drop table t1;
+create table t1 (a char(5));
+insert into t1 values ("Ok");
+handler t1 open as t;
+handler t read first;
+a
+Ok
+use mysql;
+handler t read first;
+a
+Ok
+handler t close;
+handler test.t1 open as t;
+handler t read first;
+a
+Ok
+handler t close;
+use test;
+drop table t1;
+create table t1 ( a int, b int, INDEX a  (a) );
+insert into t1 values (1,2), (2,1);
+handler t1 open;
+handler t1 read a=(1) where b=2;
+a	b
+1	2
+handler t1 read a=(1) where b=3;
+a	b
+handler t1 read a=(1) where b=1;
+a	b
+handler t1 close;
+drop table t1;
+create table t1 (c1 char(20));
+insert into t1 values ("t1");
+handler t1 open as h1;
+handler h1 read first limit 9;
+c1
+t1
+create table t2 (c1 char(20));
+insert into t2 values ("t2");
+handler t2 open as h2;
+handler h2 read first limit 9;
+c1
+t2
+create table t3 (c1 char(20));
+insert into t3 values ("t3");
+handler t3 open as h3;
+handler h3 read first limit 9;
+c1
+t3
+create table t4 (c1 char(20));
+insert into t4 values ("t4");
+handler t4 open as h4;
+handler h4 read first limit 9;
+c1
+t4
+create table t5 (c1 char(20));
+insert into t5 values ("t5");
+handler t5 open as h5;
+handler h5 read first limit 9;
+c1
+t5
+alter table t1 engine=MyISAM;
+handler h1 read first limit 9;
+ERROR 42S02: Unknown table 'h1' in HANDLER
+handler h2 read first limit 9;
+c1
+t2
+handler h3 read first limit 9;
+c1
+t3
+handler h4 read first limit 9;
+c1
+t4
+handler h5 read first limit 9;
+c1
+t5
+alter table t5 engine=MyISAM;
+handler h1 read first limit 9;
+ERROR 42S02: Unknown table 'h1' in HANDLER
+handler h2 read first limit 9;
+c1
+t2
+handler h3 read first limit 9;
+c1
+t3
+handler h4 read first limit 9;
+c1
+t4
+handler h5 read first limit 9;
+ERROR 42S02: Unknown table 'h5' in HANDLER
+alter table t3 engine=MyISAM;
+handler h1 read first limit 9;
+ERROR 42S02: Unknown table 'h1' in HANDLER
+handler h2 read first limit 9;
+c1
+t2
+handler h3 read first limit 9;
+ERROR 42S02: Unknown table 'h3' in HANDLER
+handler h4 read first limit 9;
+c1
+t4
+handler h5 read first limit 9;
+ERROR 42S02: Unknown table 'h5' in HANDLER
+handler h2 close;
+handler h4 close;
+handler t1 open as h1_1;
+handler t1 open as h1_2;
+handler t1 open as h1_3;
+handler h1_1 read first limit 9;
+c1
+t1
+handler h1_2 read first limit 9;
+c1
+t1
+handler h1_3 read first limit 9;
+c1
+t1
+alter table t1 engine=Aria;
+handler h1_1 read first limit 9;
+ERROR 42S02: Unknown table 'h1_1' in HANDLER
+handler h1_2 read first limit 9;
+ERROR 42S02: Unknown table 'h1_2' in HANDLER
+handler h1_3 read first limit 9;
+ERROR 42S02: Unknown table 'h1_3' in HANDLER
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+drop table t5;
+create table t1 (c1 int);
+insert into t1 values (1);
+handler t1 open;
+handler t1 read first;
+c1
+1
+send the below to another connection, do not wait for the result
+optimize table t1;
+proceed with the normal connection
+handler t1 read next;
+c1
+1
+handler t1 close;
+read the result from the other connection
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	status	OK
+proceed with the normal connection
+drop table t1;
+CREATE TABLE t1 (  no1 smallint(5) NOT NULL default '0',  no2 int(10) NOT NULL default '0',  PRIMARY KEY  (no1,no2));
+INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
+HANDLER t1 OPEN;
+HANDLER t1 READ `primary` = (1, 1000);
+no1	no2
+HANDLER t1 READ `primary` PREV;
+no1	no2
+1	275
+HANDLER t1 READ `primary` = (1, 1000);
+no1	no2
+HANDLER t1 READ `primary` NEXT;
+no1	no2
+2	6
+DROP TABLE t1;
+create table t1 (c1 int);
+insert into t1 values (14397);
+flush tables with read lock;
+drop table t1;
+ERROR HY000: Can't execute the query because you have a conflicting read lock
+send the below to another connection, do not wait for the result
+drop table t1;
+proceed with the normal connection
+select * from t1;
+c1
+14397
+unlock tables;
+read the result from the other connection
+proceed with the normal connection
+select * from t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
+drop table if exists t1;
+Warnings:
+Note	1051	Unknown table 't1'
+create table t1 (a int not null) ENGINE=CSV;
+--> client 2
+handler t1 open;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+--> client 1
+drop table t1;
+create table t1 (a int);
+handler t1 open as t1_alias;
+handler t1_alias read a next;
+ERROR 42000: Key 'a' doesn't exist in table 't1_alias'
+handler t1_alias READ a next where inexistent > 0;
+ERROR 42S22: Unknown column 'inexistent' in 'field list'
+handler t1_alias read a next;
+ERROR 42000: Key 'a' doesn't exist in table 't1_alias'
+handler t1_alias READ a next where inexistent > 0;
+ERROR 42S22: Unknown column 'inexistent' in 'field list'
+handler t1_alias close;
+drop table t1;
+create temporary table t1 (a int, b char(1), key a  (a), key b(a,b));
+insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
+(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
+select a,b from t1;
+a	b
+0	a
+1	b
+2	c
+3	d
+4	e
+5	f
+6	g
+7	h
+8	i
+9	j
+9	k
+handler t1 open as a1;
+handler a1 read a=(1);
+a	b
+1	b
+handler a1 read a next;
+a	b
+2	c
+handler a1 read a next;
+a	b
+3	d
+select a,b from t1;
+ERROR HY000: Can't reopen table: 'a1'
+handler a1 read a prev;
+a	b
+2	c
+handler a1 read a prev;
+a	b
+1	b
+handler a1 read a=(6) where b="g";
+a	b
+6	g
+handler a1 close;
+select a,b from t1;
+a	b
+0	a
+1	b
+2	c
+3	d
+4	e
+5	f
+6	g
+7	h
+8	i
+9	j
+9	k
+handler t1 open as a2;
+handler a2 read a=(9);
+a	b
+9	j
+handler a2 read a next;
+a	b
+9	k
+handler a2 read a prev limit 2;
+a	b
+9	j
+8	i
+handler a2 read a last;
+a	b
+9	k
+handler a2 read a prev;
+a	b
+9	j
+handler a2 close;
+drop table t1;
+create table t1 (a int);
+create temporary table t2 (a int, key  (a));
+handler t1 open as a1;
+handler t2 open as a2;
+handler a2 read a first;
+a
+drop table t1, t2;
+handler a2 read a next;
+ERROR 42S02: Unknown table 'a2' in HANDLER
+handler a1 close;
+ERROR 42S02: Unknown table 'a1' in HANDLER
+create table t1 (a int, key  (a));
+create table t2 like t1;
+handler t1 open as a1;
+handler t2 open as a2;
+handler a1 read a first;
+a
+handler a2 read a first;
+a
+alter table t1 add b int;
+handler a1 close;
+ERROR 42S02: Unknown table 'a1' in HANDLER
+handler a2 close;
+drop table t1, t2;
+create table t1 (a int, key  (a));
+handler t1 open as a1;
+handler a1 read a first;
+a
+rename table t1 to t2;
+handler a1 read a first;
+ERROR 42S02: Unknown table 'a1' in HANDLER
+drop table t2;
+create table t1 (a int, key  (a));
+create table t2 like t1;
+handler t1 open as a1;
+handler t2 open as a2;
+handler a1 read a first;
+a
+handler a2 read a first;
+a
+optimize table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	status	Table is already up to date
+handler a1 close;
+ERROR 42S02: Unknown table 'a1' in HANDLER
+handler a2 close;
+drop table t1, t2;
+#
+# BUG#51877 - HANDLER interface causes invalid memory read
+#
+CREATE TABLE t1(a INT, KEY  (a));
+HANDLER t1 OPEN;
+HANDLER t1 READ a FIRST;
+a
+INSERT INTO t1 VALUES(1);
+HANDLER t1 READ a NEXT;
+a
+1
+HANDLER t1 CLOSE;
+DROP TABLE t1;
+#
+# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash 
+#
+CREATE TABLE t1 AS SELECT 1 AS f1;
+HANDLER t1 OPEN;
+TRUNCATE t1;
+HANDLER t1 READ FIRST;
+ERROR 42S02: Unknown table 't1' in HANDLER
+DROP TABLE t1;
+CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1;
+HANDLER t1 OPEN;
+TRUNCATE t1;
+HANDLER t1 READ FIRST;
+ERROR 42S02: Unknown table 't1' in HANDLER
+DROP TABLE t1;
+#
+# Bug #54007: assert in ha_myisam::index_next , HANDLER
+#
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b));
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST;
+a	b
+HANDLER t1 READ `PRIMARY` NEXT;
+a	b
+HANDLER t1 READ ab NEXT;
+a	b
+HANDLER t1 READ b NEXT;
+a	b
+HANDLER t1 READ NEXT;
+a	b
+HANDLER t1 CLOSE;
+INSERT INTO t1 VALUES (2, 20), (1, 10), (4, 40), (3, 30);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST;
+a	b
+2	20
+HANDLER t1 READ NEXT;
+a	b
+1	10
+HANDLER t1 READ `PRIMARY` NEXT;
+a	b
+1	10
+HANDLER t1 READ `PRIMARY` NEXT;
+a	b
+2	20
+HANDLER t1 READ ab NEXT;
+a	b
+1	10
+HANDLER t1 READ ab NEXT;
+a	b
+2	20
+HANDLER t1 READ b NEXT;
+a	b
+1	10
+HANDLER t1 READ b NEXT;
+a	b
+2	20
+HANDLER t1 READ b NEXT;
+a	b
+3	30
+HANDLER t1 READ b NEXT;
+a	b
+4	40
+HANDLER t1 READ b NEXT;
+a	b
+HANDLER t1 READ NEXT;
+a	b
+2	20
+HANDLER t1 READ NEXT;
+a	b
+1	10
+HANDLER t1 READ NEXT;
+a	b
+4	40
+HANDLER t1 CLOSE;
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST;
+a	b
+2	20
+HANDLER t1 READ `PRIMARY` PREV;
+a	b
+4	40
+HANDLER t1 READ `PRIMARY` PREV;
+a	b
+3	30
+HANDLER t1 READ b PREV;
+a	b
+4	40
+HANDLER t1 READ b PREV;
+a	b
+3	30
+HANDLER t1 CLOSE;
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST;
+a	b
+2	20
+HANDLER t1 READ `PRIMARY` PREV LIMIT 3;
+a	b
+4	40
+3	30
+2	20
+HANDLER t1 READ b NEXT LIMIT 5;
+a	b
+1	10
+2	20
+3	30
+4	40
+HANDLER t1 CLOSE;
+DROP TABLE t1;
+End of 5.1 tests

=== added file 'mysql-test/suite/handler/aria.test'
--- a/mysql-test/suite/handler/aria.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/handler/aria.test	2011-01-10 21:22:40 +0000
@@ -0,0 +1,82 @@
+# t/handler_innodb.test
+#
+# test of HANDLER ...
+#
+# Last update:
+# 2006-07-31 ML test refactored (MySQL 5.1)
+#               code of t/handler.test and t/innodb_handler.test united
+#               main testing code put into handler.inc
+#               rename t/innodb_handler.test to t/handler_innodb.test
+#
+
+--source include/have_maria.inc
+let $engine_type= Aria;
+
+--source init.inc
+--source handler.inc
+
+--echo #
+--echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash 
+--echo #
+CREATE TABLE t1 AS SELECT 1 AS f1; 
+HANDLER t1 OPEN;
+TRUNCATE t1;
+--error ER_UNKNOWN_TABLE
+HANDLER t1 READ FIRST;
+DROP TABLE t1;
+
+CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1; 
+HANDLER t1 OPEN;
+TRUNCATE t1;
+--error ER_UNKNOWN_TABLE
+HANDLER t1 READ FIRST;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #54007: assert in ha_myisam::index_next , HANDLER
+--echo #
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b));
+
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST;
+HANDLER t1 READ `PRIMARY` NEXT;
+HANDLER t1 READ ab NEXT;
+HANDLER t1 READ b NEXT;
+HANDLER t1 READ NEXT;
+HANDLER t1 CLOSE;
+
+INSERT INTO t1 VALUES (2, 20), (1, 10), (4, 40), (3, 30);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST;
+HANDLER t1 READ NEXT;
+HANDLER t1 READ `PRIMARY` NEXT;
+HANDLER t1 READ `PRIMARY` NEXT;
+HANDLER t1 READ ab NEXT;
+HANDLER t1 READ ab NEXT;
+HANDLER t1 READ b NEXT;
+HANDLER t1 READ b NEXT;
+HANDLER t1 READ b NEXT;
+HANDLER t1 READ b NEXT;
+HANDLER t1 READ b NEXT;
+HANDLER t1 READ NEXT;
+HANDLER t1 READ NEXT;
+HANDLER t1 READ NEXT;
+HANDLER t1 CLOSE;
+
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST;
+HANDLER t1 READ `PRIMARY` PREV;
+HANDLER t1 READ `PRIMARY` PREV;
+HANDLER t1 READ b PREV;
+HANDLER t1 READ b PREV;
+HANDLER t1 CLOSE;
+
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST;
+HANDLER t1 READ `PRIMARY` PREV LIMIT 3;
+HANDLER t1 READ b NEXT LIMIT 5;
+HANDLER t1 CLOSE;
+
+DROP TABLE t1;
+
+--echo End of 5.1 tests

=== renamed file 'mysql-test/include/handler.inc' => 'mysql-test/suite/handler/handler.inc'
--- a/mysql-test/include/handler.inc	2009-07-10 23:12:13 +0000
+++ b/mysql-test/suite/handler/handler.inc	2011-01-10 21:22:40 +0000
@@ -1,5 +1,7 @@
-# include/handler.inc
+# handler.inc
 #
+# See init.inc for setup of variables for this script
+# 
 # The variables
 #     $engine_type       -- storage engine to be tested
 #     $other_engine_type -- storage engine <> $engine_type
@@ -8,31 +10,19 @@
 #                           2. $other_handler_engine_type must point to an all
 #                              time available storage engine
 #                              2006-08 MySQL 5.1 MyISAM and MEMORY only
-# have to be set before sourcing this script.
--- source include/not_embedded.inc
 #
 # test of HANDLER ...
 #
 # Last update:
 # 2006-07-31 ML test refactored (MySQL 5.1)
 #               code of t/handler.test and t/innodb_handler.test united
-#               main testing code put into include/handler.inc
-#
-
-eval SET SESSION STORAGE_ENGINE = $engine_type;
-
---disable_warnings
-drop table if exists t1,t3,t4,t5;
---enable_warnings
-
-create table t1 (a int, b char(10), key a(a), key b(a,b));
-insert into t1 values
-(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
-(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
-(20,"ggg"),(21,"hhh"),(22,"iii");
+#               main testing code put into handler.inc
+#
+
+#
+# Start testing the table created in init.inc
+#
 handler t1 open as t2;
--- error 1064
-handler t2 read a=(SELECT 1);
 handler t2 read a first;
 handler t2 read a next;
 handler t2 read a next;
@@ -65,12 +55,34 @@
 handler t2 read a=(11);
 handler t2 read a>=(11);
 
+# Search on something we ca nfind
 handler t2 read a=(18);
 handler t2 read a>=(18);
 handler t2 read a>(18);
 handler t2 read a<=(18);
 handler t2 read a<(18);
 
+# Search on something we can't find
+handler t2 read a=(15);
+handler t2 read a>=(15);
+handler t2 read a>(15);
+handler t2 read a<=(15);
+handler t2 read a<(15);
+
+# Search from upper end
+handler t2 read a=(54);
+handler t2 read a>=(54);
+handler t2 read a>(54);
+handler t2 read a<=(54);
+handler t2 read a<(54);
+
+# Search from lower end
+handler t2 read a=(1);
+handler t2 read a>=(1);
+handler t2 read a>(1);
+handler t2 read a<=(1);
+handler t2 read a<(1);
+
 handler t2 read a first limit 5;
 handler t2 read a next  limit 3;
 handler t2 read a prev  limit 10;
@@ -85,8 +97,6 @@
 handler t2 read first;
 handler t2 read next;
 handler t2 read next;
---error 1064
-handler t2 read last;
 handler t2 close;
 
 handler t1 open;
@@ -110,7 +120,7 @@
 #
 handler t1 open as t2;
 drop table t1;
-create table t1 (a int);
+create table t1 (a int not null);
 insert into t1 values (17);
 --error 1109
 handler t2 read first;
@@ -137,7 +147,7 @@
 #
 # Test for #751
 #
-create table t1(a int, index(a));
+eval create table t1(a int, index $key_type (a));
 insert into t1 values (1), (2), (3);
 handler t1 open;
 --error 1054
@@ -164,7 +174,7 @@
 #
 # BUG#3649
 #
-create table t1 ( a int, b int, INDEX a (a) );
+eval create table t1 ( a int, b int, INDEX a $key_type (a) );
 insert into t1 values (1,2), (2,1);
 handler t1 open;
 handler t1 read a=(1) where b=2;
@@ -174,143 +184,6 @@
 drop table t1;
 
 #
-# Check if two database names beginning the same are seen as different.
-#
-# This database begins like the usual 'test' database.
-#
---disable_warnings
-drop database if exists test_test;
---enable_warnings
-create database test_test;
-use test_test;
-create table t1(table_id char(20) primary key);
-insert into t1 values ('test_test.t1');
-insert into t1 values ('');
-handler t1 open;
-handler t1 read first limit 9;
-create table t2(table_id char(20) primary key);
-insert into t2 values ('test_test.t2');
-insert into t2 values ('');
-handler t2 open;
-handler t2 read first limit 9;
-#
-# This is the usual 'test' database.
-#
-use test;
---disable_warnings
-drop table if exists t1;
---enable_warnings
-create table t1(table_id char(20) primary key);
-insert into t1 values ('test.t1');
-insert into t1 values ('');
---error 1066
-handler t1 open;
-#
-# Check accesibility of all the tables.
-#
-use test;
---error 1064
-handler test.t1 read first limit 9;
---error 1064
-handler test_test.t1 read first limit 9;
-handler t1 read first limit 9;
---error 1064
-handler test_test.t2 read first limit 9;
-handler t2 read first limit 9;
-
-#
-# Cleanup.
-#
-
---error 1064
-handler test_test.t1 close;
-handler t1 close;
-drop table test_test.t1;
---error 1064
-handler test_test.t2 close;
-handler t2 close;
-drop table test_test.t2;
-drop database test_test;
-
-#
-use test;
---error 1064
-handler test.t1 close;
---error 1109
-handler t1 close;
-drop table test.t1;
-
-#
-# BUG#4335
-#
---disable_warnings
-drop database if exists test_test;
-drop table if exists t1;
-drop table if exists t2;
-drop table if exists t3;
---enable_warnings
-create database test_test;
-use test_test;
-create table t1 (c1 char(20));
-insert into t1 values ('test_test.t1');
-create table t3 (c1 char(20));
-insert into t3 values ('test_test.t3');
-handler t1 open;
-handler t1 read first limit 9;
-handler t1 open h1;
-handler h1 read first limit 9;
-use test;
-create table t1 (c1 char(20));
-create table t2 (c1 char(20));
-create table t3 (c1 char(20));
-insert into t1 values ('t1');
-insert into t2 values ('t2');
-insert into t3 values ('t3');
---error 1066
-handler t1 open;
---error 1066
-handler t2 open t1;
---error 1066
-handler t3 open t1;
-handler t1 read first limit 9;
---error 1064
-handler test.t1 close;
---error 1066
-handler test.t1 open h1;
---error 1066
-handler test_test.t1 open h1;
-handler test_test.t3 open h3;
-handler test.t1 open h2;
-handler t1 read first limit 9;
-handler h1 read first limit 9;
-handler h2 read first limit 9;
-handler h3 read first limit 9;
-handler h2 read first limit 9;
---error 1064
-handler test.h1 close;
-handler t1 close;
-handler h1 close;
-handler h2 close;
---error 1109
-handler t1 read first limit 9;
---error 1109
-handler h1 read first limit 9;
---error 1109
-handler h2 read first limit 9;
-handler h3 read first limit 9;
-handler h3 read first limit 9;
-use test_test;
-handler h3 read first limit 9;
---error 1064
-handler test.h3 read first limit 9;
-handler h3 close;
-use test;
-drop table t3;
-drop table t2;
-drop table t1;
-drop database test_test;
-
-#
 # Test if fix for BUG#4286 correctly closes handler tables.
 #
 create table t1 (c1 char(20));
@@ -410,11 +283,13 @@
 connection default;
 drop table t1;
 
-CREATE TABLE t1 (  no1 smallint(5) NOT NULL default '0',  no2 int(10) NOT NULL default '0',  PRIMARY KEY  (no1,no2));
+eval CREATE TABLE t1 (  no1 smallint(5) NOT NULL default '0',  no2 int(10) NOT NULL default '0',  PRIMARY KEY $key_type (no1,no2));
 INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
 HANDLER t1 OPEN;
 HANDLER t1 READ `primary` = (1, 1000);
 HANDLER t1 READ `primary` PREV;
+HANDLER t1 READ `primary` = (1, 1000);
+HANDLER t1 READ `primary` NEXT;
 DROP TABLE t1;
 
 # End of 4.1 tests
@@ -468,10 +343,7 @@
 #
 # Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one
 #
---disable_warnings
-drop table if exists t1;
---enable_warnings
-eval create table t1 (a int) ENGINE=$other_engine_type;
+eval create table t1 (a int not null) ENGINE=$other_engine_type;
 --echo --> client 2
 connection con2;
 --error 1031
@@ -484,9 +356,6 @@
 #
 # Bug#30632 HANDLER read failure causes hang
 #
---disable_warnings
-drop table if exists t1;
---enable_warnings
 create table t1 (a int);
 handler t1 open as t1_alias;
 --error 1176
@@ -501,89 +370,18 @@
 drop table t1;
 
 #
-# Bug#21587 FLUSH TABLES causes server crash when used with HANDLER statements
-#
-
---disable_warnings
-drop table if exists t1,t2;
---enable_warnings
-create table t1 (c1 int);
-create table t2 (c1 int);
-insert into t1 values (1);
-insert into t2 values (2);
---echo connection: default
-handler t1 open;
-handler t1 read first;
-connect (flush,localhost,root,,);
-connection flush;
---echo connection: flush
---send flush tables;
-connection default;
---echo connection: default
-let $wait_condition=
-  select count(*) = 1 from information_schema.processlist
-  where state = "Flushing tables";
---source include/wait_condition.inc
-handler t2 open;
-handler t2 read first;
-handler t1 read next;
-handler t1 close;
-handler t2 close;
-connection flush;
-reap;
-connection default;
-drop table t1,t2;
-disconnect flush;
-
-#
-# Bug#31409 RENAME TABLE causes server crash or deadlock when used with HANDLER statements
-#
-
---disable_warnings
-drop table if exists t1,t2;
---enable_warnings
-create table t1 (c1 int);
---echo connection: default
-handler t1 open;
-handler t1 read first;
-connect (flush,localhost,root,,);
-connection flush;
---echo connection: flush
---send rename table t1 to t2;
-connection default;
---echo connection: default
-let $wait_condition=
-  select count(*) = 1 from information_schema.processlist
-  where state = "Waiting for table" and info = "rename table t1 to t2";
---source include/wait_condition.inc
-handler t2 open;
-handler t2 read first;
---error ER_NO_SUCH_TABLE
-handler t1 read next;
-handler t1 close;
-handler t2 close;
-connection flush;
-reap;
-connection default;
-drop table t2;
-disconnect flush;
-
-#
 # Bug#30882 Dropping a temporary table inside a stored function may cause a server crash
 #
 # Test HANDLER statements in conjunction with temporary tables. While the temporary table
 # is open by a HANDLER, no other statement can access it.
 #
 
---disable_warnings
-drop table if exists t1;
---enable_warnings
-create temporary table t1 (a int, b char(1), key a(a), key b(a,b));
+eval create temporary table t1 (a int, b char(1), key a $key_type (a), key b(a,b));
 insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
-                      (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
+                      (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
 select a,b from t1;
 handler t1 open as a1;
-handler a1 read a first;
+handler a1 read a=(1);
 handler a1 read a next;
 handler a1 read a next;
 --error ER_CANT_REOPEN_TABLE
@@ -594,41 +392,19 @@
 handler a1 close;
 select a,b from t1;
 handler t1 open as a2;
-handler a2 read a first;
+handler a2 read a=(9);
+handler a2 read a next;
+handler a2 read a prev limit 2;
+--error 0,1031
 handler a2 read a last;
 handler a2 read a prev;
 handler a2 close;
 drop table t1;
 
-#
-# Bug#31397 Inconsistent drop table behavior of handler tables.
-#
-
---disable_warnings
-drop table if exists t1,t2;
---enable_warnings
-create table t1 (a int);
-handler t1 open as t1_alias;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-flush tables;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-handler t1_alias close;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-handler t1_alias read first;
-drop table t1;
---error ER_UNKNOWN_TABLE
-handler t1_alias read next;
-
 # Test that temporary tables associated with handlers are properly dropped.
 
 create table t1 (a int);
-create temporary table t2 (a int, key(a));
+eval create temporary table t2 (a int, key $key_type (a));
 handler t1 open as a1;
 handler t2 open as a2;
 handler a2 read a first;
@@ -640,7 +416,7 @@
 
 # Alter table drop handlers
 
-create table t1 (a int, key(a));
+eval create table t1 (a int, key $key_type (a));
 create table t2 like t1;
 handler t1 open as a1;
 handler t2 open as a2;
@@ -654,7 +430,7 @@
 
 # Rename table drop handlers
 
-create table t1 (a int, key(a));
+eval create table t1 (a int, key $key_type (a));
 handler t1 open as a1;
 handler a1 read a first;
 rename table t1 to t2;
@@ -664,7 +440,7 @@
 
 # Optimize table drop handlers
 
-create table t1 (a int, key(a));
+eval create table t1 (a int, key $key_type (a));
 create table t2 like t1;
 handler t1 open as a1;
 handler t2 open as a2;
@@ -676,56 +452,14 @@
 handler a2 close;
 drop table t1, t2;
 
-# Flush tables causes handlers reopen
-
-create table t1 (a int, b char(1), key a(a), key b(a,b));
-insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
-                      (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
-handler t1 open;
-handler t1 read a first;
-handler t1 read a next;
-flush tables;
-handler t1 read a next;
-handler t1 read a next;
-flush tables with read lock;
-handler t1 read a next;
-unlock tables;
-drop table t1;
---error ER_UNKNOWN_TABLE
-handler t1 read a next;
-
-#
-# Bug#41110: crash with handler command when used concurrently with alter table
-# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table
-#
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-create table t1 (a int);
-insert into t1 values (1);
-handler t1 open;
-connect(con1,localhost,root,,);
-send alter table t1 engine=memory;
-connection default;
-let $wait_condition=
-  select count(*) = 1 from information_schema.processlist
-  where state = "rename result table" and info = "alter table t1 engine=memory";
---source include/wait_condition.inc
---error ER_ILLEGAL_HA
-handler t1 read a next;
-handler t1 close;
-connection con1;
---reap
-drop table t1;
-disconnect con1;
---source include/wait_until_disconnected.inc
-connection default;
-
-#
-# Bug#44151 using handler commands on information_schema tables crashes server
-#
-USE information_schema;
---error ER_WRONG_USAGE
-HANDLER COLUMNS OPEN;
-USE test;
+--echo #
+--echo # BUG#51877 - HANDLER interface causes invalid memory read
+--echo #
+eval CREATE TABLE t1(a INT, KEY $key_type (a));
+HANDLER t1 OPEN;
+HANDLER t1 READ a FIRST;
+INSERT INTO t1 VALUES(1);
+--error 0,ER_CHECKREAD
+HANDLER t1 READ a NEXT;
+HANDLER t1 CLOSE;
+DROP TABLE t1;

=== added file 'mysql-test/suite/handler/init.inc'
--- a/mysql-test/suite/handler/init.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/handler/init.inc	2011-01-10 21:22:40 +0000
@@ -0,0 +1,33 @@
+# Setup things for handler.inc
+#
+# Input variables
+#     $engine_type       -- storage engine to be tested
+#     $key_type          -- set if you want a non standard key type
+#
+# This scripts sets up default values for:
+#     $other_engine_type -- storage engine <> $engine_type
+#     $other_handler_engine_type -- storage engine <> $engine_type, if possible
+#                           1. $other_handler_engine_type must support handler
+#                           2. $other_handler_engine_type must point to an all
+#                              time available storage engine
+# have to be set before sourcing this script.
+#
+# Handler tests don't work with embedded server
+#
+-- source include/not_embedded.inc
+
+eval SET SESSION STORAGE_ENGINE = $engine_type;
+let $other_engine_type= CSV;
+let $other_handler_engine_type= MyISAM;
+
+--disable_warnings
+drop table if exists t1,t3,t4,t5;
+--enable_warnings
+
+# Create default test table
+
+eval create table t1 (a int, b char(10), key a $key_type (a), key b $key_type (a,b));
+insert into t1 values
+(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
+(14,"aaa"),(16,"ccc"),(16,"xxx"),
+(20,"ggg"),(21,"hhh"),(22,"iii");

=== renamed file 'mysql-test/r/handler_innodb.result' => 'mysql-test/suite/handler/innodb.result'
--- a/mysql-test/r/handler_innodb.result	2009-07-10 23:12:13 +0000
+++ b/mysql-test/suite/handler/innodb.result	2011-01-12 13:41:39 +0000
@@ -1,25 +1,23 @@
 SET SESSION STORAGE_ENGINE = InnoDB;
 drop table if exists t1,t3,t4,t5;
-create table t1 (a int, b char(10), key a(a), key b(a,b));
+create table t1 (a int, b char(10), key a  (a), key b  (a,b));
 insert into t1 values
 (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
-(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
+(14,"aaa"),(16,"ccc"),(16,"xxx"),
 (20,"ggg"),(21,"hhh"),(22,"iii");
 handler t1 open as t2;
-handler t2 read a=(SELECT 1);
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
 handler t2 read a first;
 a	b
 14	aaa
 handler t2 read a next;
 a	b
-15	bbb
-handler t2 read a next;
-a	b
 16	ccc
+handler t2 read a next;
+a	b
+16	xxx
 handler t2 read a prev;
 a	b
-15	bbb
+16	ccc
 handler t2 read a last;
 a	b
 22	iii
@@ -47,7 +45,6 @@
 a	b
 handler t2 read a=(15);
 a	b
-15	bbb
 handler t2 read a=(16);
 a	b
 16	ccc
@@ -84,26 +81,64 @@
 handler t2 read a<(18);
 a	b
 17	ddd
+handler t2 read a=(15);
+a	b
+handler t2 read a>=(15);
+a	b
+16	ccc
+handler t2 read a>(15);
+a	b
+16	ccc
+handler t2 read a<=(15);
+a	b
+14	aaa
+handler t2 read a<(15);
+a	b
+14	aaa
+handler t2 read a=(54);
+a	b
+handler t2 read a>=(54);
+a	b
+handler t2 read a>(54);
+a	b
+handler t2 read a<=(54);
+a	b
+22	iii
+handler t2 read a<(54);
+a	b
+22	iii
+handler t2 read a=(1);
+a	b
+handler t2 read a>=(1);
+a	b
+14	aaa
+handler t2 read a>(1);
+a	b
+14	aaa
+handler t2 read a<=(1);
+a	b
+handler t2 read a<(1);
+a	b
 handler t2 read a first limit 5;
 a	b
 14	aaa
-15	bbb
 16	ccc
 16	xxx
 17	ddd
+18	eee
 handler t2 read a next  limit 3;
 a	b
-18	eee
 19	fff
 19	yyy
+20	ggg
 handler t2 read a prev  limit 10;
 a	b
+19	yyy
 19	fff
 18	eee
 17	ddd
 16	xxx
 16	ccc
-15	bbb
 14	aaa
 handler t2 read a>=(16) limit 4;
 a	b
@@ -135,8 +170,6 @@
 handler t2 read next;
 a	b
 19	fff
-handler t2 read last;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
 handler t2 close;
 handler t1 open;
 handler t1 read a next;
@@ -144,7 +177,7 @@
 14	aaa
 handler t1 read a next;
 a	b
-15	bbb
+16	ccc
 handler t1 close;
 handler t1 open;
 handler t1 read a prev;
@@ -163,12 +196,12 @@
 ERROR 42S02: Unknown table 't2' in HANDLER
 handler t1 open as t2;
 drop table t1;
-create table t1 (a int);
+create table t1 (a int not null);
 insert into t1 values (17);
 handler t2 read first;
 ERROR 42S02: Unknown table 't2' in HANDLER
 handler t1 open as t2;
-alter table t1 engine=MEMORY;
+alter table t1 engine=CSV;
 handler t2 read first;
 ERROR 42S02: Unknown table 't2' in HANDLER
 drop table t1;
@@ -191,7 +224,7 @@
 a
 6
 drop table t1;
-create table t1(a int, index(a));
+create table t1(a int, index  (a));
 insert into t1 values (1), (2), (3);
 handler t1 open;
 handler t1 read a=(W);
@@ -217,7 +250,7 @@
 handler t close;
 use test;
 drop table t1;
-create table t1 ( a int, b int, INDEX a (a) );
+create table t1 ( a int, b int, INDEX a  (a) );
 insert into t1 values (1,2), (2,1);
 handler t1 open;
 handler t1 read a=(1) where b=2;
@@ -229,148 +262,6 @@
 a	b
 handler t1 close;
 drop table t1;
-drop database if exists test_test;
-create database test_test;
-use test_test;
-create table t1(table_id char(20) primary key);
-insert into t1 values ('test_test.t1');
-insert into t1 values ('');
-handler t1 open;
-handler t1 read first limit 9;
-table_id
-
-test_test.t1
-create table t2(table_id char(20) primary key);
-insert into t2 values ('test_test.t2');
-insert into t2 values ('');
-handler t2 open;
-handler t2 read first limit 9;
-table_id
-
-test_test.t2
-use test;
-drop table if exists t1;
-create table t1(table_id char(20) primary key);
-insert into t1 values ('test.t1');
-insert into t1 values ('');
-handler t1 open;
-ERROR 42000: Not unique table/alias: 't1'
-use test;
-handler test.t1 read first limit 9;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
-handler test_test.t1 read first limit 9;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
-handler t1 read first limit 9;
-table_id
-
-test_test.t1
-handler test_test.t2 read first limit 9;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
-handler t2 read first limit 9;
-table_id
-
-test_test.t2
-handler test_test.t1 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler t1 close;
-drop table test_test.t1;
-handler test_test.t2 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler t2 close;
-drop table test_test.t2;
-drop database test_test;
-use test;
-handler test.t1 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler t1 close;
-ERROR 42S02: Unknown table 't1' in HANDLER
-drop table test.t1;
-drop database if exists test_test;
-drop table if exists t1;
-drop table if exists t2;
-drop table if exists t3;
-create database test_test;
-use test_test;
-create table t1 (c1 char(20));
-insert into t1 values ('test_test.t1');
-create table t3 (c1 char(20));
-insert into t3 values ('test_test.t3');
-handler t1 open;
-handler t1 read first limit 9;
-c1
-test_test.t1
-handler t1 open h1;
-handler h1 read first limit 9;
-c1
-test_test.t1
-use test;
-create table t1 (c1 char(20));
-create table t2 (c1 char(20));
-create table t3 (c1 char(20));
-insert into t1 values ('t1');
-insert into t2 values ('t2');
-insert into t3 values ('t3');
-handler t1 open;
-ERROR 42000: Not unique table/alias: 't1'
-handler t2 open t1;
-ERROR 42000: Not unique table/alias: 't1'
-handler t3 open t1;
-ERROR 42000: Not unique table/alias: 't1'
-handler t1 read first limit 9;
-c1
-test_test.t1
-handler test.t1 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler test.t1 open h1;
-ERROR 42000: Not unique table/alias: 'h1'
-handler test_test.t1 open h1;
-ERROR 42000: Not unique table/alias: 'h1'
-handler test_test.t3 open h3;
-handler test.t1 open h2;
-handler t1 read first limit 9;
-c1
-test_test.t1
-handler h1 read first limit 9;
-c1
-test_test.t1
-handler h2 read first limit 9;
-c1
-t1
-handler h3 read first limit 9;
-c1
-test_test.t3
-handler h2 read first limit 9;
-c1
-t1
-handler test.h1 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler t1 close;
-handler h1 close;
-handler h2 close;
-handler t1 read first limit 9;
-ERROR 42S02: Unknown table 't1' in HANDLER
-handler h1 read first limit 9;
-ERROR 42S02: Unknown table 'h1' in HANDLER
-handler h2 read first limit 9;
-ERROR 42S02: Unknown table 'h2' in HANDLER
-handler h3 read first limit 9;
-c1
-test_test.t3
-handler h3 read first limit 9;
-c1
-test_test.t3
-use test_test;
-handler h3 read first limit 9;
-c1
-test_test.t3
-handler test.h3 read first limit 9;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
-handler h3 close;
-use test;
-drop table t3;
-drop table t2;
-drop table t1;
-drop database test_test;
 create table t1 (c1 char(20));
 insert into t1 values ("t1");
 handler t1 open as h1;
@@ -496,6 +387,11 @@
 HANDLER t1 READ `primary` PREV;
 no1	no2
 1	275
+HANDLER t1 READ `primary` = (1, 1000);
+no1	no2
+HANDLER t1 READ `primary` NEXT;
+no1	no2
+2	8
 DROP TABLE t1;
 create table t1 (c1 int);
 insert into t1 values (14397);
@@ -516,14 +412,12 @@
 drop table if exists t1;
 Warnings:
 Note	1051	Unknown table 't1'
-drop table if exists t1;
-create table t1 (a int) ENGINE=MEMORY;
+create table t1 (a int not null) ENGINE=CSV;
 --> client 2
 handler t1 open;
 ERROR HY000: Table storage engine for 't1' doesn't have this option
 --> client 1
 drop table t1;
-drop table if exists t1;
 create table t1 (a int);
 handler t1 open as t1_alias;
 handler t1_alias read a next;
@@ -536,50 +430,9 @@
 ERROR 42S22: Unknown column 'inexistent' in 'field list'
 handler t1_alias close;
 drop table t1;
-drop table if exists t1,t2;
-create table t1 (c1 int);
-create table t2 (c1 int);
-insert into t1 values (1);
-insert into t2 values (2);
-connection: default
-handler t1 open;
-handler t1 read first;
-c1
-1
-connection: flush
-flush tables;;
-connection: default
-handler t2 open;
-handler t2 read first;
-c1
-2
-handler t1 read next;
-c1
-1
-handler t1 close;
-handler t2 close;
-drop table t1,t2;
-drop table if exists t1,t2;
-create table t1 (c1 int);
-connection: default
-handler t1 open;
-handler t1 read first;
-c1
-connection: flush
-rename table t1 to t2;;
-connection: default
-handler t2 open;
-handler t2 read first;
-c1
-handler t1 read next;
-ERROR 42S02: Table 'test.t1' doesn't exist
-handler t1 close;
-handler t2 close;
-drop table t2;
-drop table if exists t1;
-create temporary table t1 (a int, b char(1), key a(a), key b(a,b));
+create temporary table t1 (a int, b char(1), key a  (a), key b(a,b));
 insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
-(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
+(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
 select a,b from t1;
 a	b
 0	a
@@ -592,24 +445,25 @@
 7	h
 8	i
 9	j
+9	k
 handler t1 open as a1;
-handler a1 read a first;
-a	b
-0	a
-handler a1 read a next;
+handler a1 read a=(1);
 a	b
 1	b
 handler a1 read a next;
 a	b
 2	c
+handler a1 read a next;
+a	b
+3	d
 select a,b from t1;
 ERROR HY000: Can't reopen table: 'a1'
 handler a1 read a prev;
 a	b
+2	c
+handler a1 read a prev;
+a	b
 1	b
-handler a1 read a prev;
-a	b
-0	a
 handler a1 read a=(6) where b="g";
 a	b
 6	g
@@ -626,39 +480,28 @@
 7	h
 8	i
 9	j
+9	k
 handler t1 open as a2;
-handler a2 read a first;
-a	b
-0	a
+handler a2 read a=(9);
+a	b
+9	j
+handler a2 read a next;
+a	b
+9	k
+handler a2 read a prev limit 2;
+a	b
+9	j
+8	i
 handler a2 read a last;
 a	b
-9	j
+9	k
 handler a2 read a prev;
 a	b
-8	i
+9	j
 handler a2 close;
 drop table t1;
-drop table if exists t1,t2;
-create table t1 (a int);
-handler t1 open as t1_alias;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-flush tables;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-handler t1_alias close;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-handler t1_alias read first;
-a
-drop table t1;
-handler t1_alias read next;
-ERROR 42S02: Unknown table 't1_alias' in HANDLER
-create table t1 (a int);
-create temporary table t2 (a int, key(a));
+create table t1 (a int);
+create temporary table t2 (a int, key  (a));
 handler t1 open as a1;
 handler t2 open as a2;
 handler a2 read a first;
@@ -668,7 +511,7 @@
 ERROR 42S02: Unknown table 'a2' in HANDLER
 handler a1 close;
 ERROR 42S02: Unknown table 'a1' in HANDLER
-create table t1 (a int, key(a));
+create table t1 (a int, key  (a));
 create table t2 like t1;
 handler t1 open as a1;
 handler t2 open as a2;
@@ -681,7 +524,7 @@
 ERROR 42S02: Unknown table 'a1' in HANDLER
 handler a2 close;
 drop table t1, t2;
-create table t1 (a int, key(a));
+create table t1 (a int, key  (a));
 handler t1 open as a1;
 handler a1 read a first;
 a
@@ -689,7 +532,7 @@
 handler a1 read a first;
 ERROR 42S02: Unknown table 'a1' in HANDLER
 drop table t2;
-create table t1 (a int, key(a));
+create table t1 (a int, key  (a));
 create table t2 like t1;
 handler t1 open as a1;
 handler t2 open as a2;
@@ -705,41 +548,25 @@
 ERROR 42S02: Unknown table 'a1' in HANDLER
 handler a2 close;
 drop table t1, t2;
-create table t1 (a int, b char(1), key a(a), key b(a,b));
-insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
-(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
-handler t1 open;
-handler t1 read a first;
-a	b
-0	a
-handler t1 read a next;
-a	b
-1	b
-flush tables;
-handler t1 read a next;
-a	b
-0	a
-handler t1 read a next;
-a	b
-1	b
-flush tables with read lock;
-handler t1 read a next;
-a	b
-0	a
-unlock tables;
-drop table t1;
-handler t1 read a next;
-ERROR 42S02: Unknown table 't1' in HANDLER
-drop table if exists t1;
-create table t1 (a int);
-insert into t1 values (1);
-handler t1 open;
-alter table t1 engine=memory;
-handler t1 read a next;
-ERROR HY000: Table storage engine for 't1' doesn't have this option
-handler t1 close;
-drop table t1;
-USE information_schema;
-HANDLER COLUMNS OPEN;
-ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema
-USE test;
+#
+# BUG#51877 - HANDLER interface causes invalid memory read
+#
+CREATE TABLE t1(a INT, KEY  (a));
+HANDLER t1 OPEN;
+HANDLER t1 READ a FIRST;
+a
+INSERT INTO t1 VALUES(1);
+HANDLER t1 READ a NEXT;
+a
+HANDLER t1 CLOSE;
+DROP TABLE t1;
+CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f2 <= 1;
+f1	f2
+1	1
+HANDLER t1 READ `PRIMARY` PREV;
+f1	f2
+3	3
+DROP TABLE t1;

=== renamed file 'mysql-test/t/handler_innodb.test' => 'mysql-test/suite/handler/innodb.test'
--- a/mysql-test/t/handler_innodb.test	2006-08-16 17:29:49 +0000
+++ b/mysql-test/suite/handler/innodb.test	2011-01-12 13:41:39 +0000
@@ -5,16 +5,24 @@
 # Last update:
 # 2006-07-31 ML test refactored (MySQL 5.1)
 #               code of t/handler.test and t/innodb_handler.test united
-#               main testing code put into include/handler.inc
+#               main testing code put into handler.inc
 #               rename t/innodb_handler.test to t/handler_innodb.test
 #
 
-# should work in embedded server after mysqltest is fixed
---source include/not_embedded.inc
-
 --source include/have_innodb.inc
+
 let $engine_type= InnoDB;
-let $other_engine_type= MEMORY;
-let $other_handler_engine_type= MyISAM;
-
---source include/handler.inc
+
+--source init.inc
+--source handler.inc
+
+#
+# LP#697610 ha_index_prev(uchar*): Assertion `inited==INDEX'
+#
+
+CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f2 <= 1;
+HANDLER t1 READ `PRIMARY` PREV;
+DROP TABLE t1;

=== added file 'mysql-test/suite/handler/interface.result'
--- a/mysql-test/suite/handler/interface.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/handler/interface.result	2011-01-10 21:22:40 +0000
@@ -0,0 +1,259 @@
+drop table if exists t1,t3,t4,t5;
+drop database if exists test_test;
+SET SESSION STORAGE_ENGINE = MyISAM;
+drop table if exists t1,t3,t4,t5;
+create table t1 (a int, b char(10), key a  (a), key b  (a,b));
+insert into t1 values
+(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
+(14,"aaa"),(16,"ccc"),(16,"xxx"),
+(20,"ggg"),(21,"hhh"),(22,"iii");
+handler t1 open;
+handler t1 read a=(SELECT 1);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
+handler t1 read a=(1) FIRST;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIRST' at line 1
+handler t1 read a=(1) NEXT;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NEXT' at line 1
+handler t1 read last;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+handler t1 close;
+drop table t1;
+CREATE TABLE t1(a INT, PRIMARY KEY(a));
+insert into t1 values(1),(2);
+handler t1 open;
+handler t1 read primary=(1);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary=(1)' at line 1
+handler t1 read `primary`=(1);
+a
+1
+handler t1 close;
+drop table t1;
+create database test_test;
+use test_test;
+create table t1(table_id char(20), primary key  (table_id));
+insert into t1 values ('test_test.t1');
+insert into t1 values ('');
+handler t1 open;
+handler t1 read first limit 9;
+table_id
+test_test.t1
+
+create table t2(table_id char(20), primary key  (table_id));
+insert into t2 values ('test_test.t2');
+insert into t2 values ('');
+handler t2 open;
+handler t2 read first limit 9;
+table_id
+test_test.t2
+
+use test;
+create table t1(table_id char(20), primary key  (table_id));
+insert into t1 values ('test.t1');
+insert into t1 values ('');
+handler t1 open;
+ERROR 42000: Not unique table/alias: 't1'
+use test;
+handler test.t1 read first limit 9;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
+handler test_test.t1 read first limit 9;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
+handler t1 read first limit 9;
+table_id
+test_test.t1
+
+handler test_test.t2 read first limit 9;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
+handler t2 read first limit 9;
+table_id
+test_test.t2
+
+handler test_test.t1 close;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
+handler t1 close;
+drop table test_test.t1;
+handler test_test.t2 close;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
+handler t2 close;
+drop table test_test.t2;
+drop database test_test;
+use test;
+handler test.t1 close;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
+handler t1 close;
+ERROR 42S02: Unknown table 't1' in HANDLER
+drop table test.t1;
+create database test_test;
+use test_test;
+create table t1 (c1 char(20));
+insert into t1 values ('test_test.t1');
+create table t3 (c1 char(20));
+insert into t3 values ('test_test.t3');
+handler t1 open;
+handler t1 read first limit 9;
+c1
+test_test.t1
+handler t1 open h1;
+handler h1 read first limit 9;
+c1
+test_test.t1
+use test;
+create table t1 (c1 char(20));
+create table t2 (c1 char(20));
+create table t3 (c1 char(20));
+insert into t1 values ('t1');
+insert into t2 values ('t2');
+insert into t3 values ('t3');
+handler t1 open;
+ERROR 42000: Not unique table/alias: 't1'
+handler t2 open t1;
+ERROR 42000: Not unique table/alias: 't1'
+handler t3 open t1;
+ERROR 42000: Not unique table/alias: 't1'
+handler t1 read first limit 9;
+c1
+test_test.t1
+handler test.t1 close;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
+handler test.t1 open h1;
+ERROR 42000: Not unique table/alias: 'h1'
+handler test_test.t1 open h1;
+ERROR 42000: Not unique table/alias: 'h1'
+handler test_test.t3 open h3;
+handler test.t1 open h2;
+handler t1 read first limit 9;
+c1
+test_test.t1
+handler h1 read first limit 9;
+c1
+test_test.t1
+handler h2 read first limit 9;
+c1
+t1
+handler h3 read first limit 9;
+c1
+test_test.t3
+handler h2 read first limit 9;
+c1
+t1
+handler test.h1 close;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
+handler t1 close;
+handler h1 close;
+handler h2 close;
+handler t1 read first limit 9;
+ERROR 42S02: Unknown table 't1' in HANDLER
+handler h1 read first limit 9;
+ERROR 42S02: Unknown table 'h1' in HANDLER
+handler h2 read first limit 9;
+ERROR 42S02: Unknown table 'h2' in HANDLER
+handler h3 read first limit 9;
+c1
+test_test.t3
+handler h3 read first limit 9;
+c1
+test_test.t3
+use test_test;
+handler h3 read first limit 9;
+c1
+test_test.t3
+handler test.h3 read first limit 9;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
+handler h3 close;
+use test;
+drop table t3;
+drop table t2;
+drop table t1;
+drop database test_test;
+create table t1 (c1 int);
+create table t2 (c1 int);
+insert into t1 values (1);
+insert into t2 values (2);
+connection: default
+handler t1 open;
+handler t1 read first;
+c1
+1
+connection: flush
+flush tables;;
+connection: default
+handler t2 open;
+handler t2 read first;
+c1
+2
+handler t1 read next;
+c1
+1
+handler t1 close;
+handler t2 close;
+drop table t1,t2;
+create table t1 (a int);
+handler t1 open as t1_alias;
+drop table t1;
+create table t1 (a int);
+handler t1 open as t1_alias;
+flush tables;
+drop table t1;
+create table t1 (a int);
+handler t1 open as t1_alias;
+handler t1_alias close;
+drop table t1;
+create table t1 (a int);
+handler t1 open as t1_alias;
+handler t1_alias read first;
+a
+drop table t1;
+handler t1_alias read next;
+ERROR 42S02: Unknown table 't1_alias' in HANDLER
+create table t1 (c1 int);
+connection: default
+handler t1 open;
+handler t1 read first;
+c1
+connection: flush
+rename table t1 to t2;;
+connection: default
+handler t2 open;
+handler t2 read first;
+c1
+handler t1 read next;
+ERROR 42S02: Table 'test.t1' doesn't exist
+handler t1 close;
+handler t2 close;
+drop table t2;
+create table t1 (a int, b char(1), key a  (a), key b  (a,b));
+insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
+(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
+handler t1 open;
+handler t1 read a first;
+a	b
+0	a
+handler t1 read a next;
+a	b
+1	b
+flush tables;
+handler t1 read a next;
+a	b
+0	a
+handler t1 read a next;
+a	b
+1	b
+flush tables with read lock;
+handler t1 read a next;
+a	b
+0	a
+unlock tables;
+drop table t1;
+handler t1 read a next;
+ERROR 42S02: Unknown table 't1' in HANDLER
+drop table if exists t1;
+create table t1 (a int not null);
+insert into t1 values (1);
+handler t1 open;
+alter table t1 engine=csv;
+handler t1 read a next;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+handler t1 close;
+drop table t1;
+USE information_schema;
+HANDLER COLUMNS OPEN;
+ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema

=== added file 'mysql-test/suite/handler/interface.test'
--- a/mysql-test/suite/handler/interface.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/handler/interface.test	2011-01-10 21:22:40 +0000
@@ -0,0 +1,307 @@
+#
+# Tests of handler interface that are system independent
+#
+# Handler tests don't work yet with embedded server
+#
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1,t3,t4,t5;
+drop database if exists test_test;
+--enable_warnings
+
+# Run tests with myisam (any engine should be ok)
+
+let $engine_type= MyISAM;
+
+--source init.inc
+
+#
+# Do some syntax checking
+#
+
+handler t1 open;
+--error ER_PARSE_ERROR
+handler t1 read a=(SELECT 1);
+--error ER_PARSE_ERROR
+handler t1 read a=(1) FIRST;
+--error ER_PARSE_ERROR
+handler t1 read a=(1) NEXT;
+--error ER_PARSE_ERROR
+handler t1 read last;
+handler t1 close;
+drop table t1;
+
+CREATE TABLE t1(a INT, PRIMARY KEY(a));
+insert into t1 values(1),(2);
+handler t1 open;
+--error ER_PARSE_ERROR
+handler t1 read primary=(1);
+handler t1 read `primary`=(1);
+handler t1 close;
+drop table t1;
+
+#
+# Check if two database names beginning the same are seen as different.
+#
+# This database begins like the usual 'test' database.
+#
+create database test_test;
+use test_test;
+eval create table t1(table_id char(20), primary key $key_type (table_id));
+insert into t1 values ('test_test.t1');
+insert into t1 values ('');
+handler t1 open;
+handler t1 read first limit 9;
+eval create table t2(table_id char(20), primary key $key_type (table_id));
+insert into t2 values ('test_test.t2');
+insert into t2 values ('');
+handler t2 open;
+handler t2 read first limit 9;
+#
+# This is the usual 'test' database.
+#
+use test;
+eval create table t1(table_id char(20), primary key $key_type (table_id));
+insert into t1 values ('test.t1');
+insert into t1 values ('');
+--error 1066
+handler t1 open;
+#
+# Check accessibility of all the tables.
+#
+use test;
+--error 1064
+handler test.t1 read first limit 9;
+--error 1064
+handler test_test.t1 read first limit 9;
+handler t1 read first limit 9;
+--error 1064
+handler test_test.t2 read first limit 9;
+handler t2 read first limit 9;
+
+#
+# Cleanup.
+#
+
+--error 1064
+handler test_test.t1 close;
+handler t1 close;
+drop table test_test.t1;
+--error 1064
+handler test_test.t2 close;
+handler t2 close;
+drop table test_test.t2;
+drop database test_test;
+
+#
+use test;
+--error 1064
+handler test.t1 close;
+--error 1109
+handler t1 close;
+drop table test.t1;
+
+#
+# BUG#4335 one name can be handler open'ed many times
+#
+
+create database test_test;
+use test_test;
+create table t1 (c1 char(20));
+insert into t1 values ('test_test.t1');
+create table t3 (c1 char(20));
+insert into t3 values ('test_test.t3');
+handler t1 open;
+handler t1 read first limit 9;
+handler t1 open h1;
+handler h1 read first limit 9;
+use test;
+create table t1 (c1 char(20));
+create table t2 (c1 char(20));
+create table t3 (c1 char(20));
+insert into t1 values ('t1');
+insert into t2 values ('t2');
+insert into t3 values ('t3');
+--error 1066
+handler t1 open;
+--error 1066
+handler t2 open t1;
+--error 1066
+handler t3 open t1;
+handler t1 read first limit 9;
+--error 1064
+handler test.t1 close;
+--error 1066
+handler test.t1 open h1;
+--error 1066
+handler test_test.t1 open h1;
+handler test_test.t3 open h3;
+handler test.t1 open h2;
+handler t1 read first limit 9;
+handler h1 read first limit 9;
+handler h2 read first limit 9;
+handler h3 read first limit 9;
+handler h2 read first limit 9;
+--error 1064
+handler test.h1 close;
+handler t1 close;
+handler h1 close;
+handler h2 close;
+--error 1109
+handler t1 read first limit 9;
+--error 1109
+handler h1 read first limit 9;
+--error 1109
+handler h2 read first limit 9;
+handler h3 read first limit 9;
+handler h3 read first limit 9;
+use test_test;
+handler h3 read first limit 9;
+--error 1064
+handler test.h3 read first limit 9;
+handler h3 close;
+use test;
+drop table t3;
+drop table t2;
+drop table t1;
+drop database test_test;
+
+#
+# Bug#21587 FLUSH TABLES causes server crash when used with HANDLER statements
+#
+
+create table t1 (c1 int);
+create table t2 (c1 int);
+insert into t1 values (1);
+insert into t2 values (2);
+--echo connection: default
+handler t1 open;
+handler t1 read first;
+connect (flush,localhost,root,,);
+connection flush;
+--echo connection: flush
+--send flush tables;
+connection default;
+--echo connection: default
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Flushing tables";
+--source include/wait_condition.inc
+handler t2 open;
+handler t2 read first;
+handler t1 read next;
+handler t1 close;
+handler t2 close;
+connection flush;
+reap;
+connection default;
+drop table t1,t2;
+disconnect flush;
+
+#
+# Bug#31397 Inconsistent drop table behavior of handler tables.
+#
+
+create table t1 (a int);
+handler t1 open as t1_alias;
+drop table t1;
+create table t1 (a int);
+handler t1 open as t1_alias;
+flush tables;
+drop table t1;
+create table t1 (a int);
+handler t1 open as t1_alias;
+handler t1_alias close;
+drop table t1;
+create table t1 (a int);
+handler t1 open as t1_alias;
+handler t1_alias read first;
+drop table t1;
+--error ER_UNKNOWN_TABLE
+handler t1_alias read next;
+
+#
+# Bug#31409 RENAME TABLE causes server crash or deadlock when used with
+# HANDLER statements
+#
+
+create table t1 (c1 int);
+--echo connection: default
+handler t1 open;
+handler t1 read first;
+connect (flush,localhost,root,,);
+connection flush;
+--echo connection: flush
+--send rename table t1 to t2;
+connection default;
+--echo connection: default
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Waiting for table" and info = "rename table t1 to t2";
+--source include/wait_condition.inc
+handler t2 open;
+handler t2 read first;
+--error ER_NO_SUCH_TABLE
+handler t1 read next;
+handler t1 close;
+handler t2 close;
+connection flush;
+reap;
+connection default;
+drop table t2;
+disconnect flush;
+
+# Flush tables causes handlers reopen
+
+eval create table t1 (a int, b char(1), key a $key_type (a), key b $key_type (a,b));
+insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
+                      (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
+handler t1 open;
+handler t1 read a first;
+handler t1 read a next;
+flush tables;
+handler t1 read a next;
+handler t1 read a next;
+flush tables with read lock;
+handler t1 read a next;
+unlock tables;
+drop table t1;
+--error ER_UNKNOWN_TABLE
+handler t1 read a next;
+
+#
+# Bug#41110: crash with handler command when used concurrently with alter table
+# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int not null);
+insert into t1 values (1);
+handler t1 open;
+connect(con1,localhost,root,,);
+send alter table t1 engine=csv;
+connection default;
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "rename result table" and info = "alter table t1 engine=csv";
+--source include/wait_condition.inc
+--error ER_ILLEGAL_HA
+handler t1 read a next;
+handler t1 close;
+connection con1;
+--reap
+drop table t1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+connection default;
+
+#
+# Bug#44151 using handler commands on information_schema tables crashes server
+#
+
+USE information_schema;
+--error ER_WRONG_USAGE
+HANDLER COLUMNS OPEN;

=== renamed file 'mysql-test/r/handler_myisam.result' => 'mysql-test/suite/handler/myisam.result'
--- a/mysql-test/r/handler_myisam.result	2010-06-09 10:45:04 +0000
+++ b/mysql-test/suite/handler/myisam.result	2011-01-10 21:22:40 +0000
@@ -1,25 +1,23 @@
 SET SESSION STORAGE_ENGINE = MyISAM;
 drop table if exists t1,t3,t4,t5;
-create table t1 (a int, b char(10), key a(a), key b(a,b));
+create table t1 (a int, b char(10), key a  (a), key b  (a,b));
 insert into t1 values
 (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
-(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
+(14,"aaa"),(16,"ccc"),(16,"xxx"),
 (20,"ggg"),(21,"hhh"),(22,"iii");
 handler t1 open as t2;
-handler t2 read a=(SELECT 1);
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
 handler t2 read a first;
 a	b
 14	aaa
 handler t2 read a next;
 a	b
-15	bbb
-handler t2 read a next;
-a	b
 16	ccc
+handler t2 read a next;
+a	b
+16	xxx
 handler t2 read a prev;
 a	b
-15	bbb
+16	ccc
 handler t2 read a last;
 a	b
 22	iii
@@ -47,7 +45,6 @@
 a	b
 handler t2 read a=(15);
 a	b
-15	bbb
 handler t2 read a=(16);
 a	b
 16	ccc
@@ -84,26 +81,64 @@
 handler t2 read a<(18);
 a	b
 17	ddd
+handler t2 read a=(15);
+a	b
+handler t2 read a>=(15);
+a	b
+16	ccc
+handler t2 read a>(15);
+a	b
+16	ccc
+handler t2 read a<=(15);
+a	b
+14	aaa
+handler t2 read a<(15);
+a	b
+14	aaa
+handler t2 read a=(54);
+a	b
+handler t2 read a>=(54);
+a	b
+handler t2 read a>(54);
+a	b
+handler t2 read a<=(54);
+a	b
+22	iii
+handler t2 read a<(54);
+a	b
+22	iii
+handler t2 read a=(1);
+a	b
+handler t2 read a>=(1);
+a	b
+14	aaa
+handler t2 read a>(1);
+a	b
+14	aaa
+handler t2 read a<=(1);
+a	b
+handler t2 read a<(1);
+a	b
 handler t2 read a first limit 5;
 a	b
 14	aaa
-15	bbb
 16	ccc
 16	xxx
 17	ddd
+18	eee
 handler t2 read a next  limit 3;
 a	b
-18	eee
 19	fff
 19	yyy
+20	ggg
 handler t2 read a prev  limit 10;
 a	b
+19	yyy
 19	fff
 18	eee
 17	ddd
 16	xxx
 16	ccc
-15	bbb
 14	aaa
 handler t2 read a>=(16) limit 4;
 a	b
@@ -135,8 +170,6 @@
 handler t2 read next;
 a	b
 19	fff
-handler t2 read last;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
 handler t2 close;
 handler t1 open;
 handler t1 read a next;
@@ -144,7 +177,7 @@
 14	aaa
 handler t1 read a next;
 a	b
-15	bbb
+16	ccc
 handler t1 close;
 handler t1 open;
 handler t1 read a prev;
@@ -163,12 +196,12 @@
 ERROR 42S02: Unknown table 't2' in HANDLER
 handler t1 open as t2;
 drop table t1;
-create table t1 (a int);
+create table t1 (a int not null);
 insert into t1 values (17);
 handler t2 read first;
 ERROR 42S02: Unknown table 't2' in HANDLER
 handler t1 open as t2;
-alter table t1 engine=MEMORY;
+alter table t1 engine=CSV;
 handler t2 read first;
 ERROR 42S02: Unknown table 't2' in HANDLER
 drop table t1;
@@ -191,7 +224,7 @@
 a
 6
 drop table t1;
-create table t1(a int, index(a));
+create table t1(a int, index  (a));
 insert into t1 values (1), (2), (3);
 handler t1 open;
 handler t1 read a=(W);
@@ -217,7 +250,7 @@
 handler t close;
 use test;
 drop table t1;
-create table t1 ( a int, b int, INDEX a (a) );
+create table t1 ( a int, b int, INDEX a  (a) );
 insert into t1 values (1,2), (2,1);
 handler t1 open;
 handler t1 read a=(1) where b=2;
@@ -229,148 +262,6 @@
 a	b
 handler t1 close;
 drop table t1;
-drop database if exists test_test;
-create database test_test;
-use test_test;
-create table t1(table_id char(20) primary key);
-insert into t1 values ('test_test.t1');
-insert into t1 values ('');
-handler t1 open;
-handler t1 read first limit 9;
-table_id
-test_test.t1
-
-create table t2(table_id char(20) primary key);
-insert into t2 values ('test_test.t2');
-insert into t2 values ('');
-handler t2 open;
-handler t2 read first limit 9;
-table_id
-test_test.t2
-
-use test;
-drop table if exists t1;
-create table t1(table_id char(20) primary key);
-insert into t1 values ('test.t1');
-insert into t1 values ('');
-handler t1 open;
-ERROR 42000: Not unique table/alias: 't1'
-use test;
-handler test.t1 read first limit 9;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
-handler test_test.t1 read first limit 9;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
-handler t1 read first limit 9;
-table_id
-test_test.t1
-
-handler test_test.t2 read first limit 9;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
-handler t2 read first limit 9;
-table_id
-test_test.t2
-
-handler test_test.t1 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler t1 close;
-drop table test_test.t1;
-handler test_test.t2 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler t2 close;
-drop table test_test.t2;
-drop database test_test;
-use test;
-handler test.t1 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler t1 close;
-ERROR 42S02: Unknown table 't1' in HANDLER
-drop table test.t1;
-drop database if exists test_test;
-drop table if exists t1;
-drop table if exists t2;
-drop table if exists t3;
-create database test_test;
-use test_test;
-create table t1 (c1 char(20));
-insert into t1 values ('test_test.t1');
-create table t3 (c1 char(20));
-insert into t3 values ('test_test.t3');
-handler t1 open;
-handler t1 read first limit 9;
-c1
-test_test.t1
-handler t1 open h1;
-handler h1 read first limit 9;
-c1
-test_test.t1
-use test;
-create table t1 (c1 char(20));
-create table t2 (c1 char(20));
-create table t3 (c1 char(20));
-insert into t1 values ('t1');
-insert into t2 values ('t2');
-insert into t3 values ('t3');
-handler t1 open;
-ERROR 42000: Not unique table/alias: 't1'
-handler t2 open t1;
-ERROR 42000: Not unique table/alias: 't1'
-handler t3 open t1;
-ERROR 42000: Not unique table/alias: 't1'
-handler t1 read first limit 9;
-c1
-test_test.t1
-handler test.t1 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler test.t1 open h1;
-ERROR 42000: Not unique table/alias: 'h1'
-handler test_test.t1 open h1;
-ERROR 42000: Not unique table/alias: 'h1'
-handler test_test.t3 open h3;
-handler test.t1 open h2;
-handler t1 read first limit 9;
-c1
-test_test.t1
-handler h1 read first limit 9;
-c1
-test_test.t1
-handler h2 read first limit 9;
-c1
-t1
-handler h3 read first limit 9;
-c1
-test_test.t3
-handler h2 read first limit 9;
-c1
-t1
-handler test.h1 close;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'close' at line 1
-handler t1 close;
-handler h1 close;
-handler h2 close;
-handler t1 read first limit 9;
-ERROR 42S02: Unknown table 't1' in HANDLER
-handler h1 read first limit 9;
-ERROR 42S02: Unknown table 'h1' in HANDLER
-handler h2 read first limit 9;
-ERROR 42S02: Unknown table 'h2' in HANDLER
-handler h3 read first limit 9;
-c1
-test_test.t3
-handler h3 read first limit 9;
-c1
-test_test.t3
-use test_test;
-handler h3 read first limit 9;
-c1
-test_test.t3
-handler test.h3 read first limit 9;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read first limit 9' at line 1
-handler h3 close;
-use test;
-drop table t3;
-drop table t2;
-drop table t1;
-drop database test_test;
 create table t1 (c1 char(20));
 insert into t1 values ("t1");
 handler t1 open as h1;
@@ -495,6 +386,11 @@
 HANDLER t1 READ `primary` PREV;
 no1	no2
 1	275
+HANDLER t1 READ `primary` = (1, 1000);
+no1	no2
+HANDLER t1 READ `primary` NEXT;
+no1	no2
+2	6
 DROP TABLE t1;
 create table t1 (c1 int);
 insert into t1 values (14397);
@@ -515,14 +411,12 @@
 drop table if exists t1;
 Warnings:
 Note	1051	Unknown table 't1'
-drop table if exists t1;
-create table t1 (a int) ENGINE=MEMORY;
+create table t1 (a int not null) ENGINE=CSV;
 --> client 2
 handler t1 open;
 ERROR HY000: Table storage engine for 't1' doesn't have this option
 --> client 1
 drop table t1;
-drop table if exists t1;
 create table t1 (a int);
 handler t1 open as t1_alias;
 handler t1_alias read a next;
@@ -535,50 +429,9 @@
 ERROR 42S22: Unknown column 'inexistent' in 'field list'
 handler t1_alias close;
 drop table t1;
-drop table if exists t1,t2;
-create table t1 (c1 int);
-create table t2 (c1 int);
-insert into t1 values (1);
-insert into t2 values (2);
-connection: default
-handler t1 open;
-handler t1 read first;
-c1
-1
-connection: flush
-flush tables;;
-connection: default
-handler t2 open;
-handler t2 read first;
-c1
-2
-handler t1 read next;
-c1
-1
-handler t1 close;
-handler t2 close;
-drop table t1,t2;
-drop table if exists t1,t2;
-create table t1 (c1 int);
-connection: default
-handler t1 open;
-handler t1 read first;
-c1
-connection: flush
-rename table t1 to t2;;
-connection: default
-handler t2 open;
-handler t2 read first;
-c1
-handler t1 read next;
-ERROR 42S02: Table 'test.t1' doesn't exist
-handler t1 close;
-handler t2 close;
-drop table t2;
-drop table if exists t1;
-create temporary table t1 (a int, b char(1), key a(a), key b(a,b));
+create temporary table t1 (a int, b char(1), key a  (a), key b(a,b));
 insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
-(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
+(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
 select a,b from t1;
 a	b
 0	a
@@ -591,24 +444,25 @@
 7	h
 8	i
 9	j
+9	k
 handler t1 open as a1;
-handler a1 read a first;
-a	b
-0	a
-handler a1 read a next;
+handler a1 read a=(1);
 a	b
 1	b
 handler a1 read a next;
 a	b
 2	c
+handler a1 read a next;
+a	b
+3	d
 select a,b from t1;
 ERROR HY000: Can't reopen table: 'a1'
 handler a1 read a prev;
 a	b
+2	c
+handler a1 read a prev;
+a	b
 1	b
-handler a1 read a prev;
-a	b
-0	a
 handler a1 read a=(6) where b="g";
 a	b
 6	g
@@ -625,39 +479,28 @@
 7	h
 8	i
 9	j
+9	k
 handler t1 open as a2;
-handler a2 read a first;
-a	b
-0	a
+handler a2 read a=(9);
+a	b
+9	j
+handler a2 read a next;
+a	b
+9	k
+handler a2 read a prev limit 2;
+a	b
+9	j
+8	i
 handler a2 read a last;
 a	b
-9	j
+9	k
 handler a2 read a prev;
 a	b
-8	i
+9	j
 handler a2 close;
 drop table t1;
-drop table if exists t1,t2;
-create table t1 (a int);
-handler t1 open as t1_alias;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-flush tables;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-handler t1_alias close;
-drop table t1;
-create table t1 (a int);
-handler t1 open as t1_alias;
-handler t1_alias read first;
-a
-drop table t1;
-handler t1_alias read next;
-ERROR 42S02: Unknown table 't1_alias' in HANDLER
-create table t1 (a int);
-create temporary table t2 (a int, key(a));
+create table t1 (a int);
+create temporary table t2 (a int, key  (a));
 handler t1 open as a1;
 handler t2 open as a2;
 handler a2 read a first;
@@ -667,7 +510,7 @@
 ERROR 42S02: Unknown table 'a2' in HANDLER
 handler a1 close;
 ERROR 42S02: Unknown table 'a1' in HANDLER
-create table t1 (a int, key(a));
+create table t1 (a int, key  (a));
 create table t2 like t1;
 handler t1 open as a1;
 handler t2 open as a2;
@@ -680,7 +523,7 @@
 ERROR 42S02: Unknown table 'a1' in HANDLER
 handler a2 close;
 drop table t1, t2;
-create table t1 (a int, key(a));
+create table t1 (a int, key  (a));
 handler t1 open as a1;
 handler a1 read a first;
 a
@@ -688,7 +531,7 @@
 handler a1 read a first;
 ERROR 42S02: Unknown table 'a1' in HANDLER
 drop table t2;
-create table t1 (a int, key(a));
+create table t1 (a int, key  (a));
 create table t2 like t1;
 handler t1 open as a1;
 handler t2 open as a2;
@@ -703,63 +546,10 @@
 ERROR 42S02: Unknown table 'a1' in HANDLER
 handler a2 close;
 drop table t1, t2;
-create table t1 (a int, b char(1), key a(a), key b(a,b));
-insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
-(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j");
-handler t1 open;
-handler t1 read a first;
-a	b
-0	a
-handler t1 read a next;
-a	b
-1	b
-flush tables;
-handler t1 read a next;
-a	b
-0	a
-handler t1 read a next;
-a	b
-1	b
-flush tables with read lock;
-handler t1 read a next;
-a	b
-0	a
-unlock tables;
-drop table t1;
-handler t1 read a next;
-ERROR 42S02: Unknown table 't1' in HANDLER
-drop table if exists t1;
-create table t1 (a int);
-insert into t1 values (1);
-handler t1 open;
-alter table t1 engine=memory;
-handler t1 read a next;
-ERROR HY000: Table storage engine for 't1' doesn't have this option
-handler t1 close;
-drop table t1;
-USE information_schema;
-HANDLER COLUMNS OPEN;
-ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema
-USE test;
-#
-# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash 
-#
-CREATE TABLE t1 AS SELECT 1 AS f1;
-HANDLER t1 OPEN;
-TRUNCATE t1;
-HANDLER t1 READ FIRST;
-ERROR 42S02: Unknown table 't1' in HANDLER
-DROP TABLE t1;
-CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1;
-HANDLER t1 OPEN;
-TRUNCATE t1;
-HANDLER t1 READ FIRST;
-ERROR 42S02: Unknown table 't1' in HANDLER
-DROP TABLE t1;
 #
 # BUG#51877 - HANDLER interface causes invalid memory read
 #
-CREATE TABLE t1(a INT, KEY(a));
+CREATE TABLE t1(a INT, KEY  (a));
 HANDLER t1 OPEN;
 HANDLER t1 READ a FIRST;
 a
@@ -770,6 +560,21 @@
 HANDLER t1 CLOSE;
 DROP TABLE t1;
 #
+# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash 
+#
+CREATE TABLE t1 AS SELECT 1 AS f1;
+HANDLER t1 OPEN;
+TRUNCATE t1;
+HANDLER t1 READ FIRST;
+ERROR 42S02: Unknown table 't1' in HANDLER
+DROP TABLE t1;
+CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1;
+HANDLER t1 OPEN;
+TRUNCATE t1;
+HANDLER t1 READ FIRST;
+ERROR 42S02: Unknown table 't1' in HANDLER
+DROP TABLE t1;
+#
 # Bug #54007: assert in ha_myisam::index_next , HANDLER
 #
 CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b));
@@ -821,12 +626,13 @@
 a	b
 HANDLER t1 READ NEXT;
 a	b
+2	20
+HANDLER t1 READ NEXT;
+a	b
+1	10
+HANDLER t1 READ NEXT;
+a	b
 4	40
-HANDLER t1 READ NEXT;
-a	b
-3	30
-HANDLER t1 READ NEXT;
-a	b
 HANDLER t1 CLOSE;
 HANDLER t1 OPEN;
 HANDLER t1 READ FIRST;

=== renamed file 'mysql-test/t/handler_myisam.test' => 'mysql-test/suite/handler/myisam.test'
--- a/mysql-test/t/handler_myisam.test	2010-06-09 10:45:04 +0000
+++ b/mysql-test/suite/handler/myisam.test	2011-01-10 21:22:40 +0000
@@ -5,20 +5,14 @@
 # Last update:
 # 2006-07-31 ML test refactored (MySQL 5.1)
 #               code of t/handler.test and t/innodb_handler.test united
-#               main testing code put into include/handler.inc
+#               main testing code put into handler.inc
 #               rename t/handler.test to t/handler_myisam.test
 #
 
-# should work in embedded server after mysqltest is fixed
---source include/not_embedded.inc
-
 let $engine_type= MyISAM;
-let $other_engine_type= MEMORY;
-# There is unfortunately no other all time available storage engine
-# which supports the handler interface
-let $other_handler_engine_type= MyISAM;
 
---source include/handler.inc
+--source init.inc
+--source handler.inc
 
 --echo #
 --echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash 
@@ -38,18 +32,6 @@
 DROP TABLE t1;
 
 --echo #
---echo # BUG#51877 - HANDLER interface causes invalid memory read
---echo #
-CREATE TABLE t1(a INT, KEY(a));
-HANDLER t1 OPEN;
-HANDLER t1 READ a FIRST;
-INSERT INTO t1 VALUES(1);
-HANDLER t1 READ a NEXT;
-HANDLER t1 CLOSE;
-DROP TABLE t1;
-
-
---echo #
 --echo # Bug #54007: assert in ha_myisam::index_next , HANDLER
 --echo #
 CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b));

=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result	2010-12-24 16:17:43 +0000
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result	2011-01-23 06:22:04 +0000
@@ -2615,6 +2615,13 @@
 Extra	Using index
 DROP TABLE t1;
 #
+# ALTER TABLE IGNORE didn't ignore duplicates for unique add index
+#
+create table t1 (a int primary key, b int) engine = innodb;
+insert into t1 values (1,1),(2,1);
+alter ignore table t1 add unique `main` (b);
+drop table t1;
+#
 End of 5.1 tests
 #
 # Test for bug #39932 "create table fails if column for FK is in different

=== modified file 'mysql-test/suite/innodb/t/innodb_mysql.test'
--- a/mysql-test/suite/innodb/t/innodb_mysql.test	2010-11-23 21:39:59 +0000
+++ b/mysql-test/suite/innodb/t/innodb_mysql.test	2011-01-05 13:09:06 +0000
@@ -841,6 +841,15 @@
 DROP TABLE t1;
 
 --echo #
+--echo # ALTER TABLE IGNORE didn't ignore duplicates for unique add index
+--echo #
+
+create table t1 (a int primary key, b int) engine = innodb;
+insert into t1 values (1,1),(2,1);
+alter ignore table t1 add unique `main` (b);
+drop table t1;
+
+--echo #
 
 
 --echo End of 5.1 tests

=== modified file 'mysql-test/suite/maria/r/maria.result'
--- a/mysql-test/suite/maria/r/maria.result	2010-09-12 16:40:01 +0000
+++ b/mysql-test/suite/maria/r/maria.result	2011-01-05 14:03:58 +0000
@@ -1,6 +1,6 @@
 select * from INFORMATION_SCHEMA.ENGINES where ENGINE="ARIA";
 ENGINE	SUPPORT	COMMENT	TRANSACTIONS	XA	SAVEPOINTS
-Aria	YES	Crash-safe tables with MyISAM heritage	YES	NO	NO
+Aria	YES	Crash-safe tables with MyISAM heritage	NO	NO	NO
 set global storage_engine=aria;
 set session storage_engine=aria;
 set global aria_page_checksum=0;
@@ -2624,3 +2624,19 @@
 INSERT INTO t1 ( f1 , f2 , f3 , f4 ) SELECT f1 , f4 , f1 , f4 FROM t1;
 DELETE FROM t1;
 drop table t1;
+create table t1 (a int not null primary key, b blob) engine=maria transactional=1;
+insert into t1 values(1,repeat('a',8000));
+insert into t1 values(2,repeat('b',8000));
+insert into t1 values(3,repeat('c',8000));
+flush tables;
+delete from t1 where a>1;
+insert into t1 values(1,repeat('d',8000*3));
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+flush tables;
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+repair table t1 extended;
+Table	Op	Msg_type	Msg_text
+test.t1	repair	status	OK
+drop table t1;

=== modified file 'mysql-test/suite/maria/r/maria3.result'
--- a/mysql-test/suite/maria/r/maria3.result	2010-09-12 16:40:01 +0000
+++ b/mysql-test/suite/maria/r/maria3.result	2010-12-27 09:53:02 +0000
@@ -1,6 +1,6 @@
 select * from INFORMATION_SCHEMA.ENGINES where ENGINE="ARIA";
 ENGINE	SUPPORT	COMMENT	TRANSACTIONS	XA	SAVEPOINTS
-Aria	YES	Crash-safe tables with MyISAM heritage	YES	NO	NO
+Aria	YES	Crash-safe tables with MyISAM heritage	NO	NO	NO
 set global storage_engine=aria;
 set session storage_engine=aria;
 set global aria_page_checksum=0;

=== modified file 'mysql-test/suite/maria/t/maria-recovery-rtree-ft.test'
--- a/mysql-test/suite/maria/t/maria-recovery-rtree-ft.test	2010-09-12 16:40:01 +0000
+++ b/mysql-test/suite/maria/t/maria-recovery-rtree-ft.test	2011-01-05 14:03:58 +0000
@@ -6,6 +6,7 @@
 # Binary must be compiled with debug for crash to occur
 --source include/have_debug.inc
 --source include/have_maria.inc
+--source include/long_test.inc
 
 set global aria_log_file_size=4294967295;
 let $MARIA_LOG=.;

=== modified file 'mysql-test/suite/maria/t/maria.test'
--- a/mysql-test/suite/maria/t/maria.test	2010-09-12 16:40:01 +0000
+++ b/mysql-test/suite/maria/t/maria.test	2011-01-05 14:03:58 +0000
@@ -1911,6 +1911,24 @@
 drop table t1;
 
 #
+# Test of problem where REPAIR finds old deleted rows.
+#
+
+create table t1 (a int not null primary key, b blob) engine=maria transactional=1;
+insert into t1 values(1,repeat('a',8000));
+insert into t1 values(2,repeat('b',8000));
+insert into t1 values(3,repeat('c',8000));
+flush tables;
+delete from t1 where a>1;
+--error 1062
+insert into t1 values(1,repeat('d',8000*3));
+flush tables;
+check table t1;
+# This failed by finding 2 extra rows.
+repair table t1 extended;
+drop table t1;
+
+#
 # End of test
 #
 # Set defaults back

=== modified file 'mysql-test/suite/parts/t/partition_alter2_1_myisam.test'
--- a/mysql-test/suite/parts/t/partition_alter2_1_myisam.test	2009-10-09 13:08:09 +0000
+++ b/mysql-test/suite/parts/t/partition_alter2_1_myisam.test	2011-01-03 14:33:39 +0000
@@ -22,6 +22,8 @@
 # any of the variables.
 #
 
+--source include/long_test.inc
+
 #------------------------------------------------------------------------------#
 # General not engine specific settings and requirements
 

=== modified file 'mysql-test/suite/parts/t/partition_alter2_2_myisam.test'
--- a/mysql-test/suite/parts/t/partition_alter2_2_myisam.test	2009-10-09 13:08:09 +0000
+++ b/mysql-test/suite/parts/t/partition_alter2_2_myisam.test	2011-01-03 14:33:39 +0000
@@ -22,6 +22,8 @@
 # any of the variables.
 #
 
+--source include/long_test.inc
+
 #------------------------------------------------------------------------------#
 # General not engine specific settings and requirements
 

=== modified file 'mysql-test/suite/parts/t/partition_basic_innodb.test'
--- a/mysql-test/suite/parts/t/partition_basic_innodb.test	2009-10-09 13:08:09 +0000
+++ b/mysql-test/suite/parts/t/partition_basic_innodb.test	2011-01-03 14:33:39 +0000
@@ -22,6 +22,8 @@
 # any of the variables.
 #
 
+--source include/long_test.inc
+
 #------------------------------------------------------------------------------#
 # General not engine specific settings and requirements
 

=== modified file 'mysql-test/suite/parts/t/partition_decimal_myisam.test'
--- a/mysql-test/suite/parts/t/partition_decimal_myisam.test	2007-11-20 15:04:07 +0000
+++ b/mysql-test/suite/parts/t/partition_decimal_myisam.test	2011-01-03 14:33:39 +0000
@@ -22,6 +22,8 @@
 # any of the variables.
 #
 
+--source include/long_test.inc
+
 #------------------------------------------------------------------------------#
 # General not engine specific settings and requirements
 

=== modified file 'mysql-test/suite/parts/t/partition_float_myisam.test'
--- a/mysql-test/suite/parts/t/partition_float_myisam.test	2007-11-20 15:04:07 +0000
+++ b/mysql-test/suite/parts/t/partition_float_myisam.test	2011-01-03 14:33:39 +0000
@@ -22,6 +22,8 @@
 # any of the variables.
 #
 
+--source include/long_test.inc
+
 #------------------------------------------------------------------------------#
 # General not engine specific settings and requirements
 

=== modified file 'mysql-test/suite/parts/t/partition_int_myisam.test'
--- a/mysql-test/suite/parts/t/partition_int_myisam.test	2007-11-20 15:04:07 +0000
+++ b/mysql-test/suite/parts/t/partition_int_myisam.test	2011-01-03 14:33:39 +0000
@@ -22,6 +22,8 @@
 # any of the variables.
 #
 
+--source include/long_test.inc
+
 #------------------------------------------------------------------------------#
 # General not engine specific settings and requirements
 

=== modified file 'mysql-test/suite/rpl/r/rpl_stop_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_stop_slave.result	2010-10-16 12:03:44 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stop_slave.result	2011-01-03 14:33:39 +0000
@@ -38,6 +38,7 @@
 [ On Slave1 ]
 # To resume slave SQL thread
 SET DEBUG_SYNC= 'now SIGNAL signal.continue';
+SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
 SET DEBUG_SYNC= 'RESET';
 
 [ On Slave ]
@@ -63,6 +64,7 @@
 [ On Slave1 ]
 # To resume slave SQL thread
 SET DEBUG_SYNC= 'now SIGNAL signal.continue';
+SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
 SET DEBUG_SYNC= 'RESET';
 
 [ On Slave ]
@@ -89,6 +91,7 @@
 [ On Slave1 ]
 # To resume slave SQL thread
 SET DEBUG_SYNC= 'now SIGNAL signal.continue';
+SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
 SET DEBUG_SYNC= 'RESET';
 
 [ On Slave ]
@@ -115,6 +118,7 @@
 [ On Slave1 ]
 # To resume slave SQL thread
 SET DEBUG_SYNC= 'now SIGNAL signal.continue';
+SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
 SET DEBUG_SYNC= 'RESET';
 
 [ On Slave ]

=== modified file 'mysql-test/suite/rpl/t/rpl_deadlock_innodb.test'
--- a/mysql-test/suite/rpl/t/rpl_deadlock_innodb.test	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_deadlock_innodb.test	2011-01-03 14:33:39 +0000
@@ -7,5 +7,6 @@
 ########################################################
 -- source include/not_ndb_default.inc
 -- source include/have_innodb.inc
+-- source include/long_test.inc
 let $engine_type=innodb;
 -- source extra/rpl_tests/rpl_deadlock.test

=== modified file 'mysql-test/suite/rpl/t/rpl_row_sp003.test'
--- a/mysql-test/suite/rpl/t/rpl_row_sp003.test	2009-06-05 15:35:22 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_sp003.test	2011-01-03 14:33:39 +0000
@@ -10,6 +10,7 @@
 -- source include/have_binlog_format_row.inc
 # Slow test, don't run during staging part
 -- source include/not_staging.inc
+--source include/long_test.inc
 -- source include/master-slave.inc
 
 let $engine_type=INNODB;

=== modified file 'mysql-test/suite/vcol/inc/vcol_unsupported_storage_engines.inc'
--- a/mysql-test/suite/vcol/inc/vcol_unsupported_storage_engines.inc	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/inc/vcol_unsupported_storage_engines.inc	2010-12-31 09:39:14 +0000
@@ -13,9 +13,9 @@
 # Change: Syntax changed
 ################################################################################
 
---error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
+--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
 create table t1 (a int, b int as (a+1));
-create table t1 (a int);
---error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
+create table t1 (a int not null);
+--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
 alter table t1 add column b int as (a+1);
 drop table t1;

=== modified file 'mysql-test/suite/vcol/r/vcol_archive.result'
--- a/mysql-test/suite/vcol/r/vcol_archive.result	2010-07-13 14:34:14 +0000
+++ b/mysql-test/suite/vcol/r/vcol_archive.result	2010-12-31 09:39:14 +0000
@@ -1,7 +1,7 @@
 SET @@session.storage_engine = 'archive';
 create table t1 (a int, b int as (a+1));
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
-create table t1 (a int);
+ERROR HY000: ARCHIVE storage engine does not support computed columns
+create table t1 (a int not null);
 alter table t1 add column b int as (a+1);
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
+ERROR HY000: ARCHIVE storage engine does not support computed columns
 drop table t1;

=== modified file 'mysql-test/suite/vcol/r/vcol_blackhole.result'
--- a/mysql-test/suite/vcol/r/vcol_blackhole.result	2010-07-13 14:34:14 +0000
+++ b/mysql-test/suite/vcol/r/vcol_blackhole.result	2010-12-31 09:39:14 +0000
@@ -1,7 +1,7 @@
 SET @@session.storage_engine = 'blackhole';
 create table t1 (a int, b int as (a+1));
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
-create table t1 (a int);
+ERROR HY000: BLACKHOLE storage engine does not support computed columns
+create table t1 (a int not null);
 alter table t1 add column b int as (a+1);
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
+ERROR HY000: BLACKHOLE storage engine does not support computed columns
 drop table t1;

=== modified file 'mysql-test/suite/vcol/r/vcol_csv.result'
--- a/mysql-test/suite/vcol/r/vcol_csv.result	2010-07-13 14:34:14 +0000
+++ b/mysql-test/suite/vcol/r/vcol_csv.result	2010-12-31 09:39:14 +0000
@@ -1,7 +1,7 @@
 SET @@session.storage_engine = 'CSV';
 create table t1 (a int, b int as (a+1));
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
+ERROR HY000: CSV storage engine does not support computed columns
 create table t1 (a int not null);
 alter table t1 add column b int as (a+1);
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
+ERROR HY000: CSV storage engine does not support computed columns
 drop table t1;

=== modified file 'mysql-test/suite/vcol/r/vcol_memory.result'
--- a/mysql-test/suite/vcol/r/vcol_memory.result	2010-07-13 14:34:14 +0000
+++ b/mysql-test/suite/vcol/r/vcol_memory.result	2010-12-31 09:39:14 +0000
@@ -1,7 +1,7 @@
 SET @@session.storage_engine = 'memory';
 create table t1 (a int, b int as (a+1));
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
-create table t1 (a int);
+ERROR HY000: MEMORY storage engine does not support computed columns
+create table t1 (a int not null);
 alter table t1 add column b int as (a+1);
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
+ERROR HY000: MEMORY storage engine does not support computed columns
 drop table t1;

=== modified file 'mysql-test/suite/vcol/r/vcol_merge.result'
--- a/mysql-test/suite/vcol/r/vcol_merge.result	2010-07-13 14:34:14 +0000
+++ b/mysql-test/suite/vcol/r/vcol_merge.result	2010-12-31 09:39:14 +0000
@@ -4,5 +4,5 @@
 insert into t1 values (1,default);
 insert into t2 values (2,default);
 create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
-ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
+ERROR HY000: MRG_MYISAM storage engine does not support computed columns
 drop table t1,t2;

=== modified file 'mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result'
--- a/mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result	2010-07-13 14:34:14 +0000
+++ b/mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result	2010-12-31 09:39:14 +0000
@@ -76,7 +76,7 @@
 # Case 7. ALTER. Modify virtual stored -> virtual non-stored
 create table t1 (a int, b int as (a % 2) persistent);
 alter table t1 modify b int as (a % 2);
-ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
+ERROR HY000: This is not yet supported for computed columns
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -87,7 +87,7 @@
 # Case 8. ALTER. Modify virtual non-stored -> virtual stored
 create table t1 (a int, b int as (a % 2));
 alter table t1 modify b int as (a % 2) persistent;
-ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
+ERROR HY000: This is not yet supported for computed columns
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result'
--- a/mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result	2010-07-13 14:34:14 +0000
+++ b/mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result	2010-12-31 09:39:14 +0000
@@ -76,7 +76,7 @@
 # Case 7. ALTER. Modify virtual stored -> virtual non-stored
 create table t1 (a int, b int as (a % 2) persistent);
 alter table t1 modify b int as (a % 2);
-ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
+ERROR HY000: This is not yet supported for computed columns
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -87,7 +87,7 @@
 # Case 8. ALTER. Modify virtual non-stored -> virtual stored
 create table t1 (a int, b int as (a % 2));
 alter table t1 modify b int as (a % 2) persistent;
-ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
+ERROR HY000: This is not yet supported for computed columns
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/suite/vcol/t/rpl_vcol.test'
--- a/mysql-test/suite/vcol/t/rpl_vcol.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/rpl_vcol.test	2010-12-31 09:39:14 +0000
@@ -27,7 +27,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 SET @@session.storage_engine = 'InnoDB';
 
 #------------------------------------------------------------------------------#

=== modified file 'mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test	2010-12-31 09:39:14 +0000
@@ -32,7 +32,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 let $skip_full_text_checks = 1;

=== modified file 'mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test	2010-12-31 09:39:14 +0000
@@ -33,7 +33,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_csv.test'
--- a/mysql-test/suite/vcol/t/vcol_csv.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_csv.test	2010-12-31 09:39:14 +0000
@@ -41,13 +41,7 @@
 # Execute the tests to be applied to all storage engines
 
 #------------------------------------------------------------------------------#
-# Execute storage engine specific tests
---error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
-create table t1 (a int, b int as (a+1));
-create table t1 (a int not null);
---error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
-alter table t1 add column b int as (a+1);
-drop table t1;
+--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
 
 #------------------------------------------------------------------------------#
 # Cleanup

=== modified file 'mysql-test/suite/vcol/t/vcol_handler_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_handler_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_handler_innodb.test	2010-12-31 09:39:14 +0000
@@ -33,7 +33,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test	2010-12-31 09:39:14 +0000
@@ -33,7 +33,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_keys_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_keys_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_keys_innodb.test	2010-12-31 09:39:14 +0000
@@ -33,7 +33,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_merge.test'
--- a/mysql-test/suite/vcol/t/vcol_merge.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_merge.test	2010-12-31 09:39:14 +0000
@@ -48,7 +48,7 @@
 create table t2 (a int, b int as (a % 10));
 insert into t1 values (1,default);
 insert into t2 values (2,default);
---error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
+--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
 create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
 drop table t1,t2;
 

=== modified file 'mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test	2010-12-31 09:39:14 +0000
@@ -35,7 +35,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_partition_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_partition_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_partition_innodb.test	2010-12-31 09:39:14 +0000
@@ -34,7 +34,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_select_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_select_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_select_innodb.test	2010-12-31 09:39:14 +0000
@@ -33,7 +33,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test	2010-12-31 09:39:14 +0000
@@ -32,7 +32,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test	2010-12-31 09:39:14 +0000
@@ -34,7 +34,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/suite/vcol/t/vcol_view_innodb.test'
--- a/mysql-test/suite/vcol/t/vcol_view_innodb.test	2009-10-16 22:57:48 +0000
+++ b/mysql-test/suite/vcol/t/vcol_view_innodb.test	2010-12-31 09:39:14 +0000
@@ -33,7 +33,7 @@
 
 ##### Storage engine to be tested
 # Set the session storage engine
---source include/have_innodb.inc
+--source include/have_xtradb.inc
 eval SET @@session.storage_engine = 'InnoDB';
 
 ##### Workarounds for known open engine specific bugs

=== modified file 'mysql-test/t/join_outer.test'
--- a/mysql-test/t/join_outer.test	2010-11-24 22:57:34 +0000
+++ b/mysql-test/t/join_outer.test	2011-01-03 14:33:39 +0000
@@ -1,3 +1,5 @@
+--source include/long_test.inc
+
 #
 # test of left outer join
 #

=== modified file 'mysql-test/t/lock_multi.test'
--- a/mysql-test/t/lock_multi.test	2009-12-18 20:32:55 +0000
+++ b/mysql-test/t/lock_multi.test	2011-01-10 21:22:40 +0000
@@ -484,22 +484,6 @@
 connection default;
 drop table t1;
 
-#
-# Bug#25856 HANDLER table OPEN in one connection lock DROP TABLE in another one
-#
---disable_warnings
-drop table if exists t1;
---enable_warnings
-create table t1 (a int) ENGINE=MEMORY;
---echo --> client 2
-connection locker;
---error ER_ILLEGAL_HA
-handler t1 open;
---echo --> client 1
-connection default;
-drop table t1;
-
-
 # Disconnect sessions used in many subtests above
 disconnect locker;
 disconnect reader;

=== modified file 'mysql-test/t/multi_update2.test'
--- a/mysql-test/t/multi_update2.test	2009-10-28 07:52:34 +0000
+++ b/mysql-test/t/multi_update2.test	2011-01-03 14:33:39 +0000
@@ -1,3 +1,5 @@
+--source include/long_test.inc
+
 #
 # Test of update statement that uses many tables.
 #

=== added file 'mysql-test/t/mysqlbinlog-innodb.test'
--- a/mysql-test/t/mysqlbinlog-innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysqlbinlog-innodb.test	2011-01-13 12:28:36 +0000
@@ -0,0 +1,31 @@
+-- source include/have_binlog_format_statement.inc
+-- source include/have_log_bin.inc
+-- source include/have_innodb.inc
+
+#
+# MBug#702303: Spurious `use` statements in output from mysqlbinlog --rewrite-db="a->b" 
+#
+let $MYSQLD_DATADIR= `select @@datadir`;
+SET TIMESTAMP=1000000000;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
+CREATE DATABASE test2;
+
+RESET MASTER;
+USE test2;
+BEGIN;
+USE test;
+INSERT INTO t1 VALUES (1);
+USE test2;
+COMMIT;
+BEGIN;
+USE test;
+INSERT INTO t1 VALUES (2);
+USE test2;
+COMMIT;
+USE test;
+SELECT * FROM t1 ORDER BY a;
+FLUSH LOGS;
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --short-form
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --short-form --rewrite-db="test->foo" --rewrite-db="test2->bar"
+DROP DATABASE test2;
+DROP TABLE t1;

=== modified file 'mysql-test/t/pool_of_threads.test'
--- a/mysql-test/t/pool_of_threads.test	2009-06-05 15:35:22 +0000
+++ b/mysql-test/t/pool_of_threads.test	2011-01-03 14:33:39 +0000
@@ -4,6 +4,7 @@
 -- source include/have_pool_of_threads.inc
 # Slow test, don't run during staging part
 -- source include/not_staging.inc
+-- source include/long_test.inc
 -- source include/common-tests.inc
 
 

=== modified file 'mysql-test/t/query_cache.test'
--- a/mysql-test/t/query_cache.test	2010-01-11 13:15:28 +0000
+++ b/mysql-test/t/query_cache.test	2011-01-03 14:33:39 +0000
@@ -1,4 +1,5 @@
 -- source include/have_query_cache.inc
+-- source include/long_test.inc
 
 #
 # Tests with query cache

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2010-11-23 18:43:34 +0000
+++ b/mysql-test/t/subselect.test	2010-12-24 23:30:23 +0000
@@ -3759,4 +3759,19 @@
 
 drop table t1,t2;
 
+--echo #
+--echo # Bug LP#693935/#58727: Assertion failure with 
+--echo # a single row subquery returning more than one row
+--echo #
+
+create table t1 (a char(1) charset utf8);
+insert into t1 values ('a'), ('b');
+create table t2 (a binary(1));
+insert into t2 values ('x'), ('y');
+
+-- error ER_SUBQUERY_NO_1_ROW
+select * from t2 where a=(select a from t1) and a='x';
+
+drop table t1,t2;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/table_elim.test'
--- a/mysql-test/t/table_elim.test	2010-03-06 12:09:02 +0000
+++ b/mysql-test/t/table_elim.test	2011-01-11 10:42:16 +0000
@@ -467,3 +467,35 @@
   field4 != 6;
 
 drop table t0,t1,t2,t3,t4,t5,t6;
+
+--echo #
+--echo # BUG#675118: Elimination of a table results in an invalid execution plan
+--echo #
+CREATE TABLE t1 (f1 int(11), PRIMARY KEY (f1)) ;
+
+CREATE TABLE t2 (f4 varchar(1024), KEY (f4)) ;
+INSERT IGNORE INTO t2 VALUES ('xcddwntkbxyorzdv'),
+   ('cnxxcddwntkbxyor'),('r'),('r'), ('did'),('I'),('when'),
+   ('hczkfqjeggivdvac'),('e'),('okay'),('up');
+
+CREATE TABLE t3 (f4 varchar(1024), f1 int(11), f2 int(11)) ;
+INSERT IGNORE INTO t3 VALUES ('f','4','0'),('n','5','-996540416');
+
+CREATE TABLE t4 (f1 int(11), f3 varchar(10)) ;
+INSERT IGNORE INTO t4 VALUES ('8','n'),('9','nwzcerzsgx'),('10','c');
+
+CREATE TABLE t5 (f5 int(11), KEY (f5)) ;
+
+EXPLAIN 
+SELECT t3.f2
+FROM t2
+LEFT JOIN t3
+LEFT JOIN t4
+LEFT JOIN t1 ON t4.f1 = t1.f1
+JOIN t5 ON t4.f3 ON t3.f1 = t5.f5 ON t2.f4 = t3.f4
+WHERE t3.f2 ;
+--echo # ^^ The above must not produce a QEP of t3,t5,t2,t4
+--echo #    as that violates the "no interleaving of outer join nests" rule.
+
+DROP TABLE t1,t2,t3,t4,t5;
+

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp	2010-08-05 19:56:11 +0000
+++ b/mysql-test/valgrind.supp	2011-01-14 14:51:18 +0000
@@ -546,6 +546,19 @@
    fun:_dl_signal_error
 }
 
+{
+   dlsym memory loss from plugin
+   Memcheck:Leak
+   obj:/lib*/ld-*.so
+   obj:/lib*/ld-*.so
+   obj:/lib*/ld-*.so
+   obj:/lib*/libc-*.so
+   obj:/lib*/libdl-*.so
+   obj:/lib*/ld-*.so
+   obj:/lib*/libdl-*.so
+   fun:dlsym
+}
+
 #
 # Reading wrong addresses on SuSe Linux 10.3 32 bit
 #

=== modified file 'mysys/tree.c'
--- a/mysys/tree.c	2010-09-13 22:22:11 +0000
+++ b/mysys/tree.c	2011-01-23 06:22:04 +0000
@@ -377,6 +377,7 @@
       case HA_READ_KEY_EXACT:
       case HA_READ_KEY_OR_NEXT:
       case HA_READ_BEFORE_KEY:
+      case HA_READ_KEY_OR_PREV:
 	last_equal_element= parents;
 	cmp= 1;
 	break;
@@ -420,6 +421,9 @@
   case HA_READ_BEFORE_KEY:
     *last_pos= last_right_step_parent;
     break;
+  case HA_READ_KEY_OR_PREV:
+    *last_pos= last_equal_element ? last_equal_element : last_right_step_parent;
+    break;
   default:
     return NULL;
   }

=== modified file 'plugin/auth/dialog.c'
--- a/plugin/auth/dialog.c	2010-04-08 13:58:04 +0000
+++ b/plugin/auth/dialog.c	2011-01-12 11:11:21 +0000
@@ -327,7 +327,10 @@
   or fall back to the default implementation.
 */
 
-static int init_dialog()
+static int init_dialog(char *errbuf __attribute__((unused)),
+                       size_t sizeof_errbuf __attribute__((unused)),
+                       int argc __attribute__((unused)),
+                       va_list args __attribute__((unused)))
 {
   void *sym= dlsym(RTLD_DEFAULT, "mysql_authentication_dialog_ask");
   ask= sym ? (mysql_authentication_dialog_ask_t)sym : builtin_ask;

=== modified file 'scripts/mysql_convert_table_format.sh'
--- a/scripts/mysql_convert_table_format.sh	2009-04-28 18:47:34 +0000
+++ b/scripts/mysql_convert_table_format.sh	2011-01-07 15:58:12 +0000
@@ -28,7 +28,7 @@
 $exit_status=0;
 
 GetOptions(
-  "e|engine|type=s"       => \$opt_type,
+  "e|engine|type=s"       => \$opt_engine,
   "f|force"               => \$opt_force,
   "help|?"               => \$opt_help,
   "h|host=s"              => \$opt_host,

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2010-08-06 08:05:44 +0000
+++ b/sql-common/client.c	2011-01-06 14:55:29 +0000
@@ -1978,7 +1978,7 @@
   char *buff, *end;
   int res= 1;
 
-  buff= my_alloca(USERNAME_LENGTH + data_len + 1 + NAME_LEN + 2 + NAME_LEN);
+  buff= my_alloca(USERNAME_LENGTH+1 + data_len+1 + NAME_LEN+1 + 2 + NAME_LEN+1);
 
   end= strmake(buff, mysql->user, USERNAME_LENGTH) + 1;
 

=== modified file 'sql-common/client_plugin.c'
--- a/sql-common/client_plugin.c	2010-03-29 15:13:53 +0000
+++ b/sql-common/client_plugin.c	2011-01-20 12:00:46 +0000
@@ -50,7 +50,8 @@
 static my_bool initialized= 0;
 static MEM_ROOT mem_root;
 
-static const char *plugin_declarations_sym= "_mysql_client_plugin_declaration_";
+static const char *plugin_declarations_sym __attribute__((unused)) =
+                                "_mysql_client_plugin_declaration_";
 static uint plugin_version[MYSQL_CLIENT_MAX_PLUGINS]=
 {
   0, /* these two are taken by Connector/C */
@@ -180,7 +181,7 @@
     plugin->deinit();
 err1:
   if (dlhandle)
-    dlclose(dlhandle);
+    (void)dlclose(dlhandle);
   set_mysql_extended_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD, unknown_sqlstate,
                            ER(CR_AUTH_PLUGIN_CANNOT_LOAD), plugin->name,
                            errmsg);
@@ -239,6 +240,8 @@
 {
   MYSQL mysql;
   struct st_mysql_client_plugin **builtin;
+  va_list unused;
+  LINT_INIT_STRUCT(unused);
 
   if (initialized)
     return 0;
@@ -255,7 +258,7 @@
   pthread_mutex_lock(&LOCK_load_client_plugin);
 
   for (builtin= mysql_client_builtins; *builtin; builtin++)
-    add_plugin(&mysql, *builtin, 0, 0, 0);
+    add_plugin(&mysql, *builtin, 0, 0, unused);
 
   pthread_mutex_unlock(&LOCK_load_client_plugin);
 
@@ -285,7 +288,7 @@
       if (p->plugin->deinit)
         p->plugin->deinit();
       if (p->dlhandle)
-        dlclose(p->dlhandle);
+        (void)dlclose(p->dlhandle);
     }
 
   bzero(&plugin_list, sizeof(plugin_list));
@@ -301,6 +304,9 @@
 mysql_client_register_plugin(MYSQL *mysql,
                              struct st_mysql_client_plugin *plugin)
 {
+  va_list unused;
+  LINT_INIT_STRUCT(unused);
+
   if (is_not_initialized(mysql, plugin->name))
     return NULL;
 
@@ -315,7 +321,7 @@
     plugin= NULL;
   }
   else
-    plugin= add_plugin(mysql, plugin, 0, 0, 0);
+    plugin= add_plugin(mysql, plugin, 0, 0, unused);
 
   pthread_mutex_unlock(&LOCK_load_client_plugin);
   return plugin;
@@ -360,7 +366,7 @@
   if (!(sym= dlsym(dlhandle, plugin_declarations_sym)))
   {
     errmsg= "not a plugin";
-    dlclose(dlhandle);
+    (void)dlclose(dlhandle);
     goto err;
   }
 

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	2010-11-30 21:11:03 +0000
+++ b/sql/ha_partition.h	2010-12-31 09:39:14 +0000
@@ -253,7 +253,6 @@
     DBUG_RETURN(0);
   }
   virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
-  bool check_if_supported_virtual_columns(void) { return TRUE;}
   virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
                                           uint table_changes);
 private:

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2010-11-30 21:11:03 +0000
+++ b/sql/handler.cc	2011-01-14 14:49:27 +0000
@@ -2736,7 +2736,10 @@
     textno=ER_DUP_UNIQUE;
     break;
   case HA_ERR_RECORD_CHANGED:
-    SET_FATAL_ERROR;
+    /*
+      This is not fatal error when using HANDLER interface
+      SET_FATAL_ERROR;
+    */
     textno=ER_CHECKREAD;
     break;
   case HA_ERR_CRASHED:
@@ -4520,11 +4523,11 @@
   int error, error1;
   LINT_INIT(error1);
 
-  error= index_init(index, 0);
+  error= ha_index_init(index, 0);
   if (!error)
   {
     error= index_read_map(buf, key, keypart_map, find_flag);
-    error1= index_end();
+    error1= ha_index_end();
   }
   return error ?  error : error1;
 }

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2010-11-19 21:33:47 +0000
+++ b/sql/handler.h	2011-01-12 15:38:13 +0000
@@ -137,6 +137,7 @@
 #define HA_BINLOG_STMT_CAPABLE (LL(1) << 35)
 /* Has automatic checksums and uses the new checksum format */
 #define HA_HAS_NEW_CHECKSUM    (LL(1) << 36)
+#define HA_CAN_VIRTUAL_COLUMNS (LL(1) << 37)
 
 /*
   Set of all binlog flags. Currently only contain the capabilities
@@ -1320,14 +1321,18 @@
     DBUG_ENTER("ha_index_init");
     DBUG_ASSERT(inited==NONE);
     if (!(result= index_init(idx, sorted)))
-      inited=INDEX;
+    {
+      inited=       INDEX;
+      active_index= idx;
+    }
     DBUG_RETURN(result);
   }
   int ha_index_end()
   {
     DBUG_ENTER("ha_index_end");
     DBUG_ASSERT(inited==INDEX);
-    inited=NONE;
+    inited=       NONE;
+    active_index= MAX_KEY;
     DBUG_RETURN(index_end());
   }
   /* This is called after index_init() if we need to do a index scan */
@@ -1510,7 +1515,12 @@
     as there may be several calls to this routine.
   */
   virtual void column_bitmaps_signal();
-  uint get_index(void) const { return active_index; }
+  /*
+    We have to check for inited as some engines, like innodb, sets
+    active_index during table scan.
+  */
+  uint get_index(void) const
+  { return inited == INDEX ? active_index : MAX_KEY; }
   virtual int close(void)=0;
 
   /**
@@ -1752,6 +1762,7 @@
   { return(NULL);}  /* gets tablespace name from handler */
   /** used in ALTER TABLE; 1 if changing storage engine is allowed */
   virtual bool can_switch_engines() { return 1; }
+  virtual int can_continue_handler_scan() { return 0; }
   /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
   virtual int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
   { return 0; }
@@ -1955,17 +1966,6 @@
 
   LEX_STRING *engine_name() { return hton_name(ht); }
 
-  /*
-    @brief
-    Check whether the engine supports virtual columns
-    
-    @retval
-      FALSE   if the engine does not support virtual columns    
-    @retval
-      TRUE    if the engine supports virtual columns
-  */
-  virtual bool check_if_supported_virtual_columns(void) { return FALSE;}
-
 protected:
   /* deprecated, don't use in new engines */
   inline void ha_statistic_increment(ulong SSV::*offset) const { }
@@ -2006,8 +2006,8 @@
   */
 
   virtual int open(const char *name, int mode, uint test_if_locked)=0;
-  virtual int index_init(uint idx, bool sorted) { active_index= idx; return 0; }
-  virtual int index_end() { active_index= MAX_KEY; return 0; }
+  virtual int index_init(uint idx, bool sorted) { return 0; }
+  virtual int index_end() { return 0; }
   /**
     rnd_init() can be called two times without rnd_end() in between
     (it only makes sense if scan=1).

=== modified file 'sql/item.h'
--- a/sql/item.h	2010-11-30 21:11:03 +0000
+++ b/sql/item.h	2011-01-05 14:03:58 +0000
@@ -574,10 +574,17 @@
   Field *make_string_field(TABLE *table);
   virtual bool fix_fields(THD *, Item **);
   /*
-    should be used in case where we are sure that we do not need
+    This method should be used in case where we are sure that we do not need
     complete fix_fields() procedure.
+    Usually this method is used by the optimizer when it has to create a new
+    item out of other already fixed items. For example, if the optimizer has
+    to create a new Item_func for an inferred equality whose left and right
+    parts are already fixed items. In some cases the optimizer cannot use
+    directly fixed items as the arguments of the created functional item, 
+    but rather uses intermediate type conversion items. Then the method is
+    supposed to be applied recursively.  
   */
-  inline void quick_fix_field() { fixed= 1; }
+  virtual inline void quick_fix_field() { fixed= 1; }
   /* Function returns 1 on overflow and -1 on fatal errors */
   int save_in_field_no_warnings(Field *field, bool no_conversions);
   virtual int save_in_field(Field *field, bool no_conversions);

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2010-11-30 21:11:03 +0000
+++ b/sql/item_func.cc	2011-01-05 14:03:58 +0000
@@ -202,6 +202,21 @@
   return FALSE;
 }
 
+void
+Item_func::quick_fix_field()
+{
+  Item **arg,**arg_end;
+  if (arg_count)
+  {
+    for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
+    {
+      if (!(*arg)->fixed)
+        (*arg)->quick_fix_field();
+    }
+  }
+  fixed= 1;
+}
+
 
 bool Item_func::walk(Item_processor processor, bool walk_subquery,
                      uchar *argument)

=== modified file 'sql/item_func.h'
--- a/sql/item_func.h	2010-11-30 21:11:03 +0000
+++ b/sql/item_func.h	2011-01-05 14:03:58 +0000
@@ -117,6 +117,7 @@
   // Constructor used for Item_cond_and/or (see Item comment)
   Item_func(THD *thd, Item_func *item);
   bool fix_fields(THD *, Item **ref);
+  void quick_fix_field();
   table_map used_tables() const;
   table_map not_null_tables() const;
   void update_used_tables();

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2010-09-12 12:29:54 +0000
+++ b/sql/share/errmsg.txt	2010-12-31 09:39:14 +0000
@@ -6017,7 +6017,7 @@
         eng "Only integers allowed as number here"
         ger "An dieser Stelle sind nur Ganzzahlen zul?ssig"
 ER_UNSUPORTED_LOG_ENGINE
-        eng "This storage engine cannot be used for log tables""
+        eng "This storage engine cannot be used for log tables"
         ger "Diese Speicher-Engine kann f?r Logtabellen nicht verwendet werden"
 ER_BAD_LOG_STATEMENT
         eng "You cannot '%s' a log table if logging is enabled"
@@ -6236,13 +6236,15 @@
         eng "The value specified for computed column '%s' in table '%s' ignored"
 
 ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
-        eng "'%s' is not yet supported for computed columns"
+        eng "This is not yet supported for computed columns"
 
 ER_CONST_EXPR_IN_VCOL
         eng "Constant expression in computed column function is not allowed"
 
 ER_ROW_EXPR_FOR_VCOL
         eng "Expression for computed column cannot return a row"
+ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
+        eng "%s storage engine does not support computed columns"
 ER_UNKNOWN_OPTION
         eng "Unknown option '%-.64s'"
 ER_BAD_OPTION_VALUE

=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc	2010-08-05 19:56:11 +0000
+++ b/sql/sql_handler.cc	2011-01-10 21:42:47 +0000
@@ -548,6 +548,12 @@
         mode= RLAST;
     }
   }
+  else if (table->file->inited != handler::RND)
+  {
+    /* Convert RNEXT to RFIRST if we haven't started row scan */
+    if (mode == RNEXT)
+      mode= RFIRST;
+  }
 
   if (insert_fields(thd, &thd->lex->select_lex.context,
                     tables->db, tables->alias, &it, 0))
@@ -569,6 +575,8 @@
     case RNEXT:
       if (table->file->inited != handler::NONE)
       {
+        if ((error= table->file->can_continue_handler_scan()))
+          break;
         if (keyname)
         {
           /* Check if we read from the same index. */
@@ -603,7 +611,9 @@
       DBUG_ASSERT((uint) keyno == table->file->get_index());
       if (table->file->inited != handler::NONE)
       {
-        error=table->file->ha_index_prev(table->record[0]);
+        if ((error= table->file->can_continue_handler_scan()))
+          break;
+        error= table->file->ha_index_prev(table->record[0]);
         break;
       }
       /* else fall through */
@@ -673,8 +683,11 @@
         continue;
       if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
       {
-        sql_print_error("mysql_ha_read: Got error %d when reading table '%s'",
-                        error, tables->table_name);
+        /* Don't give error in the log file for some expected problems */
+        if (error != HA_ERR_RECORD_CHANGED && error != HA_ERR_WRONG_COMMAND)
+          sql_print_error("mysql_ha_read: Got error %d when reading "
+                          "table '%s'",
+                          error, tables->table_name);
         table->file->print_error(error,MYF(0));
         goto err;
       }

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2010-11-30 21:11:03 +0000
+++ b/sql/sql_parse.cc	2011-01-05 14:03:58 +0000
@@ -3233,12 +3233,17 @@
 
     DBUG_EXECUTE_IF("after_mysql_insert",
                     {
-                      const char act[]=
+                      const char act1[]=
                         "now "
                         "wait_for signal.continue";
+                      const char act2[]=
+                        "now "
+                        "signal signal.continued";
                       DBUG_ASSERT(opt_debug_sync_timeout > 0);
-                      DBUG_ASSERT(!debug_sync_set_action(current_thd,
-                                                         STRING_WITH_LEN(act)));
+                      DBUG_ASSERT(!debug_sync_set_action(thd,
+                                                         STRING_WITH_LEN(act1)));
+                      DBUG_ASSERT(!debug_sync_set_action(thd,
+                                                         STRING_WITH_LEN(act2)));
                     };);
     break;
   }

=== modified file 'sql/sql_plugin_services.h'
--- a/sql/sql_plugin_services.h	2010-03-03 14:44:14 +0000
+++ b/sql/sql_plugin_services.h	2011-01-20 12:00:46 +0000
@@ -36,7 +36,7 @@
   thd_make_lex_string
 };
 
-static struct st_service_ref list_of_services[]=
+static struct st_service_ref list_of_services[] __attribute__((unused)) =
 {
   { "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler },
   { "thd_alloc_service",   VERSION_thd_alloc,   &thd_alloc_handler }

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-12-24 16:17:43 +0000
+++ b/sql/sql_select.cc	2011-01-23 06:22:04 +0000
@@ -5079,7 +5079,7 @@
 
     All other cases are in-between these two extremes. Thus the parameter
     'search_depth' controlls the exhaustiveness of the search. The higher the
-    value, the longer the optimizaton time and possibly the better the
+    value, the longer the optimization time and possibly the better the
     resulting plan. The lower the value, the fewer alternative plans are
     estimated, but the more likely to get a bad QEP.
 
@@ -11217,6 +11217,11 @@
     DBUG_EXECUTE_IF("raise_error", write_err= HA_ERR_FOUND_DUPP_KEY ;);
     if (write_err)
       goto err;
+    if (thd->killed)
+    {
+      thd->send_kill_message();
+      goto err_killed;
+    }
   }
   /* copy row that filled HEAP table */
   if ((write_err=new_table.file->ha_write_row(table->record[0])))
@@ -11247,6 +11252,7 @@
  err:
   DBUG_PRINT("error",("Got error: %d",write_err));
   table->file->print_error(write_err, MYF(0));
+err_killed:
   (void) table->file->ha_rnd_end();
   (void) new_table.file->close();
  err1:

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-11-30 21:11:03 +0000
+++ b/sql/sql_table.cc	2011-01-05 14:03:58 +0000
@@ -3929,12 +3929,16 @@
   }
 
   /* Give warnings for not supported table options */
-  if (create_info->transactional && !file->ht->commit)
-    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
-                        ER_ILLEGAL_HA_CREATE_OPTION,
-                        ER(ER_ILLEGAL_HA_CREATE_OPTION),
-                        file->engine_name()->str,
-                        "TRANSACTIONAL=1");
+#if defined(WITH_ARIA_STORAGE_ENGINE)
+  extern handlerton *maria_hton;
+  if (file->ht != maria_hton)
+#endif
+    if (create_info->transactional)
+      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+                          ER_ILLEGAL_HA_CREATE_OPTION,
+                          ER(ER_ILLEGAL_HA_CREATE_OPTION),
+                          file->engine_name()->str,
+                          "TRANSACTIONAL=1");
 
   VOID(pthread_mutex_lock(&LOCK_open));
   if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
@@ -6276,9 +6280,7 @@
       def->field=field;
       if (field->stored_in_db != def->stored_in_db)
       {
-        my_error(ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN,
-                 MYF(0),
-                 "Changing the STORED status");
+        my_error(ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN, MYF(0));
         goto err;
       }
       if (!def->after)
@@ -7226,6 +7228,16 @@
           /* Non-primary unique key. */
           needed_online_flags|=  HA_ONLINE_ADD_UNIQUE_INDEX;
           needed_fast_flags|= HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES;
+          if (ignore)
+          {
+            /*
+              If ignore is used, we have to remove all duplicate rows,
+              which require a full table copy.
+            */
+            need_copy_table= ALTER_TABLE_DATA_CHANGED;
+            pk_changed= 2;                      // Don't change need_copy_table
+            break;
+          }
         }
       }
       else

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-11-30 21:11:03 +0000
+++ b/sql/table.cc	2010-12-31 09:39:14 +0000
@@ -2337,14 +2337,11 @@
 
   /* Check virtual columns against table's storage engine. */
   if (share->vfields && 
-        ((outparam->file && 
-          !outparam->file->check_if_supported_virtual_columns()) ||
-	 (!outparam->file && share->db_type() && 
-	   share->db_type()->db_type == DB_TYPE_CSV_DB))) // Workaround for CSV
+        !(outparam->file && 
+          (outparam->file->ha_table_flags() & HA_CAN_VIRTUAL_COLUMNS)))
   {
-    my_error(ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN,
-             MYF(0), 
-             "Specified storage engine");
+    my_error(ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS, MYF(0),
+             plugin_name(share->db_plugin)->str);
     error_reported= TRUE;
     goto err;
   }

=== modified file 'sql/table.h'
--- a/sql/table.h	2010-12-24 16:17:43 +0000
+++ b/sql/table.h	2011-01-23 06:22:04 +0000
@@ -1781,7 +1781,7 @@
 
      2. All child join nest nodes are fully covered.
    */
-  bool is_fully_covered() const { return join_list.elements == counter; }
+  bool is_fully_covered() const { return n_tables == counter; }
 } NESTED_JOIN;
 
 

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2010-09-11 18:43:48 +0000
+++ b/storage/federated/ha_federated.cc	2011-01-12 15:38:13 +0000
@@ -2453,7 +2453,6 @@
 {
   DBUG_ENTER("ha_federated::index_init");
   DBUG_PRINT("info", ("table: '%s'  key: %u", table->s->table_name.str, keynr));
-  active_index= keynr;
   DBUG_RETURN(0);
 }
 
@@ -2589,7 +2588,6 @@
 {
   DBUG_ENTER("ha_federated::index_end");
   free_result();
-  active_index= MAX_KEY;
   DBUG_RETURN(0);
 }
 

=== modified file 'storage/ibmdb2i/db2i_ioBuffers.h'
--- a/storage/ibmdb2i/db2i_ioBuffers.h	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_ioBuffers.h	2011-01-07 11:45:59 +0000
@@ -290,7 +290,7 @@
       Return a pointer to the next row in the table, where "next" is defined
       by the orientation.
       
-      @param orientaton
+      @param orientation
       @param[out] rrn The relative record number of the row returned. Not reliable
                       if NULL is returned by this function.
       

=== modified file 'storage/innodb_plugin/trx/trx0sys.c'
--- a/storage/innodb_plugin/trx/trx0sys.c	2010-09-15 16:58:36 +0000
+++ b/storage/innodb_plugin/trx/trx0sys.c	2011-01-07 11:45:59 +0000
@@ -1343,7 +1343,7 @@
 
 
 /* THESE ARE COPIED FROM NON-HOTBACKUP PART OF THE INNODB SOURCE TREE
-   (This code duplicaton should be fixed at some point!)
+   (This code duplication should be fixed at some point!)
 */
 
 #define	TRX_SYS_SPACE	0	/* the SYSTEM tablespace */

=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc	2010-11-19 21:33:47 +0000
+++ b/storage/maria/ha_maria.cc	2011-01-12 15:38:13 +0000
@@ -228,7 +228,7 @@
        "The size of the buffer used for index blocks for Aria tables. "
        "Increase this to get better index handling (for all reads and "
        "multiple writes) to as much as you can afford.", 0, 0,
-       KEY_CACHE_SIZE, 0, ~(ulong) 0, 1);
+       KEY_CACHE_SIZE, 8192*16L, ~(ulong) 0, 1);
 
 static MYSQL_SYSVAR_ULONG(pagecache_division_limit, pagecache_division_limit,
        PLUGIN_VAR_RQCMDARG,
@@ -821,7 +821,7 @@
                 HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
                 HA_DUPLICATE_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
                 HA_FILE_BASED | HA_CAN_GEOMETRY | CANNOT_ROLLBACK_FLAG |
-                HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS |
+                HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS | HA_CAN_VIRTUAL_COLUMNS |
                 HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT),
 can_enable_indexes(1), bulk_insert_single_undo(BULK_INSERT_NONE)
 {}
@@ -1059,8 +1059,6 @@
 
 int ha_maria::write_row(uchar * buf)
 {
-  ha_statistic_increment(&SSV::ha_write_count);
-
   /* If we have a timestamp column, update it to the current time */
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
@@ -2060,6 +2058,7 @@
   DBUG_ENTER("ha_maria::check_and_repair");
 
   check_opt.init();
+  check_opt.flags= T_MEDIUM | T_AUTO_REPAIR;
 
   error= 1;
   if ((file->s->state.changed &
@@ -2080,7 +2079,6 @@
     DBUG_RETURN(error);
 
   error= 0;
-  check_opt.flags= T_MEDIUM | T_AUTO_REPAIR;
   // Don't use quick if deleted rows
   if (!file->state->del && (maria_recover_options & HA_RECOVER_QUICK))
     check_opt.flags |= T_QUICK;
@@ -2131,7 +2129,6 @@
 int ha_maria::update_row(const uchar * old_data, uchar * new_data)
 {
   CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONING("UPDATE in WRITE CONCURRENT");
-  ha_statistic_increment(&SSV::ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
     table->timestamp_field->set_time();
   return maria_update(file, old_data, new_data);
@@ -2141,7 +2138,6 @@
 int ha_maria::delete_row(const uchar * buf)
 {
   CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONING("DELETE in WRITE CONCURRENT");
-  ha_statistic_increment(&SSV::ha_delete_count);
   return maria_delete(file, buf);
 }
 
@@ -2151,7 +2147,6 @@
 			     enum ha_rkey_function find_flag)
 {
   DBUG_ASSERT(inited == INDEX);
-  ha_statistic_increment(&SSV::ha_read_key_count);
   int error= maria_rkey(file, buf, active_index, key, keypart_map, find_flag);
   table->status= error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -2162,7 +2157,6 @@
 				 key_part_map keypart_map,
 				 enum ha_rkey_function find_flag)
 {
-  ha_statistic_increment(&SSV::ha_read_key_count);
   int error= maria_rkey(file, buf, index, key, keypart_map, find_flag);
   table->status= error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -2174,7 +2168,6 @@
 {
   DBUG_ENTER("ha_maria::index_read_last_map");
   DBUG_ASSERT(inited == INDEX);
-  ha_statistic_increment(&SSV::ha_read_key_count);
   int error= maria_rkey(file, buf, active_index, key, keypart_map,
                         HA_READ_PREFIX_LAST);
   table->status= error ? STATUS_NOT_FOUND : 0;
@@ -2185,7 +2178,6 @@
 int ha_maria::index_next(uchar * buf)
 {
   DBUG_ASSERT(inited == INDEX);
-  ha_statistic_increment(&SSV::ha_read_next_count);
   int error= maria_rnext(file, buf, active_index);
   table->status= error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -2195,7 +2187,6 @@
 int ha_maria::index_prev(uchar * buf)
 {
   DBUG_ASSERT(inited == INDEX);
-  ha_statistic_increment(&SSV::ha_read_prev_count);
   int error= maria_rprev(file, buf, active_index);
   table->status= error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -2205,7 +2196,6 @@
 int ha_maria::index_first(uchar * buf)
 {
   DBUG_ASSERT(inited == INDEX);
-  ha_statistic_increment(&SSV::ha_read_first_count);
   int error= maria_rfirst(file, buf, active_index);
   table->status= error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -2215,7 +2205,6 @@
 int ha_maria::index_last(uchar * buf)
 {
   DBUG_ASSERT(inited == INDEX);
-  ha_statistic_increment(&SSV::ha_read_last_count);
   int error= maria_rlast(file, buf, active_index);
   table->status= error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -2228,7 +2217,6 @@
 {
   int error;
   DBUG_ASSERT(inited == INDEX);
-  ha_statistic_increment(&SSV::ha_read_next_count);
   /*
     TODO: Delete this loop in Maria 1.5 as versioning will ensure this never
     happens
@@ -2260,7 +2248,6 @@
 
 int ha_maria::rnd_next(uchar *buf)
 {
-  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   int error= maria_scan(file, buf);
   table->status= error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -2282,7 +2269,6 @@
 
 int ha_maria::rnd_pos(uchar *buf, uchar *pos)
 {
-  ha_statistic_increment(&SSV::ha_read_rnd_count);
   int error= maria_rrnd(file, buf, my_get_ptr(pos, ref_length));
   table->status= error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -3302,6 +3288,9 @@
   maria_hton->panic= maria_hton_panic;
   maria_hton->commit= maria_commit;
   maria_hton->rollback= maria_rollback;
+#ifdef MARIA_CANNOT_ROLLBACK
+  maria_hton->commit= 0;
+#endif
   maria_hton->flush_logs= maria_flush_logs;
   maria_hton->show_status= maria_show_status;
   /* TODO: decide if we support Maria being used for log tables */

=== modified file 'storage/maria/ha_maria.h'
--- a/storage/maria/ha_maria.h	2010-09-14 21:06:54 +0000
+++ b/storage/maria/ha_maria.h	2010-12-31 09:39:14 +0000
@@ -143,7 +143,6 @@
   int assign_to_keycache(THD * thd, HA_CHECK_OPT * check_opt);
   int preload_keys(THD * thd, HA_CHECK_OPT * check_opt);
   bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
-  bool check_if_supported_virtual_columns(void) { return TRUE;}
 #ifdef HAVE_REPLICATION
   int dump(THD * thd, int fd);
   int net_read_dump(NET * net);

=== modified file 'storage/maria/ma_bitmap.c'
--- a/storage/maria/ma_bitmap.c	2010-11-15 20:44:41 +0000
+++ b/storage/maria/ma_bitmap.c	2011-01-04 22:09:05 +0000
@@ -399,7 +399,8 @@
       become false, wake them up.
     */
     DBUG_PRINT("info", ("bitmap flusher waking up others"));
-    pthread_cond_broadcast(&bitmap->bitmap_cond);
+    if (bitmap->flush_all_requested)
+      pthread_cond_broadcast(&bitmap->bitmap_cond);
   }
   pthread_mutex_unlock(&bitmap->bitmap_lock);
   DBUG_RETURN(res);
@@ -465,7 +466,8 @@
   bitmap->flush_all_requested--;
   bitmap->non_flushable= 0;
   pthread_mutex_unlock(&bitmap->bitmap_lock);
-  pthread_cond_broadcast(&bitmap->bitmap_cond);
+  if (bitmap->flush_all_requested > 0)
+    pthread_cond_broadcast(&bitmap->bitmap_cond);
   DBUG_VOID_RETURN;
 }
 

=== modified file 'storage/maria/ma_blockrec.c'
--- a/storage/maria/ma_blockrec.c	2010-11-04 14:57:30 +0000
+++ b/storage/maria/ma_blockrec.c	2011-01-07 10:17:34 +0000
@@ -2506,7 +2506,7 @@
   }
   if (delete_count &&
       pagecache_delete_pages(share->pagecache, &info->dfile,
-                             page, delete_count, PAGECACHE_LOCK_WRITE, 0))
+                             page, delete_count, PAGECACHE_LOCK_WRITE, 1))
     res= 1;
 
   if (share->now_transactional)
@@ -2816,7 +2816,6 @@
   DBUG_PRINT("info", ("Used head length on page: %u  header_length: %u",
                       head_length,
                       (uint) (flag & ROW_FLAG_TRANSID ? TRANSID_SIZE : 0)));
-  DBUG_ASSERT(data <= end_of_data);
   if (head_length < share->base.min_block_length)
   {
     /* Extend row to be of size min_block_length */
@@ -2825,6 +2824,7 @@
     data+= diff_length;
     head_length= share->base.min_block_length;
   }
+  DBUG_ASSERT(data <= end_of_data);
   /*
     If this is a redo entry (ie, undo_lsn != LSN_ERROR) then we should have
     written exactly head_length bytes (same as original record).
@@ -3492,7 +3492,9 @@
 
   /* page will be pinned & locked by get_head_or_tail_page */
   if (get_head_or_tail_page(info, blocks->block, info->buff,
-                            row->space_on_head_page, HEAD_PAGE,
+                            max(row->space_on_head_page,
+                                info->s->base.min_block_length),
+                            HEAD_PAGE,
                             PAGECACHE_LOCK_WRITE, &row_pos))
     goto err;
   row->lastpos= ma_recordpos(blocks->block->page, row_pos.rownr);
@@ -4179,6 +4181,13 @@
                                 log_data, NULL))
         DBUG_RETURN(1);
     }
+    /*
+      Mark that this page must be written to disk by page cache, even
+      if we could call pagecache_delete() on it.
+      This is needed to ensure that repair finds the empty page on disk
+      and not old data.
+    */
+    pagecache_set_write_on_delete_by_link(page_link.link);
     DBUG_ASSERT(empty_space >= share->bitmap.sizes[0]);
   }
 
@@ -4932,7 +4941,7 @@
       goto err;
   }
 #ifdef EXTRA_DEBUG
-  if (share->calc_checksum)
+  if (share->calc_checksum && !info->in_check_table)
   {
     /* Esnure that row checksum is correct */
     DBUG_ASSERT(((share->calc_checksum)(info, record) & 255) ==
@@ -6485,7 +6494,13 @@
    @param  info            Maria handler
    @param  header          Header (without FILEID)
 
-   @note It marks the pages free in the bitmap
+   Mark the pages free in the bitmap.
+
+   We have to check against _ma_redo_not_needed_for_page()
+   to guard against the case where we first clear a block and after
+   that insert new data into the blocks.  If we would unconditionally
+   clear the bitmap here, future changes would be ignored for the page
+   if it's not in the dirty list (ie, it would be flushed).
 
    @return Operation status
      @retval 0      OK
@@ -6494,19 +6509,25 @@
 
 uint _ma_apply_redo_free_blocks(MARIA_HA *info,
                                 LSN lsn __attribute__((unused)),
+                                LSN redo_lsn,
                                 const uchar *header)
 {
   MARIA_SHARE *share= info->s;
   uint ranges;
+  uint16 sid;
   DBUG_ENTER("_ma_apply_redo_free_blocks");
 
   share->state.changed|= (STATE_CHANGED | STATE_NOT_ZEROFILLED |
                           STATE_NOT_MOVABLE);
 
+  sid= fileid_korr(header);
+  header+= FILEID_STORE_SIZE;
   ranges= pagerange_korr(header);
   header+= PAGERANGE_STORE_SIZE;
   DBUG_ASSERT(ranges > 0);
 
+  /** @todo leave bitmap lock to the bitmap code... */
+  pthread_mutex_lock(&share->bitmap.bitmap_lock);
   while (ranges--)
   {
     my_bool res;
@@ -6523,18 +6544,22 @@
 
     DBUG_PRINT("info", ("page: %lu  pages: %u", (long) page, page_range));
 
-    /** @todo leave bitmap lock to the bitmap code... */
-    pthread_mutex_lock(&share->bitmap.bitmap_lock);
-    res= _ma_bitmap_reset_full_page_bits(info, &share->bitmap, start_page,
-                                         page_range);
-    pthread_mutex_unlock(&share->bitmap.bitmap_lock);
-    if (res)
+    for ( ; page_range-- ; start_page++)
     {
-      _ma_mark_file_crashed(share);
-      DBUG_ASSERT(0);
-      DBUG_RETURN(res);
+      if (_ma_redo_not_needed_for_page(sid, redo_lsn, start_page, FALSE))
+        continue;
+      res= _ma_bitmap_reset_full_page_bits(info, &share->bitmap, start_page,
+                                           1);
+      if (res)
+      {
+        pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+        _ma_mark_file_crashed(share);
+        DBUG_ASSERT(0);
+        DBUG_RETURN(res);
+      }
     }
   }
+  pthread_mutex_unlock(&share->bitmap.bitmap_lock);
   DBUG_RETURN(0);
 }
 
@@ -6687,21 +6712,23 @@
       uint      page_range;
       pgcache_page_no_t page, start_page;
       uchar     *buff;
+      uint	data_on_page= data_size;
 
       start_page= page= page_korr(header);
       header+= PAGE_STORE_SIZE;
       page_range= pagerange_korr(header);
       header+= PAGERANGE_STORE_SIZE;
 
-      for (i= page_range; i-- > 0 ; page++)
+      for (i= page_range; i-- > 0 ; page++, data+= data_on_page)
       {
         MARIA_PINNED_PAGE page_link;
         enum pagecache_page_lock unlock_method;
         enum pagecache_page_pin unpin_method;
-        uint length;
 
         set_if_smaller(first_page2, page);
         set_if_bigger(last_page2, page);
+        if (i == 0 && sub_ranges == 0)
+          data_on_page= data_size - empty_space; /* data on last page */
         if (_ma_redo_not_needed_for_page(sid, redo_lsn, page, FALSE))
           continue;
 
@@ -6764,7 +6791,7 @@
                                        PAGECACHE_LOCK_WRITE_UNLOCK,
                                        PAGECACHE_UNPIN, LSN_IMPOSSIBLE,
                                        LSN_IMPOSSIBLE, 0, FALSE);
-              continue;
+              goto fix_bitmap;
             }
             DBUG_ASSERT((found_page_type == (uchar) BLOB_PAGE) ||
                         (found_page_type == (uchar) UNALLOCATED_PAGE));
@@ -6780,33 +6807,32 @@
         lsn_store(buff, lsn);
         buff[PAGE_TYPE_OFFSET]= BLOB_PAGE;
 
-        length= data_size;
-        if (i == 0 && sub_ranges == 0)
+        if (data_on_page != data_size)
         {
           /*
             Last page may be only partly filled. We zero the rest, like
             write_full_pages() does.
           */
-          length-= empty_space;
           bzero(buff + share->block_size - PAGE_SUFFIX_SIZE - empty_space,
                 empty_space);
         }
-        memcpy(buff+ PAGE_TYPE_OFFSET + 1, data, length);
-        data+= length;
+        memcpy(buff+ PAGE_TYPE_OFFSET + 1, data, data_on_page);
         if (pagecache_write(share->pagecache,
                             &info->dfile, page, 0,
                             buff, PAGECACHE_PLAIN_PAGE,
                             unlock_method, unpin_method,
                             PAGECACHE_WRITE_DELAY, 0, LSN_IMPOSSIBLE))
           goto err;
-      }
+
+    fix_bitmap:
       /** @todo leave bitmap lock to the bitmap code... */
-      pthread_mutex_lock(&share->bitmap.bitmap_lock);
-      res= _ma_bitmap_set_full_page_bits(info, &share->bitmap, start_page,
-                                         page_range);
-      pthread_mutex_unlock(&share->bitmap.bitmap_lock);
-      if (res)
-        goto err;
+        pthread_mutex_lock(&share->bitmap.bitmap_lock);
+        res= _ma_bitmap_set_full_page_bits(info, &share->bitmap, page,
+                                           1);
+        pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+        if (res)
+          goto err;
+      }
     }
   }
   *first_page= first_page2;

=== modified file 'storage/maria/ma_blockrec.h'
--- a/storage/maria/ma_blockrec.h	2010-11-03 12:14:02 +0000
+++ b/storage/maria/ma_blockrec.h	2011-01-04 22:09:05 +0000
@@ -235,7 +235,7 @@
 uint _ma_apply_redo_purge_row_head_or_tail(MARIA_HA *info, LSN lsn,
                                            uint page_type,
                                            const uchar *header);
-uint _ma_apply_redo_free_blocks(MARIA_HA *info, LSN lsn,
+uint _ma_apply_redo_free_blocks(MARIA_HA *info, LSN lsn, LSN rec_lsn,
                                 const uchar *header);
 uint _ma_apply_redo_free_head_or_tail(MARIA_HA *info, LSN lsn,
                                       const uchar *header);

=== modified file 'storage/maria/ma_check.c'
--- a/storage/maria/ma_check.c	2010-12-13 13:51:47 +0000
+++ b/storage/maria/ma_check.c	2011-01-11 12:29:19 +0000
@@ -100,6 +100,9 @@
 static TrID max_trid_in_system(void);
 static void _ma_check_print_not_visible_error(HA_CHECK *param, TrID used_trid);
 void retry_if_quick(MARIA_SORT_PARAM *param, int error);
+static void print_bitmap_description(MARIA_SHARE *share,
+                                     pgcache_page_no_t page,
+                                     uchar *buff);
 
 
 /* Initialize check param with default values */
@@ -878,6 +881,7 @@
   }
 
   info->last_key.keyinfo= tmp_key.keyinfo= keyinfo;
+  info->lastinx= ~0;                            /* Safety */
   tmp_key.data= tmp_key_buff;
   for ( ;; )
   {
@@ -1131,6 +1135,7 @@
       {
         (*keyinfo->make_key)(info, &key, keynr, info->lastkey_buff, record,
                              start_recpos, 0);
+        info->last_key.keyinfo= key.keyinfo;
         if (extend)
         {
           /* We don't need to lock the key tree here as we don't allow
@@ -1842,6 +1847,8 @@
       }
       param->used+= block_size;
       param->link_used+= block_size;
+      if (param->verbose > 2)
+        print_bitmap_description(share, page, bitmap_buff);
       continue;
     }
     /* Skip pages marked as empty in bitmap */
@@ -2034,6 +2041,8 @@
   bzero((char*) param->tmp_key_crc,
         share->base.keys * sizeof(param->tmp_key_crc[0]));
 
+  info->in_check_table= 1;       /* Don't assert on checksum errors */
+
   switch (share->data_file_type) {
   case BLOCK_RECORD:
     error= check_block_record(param, info, extend, record);
@@ -2049,6 +2058,8 @@
     break;
   } /* switch */
 
+  info->in_check_table= 0;
+
   if (error)
     goto err;
 
@@ -2177,12 +2188,17 @@
            llstr(param->del_length, llbuff2));
     printf("Empty space:  %12s    Linkdata:     %10s\n",
            llstr(param->empty, llbuff),llstr(param->link_used, llbuff2));
-    if (param->lost)
-      printf("Lost space:   %12s", llstr(param->lost, llbuff));
-    if (param->max_found_trid)
+    if (share->data_file_type == BLOCK_RECORD)
     {
-      printf("Max trans. id: %11s\n",
-             llstr(param->max_found_trid, llbuff));
+      printf("Full pages:   %12s    Tail count: %12s\n",
+             llstr(param->full_page_count, llbuff),
+             llstr(param->tail_count, llbuff2));
+      printf("Lost space:   %12s\n", llstr(param->lost, llbuff));
+      if (param->max_found_trid)
+      {
+        printf("Max trans. id: %11s\n",
+               llstr(param->max_found_trid, llbuff));
+      }
     }
   }
   my_free(record,MYF(0));
@@ -2616,6 +2632,7 @@
 
   maria_lock_memory(param);			/* Everything is alloced */
 
+  sort_param.sort_info->info->in_check_table= 1;
   /* Re-create all keys, which are set in key_map. */
   while (!(error=sort_get_next_record(&sort_param)))
   {
@@ -2783,6 +2800,7 @@
   VOID(end_io_cache(&sort_info.new_info->rec_cache));
   info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
   sort_info.new_info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
+  sort_param.sort_info->info->in_check_table= 0;
   /* this below could fail, shouldn't we detect error? */
   if (got_error)
   {
@@ -3233,6 +3251,7 @@
   uint block_size= share->block_size;
   my_bool zero_lsn= (share->base.born_transactional &&
                      !(param->testflag & T_ZEROFILL_KEEP_LSN));
+  int error= 1;
   DBUG_ENTER("maria_zerofill_index");
 
   if (!(param->testflag & T_SILENT))
@@ -3257,7 +3276,7 @@
       _ma_check_print_error(param,
                             "Page %9s: Got error %d when reading index file",
                             llstr(pos, llbuff), my_errno);
-      DBUG_RETURN(1);
+      goto end;
     }
     if (zero_lsn)
       bzero(buff, LSN_SIZE);
@@ -3265,7 +3284,7 @@
     if (share->base.born_transactional)
     {
       uint keynr= _ma_get_keynr(share, buff);
-      if (keynr != MARIA_DELETE_KEY_NR)
+      if (keynr < share->base.keys)
       {
         MARIA_PAGE page;
         DBUG_ASSERT(keynr < share->base.keys);
@@ -3277,7 +3296,7 @@
                                 "Page %9s: Got error %d when reading index "
                                 "file",
                                 llstr(pos, llbuff), my_errno);
-          DBUG_RETURN(1);
+          goto end;
         }
       }
     }
@@ -3291,10 +3310,13 @@
                              PAGECACHE_UNPIN, LSN_IMPOSSIBLE,
                              LSN_IMPOSSIBLE, 1, FALSE);
   }
+  error= 0;                                     /* ok */
+
+end:
   if (flush_pagecache_blocks(share->pagecache, &share->kfile,
                              FLUSH_FORCE_WRITE))
     DBUG_RETURN(1);
-  DBUG_RETURN(0);
+  DBUG_RETURN(error);
 }
 
 
@@ -4754,7 +4776,7 @@
         DBUG_RETURN(-1);
       }
       /* Retry only if wrong record, not if disk error */
-      if (flag != HA_ERR_WRONG_IN_RECORD)
+      if (flag != HA_ERR_WRONG_IN_RECORD && flag != HA_ERR_WRONG_CRC)
       {
         retry_if_quick(sort_param, flag);
         DBUG_RETURN(flag);
@@ -6444,6 +6466,9 @@
 
 static void unuse_data_file_descriptor(MARIA_HA *info)
 {
+  (void) flush_pagecache_blocks(info->s->pagecache,
+                                &info->s->bitmap.file,
+                                FLUSH_IGNORE_CHANGED);
   info->dfile.file= info->s->bitmap.file.file= -1;
   _ma_bitmap_reset_cache(info->s);
 }
@@ -6799,3 +6824,46 @@
     param->testflag|=T_RETRY_WITHOUT_QUICK;
   }
 }
+
+/* Print information about bitmap page */
+
+static void print_bitmap_description(MARIA_SHARE *share,
+                                     pgcache_page_no_t page,
+                                     uchar *bitmap_data)
+{
+  uchar *pos, *end;
+  MARIA_FILE_BITMAP *bitmap= &share->bitmap;
+  uint count=0, dot_printed= 0;
+  char buff[80], last[80];
+
+  printf("Bitmap page %lu\n", (ulong) page);
+  page++;
+  last[0]=0;
+  for (pos= bitmap_data, end= pos+ bitmap->used_size ; pos < end ; pos+= 6)
+  {
+    ulonglong bits= uint6korr(pos);    /* 6 bytes = 6*8/3= 16 patterns */
+    uint i;
+
+    for (i= 0; i < 16 ; i++, bits>>= 3)
+    {
+      if (count > 60)
+      {
+        buff[count]= 0;
+        if (strcmp(buff, last))
+        {
+          memcpy(last, buff, count+1);
+          printf("%8lu: %s\n", (ulong) page - count, buff);
+          dot_printed= 0;
+        }
+        else if (!(dot_printed++))
+          printf("...\n");
+        count= 0;
+      }
+      buff[count++]= '0' + (uint) (bits & 7);
+      page++;
+    }
+  }
+  buff[count]= 0;
+  printf("%8lu: %s\n", (ulong) page - count, buff);
+  fputs("\n", stdout);
+}

=== modified file 'storage/maria/ma_extra.c'
--- a/storage/maria/ma_extra.c	2010-02-10 19:06:24 +0000
+++ b/storage/maria/ma_extra.c	2011-01-10 21:22:40 +0000
@@ -50,7 +50,7 @@
 
   switch (function) {
   case HA_EXTRA_RESET_STATE:		/* Reset state (don't free buffers) */
-    info->lastinx= 0;			/* Use first index as def */
+    info->lastinx= ~0;			/* Detect index changes */
     info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR;
     info->page_changed= 1;
 					/* Next/prev gives first/last */
@@ -545,7 +545,7 @@
 #endif
   info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS);
   info->quick_mode= 0;
-  info->lastinx= 0;			/* Use first index as def */
+  info->lastinx= ~0;			/* detect index changes */
   info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR;
   info->page_changed= 1;
   info->update= ((info->update & HA_STATE_CHANGED) | HA_STATE_NEXT_FOUND |

=== modified file 'storage/maria/ma_ft_boolean_search.c'
--- a/storage/maria/ma_ft_boolean_search.c	2010-01-06 19:20:16 +0000
+++ b/storage/maria/ma_ft_boolean_search.c	2011-01-11 12:29:19 +0000
@@ -356,7 +356,8 @@
   {
     ftbw->key_root=info->s->state.key_root[ftb->keynr];
     ftbw->keyinfo=info->s->keyinfo+ftb->keynr;
-    key.keyinfo= ftbw->keyinfo;
+    info->last_key.keyinfo= key.keyinfo= ftbw->keyinfo;
+    info->lastinx= ~0;                            /* Safety */
     key.data= ftbw->word;
     key.data_length= ftbw->len;
     key.ref_length= 0;
@@ -380,7 +381,8 @@
                    max_docid);
     }
 
-    key.keyinfo= ftbw->keyinfo;
+    info->last_key.keyinfo= key.keyinfo= ftbw->keyinfo;
+    info->lastinx= ~0;                            /* Safety */
     key.data= lastkey_buf;
     key.data_length= USE_WHOLE_KEY;
     key.ref_length= 0;

=== modified file 'storage/maria/ma_open.c'
--- a/storage/maria/ma_open.c	2010-11-02 15:22:57 +0000
+++ b/storage/maria/ma_open.c	2011-01-10 21:22:40 +0000
@@ -130,6 +130,8 @@
 
   info.s=share;
   info.cur_row.lastpos= HA_OFFSET_ERROR;
+  /* Impossible first index to force initialization in _ma_check_index() */
+  info.lastinx= ~0;
   info.update= (short) (HA_STATE_NEXT_FOUND+HA_STATE_PREV_FOUND);
   info.opt_flag=READ_CHECK_USED;
   info.this_unique= (ulong) info.dfile.file; /* Uniq number in process */

=== modified file 'storage/maria/ma_pagecache.c'
--- a/storage/maria/ma_pagecache.c	2010-12-04 11:15:16 +0000
+++ b/storage/maria/ma_pagecache.c	2011-01-12 15:58:13 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2008 MySQL AB
+/* Copyright (C) 2000-2008 MySQL AB, 2008-2011 Monty Program 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
@@ -158,6 +158,7 @@
 #define PCBLOCK_IN_FLUSH   16 /* block is in flush operation                 */
 #define PCBLOCK_CHANGED    32 /* block buffer contains a dirty page          */
 #define PCBLOCK_DIRECT_W   64 /* possible direct write to the block          */
+#define PCBLOCK_DEL_WRITE 128 /* should be written on delete                 */
 
 /* page status, returned by find_block */
 #define PAGE_READ               0
@@ -759,6 +760,8 @@
   {
     if (blocks < 8)
     {
+      my_message(ENOMEM, "Not enough memory to allocate 8 pagecache pages",
+                 MYF(0));
       my_errno= ENOMEM;
       goto err;
     }
@@ -1215,7 +1218,7 @@
   link_changed(block, &pagecache->file_blocks[FILE_HASH(*file)]);
   if (block->status & PCBLOCK_CHANGED)
   {
-    block->status&= ~PCBLOCK_CHANGED;
+    block->status&= ~(PCBLOCK_CHANGED | PCBLOCK_DEL_WRITE);
     block->rec_lsn= LSN_MAX;
     pagecache->blocks_changed--;
     pagecache->global_blocks_changed--;
@@ -3473,6 +3476,31 @@
 
 
 /*
+  @brief Set/reset flag that page always should be flushed on delete
+
+  @param pagecache      pointer to a page cache data structure
+  @param link           direct link to page (returned by read or write)
+  @param write          write on delete flag value
+
+*/
+
+void pagecache_set_write_on_delete_by_link(PAGECACHE_BLOCK_LINK *block)
+{
+  DBUG_ENTER("pagecache_set_write_on_delete_by_link");
+  DBUG_PRINT("enter", ("fd: %d block 0x%lx  %d -> TRUE",
+                       block->hash_link->file.file,
+                       (ulong) block,
+                       (int) block->status & PCBLOCK_DEL_WRITE));
+  DBUG_ASSERT(block->pins); /* should be pinned */
+  DBUG_ASSERT(block->wlocks); /* should be write locked */
+
+  block->status|= PCBLOCK_DEL_WRITE;
+
+  DBUG_VOID_RETURN;
+}
+
+
+/*
   @brief Delete page from the buffer (common part for link and file/page)
 
   @param pagecache      pointer to a page cache data structure
@@ -3501,6 +3529,7 @@
   }
   if (block->status & PCBLOCK_CHANGED)
   {
+    flush= (flush || (block->status & PCBLOCK_DEL_WRITE));
     if (flush)
     {
       /* The block contains a dirty page - push it out of the cache */
@@ -4187,6 +4216,7 @@
   DBUG_ASSERT(block->rlocks == 0);
   DBUG_ASSERT(block->rlocks_queue == 0);
   DBUG_ASSERT(block->pins == 0);
+  DBUG_ASSERT((block->status & ~(PCBLOCK_ERROR | PCBLOCK_READ | PCBLOCK_IN_FLUSH | PCBLOCK_CHANGED | PCBLOCK_REASSIGNED | PCBLOCK_DEL_WRITE)) == 0);
   block->status= 0;
 #ifndef DBUG_OFF
   block->type= PAGECACHE_EMPTY_PAGE;
@@ -4515,6 +4545,7 @@
           KEYCACHE_DBUG_ASSERT(count<= pagecache->blocks_used);
         }
       }
+      count++;    /* Allocate one extra for easy end-of-buffer test */
       /* Allocate a new buffer only if its bigger than the one we have */
       if (count > FLUSH_CACHE &&
           !(cache=
@@ -4552,22 +4583,24 @@
         DBUG_ASSERT(filter_res == FLUSH_FILTER_OK);
       }
       {
+        DBUG_ASSERT(!(block->status & PCBLOCK_IN_FLUSH));
         /*
-           Mark the block with BLOCK_IN_FLUSH in order not to let
-           other threads to use it for new pages and interfere with
-           our sequence of flushing dirty file pages
+          We care only for the blocks for which flushing was not
+          initiated by other threads as a result of page swapping
         */
-        block->status|= PCBLOCK_IN_FLUSH;
-
         if (! (block->status & PCBLOCK_IN_SWITCH))
         {
-	  /*
-	    We care only for the blocks for which flushing was not
-	    initiated by other threads as a result of page swapping
+          /*
+            Mark the block with BLOCK_IN_FLUSH in order not to let
+            other threads to use it for new pages and interfere with
+            our sequence of flushing dirty file pages
           */
+          block->status|= PCBLOCK_IN_FLUSH;
+
           reg_requests(pagecache, block, 1);
           if (type != FLUSH_IGNORE_CHANGED)
           {
+            *pos++= block;
 	    /* It's not a temporary file */
             if (pos == end)
             {
@@ -4587,7 +4620,6 @@
               */
               goto restart;
             }
-            *pos++= block;
           }
           else
           {

=== modified file 'storage/maria/ma_pagecache.h'
--- a/storage/maria/ma_pagecache.h	2008-10-14 15:18:14 +0000
+++ b/storage/maria/ma_pagecache.h	2011-01-07 10:17:34 +0000
@@ -251,6 +251,7 @@
 extern void pagecache_unpin_by_link(PAGECACHE *pagecache,
                                     PAGECACHE_BLOCK_LINK *link,
                                     LSN lsn);
+extern void pagecache_set_write_on_delete_by_link(PAGECACHE_BLOCK_LINK *block);
 
 
 /* Results of flush operation (bit field in fact) */

=== modified file 'storage/maria/ma_recovery.c'
--- a/storage/maria/ma_recovery.c	2010-09-16 07:58:57 +0000
+++ b/storage/maria/ma_recovery.c	2011-01-07 10:05:46 +0000
@@ -28,6 +28,7 @@
 #include "trnman.h"
 #include "ma_key_recover.h"
 #include "ma_recovery_util.h"
+#include "hash.h"
 
 struct st_trn_for_recovery /* used only in the REDO phase */
 {
@@ -58,6 +59,7 @@
 static int (*save_error_handler_hook)(uint, const char *,myf);
 static uint recovery_warnings; /**< count of warnings */
 static uint recovery_found_crashed_tables;
+HASH tables_to_redo;                          /* For maria_read_log */
 
 #define prototype_redo_exec_hook(R)                                          \
   static int exec_REDO_LOGREC_ ## R(const TRANSLOG_HEADER_BUFFER *rec)
@@ -184,6 +186,21 @@
 }
 
 
+static my_bool table_is_part_of_recovery_set(LEX_STRING *file_name)
+{
+  uint offset =0;
+  if (!tables_to_redo.records)
+    return 1;                                   /* Default, recover table */
+
+  /* Skip base directory */
+  if (file_name->str[0] == '.' &&
+      (file_name->str[1] == '/' || file_name->str[1] == '\\'))
+    offset= 2;
+  /* Only recover if table is in hash */
+  return my_hash_search(&tables_to_redo, (uchar*) file_name->str + offset,
+                        file_name->length - offset) != 0;
+}
+
 /**
    @brief Recovers from the last checkpoint.
 
@@ -1643,8 +1660,8 @@
   }
 
   buff= log_record_buffer.str;
-  if (_ma_apply_redo_free_blocks(info, current_group_end_lsn,
-                                 buff + FILEID_STORE_SIZE))
+  if (_ma_apply_redo_free_blocks(info, current_group_end_lsn, rec->lsn,
+                                 buff))
     goto end;
   error= 0;
 end:
@@ -3015,10 +3032,11 @@
     page= page_korr(rec->header + FILEID_STORE_SIZE);
     llstr(page, llbuf);
     break;
+  case LOGREC_REDO_FREE_BLOCKS:
     /*
-      For REDO_FREE_BLOCKS, no need to look at dirty pages list: it does not
-      read data pages, only reads/modifies bitmap page(s) which is cheap.
+      We are checking against the dirty pages in _ma_apply_redo_free_blocks()
     */
+    break;
   default:
     break;
   }
@@ -3036,6 +3054,12 @@
   share= info->s;
   tprint(tracef, ", '%s'", share->open_file_name.str);
   DBUG_ASSERT(in_redo_phase);
+  if (!table_is_part_of_recovery_set(&share->open_file_name))
+  {
+    tprint(tracef, ", skipped by user\n");
+    return NULL;
+  }
+
   if (cmp_translog_addr(rec->lsn, share->lsn_of_file_id) <= 0)
   {
     /*
@@ -3069,7 +3093,6 @@
       REDO_INSERT_ROW_BLOBS will consult list by itself, as it covers several
       pages.
     */
-    tprint(tracef, " page %s", llbuf);
     if (_ma_redo_not_needed_for_page(sid, rec->lsn, page,
                                      index_page_redo_entry))
       return NULL;
@@ -3106,6 +3129,13 @@
   }
   share= info->s;
   tprint(tracef, ", '%s'", share->open_file_name.str);
+
+  if (!table_is_part_of_recovery_set(&share->open_file_name))
+  {
+    tprint(tracef, ", skipped by user\n");
+    return NULL;
+  }
+
   if (cmp_translog_addr(rec->lsn, share->lsn_of_file_id) <= 0)
   {
     tprint(tracef, ", table's LOGREC_FILE_ID has LSN (%lu,0x%lx) more recent"

=== modified file 'storage/maria/ma_recovery.h'
--- a/storage/maria/ma_recovery.h	2010-08-05 15:56:31 +0000
+++ b/storage/maria/ma_recovery.h	2011-01-06 20:49:17 +0000
@@ -30,4 +30,6 @@
                     FILE *trace_file,
                     my_bool execute_undo_phase, my_bool skip_DDLs,
                     my_bool take_checkpoints, uint *warnings_count);
+/* Table of tables to recover */
+extern HASH tables_to_redo;
 C_MODE_END

=== modified file 'storage/maria/ma_recovery_util.c'
--- a/storage/maria/ma_recovery_util.c	2010-07-30 07:45:27 +0000
+++ b/storage/maria/ma_recovery_util.c	2011-01-06 20:49:17 +0000
@@ -129,16 +129,20 @@
       Next 2 bytes: table's short id
       Next 5 bytes: page number
     */
+    char llbuf[22];
     uint64 file_and_page_id=
       (((uint64)((index << 16) | shortid)) << 40) | page;
     struct st_dirty_page *dirty_page= (struct st_dirty_page *)
       hash_search(&all_dirty_pages,
                   (uchar *)&file_and_page_id, sizeof(file_and_page_id));
-    DBUG_PRINT("info", ("in dirty pages list: %d", dirty_page != NULL));
+    DBUG_PRINT("info", ("page %lld in dirty pages list: %d",
+                        (ulonglong) page,
+                        dirty_page != NULL));
     if ((dirty_page == NULL) ||
         cmp_translog_addr(lsn, dirty_page->rec_lsn) < 0)
     {
-      tprint(tracef, ", ignoring because of dirty_pages list\n");
+      tprint(tracef, ", ignoring page %s because of dirty_pages list\n",
+             llstr((ulonglong) page, llbuf));
       return TRUE;
     }
   }

=== modified file 'storage/maria/ma_rkey.c'
--- a/storage/maria/ma_rkey.c	2010-03-09 19:22:24 +0000
+++ b/storage/maria/ma_rkey.c	2011-01-10 21:22:40 +0000
@@ -43,7 +43,7 @@
 
   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
   info->last_key_func= search_flag;
-  keyinfo= share->keyinfo + inx;
+  keyinfo= info->last_key.keyinfo;
 
   key_buff= info->lastkey_buff+info->s->base.max_key_length;
 

=== modified file 'storage/maria/ma_rnext.c'
--- a/storage/maria/ma_rnext.c	2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_rnext.c	2011-01-10 21:22:40 +0000
@@ -30,6 +30,7 @@
   uint flag;
   MARIA_SHARE *share= info->s;
   MARIA_KEYDEF *keyinfo;
+  uint update_mask= HA_STATE_NEXT_FOUND;
   DBUG_ENTER("maria_rnext");
 
   if ((inx = _ma_check_index(info,inx)) < 0)
@@ -61,6 +62,20 @@
       error= _ma_search_first(info, keyinfo, share->state.key_root[inx]);
       break;
     }
+    /*
+      "search first" failed. This means we have no pivot for
+      "search next", or in other words MI_INFO::lastkey is
+      likely uninitialized.
+
+      Normally SQL layer would never request "search next" if
+      "search first" failed. But HANDLER may do anything.
+
+      As mi_rnext() without preceeding mi_rkey()/mi_rfirst()
+      equals to mi_rfirst(), we must restore original state
+      as if failing mi_rfirst() was not called.
+    */
+    if (error)
+      update_mask|= HA_STATE_PREV_FOUND;
   }
   else
   {
@@ -104,7 +119,7 @@
 
 	/* Don't clear if database-changed */
   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
-  info->update|= HA_STATE_NEXT_FOUND;
+  info->update|= update_mask;
 
   if (error)
   {

=== modified file 'storage/maria/ma_rsame.c'
--- a/storage/maria/ma_rsame.c	2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_rsame.c	2011-01-11 11:27:16 +0000
@@ -19,7 +19,7 @@
   Find current row with read on position or read on key
 
   @notes
-  If inx >= 0 find record using key
+  If inx >= 0 find record using key else re-read row on last position
 
   @warning
   This function is not row version safe.
@@ -29,6 +29,7 @@
   @retval 0                      Ok
   @retval HA_ERR_KEY_NOT_FOUND   Row is deleted
   @retval HA_ERR_END_OF_FILE     End of file
+  @retval HA_ERR_WRONG_INDEX	 Wrong inx argument
 */
 
 
@@ -36,10 +37,10 @@
 {
   DBUG_ENTER("maria_rsame");
 
-  if (inx != -1 && ! maria_is_key_active(info->s->state.key_map, inx))
+  if (inx >= 0 && _ma_check_index(info, inx) < 0)
   {
     DBUG_PRINT("error", ("wrong index usage"));
-    DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
+    DBUG_RETURN(my_errno);
   }
   if (info->cur_row.lastpos == HA_OFFSET_ERROR ||
       info->update & HA_STATE_DELETED)
@@ -55,8 +56,7 @@
 
   if (inx >= 0)
   {
-    MARIA_KEYDEF *keyinfo= info->s->keyinfo + inx;
-    info->lastinx= inx;
+    MARIA_KEYDEF *keyinfo= info->last_key.keyinfo;
     (*keyinfo->make_key)(info, &info->last_key, (uint) inx,
                          info->lastkey_buff, record,
                          info->cur_row.lastpos,

=== modified file 'storage/maria/ma_rt_index.c'
--- a/storage/maria/ma_rt_index.c	2010-08-09 17:05:42 +0000
+++ b/storage/maria/ma_rt_index.c	2011-01-11 10:18:03 +0000
@@ -134,7 +134,6 @@
         tmp_key.data_length= key_data_length;
 
         info->cur_row.lastpos= _ma_row_pos_from_key(&tmp_key);
-        info->last_key.keyinfo= keyinfo;
         info->last_key.data_length= key_data_length;
         info->last_key.ref_length=  share->base.rec_reflength;
         info->last_key.flag= 0;

=== modified file 'storage/maria/ma_search.c'
--- a/storage/maria/ma_search.c	2010-10-14 22:46:20 +0000
+++ b/storage/maria/ma_search.c	2011-01-11 12:29:19 +0000
@@ -38,12 +38,18 @@
   if (info->lastinx != inx)             /* Index changed */
   {
     info->lastinx = inx;
+    info->last_key.keyinfo= info->s->keyinfo + inx;
+    info->last_key.flag= 0;
     info->page_changed=1;
     info->update= ((info->update & (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED)) |
                    HA_STATE_NEXT_FOUND | HA_STATE_PREV_FOUND);
   }
-  if (info->opt_flag & WRITE_CACHE_USED && flush_io_cache(&info->rec_cache))
+  if ((info->opt_flag & WRITE_CACHE_USED) && flush_io_cache(&info->rec_cache))
+  {
+    if (unlikely(!my_errno))
+      my_errno= HA_ERR_INTERNAL_ERROR;          /* Impossible */
     return(-1);
+  }
   return(inx);
 } /* _ma_check_index */
 
@@ -95,6 +101,7 @@
 
    @note
      Position to row is stored in info->lastpos
+     Last used key is stored in info->last_key
 
    @return
    @retval  0   ok (key found)
@@ -120,6 +127,7 @@
                       (ulong) (pos / info->s->block_size),
                       nextflag, (ulong) info->cur_row.lastpos));
   DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE, key););
+  DBUG_ASSERT(info->last_key.keyinfo == key->keyinfo);
 
   if (pos == HA_OFFSET_ERROR)
   {
@@ -180,7 +188,6 @@
     }
   }
 
-  info->last_key.keyinfo= keyinfo;
   if ((nextflag & (SEARCH_SMALLER | SEARCH_LAST)) && flag != 0)
   {
     uint not_used[2];
@@ -1696,7 +1703,7 @@
   }
 
   tmp_key.data=   lastkey;
-  info->last_key.keyinfo= tmp_key.keyinfo= keyinfo;
+  tmp_key.keyinfo= keyinfo;
 
   if (nextflag & SEARCH_BIGGER)                                 /* Next key */
   {
@@ -1778,8 +1785,6 @@
     first_pos= page.buff + share->keypage_header + page.node;
   } while ((pos= _ma_kpos(page.node, first_pos)) != HA_OFFSET_ERROR);
 
-  info->last_key.keyinfo= keyinfo;
-
   if (!(*keyinfo->get_key)(&info->last_key, page.flag, page.node, &first_pos))
     DBUG_RETURN(-1);                            /* Crashed */
 
@@ -1830,8 +1835,6 @@
     end_of_page= page.buff + page.size;
   } while ((pos= _ma_kpos(page.node, end_of_page)) != HA_OFFSET_ERROR);
 
-  info->last_key.keyinfo= keyinfo;
-
   if (!_ma_get_last_key(&info->last_key, &page, end_of_page))
     DBUG_RETURN(-1);
   info->cur_row.lastpos= _ma_row_pos_from_key(&info->last_key);

=== modified file 'storage/maria/ma_sort.c'
--- a/storage/maria/ma_sort.c	2010-09-12 16:40:01 +0000
+++ b/storage/maria/ma_sort.c	2011-01-07 16:07:22 +0000
@@ -275,12 +275,13 @@
   idx=error=0;
   sort_keys[0]= (uchar*) (sort_keys+keys);
 
+  info->sort_info->info->in_check_table= 1;
   while (!(error=(*info->key_read)(info,sort_keys[idx])))
   {
     if (info->real_key_length > info->key_length)
     {
       if (write_key(info,sort_keys[idx],tempfile_for_exceptions))
-        DBUG_RETURN(HA_POS_ERROR);		/* purecov: inspected */
+        goto err;                             /* purecov: inspected */
       continue;
     }
 
@@ -289,7 +290,7 @@
       if (info->write_keys(info,sort_keys,idx-1,
                            (BUFFPEK *)alloc_dynamic(buffpek),
                            tempfile))
-      DBUG_RETURN(HA_POS_ERROR);		/* purecov: inspected */
+        goto err;                             /* purecov: inspected */
 
       sort_keys[0]=(uchar*) (sort_keys+keys);
       memcpy(sort_keys[0],sort_keys[idx-1],(size_t) info->key_length);
@@ -298,18 +299,23 @@
     sort_keys[idx]=sort_keys[idx-1]+info->key_length;
   }
   if (error > 0)
-    DBUG_RETURN(HA_POS_ERROR);		/* Aborted by get_key */ /* purecov: inspected */
+    goto err;                             /* purecov: inspected */
   if (buffpek->elements)
   {
     if (info->write_keys(info,sort_keys,idx,(BUFFPEK *)alloc_dynamic(buffpek),
                          tempfile))
-      DBUG_RETURN(HA_POS_ERROR);		/* purecov: inspected */
+      goto err;                         /* purecov: inspected */      
     *maxbuffer=buffpek->elements-1;
   }
   else
     *maxbuffer=0;
 
+  info->sort_info->info->in_check_table= 0;
   DBUG_RETURN((*maxbuffer)*(keys-1)+idx);
+
+err:
+  info->sort_info->info->in_check_table= 0;   /* purecov: inspected */
+  DBUG_RETURN(HA_POS_ERROR);                  /* purecov: inspected */
 } /* find_all_keys */
 
 

=== modified file 'storage/maria/ma_unique.c'
--- a/storage/maria/ma_unique.c	2010-09-07 20:57:00 +0000
+++ b/storage/maria/ma_unique.c	2011-01-11 10:18:03 +0000
@@ -34,6 +34,7 @@
   MARIA_KEYDEF *keyinfo= &info->s->keyinfo[def->key];
   uchar *key_buff= info->lastkey_buff2;
   MARIA_KEY key;
+  int error= 0;
   DBUG_ENTER("_ma_check_unique");
   DBUG_PRINT("enter",("unique_hash: %lu", (ulong) unique_hash));
 
@@ -44,12 +45,18 @@
   /* The above changed info->lastkey_buff2. Inform maria_rnext_same(). */
   info->update&= ~HA_STATE_RNEXT_SAME;
 
+  /* Setup that unique key is active key */
+  info->last_key.keyinfo= keyinfo;
+
+  /* any key pointer in data is destroyed */
+  info->lastinx= ~0;
+
   DBUG_ASSERT(key.data_length == MARIA_UNIQUE_HASH_LENGTH);
   if (_ma_search(info, &key, SEARCH_FIND, info->s->state.key_root[def->key]))
   {
     info->page_changed=1;			/* Can't optimize read next */
     info->cur_row.lastpos= lastpos;
-    DBUG_RETURN(0);				/* No matching rows */
+    goto end;
   }
 
   for (;;)
@@ -63,7 +70,8 @@
       info->page_changed= 1;			/* Can't optimize read next */
       info->cur_row.lastpos= lastpos;
       DBUG_PRINT("info",("Found duplicate"));
-      DBUG_RETURN(1);				/* Found identical  */
+      error= 1;                                 /* Found identical  */
+      goto end;
     }
     DBUG_ASSERT(info->last_key.data_length == MARIA_UNIQUE_HASH_LENGTH);
     if (_ma_search_next(info, &info->last_key, SEARCH_BIGGER,
@@ -72,9 +80,12 @@
     {
       info->page_changed= 1;			/* Can't optimize read next */
       info->cur_row.lastpos= lastpos;
-      DBUG_RETURN(0);				/* end of tree */
+      break;                                    /* end of tree */
     }
   }
+
+end:
+  DBUG_RETURN(error);
 }
 
 

=== modified file 'storage/maria/maria_def.h'
--- a/storage/maria/maria_def.h	2010-12-10 15:15:18 +0000
+++ b/storage/maria/maria_def.h	2011-01-06 20:49:17 +0000
@@ -570,6 +570,7 @@
   my_bool was_locked;			/* Was locked in panic */
   my_bool append_insert_at_end;		/* Set if concurrent insert */
   my_bool quick_mode;
+  my_bool in_check_table;                /* We are running check tables */
   /* Marker if key_del_changed */
   /* If info->keyread_buff can't be used for rnext */
   my_bool page_changed;

=== modified file 'storage/maria/maria_read_log.c'
--- a/storage/maria/maria_read_log.c	2010-09-12 16:40:01 +0000
+++ b/storage/maria/maria_read_log.c	2011-01-12 15:38:13 +0000
@@ -192,14 +192,18 @@
   {"display-only", 'd', "display brief info read from records' header",
    &opt_display_only, &opt_display_only, 0, GET_BOOL,
    NO_ARG,0, 0, 0, 0, 0, 0},
+  { "end-lsn", 'e', "Stop applying at this lsn. If end-lsn is used, UNDO:s "
+    "will not be applied", &opt_end_lsn, &opt_end_lsn,
+    0, GET_ULL, REQUIRED_ARG, 0, 0, ~(longlong) 0, 0, 0, 0 },
   {"aria-log-dir-path", 'l',
     "Path to the directory where to store transactional log",
     (uchar **) &maria_data_root, (uchar **) &maria_data_root, 0,
     GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  { "page-buffer-size", 'P', "",
+  { "page-buffer-size", 'P',
+    "The size of the buffer used for index blocks for Maria tables",
     &opt_page_buffer_size, &opt_page_buffer_size, 0,
     GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT,
-    (long) USE_BUFFER_INIT, (long) ~(ulong) 0, (long) MALLOC_OVERHEAD,
+    1024L*1024L, (long) ~(ulong) 0, (long) MALLOC_OVERHEAD,
     (long) IO_SIZE, 0},
   { "start-from-lsn", 'o', "Start reading log from this lsn",
     &opt_start_from_lsn, &opt_start_from_lsn,
@@ -207,15 +211,12 @@
   {"start-from-checkpoint", 'C', "Start applying from last checkpoint",
    &opt_start_from_checkpoint, &opt_start_from_checkpoint, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  { "end-lsn", 'e', "Stop applying at this lsn. If end-lsn is used, UNDO:s "
-    "will not be applied", &opt_end_lsn, &opt_end_lsn,
-    0, GET_ULL, REQUIRED_ARG, 0, 0, ~(longlong) 0, 0, 0, 0 },
   {"silent", 's', "Print less information during apply/undo phase",
    &opt_silent, &opt_silent, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  {"verbose", 'v', "Print more information during apply/undo phase",
-   &maria_recovery_verbose, &maria_recovery_verbose, 0,
-   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"tables-to-redo", 'T',
+   "List of tables sepearated with , that we should apply REDO on. Use this if you only want to recover some tables",
+   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"tmpdir", 't', "Path for temporary files. Multiple paths can be specified, "
    "separated by "
 #if defined( __WIN__) || defined(__NETWARE__)
@@ -227,6 +228,9 @@
   {"undo", 'u', "Apply UNDO records to tables. (disable with --disable-undo)",
    (uchar **) &opt_apply_undo, (uchar **) &opt_apply_undo, 0,
    GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+  {"verbose", 'v', "Print more information during apply/undo phase",
+   &maria_recovery_verbose, &maria_recovery_verbose, 0,
+   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"version", 'V', "Print version and exit.",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
@@ -245,7 +249,7 @@
 static void usage(void)
 {
   print_version();
-  puts("Copyright (C) 2007 MySQL AB");
+  puts("Copyright (C) 2007 MySQL AB, 2009-2011 Monty Program Ab");
   puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
   puts("and you are welcome to modify and redistribute it under the GPL license\n");
 
@@ -266,10 +270,18 @@
 
 #include <help_end.h>
 
+static uchar* my_hash_get_string(const uchar *record, size_t *length,
+                                my_bool first __attribute__ ((unused)))
+{
+  *length= (size_t) (strcend((const char*) record,',')- (const char*) record);
+  return (uchar*) record;
+}
+
+
 static my_bool
 get_one_option(int optid __attribute__((unused)),
                const struct my_option *opt __attribute__((unused)),
-               char *argument __attribute__((unused)))
+               char *argument)
 {
   switch (optid) {
   case '?':
@@ -278,6 +290,23 @@
   case 'V':
     print_version();
     exit(0);
+  case 'T':
+  {
+    char *pos;
+    if (!my_hash_inited(&tables_to_redo))
+    {
+      my_hash_init2(&tables_to_redo, 16, &my_charset_bin,
+                    16, 0, 0, my_hash_get_string, 0, HASH_UNIQUE);
+    }
+    do
+    {
+      pos= strcend(argument, ',');
+      if (pos != argument)                      /* Skip empty strings */
+        my_hash_insert(&tables_to_redo, (uchar*) argument);
+      argument= pos+1;
+    } while (*(pos++));
+    break;
+  }
 #ifndef DBUG_OFF
   case '#':
     DBUG_SET_INITIAL(argument ? argument : default_dbug_option);
@@ -290,6 +319,7 @@
 static void get_options(int *argc,char ***argv)
 {
   int ho_error;
+  my_bool need_help= 0;
 
   if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
     exit(ho_error);
@@ -297,8 +327,23 @@
   if (!opt_apply)
     opt_apply_undo= FALSE;
 
-  if (((opt_display_only + opt_apply) != 1) || (*argc > 0))
-  {
+  if (*argc > 0)
+  {
+    need_help= 1;
+    fprintf(stderr, "Too many arguments given\n");
+  }
+  if ((opt_display_only + opt_apply) != 1)
+  {
+    need_help= 1;
+    fprintf(stderr,
+            "You must use one and only one of the options 'display-only' or "
+            "'apply'\n");
+  }
+
+  if (need_help)
+  {
+    fflush(stderr);
+    need_help =1;
     usage();
     exit(1);
   }

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2010-11-19 21:33:47 +0000
+++ b/storage/myisam/ha_myisam.cc	2010-12-31 09:39:14 +0000
@@ -545,6 +545,7 @@
   :handler(hton, table_arg), file(0),
   int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
                   HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
+                  HA_CAN_VIRTUAL_COLUMNS |
                   HA_DUPLICATE_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
                   HA_FILE_BASED | HA_CAN_GEOMETRY | HA_NO_TRANSACTIONS |
                   HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS |

=== modified file 'storage/myisam/ha_myisam.h'
--- a/storage/myisam/ha_myisam.h	2010-11-19 21:33:47 +0000
+++ b/storage/myisam/ha_myisam.h	2010-12-31 09:39:14 +0000
@@ -133,7 +133,6 @@
   int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt);
   int preload_keys(THD* thd, HA_CHECK_OPT* check_opt);
   bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
-  bool check_if_supported_virtual_columns(void) { return TRUE;}
 #ifdef HAVE_REPLICATION
   int dump(THD* thd, int fd);
   int net_read_dump(NET* net);

=== modified file 'storage/myisammrg/ha_myisammrg.cc'
--- a/storage/myisammrg/ha_myisammrg.cc	2010-11-30 21:11:03 +0000
+++ b/storage/myisammrg/ha_myisammrg.cc	2011-01-07 11:45:59 +0000
@@ -1057,9 +1057,9 @@
 
   /*
     When MERGE table is open, but not yet attached, other threads
-    could flush it, which means call mysql_lock_abort_for_thread()
+    could flush it, which means calling mysql_lock_abort_for_thread()
     on this threads TABLE. 'children_attached' is FALSE in this
-    situaton. Since the table is not locked, return no lock data.
+    situation. Since the table is not locked, return no lock data.
   */
   if (!this->file->children_attached)
     goto end; /* purecov: tested */

=== modified file 'storage/ndb/include/ndbapi/NdbError.hpp'
--- a/storage/ndb/include/ndbapi/NdbError.hpp	2006-12-23 19:20:40 +0000
+++ b/storage/ndb/include/ndbapi/NdbError.hpp	2011-01-07 11:45:59 +0000
@@ -66,7 +66,7 @@
     
     /**
      * The error code indicates a permanent error.<br>
-     * (Includes classificatons: NdbError::PermanentError, 
+     * (Includes classifications: NdbError::PermanentError, 
      *  NdbError::ApplicationError, NdbError::NoDataFound,
      *  NdbError::ConstraintViolation, NdbError::SchemaError,
      *  NdbError::UserDefinedError, NdbError::InternalError, and, 

=== modified file 'storage/ndb/include/util/File.hpp'
--- a/storage/ndb/include/util/File.hpp	2006-12-31 00:32:21 +0000
+++ b/storage/ndb/include/util/File.hpp	2011-01-07 11:45:59 +0000
@@ -31,7 +31,7 @@
    * Returns time for last contents modification of a file.
    *
    * @param aFileName a filename to check.
-   * @return the time for last contents modificaton of the file.
+   * @return the time for last contents modification of the file.
    */
   static time_t mtime(const char* aFileName);      
 

=== modified file 'storage/xtradb/handler/ha_innodb.cc'
--- a/storage/xtradb/handler/ha_innodb.cc	2010-11-30 21:11:03 +0000
+++ b/storage/xtradb/handler/ha_innodb.cc	2010-12-31 09:39:14 +0000
@@ -1471,7 +1471,7 @@
 ha_innobase::ha_innobase(handlerton *hton, TABLE_SHARE *table_arg)
   :handler(hton, table_arg),
   int_table_flags(HA_REC_NOT_IN_SEQ |
-		  HA_NULL_IN_KEY |
+		  HA_NULL_IN_KEY | HA_CAN_VIRTUAL_COLUMNS |
 		  HA_CAN_INDEX_BLOBS |
 		  HA_CAN_SQL_HANDLER |
 		  HA_PRIMARY_KEY_REQUIRED_FOR_POSITION |

=== modified file 'storage/xtradb/handler/ha_innodb.h'
--- a/storage/xtradb/handler/ha_innodb.h	2010-11-30 21:11:03 +0000
+++ b/storage/xtradb/handler/ha_innodb.h	2010-12-31 09:39:14 +0000
@@ -222,7 +222,6 @@
 	/** @} */
 	bool check_if_incompatible_data(HA_CREATE_INFO *info,
 					uint table_changes);
-	bool check_if_supported_virtual_columns(void) { return TRUE; }
 };
 
 /* Some accessor functions which the InnoDB plugin needs, but which

=== modified file 'storage/xtradb/trx/trx0sys.c'
--- a/storage/xtradb/trx/trx0sys.c	2010-11-24 13:04:38 +0000
+++ b/storage/xtradb/trx/trx0sys.c	2011-01-07 11:45:59 +0000
@@ -1667,7 +1667,7 @@
 
 
 /* THESE ARE COPIED FROM NON-HOTBACKUP PART OF THE INNODB SOURCE TREE
-   (This code duplicaton should be fixed at some point!)
+   (This code duplication should be fixed at some point!)
 */
 
 #define	TRX_SYS_SPACE	0	/* the SYSTEM tablespace */



More information about the commits mailing list