List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:April 22 2011 3:14pm
Subject:bzr push into mysql-trunk branch (chris.powers:3284 to 3285)
View as plain text  
 3285 Christopher Powers	2011-04-21 [merge]
      merge with mysql-trunk

    added:
      mysql-test/suite/innodb/r/innodb_bug11933790.result
      mysql-test/suite/innodb/r/innodb_bug59410.result
      mysql-test/suite/innodb/r/innodb_bug59641.result
      mysql-test/suite/innodb/t/innodb_bug11933790.test
      mysql-test/suite/innodb/t/innodb_bug59410.test
      mysql-test/suite/innodb/t/innodb_bug59641.test
      storage/innobase/include/srv0conc.h
      storage/innobase/srv/srv0conc.c
    modified:
      client/mysqltest.cc
      include/mysql/psi/psi.h
      include/mysql/psi/psi_abi_v2.h.pp
      mysql-test/r/func_math.result
      mysql-test/suite/innodb/r/innodb_monitor.result
      mysql-test/suite/perfschema/r/misc.result
      mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/t/misc.test
      mysql-test/suite/sys_vars/r/all_vars.result
      mysql-test/t/func_math.test
      sql/handler.cc
      sql/item_func.cc
      sql/mysqld.h
      sql/sql_class.cc
      storage/innobase/CMakeLists.txt
      storage/innobase/btr/btr0btr.c
      storage/innobase/btr/btr0cur.c
      storage/innobase/buf/buf0buf.c
      storage/innobase/buf/buf0flu.c
      storage/innobase/buf/buf0lru.c
      storage/innobase/dict/dict0crea.c
      storage/innobase/dict/dict0dict.c
      storage/innobase/dict/dict0load.c
      storage/innobase/dict/dict0mem.c
      storage/innobase/dict/dict0stats.c
      storage/innobase/fil/fil0fil.c
      storage/innobase/fsp/fsp0fsp.c
      storage/innobase/ha/ha0ha.c
      storage/innobase/ha/hash0hash.c
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/ha_innodb.h
      storage/innobase/handler/handler0alter.cc
      storage/innobase/handler/i_s.cc
      storage/innobase/ibuf/ibuf0ibuf.c
      storage/innobase/include/buf0buf.h
      storage/innobase/include/buf0buf.ic
      storage/innobase/include/buf0flu.h
      storage/innobase/include/buf0lru.h
      storage/innobase/include/dict0dict.ic
      storage/innobase/include/dict0mem.ic
      storage/innobase/include/dict0priv.ic
      storage/innobase/include/fsp0fsp.h
      storage/innobase/include/log0log.h
      storage/innobase/include/log0log.ic
      storage/innobase/include/os0file.h
      storage/innobase/include/os0sync.h
      storage/innobase/include/os0thread.h
      storage/innobase/include/srv0mon.h
      storage/innobase/include/srv0srv.h
      storage/innobase/include/sync0arr.h
      storage/innobase/include/sync0arr.ic
      storage/innobase/include/sync0rw.h
      storage/innobase/include/sync0rw.ic
      storage/innobase/include/sync0sync.h
      storage/innobase/include/trx0sys.h
      storage/innobase/include/trx0trx.h
      storage/innobase/include/trx0undo.h
      storage/innobase/include/univ.i
      storage/innobase/include/ut0bh.ic
      storage/innobase/include/ut0dbg.h
      storage/innobase/include/ut0ut.h
      storage/innobase/include/ut0vec.h
      storage/innobase/include/ut0vec.ic
      storage/innobase/lock/lock0lock.c
      storage/innobase/lock/lock0wait.c
      storage/innobase/log/log0log.c
      storage/innobase/log/log0recv.c
      storage/innobase/mem/mem0dbg.c
      storage/innobase/mtr/mtr0log.c
      storage/innobase/os/os0file.c
      storage/innobase/os/os0sync.c
      storage/innobase/os/os0thread.c
      storage/innobase/page/page0zip.c
      storage/innobase/que/que0que.c
      storage/innobase/row/row0merge.c
      storage/innobase/row/row0mysql.c
      storage/innobase/row/row0row.c
      storage/innobase/row/row0sel.c
      storage/innobase/row/row0uins.c
      storage/innobase/row/row0upd.c
      storage/innobase/srv/srv0mon.c
      storage/innobase/srv/srv0srv.c
      storage/innobase/srv/srv0start.c
      storage/innobase/sync/sync0arr.c
      storage/innobase/sync/sync0rw.c
      storage/innobase/sync/sync0sync.c
      storage/innobase/trx/trx0purge.c
      storage/innobase/trx/trx0roll.c
      storage/innobase/trx/trx0sys.c
      storage/innobase/trx/trx0trx.c
      storage/innobase/trx/trx0undo.c
      storage/innobase/ut/ut0dbg.c
      storage/innobase/ut/ut0ut.c
 3284 cpowers	2011-04-19
      WL#4896 "Performance Schema Net IO"
      
      Remove debugging code

    modified:
      storage/perfschema/pfs_stat.h
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2011-03-22 15:40:32 +0000
+++ b/client/mysqltest.cc	2011-04-11 14:57:47 +0000
@@ -4569,13 +4569,14 @@ static int my_kill(int pid, int sig)
   command  called command
 
   DESCRIPTION
-  shutdown [<timeout>]
+  shutdown_server [<timeout>]
 
 */
 
 void do_shutdown_server(struct st_command *command)
 {
-  int timeout=60, pid;
+  long timeout=60;
+  int pid;
   DYNAMIC_STRING ds_pidfile_name;
   MYSQL* mysql = &cur_con->mysql;
   static DYNAMIC_STRING ds_timeout;
@@ -4590,8 +4591,9 @@ void do_shutdown_server(struct st_comman
 
   if (ds_timeout.length)
   {
-    timeout= atoi(ds_timeout.str);
-    if (timeout == 0)
+    char* endptr;
+    timeout= strtol(ds_timeout.str, &endptr, 10);
+    if (*endptr != '\0')
       die("Illegal argument for timeout: '%s'", ds_timeout.str);
   }
   dynstr_free(&ds_timeout);
@@ -4633,7 +4635,7 @@ void do_shutdown_server(struct st_comman
       DBUG_PRINT("info", ("Process %d does not exist anymore", pid));
       DBUG_VOID_RETURN;
     }
-    DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout));
+    DBUG_PRINT("info", ("Sleeping, timeout: %ld", timeout));
     my_sleep(1000000L);
   }
 

=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h	2011-03-28 20:15:26 +0000
+++ b/include/mysql/psi/psi.h	2011-04-22 03:07:02 +0000
@@ -1964,12 +1964,27 @@ struct PSI_file_info_v2
 };
 
 /** Placeholder */
+struct PSI_stage_info_v2
+{
+  /** Placeholder */
+  int placeholder;
+};
+
+/** Placeholder */
+struct PSI_statement_info_v2
+{
+  /** Placeholder */
+  int placeholder;
+};
+
+/** Placeholder */
 struct PSI_idle_locker_state_v2
 {
   /** Placeholder */
   int placeholder;
 };
 
+/** Placeholder */
 struct PSI_mutex_locker_state_v2
 {
   /** Placeholder */
@@ -2107,6 +2122,31 @@ struct PSI_none
 };
 typedef struct PSI_none PSI;
 
+/**
+  Stage instrument information.
+  @since PSI_VERSION_1
+  This structure is used to register an instrumented stage.
+*/
+struct PSI_stage_info_none
+{
+  /** Unused stage key. */
+  unsigned int m_key;
+  /** The name of the stage instrument. */
+  const char *m_name;
+  /** Unused stage flags. */
+  int m_flags;
+};
+
+/**
+  The stage instrumentation has to co exist with the legacy
+  THD::set_proc_info instrumentation.
+  To avoid duplication of the instrumentation in the server,
+  the common PSI_stage_info structure is used,
+  so we export it here, even when not building
+  with HAVE_PSI_INTERFACE.
+*/
+typedef struct PSI_stage_info_none PSI_stage_info;
+
 #endif /* HAVE_PSI_INTERFACE */
 
 extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;

=== modified file 'include/mysql/psi/psi_abi_v2.h.pp'
--- a/include/mysql/psi/psi_abi_v2.h.pp	2011-03-29 00:46:15 +0000
+++ b/include/mysql/psi/psi_abi_v2.h.pp	2011-04-22 03:07:02 +0000
@@ -123,6 +123,14 @@ struct PSI_file_info_v2
 {
   int placeholder;
 };
+struct PSI_stage_info_v2
+{
+  int placeholder;
+};
+struct PSI_statement_info_v2
+{
+  int placeholder;
+};
 struct PSI_idle_locker_state_v2
 {
   int placeholder;

=== modified file 'mysql-test/r/func_math.result'
--- a/mysql-test/r/func_math.result	2011-03-28 09:04:13 +0000
+++ b/mysql-test/r/func_math.result	2011-04-20 07:56:57 +0000
@@ -521,6 +521,28 @@ CREATE TABLE t1 SELECT CEIL(LINESTRINGFR
 DROP TABLE t1;
 CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
 DROP TABLE t1;
+#
+# Bug#11765923  58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
+#
+CREATE TABLE t1(f1 DECIMAL(22,1));
+INSERT INTO t1 VALUES (0),(1);
+SELECT ROUND(f1, f1) FROM t1;
+ROUND(f1, f1)
+0.0
+1.0
+SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
+ROUND(f1, f1)
+0.0
+1.0
+DROP TABLE t1;
+#
+# Bug#11764671  57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
+#
+SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
+ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'))
+-4939092.0000
+Warnings:
+Warning	1292	Truncated incorrect DOUBLE value: 'a'
 End of 5.1 tests
 #
 # Bug #8433: Overflow must be an error

=== added file 'mysql-test/suite/innodb/r/innodb_bug11933790.result'
--- a/mysql-test/suite/innodb/r/innodb_bug11933790.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug11933790.result	2011-04-04 14:19:29 +0000
@@ -0,0 +1,4 @@
+call mtr.add_suppression("InnoDB: Error while trying to save table statistics for table .+bug11933790: Lock wait timeout");
+ANALYZE TABLE bug11933790;
+Table	Op	Msg_type	Msg_text
+test.bug11933790	analyze	status	Operation failed

=== added file 'mysql-test/suite/innodb/r/innodb_bug59410.result'
--- a/mysql-test/suite/innodb/r/innodb_bug59410.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug59410.result	2011-04-05 08:30:38 +0000
@@ -0,0 +1,17 @@
+create table `bug59410_1`(`a` int)engine=innodb;
+insert into `bug59410_1` values (1),(2),(3);
+select 1 from `bug59410_1` where `a` <> any (
+select 1 from `bug59410_1` where `a` <> 1 for update)
+for update;
+1
+1
+1
+drop table bug59410_1;
+create table bug59410_2(`a` char(1),`b` int)engine=innodb;
+insert into bug59410_2 values('0',0);
+set transaction isolation level read uncommitted;
+start transaction;
+set @a=(select b from bug59410_2 where
+(select 1 from bug59410_2 where a group by @a=b)
+group by @a:=b);
+drop table bug59410_2;

=== added file 'mysql-test/suite/innodb/r/innodb_bug59641.result'
--- a/mysql-test/suite/innodb/r/innodb_bug59641.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug59641.result	2011-04-07 18:12:54 +0000
@@ -0,0 +1,57 @@
+CREATE TABLE t(a INT PRIMARY KEY, b INT)ENGINE=InnoDB;
+INSERT INTO t VALUES(2,2),(4,4),(8,8),(16,16),(32,32);
+COMMIT;
+XA START '123';
+INSERT INTO t VALUES(1,1);
+XA END '123';
+XA PREPARE '123';
+XA START '456';
+INSERT INTO t VALUES(3,47),(5,67);
+UPDATE t SET b=2*b WHERE a BETWEEN 5 AND 8;
+XA END '456';
+XA PREPARE '456';
+XA START '789';
+UPDATE t SET b=4*a WHERE a=32;
+XA END '789';
+XA PREPARE '789';
+call mtr.add_suppression("Found 3 prepared XA transactions");
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT * FROM t;
+a	b
+1	1
+2	2
+3	47
+4	4
+5	134
+8	16
+16	16
+32	128
+COMMIT;
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT * FROM t;
+a	b
+1	1
+2	2
+3	47
+4	4
+5	134
+8	16
+16	16
+32	128
+COMMIT;
+XA RECOVER;
+formatID	gtrid_length	bqual_length	data
+1	3	0	789
+1	3	0	456
+1	3	0	123
+XA ROLLBACK '123';
+XA ROLLBACK '456';
+XA COMMIT '789';
+SELECT * FROM t;
+a	b
+2	2
+4	4
+8	8
+16	16
+32	128
+DROP TABLE t;

=== modified file 'mysql-test/suite/innodb/r/innodb_monitor.result'
--- a/mysql-test/suite/innodb/r/innodb_monitor.result	2011-02-28 09:35:01 +0000
+++ b/mysql-test/suite/innodb/r/innodb_monitor.result	2011-04-14 06:31:44 +0000
@@ -110,6 +110,7 @@ trx_undo_slots_cached	disabled
 trx_rseg_curent_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
+purge_invoked	disabled
 purge_undo_log_pages	disabled
 purge_dml_delay_usec	disabled
 log_checkpoints	disabled
@@ -289,6 +290,7 @@ trx_undo_slots_cached	enabled
 trx_rseg_curent_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
+purge_invoked	enabled
 purge_undo_log_pages	enabled
 purge_dml_delay_usec	enabled
 log_checkpoints	enabled
@@ -470,6 +472,7 @@ trx_undo_slots_cached	disabled
 trx_rseg_curent_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
+purge_invoked	disabled
 purge_undo_log_pages	disabled
 purge_dml_delay_usec	disabled
 log_checkpoints	disabled
@@ -649,6 +652,7 @@ trx_undo_slots_cached	0	disabled
 trx_rseg_curent_size	0	disabled
 purge_del_mark_records	0	disabled
 purge_upd_exist_or_extern_records	0	disabled
+purge_invoked	0	disabled
 purge_undo_log_pages	0	disabled
 purge_dml_delay_usec	0	disabled
 log_checkpoints	0	disabled
@@ -882,6 +886,7 @@ trx_undo_slots_cached	enabled
 trx_rseg_curent_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
+purge_invoked	enabled
 purge_undo_log_pages	enabled
 purge_dml_delay_usec	enabled
 log_checkpoints	enabled
@@ -1061,6 +1066,7 @@ trx_undo_slots_cached	disabled
 trx_rseg_curent_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
+purge_invoked	disabled
 purge_undo_log_pages	disabled
 purge_dml_delay_usec	disabled
 log_checkpoints	disabled
@@ -1240,6 +1246,7 @@ trx_undo_slots_cached	enabled
 trx_rseg_curent_size	enabled
 purge_del_mark_records	enabled
 purge_upd_exist_or_extern_records	enabled
+purge_invoked	enabled
 purge_undo_log_pages	enabled
 purge_dml_delay_usec	enabled
 log_checkpoints	enabled
@@ -1419,6 +1426,7 @@ trx_undo_slots_cached	disabled
 trx_rseg_curent_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
+purge_invoked	disabled
 purge_undo_log_pages	disabled
 purge_dml_delay_usec	disabled
 log_checkpoints	disabled
@@ -1598,6 +1606,7 @@ trx_undo_slots_cached	disabled
 trx_rseg_curent_size	disabled
 purge_del_mark_records	disabled
 purge_upd_exist_or_extern_records	disabled
+purge_invoked	disabled
 purge_undo_log_pages	disabled
 purge_dml_delay_usec	disabled
 log_checkpoints	enabled

=== added file 'mysql-test/suite/innodb/t/innodb_bug11933790.test'
--- a/mysql-test/suite/innodb/t/innodb_bug11933790.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug11933790.test	2011-04-04 14:19:29 +0000
@@ -0,0 +1,48 @@
+#
+# Bug 11933790 - INNODB ASSERTS TRX->IN_MYSQL_TRX_LIST IN ANALYZE WITH
+# PERSISTENT STATS
+#
+
+-- source include/have_innodb.inc
+-- source suite/innodb/include/innodb_stats_bootstrap.inc
+
+call mtr.add_suppression("InnoDB: Error while trying to save table statistics for table .+bug11933790: Lock wait timeout");
+
+# we are only interested that the below commands do not crash the server
+-- disable_query_log
+-- disable_result_log
+
+SET SESSION innodb_analyze_is_persistent=1;
+
+CREATE TABLE bug11933790 (c INT) ENGINE=INNODB;
+
+# add some records to innodb.table_stats
+ANALYZE TABLE bug11933790;
+
+SET autocommit=0;
+
+# lock the records in innodb.table_stats
+SELECT * FROM innodb.table_stats FOR UPDATE;
+
+-- connect (con1,localhost,root,,)
+
+-- connection con1
+
+SET SESSION innodb_analyze_is_persistent=1;
+
+# this will fail with lock wait timeout; if the bug is present then mysqld
+# crashes here
+-- enable_query_log
+-- enable_result_log
+ANALYZE TABLE bug11933790;
+-- disable_query_log
+-- disable_result_log
+
+-- connection default
+
+-- disconnect con1
+
+COMMIT;
+
+DROP TABLE bug11933790;
+DROP DATABASE innodb;

=== added file 'mysql-test/suite/innodb/t/innodb_bug59410.test'
--- a/mysql-test/suite/innodb/t/innodb_bug59410.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug59410.test	2011-04-06 11:40:57 +0000
@@ -0,0 +1,24 @@
+#
+# Bug#59410 read uncommitted: unlock row could not find a 3 mode lock on the record
+#
+-- source include/have_innodb.inc
+
+# only interested that the following do not produce something like
+# InnoDB: Error: unlock row could not find a 2 mode lock on the record
+# in the error log
+
+create table `bug59410_1`(`a` int)engine=innodb;
+insert into `bug59410_1` values (1),(2),(3);
+select 1 from `bug59410_1` where `a` <> any (
+select 1 from `bug59410_1` where `a` <> 1 for update)
+for update;
+drop table bug59410_1;
+
+create table bug59410_2(`a` char(1),`b` int)engine=innodb;
+insert into bug59410_2 values('0',0);
+set transaction isolation level read uncommitted;
+start transaction;
+set @a=(select b from bug59410_2 where
+(select 1 from bug59410_2 where a group by @a=b)
+group by @a:=b);
+drop table bug59410_2;

=== added file 'mysql-test/suite/innodb/t/innodb_bug59641.test'
--- a/mysql-test/suite/innodb/t/innodb_bug59641.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug59641.test	2011-04-21 07:56:17 +0000
@@ -0,0 +1,68 @@
+# Bug #59641 Prepared XA transaction causes shutdown hang after a crash
+
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+CREATE TABLE t(a INT PRIMARY KEY, b INT)ENGINE=InnoDB;
+INSERT INTO t VALUES(2,2),(4,4),(8,8),(16,16),(32,32);
+COMMIT;
+XA START '123';
+INSERT INTO t VALUES(1,1);
+XA END '123';
+XA PREPARE '123';
+
+CONNECT (con1,localhost,root,,);
+CONNECTION con1;
+
+XA START '456';
+INSERT INTO t VALUES(3,47),(5,67);
+UPDATE t SET b=2*b WHERE a BETWEEN 5 AND 8;
+XA END '456';
+XA PREPARE '456';
+
+CONNECT (con2,localhost,root,,);
+CONNECTION con2;
+
+XA START '789';
+UPDATE t SET b=4*a WHERE a=32;
+XA END '789';
+XA PREPARE '789';
+
+CONNECT (con3,localhost,root,,);
+CONNECTION con3;
+# The server would issue this warning on restart.
+call mtr.add_suppression("Found 3 prepared XA transactions");
+
+# Kill the server without sending a shutdown command
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- shutdown_server 0
+-- source include/wait_until_disconnected.inc
+
+# Restart the server.
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT * FROM t;
+COMMIT;
+
+# Shut down the server. This would hang because of the bug.
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- shutdown_server
+-- source include/wait_until_disconnected.inc
+
+# Restart the server.
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+SELECT * FROM t;
+COMMIT;
+XA RECOVER;
+XA ROLLBACK '123';
+XA ROLLBACK '456';
+XA COMMIT '789';
+SELECT * FROM t;
+
+DROP TABLE t;

=== modified file 'mysql-test/suite/perfschema/r/misc.result'
--- a/mysql-test/suite/perfschema/r/misc.result	2010-12-01 18:46:51 +0000
+++ b/mysql-test/suite/perfschema/r/misc.result	2011-04-20 17:56:53 +0000
@@ -27,3 +27,23 @@ where file_name like "%ghost%";
 FILE_NAME	EVENT_NAME	OPEN_COUNT
 select * from performance_schema.no_such_table;
 ERROR 42S02: Table 'performance_schema.no_such_table' doesn't exist
+DROP TABLE IF EXISTS t_60905;
+CREATE TABLE t_60905 (i INT, j INT, KEY(i)) ENGINE = InnoDB;
+INSERT INTO t_60905 VALUES
+(1,2), (3,4), (5,6), (7,8), (9,10);
+DELETE FROM t_60905 WHERE i = 1;
+DELETE FROM t_60905 WHERE j = 8;
+SELECT object_schema,
+object_name,
+index_name,
+count_fetch,
+count_insert,
+count_update,
+count_delete
+FROM performance_schema.table_io_waits_summary_by_index_usage
+WHERE object_schema = 'test'
+   AND object_name = 't_60905';
+object_schema	object_name	index_name	count_fetch	count_insert	count_update	count_delete
+test	t_60905	i	2	0	0	1
+test	t_60905	NULL	5	5	0	1
+DROP TABLE t_60905;

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result	2011-04-22 03:07:02 +0000
@@ -207,10 +207,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -250,10 +250,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -331,10 +331,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -376,10 +376,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -466,10 +466,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -513,10 +513,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -612,10 +612,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -663,10 +663,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -711,10 +711,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -760,10 +760,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -805,10 +805,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -848,10 +848,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -889,10 +889,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -928,10 +928,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -968,10 +968,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result	2011-04-22 03:07:02 +0000
@@ -206,10 +206,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -249,10 +249,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -330,10 +330,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -375,10 +375,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -465,10 +465,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -512,10 +512,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -611,10 +611,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -662,10 +662,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -710,10 +710,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -759,10 +759,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -804,10 +804,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -847,10 +847,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -888,10 +888,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -927,10 +927,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -967,10 +967,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result	2011-04-22 03:07:02 +0000
@@ -207,10 +207,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -250,10 +250,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -331,10 +331,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -376,10 +376,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -466,10 +466,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -513,10 +513,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -612,10 +612,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -663,10 +663,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -711,10 +711,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -760,10 +760,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -805,10 +805,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -848,10 +848,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -889,10 +889,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -928,10 +928,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -968,10 +968,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result	2011-04-22 03:07:02 +0000
@@ -206,10 +206,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -249,10 +249,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -330,10 +330,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -375,10 +375,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -465,10 +465,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -512,10 +512,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -611,10 +611,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -662,10 +662,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -710,10 +710,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -759,10 +759,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -804,10 +804,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -847,10 +847,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -888,10 +888,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -927,10 +927,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -967,10 +967,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -256,10 +256,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -341,10 +341,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -390,10 +390,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -484,10 +484,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -535,10 +535,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -638,10 +638,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -693,10 +693,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -745,10 +745,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -798,10 +798,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -847,10 +847,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -894,10 +894,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -939,10 +939,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -982,10 +982,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -1026,10 +1026,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result	2011-04-22 03:07:02 +0000
@@ -210,10 +210,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -259,10 +259,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -346,10 +346,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -397,10 +397,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -493,10 +493,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -546,10 +546,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -651,10 +651,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -708,10 +708,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -762,10 +762,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -817,10 +817,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -868,10 +868,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -917,10 +917,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -964,10 +964,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -1009,10 +1009,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -1055,10 +1055,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/lock/table/sql/handler	32	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -256,10 +256,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -341,10 +341,10 @@ wait/io/table/sql/handler	44	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -390,10 +390,10 @@ wait/io/table/sql/handler	44	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -484,10 +484,10 @@ wait/io/table/sql/handler	81	TABLE	test
 wait/lock/table/sql/handler	42	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -535,10 +535,10 @@ wait/io/table/sql/handler	81	TABLE	test
 wait/lock/table/sql/handler	42	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -638,10 +638,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	56	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -693,10 +693,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -745,10 +745,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -798,10 +798,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -847,10 +847,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -894,10 +894,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -939,10 +939,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -982,10 +982,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -1026,10 +1026,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result	2011-04-22 03:07:02 +0000
@@ -210,10 +210,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -259,10 +259,10 @@ wait/io/table/sql/handler	17	TABLE	test
 wait/lock/table/sql/handler	14	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -346,10 +346,10 @@ wait/io/table/sql/handler	44	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -397,10 +397,10 @@ wait/io/table/sql/handler	44	TABLE	test
 wait/lock/table/sql/handler	28	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -493,10 +493,10 @@ wait/io/table/sql/handler	81	TABLE	test
 wait/lock/table/sql/handler	42	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -546,10 +546,10 @@ wait/io/table/sql/handler	81	TABLE	test
 wait/lock/table/sql/handler	42	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -651,10 +651,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	56	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -708,10 +708,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -762,10 +762,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -817,10 +817,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -868,10 +868,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -917,10 +917,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -964,10 +964,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -1009,10 +1009,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -1055,10 +1055,10 @@ wait/io/table/sql/handler	128	TABLE	test
 wait/lock/table/sql/handler	60	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result	2011-04-22 03:07:02 +0000
@@ -207,10 +207,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -250,10 +250,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -331,10 +331,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -376,10 +376,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -466,10 +466,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -513,10 +513,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -612,10 +612,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -663,10 +663,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -711,10 +711,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -760,10 +760,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -805,10 +805,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -848,10 +848,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -889,10 +889,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -928,10 +928,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -968,10 +968,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result	2011-04-22 03:07:02 +0000
@@ -206,10 +206,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -249,10 +249,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -330,10 +330,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -375,10 +375,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -465,10 +465,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -512,10 +512,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -611,10 +611,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -662,10 +662,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -710,10 +710,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -759,10 +759,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -804,10 +804,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -847,10 +847,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -888,10 +888,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -927,10 +927,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -967,10 +967,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result	2011-04-22 03:07:02 +0000
@@ -207,10 +207,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -250,10 +250,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -331,10 +331,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -376,10 +376,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -466,10 +466,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -513,10 +513,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -612,10 +612,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -663,10 +663,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -711,10 +711,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -760,10 +760,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -805,10 +805,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -848,10 +848,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -889,10 +889,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -928,10 +928,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -968,10 +968,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result	2011-04-22 03:07:02 +0000
@@ -206,10 +206,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -249,10 +249,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -330,10 +330,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -375,10 +375,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -465,10 +465,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -512,10 +512,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -611,10 +611,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -662,10 +662,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -710,10 +710,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -759,10 +759,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -804,10 +804,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -847,10 +847,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -888,10 +888,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -927,10 +927,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -967,10 +967,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -252,10 +252,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -333,10 +333,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -378,10 +378,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -468,10 +468,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -515,10 +515,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -614,10 +614,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -665,10 +665,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -713,10 +713,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -762,10 +762,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -807,10 +807,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -850,10 +850,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -891,10 +891,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -930,10 +930,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -970,10 +970,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result	2011-04-22 03:07:02 +0000
@@ -208,10 +208,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -251,10 +251,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -332,10 +332,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -377,10 +377,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -467,10 +467,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -514,10 +514,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -613,10 +613,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -664,10 +664,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -712,10 +712,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -761,10 +761,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -806,10 +806,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -849,10 +849,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -890,10 +890,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -929,10 +929,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -969,10 +969,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -252,10 +252,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -333,10 +333,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -378,10 +378,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -468,10 +468,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -515,10 +515,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -614,10 +614,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -665,10 +665,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -713,10 +713,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -762,10 +762,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -807,10 +807,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -850,10 +850,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -891,10 +891,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -930,10 +930,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -970,10 +970,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result	2011-04-22 03:07:02 +0000
@@ -208,10 +208,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -251,10 +251,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -332,10 +332,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -377,10 +377,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -467,10 +467,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -514,10 +514,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -613,10 +613,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -664,10 +664,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -712,10 +712,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -761,10 +761,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -806,10 +806,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -849,10 +849,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -890,10 +890,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -929,10 +929,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -969,10 +969,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ wait/io/table/sql/handler	8	TABLE	test	t
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -254,10 +254,10 @@ wait/io/table/sql/handler	8	TABLE	test	t
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -337,10 +337,10 @@ wait/io/table/sql/handler	8	TABLE	test	t
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -384,10 +384,10 @@ wait/io/table/sql/handler	8	TABLE	test	t
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -476,10 +476,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -525,10 +525,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -626,10 +626,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -679,10 +679,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -729,10 +729,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -780,10 +780,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -827,10 +827,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -872,10 +872,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -915,10 +915,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -956,10 +956,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -998,10 +998,10 @@ wait/io/table/sql/handler	23	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ wait/io/table/sql/handler	12	TABLE	test
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -255,10 +255,10 @@ wait/io/table/sql/handler	12	TABLE	test
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -339,10 +339,10 @@ wait/io/table/sql/handler	12	TABLE	test
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -387,10 +387,10 @@ wait/io/table/sql/handler	12	TABLE	test
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -480,10 +480,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -530,10 +530,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -632,10 +632,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -686,10 +686,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -737,10 +737,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -789,10 +789,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -837,10 +837,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -883,10 +883,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -927,10 +927,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -969,10 +969,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -1012,10 +1012,10 @@ wait/io/table/sql/handler	36	TABLE	test
 wait/io/table/sql/handler	54	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ wait/io/table/sql/handler	8	TABLE	test	t
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -254,10 +254,10 @@ wait/io/table/sql/handler	8	TABLE	test	t
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -337,10 +337,10 @@ wait/io/table/sql/handler	20	TABLE	test
 wait/io/table/sql/handler	44	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -384,10 +384,10 @@ wait/io/table/sql/handler	20	TABLE	test
 wait/io/table/sql/handler	44	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -476,10 +476,10 @@ wait/io/table/sql/handler	35	TABLE	test
 wait/io/table/sql/handler	81	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -525,10 +525,10 @@ wait/io/table/sql/handler	35	TABLE	test
 wait/io/table/sql/handler	81	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -626,10 +626,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -679,10 +679,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -729,10 +729,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -780,10 +780,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -827,10 +827,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -872,10 +872,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -915,10 +915,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -956,10 +956,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -998,10 +998,10 @@ wait/io/table/sql/handler	53	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ wait/io/table/sql/handler	12	TABLE	test
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -255,10 +255,10 @@ wait/io/table/sql/handler	12	TABLE	test
 wait/io/table/sql/handler	17	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -339,10 +339,10 @@ wait/io/table/sql/handler	30	TABLE	test
 wait/io/table/sql/handler	44	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -387,10 +387,10 @@ wait/io/table/sql/handler	30	TABLE	test
 wait/io/table/sql/handler	44	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -480,10 +480,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/io/table/sql/handler	81	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -530,10 +530,10 @@ wait/io/table/sql/handler	54	TABLE	test
 wait/io/table/sql/handler	81	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -632,10 +632,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -686,10 +686,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -737,10 +737,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -789,10 +789,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -837,10 +837,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -883,10 +883,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -927,10 +927,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -969,10 +969,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -1012,10 +1012,10 @@ wait/io/table/sql/handler	84	TABLE	test
 wait/io/table/sql/handler	128	TABLE	test	t3
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -252,10 +252,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -333,10 +333,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -378,10 +378,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -468,10 +468,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -515,10 +515,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -614,10 +614,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -665,10 +665,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -713,10 +713,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -762,10 +762,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -807,10 +807,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -850,10 +850,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -891,10 +891,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -930,10 +930,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -970,10 +970,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result	2011-04-22 03:07:02 +0000
@@ -208,10 +208,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -251,10 +251,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -332,10 +332,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -377,10 +377,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -467,10 +467,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -514,10 +514,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -613,10 +613,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -664,10 +664,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -712,10 +712,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -761,10 +761,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -806,10 +806,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -849,10 +849,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -890,10 +890,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -929,10 +929,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -969,10 +969,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	20	12	8	12	2	6	0
+TABLE	test	t1	NULL	18	12	6	12	2	4	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	32	20	12	20	4	8	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result	2011-04-22 03:07:02 +0000
@@ -209,10 +209,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -252,10 +252,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -333,10 +333,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -378,10 +378,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -468,10 +468,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -515,10 +515,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -614,10 +614,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -665,10 +665,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -713,10 +713,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -762,10 +762,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -807,10 +807,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -850,10 +850,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -891,10 +891,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -930,10 +930,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -970,10 +970,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	0	0	0	0	0	0	0
 TABLE	test	t2	index_b	0	0	0	0	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result	2011-03-28 23:37:10 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result	2011-04-22 03:07:02 +0000
@@ -208,10 +208,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -251,10 +251,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	7	4	3	4	1	2	0
+TABLE	test	t1	NULL	6	4	2	4	1	1	0
 TABLE	test	t1	index_b	0	0	0	0	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	1	1	0	1	0	0	0
+TABLE	test	t1	PRIMARY	2	1	1	1	0	1	0
 TABLE	test	t2	NULL	10	6	4	6	2	2	0
 TABLE	test	t2	index_b	1	1	0	1	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -332,10 +332,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -377,10 +377,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	17	10	7	10	2	5	0
+TABLE	test	t1	NULL	15	10	5	10	2	3	0
 TABLE	test	t1	index_b	1	1	0	1	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	2	2	0	2	0	0	0
+TABLE	test	t1	PRIMARY	4	2	2	2	0	2	0
 TABLE	test	t2	NULL	26	16	10	16	4	6	0
 TABLE	test	t2	index_b	2	2	0	2	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -467,10 +467,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -514,10 +514,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	30	18	12	18	3	9	0
+TABLE	test	t1	NULL	27	18	9	18	3	6	0
 TABLE	test	t1	index_b	2	2	0	2	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	3	3	0	3	0	0	0
+TABLE	test	t1	PRIMARY	6	3	3	3	0	3	0
 TABLE	test	t2	NULL	48	30	18	30	6	12	0
 TABLE	test	t2	index_b	3	3	0	3	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -613,10 +613,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -664,10 +664,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -712,10 +712,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -761,10 +761,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -806,10 +806,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -849,10 +849,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -890,10 +890,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -929,10 +929,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0
@@ -969,10 +969,10 @@ execute dump_history;
 event_name	count(event_name)	object_type	object_schema	object_name
 execute dump_index_io;
 object_type	object_schema	object_name	index_name	count_star	count_read	count_write	count_fetch	count_insert	count_update	count_delete
-TABLE	test	t1	NULL	46	28	18	28	4	14	0
+TABLE	test	t1	NULL	42	28	14	28	4	10	0
 TABLE	test	t1	index_b	3	3	0	3	0	0	0
 TABLE	test	t1	index_cb	0	0	0	0	0	0	0
-TABLE	test	t1	PRIMARY	4	4	0	4	0	0	0
+TABLE	test	t1	PRIMARY	8	4	4	4	0	4	0
 TABLE	test	t2	NULL	76	48	28	48	8	20	0
 TABLE	test	t2	index_b	4	4	0	4	0	0	0
 TABLE	test	t2	index_cb	0	0	0	0	0	0	0

=== modified file 'mysql-test/suite/perfschema/t/misc.test'
--- a/mysql-test/suite/perfschema/t/misc.test	2010-12-01 18:46:51 +0000
+++ b/mysql-test/suite/perfschema/t/misc.test	2011-04-20 17:56:53 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -83,3 +83,34 @@ select * from performance_schema.file_in
 --error ER_NO_SUCH_TABLE
 select * from performance_schema.no_such_table;
 
+#
+# Bug#12370950 - 60905: TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE AGGREGATES NON-INSERT DML WRONGLY
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t_60905;
+--enable_warnings
+CREATE TABLE t_60905 (i INT, j INT, KEY(i)) ENGINE = InnoDB;
+INSERT INTO t_60905 VALUES
+(1,2), (3,4), (5,6), (7,8), (9,10);
+
+# should delete with a "single" PRIMARY lookup (2 PRIMARY fetch, 1 PRIMARY delete)
+DELETE FROM t_60905 WHERE i = 1;
+
+# should delete with a full scan (5 NULL fetch, 1 NULL delete)
+DELETE FROM t_60905 WHERE j = 8;
+
+# show the instrument data
+SELECT object_schema,
+       object_name,
+       index_name,
+       count_fetch,
+       count_insert,
+       count_update,
+       count_delete
+  FROM performance_schema.table_io_waits_summary_by_index_usage
+ WHERE object_schema = 'test'
+   AND object_name = 't_60905';
+
+DROP TABLE t_60905;
+

=== modified file 'mysql-test/suite/sys_vars/r/all_vars.result'
--- a/mysql-test/suite/sys_vars/r/all_vars.result	2011-03-11 20:47:31 +0000
+++ b/mysql-test/suite/sys_vars/r/all_vars.result	2011-04-22 03:07:02 +0000
@@ -23,6 +23,7 @@ INNODB_PRINT_ALL_DEADLOCKS
 INNODB_MONITOR_RESET_ALL
 INNODB_STATS_METHOD
 LOG_BIN_INDEX
+INNODB_SYNC_ARRAY_SIZE
 INNODB_MONITOR_DISABLE
 INNODB_FILE_FORMAT_MAX
 INNODB_MONITOR_ENABLE
@@ -37,6 +38,7 @@ INNODB_PRINT_ALL_DEADLOCKS
 INNODB_MONITOR_RESET_ALL
 INNODB_STATS_METHOD
 LOG_BIN_INDEX
+INNODB_SYNC_ARRAY_SIZE
 INNODB_MONITOR_DISABLE
 INNODB_FILE_FORMAT_MAX
 INNODB_MONITOR_ENABLE

=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test	2011-03-28 09:04:13 +0000
+++ b/mysql-test/t/func_math.test	2011-04-20 07:56:57 +0000
@@ -354,6 +354,22 @@ DROP TABLE t1;
 CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#11765923  58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
+--echo #
+
+CREATE TABLE t1(f1 DECIMAL(22,1));
+INSERT INTO t1 VALUES (0),(1);
+SELECT ROUND(f1, f1) FROM t1;
+SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11764671  57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
+--echo #
+
+SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-03-28 08:10:39 +0000
+++ b/sql/handler.cc	2011-04-18 23:41:45 +0000
@@ -5982,7 +5982,7 @@ int handler::ha_update_row(const uchar *
   mark_trx_read_write();
 
   MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
-                            PSI_TABLE_UPDATE_ROW, MAX_KEY, 0);
+                            PSI_TABLE_UPDATE_ROW, active_index, 0);
 
   error= update_row(old_data, new_data);
 
@@ -6007,7 +6007,7 @@ int handler::ha_delete_row(const uchar *
   mark_trx_read_write();
 
   MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
-                            PSI_TABLE_DELETE_ROW, MAX_KEY, 0);
+                            PSI_TABLE_DELETE_ROW, active_index, 0);
 
   error= delete_row(buf);
 

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-04-15 09:04:21 +0000
+++ b/sql/item_func.cc	2011-04-20 07:56:57 +0000
@@ -2420,10 +2420,7 @@ my_decimal *Item_func_round::decimal_op(
   if (!(null_value= (args[0]->null_value || args[1]->null_value ||
                      my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
                                       truncate, decimal_value) > 1))) 
-  {
-    decimal_value->frac= decimals;
     return decimal_value;
-  }
   return 0;
 }
 

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2011-03-28 20:15:26 +0000
+++ b/sql/mysqld.h	2011-04-22 03:07:02 +0000
@@ -389,6 +389,7 @@ extern PSI_stage_info stage_waiting_for_
 extern PSI_stage_info stage_waiting_to_finalize_termination;
 extern PSI_stage_info stage_waiting_to_get_readlock;
 
+#ifdef HAVE_PSI_INTERFACE
 /**
   Statement instrumentation keys (sql).
   The last entry, at [SQLCOM_END], is for parsing errors.
@@ -403,6 +404,7 @@ extern PSI_statement_info com_statement_
 
 void init_sql_statement_info();
 void init_com_statement_info();
+#endif /* HAVE_PSI_INTERFACE */
 
 #ifndef __WIN__
 extern pthread_t signal_thread;

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-04-15 12:14:35 +0000
+++ b/sql/sql_class.cc	2011-04-21 05:36:23 +0000
@@ -3860,6 +3860,7 @@ bool xid_cache_insert(XID *xid, enum xa_
     xs->xa_state=xa_state;
     xs->xid.set(xid);
     xs->in_thd=0;
+    xs->rm_error=0;
     res=my_hash_insert(&xid_cache, (uchar*)xs);
   }
   mysql_mutex_unlock(&LOCK_xid_cache);

=== modified file 'storage/innobase/CMakeLists.txt'
--- a/storage/innobase/CMakeLists.txt	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/CMakeLists.txt	2011-04-18 02:17:16 +0000
@@ -220,39 +220,102 @@ IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8
 				    PROPERTIES COMPILE_FLAGS -Od)
 ENDIF()
 
-SET(INNOBASE_SOURCES	btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
-			buf/buf0buddy.c buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c
-			data/data0data.c data/data0type.c
-			dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c dict/dict0load.c dict/dict0mem.c dict/dict0stats.c
-			dyn/dyn0dyn.c
-			eval/eval0eval.c eval/eval0proc.c
-			fil/fil0fil.c
-			fsp/fsp0fsp.c
-			fut/fut0fut.c fut/fut0lst.c
-			ha/ha0ha.c ha/hash0hash.c ha/ha0storage.c
-			ibuf/ibuf0ibuf.c
-			pars/lexyy.c pars/pars0grm.c pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c
-			lock/lock0lock.c lock/lock0iter.c lock/lock0wait.c
-			log/log0log.c log/log0recv.c
-			mach/mach0data.c
-			mem/mem0mem.c mem/mem0pool.c
-			mtr/mtr0log.c mtr/mtr0mtr.c
-			os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c
-			page/page0cur.c page/page0page.c page/page0zip.c
-			que/que0que.c
-			handler/ha_innodb.cc handler/handler0alter.cc handler/i_s.cc
-			read/read0read.c
-			rem/rem0cmp.c rem/rem0rec.c
-			row/row0ext.c row/row0ins.c row/row0merge.c row/row0mysql.c row/row0purge.c row/row0row.c
-			row/row0sel.c row/row0uins.c row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c
-			srv/srv0mon.c srv/srv0srv.c srv/srv0start.c
-			sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c
-			trx/trx0i_s.c trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c
-			trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c
-			usr/usr0sess.c
-			ut/ut0byte.c ut/ut0dbg.c ut/ut0list.c ut/ut0mem.c
-		       	ut/ut0rbt.c ut/ut0bh.c ut/ut0rnd.c
-			ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c)
+SET(INNOBASE_SOURCES
+	btr/btr0btr.c
+	btr/btr0cur.c
+	btr/btr0pcur.c
+	btr/btr0sea.c
+	buf/buf0buddy.c
+	buf/buf0buf.c
+	buf/buf0flu.c
+	buf/buf0lru.c
+	buf/buf0rea.c
+	data/data0data.c
+	data/data0type.c
+	dict/dict0boot.c
+	dict/dict0crea.c
+	dict/dict0dict.c
+	dict/dict0load.c
+	dict/dict0mem.c
+	dict/dict0stats.c
+	dyn/dyn0dyn.c
+	eval/eval0eval.c
+	eval/eval0proc.c
+	fil/fil0fil.c
+	fsp/fsp0fsp.c
+	fut/fut0fut.c
+	fut/fut0lst.c
+	ha/ha0ha.c
+	ha/ha0storage.c
+	ha/hash0hash.c
+	handler/ha_innodb.cc
+	handler/handler0alter.cc
+	handler/i_s.cc
+	ibuf/ibuf0ibuf.c
+	lock/lock0iter.c
+	lock/lock0lock.c
+	lock/lock0wait.c
+	log/log0log.c
+	log/log0recv.c
+	mach/mach0data.c
+	mem/mem0mem.c
+	mem/mem0pool.c
+	mtr/mtr0log.c
+	mtr/mtr0mtr.c
+	os/os0file.c
+	os/os0proc.c
+	os/os0sync.c
+	os/os0thread.c
+	page/page0cur.c
+	page/page0page.c
+	page/page0zip.c
+	pars/lexyy.c
+	pars/pars0grm.c
+	pars/pars0opt.c
+	pars/pars0pars.c
+	pars/pars0sym.c
+	que/que0que.c
+	read/read0read.c
+	rem/rem0cmp.c
+	rem/rem0rec.c
+	row/row0ext.c
+	row/row0ins.c
+	row/row0merge.c
+	row/row0mysql.c
+	row/row0purge.c
+	row/row0row.c
+	row/row0sel.c
+	row/row0uins.c
+	row/row0umod.c
+	row/row0undo.c
+	row/row0upd.c
+	row/row0vers.c
+	srv/srv0conc.c
+	srv/srv0mon.c
+	srv/srv0srv.c
+	srv/srv0start.c
+	sync/sync0arr.c
+	sync/sync0rw.c
+	sync/sync0sync.c
+	trx/trx0i_s.c
+	trx/trx0purge.c
+	trx/trx0rec.c
+	trx/trx0roll.c
+	trx/trx0rseg.c
+	trx/trx0sys.c
+	trx/trx0trx.c
+	trx/trx0undo.c
+	usr/usr0sess.c
+	ut/ut0bh.c
+	ut/ut0byte.c
+	ut/ut0dbg.c
+	ut/ut0list.c
+	ut/ut0mem.c
+	ut/ut0rbt.c
+	ut/ut0rnd.c
+	ut/ut0ut.c
+	ut/ut0vec.c
+	ut/ut0wqueue.c)
 
 IF(WITH_INNODB)
   # Legacy option

=== modified file 'storage/innobase/btr/btr0btr.c'
--- a/storage/innobase/btr/btr0btr.c	2011-02-08 12:16:14 +0000
+++ b/storage/innobase/btr/btr0btr.c	2011-04-13 08:34:16 +0000
@@ -1515,7 +1515,9 @@ btr_page_reorganize_low(
 	dict_index_t*	index,	/*!< in: record descriptor */
 	mtr_t*		mtr)	/*!< in: mtr */
 {
+#ifndef UNIV_HOTBACKUP
 	buf_pool_t*	buf_pool	= buf_pool_from_bpage(&block->page);
+#endif /* !UNIV_HOTBACKUP */
 	page_t*		page		= buf_block_get_frame(block);
 	page_zip_des_t*	page_zip	= buf_block_get_page_zip(block);
 	buf_block_t*	temp_block;

=== modified file 'storage/innobase/btr/btr0cur.c'
--- a/storage/innobase/btr/btr0cur.c	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/btr/btr0cur.c	2011-04-20 10:47:27 +0000
@@ -1105,29 +1105,27 @@ btr_cur_ins_lock_and_undo(
 					     btr_cur_get_block(cursor),
 					     index, thr, mtr, inherit);
 
-	if (err != DB_SUCCESS) {
+	if (err != DB_SUCCESS
+	    || !dict_index_is_clust(index) || dict_index_is_ibuf(index)) {
 
 		return(err);
 	}
 
-	if (dict_index_is_clust(index) && !dict_index_is_ibuf(index)) {
-
-		err = trx_undo_report_row_operation(flags, TRX_UNDO_INSERT_OP,
-						    thr, index, entry,
-						    NULL, 0, NULL,
-						    &roll_ptr);
-		if (err != DB_SUCCESS) {
+	err = trx_undo_report_row_operation(flags, TRX_UNDO_INSERT_OP,
+					    thr, index, entry,
+					    NULL, 0, NULL,
+					    &roll_ptr);
+	if (err != DB_SUCCESS) {
 
-			return(err);
-		}
+		return(err);
+	}
 
-		/* Now we can fill in the roll ptr field in entry */
+	/* Now we can fill in the roll ptr field in entry */
 
-		if (!(flags & BTR_KEEP_SYS_FLAG)) {
+	if (!(flags & BTR_KEEP_SYS_FLAG)) {
 
-			row_upd_index_entry_sys_field(entry, index,
-						      DATA_ROLL_PTR, roll_ptr);
-		}
+		row_upd_index_entry_sys_field(entry, index,
+					      DATA_ROLL_PTR, roll_ptr);
 	}
 
 	return(DB_SUCCESS);
@@ -1920,8 +1918,8 @@ btr_cur_update_in_place(
 				    trx, roll_ptr, mtr);
 
 	if (was_delete_marked
-	    && !rec_get_deleted_flag(rec, page_is_comp(
-					     buf_block_get_frame(block)))) {
+	    && !rec_get_deleted_flag(
+		    rec, page_is_comp(buf_block_get_frame(block)))) {
 		/* The new updated record owns its possible externally
 		stored fields */
 
@@ -2429,8 +2427,8 @@ make_external:
 	record on its page? */
 	was_first = page_cur_is_before_first(page_cursor);
 
-	/* The first parameter means that no lock checking and undo logging
-	is made in the insert */
+	/* Lock checks and undo logging were already performed by
+	btr_cur_upd_lock_and_undo(). */
 
 	err = btr_cur_pessimistic_insert(BTR_NO_UNDO_LOG_FLAG
 					 | BTR_NO_LOCKING_FLAG
@@ -3264,9 +3262,14 @@ btr_estimate_n_rows_in_range_on_level(
 
 		mtr_start(&mtr);
 
-		/* fetch the page */
-		block = buf_page_get(space, zip_size, page_no, RW_S_LATCH,
-				     &mtr);
+		/* Fetch the page. Because we are not holding the
+		index->lock, the tree may have changed and we may be
+		attempting to read a page that is no longer part of
+		the B-tree. We pass BUF_GET_POSSIBLY_FREED in order to
+		silence a debug assertion about this. */
+		block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH,
+					 NULL, BUF_GET_POSSIBLY_FREED,
+					 __FILE__, __LINE__, &mtr);
 
 		page = buf_block_get_frame(block);
 
@@ -3285,6 +3288,13 @@ btr_estimate_n_rows_in_range_on_level(
 			goto inexact;
 		}
 
+		/* It is possible but highly unlikely that the page was
+		originally written by an old version of InnoDB that did
+		not initialize FIL_PAGE_TYPE on other than B-tree pages.
+		For example, this could be an almost-empty BLOB page
+		that happens to contain the magic values in the fields
+		that we checked above. */
+
 		n_pages_read++;
 
 		if (page_no != slot1->page_no) {

=== modified file 'storage/innobase/buf/buf0buf.c'
--- a/storage/innobase/buf/buf0buf.c	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/buf/buf0buf.c	2011-04-13 08:34:16 +0000
@@ -294,7 +294,6 @@ be effective only if PFS_GROUP_BUFFER_SY
 
 # endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */
 #endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
-#endif /* !UNIV_HOTBACKUP */
 
 /** Macro to determine whether the read of write counter is used depending
 on the io_type */
@@ -445,6 +444,7 @@ buf_block_alloc(
 
 	return(block);
 }
+#endif /* !UNIV_HOTBACKUP */
 
 /********************************************************************//**
 Calculates a page checksum which is stored to the page when it is written
@@ -1239,7 +1239,7 @@ buf_pool_init_instance(
 		buf_pool->curr_size = chunk->size;
 		buf_pool->curr_pool_size = buf_pool->curr_size * UNIV_PAGE_SIZE;
 
-		/* Number of locks portecting page_hash must be a
+		/* Number of locks protecting page_hash must be a
 		power of two */
 		srv_n_page_hash_locks =
 				 ut_2_power_up(srv_n_page_hash_locks);
@@ -2366,11 +2366,14 @@ buf_page_set_file_page_was_freed(
 					   &hash_lock);
 
 	if (bpage) {
+		mutex_t*	block_mutex = buf_page_get_mutex(bpage);
 		ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage));
+		mutex_enter(block_mutex);
+		rw_lock_s_unlock(hash_lock);
 		/* bpage->file_page_was_freed can already hold
 		when this code is invoked from dict_drop_index_tree() */
 		bpage->file_page_was_freed = TRUE;
-		rw_lock_s_unlock(hash_lock);
+		mutex_exit(block_mutex);
 	}
 
 	return(bpage);
@@ -2396,9 +2399,12 @@ buf_page_reset_file_page_was_freed(
 	bpage = buf_page_hash_get_s_locked(buf_pool, space, offset,
 					   &hash_lock);
 	if (bpage) {
+		mutex_t*	block_mutex = buf_page_get_mutex(bpage);
 		ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage));
-		bpage->file_page_was_freed = FALSE;
+		mutex_enter(block_mutex);
 		rw_lock_s_unlock(hash_lock);
+		bpage->file_page_was_freed = FALSE;
+		mutex_exit(block_mutex);
 	}
 
 	return(bpage);
@@ -2534,13 +2540,12 @@ got_block:
 	access_time = buf_page_is_accessed(bpage);
 
 	rw_lock_s_unlock(hash_lock);
-	mutex_exit(block_mutex);
-
-	buf_page_set_accessed_make_young(bpage, access_time);
-
 #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	ut_a(!bpage->file_page_was_freed);
 #endif
+	mutex_exit(block_mutex);
+
+	buf_page_set_accessed_make_young(bpage, access_time);
 
 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 	ut_a(++buf_dbg_counter % 5771 || buf_validate());
@@ -2897,6 +2902,7 @@ buf_page_get_gen(
 	case BUF_GET_IF_IN_POOL:
 	case BUF_PEEK_IF_IN_POOL:
 	case BUF_GET_IF_IN_POOL_OR_WATCH:
+	case BUF_GET_POSSIBLY_FREED:
 		break;
 	default:
 		ut_error;
@@ -3279,7 +3285,10 @@ wait_until_unfixed:
 #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
 
 	buf_block_buf_fix_inc(block, file, line);
-
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
+	ut_a(mode == BUF_GET_POSSIBLY_FREED
+	     || !block->page.file_page_was_freed);
+#endif
 	mutex_exit(&block->mutex);
 
 	/* Check if this is the first access to the page */
@@ -3290,10 +3299,6 @@ wait_until_unfixed:
 		buf_page_set_accessed_make_young(&block->page, access_time);
 	}
 
-#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
-	ut_a(!block->page.file_page_was_freed);
-#endif
-
 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 	ut_a(++buf_dbg_counter % 5771 || buf_validate());
 	ut_a(block->page.buf_fix_count > 0);
@@ -3370,8 +3375,7 @@ buf_page_optimistic_get(
 /*====================*/
 	ulint		rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH */
 	buf_block_t*	block,	/*!< in: guessed buffer block */
-	ib_uint64_t	modify_clock,/*!< in: modify clock value if mode is
-				..._GUESS_ON_CLOCK */
+	ib_uint64_t	modify_clock,/*!< in: modify clock value */
 	const char*	file,	/*!< in: file name */
 	ulint		line,	/*!< in: line where called */
 	mtr_t*		mtr)	/*!< in: mini-transaction */
@@ -3455,8 +3459,11 @@ buf_page_optimistic_get(
 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
 
 #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
-	ut_a(block->page.file_page_was_freed == FALSE);
+	mutex_enter(&block->mutex);
+	ut_a(!block->page.file_page_was_freed);
+	mutex_exit(&block->mutex);
 #endif
+
 	if (UNIV_UNLIKELY(!access_time)) {
 		/* In the case of a first access, try to apply linear
 		read-ahead */
@@ -3568,7 +3575,9 @@ buf_page_get_known_nowait(
 	ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
 #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
-	ut_a(block->page.file_page_was_freed == FALSE);
+	mutex_enter(&block->mutex);
+	ut_a(!block->page.file_page_was_freed);
+	mutex_exit(&block->mutex);
 #endif
 
 #ifdef UNIV_IBUF_COUNT_DEBUG
@@ -3657,7 +3666,9 @@ buf_page_try_get_func(
 	ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
 #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
 #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
-	ut_a(block->page.file_page_was_freed == FALSE);
+	mutex_enter(&block->mutex);
+	ut_a(!block->page.file_page_was_freed);
+	mutex_exit(&block->mutex);
 #endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 	buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
 

=== modified file 'storage/innobase/buf/buf0flu.c'
--- a/storage/innobase/buf/buf0flu.c	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/buf/buf0flu.c	2011-04-05 11:12:48 +0000
@@ -1744,7 +1744,7 @@ buf_flush_batch(
 	ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad((flush_type != BUF_FLUSH_LIST)
-	      || sync_thread_levels_empty_gen(TRUE));
+	      || sync_thread_levels_empty_except_dict());
 #endif /* UNIV_SYNC_DEBUG */
 
 	buf_pool_mutex_enter(buf_pool);

=== modified file 'storage/innobase/buf/buf0lru.c'
--- a/storage/innobase/buf/buf0lru.c	2011-02-28 14:02:27 +0000
+++ b/storage/innobase/buf/buf0lru.c	2011-04-13 08:34:16 +0000
@@ -25,6 +25,7 @@ Created 11/5/1995 Heikki Tuuri
 
 #include "buf0lru.h"
 
+#ifndef UNIV_HOTBACKUP
 #ifdef UNIV_NONINL
 #include "buf0lru.ic"
 #endif
@@ -2390,3 +2391,4 @@ buf_LRU_print(void)
 	}
 }
 #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
+#endif /* !UNIV_HOTBACKUP */

=== modified file 'storage/innobase/dict/dict0crea.c'
--- a/storage/innobase/dict/dict0crea.c	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/dict/dict0crea.c	2011-04-08 18:42:14 +0000
@@ -75,6 +75,7 @@ dict_create_sys_tables_tuple(
 	dfield = dtuple_get_nth_field(entry, 0/*NAME*/);
 
 	dfield_set_data(dfield, table->name, ut_strlen(table->name));
+
 	/* 3: ID -------------------------------*/
 	dfield = dtuple_get_nth_field(entry, 1/*ID*/);
 
@@ -82,6 +83,7 @@ dict_create_sys_tables_tuple(
 	mach_write_to_8(ptr, table->id);
 
 	dfield_set_data(dfield, ptr, 8);
+
 	/* 4: N_COLS ---------------------------*/
 	dfield = dtuple_get_nth_field(entry, 2/*N_COLS*/);
 
@@ -93,7 +95,8 @@ dict_create_sys_tables_tuple(
 	mach_write_to_4(ptr, table->n_def
 			| ((table->flags & DICT_TF_COMPACT) << 31));
 	dfield_set_data(dfield, ptr, 4);
-	/* 5: TYPE -----------------------------*/
+
+	/* 5: TYPE (table flags) -----------------------------*/
 	dfield = dtuple_get_nth_field(entry, 3/*TYPE*/);
 
 	ptr = mem_heap_alloc(heap, 4);
@@ -109,14 +112,15 @@ dict_create_sys_tables_tuple(
 	}
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/* 6: MIX_ID (obsolete) ---------------------------*/
 	dfield = dtuple_get_nth_field(entry, 4/*MIX_ID*/);
 
 	ptr = mem_heap_zalloc(heap, 8);
 
 	dfield_set_data(dfield, ptr, 8);
-	/* 7: MIX_LEN (additional flags) --------------------------*/
 
+	/* 7: MIX_LEN (additional flags) --------------------------*/
 	dfield = dtuple_get_nth_field(entry, 5/*MIX_LEN*/);
 
 	ptr = mem_heap_alloc(heap, 4);
@@ -125,6 +129,7 @@ dict_create_sys_tables_tuple(
 	mach_write_to_4(ptr, table->flags2);
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/* 8: CLUSTER_NAME ---------------------*/
 	dfield = dtuple_get_nth_field(entry, 6/*CLUSTER_NAME*/);
 	dfield_set_null(dfield); /* not supported */
@@ -381,6 +386,7 @@ dict_create_sys_indexes_tuple(
 	mach_write_to_8(ptr, table->id);
 
 	dfield_set_data(dfield, ptr, 8);
+
 	/* 1: ID ----------------------------*/
 	dfield = dtuple_get_nth_field(entry, 1/*ID*/);
 
@@ -388,10 +394,12 @@ dict_create_sys_indexes_tuple(
 	mach_write_to_8(ptr, index->id);
 
 	dfield_set_data(dfield, ptr, 8);
+
 	/* 4: NAME --------------------------*/
 	dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
 
 	dfield_set_data(dfield, index->name, ut_strlen(index->name));
+
 	/* 5: N_FIELDS ----------------------*/
 	dfield = dtuple_get_nth_field(entry, 3/*N_FIELDS*/);
 
@@ -399,6 +407,7 @@ dict_create_sys_indexes_tuple(
 	mach_write_to_4(ptr, index->n_fields);
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/* 6: TYPE --------------------------*/
 	dfield = dtuple_get_nth_field(entry, 4/*TYPE*/);
 
@@ -406,6 +415,7 @@ dict_create_sys_indexes_tuple(
 	mach_write_to_4(ptr, index->type);
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/* 7: SPACE --------------------------*/
 
 #if DICT_SYS_INDEXES_SPACE_NO_FIELD != 7
@@ -418,6 +428,7 @@ dict_create_sys_indexes_tuple(
 	mach_write_to_4(ptr, index->space);
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/* 8: PAGE_NO --------------------------*/
 
 #if DICT_SYS_INDEXES_PAGE_NO_FIELD != 8
@@ -430,6 +441,7 @@ dict_create_sys_indexes_tuple(
 	mach_write_to_4(ptr, FIL_NULL);
 
 	dfield_set_data(dfield, ptr, 4);
+
 	/*--------------------------------*/
 
 	return(entry);

=== modified file 'storage/innobase/dict/dict0dict.c'
--- a/storage/innobase/dict/dict0dict.c	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/dict/dict0dict.c	2011-04-13 08:34:16 +0000
@@ -5111,6 +5111,7 @@ dict_ind_init(void)
 	dict_ind_redundant->cached = dict_ind_compact->cached = TRUE;
 }
 
+#ifndef UNIV_HOTBACKUP
 /**********************************************************************//**
 Frees dict_ind_redundant and dict_ind_compact. */
 static
@@ -5131,7 +5132,6 @@ dict_ind_free(void)
 	dict_mem_table_free(table);
 }
 
-#ifndef UNIV_HOTBACKUP
 /**********************************************************************//**
 Get index by name
 @return	index, NULL if does not exist */

=== modified file 'storage/innobase/dict/dict0load.c'
--- a/storage/innobase/dict/dict0load.c	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/dict/dict0load.c	2011-04-14 13:41:47 +0000
@@ -1792,7 +1792,8 @@ err_exit:
 #endif /* 0 */
 	mem_heap_free(heap);
 
-	ut_ad(ignore_err != DICT_ERR_IGNORE_NONE || table->corrupted == FALSE);
+	ut_ad(!table || ignore_err != DICT_ERR_IGNORE_NONE
+	      || !table->corrupted);
 
 	return(table);
 }

=== modified file 'storage/innobase/dict/dict0mem.c'
--- a/storage/innobase/dict/dict0mem.c	2011-03-18 15:48:14 +0000
+++ b/storage/innobase/dict/dict0mem.c	2011-04-13 08:34:16 +0000
@@ -34,8 +34,8 @@ Created 1/8/1996 Heikki Tuuri
 #include "mach0data.h"
 #include "dict0dict.h"
 #include "srv0srv.h" /* srv_lower_case_table_names */
-#include "ha_prototypes.h" /* innobase_casedn_str()*/
 #ifndef UNIV_HOTBACKUP
+# include "ha_prototypes.h" /* innobase_casedn_str()*/
 # include "lock0lock.h"
 #endif /* !UNIV_HOTBACKUP */
 #ifdef UNIV_BLOB_DEBUG
@@ -275,6 +275,7 @@ dict_mem_index_create(
 	return(index);
 }
 
+#ifndef UNIV_HOTBACKUP
 /**********************************************************************//**
 Creates and initializes a foreign constraint memory object.
 @return	own: foreign constraint struct */
@@ -348,6 +349,7 @@ dict_mem_referenced_table_name_lookup_se
 			= foreign->referenced_table_name;
 	}
 }
+#endif /* !UNIV_HOTBACKUP */
 
 /**********************************************************************//**
 Adds a field definition to an index. NOTE: does not take a copy

=== modified file 'storage/innobase/dict/dict0stats.c'
--- a/storage/innobase/dict/dict0stats.c	2011-03-18 12:49:38 +0000
+++ b/storage/innobase/dict/dict0stats.c	2011-04-04 14:19:29 +0000
@@ -44,7 +44,7 @@ Created Jan 06, 2010 Vasil Dimov
 #include "row0sel.h" /* sel_node_struct */
 #include "row0types.h" /* sel_node_t */
 #include "trx0trx.h" /* trx_create() */
-#include "trx0roll.h" /* trx_rollback_for_mysql() */
+#include "trx0roll.h" /* trx_rollback_to_savepoint() */
 #include "usr0types.h" /* sess_t */
 #include "ut0rnd.h" /* ut_rnd_interval() */
 
@@ -1659,7 +1659,10 @@ dict_stats_save(
 
 end_rollback:
 
-	trx_rollback_for_mysql(trx);
+	trx->op_info = "rollback of internal transaction on stats tables";
+	trx_rollback_to_savepoint(trx, NULL);
+	trx->op_info = "";
+	ut_a(trx->error_state == DB_SUCCESS);
 
 end_free:
 

=== modified file 'storage/innobase/fil/fil0fil.c'
--- a/storage/innobase/fil/fil0fil.c	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/fil/fil0fil.c	2011-04-08 18:42:14 +0000
@@ -3346,7 +3346,7 @@ fil_load_single_table_tablespace(
 		return;
 	}
 #endif
-	/* Read the first page of the tablespace if the size big enough */
+	/* Read the first page of the tablespace if the size is big enough */
 
 	buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
 	/* Align the memory for file i/o if we might have O_DIRECT set */
@@ -4524,8 +4524,8 @@ fil_aio_wait(
 		ret = os_aio_linux_handle(segment, &fil_node,
 					  &message, &type);
 #else
-		ret = 0; /* Eliminate compiler warning */
 		ut_error;
+		ret = 0; /* Eliminate compiler warning */
 #endif
 	} else {
 		srv_set_io_thread_op_info(segment, "simulated aio handle");
@@ -4535,6 +4535,10 @@ fil_aio_wait(
 	}
 
 	ut_a(ret);
+	if (UNIV_UNLIKELY(fil_node == NULL)) {
+		ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS);
+		return;
+	}
 
 	srv_set_io_thread_op_info(segment, "complete io for fil node");
 

=== modified file 'storage/innobase/fsp/fsp0fsp.c'
--- a/storage/innobase/fsp/fsp0fsp.c	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/fsp/fsp0fsp.c	2011-04-06 11:07:44 +0000
@@ -1097,38 +1097,6 @@ fsp_header_inc_size(
 }
 
 /**********************************************************************//**
-Gets the current free limit of the system tablespace.  The free limit
-means the place of the first page which has never been put to the
-free list for allocation.  The space above that address is initialized
-to zero.  Sets also the global variable log_fsp_current_free_limit.
-@return	free limit in megabytes */
-UNIV_INTERN
-ulint
-fsp_header_get_free_limit(void)
-/*===========================*/
-{
-	fsp_header_t*	header;
-	ulint		limit;
-	mtr_t		mtr;
-
-	mtr_start(&mtr);
-
-	mtr_x_lock(fil_space_get_latch(0, NULL), &mtr);
-
-	header = fsp_get_space_header(0, 0, &mtr);
-
-	limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, &mtr);
-
-	limit /= ((1024 * 1024) / UNIV_PAGE_SIZE);
-
-	log_fsp_current_free_limit_set_and_checkpoint(limit);
-
-	mtr_commit(&mtr);
-
-	return(limit);
-}
-
-/**********************************************************************//**
 Gets the size of the system tablespace from the tablespace header.  If
 we do not have an auto-extending data file, this should be equal to
 the size of the data files.  If there is an auto-extending data file,
@@ -1395,15 +1363,6 @@ fsp_fill_free_list(
 		mlog_write_ulint(header + FSP_FREE_LIMIT, i + FSP_EXTENT_SIZE,
 				 MLOG_4BYTES, mtr);
 
-		/* Update the free limit info in the log system and make
-		a checkpoint */
-		if (space == 0) {
-			ut_a(!zip_size);
-			log_fsp_current_free_limit_set_and_checkpoint(
-				(i + FSP_EXTENT_SIZE)
-				/ ((1024 * 1024) / UNIV_PAGE_SIZE));
-		}
-
 		if (UNIV_UNLIKELY(init_xdes)) {
 
 			buf_block_t*	block;

=== modified file 'storage/innobase/ha/ha0ha.c'
--- a/storage/innobase/ha/ha0ha.c	2011-02-17 14:06:09 +0000
+++ b/storage/innobase/ha/ha0ha.c	2011-04-13 08:34:16 +0000
@@ -31,7 +31,9 @@ Created 8/22/1994 Heikki Tuuri
 #ifdef UNIV_DEBUG
 # include "buf0buf.h"
 #endif /* UNIV_DEBUG */
-#include "btr0sea.h"
+#ifndef UNIV_HOTBACKUP
+# include "btr0sea.h"
+#endif /* !UNIV_HOTBACKUP */
 #include "page0page.h"
 
 /*************************************************************//**
@@ -223,12 +225,14 @@ ha_insert_for_fold_func(
 		prev_node = prev_node->next;
 	}
 
+#ifndef UNIV_HOTBACKUP
 	/* We are in the process of disabling hash index, do not add
 	new chain node */
 	if (!btr_search_enabled) {
 		ut_ad(!btr_search_fully_disabled);
 		return(TRUE);
 	}
+#endif /* !UNIV_HOTBACKUP */
 
 	/* We have to allocate a new chain node */
 

=== modified file 'storage/innobase/ha/hash0hash.c'
--- a/storage/innobase/ha/hash0hash.c	2010-12-08 15:30:01 +0000
+++ b/storage/innobase/ha/hash0hash.c	2011-04-11 15:55:35 +0000
@@ -34,9 +34,11 @@ Created 5/20/1997 Heikki Tuuri
 
 # ifdef UNIV_PFS_MUTEX
 UNIV_INTERN mysql_pfs_key_t	hash_table_mutex_key;
-UNIV_INTERN mysql_pfs_key_t	hash_table_rw_lock_key;
 # endif /* UNIV_PFS_MUTEX */
 
+# ifdef UNIV_PFS_RWLOCK
+UNIV_INTERN mysql_pfs_key_t	hash_table_rw_lock_key;
+# endif /* UNIV_PFS_RWLOCK */
 /************************************************************//**
 Reserves the mutex for a fold value in a hash table. */
 UNIV_INTERN

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2011-04-13 18:43:08 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2011-04-21 05:36:23 +0000
@@ -278,7 +278,6 @@ static PSI_mutex_info all_innodb_mutexes
 	{&srv_innodb_monitor_mutex_key, "srv_innodb_monitor_mutex", 0},
 	{&srv_misc_tmpfile_mutex_key, "srv_misc_tmpfile_mutex", 0},
 	{&srv_monitor_file_mutex_key, "srv_monitor_file_mutex", 0},
-	{&syn_arr_mutex_key, "syn_arr_mutex", 0},
 #  ifdef UNIV_SYNC_DEBUG
 	{&sync_thread_mutex_key, "sync_thread_mutex", 0},
 #  endif /* UNIV_SYNC_DEBUG */
@@ -323,7 +322,8 @@ static PSI_rwlock_info all_innodb_rwlock
 	{&trx_purge_latch_key, "trx_purge_latch", 0},
 	{&index_tree_rw_lock_key, "index_tree_rw_lock", 0},
 	{&trx_sys_rw_lock_key, "trx_sys_lock", 0},
-	{&dict_table_stats_latch_key, "dict_table_stats", 0}
+	{&dict_table_stats_latch_key, "dict_table_stats", 0},
+	{&hash_table_rw_lock_key, "hash table locks", 0}
 };
 # endif /* UNIV_PFS_RWLOCK */
 
@@ -6679,10 +6679,6 @@ create_table_def(
 	DBUG_PRINT("enter", ("table_name: %s", table_name));
 
 	ut_a(trx->mysql_thd != NULL);
-	if (IS_MAGIC_TABLE_AND_USER_DENIED_ACCESS(table_name,
-						  (THD*) trx->mysql_thd)) {
-		DBUG_RETURN(HA_ERR_GENERIC);
-	}
 
 	/* MySQL does the name length check. But we do additional check
 	on the name length here */
@@ -6803,6 +6799,8 @@ err_col:
 			col_len);
 	}
 
+	srv_lower_case_table_names = lower_case_table_names;
+
 	error = row_create_table_for_mysql(table, trx);
 
 	if (error == DB_DUPLICATE_KEY) {
@@ -7220,36 +7218,15 @@ ha_innobase::create(
 		DBUG_RETURN(HA_ERR_TO_BIG_ROW);
 	}
 
-	/* Get the transaction associated with the current thd, or create one
-	if not yet created */
-
-	parent_trx = check_trx_exists(thd);
-
-	/* In case MySQL calls this in the middle of a SELECT query, release
-	possible adaptive hash latch to avoid deadlocks of threads */
-
-	trx_search_latch_release_if_reserved(parent_trx);
-
-	trx = innobase_trx_allocate(thd);
-
-	srv_lower_case_table_names = lower_case_table_names;
-
 	strcpy(name2, name);
 
 	normalize_table_name(norm_name, name2);
 
-	/* Latch the InnoDB data dictionary exclusively so that no deadlocks
-	or lock waits can happen in it during a table create operation.
-	Drop table etc. do this latching in row0mysql.c. */
-
-	row_mysql_lock_data_dictionary(trx);
-
 	/* Create the table definition in InnoDB */
 
 	/* Validate create options if innodb_strict_mode is set. */
 	if (!create_options_are_valid(thd, form, create_info)) {
-		error = ER_ILLEGAL_HA_CREATE_OPTION;
-		goto cleanup;
+		DBUG_RETURN(ER_ILLEGAL_HA_CREATE_OPTION);
 	}
 
 	if (create_info->key_block_size) {
@@ -7391,16 +7368,37 @@ ha_innobase::create(
 
 	/* Check for name conflicts (with reserved name) for
 	any user indices to be created. */
-	if (innobase_index_name_is_reserved(trx, form->key_info,
+	if (innobase_index_name_is_reserved(thd, form->key_info,
 					    form->s->keys)) {
-		error = -1;
-		goto cleanup;
+		DBUG_RETURN(-1);
+	}
+
+	if (IS_MAGIC_TABLE_AND_USER_DENIED_ACCESS(norm_name, thd)) {
+		DBUG_RETURN(HA_ERR_GENERIC);
 	}
 
 	if (create_info->options & HA_LEX_CREATE_TMP_TABLE) {
 		flags2 |= DICT_TF2_TEMPORARY;
 	}
 
+	/* Get the transaction associated with the current thd, or create one
+	if not yet created */
+
+	parent_trx = check_trx_exists(thd);
+
+	/* In case MySQL calls this in the middle of a SELECT query, release
+	possible adaptive hash latch to avoid deadlocks of threads */
+
+	trx_search_latch_release_if_reserved(parent_trx);
+
+	trx = innobase_trx_allocate(thd);
+
+	/* Latch the InnoDB data dictionary exclusively so that no deadlocks
+	or lock waits can happen in it during a table create operation.
+	Drop table etc. do this latching in row0mysql.c. */
+
+	row_mysql_lock_data_dictionary(trx);
+
 	error = create_table_def(trx, form, norm_name,
 		create_info->options & HA_LEX_CREATE_TMP_TABLE ? name2 : NULL,
 		flags, flags2);
@@ -7669,14 +7667,14 @@ ha_innobase::delete_table(
 
 	trx = innobase_trx_allocate(thd);
 
-	srv_lower_case_table_names = lower_case_table_names;
-
 	name_len = strlen(name);
 
 	ut_a(name_len < 1000);
 
 	/* Drop the table in InnoDB */
 
+	srv_lower_case_table_names = lower_case_table_names;
+
 	error = row_drop_table_for_mysql(norm_name, trx,
 					 thd_sql_command(thd)
 					 == SQLCOM_DROP_DB);
@@ -7788,8 +7786,6 @@ innobase_rename_table(
 	char*	norm_to;
 	char*	norm_from;
 
-	srv_lower_case_table_names = lower_case_table_names;
-
 	// Magic number 64 arbitrary
 	norm_to = (char*) my_malloc(strlen(to) + 64, MYF(0));
 	norm_from = (char*) my_malloc(strlen(from) + 64, MYF(0));
@@ -7804,6 +7800,8 @@ innobase_rename_table(
 		row_mysql_lock_data_dictionary(trx);
 	}
 
+	srv_lower_case_table_names = lower_case_table_names;
+
 	error = row_rename_table_for_mysql(
 		norm_from, norm_to, trx, lock_and_commit);
 
@@ -10788,7 +10786,7 @@ innobase_commit_by_xid(
 
 	if (trx) {
 		innobase_commit_low(trx);
-
+		trx_free_for_background(trx);
 		return(XA_OK);
 	} else {
 		return(XAER_NOTA);
@@ -10814,7 +10812,9 @@ innobase_rollback_by_xid(
 	trx = trx_get_trx_by_xid(xid);
 
 	if (trx) {
-		return(innobase_rollback_trx(trx));
+		int	ret = innobase_rollback_trx(trx);
+		trx_free_for_background(trx);
+		return(ret);
 	} else {
 		return(XAER_NOTA);
 	}
@@ -11992,17 +11992,17 @@ show_innodb_vars(
 
 /****************************************************************//**
 This function checks each index name for a table against reserved
-system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
-this function pushes an warning message to the client, and returns true. */
+system default primary index name 'GEN_CLUST_INDEX'. If a name
+matches, this function pushes an warning message to the client,
+and returns true.
+@return true if the index name matches the reserved name */
 extern "C" UNIV_INTERN
 bool
 innobase_index_name_is_reserved(
 /*============================*/
-					/* out: true if an index name
-					matches the reserved name */
-	const trx_t*	trx,		/* in: InnoDB transaction handle */
-	const KEY*	key_info,	/* in: Indexes to be created */
-	ulint		num_of_keys)	/* in: Number of indexes to
+	THD*		thd,		/*!< in/out: MySQL connection */
+	const KEY*	key_info,	/*!< in: Indexes to be created */
+	ulint		num_of_keys)	/*!< in: Number of indexes to
 					be created. */
 {
 	const KEY*	key;
@@ -12014,7 +12014,7 @@ innobase_index_name_is_reserved(
 		if (innobase_strcasecmp(key->name,
 					innobase_index_reserve_name) == 0) {
 			/* Push warning to mysql */
-			push_warning_printf((THD*) trx->mysql_thd,
+			push_warning_printf(thd,
 					    MYSQL_ERROR::WARN_LEVEL_WARN,
 					    ER_WRONG_NAME_FOR_INDEX,
 					    "Cannot Create Index with name "
@@ -12088,6 +12088,14 @@ static MYSQL_SYSVAR_ULONG(purge_threads,
   0,			/* Minimum value */
   32, 0);		/* Maximum value */
 
+static MYSQL_SYSVAR_ULONG(sync_array_size, srv_sync_array_size,
+  PLUGIN_VAR_OPCMDARG,
+  "Size of the mutex/lock wait array. Default is 32.",
+  NULL, NULL,
+  32,			/* Default setting */
+  1,			/* Minimum value */
+  1024, 0);		/* Maximum value */
+
 static MYSQL_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
   PLUGIN_VAR_OPCMDARG,
   "Speeds up the shutdown process of the InnoDB storage engine. Possible "
@@ -12504,6 +12512,7 @@ static struct st_mysql_sys_var* innobase
 #endif /* defined UNIV_DEBUG || defined UNIV_PERF_DEBUG */
   MYSQL_SYSVAR(print_all_deadlocks),
   MYSQL_SYSVAR(rollback_segments),
+  MYSQL_SYSVAR(sync_array_size),
   NULL
 };
 

=== modified file 'storage/innobase/handler/ha_innodb.h'
--- a/storage/innobase/handler/ha_innodb.h	2011-03-22 11:44:40 +0000
+++ b/storage/innobase/handler/ha_innodb.h	2011-04-11 14:57:47 +0000
@@ -388,15 +388,14 @@ innobase_trx_allocate(
 This function checks each index name for a table against reserved
 system default primary index name 'GEN_CLUST_INDEX'. If a name
 matches, this function pushes an warning message to the client,
-and returns true. */
+and returns true.
+@return true if the index name matches the reserved name */
 extern "C"
 bool
 innobase_index_name_is_reserved(
 /*============================*/
-					/* out: true if the index name
-					matches the reserved name */
-	const trx_t*	trx,		/* in: InnoDB transaction handle */
-	const KEY*	key_info,	/* in: Indexes to be created */
-	ulint		num_of_keys);	/* in: Number of indexes to
+	THD*		thd,		/*!< in/out: MySQL connection */
+	const KEY*	key_info,	/*!< in: Indexes to be created */
+	ulint		num_of_keys);	/*!< in: Number of indexes to
 					be created. */
 

=== modified file 'storage/innobase/handler/handler0alter.cc'
--- a/storage/innobase/handler/handler0alter.cc	2011-03-30 12:20:45 +0000
+++ b/storage/innobase/handler/handler0alter.cc	2011-04-11 14:57:47 +0000
@@ -629,21 +629,15 @@ innobase_add_index_cleanup(
 /*=======================*/
 	row_prebuilt_t*	prebuilt,		/*!< in/out: prebuilt */
 	trx_t*		trx,			/*!< in/out: transaction */
-	dict_table_t*	table,			/*!< in/out: table on which
+	dict_table_t*	table)			/*!< in/out: table on which
 						the indexes were going to be
 						created */
-	mem_heap_t*	heap)			/*!< in/own: heap that was
-						going to be used for the index
-						creation */
 {
-	mem_heap_free(heap);
-
 	trx_rollback_to_savepoint(trx, NULL);
 
 	ut_a(trx != prebuilt->trx);
 
 	trx_free_for_mysql(trx);
-	trx = NULL;
 
 	trx_commit_for_mysql(prebuilt->trx);
 
@@ -653,7 +647,7 @@ innobase_add_index_cleanup(
 
 		dict_mutex_enter_for_mysql();
 
-		/* Note: This check exludes the system tables. However, we
+		/* Note: This check excludes the system tables. However, we
 		should be safe because users cannot add indexes to system
 	        tables. */
 
@@ -706,43 +700,39 @@ ha_innobase::add_index(
 
 	update_thd();
 
-	heap = mem_heap_create(1024);
-
 	/* In case MySQL calls this in the middle of a SELECT query, release
 	possible adaptive hash latch to avoid deadlocks of threads. */
 	trx_search_latch_release_if_reserved(prebuilt->trx);
-	trx_start_if_not_started_xa(prebuilt->trx);
 
-	/* Create a background transaction for the operations on
-	the data dictionary tables. */
-	trx = innobase_trx_allocate(user_thd);
-	trx_start_if_not_started_xa(trx);
+	/* Check if the index name is reserved. */
+	if (innobase_index_name_is_reserved(user_thd, key_info, num_of_keys)) {
+		DBUG_RETURN(-1);
+	}
 
 	indexed_table = dict_table_open_on_name(prebuilt->table->name, FALSE);
 
 	innodb_table = indexed_table;
 
 	if (UNIV_UNLIKELY(!innodb_table)) {
-		innobase_add_index_cleanup(prebuilt, trx, NULL, heap);
-
 		DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
 	}
 
-	/* Check if the index name is reserved. */
-	if (innobase_index_name_is_reserved(trx, key_info, num_of_keys)) {
-		error = -1;
-	} else {
-		/* Check that index keys are sensible */
-		error = innobase_check_index_keys(key_info, num_of_keys,
-						  innodb_table);
-	}
+	/* Check that index keys are sensible */
+	error = innobase_check_index_keys(key_info, num_of_keys, innodb_table);
 
 	if (UNIV_UNLIKELY(error)) {
-		innobase_add_index_cleanup(prebuilt, trx, innodb_table, heap);
-
+		dict_table_close(innodb_table, FALSE);
 		DBUG_RETURN(error);
 	}
 
+	heap = mem_heap_create(1024);
+	trx_start_if_not_started(prebuilt->trx);
+
+	/* Create a background transaction for the operations on
+	the data dictionary tables. */
+	trx = innobase_trx_allocate(user_thd);
+	trx_start_if_not_started(trx);
+
 	/* We don't want this table to be evicted from the cache while we
 	are building an index on it. Another issue is that while we are
 	building the index this table could be referred to in a foreign
@@ -830,9 +820,10 @@ ha_innobase::add_index(
 			ut_d(dict_table_check_for_dup_indexes(innodb_table,
 							      FALSE));
 			row_mysql_unlock_data_dictionary(trx);
+			mem_heap_free(heap);
 
 			innobase_add_index_cleanup(
-				prebuilt, trx, innodb_table, heap);
+				prebuilt, trx, innodb_table);
 
 			DBUG_RETURN(error);
 		}
@@ -929,11 +920,11 @@ error_handling:
 		error = row_merge_rename_tables(innodb_table, indexed_table,
 						tmp_name, trx);
 
-		if (error != DB_SUCCESS) {
+		dict_table_close(innodb_table, dict_locked);
+		ut_a(innodb_table->n_ref_count == 1);
 
-			dict_table_close(innodb_table, dict_locked);
+		if (error != DB_SUCCESS) {
 
-			ut_a(innodb_table->n_ref_count == 1);
 			ut_a(indexed_table->n_ref_count == 0);
 
 			row_merge_drop_table(trx, indexed_table);
@@ -953,10 +944,6 @@ error_handling:
 
 		trx_commit_for_mysql(prebuilt->trx);
 
-		dict_table_close(innodb_table, dict_locked);
-
-		ut_a(innodb_table->n_ref_count == 1);
-
 		row_prebuilt_free(prebuilt, TRUE);
 
 		ut_a(innodb_table->n_ref_count == 0);

=== modified file 'storage/innobase/handler/i_s.cc'
--- a/storage/innobase/handler/i_s.cc	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/handler/i_s.cc	2011-04-13 13:27:46 +0000
@@ -3168,10 +3168,17 @@ i_s_innodb_buffer_page_fill(
 			do not want to hold the InnoDB mutex while
 			filling the IS table */
 			if (index) {
+				const char*	name_ptr = index->name;
+
+				if (name_ptr[0] == TEMP_INDEX_PREFIX) {
+					name_ptr++;
+				}
+
+				index_name = mem_heap_strdup(heap, name_ptr);
+
 				table_name = mem_heap_strdup(heap,
 							     index->table_name);
 
-				index_name = mem_heap_strdup(heap, index->name);
 			}
 
 			mutex_exit(&dict_sys->mutex);
@@ -3851,10 +3858,16 @@ i_s_innodb_buf_page_lru_fill(
 			do not want to hold the InnoDB mutex while
 			filling the IS table */
 			if (index) {
+				const char*	name_ptr = index->name;
+
+				if (name_ptr[0] == TEMP_INDEX_PREFIX) {
+					name_ptr++;
+				}
+
+				index_name = mem_heap_strdup(heap, name_ptr);
+
 				table_name = mem_heap_strdup(heap,
 							     index->table_name);
-
-				index_name = mem_heap_strdup(heap, index->name);
 			}
 
 			mutex_exit(&dict_sys->mutex);
@@ -3947,7 +3960,7 @@ i_s_innodb_fill_buffer_lru(
 	buf_pool_t*		buf_pool,	/*!< in: buffer pool to scan */
 	const ulint		pool_id)	/*!< in: buffer pool id */
 {
-	int			status;
+	int			status = 0;
 	buf_page_info_t*	info_buffer;
 	ulint			lru_pos = 0;
 	const buf_page_t*	bpage;
@@ -3993,10 +4006,10 @@ i_s_innodb_fill_buffer_lru(
 exit:
 	buf_pool_mutex_exit(buf_pool);
 
-	status = i_s_innodb_buf_page_lru_fill(
-		thd, tables, info_buffer, lru_len);
-
 	if (info_buffer) {
+		status = i_s_innodb_buf_page_lru_fill(
+			thd, tables, info_buffer, lru_len);
+
 		my_free(info_buffer);
 	}
 
@@ -4713,14 +4726,19 @@ i_s_dict_fill_sys_indexes(
 	TABLE*		table_to_fill)	/*!< in/out: fill this table */
 {
 	Field**		fields;
+	const char*	name_ptr = index->name;
 
 	DBUG_ENTER("i_s_dict_fill_sys_indexes");
 
 	fields = table_to_fill->field;
 
-	OK(fields[SYS_INDEX_ID]->store(longlong(index->id), TRUE));
+	if (name_ptr[0] == TEMP_INDEX_PREFIX) {
+		name_ptr++;
+	}
+
+	OK(field_store_string(fields[SYS_INDEX_NAME], name_ptr));
 
-	OK(field_store_string(fields[SYS_INDEX_NAME], index->name));
+	OK(fields[SYS_INDEX_ID]->store(longlong(index->id), TRUE));
 
 	OK(fields[SYS_INDEX_TABLE_ID]->store(longlong(table_id), TRUE));
 

=== modified file 'storage/innobase/ibuf/ibuf0ibuf.c'
--- a/storage/innobase/ibuf/ibuf0ibuf.c	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/ibuf/ibuf0ibuf.c	2011-04-20 07:13:04 +0000
@@ -1195,18 +1195,7 @@ ibuf_page_low(
 				ibuf_bitmap_page_no_calc(zip_size, page_no),
 				RW_NO_LATCH, NULL, BUF_GET_NO_LATCH,
 				file, line, &local_mtr));
-# ifdef UNIV_SYNC_DEBUG
-		/* This is for tracking Bug #58212. This check and message can
-		be removed once it has been established that our assumptions
-		about this condition are correct. The bug was only a one-time
-		occurrence, unable to repeat since then. */
-		void* latch = sync_thread_levels_contains(SYNC_IBUF_BITMAP);
-		if (latch) {
-			fprintf(stderr, "Bug#58212 UNIV_SYNC_DEBUG"
-				" levels %p (%u,%u)\n",
-				latch, (unsigned) space, (unsigned) page_no);
-		}
-# endif /* UNIV_SYNC_DEBUG */
+
 		ret = ibuf_bitmap_page_get_bits_low(
 			bitmap_page, page_no, zip_size,
 			MTR_MEMO_BUF_FIX, &local_mtr, IBUF_BITMAP_IBUF);

=== modified file 'storage/innobase/include/buf0buf.h'
--- a/storage/innobase/include/buf0buf.h	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/include/buf0buf.h	2011-04-13 08:22:11 +0000
@@ -54,6 +54,9 @@ Created 11/5/1995 Heikki Tuuri
 					/*!< Get the page only if it's in the
 					buffer pool, if not then set a watch
 					on the page. */
+#define BUF_GET_POSSIBLY_FREED		16
+					/*!< Like BUF_GET, but do not mind
+					if the file page has been freed. */
 /* @} */
 /** @name Modes for buf_page_get_known_nowait */
 /* @{ */
@@ -331,8 +334,7 @@ buf_page_optimistic_get(
 /*====================*/
 	ulint		rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH */
 	buf_block_t*	block,	/*!< in: guessed block */
-	ib_uint64_t	modify_clock,/*!< in: modify clock value if mode is
-				..._GUESS_ON_CLOCK */
+	ib_uint64_t	modify_clock,/*!< in: modify clock value */
 	const char*	file,	/*!< in: file name */
 	ulint		line,	/*!< in: line where called */
 	mtr_t*		mtr);	/*!< in: mini-transaction */
@@ -1496,8 +1498,10 @@ struct buf_page_struct{
 	/* @} */
 # if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
 	ibool		file_page_was_freed;
-					/*!< this is set to TRUE when fsp
-					frees a page in buffer pool */
+					/*!< this is set to TRUE when
+					fsp frees a page in buffer pool;
+					protected by buf_pool->zip_mutex
+					or buf_block_struct::mutex. */
 # endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
 #endif /* !UNIV_HOTBACKUP */
 };

=== modified file 'storage/innobase/include/buf0buf.ic'
--- a/storage/innobase/include/buf0buf.ic	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/include/buf0buf.ic	2011-04-19 13:16:51 +0000
@@ -35,6 +35,7 @@ Created 11/5/1995 Heikki Tuuri
 #include "buf0lru.h"
 #include "buf0rea.h"
 
+#ifndef UNIV_HOTBACKUP
 /** A chunk of buffers. The buffer pool is allocated in chunks. */
 struct buf_chunk_struct{
 	ulint		mem_size;	/*!< allocated size of the chunk */
@@ -171,6 +172,7 @@ buf_page_peek_if_too_old(
 			     / (BUF_LRU_OLD_RATIO_DIV * 4))));
 	}
 }
+#endif /* !UNIV_HOTBACKUP */
 
 /*********************************************************************//**
 Gets the state of a block.
@@ -986,8 +988,6 @@ buf_page_hash_get_low(
 {
 	buf_page_t*	bpage;
 
-	ut_ad(buf_pool);
-
 #ifdef UNIV_SYNC_DEBUG
 	ulint		hash_fold;
 	rw_lock_t*	hash_lock;
@@ -1076,7 +1076,8 @@ buf_page_hash_get_locked(
 
 	bpage = buf_page_hash_get_low(buf_pool, space, offset, fold);
 
-	if (!bpage || UNIV_UNLIKELY(buf_pool_watch_is_sentinel(buf_pool, bpage))) {
+	if (!bpage
+	    || UNIV_UNLIKELY(buf_pool_watch_is_sentinel(buf_pool, bpage))) {
 		bpage = NULL;
 		goto unlock_and_exit;
 	}
@@ -1221,7 +1222,6 @@ buf_page_release_zip(
 		break;
 	}
 
-	
 	ut_error;
 }
 

=== modified file 'storage/innobase/include/buf0flu.h'
--- a/storage/innobase/include/buf0flu.h	2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/buf0flu.h	2011-04-13 08:34:16 +0000
@@ -28,10 +28,10 @@ Created 11/5/1995 Heikki Tuuri
 
 #include "univ.i"
 #include "ut0byte.h"
+#include "log0log.h"
 #ifndef UNIV_HOTBACKUP
 #include "mtr0types.h"
 #include "buf0types.h"
-#include "log0log.h"
 
 /** Flag indicating if the page_cleaner is in active state. */
 extern ibool buf_page_cleaner_is_active;

=== modified file 'storage/innobase/include/buf0lru.h'
--- a/storage/innobase/include/buf0lru.h	2011-02-03 22:18:48 +0000
+++ b/storage/innobase/include/buf0lru.h	2011-04-13 08:34:16 +0000
@@ -27,6 +27,7 @@ Created 11/5/1995 Heikki Tuuri
 #define buf0lru_h
 
 #include "univ.i"
+#ifndef UNIV_HOTBACKUP
 #include "ut0byte.h"
 #include "buf0types.h"
 
@@ -293,4 +294,6 @@ Increments the page_zip_decompress() cou
 #include "buf0lru.ic"
 #endif
 
+#endif /* !UNIV_HOTBACKUP */
+
 #endif

=== modified file 'storage/innobase/include/dict0dict.ic'
--- a/storage/innobase/include/dict0dict.ic	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/include/dict0dict.ic	2011-04-13 08:34:16 +0000
@@ -144,7 +144,7 @@ ulint
 dict_col_get_fixed_size(
 /*====================*/
 	const dict_col_t*	col,	/*!< in: column */
-	ulint			comp)	/*!< in: nonzero=ROW_FORMAT=COMPACT  */
+	ulint			comp)	/*!< in: nonzero=ROW_FORMAT=COMPACT */
 {
 	return(dtype_get_fixed_size_low(col->mtype, col->prtype, col->len,
 					col->mbminmaxlen, comp));
@@ -490,6 +490,7 @@ dict_table_zip_size(
 	return(dict_table_flags_to_zip_size(table->flags));
 }
 
+#ifndef UNIV_HOTBACKUP
 /*********************************************************************//**
 Obtain exclusive locks on all index trees of the table. This is to prevent
 accessing index trees while InnoDB is updating internal metadata for
@@ -532,6 +533,8 @@ dict_table_x_unlock_indexes(
 		rw_lock_x_unlock(dict_index_get_lock(index));
 	}
 }
+#endif /* !UNIV_HOTBACKUP */
+
 /********************************************************************//**
 Gets the number of fields in the internal representation of an index,
 including fields added by the dictionary system.

=== modified file 'storage/innobase/include/dict0mem.ic'
--- a/storage/innobase/include/dict0mem.ic	2010-07-29 10:44:35 +0000
+++ b/storage/innobase/include/dict0mem.ic	2011-04-08 18:42:14 +0000
@@ -57,16 +57,18 @@ dict_mem_fill_index_struct(
 		index->fields = NULL;
 	}
 
-        index->type = type;
+	/* Assign a ulint to a 4-bit-mapped field.
+	Only the low-order 4 bits are assigned. */
+	index->type = type;
 #ifndef UNIV_HOTBACKUP
-        index->space = (unsigned int) space;
-        index->page = FIL_NULL;
+	index->space = (unsigned int) space;
+	index->page = FIL_NULL;
 #endif /* !UNIV_HOTBACKUP */
-        index->table_name = table_name;
-        index->n_fields = (unsigned int) n_fields;
-        /* The '1 +' above prevents allocation
-        of an empty mem block */
+	index->table_name = table_name;
+	index->n_fields = (unsigned int) n_fields;
+	/* The '1 +' above prevents allocation
+	of an empty mem block */
 #ifdef UNIV_DEBUG
-        index->magic_n = DICT_INDEX_MAGIC_N;
+	index->magic_n = DICT_INDEX_MAGIC_N;
 #endif /* UNIV_DEBUG */
 }

=== modified file 'storage/innobase/include/dict0priv.ic'
--- a/storage/innobase/include/dict0priv.ic	2011-02-09 09:27:12 +0000
+++ b/storage/innobase/include/dict0priv.ic	2011-04-13 08:34:16 +0000
@@ -26,6 +26,7 @@ Created  Wed 13 Oct 2010 16:10:14 EST Su
 #include "dict0dict.h"
 #include "dict0load.h"
 #include "dict0priv.h"
+#ifndef UNIV_HOTBACKUP
 
 /**********************************************************************//**
 Gets a table; loads it to the dictionary cache if necessary. A low-level
@@ -107,3 +108,4 @@ dict_table_check_if_in_cache_low(
 		    !strcmp(table->name, table_name));
 	return(table);
 }
+#endif /*! UNIV_HOTBACKUP */

=== modified file 'storage/innobase/include/fsp0fsp.h'
--- a/storage/innobase/include/fsp0fsp.h	2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/fsp0fsp.h	2011-04-06 11:07:44 +0000
@@ -41,16 +41,6 @@ void
 fsp_init(void);
 /*==========*/
 /**********************************************************************//**
-Gets the current free limit of the system tablespace.  The free limit
-means the place of the first page which has never been put to the
-free list for allocation.  The space above that address is initialized
-to zero.  Sets also the global variable log_fsp_current_free_limit.
-@return	free limit in megabytes */
-UNIV_INTERN
-ulint
-fsp_header_get_free_limit(void);
-/*===========================*/
-/**********************************************************************//**
 Gets the size of the system tablespace from the tablespace header.  If
 we do not have an auto-extending data file, this should be equal to
 the size of the data files.  If there is an auto-extending data file,

=== modified file 'storage/innobase/include/log0log.h'
--- a/storage/innobase/include/log0log.h	2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/log0log.h	2011-04-13 08:34:16 +0000
@@ -69,17 +69,6 @@ extern	ibool	log_debug_writes;
 /** Maximum number of log groups in log_group_struct::checkpoint_buf */
 #define LOG_MAX_N_GROUPS	32
 
-#ifndef UNIV_HOTBACKUP
-/****************************************************************//**
-Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,
-so that we know that the limit has been written to a log checkpoint field
-on disk. */
-UNIV_INTERN
-void
-log_fsp_current_free_limit_set_and_checkpoint(
-/*==========================================*/
-	ulint	limit);	/*!< in: limit to set */
-#endif /* !UNIV_HOTBACKUP */
 /*******************************************************************//**
 Calculates where in log files we find a specified lsn.
 @return	log file number */
@@ -638,23 +627,38 @@ extern log_t*	log_sys;
 							+ LOG_MAX_N_GROUPS * 8)
 #define LOG_CHECKPOINT_CHECKSUM_1	LOG_CHECKPOINT_ARRAY_END
 #define LOG_CHECKPOINT_CHECKSUM_2	(4 + LOG_CHECKPOINT_ARRAY_END)
+#if 0
 #define LOG_CHECKPOINT_FSP_FREE_LIMIT	(8 + LOG_CHECKPOINT_ARRAY_END)
-					/* current fsp free limit in
+					/*!< Not used (0);
+					This used to contain the
+					current fsp free limit in
 					tablespace 0, in units of one
-					megabyte; this information is only used
-					by ibbackup to decide if it can
-					truncate unused ends of
-					non-auto-extending data files in space
-					0 */
+					megabyte.
+
+					This information might have been used
+					since ibbackup version 0.35 but
+					before 1.41 to decide if unused ends of
+					non-auto-extending data files
+					in space 0 can be truncated.
+
+					This information was made obsolete
+					by ibbackup --compress. */
 #define LOG_CHECKPOINT_FSP_MAGIC_N	(12 + LOG_CHECKPOINT_ARRAY_END)
-					/* this magic number tells if the
+					/*!< Not used (0);
+					This magic number tells if the
 					checkpoint contains the above field:
 					the field was added to
-					InnoDB-3.23.50 */
+					InnoDB-3.23.50 and
+					removed from MySQL 5.6 */
+#define LOG_CHECKPOINT_FSP_MAGIC_N_VAL	1441231243
+					/*!< if LOG_CHECKPOINT_FSP_MAGIC_N
+					contains this value, then
+					LOG_CHECKPOINT_FSP_FREE_LIMIT
+					is valid */
+#endif
 #define LOG_CHECKPOINT_OFFSET_HIGH32	(16 + LOG_CHECKPOINT_ARRAY_END)
 #define LOG_CHECKPOINT_SIZE		(20 + LOG_CHECKPOINT_ARRAY_END)
 
-#define LOG_CHECKPOINT_FSP_MAGIC_N_VAL	1441231243
 
 /* Offsets of a log file header */
 #define LOG_GROUP_ID		0	/* log group number */
@@ -761,7 +765,6 @@ struct log_struct{
 					buffer */
 #ifndef UNIV_HOTBACKUP
 	mutex_t		mutex;		/*!< mutex protecting the log */
-#endif /* !UNIV_HOTBACKUP */
 
 	mutex_t		log_flush_order_mutex;/*!< mutex to serialize access to
 					the flush list when we are putting
@@ -771,6 +774,7 @@ struct log_struct{
 					mtr_commit and still ensure that
 					insertions in the flush_list happen
 					in the LSN order. */
+#endif /* !UNIV_HOTBACKUP */
 	byte*		buf_ptr;	/* unaligned log buffer */
 	byte*		buf;		/*!< log buffer */
 	ulint		buf_size;	/*!< log buffer size in bytes */

=== modified file 'storage/innobase/include/log0log.ic'
--- a/storage/innobase/include/log0log.ic	2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/log0log.ic	2011-04-05 11:12:48 +0000
@@ -439,7 +439,7 @@ log_free_check(void)
 {
 
 #ifdef UNIV_SYNC_DEBUG
-	ut_ad(sync_thread_levels_empty_gen(TRUE));
+	ut_ad(sync_thread_levels_empty_except_dict());
 #endif /* UNIV_SYNC_DEBUG */
 
 	if (log_sys->check_flush_or_checkpoint) {

=== modified file 'storage/innobase/include/os0file.h'
--- a/storage/innobase/include/os0file.h	2010-12-01 08:52:55 +0000
+++ b/storage/innobase/include/os0file.h	2011-04-13 08:34:16 +0000
@@ -308,7 +308,7 @@ to original un-instrumented file I/O API
 # define os_file_create(key, name, create, purpose, type, success)	\
 	os_file_create_func(name, create, purpose, type, success)
 
-# define os_file_create_simple(key, name, create, access, success)	\
+# define os_file_create_simple(key, name, create_mode, access, success)	\
 	os_file_create_simple_func(name, create_mode, access, success)
 
 # define os_file_create_simple_no_error_handling(			\

=== modified file 'storage/innobase/include/os0sync.h'
--- a/storage/innobase/include/os0sync.h	2011-02-15 09:40:34 +0000
+++ b/storage/innobase/include/os0sync.h	2011-04-05 11:12:48 +0000
@@ -162,10 +162,7 @@ os_event_free(
 	os_event_t	event);	/*!< in: event to free */
 
 /**********************************************************//**
-Waits for an event object until it is in the signaled state. If
-srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the
-waiting thread when the event becomes signaled (or immediately if the
-event is already in the signaled state).
+Waits for an event object until it is in the signaled state.
 
 Typically, if the event has been signalled after the os_event_reset()
 we'll return immediately because event->is_set == TRUE.

=== modified file 'storage/innobase/include/os0thread.h'
--- a/storage/innobase/include/os0thread.h	2011-01-21 04:22:26 +0000
+++ b/storage/innobase/include/os0thread.h	2011-04-06 06:35:25 +0000
@@ -107,8 +107,9 @@ UNIV_INTERN
 void
 os_thread_exit(
 /*===========*/
-	void*	exit_value);	/*!< in: exit value; in Windows this void*
+	void*	exit_value)	/*!< in: exit value; in Windows this void*
 				is cast as a DWORD */
+	UNIV_COLD __attribute__((noreturn));
 /*****************************************************************//**
 Returns the thread identifier of current thread.
 @return	current thread identifier */
@@ -117,13 +118,6 @@ os_thread_id_t
 os_thread_get_curr_id(void);
 /*========================*/
 /*****************************************************************//**
-Returns handle to the current thread.
-@return	current thread handle */
-UNIV_INTERN
-os_thread_t
-os_thread_get_curr(void);
-/*====================*/
-/*****************************************************************//**
 Advises the os to give up remainder of the thread's time slice. */
 UNIV_INTERN
 void
@@ -136,29 +130,6 @@ void
 os_thread_sleep(
 /*============*/
 	ulint	tm);	/*!< in: time in microseconds */
-/******************************************************************//**
-Gets a thread priority.
-@return	priority */
-UNIV_INTERN
-ulint
-os_thread_get_priority(
-/*===================*/
-	os_thread_t	handle);/*!< in: OS handle to the thread */
-/******************************************************************//**
-Sets a thread priority. */
-UNIV_INTERN
-void
-os_thread_set_priority(
-/*===================*/
-	os_thread_t	handle,	/*!< in: OS handle to the thread */
-	ulint		pri);	/*!< in: priority: one of OS_PRIORITY_... */
-/******************************************************************//**
-Gets the last operating system error code for the calling thread.
-@return	last error on Windows, 0 otherwise */
-UNIV_INTERN
-ulint
-os_thread_get_last_error(void);
-/*==========================*/
 
 #ifndef UNIV_NONINL
 #include "os0thread.ic"

=== added file 'storage/innobase/include/srv0conc.h'
--- a/storage/innobase/include/srv0conc.h	1970-01-01 00:00:00 +0000
+++ b/storage/innobase/include/srv0conc.h	2011-04-18 02:17:16 +0000
@@ -0,0 +1,124 @@
+/*****************************************************************************
+
+Copyright (c) 2011, Oracle and/or its affiliates. All Rights Reserved.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+Portions of this file contain modifications contributed and copyrighted
+by Percona Inc.. Those modifications are
+gratefully acknowledged and are described briefly in the InnoDB
+documentation. The contributions by Percona Inc. are incorporated with
+their permission, and subject to the conditions contained in the file
+COPYING.Percona.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/**************************************************//**
+@file srv/srv0conc.h
+
+InnoDB concurrency manager header file
+
+Created 2011/04/18 Sunny Bains
+*******************************************************/
+
+#ifndef srv_conc_h
+#define srv_conc_h
+
+/** We are prepared for a situation that we have this many threads waiting for
+a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets the
+value. */
+
+extern	ulint	srv_max_n_threads;
+
+/** The following controls how many threads we let inside InnoDB concurrently:
+threads waiting for locks are not counted into the number because otherwise
+we could get a deadlock. MySQL creates a thread for each user session, and
+semaphore contention and convoy problems can occur withput this restriction.
+Value 10 should be good if there are less than 4 processors + 4 disks in the
+computer. Bigger computers need bigger values. Value 0 will disable the
+concurrency check. */
+
+extern ulong	srv_thread_concurrency;
+
+/** Number of transactions that have declared_to_be_inside_innodb set.
+It used to be a non-error for this value to drop below zero temporarily.
+This is no longer true. We'll, however, keep the lint datatype to add
+assertions to catch any corner cases that we may have missed. */
+
+extern	lint	srv_conc_n_threads;
+
+/*********************************************************************//**
+Initialise the concurrency management data structures */
+void
+srv_conc_init(void);
+/*===============*/
+
+/*********************************************************************//**
+Free the concurrency management data structures */
+void
+srv_conc_free(void);
+/*===============*/
+
+/*********************************************************************//**
+Puts an OS thread to wait if there are too many concurrent threads
+(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
+UNIV_INTERN
+void
+srv_conc_enter_innodb(
+/*==================*/
+	trx_t*	trx);		/*!< in: transaction object associated
+				with the thread */
+
+/*********************************************************************//**
+This lets a thread enter InnoDB regardless of the number of threads inside
+InnoDB. This must be called when a thread ends a lock wait. */
+UNIV_INTERN
+void
+srv_conc_force_enter_innodb(
+/*========================*/
+	trx_t*	trx);		/*!< in: transaction object associated with
+				the thread */
+
+/*********************************************************************//**
+This must be called when a thread exits InnoDB in a lock wait or at the
+end of an SQL statement. */
+UNIV_INTERN
+void
+srv_conc_force_exit_innodb(
+/*=======================*/
+	trx_t*	trx);		/*!< in: transaction object associated with
+				the thread */
+
+/*********************************************************************//**
+This must be called when a thread exits InnoDB. */
+UNIV_INTERN
+void
+srv_conc_exit_innodb(
+/*=================*/
+	trx_t*	trx);		/*!< in: transaction object associated with
+				the thread */
+
+/*********************************************************************//**
+Get the count of threads waiting inside InnoDB. */
+UNIV_INTERN
+ulint
+srv_conc_get_waiting_threads(void);
+/*==============================*/
+
+#endif /* srv_conc_h */

=== modified file 'storage/innobase/include/srv0mon.h'
--- a/storage/innobase/include/srv0mon.h	2011-02-28 09:35:01 +0000
+++ b/storage/innobase/include/srv0mon.h	2011-04-14 06:31:44 +0000
@@ -250,6 +250,7 @@ enum monitor_id_value {
 	MONITOR_MODULE_PURGE,
 	MONITOR_N_DEL_ROW_PURGE,
 	MONITOR_N_UPD_EXIST_EXTERN,
+	MONITOR_PURGE_INVOKED,
 	MONITOR_PURGE_N_PAGE_HANDLED,
 	MONITOR_DML_PURGE_DELAY,
 

=== modified file 'storage/innobase/include/srv0srv.h'
--- a/storage/innobase/include/srv0srv.h	2011-03-23 13:46:37 +0000
+++ b/storage/innobase/include/srv0srv.h	2011-04-18 02:17:16 +0000
@@ -48,6 +48,7 @@ Created 10/10/1995 Heikki Tuuri
 #include "os0sync.h"
 #include "que0types.h"
 #include "trx0types.h"
+#include "srv0conc.h"
 
 extern const char*	srv_main_thread_op_info;
 
@@ -115,7 +116,6 @@ extern ulint	srv_max_file_format_at_star
 /** Place locks to records only i.e. do not use next-key locking except
 on duplicate key checking and foreign key checking */
 extern ibool	srv_locks_unsafe_for_binlog;
-#endif /* !UNIV_HOTBACKUP */
 
 /* If this flag is TRUE, then we will use the native aio of the
 OS (provided we compiled Innobase with it in), otherwise we will
@@ -125,6 +125,7 @@ extern my_bool	srv_use_native_aio;
 #ifdef __WIN__
 extern ibool	srv_use_native_conditions;
 #endif
+#endif /* !UNIV_HOTBACKUP */
 extern ulint	srv_n_data_files;
 extern char**	srv_data_file_names;
 extern ulint*	srv_data_file_sizes;
@@ -195,11 +196,6 @@ extern ulint	srv_max_n_open_files;
 extern ulint	srv_max_dirty_pages_pct;
 
 extern ulint	srv_force_recovery;
-extern ulong	srv_thread_concurrency;
-
-extern ulint	srv_max_n_threads;
-
-extern lint	srv_conc_n_threads;
 
 extern ulint	srv_fast_shutdown;	/*!< If this is 1, do not do a
 					purge and index buffer merge.
@@ -304,6 +300,9 @@ extern ulong srv_purge_batch_size;
 /* the number of rollback segments to use */
 extern ulong srv_rollback_segments;
 
+/* the number of sync wait arrays */
+extern ulong srv_sync_array_size;
+
 /* variable that counts amount of data read in total (in bytes) */
 extern ulint srv_data_read;
 
@@ -519,6 +518,16 @@ srv_master_thread(
 	void*	arg);	/*!< in: a dummy parameter required by
 			os_thread_create */
 /*******************************************************************//**
+Tells the purge thread that there has been activity in the database
+and wakes up the purge thread if it is suspended (not sleeping).  Note
+that there is a small chance that the purge thread stays suspended
+(we do not protect our operation with the srv_sys_t:mutex, for
+performance reasons). */
+UNIV_INTERN
+void
+srv_wake_purge_thread_if_not_active(void);
+/*=====================================*/
+/*******************************************************************//**
 Wakes up the purge thread if it's not already awake. */
 UNIV_INTERN
 void
@@ -541,41 +550,6 @@ void
 srv_wake_master_thread(void);
 /*========================*/
 /*********************************************************************//**
-Puts an OS thread to wait if there are too many concurrent threads
-(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
-UNIV_INTERN
-void
-srv_conc_enter_innodb(
-/*==================*/
-	trx_t*	trx);	/*!< in: transaction object associated with the
-			thread */
-/*********************************************************************//**
-This lets a thread enter InnoDB regardless of the number of threads inside
-InnoDB. This must be called when a thread ends a lock wait. */
-UNIV_INTERN
-void
-srv_conc_force_enter_innodb(
-/*========================*/
-	trx_t*	trx);	/*!< in: transaction object associated with the
-			thread */
-/*********************************************************************//**
-This must be called when a thread exits InnoDB in a lock wait or at the
-end of an SQL statement. */
-UNIV_INTERN
-void
-srv_conc_force_exit_innodb(
-/*=======================*/
-	trx_t*	trx);	/*!< in: transaction object associated with the
-			thread */
-/*********************************************************************//**
-This must be called when a thread exits InnoDB. */
-UNIV_INTERN
-void
-srv_conc_exit_innodb(
-/*=================*/
-	trx_t*	trx);	/*!< in: transaction object associated with the
-			thread */
-/*********************************************************************//**
 A thread which prints the info output by various InnoDB monitors.
 @return	a dummy parameter */
 UNIV_INTERN
@@ -639,16 +613,6 @@ void
 srv_inc_activity_count(void);
 /*=========================*/
 
-/*********************************************************************//**
-Asynchronous purge thread.
-@return	a dummy parameter */
-UNIV_INTERN
-os_thread_ret_t
-srv_purge_thread(
-/*=============*/
-	void*	arg __attribute__((unused)));	/*!< in: a dummy parameter
-						required by os_thread_create */
-
 /**********************************************************************//**
 Enqueues a task to server task queue and releases a worker thread, if there
 is a suspended one. */
@@ -784,8 +748,6 @@ struct export_var_struct{
 
 /** Thread slot in the thread table.  */
 struct srv_slot_struct{
-	os_thread_id_t	id;			/*!< thread id */
-	os_thread_t	handle;			/*!< thread handle */
 	enum srv_thread_type
 			type;			/*!< thread type: user,
 						utility etc. */

=== modified file 'storage/innobase/include/sync0arr.h'
--- a/storage/innobase/include/sync0arr.h	2011-03-30 12:02:53 +0000
+++ b/storage/innobase/include/sync0arr.h	2011-04-12 01:21:37 +0000
@@ -36,32 +36,6 @@ typedef struct sync_cell_struct		sync_ce
 /** Synchronization wait array */
 typedef struct sync_array_struct	sync_array_t;
 
-/** Parameters for sync_array_create() @{ */
-#define SYNC_ARRAY_OS_MUTEX	1	/*!< protected by os_mutex_t */
-#define SYNC_ARRAY_MUTEX	2	/*!< protected by mutex_t */
-/* @} */
-
-/*******************************************************************//**
-Creates a synchronization wait array. It is protected by a mutex
-which is automatically reserved when the functions operating on it
-are called.
-@return	own: created wait array */
-UNIV_INTERN
-sync_array_t*
-sync_array_create(
-/*==============*/
-	ulint	n_cells,	/*!< in: number of cells in the array
-				to create */
-	ulint	protection);	/*!< in: either SYNC_ARRAY_OS_MUTEX or
-				SYNC_ARRAY_MUTEX: determines the type
-				of mutex protecting the data structure */
-/******************************************************************//**
-Frees the resources in a wait array. */
-UNIV_INTERN
-void
-sync_array_free(
-/*============*/
-	sync_array_t*	arr);	/*!< in, own: sync wait array */
 /******************************************************************//**
 Reserves a wait array cell for waiting for an object.
 The event of the cell is reset to nonsignalled state. */
@@ -99,9 +73,9 @@ sync_array_free_cell(
 Note that one of the wait objects was signalled. */
 UNIV_INTERN
 void
-sync_array_object_signalled(
-/*========================*/
-	sync_array_t*	arr);	/*!< in: wait array */
+sync_array_object_signalled(void);
+/*=============================*/
+
 /**********************************************************************//**
 If the wakeup algorithm does not work perfectly at semaphore relases,
 this function will do the waking (see the comment in mutex_exit). This
@@ -132,11 +106,30 @@ sync_array_validate(
 Prints info of the wait array. */
 UNIV_INTERN
 void
-sync_array_print_info(
+sync_array_print(
+/*=============*/
+	FILE*		file);	/*!< in: file where to print */
+
+/**********************************************************************//**
+Create the primary system wait array(s), they are protected by an OS mutex */
+UNIV_INTERN
+void
+sync_array_init(
+/*============*/
+	ulint		n_threads);	/*!< in: Number of slots to create */
+/**********************************************************************//**
+Close sync array wait sub-system. */
+UNIV_INTERN
+void
+sync_array_close(void);
 /*==================*/
-	FILE*		file,	/*!< in: file where to print */
-	sync_array_t*	arr);	/*!< in: wait array */
 
+/**********************************************************************//**
+Get an instance of the sync wait array. */
+UNIV_INTERN
+sync_array_t*
+sync_array_get(void);
+/*================*/
 
 #ifndef UNIV_NONINL
 #include "sync0arr.ic"

=== modified file 'storage/innobase/include/sync0arr.ic'
--- a/storage/innobase/include/sync0arr.ic	2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/sync0arr.ic	2011-04-12 01:21:37 +0000
@@ -24,4 +24,3 @@ Inline code
 
 Created 9/5/1995 Heikki Tuuri
 *******************************************************/
-

=== modified file 'storage/innobase/include/sync0rw.h'
--- a/storage/innobase/include/sync0rw.h	2011-01-18 10:37:13 +0000
+++ b/storage/innobase/include/sync0rw.h	2011-04-11 15:55:35 +0000
@@ -123,6 +123,8 @@ extern	mysql_pfs_key_t	trx_i_s_cache_loc
 extern	mysql_pfs_key_t	trx_purge_latch_key;
 extern	mysql_pfs_key_t	index_tree_rw_lock_key;
 extern	mysql_pfs_key_t	dict_table_stats_latch_key;
+extern  mysql_pfs_key_t trx_sys_rw_lock_key;
+extern  mysql_pfs_key_t hash_table_rw_lock_key;
 #endif /* UNIV_PFS_RWLOCK */
 
 

=== modified file 'storage/innobase/include/sync0rw.ic'
--- a/storage/innobase/include/sync0rw.ic	2011-02-15 09:52:01 +0000
+++ b/storage/innobase/include/sync0rw.ic	2011-04-12 01:21:37 +0000
@@ -504,7 +504,7 @@ rw_lock_s_unlock_func(
                 anyway. We do not wake other waiters, because they can't
                 exist without wait_ex waiter and wait_ex waiter goes first.*/
 		os_event_set(lock->wait_ex_event);
-		sync_array_object_signalled(sync_primary_wait_array);
+		sync_array_object_signalled();
 
 	}
 
@@ -578,7 +578,7 @@ rw_lock_x_unlock_func(
 		if (lock->waiters) {
 			rw_lock_reset_waiter_flag(lock);
 			os_event_set(lock->event);
-			sync_array_object_signalled(sync_primary_wait_array);
+			sync_array_object_signalled();
 		}
 	}
 

=== modified file 'storage/innobase/include/sync0sync.h'
--- a/storage/innobase/include/sync0sync.h	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/include/sync0sync.h	2011-04-12 13:27:46 +0000
@@ -103,7 +103,6 @@ extern mysql_pfs_key_t	srv_innodb_monito
 extern mysql_pfs_key_t	srv_misc_tmpfile_mutex_key;
 extern mysql_pfs_key_t	srv_threads_mutex_key;
 extern mysql_pfs_key_t	srv_monitor_file_mutex_key;
-extern mysql_pfs_key_t	syn_arr_mutex_key;
 # ifdef UNIV_SYNC_DEBUG
 extern mysql_pfs_key_t	sync_thread_mutex_key;
 # endif /* UNIV_SYNC_DEBUG */
@@ -112,7 +111,6 @@ extern mysql_pfs_key_t	trx_undo_mutex_ke
 extern mysql_pfs_key_t	trx_mutex_key;
 extern mysql_pfs_key_t	lock_sys_mutex_key;
 extern mysql_pfs_key_t	lock_sys_wait_mutex_key;
-extern mysql_pfs_key_t	trx_sys_rw_lock_key;
 extern mysql_pfs_key_t	read_view_mutex_key;
 extern mysql_pfs_key_t	srv_sys_mutex_key;
 extern mysql_pfs_key_t	srv_sys_tasks_mutex_key;
@@ -120,7 +118,6 @@ extern mysql_pfs_key_t	srv_conc_mutex_ke
 extern mysql_pfs_key_t	event_os_mutex_key;
 extern mysql_pfs_key_t	ut_list_mutex_key;
 extern mysql_pfs_key_t	os_mutex_key;
-
 #endif /* UNIV_PFS_MUTEX */
 
 /******************************************************************//**
@@ -423,13 +420,6 @@ sync_thread_reset_level(
 /*====================*/
 	void*	latch);	/*!< in: pointer to a mutex or an rw-lock */
 /******************************************************************//**
-Checks that the level array for the current thread is empty.
-@return	TRUE if empty */
-UNIV_INTERN
-ibool
-sync_thread_levels_empty(void);
-/*==========================*/
-/******************************************************************//**
 Checks if the level array for the current thread contains a
 mutex or rw-latch at the specified level.
 @return	a matching latch, or NULL if not found */
@@ -440,17 +430,33 @@ sync_thread_levels_contains(
 	ulint	level);			/*!< in: latching order level
 					(SYNC_DICT, ...)*/
 /******************************************************************//**
-Checks if the level array for the current thread is empty.
+Checks that the level array for the current thread is empty.
 @return	a latch, or NULL if empty except the exceptions specified below */
 UNIV_INTERN
 void*
 sync_thread_levels_nonempty_gen(
 /*============================*/
-	ibool	dict_mutex_allowed);	/*!< in: TRUE if dictionary mutex is
-					allowed to be owned by the thread,
-					also purge_is_running mutex is
-					allowed */
-#define sync_thread_levels_empty_gen(d) (!sync_thread_levels_nonempty_gen(d))
+	ibool	dict_mutex_allowed)	/*!< in: TRUE if dictionary mutex is
+					allowed to be owned by the thread */
+	__attribute__((warn_unused_result));
+/******************************************************************//**
+Checks if the level array for the current thread is empty,
+except for data dictionary latches. */
+#define sync_thread_levels_empty_except_dict()		\
+	(!sync_thread_levels_nonempty_gen(TRUE))
+/******************************************************************//**
+Checks if the level array for the current thread is empty,
+except for the btr_search_latch.
+@return	a latch, or NULL if empty except the exceptions specified below */
+UNIV_INTERN
+void*
+sync_thread_levels_nonempty_trx(
+/*============================*/
+	ibool	has_search_latch)
+				/*!< in: TRUE if and only if the thread
+				is supposed to hold btr_search_latch */
+	__attribute__((warn_unused_result));
+
 /******************************************************************//**
 Gets the debug information for a reserved mutex. */
 UNIV_INTERN
@@ -767,11 +773,6 @@ struct mutex_struct {
 #endif
 };
 
-/** The global array of wait cells for implementation of the databases own
-mutexes and read-write locks. */
-extern sync_array_t*	sync_primary_wait_array;/* Appears here for
-						debugging purposes only! */
-
 /** Constant determining how long spin wait is continued before suspending
 the thread. A value 600 rounds on a 1995 100 MHz Pentium seems to correspond
 to 20 microseconds. */

=== modified file 'storage/innobase/include/trx0sys.h'
--- a/storage/innobase/include/trx0sys.h	2011-02-22 05:11:15 +0000
+++ b/storage/innobase/include/trx0sys.h	2011-04-13 08:34:16 +0000
@@ -494,7 +494,7 @@ trx_sys_get_n_trx(void);
 /*===================*/
 
 /*********************************************************************
-Check if there are any active transactions.
+Check if there are any active (non-prepared) transactions.
 @return total number of active transactions or 0 if none */
 UNIV_INTERN
 ulint
@@ -632,7 +632,6 @@ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_NO. */
 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE	FSP_EXTENT_SIZE
 /* @} */
 
-#ifndef UNIV_HOTBACKUP
 /** File format tag */
 /* @{ */
 /** The offset of the file format tag on the trx system header page
@@ -651,6 +650,7 @@ identifier is added to this 64-bit const
 	 | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW)
 /* @} */
 
+#ifndef UNIV_HOTBACKUP
 /** Doublewrite control struct */
 struct trx_doublewrite_struct{
 	mutex_t	mutex;		/*!< mutex protecting the first_free field and
@@ -677,6 +677,10 @@ struct trx_sys_struct{
 	rw_lock_t	lock;		/*!< read-write lock protecting most
 					fields in this structure except when
 					noted otherwise */
+	ulint		n_mysql_trx;	/*!< Number of transactions currently
+					allocated for MySQL */
+	ulint		n_prepared_trx;	/*!< Number of transactions currently
+					in the XA PREPARED state */
 	trx_id_t	max_trx_id;	/*!< The smallest number not yet
 					assigned as a transaction id or
 					transaction number */

=== modified file 'storage/innobase/include/trx0trx.h'
--- a/storage/innobase/include/trx0trx.h	2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/trx0trx.h	2011-04-14 07:10:14 +0000
@@ -42,10 +42,6 @@ Created 3/26/1996 Heikki Tuuri
 /** Dummy session used currently in MySQL interface */
 extern sess_t*	trx_dummy_sess;
 
-/** Number of transactions currently allocated for MySQL: protected by
-trx_sys->lock */
-extern ulint	trx_n_mysql_transactions;
-
 /********************************************************************//**
 Releases the search latch if trx has reserved it. */
 UNIV_INTERN
@@ -93,18 +89,26 @@ trx_t*
 trx_allocate_for_background(void);
 /*=============================*/
 /********************************************************************//**
-Frees a transaction object for MySQL. */
+Frees a transaction object of a background operation of the master thread. */
 UNIV_INTERN
 void
-trx_free_for_mysql(
-/*===============*/
+trx_free_for_background(
+/*====================*/
 	trx_t*	trx);	/*!< in, own: trx object */
 /********************************************************************//**
-Frees a transaction object of a background operation of the master thread. */
+At shutdown, frees a transaction object that is in the PREPARED state. */
 UNIV_INTERN
 void
-trx_free_for_background(
-/*====================*/
+trx_free_prepared(
+/*==============*/
+	trx_t*	trx)	/*!< in, own: trx object */
+	UNIV_COLD __attribute__((nonnull));
+/********************************************************************//**
+Frees a transaction object for MySQL. */
+UNIV_INTERN
+void
+trx_free_for_mysql(
+/*===============*/
 	trx_t*	trx);	/*!< in, own: trx object */
 /****************************************************************//**
 Creates trx objects for transactions and initializes the trx list of
@@ -479,6 +483,9 @@ struct trx_lock_struct {
 					insertions are protected by trx->mutex
 					and lock_sys->mutex; removals are
 					protected by lock_sys->mutex */
+
+	ib_vector_t*	table_locks;	/*!< All table locks requested by this
+					transaction, including AUTOINC locks */
 };
 
 #define TRX_MAGIC_N	91118598
@@ -545,7 +552,7 @@ struct trx_struct{
 					and ACTIVE->PREPARED->COMMITTED
 					are possible when trx->in_trx_list.
 					The transition ACTIVE->PREPARED is
-					not protected by any mutex.
+					protected by trx_sys->lock.
 					The transitions ACTIVE->COMMITTED
 					and PREPARED->COMMITTED are protected
 					by lock_sys->mutex and trx->mutex.
@@ -672,14 +679,10 @@ struct trx_struct{
 					contains a pointer to the latest file
 					name; this is NULL if binlog is not
 					used */
-	ib_int64_t	mysql_log_offset;/*!< if MySQL binlog is used, this
-					 field contains the end offset of the
-					 binlog entry */
-	os_thread_id_t	mysql_thread_id;/*!< id of the MySQL thread associated
-					with this transaction object */
-	ulint		mysql_process_no;/*!< since in Linux, 'top' reports
-					process id's and not thread id's, we
-					store the process number too */
+	ib_int64_t	mysql_log_offset;
+					/*!< if MySQL binlog is used, this
+					field contains the end offset of the
+					binlog entry */
 	/*------------------------------*/
 	ulint		n_mysql_tables_in_use; /*!< number of Innobase tables
 					used in the processing of the current

=== modified file 'storage/innobase/include/trx0undo.h'
--- a/storage/innobase/include/trx0undo.h	2010-10-27 05:08:49 +0000
+++ b/storage/innobase/include/trx0undo.h	2011-04-11 14:57:47 +0000
@@ -296,6 +296,15 @@ void
 trx_undo_insert_cleanup(
 /*====================*/
 	trx_t*	trx);	/*!< in: transaction handle */
+
+/********************************************************************//**
+At shutdown, frees the undo logs of a PREPARED transaction. */
+UNIV_INTERN
+void
+trx_undo_free_prepared(
+/*===================*/
+	trx_t*	trx)	/*!< in/out: PREPARED transaction */
+	UNIV_COLD __attribute__((nonnull));
 #endif /* !UNIV_HOTBACKUP */
 /***********************************************************//**
 Parses the redo log entry of an undo log page initialization.

=== modified file 'storage/innobase/include/univ.i'
--- a/storage/innobase/include/univ.i	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/include/univ.i	2011-04-08 18:42:14 +0000
@@ -266,6 +266,19 @@ easy way to get it to work. See http://b
 #else
 # define UNIV_INTERN
 #endif
+#if defined __GNUC__ && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+/** Starting with GCC 4.3, the "cold" attribute is used to inform the
+compiler that a function is unlikely executed.  The function is
+optimized for size rather than speed and on many targets it is placed
+into special subsection of the text section so all cold functions
+appears close together improving code locality of non-cold parts of
+program.  The paths leading to call of cold functions within code are
+marked as unlikely by the branch prediction mechanism.  optimize a
+rarely invoked function for size instead for speed. */
+# define UNIV_COLD __attribute__((cold))
+#else
+# define UNIV_COLD /* empty */
+#endif
 
 #ifndef UNIV_MUST_NOT_INLINE
 /* Definition for inline version */
@@ -329,16 +342,16 @@ including new BLOB treatment */
 /** The universal page size of the database */
 #define UNIV_PAGE_SIZE		(1 << UNIV_PAGE_SIZE_SHIFT)
 
-/** log2 of smallest compressed page size (1<<10 == 1024 bytes) */
-#define UNIV_ZIP_SIZE_SHIFT_MIN	10
-
-/** log2 of largest compressed page size (1<<14 == 16384 bytes).
-A compressed page directory entry reserves 14 bits for the start offset
-and 2 bits for flags. This limits the uncompressed page size to 16k.
-So even though a 16k uncompressed page can theoretically be compressed
-into a larger compressed page, it is not a useful feature so we will
-limit both with this same constant. */
-#define UNIV_ZIP_SIZE_SHIFT_MAX	14
+/** log2 of smallest compressed page size (1<<10 == 1024 bytes) */
+#define UNIV_ZIP_SIZE_SHIFT_MIN	10
+
+/** log2 of largest compressed page size (1<<14 == 16384 bytes).
+A compressed page directory entry reserves 14 bits for the start offset
+and 2 bits for flags. This limits the uncompressed page size to 16k.
+Even though a 16k uncompressed page can theoretically be compressed
+into a larger compressed page, it is not a useful feature so we will
+limit both with this same constant. */
+#define UNIV_ZIP_SIZE_SHIFT_MAX	14
 
 /** Smallest compressed page size */
 #define UNIV_ZIP_SIZE_MIN	(1 << UNIV_ZIP_SIZE_SHIFT_MIN)

=== modified file 'storage/innobase/include/ut0bh.ic'
--- a/storage/innobase/include/ut0bh.ic	2011-02-22 20:24:34 +0000
+++ b/storage/innobase/include/ut0bh.ic	2011-04-08 18:42:14 +0000
@@ -122,4 +122,3 @@ ib_bh_last(
 		: ib_bh_get(ib_bh, ib_bh_size(ib_bh) - 1));
 }
 
-

=== modified file 'storage/innobase/include/ut0dbg.h'
--- a/storage/innobase/include/ut0dbg.h	2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/ut0dbg.h	2011-04-06 06:35:25 +0000
@@ -50,9 +50,10 @@ UNIV_INTERN
 void
 ut_dbg_assertion_failed(
 /*====================*/
-	const char* expr,	/*!< in: the failed assertion */
-	const char* file,	/*!< in: source file containing the assertion */
-	ulint line);		/*!< in: line number of the assertion */
+	const char*	expr,	/*!< in: the failed assertion */
+	const char*	file,	/*!< in: source file containing the assertion */
+	ulint		line)	/*!< in: line number of the assertion */
+	UNIV_COLD __attribute__((nonnull(2)));
 
 #if defined(__WIN__) || defined(__INTEL_COMPILER)
 # undef UT_DBG_USE_ABORT

=== modified file 'storage/innobase/include/ut0ut.h'
--- a/storage/innobase/include/ut0ut.h	2010-12-02 08:42:10 +0000
+++ b/storage/innobase/include/ut0ut.h	2011-04-06 06:35:25 +0000
@@ -279,7 +279,8 @@ UNIV_INTERN
 void
 ut_print_timestamp(
 /*===============*/
-	FILE*  file); /*!< in: file where to print */
+	FILE*	file)	/*!< in: file where to print */
+	UNIV_COLD __attribute__((nonnull));
 /**********************************************************//**
 Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */
 UNIV_INTERN

=== modified file 'storage/innobase/include/ut0vec.h'
--- a/storage/innobase/include/ut0vec.h	2010-11-30 11:03:30 +0000
+++ b/storage/innobase/include/ut0vec.h	2011-04-14 07:03:25 +0000
@@ -84,6 +84,14 @@ ib_vector_is_empty(
 	const ib_vector_t*	vec);	/*!< in: vector */
 
 /****************************************************************//**
+Reset the vector to empty. */
+UNIV_INLINE
+void
+ib_vector_reset(
+/*============*/
+	ib_vector_t*	vec);	/*!< in/out: vector */
+
+/****************************************************************//**
 Get the n'th element.
 @return	n'th element */
 UNIV_INLINE

=== modified file 'storage/innobase/include/ut0vec.ic'
--- a/storage/innobase/include/ut0vec.ic	2010-11-30 11:03:30 +0000
+++ b/storage/innobase/include/ut0vec.ic	2011-04-14 07:03:25 +0000
@@ -123,3 +123,17 @@ ib_vector_is_empty(
 {
 	return(ib_vector_size(vec) == 0);
 }
+
+/****************************************************************//**
+Reset the vector to empty. */
+UNIV_INLINE
+void
+ib_vector_reset(
+/*============*/
+	ib_vector_t*	vec)	/*!< in/out: vector */
+{
+	ut_d(memset(vec->data, 0x0, sizeof(*vec->data) * vec->used));
+	UNIV_MEM_INVALID(vec->data, sizeof(*vec->data) * vec->used);
+
+	vec->used = 0;
+}

=== modified file 'storage/innobase/lock/lock0lock.c'
--- a/storage/innobase/lock/lock0lock.c	2011-03-18 13:58:55 +0000
+++ b/storage/innobase/lock/lock0lock.c	2011-04-20 23:35:24 +0000
@@ -1403,7 +1403,8 @@ lock_rec_get_prev(
 /*============= FUNCTIONS FOR ANALYZING TABLE LOCK QUEUE ================*/
 
 /*********************************************************************//**
-Checks if a transaction has the specified table lock, or stronger.
+Checks if a transaction has the specified table lock, or stronger. This
+function should only be called by the thread that owns the transaction.
 @return	lock or NULL */
 UNIV_INLINE
 const lock_t*
@@ -1413,21 +1414,32 @@ lock_table_has(
 	const dict_table_t*	table,	/*!< in: table */
 	enum lock_mode		mode)	/*!< in: lock mode */
 {
-	const lock_t*	lock;
+	lint			i;
 
-	ut_ad(lock_mutex_own());
+	if (ib_vector_is_empty(trx->lock.table_locks)) {
+		return(NULL);
+	}
 
 	/* Look for stronger locks the same trx already has on the table */
 
-	for (lock = UT_LIST_GET_LAST(table->locks);
-	     lock != NULL;
-	     lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, lock)) {
+	for (i = ib_vector_size(trx->lock.table_locks) - 1; i >= 0; --i) {
+		const lock_t*	lock;
+		enum lock_mode	lock_mode;
 
-		if (lock->trx == trx
-		    && lock_mode_stronger_or_eq(lock_get_mode(lock), mode)) {
+		lock = ib_vector_get(trx->lock.table_locks, i);
+
+		if (lock == NULL) {
+			continue;
+		}
 
-			/* The same trx already has locked the table in
-			a mode stronger or equal to the mode given */
+		lock_mode = lock_get_mode(lock);
+
+		ut_ad(trx == lock->trx);
+		ut_ad(lock_get_type_low(lock) & LOCK_TABLE);
+		ut_ad(lock->un_member.tab_lock.table != NULL);
+
+		if (table == lock->un_member.tab_lock.table
+		    && lock_mode_stronger_or_eq(lock_mode, mode)) {
 
 			ut_ad(!lock_get_wait(lock));
 
@@ -2071,9 +2083,13 @@ lock_rec_lock_fast(
 
 			status = LOCK_REC_FAIL;
 		} else if (!impl) {
-			lock_rec_set_nth_bit(lock, heap_no);
-
-			status = LOCK_REC_SUCCESS_CREATED;
+			/* If the nth bit of the record lock is already set
+			then we do not set a new lock bit, otherwise we do
+			set */
+			if (!lock_rec_get_nth_bit(lock, heap_no)) {
+				lock_rec_set_nth_bit(lock, heap_no);
+				status = LOCK_REC_SUCCESS_CREATED;
+			}
 		}
 
 		trx_mutex_exit(trx);
@@ -3817,8 +3833,6 @@ lock_table_create(
 		lock = mem_heap_alloc(trx->lock.lock_heap, sizeof(*lock));
 	}
 
-	UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock);
-
 	lock->type_mode = type_mode | LOCK_TABLE;
 	lock->trx = trx;
 
@@ -3826,6 +3840,7 @@ lock_table_create(
 
 	ut_ad(table->n_ref_count > 0 || !table->can_be_evicted);
 
+	UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock);
 	UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock);
 
 	if (UNIV_UNLIKELY(type_mode & LOCK_WAIT)) {
@@ -3833,6 +3848,8 @@ lock_table_create(
 		lock_set_lock_and_trx_wait(lock, trx);
 	}
 
+	ib_vector_push(lock->trx->lock.table_locks, lock);
+
 	MONITOR_INC(MONITOR_TABLELOCK_CREATED);
 	MONITOR_INC(MONITOR_NUM_TABLELOCK);
 
@@ -3932,7 +3949,7 @@ lock_table_remove_low(
 	table = lock->un_member.tab_lock.table;
 
 	/* Remove the table from the transaction's AUTOINC vector, if
-	the lock that is being release is an AUTOINC lock. */
+	the lock that is being released is an AUTOINC lock. */
 	if (lock_get_mode(lock) == LOCK_AUTO_INC) {
 
 		/* The table's AUTOINC lock can get transferred to
@@ -4076,9 +4093,9 @@ lock_table_other_has_incompatible(
 	     lock != NULL;
 	     lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, lock)) {
 
-		if ((lock->trx != trx)
-		    && (!lock_mode_compatible(lock_get_mode(lock), mode))
-		    && (wait || !(lock_get_wait(lock)))) {
+		if (lock->trx != trx
+		    && !lock_mode_compatible(lock_get_mode(lock), mode)
+		    && (wait || !lock_get_wait(lock))) {
 
 			return(lock);
 		}
@@ -4102,8 +4119,9 @@ lock_table(
 	enum lock_mode	mode,	/*!< in: lock mode */
 	que_thr_t*	thr)	/*!< in: query thread */
 {
-	trx_t*	trx;
-	ulint	err;
+	trx_t*		trx;
+	ulint		err;
+	lock_t*		lock;
 
 	ut_ad(table && thr);
 
@@ -4116,36 +4134,33 @@ lock_table(
 
 	trx = thr_get_trx(thr);
 
-	lock_mutex_enter();
-
-	/* Look for stronger locks the same trx already has on the table */
+	/* Look for equal or stronger locks the same trx already
+	has on the table. No need to acquire the lock mutex here
+	because only this transacton can add/access table locks
+	to/from trx_t::table_locks. */
 
 	if (lock_table_has(trx, table, mode)) {
 
-		err = DB_SUCCESS;
+		return(DB_SUCCESS);
+	}
 
-	} else if (lock_table_other_has_incompatible(
-				trx, LOCK_WAIT, table, mode)) {
+	lock_mutex_enter();
 
 	/* We have to check if the new lock is compatible with any locks
 	other transactions have in the table lock queue. */
 
-		/* Another trx has a request on the table in an incompatible
-		mode: this trx may have to wait */
+	lock = lock_table_other_has_incompatible(trx, LOCK_WAIT, table, mode);
 
-		trx_mutex_enter(trx);
+	trx_mutex_enter(trx);
 
-		err = lock_table_enqueue_waiting(mode | flags, table, thr);
+	/* Another trx has a request on the table in an incompatible
+	mode: this trx may have to wait */
 
-		trx_mutex_exit(trx);
+	if (lock != NULL) {
+		err = lock_table_enqueue_waiting(mode | flags, table, thr);
 	} else {
-
-		trx_mutex_enter(trx);
-
 		lock_table_create(table, mode | flags, trx);
 
-		trx_mutex_exit(trx);
-
 		ut_a(!flags || mode == LOCK_S || mode == LOCK_X);
 
 		err = DB_SUCCESS;
@@ -4153,6 +4168,8 @@ lock_table(
 
 	lock_mutex_exit();
 
+	trx_mutex_exit(trx);
+
 	return(err);
 }
 
@@ -4361,8 +4378,15 @@ lock_release(
 		++count;
 	}
 
+	/* We don't remove the locks one by one from the vector for
+	efficiency reasons. We simply reset it because we would have
+	released all the locks anyway. */
+
+	ib_vector_reset(trx->lock.table_locks);
+
 	ut_a(UT_LIST_GET_LEN(trx->lock.trx_locks) == 0);
-	ut_a(ib_vector_size(trx->autoinc_locks) == 0);
+	ut_a(ib_vector_is_empty(trx->autoinc_locks));
+	ut_a(ib_vector_is_empty(trx->lock.table_locks));
 
 	mem_heap_empty(trx->lock.lock_heap);
 }
@@ -4372,6 +4396,46 @@ lock_release(
 	(lock_get_mode(lock) == LOCK_S \
 	 || lock_get_mode(lock) == LOCK_X)
 
+/*********************************************************************//**
+Removes table locks of the transaction on a table to be dropped. */
+static
+void
+lock_trx_table_locks_remove(
+/*========================*/
+	const lock_t*	lock_to_remove)		/*!< in: lock to remove */
+{
+	lint		i;
+	trx_t*		trx = lock_to_remove->trx;
+
+	ut_ad(lock_mutex_own());
+
+	trx_mutex_enter(trx);
+
+	for (i = ib_vector_size(trx->lock.table_locks) - 1; i >= 0; --i) {
+		const lock_t*	lock;
+
+		lock = ib_vector_get(trx->lock.table_locks, i);
+
+		if (lock == NULL) {
+			continue;
+		}
+
+		ut_a(trx == lock->trx);
+		ut_a(lock_get_type_low(lock) & LOCK_TABLE);
+		ut_a(lock->un_member.tab_lock.table != NULL);
+
+		if (lock == lock_to_remove) {
+			ib_vector_set(trx->lock.table_locks, i, NULL);
+			trx_mutex_exit(trx);
+			return;
+		}
+	}
+
+	trx_mutex_exit(trx);
+
+	/* Lock must exist in the vector. */
+	ut_error;
+}
 
 /*********************************************************************//**
 Removes locks of a transaction on a table to be dropped.
@@ -4387,15 +4451,14 @@ lock_remove_all_on_table_for_trx(
 	ibool		remove_also_table_sx_locks)/*!< in: also removes
 						table S and X locks */
 {
-	lock_t*	lock;
+	lock_t*		lock;
+	lock_t*		prev_lock;
 
 	ut_ad(lock_mutex_own());
 
 	for (lock = UT_LIST_GET_LAST(trx->lock.trx_locks);
 	     lock != NULL;
-	     /* No op */) {
-
-		lock_t*	prev_lock;
+	     lock = prev_lock) {
 
 		prev_lock = UT_LIST_GET_PREV(trx_locks, lock);
 
@@ -4411,10 +4474,9 @@ lock_remove_all_on_table_for_trx(
 
 			ut_a(!lock_get_wait(lock));
 
+			lock_trx_table_locks_remove(lock);
 			lock_table_remove_low(lock);
 		}
-
-		lock = prev_lock;
 	}
 }
 
@@ -4500,16 +4562,16 @@ lock_remove_all_on_table(
 						table S and X locks */
 {
 	lock_t*		lock;
-	lock_t*		prev_lock;
 
 	lock_mutex_enter();
 
-	lock = UT_LIST_GET_FIRST(table->locks);
+	for (lock = UT_LIST_GET_FIRST(table->locks);
+	     lock != NULL;
+	     /* No op */) {
 
-	while (lock != NULL) {
+		lock_t*	prev_lock;
 
-		prev_lock = UT_LIST_GET_PREV(un_member.tab_lock.locks,
-					     lock);
+		prev_lock = UT_LIST_GET_PREV(un_member.tab_lock.locks, lock);
 
 		/* If we should remove all locks (remove_also_table_sx_locks
 		is TRUE), or if the lock is not table-level S or X lock,
@@ -4521,8 +4583,8 @@ lock_remove_all_on_table(
 			ut_a(!lock_get_wait(lock));
 		}
 
-		lock_remove_all_on_table_for_trx(table, lock->trx,
-						 remove_also_table_sx_locks);
+		lock_remove_all_on_table_for_trx(
+			table, lock->trx, remove_also_table_sx_locks);
 
 		if (prev_lock == NULL) {
 			if (lock == UT_LIST_GET_FIRST(table->locks)) {
@@ -4974,6 +5036,44 @@ print_rec:
 
 #ifdef UNIV_DEBUG
 /*********************************************************************//**
+Find the the lock in the trx_t::trx_lock_t::table_locks vector.
+@return TRUE if found */
+static
+ibool
+lock_trx_table_locks_find(
+/*======================*/
+	trx_t*		trx,		/*!< in: trx to validate */
+	const lock_t*	find_lock)	/*!< in: lock to find */
+{
+	lint		i;
+	ibool		found = FALSE;
+
+	trx_mutex_enter(trx);
+
+	for (i = ib_vector_size(trx->lock.table_locks) - 1; i >= 0; --i) {
+		const lock_t*	lock;
+
+		lock = ib_vector_get(trx->lock.table_locks, i);
+
+		if (lock == NULL) {
+			continue;
+		} else if (lock == find_lock) {
+			/* Can't be duplicates. */
+			ut_a(!found);
+			found = TRUE;
+		}
+
+		ut_a(trx == lock->trx);
+		ut_a(lock_get_type_low(lock) & LOCK_TABLE);
+		ut_a(lock->un_member.tab_lock.table != NULL);
+	}
+
+	trx_mutex_exit(trx);
+
+	return(found);
+}
+
+/*********************************************************************//**
 Validates the lock queue on a table.
 @return	TRUE if ok */
 static
@@ -4982,7 +5082,8 @@ lock_table_queue_validate(
 /*======================*/
 	dict_table_t*	table)	/*!< in: table */
 {
-	lock_t*	lock;
+	lock_t*		lock;
+	ulint		count = 0;
 
 	ut_ad(lock_mutex_own());
 #ifdef UNIV_SYNC_DEBUG
@@ -4993,6 +5094,9 @@ lock_table_queue_validate(
 	     lock != NULL;
 	     lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock)) {
 
+		ulint		i;
+		ib_vector_t*	table_locks;
+
 		/* lock->trx->state cannot change from or to NOT_STARTED
 		while we are holding the trx_sys->lock. It may change
 		from ACTIVE to PREPARED, but it may not change to
@@ -5008,8 +5112,28 @@ lock_table_queue_validate(
 
 			ut_a(lock_table_has_to_wait_in_queue(lock));
 		}
+
+		ut_a(lock_trx_table_locks_find(lock->trx, lock));
+
+		/* Skip the NULL entries and only count the locks that
+		transactions have on this table. */
+		table_locks = lock->trx->lock.table_locks;
+
+		for (i = 0; i < ib_vector_size(table_locks); ++i) {
+			const lock_t*	trx_lock;
+
+			trx_lock = ib_vector_get(table_locks, i);
+
+			if (trx_lock != NULL
+			    && trx_lock->un_member.tab_lock.table == table) {
+
+				++count;
+			}
+		}
 	}
 
+	ut_a(count == UT_LIST_GET_LEN(table->locks));
+
 	return(TRUE);
 }
 
@@ -5893,6 +6017,9 @@ lock_release_autoinc_last_lock(
 
 	/* This will remove the lock from the trx autoinc_locks too. */
 	lock_table_dequeue(lock);
+
+	/* Remove from the table vector too. */
+	lock_trx_table_locks_remove(lock);
 }
 
 /*******************************************************************//**
@@ -6222,15 +6349,20 @@ lock_trx_release_locks(
 /*===================*/
 	trx_t*	trx)	/*!< in/out: transaction */
 {
+	if (UNIV_UNLIKELY(trx_state_eq(trx, TRX_STATE_PREPARED))) {
+		rw_lock_x_lock(&trx_sys->lock);
+		ut_a(trx_sys->n_prepared_trx > 0);
+		trx_sys->n_prepared_trx--;
+		rw_lock_x_unlock(&trx_sys->lock);
+	} else {
+		ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
+	}
+
 	/* The transition of trx->state to TRX_STATE_COMMITTED_IN_MEMORY
 	is protected by both the lock_sys->mutex and the trx->mutex. */
 	lock_mutex_enter();
 	trx_mutex_enter(trx);
 
-	ut_ad(trx->state == TRX_STATE_ACTIVE
-	      || trx->state == TRX_STATE_PREPARED);
-	ut_ad(trx->in_trx_list);
-
 	/* The following assignment makes the transaction committed in memory
 	and makes its changes to data visible to other transactions.
 	NOTE that there is a small discrepancy from the strict formal
@@ -6261,6 +6393,7 @@ lock_trx_release_locks(
 	the is_recovered flag. */
 
 	trx->is_recovered = FALSE;
+
 	trx_mutex_exit(trx);
 
 	lock_release(trx);

=== modified file 'storage/innobase/lock/lock0wait.c'
--- a/storage/innobase/lock/lock0wait.c	2011-02-17 14:06:09 +0000
+++ b/storage/innobase/lock/lock0wait.c	2011-04-12 07:53:47 +0000
@@ -58,10 +58,9 @@ lock_wait_table_print(void)
 	for (i = 0; i < OS_THREAD_MAX_N; i++, ++slot) {
 
 		fprintf(stderr,
-			"Slot %lu: thread id %lu, type %lu,"
+			"Slot %lu: thread type %lu,"
 			" in use %lu, susp %lu, timeout %lu, time %lu\n",
 			(ulong) i,
-			(ulong) os_thread_pf(slot->id),
 			(ulong) slot->type,
 			(ulong) slot->in_use,
 			(ulong) slot->suspended,
@@ -155,8 +154,6 @@ lock_wait_table_reserve_slot(
 			slot->in_use = TRUE;
 			slot->thr = thr;
 			slot->thr->slot = slot;
-			slot->id = os_thread_get_curr_id();
-			slot->handle = os_thread_get_curr();
 
 			if (slot->event == NULL) {
 				slot->event = os_event_create(NULL);
@@ -212,7 +209,7 @@ lock_wait_suspend_thread(
 	double		wait_time;
 	trx_t*		trx;
 	ulint		had_dict_lock;
-	ibool		was_declared_inside_innodb	= FALSE;
+	ibool		was_declared_inside_innodb;
 	ib_int64_t	start_time			= 0;
 	ib_int64_t	finish_time;
 	ulint		sec;
@@ -273,17 +270,6 @@ lock_wait_suspend_thread(
 	lock_wait_mutex_exit();
 	trx_mutex_exit(trx);
 
-	if (trx->declared_to_be_inside_innodb) {
-
-		was_declared_inside_innodb = TRUE;
-
-		/* We must declare this OS thread to exit InnoDB, since a
-		possible other thread holding a lock which this thread waits
-		for must be allowed to enter, sooner or later */
-
-		srv_conc_force_exit_innodb(trx);
-	}
-
 	had_dict_lock = trx->dict_operation_lock_mode;
 
 	switch (had_dict_lock) {
@@ -307,17 +293,21 @@ lock_wait_suspend_thread(
 
 	/* Suspend this thread and wait for the event. */
 
-	ut_ad(!trx_mutex_own(trx));
+	was_declared_inside_innodb = trx->declared_to_be_inside_innodb;
+
+	if (was_declared_inside_innodb) {
+		/* We must declare this OS thread to exit InnoDB, since a
+		possible other thread holding a lock which this thread waits
+		for must be allowed to enter, sooner or later */
+
+		srv_conc_force_exit_innodb(trx);
+	}
+
 	os_event_wait(slot->event);
 
 	/* After resuming, reacquire the data dictionary latch if
 	necessary. */
 
-	if (had_dict_lock) {
-
-		row_mysql_freeze_data_dictionary(trx);
-	}
-
 	if (was_declared_inside_innodb) {
 
 		/* Return back inside InnoDB */
@@ -325,6 +315,11 @@ lock_wait_suspend_thread(
 		srv_conc_force_enter_innodb(trx);
 	}
 
+	if (had_dict_lock) {
+
+		row_mysql_freeze_data_dictionary(trx);
+	}
+
 	wait_time = ut_difftime(ut_time(), slot->suspend_time);
 
 	/* Release the slot for others to use */

=== modified file 'storage/innobase/log/log0log.c'
--- a/storage/innobase/log/log0log.c	2011-03-09 07:32:36 +0000
+++ b/storage/innobase/log/log0log.c	2011-04-11 14:57:47 +0000
@@ -76,10 +76,6 @@ reduce the size of the log.
 
 */
 
-/* Current free limit of space 0; protected by the log sys mutex; 0 means
-uninitialized */
-UNIV_INTERN ulint	log_fsp_current_free_limit		= 0;
-
 /* Global log system variable */
 UNIV_INTERN log_t*	log_sys	= NULL;
 
@@ -165,33 +161,6 @@ log_io_complete_archive(void);
 #endif /* UNIV_LOG_ARCHIVE */
 
 /****************************************************************//**
-Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,
-so that we know that the limit has been written to a log checkpoint field
-on disk. */
-UNIV_INTERN
-void
-log_fsp_current_free_limit_set_and_checkpoint(
-/*==========================================*/
-	ulint	limit)	/*!< in: limit to set */
-{
-	ibool	success;
-
-	mutex_enter(&(log_sys->mutex));
-
-	log_fsp_current_free_limit = limit;
-
-	mutex_exit(&(log_sys->mutex));
-
-	/* Try to make a synchronous checkpoint */
-
-	success = FALSE;
-
-	while (!success) {
-		success = log_checkpoint(TRUE, TRUE);
-	}
-}
-
-/****************************************************************//**
 Returns the oldest modified block lsn in the pool, or log_sys->lsn if none
 exists.
 @return	LSN of oldest modification */
@@ -1840,15 +1809,6 @@ log_group_checkpoint(
 			      LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN);
 	mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_2, fold);
 
-	/* Starting from InnoDB-3.23.50, we also write info on allocated
-	size in the tablespace */
-
-	mach_write_to_4(buf + LOG_CHECKPOINT_FSP_FREE_LIMIT,
-			log_fsp_current_free_limit);
-
-	mach_write_to_4(buf + LOG_CHECKPOINT_FSP_MAGIC_N,
-			LOG_CHECKPOINT_FSP_MAGIC_N_VAL);
-
 	/* We alternate the physical place of the checkpoint info in the first
 	log file */
 
@@ -3145,6 +3105,8 @@ logs_empty_and_mark_files_at_shutdown(vo
 	ulint			total_trx;
 	ulint			pending_io;
 	enum srv_thread_type	active_thd;
+	const char*		thread_name;
+	ibool			server_busy;
 
 	if (srv_print_verbose_log) {
 		ut_print_timestamp(stderr);
@@ -3159,34 +3121,30 @@ loop:
 
 	count++;
 
-	/* We need the monitor threads to stop before we proceed with a
-	normal shutdown. In case of very fast shutdown, however, we can
-	proceed without waiting for monitor threads. */
-
-	if (srv_fast_shutdown < 2) {
-	       	const char*	thread_name;
-		
-		thread_name = srv_any_background_threads_are_active();
+	/* We need the monitor threads to stop before we proceed with
+	a shutdown. */
 
-		if (thread_name != NULL) {
-			/* Print a message every 60 seconds if we are waiting
-			for the monitor thread to exit. Master and worker
-		       	threads check will be done later. */
-
-			if (srv_print_verbose_log && count > 600) {
-				ut_print_timestamp(stderr);
-				fprintf(stderr, "  InnoDB: Waiting for %s "
-					"to exit\n", thread_name);
-				count = 0;
-			}
+	thread_name = srv_any_background_threads_are_active();
 
-			goto loop;
+	if (thread_name != NULL) {
+		/* Print a message every 60 seconds if we are waiting
+		for the monitor thread to exit. Master and worker
+		threads check will be done later. */
+
+		if (srv_print_verbose_log && count > 600) {
+			ut_print_timestamp(stderr);
+			fprintf(stderr, "  InnoDB: Waiting for %s to exit\n",
+				thread_name);
+			count = 0;
 		}
+
+		goto loop;
 	}
 
-	/* Check that there are no longer transactions. We need this wait even
-	for the 'very fast' shutdown, because the InnoDB layer may have
-	committed or prepared transactions and we don't want to lose them. */
+	/* Check that there are no longer transactions, except for
+	PREPARED ones. We need this wait even for the 'very fast'
+	shutdown, because the InnoDB layer may have committed or
+	prepared transactions and we don't want to lose them. */
 
 	total_trx = trx_sys_any_active_transactions();
 
@@ -3204,21 +3162,6 @@ loop:
 		goto loop;
 	}
 
-	if (srv_fast_shutdown == 2) {
-
-		/* In this fastest shutdown we do not flush the buffer pool:
-		it is essentially a 'crash' of the InnoDB server. Make sure
-		that the log is all flushed to disk, so that we can recover
-		all committed transactions in a crash recovery. We must not
-		write the lsn stamps to the data files, since at a startup
-		InnoDB deduces from the stamps if the previous shutdown was
-		clean. */
-
-		log_buffer_flush_to_disk();
-
-		return; /* We SKIP ALL THE REST !! */
-	}
-
 	/* Check that the background threads are suspended */
 
 	active_thd = srv_get_active_thread_type();
@@ -3235,9 +3178,10 @@ loop:
 
 			switch (active_thd) {
 			case SRV_NONE:
-				/* This shouldn't happen because we've already
-				checked for this case before entering the if().
-				We handle it here to avoid a compiler worning. */
+				/* This shouldn't happen because we've
+				already checked for this case before
+				entering the if().  We handle it here
+				to avoid a compiler warning. */
 				ut_error;
 			case SRV_WORKER:
 				thread_type = "worker threads";
@@ -3276,16 +3220,15 @@ loop:
 		}
 	}
 
-	mutex_enter(&(log_sys->mutex));
-
-	if (log_sys->n_pending_checkpoint_writes
+	mutex_enter(&log_sys->mutex);
+	server_busy = log_sys->n_pending_checkpoint_writes
 #ifdef UNIV_LOG_ARCHIVE
-	    || log_sys->n_pending_archive_ios
+		|| log_sys->n_pending_archive_ios
 #endif /* UNIV_LOG_ARCHIVE */
-	    || log_sys->n_pending_writes) {
-
-		mutex_exit(&(log_sys->mutex));
+		|| log_sys->n_pending_writes;
+	mutex_exit(&log_sys->mutex);
 
+	if (server_busy) {
 		if (srv_print_verbose_log && count > 600) {
 			ut_print_timestamp(stderr);
 			fprintf(stderr,
@@ -3298,8 +3241,6 @@ loop:
 		goto loop;
 	}
 
-	mutex_exit(&(log_sys->mutex));
-
 	pending_io = buf_pool_check_no_pending_io();
 
 	if (pending_io) {
@@ -3317,10 +3258,44 @@ loop:
 #ifdef UNIV_LOG_ARCHIVE
 	log_archive_all();
 #endif /* UNIV_LOG_ARCHIVE */
+	if (srv_fast_shutdown == 2) {
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			"  InnoDB: MySQL has requested a very fast shutdown"
+			" without flushing "
+			"the InnoDB buffer pool to data files."
+			" At the next mysqld startup "
+			"InnoDB will do a crash recovery!\n");
+
+		/* In this fastest shutdown we do not flush the buffer pool:
+		it is essentially a 'crash' of the InnoDB server. Make sure
+		that the log is all flushed to disk, so that we can recover
+		all committed transactions in a crash recovery. We must not
+		write the lsn stamps to the data files, since at a startup
+		InnoDB deduces from the stamps if the previous shutdown was
+		clean. */
+
+		log_buffer_flush_to_disk();
+
+		/* Check that the background threads stay suspended */
+		thread_name = srv_any_background_threads_are_active();
+		if (thread_name != NULL) {
+			fprintf(stderr,
+				"InnoDB: Warning: background thread %s"
+				" woke up during shutdown\n", thread_name);
+			goto loop;
+		}
+
+		srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE;
+		fil_close_all_files();
+		thread_name = srv_any_background_threads_are_active();
+		ut_a(!thread_name);
+		return;
+	}
 
 	log_make_checkpoint_at(LSN_MAX, TRUE);
 
-	mutex_enter(&(log_sys->mutex));
+	mutex_enter(&log_sys->mutex);
 
 	lsn = log_sys->lsn;
 
@@ -3331,7 +3306,7 @@ loop:
 #endif /* UNIV_LOG_ARCHIVE */
 	    ) {
 
-		mutex_exit(&(log_sys->mutex));
+		mutex_exit(&log_sys->mutex);
 
 		goto loop;
 	}
@@ -3349,13 +3324,14 @@ loop:
 	log_archive_close_groups(TRUE);
 #endif /* UNIV_LOG_ARCHIVE */
 
-	mutex_exit(&(log_sys->mutex));
+	mutex_exit(&log_sys->mutex);
 
 	/* Check that the background threads stay suspended */
-	if (srv_get_active_thread_type() != SRV_NONE) {
+	thread_name = srv_any_background_threads_are_active();
+	if (thread_name != NULL) {
 		fprintf(stderr,
-			"InnoDB: Warning: some background thread woke up"
-			" during shutdown\n");
+			"InnoDB: Warning: background thread %s"
+			" woke up during shutdown\n", thread_name);
 
 		goto loop;
 	}

=== modified file 'storage/innobase/log/log0recv.c'
--- a/storage/innobase/log/log0recv.c	2011-03-14 13:00:56 +0000
+++ b/storage/innobase/log/log0recv.c	2011-04-13 08:34:16 +0000
@@ -762,15 +762,12 @@ Reads the checkpoint info needed in hot
 @return	TRUE if success */
 UNIV_INTERN
 ibool
-recv_read_cp_info_for_backup(
-/*=========================*/
+recv_read_checkpoint_info_for_backup(
+/*=================================*/
 	const byte*	hdr,	/*!< in: buffer containing the log group
 				header */
 	lsn_t*		lsn,	/*!< out: checkpoint lsn */
 	lsn_t*		offset,	/*!< out: checkpoint offset in the log group */
-	ulint*		fsp_limit,/*!< out: fsp limit of space 0,
-				1000000000 if the database is running
-				with < version 3.23.50 of InnoDB */
 	ib_uint64_t*	cp_no,	/*!< out: checkpoint number */
 	ib_uint64_t*	first_header_lsn)
 				/*!< out: lsn of of the start of the
@@ -804,25 +801,8 @@ recv_read_cp_info_for_backup(
 	*lsn = mach_read_from_8(cp_buf + LOG_CHECKPOINT_LSN);
 	*offset = mach_read_from_4(
 		cp_buf + LOG_CHECKPOINT_OFFSET_LOW32);
-	*offset |= mach_read_from_4(
-		cp_buf + LOG_CHECKPOINT_OFFSET_HIGH32) << 32;
-
-	/* If the user is running a pre-3.23.50 version of InnoDB, its
-	checkpoint data does not contain the fsp limit info */
-	if (mach_read_from_4(cp_buf + LOG_CHECKPOINT_FSP_MAGIC_N)
-	    == LOG_CHECKPOINT_FSP_MAGIC_N_VAL) {
-
-		*fsp_limit = mach_read_from_4(
-			cp_buf + LOG_CHECKPOINT_FSP_FREE_LIMIT);
-
-		if (*fsp_limit == 0) {
-			*fsp_limit = 1000000000;
-		}
-	} else {
-		*fsp_limit = 1000000000;
-	}
-
-	/*	fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */
+	*offset |= ((lsn_t) mach_read_from_4(
+			    cp_buf + LOG_CHECKPOINT_OFFSET_HIGH32)) << 32;
 
 	*cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO);
 
@@ -1954,7 +1934,7 @@ recv_apply_log_recs_for_backup(void)
 			if (!success) {
 				fprintf(stderr,
 					"InnoDB: Fatal error: cannot extend"
-					" tablespace %lu to hold %lu pages\n",
+					" tablespace %u to hold %u pages\n",
 					recv_addr->space, recv_addr->page_no);
 
 				exit(1);

=== modified file 'storage/innobase/mem/mem0dbg.c'
--- a/storage/innobase/mem/mem0dbg.c	2011-02-28 07:59:28 +0000
+++ b/storage/innobase/mem/mem0dbg.c	2011-04-13 08:34:16 +0000
@@ -24,10 +24,9 @@ but is included in mem0mem.* !
 Created 6/9/1994 Heikki Tuuri
 *************************************************************************/
 
-#include "ha_prototypes.h"
-
 #ifdef UNIV_MEM_DEBUG
 # ifndef UNIV_HOTBACKUP
+#  include "ha_prototypes.h"
 /* The mutex which protects in the debug version the hash table
 containing the list of live memory heaps, and also the global
 variables below. */

=== modified file 'storage/innobase/mtr/mtr0log.c'
--- a/storage/innobase/mtr/mtr0log.c	2011-03-18 15:48:14 +0000
+++ b/storage/innobase/mtr/mtr0log.c	2011-04-08 18:42:14 +0000
@@ -538,7 +538,7 @@ mlog_parse_index(
 /*=============*/
 	byte*		ptr,	/*!< in: buffer */
 	const byte*	end_ptr,/*!< in: buffer end */
-	ibool		comp,	/*!< in: TRUE=compact record format */
+	ibool		comp,	/*!< in: TRUE=compact row format */
 	dict_index_t**	index)	/*!< out, own: dummy index */
 {
 	ulint		i, n, n_uniq;

=== modified file 'storage/innobase/os/os0file.c'
--- a/storage/innobase/os/os0file.c	2010-12-01 08:52:55 +0000
+++ b/storage/innobase/os/os0file.c	2011-04-05 11:12:48 +0000
@@ -4082,13 +4082,13 @@ os_aio_func(
 	}
 
 try_again:
-	if (mode == OS_AIO_NORMAL) {
-		if (type == OS_FILE_READ) {
-			array = os_aio_read_array;
-		} else {
-			array = os_aio_write_array;
-		}
-	} else if (mode == OS_AIO_IBUF) {
+	switch (mode) {
+	case OS_AIO_NORMAL:
+		array = (type == OS_FILE_READ)
+			? os_aio_read_array
+			: os_aio_write_array;
+		break;
+	case OS_AIO_IBUF:
 		ut_ad(type == OS_FILE_READ);
 		/* Reduce probability of deadlock bugs in connection with ibuf:
 		do not let the ibuf i/o handler sleep */
@@ -4096,19 +4096,21 @@ try_again:
 		wake_later = FALSE;
 
 		array = os_aio_ibuf_array;
-	} else if (mode == OS_AIO_LOG) {
-
+		break;
+	case OS_AIO_LOG:
 		array = os_aio_log_array;
-	} else if (mode == OS_AIO_SYNC) {
+		break;
+	case OS_AIO_SYNC:
 		array = os_aio_sync_array;
 
 #if defined(LINUX_NATIVE_AIO)
 		/* In Linux native AIO we don't use sync IO array. */
 		ut_a(!srv_use_native_aio);
 #endif /* LINUX_NATIVE_AIO */
-	} else {
-		array = NULL; /* Eliminate compiler warning */
+		break;
+	default:
 		ut_error;
+		array = NULL; /* Eliminate compiler warning */
 	}
 
 	slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
@@ -4271,11 +4273,17 @@ os_aio_windows_handle(
 					   INFINITE);
 	}
 
-	if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
-		os_thread_exit(NULL);
+	os_mutex_enter(array->mutex);
+
+	if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS
+	    && array->n_reserved == 0) {
+		*message1 = NULL;
+		*message2 = NULL;
+		os_mutex_exit(array->mutex);
+		return(TRUE);
 	}
 
-	os_mutex_enter(array->mutex);
+	ut_a(i >= WAIT_OBJECT_0 && i <= WAIT_OBJECT_0 + n);
 
 	slot = os_aio_array_get_nth_slot(array, i + segment * n);
 
@@ -4421,14 +4429,6 @@ os_aio_linux_collect(
 
 retry:
 
-	/* Go down if we are in shutdown mode.
-	In case of srv_fast_shutdown == 2, there may be pending
-	IO requests but that should be OK as we essentially treat
-	that as a crash of InnoDB. */
-	if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
-		os_thread_exit(NULL);
-	}
-
 	/* Initialize the events. The timeout value is arbitrary.
 	We probably need to experiment with it a little. */
 	memset(events, 0, sizeof(*events) * seg_size);
@@ -4437,76 +4437,72 @@ retry:
 
 	ret = io_getevents(io_ctx, 1, seg_size, events, &timeout);
 
-	/* This error handling is for any error in collecting the
-	IO requests. The errors, if any, for any particular IO
-	request are simply passed on to the calling routine. */
+	if (ret > 0) {
+		for (i = 0; i < ret; i++) {
+			os_aio_slot_t*	slot;
+			struct iocb*	control;
+
+			control = (struct iocb *)events[i].obj;
+			ut_a(control != NULL);
+
+			slot = (os_aio_slot_t *) control->data;
+
+			/* Some sanity checks. */
+			ut_a(slot != NULL);
+			ut_a(slot->reserved);
 
-	/* Not enough resources! Try again. */
-	if (ret == -EAGAIN) {
-		goto retry;
-	}
+#if defined(UNIV_AIO_DEBUG)
+			fprintf(stderr,
+				"io_getevents[%c]: slot[%p] ctx[%p]"
+				" seg[%lu]\n",
+				(slot->type == OS_FILE_WRITE) ? 'w' : 'r',
+				slot, io_ctx, segment);
+#endif
 
-	/* Interrupted! I have tested the behaviour in case of an
-	interrupt. If we have some completed IOs available then
-	the return code will be the number of IOs. We get EINTR only
-	if there are no completed IOs and we have been interrupted. */
-	if (ret == -EINTR) {
-		goto retry;
-	}
+			/* We are not scribbling previous segment. */
+			ut_a(slot->pos >= start_pos);
 
-	/* No pending request! Go back and check again. */
-	if (ret == 0) {
-		goto retry;
-	}
+			/* We have not overstepped to next segment. */
+			ut_a(slot->pos < end_pos);
 
-	/* All other errors! should cause a trap for now. */
-	if (UNIV_UNLIKELY(ret < 0)) {
-		ut_print_timestamp(stderr);
-		fprintf(stderr,
-			"  InnoDB: unexpected ret_code[%d] from"
-			" io_getevents()!\n", ret);
-		ut_error;
+			/* Mark this request as completed. The error handling
+			will be done in the calling function. */
+			os_mutex_enter(array->mutex);
+			slot->n_bytes = events[i].res;
+			slot->ret = events[i].res2;
+			slot->io_already_done = TRUE;
+			os_mutex_exit(array->mutex);
+		}
+		return;
 	}
 
-	ut_a(ret > 0);
-
-	for (i = 0; i < ret; i++) {
-		os_aio_slot_t*	slot;
-		struct iocb*	control;
-
-		control = (struct iocb *)events[i].obj;
-		ut_a(control != NULL);
-
-		slot = (os_aio_slot_t *) control->data;
-
-		/* Some sanity checks. */
-		ut_a(slot != NULL);
-		ut_a(slot->reserved);
-
-#if defined(UNIV_AIO_DEBUG)
-		fprintf(stderr,
-			"io_getevents[%c]: slot[%p] ctx[%p]"
-			" seg[%lu]\n",
-			(slot->type == OS_FILE_WRITE) ? 'w' : 'r',
-			slot, io_ctx, segment);
-#endif
-
-		/* We are not scribbling previous segment. */
-		ut_a(slot->pos >= start_pos);
+	if (UNIV_UNLIKELY(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS)) {
+		return;
+	}
 
-		/* We have not overstepped to next segment. */
-		ut_a(slot->pos < end_pos);
+	/* This error handling is for any error in collecting the
+	IO requests. The errors, if any, for any particular IO
+	request are simply passed on to the calling routine. */
 
-		/* Mark this request as completed. The error handling
-		will be done in the calling function. */
-		os_mutex_enter(array->mutex);
-		slot->n_bytes = events[i].res;
-		slot->ret = events[i].res2;
-		slot->io_already_done = TRUE;
-		os_mutex_exit(array->mutex);
+	switch (ret) {
+	case -EAGAIN:
+		/* Not enough resources! Try again. */
+	case -EINTR:
+		/* Interrupted! I have tested the behaviour in case of an
+		interrupt. If we have some completed IOs available then
+		the return code will be the number of IOs. We get EINTR only
+		if there are no completed IOs and we have been interrupted. */
+	case 0:
+		/* No pending request! Go back and check again. */
+		goto retry;
 	}
 
-	return;
+	/* All other errors should cause a trap for now. */
+	ut_print_timestamp(stderr);
+	fprintf(stderr,
+		"  InnoDB: unexpected ret_code[%d] from io_getevents()!\n",
+		ret);
+	ut_error;
 }
 
 /**********************************************************************//**
@@ -4550,20 +4546,35 @@ os_aio_linux_handle(
 
 	/* Loop until we have found a completed request. */
 	for (;;) {
+		ibool	any_reserved = FALSE;
 		os_mutex_enter(array->mutex);
 		for (i = 0; i < n; ++i) {
 			slot = os_aio_array_get_nth_slot(
-					array, i + segment * n);
-			if (slot->reserved && slot->io_already_done) {
+				array, i + segment * n);
+			if (!slot->reserved) {
+				continue;
+			} else if (slot->io_already_done) {
 				/* Something for us to work on. */
 				goto found;
+			} else {
+				any_reserved = TRUE;
 			}
 		}
 
 		os_mutex_exit(array->mutex);
 
-		/* We don't have any completed request.
-		Wait for some request. Note that we return
+		/* There is no completed request.
+		If there is no pending request at all,
+		and the system is being shut down, exit. */
+		if (UNIV_UNLIKELY
+		    (!any_reserved
+		     && srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS)) {
+			*message1 = NULL;
+			*message2 = NULL;
+			return(TRUE);
+		}
+
+		/* Wait for some request. Note that we return
 		from wait iff we have found a request. */
 
 		srv_set_io_thread_op_info(global_seg,
@@ -4659,6 +4670,7 @@ os_aio_simulated_handle(
 	byte*		combined_buf;
 	byte*		combined_buf2;
 	ibool		ret;
+	ibool		any_reserved;
 	ulint		n;
 	ulint		i;
 
@@ -4689,18 +4701,21 @@ restart:
 		goto recommended_sleep;
 	}
 
-	os_mutex_enter(array->mutex);
-
 	srv_set_io_thread_op_info(global_segment,
 				  "looking for i/o requests (b)");
 
 	/* Check if there is a slot for which the i/o has already been
 	done */
+	any_reserved = FALSE;
+
+	os_mutex_enter(array->mutex);
 
 	for (i = 0; i < n; i++) {
 		slot = os_aio_array_get_nth_slot(array, i + segment * n);
 
-		if (slot->reserved && slot->io_already_done) {
+		if (!slot->reserved) {
+			continue;
+		} else if (slot->io_already_done) {
 
 			if (os_aio_print_debug) {
 				fprintf(stderr,
@@ -4712,9 +4727,23 @@ restart:
 			ret = TRUE;
 
 			goto slot_io_done;
+		} else {
+			any_reserved = TRUE;
 		}
 	}
 
+	/* There is no completed request.
+	If there is no pending request at all,
+	and the system is being shut down, exit. */
+	if (UNIV_UNLIKELY
+	    (!any_reserved
+	     && srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS)) {
+		os_mutex_exit(array->mutex);
+		*message1 = NULL;
+		*message2 = NULL;
+		return(TRUE);
+	}
+
 	n_consecutive = 0;
 
 	/* If there are at least 2 seconds old requests, then pick the oldest

=== modified file 'storage/innobase/os/os0sync.c'
--- a/storage/innobase/os/os0sync.c	2011-02-15 09:40:34 +0000
+++ b/storage/innobase/os/os0sync.c	2011-04-05 11:12:48 +0000
@@ -570,10 +570,7 @@ os_event_free(
 }
 
 /**********************************************************//**
-Waits for an event object until it is in the signaled state. If
-srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the
-waiting thread when the event becomes signaled (or immediately if the
-event is already in the signaled state).
+Waits for an event object until it is in the signaled state.
 
 Typically, if the event has been signalled after the os_event_reset()
 we'll return immediately because event->is_set == TRUE.
@@ -598,8 +595,6 @@ os_event_wait_low(
 					returned by previous call of
 					os_event_reset(). */
 {
-	ib_int64_t	old_signal_count;
-
 #ifdef __WIN__
 	if(!srv_use_native_conditions) {
 		DWORD	err;
@@ -612,43 +607,25 @@ os_event_wait_low(
 		err = WaitForSingleObject(event->handle, INFINITE);
 
 		ut_a(err == WAIT_OBJECT_0);
-
-		if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
-			os_thread_exit(NULL);
-		}
 		return;
 	}
 #endif
 
-	os_fast_mutex_lock(&(event->os_mutex));
+	os_fast_mutex_lock(&event->os_mutex);
 
-	if (reset_sig_count) {
-		old_signal_count = reset_sig_count;
-	} else {
-		old_signal_count = event->signal_count;
+	if (!reset_sig_count) {
+		reset_sig_count = event->signal_count;
 	}
 
-	for (;;) {
-		if (event->is_set == TRUE
-		    || event->signal_count != old_signal_count) {
-
-			os_fast_mutex_unlock(&(event->os_mutex));
-
-			if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
-
-				os_thread_exit(NULL);
-			}
-			/* Ok, we may return */
-
-			return;
-		}
-
+	while (!event->is_set && event->signal_count == reset_sig_count) {
 		os_cond_wait(&(event->cond_var), &(event->os_mutex));
 
 		/* Solaris manual said that spurious wakeups may occur: we
 		have to check if the event really has been signaled after
 		we came here to wait */
 	}
+
+	os_fast_mutex_unlock(&event->os_mutex);
 }
 
 /**********************************************************//**
@@ -669,7 +646,6 @@ os_event_wait_time_low(
 
 {
 	ibool		timed_out = FALSE;
-	ib_int64_t	old_signal_count;
 
 #ifdef __WIN__
 	DWORD		time_in_ms;
@@ -739,15 +715,12 @@ os_event_wait_time_low(
 
 	os_fast_mutex_lock(&event->os_mutex);
 
-	if (reset_sig_count) {
-		old_signal_count = reset_sig_count;
-	} else {
-		old_signal_count = event->signal_count;
+	if (!reset_sig_count) {
+		reset_sig_count = event->signal_count;
 	}
 
 	do {
-		if (event->is_set == TRUE
-		    || event->signal_count != old_signal_count) {
+		if (event->is_set || event->signal_count != reset_sig_count) {
 
 			break;
 		}
@@ -765,11 +738,6 @@ os_event_wait_time_low(
 
 	os_fast_mutex_unlock(&event->os_mutex);
 
-	if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
-
-		os_thread_exit(NULL);
-	}
-
 	return(timed_out ? OS_SYNC_TIME_EXCEEDED : 0);
 }
 

=== modified file 'storage/innobase/os/os0thread.c'
--- a/storage/innobase/os/os0thread.c	2010-07-29 10:44:35 +0000
+++ b/storage/innobase/os/os0thread.c	2011-04-05 11:25:38 +0000
@@ -220,21 +220,6 @@ os_thread_exit(
 }
 
 /*****************************************************************//**
-Returns handle to the current thread.
-@return	current thread handle */
-UNIV_INTERN
-os_thread_t
-os_thread_get_curr(void)
-/*====================*/
-{
-#ifdef __WIN__
-	return(GetCurrentThread());
-#else
-	return(pthread_self());
-#endif
-}
-
-/*****************************************************************//**
 Advises the os to give up remainder of the thread's time slice. */
 UNIV_INTERN
 void
@@ -274,81 +259,3 @@ os_thread_sleep(
 	select(0, NULL, NULL, NULL, &t);
 #endif
 }
-
-#ifndef UNIV_HOTBACKUP
-/******************************************************************//**
-Sets a thread priority. */
-UNIV_INTERN
-void
-os_thread_set_priority(
-/*===================*/
-	os_thread_t	handle,	/*!< in: OS handle to the thread */
-	ulint		pri)	/*!< in: priority */
-{
-#ifdef __WIN__
-	int	os_pri;
-
-	if (pri == OS_THREAD_PRIORITY_BACKGROUND) {
-		os_pri = THREAD_PRIORITY_BELOW_NORMAL;
-	} else if (pri == OS_THREAD_PRIORITY_NORMAL) {
-		os_pri = THREAD_PRIORITY_NORMAL;
-	} else if (pri == OS_THREAD_PRIORITY_ABOVE_NORMAL) {
-		os_pri = THREAD_PRIORITY_HIGHEST;
-	} else {
-		ut_error;
-	}
-
-	ut_a(SetThreadPriority(handle, os_pri));
-#else
-	UT_NOT_USED(handle);
-	UT_NOT_USED(pri);
-#endif
-}
-
-/******************************************************************//**
-Gets a thread priority.
-@return	priority */
-UNIV_INTERN
-ulint
-os_thread_get_priority(
-/*===================*/
-	os_thread_t	handle __attribute__((unused)))
-				/*!< in: OS handle to the thread */
-{
-#ifdef __WIN__
-	int	os_pri;
-	ulint	pri;
-
-	os_pri = GetThreadPriority(handle);
-
-	if (os_pri == THREAD_PRIORITY_BELOW_NORMAL) {
-		pri = OS_THREAD_PRIORITY_BACKGROUND;
-	} else if (os_pri == THREAD_PRIORITY_NORMAL) {
-		pri = OS_THREAD_PRIORITY_NORMAL;
-	} else if (os_pri == THREAD_PRIORITY_HIGHEST) {
-		pri = OS_THREAD_PRIORITY_ABOVE_NORMAL;
-	} else {
-		ut_error;
-	}
-
-	return(pri);
-#else
-	return(0);
-#endif
-}
-
-/******************************************************************//**
-Gets the last operating system error code for the calling thread.
-@return	last error on Windows, 0 otherwise */
-UNIV_INTERN
-ulint
-os_thread_get_last_error(void)
-/*==========================*/
-{
-#ifdef __WIN__
-	return(GetLastError());
-#else
-	return(0);
-#endif
-}
-#endif /* !UNIV_HOTBACKUP */

=== modified file 'storage/innobase/page/page0zip.c'
--- a/storage/innobase/page/page0zip.c	2011-03-18 15:48:14 +0000
+++ b/storage/innobase/page/page0zip.c	2011-04-13 08:34:16 +0000
@@ -46,6 +46,7 @@ Created June 2005 by Marko Makela
 #else /* !UNIV_HOTBACKUP */
 # define lock_move_reorganize_page(block, temp_block)	((void) 0)
 # define buf_LRU_stat_inc_unzip()			((void) 0)
+# define MONITOR_INC(x)					((void) 0)
 #endif /* !UNIV_HOTBACKUP */
 
 #ifndef UNIV_HOTBACKUP
@@ -4426,7 +4427,9 @@ page_zip_reorganize(
 	dict_index_t*	index,	/*!< in: index of the B-tree node */
 	mtr_t*		mtr)	/*!< in: mini-transaction */
 {
+#ifndef UNIV_HOTBACKUP
 	buf_pool_t*	buf_pool	= buf_pool_from_block(block);
+#endif /* !UNIV_HOTBACKUP */
 	page_zip_des_t*	page_zip	= buf_block_get_page_zip(block);
 	page_t*		page		= buf_block_get_frame(block);
 	buf_block_t*	temp_block;

=== modified file 'storage/innobase/que/que0que.c'
--- a/storage/innobase/que/que0que.c	2011-02-07 11:23:17 +0000
+++ b/storage/innobase/que/que0que.c	2011-04-12 07:53:47 +0000
@@ -1155,8 +1155,8 @@ que_run_threads_low(
 	do {
 		/* Check that there is enough space in the log to accommodate
 		possible log entries by this query step; if the operation can
-	       	touch more than about 4 pages, checks must be made also within
-	       	the query step! */
+		touch more than about 4 pages, checks must be made also within
+		the query step! */
 
 		log_free_check();
 
@@ -1175,7 +1175,7 @@ que_run_threads_low(
 			ut_a(next_thr == NULL);
 
 			/* This can change next_thr to a non-NULL value
-		       	if there was a lock wait that already completed. */
+			if there was a lock wait that already completed. */
 
 			que_thr_dec_refer_count(thr, &next_thr);
 
@@ -1216,9 +1216,6 @@ loop:
 		goto loop;
 
 	case QUE_THR_LOCK_WAIT:
-		/* The ..._mysql_... function works also for InnoDB's
-		internal threads. Let us wait that the lock wait ends. */
-
 		lock_wait_suspend_thread(thr);
 
 		trx_mutex_enter(thr_get_trx(thr));

=== modified file 'storage/innobase/row/row0merge.c'
--- a/storage/innobase/row/row0merge.c	2011-03-30 12:20:45 +0000
+++ b/storage/innobase/row/row0merge.c	2011-04-05 11:12:48 +0000
@@ -1929,8 +1929,6 @@ row_merge_lock_table(
 	sel_node_t*	node;
 
 	ut_ad(trx);
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
 	ut_ad(mode == LOCK_X || mode == LOCK_S);
 
 	heap = mem_heap_create(512);
@@ -2403,8 +2401,6 @@ row_merge_rename_tables(
 	pars_info_t*	info;
 	char		old_name[MAX_FULL_NAME_LEN + 1];
 
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
 	ut_ad(old_table != new_table);
 	ut_ad(mutex_own(&dict_sys->mutex));
 

=== modified file 'storage/innobase/row/row0mysql.c'
--- a/storage/innobase/row/row0mysql.c	2011-03-30 12:20:45 +0000
+++ b/storage/innobase/row/row0mysql.c	2011-04-08 18:42:14 +0000
@@ -791,25 +791,37 @@ row_prebuilt_free(
 		mem_heap_free(prebuilt->old_vers_heap);
 	}
 
-	for (i = 0; i < MYSQL_FETCH_CACHE_SIZE; i++) {
-		if (prebuilt->fetch_cache[i] != NULL) {
+	if (prebuilt->fetch_cache[0] != NULL) {
+		byte*	base = prebuilt->fetch_cache[0] - 4;
+		byte*	ptr = base;
+
+		for (i = 0; i < MYSQL_FETCH_CACHE_SIZE; i++) {
+			byte*	row;
+			ulint	magic1;
+			ulint	magic2;
+
+			magic1 = mach_read_from_4(ptr);
+			ptr += 4;
+
+			row = ptr;
+			ptr += prebuilt->mysql_row_len;
+
+			magic2 = mach_read_from_4(ptr);
+			ptr += 4;
+
+			if (ROW_PREBUILT_FETCH_MAGIC_N != magic1
+			    || row != prebuilt->fetch_cache[i]
+			    || ROW_PREBUILT_FETCH_MAGIC_N != magic2) {
 
-			if ((ROW_PREBUILT_FETCH_MAGIC_N != mach_read_from_4(
-				     (prebuilt->fetch_cache[i]) - 4))
-			    || (ROW_PREBUILT_FETCH_MAGIC_N != mach_read_from_4(
-					(prebuilt->fetch_cache[i])
-					+ prebuilt->mysql_row_len))) {
 				fputs("InnoDB: Error: trying to free"
-				      " a corrupt fetch buffer.\n", stderr);
-
-				mem_analyze_corruption(
-					prebuilt->fetch_cache[i]);
+					" a corrupt fetch buffer.\n", stderr);
 
+				mem_analyze_corruption(base);
 				ut_error;
 			}
-
-			mem_free((prebuilt->fetch_cache[i]) - 4);
 		}
+
+		mem_free(base);
 	}
 
 	dict_table_close(prebuilt->table, dict_locked);
@@ -967,8 +979,6 @@ row_lock_table_autoinc_for_mysql(
 	ibool			was_lock_wait;
 
 	ut_ad(trx);
-	ut_ad(trx->mysql_thd != NULL
-	      && trx->mysql_thread_id == os_thread_get_curr_id());
 
 	/* If we already hold an AUTOINC lock on the table then do nothing.
         Note: We peek at the value of the current owner without acquiring
@@ -1048,8 +1058,6 @@ row_lock_table_for_mysql(
 	ibool		was_lock_wait;
 
 	ut_ad(trx);
-	ut_ad(trx->mysql_thd != NULL
-	      && trx->mysql_thread_id == os_thread_get_curr_id());
 
 	trx->op_info = "setting table lock";
 
@@ -1123,8 +1131,6 @@ row_insert_for_mysql(
 	ins_node_t*	node		= prebuilt->ins_node;
 
 	ut_ad(trx);
-	ut_ad(trx->mysql_thd != NULL
-	      && trx->mysql_thread_id == os_thread_get_curr_id());
 
 	if (prebuilt->table->ibd_file_missing) {
 		ut_print_timestamp(stderr);
@@ -1360,8 +1366,6 @@ row_update_for_mysql(
 	trx_t*		trx		= prebuilt->trx;
 
 	ut_ad(prebuilt && trx);
-	ut_ad(trx->mysql_thd != NULL
-	      && trx->mysql_thread_id == os_thread_get_curr_id());
 	UT_NOT_USED(mysql_rec);
 
 	if (prebuilt->table->ibd_file_missing) {
@@ -1529,8 +1533,6 @@ row_unlock_for_mysql(
 	trx_t*		trx		= prebuilt->trx;
 
 	ut_ad(prebuilt && trx);
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
 
 	if (UNIV_UNLIKELY
 	    (!srv_locks_unsafe_for_binlog
@@ -1830,8 +1832,6 @@ row_create_table_for_mysql(
 	ulint		table_name_len;
 	ulint		err;
 
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX));
 #endif /* UNIV_SYNC_DEBUG */
@@ -2014,8 +2014,6 @@ row_create_index_for_mysql(
 	ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX));
 #endif /* UNIV_SYNC_DEBUG */
 	ut_ad(mutex_own(&(dict_sys->mutex)));
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
 
 	trx->op_info = "creating index";
 
@@ -2418,9 +2416,6 @@ row_discard_tablespace_for_mysql(
 	table->n_foreign_key_checks_running > 0, we do not allow the
 	discard. We also reserve the data dictionary latch. */
 
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
-
 	trx->op_info = "discarding tablespace";
 	trx_start_if_not_started_xa(trx);
 
@@ -2585,9 +2580,6 @@ row_import_tablespace_for_mysql(
 	lsn_t		current_lsn;
 	ulint		err		= DB_SUCCESS;
 
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
-
 	trx_start_if_not_started_xa(trx);
 
 	trx->op_info = "importing tablespace";
@@ -2778,8 +2770,6 @@ row_truncate_table_for_mysql(
 	redo log records on the truncated tablespace, we will assign
 	a new tablespace identifier to the truncated tablespace. */
 
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
 	ut_ad(table);
 
 	if (srv_created_new_raw) {
@@ -3272,12 +3262,12 @@ check_next_foreign:
 		CREATE TABLE t2 (PRIMARY KEY (a)) SELECT * FROM t1;
 
 	If after the user transaction has done the SELECT and there is a
-       	problem in completing the CREATE TABLE operation, MySQL will drop
-       	the table. InnoDB will create a new background transaction to do the
-       	actual drop, the trx instance that is passed to this function. To
-       	preserve existing behaviour we remove the locks but ideally we
-       	shouldn't have to. There should never be record locks on a table
-       	that is going to be dropped. */
+	problem in completing the CREATE TABLE operation, MySQL will drop
+	the table. InnoDB will create a new background transaction to do the
+	actual drop, the trx instance that is passed to this function. To
+	preserve existing behaviour we remove the locks but ideally we
+	shouldn't have to. There should never be record locks on a table
+	that is going to be dropped. */
 
 	if (table->n_ref_count == 0) {
 		lock_remove_all_on_table(table, TRUE);
@@ -3311,7 +3301,7 @@ check_next_foreign:
 	}
 
 	/* If we get this far then the table to be dropped must not have
-       	any table or record locks on it. */
+	any table or record locks on it. */
 
 	ut_a(!lock_table_has_locks(table));
 
@@ -3676,8 +3666,6 @@ row_drop_database_for_mysql(
 	int	err	= DB_SUCCESS;
 	ulint	namelen	= strlen(name);
 
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
 	ut_a(name != NULL);
 	ut_a(name[namelen - 1] == '/');
 
@@ -3850,8 +3838,6 @@ row_rename_table_for_mysql(
 	ibool		old_is_tmp, new_is_tmp;
 	pars_info_t*	info			= NULL;
 
-	ut_ad(trx->mysql_thd != NULL
-	      && trx->mysql_thread_id == os_thread_get_curr_id());
 	ut_a(old_name != NULL);
 	ut_a(new_name != NULL);
 

=== modified file 'storage/innobase/row/row0row.c'
--- a/storage/innobase/row/row0row.c	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/row/row0row.c	2011-04-08 18:42:14 +0000
@@ -298,7 +298,8 @@ row_build(
 		/* REDUNDANT and COMPACT formats store a local
 		768-byte prefix of each externally stored
 		column. No cache is needed. */
-		ut_ad(dict_table_get_format(index->table) < UNIV_FORMAT_B);
+		ut_ad(dict_table_get_format(index->table)
+		      < UNIV_FORMAT_B);
 	} else if (j) {
 		*ext = row_ext_create(j, ext_cols, row,
 				      dict_table_zip_size(index->table),

=== modified file 'storage/innobase/row/row0sel.c'
--- a/storage/innobase/row/row0sel.c	2011-04-13 18:43:08 +0000
+++ b/storage/innobase/row/row0sel.c	2011-04-21 05:35:17 +0000
@@ -526,8 +526,8 @@ Pops the column values for a prefetched,
 buffers and places them to the val fields in the column nodes. */
 static
 void
-sel_pop_prefetched_row(
-/*===================*/
+sel_dequeue_prefetched_row(
+/*=======================*/
 	plan_t*	plan)	/*!< in: plan node for a table */
 {
 	sym_node_t*	column;
@@ -588,8 +588,8 @@ Pushes the column values for a prefetche
 buffers from the val fields in the column nodes. */
 UNIV_INLINE
 void
-sel_push_prefetched_row(
-/*====================*/
+sel_enqueue_prefetched_row(
+/*=======================*/
 	plan_t*	plan)	/*!< in: plan node for a table */
 {
 	sym_node_t*	column;
@@ -1365,7 +1365,7 @@ table_loop:
 	index = plan->index;
 
 	if (plan->n_rows_prefetched > 0) {
-		sel_pop_prefetched_row(plan);
+		sel_dequeue_prefetched_row(plan);
 
 		goto next_table_no_mtr;
 	}
@@ -1811,13 +1811,13 @@ skip_lock:
 		goto next_table;
 	}
 
-	sel_push_prefetched_row(plan);
+	sel_enqueue_prefetched_row(plan);
 
 	if (plan->n_rows_prefetched == SEL_MAX_N_PREFETCH) {
 
 		/* The prefetch buffer is now full */
 
-		sel_pop_prefetched_row(plan);
+		sel_dequeue_prefetched_row(plan);
 
 		goto next_table;
 	}
@@ -1916,7 +1916,7 @@ table_exhausted:
 	if (plan->n_rows_prefetched > 0) {
 		/* The table became exhausted during a prefetch */
 
-		sel_pop_prefetched_row(plan);
+		sel_dequeue_prefetched_row(plan);
 
 		goto next_table_no_mtr;
 	}
@@ -1962,7 +1962,7 @@ stop_for_a_while:
 	mtr_commit(&mtr);
 
 #ifdef UNIV_SYNC_DEBUG
-	ut_ad(sync_thread_levels_empty_gen(TRUE));
+	ut_ad(sync_thread_levels_empty_except_dict());
 #endif /* UNIV_SYNC_DEBUG */
 	err = DB_SUCCESS;
 	goto func_exit;
@@ -1982,7 +1982,7 @@ commit_mtr_for_a_while:
 	mtr_has_extra_clust_latch = FALSE;
 
 #ifdef UNIV_SYNC_DEBUG
-	ut_ad(sync_thread_levels_empty_gen(TRUE));
+	ut_ad(sync_thread_levels_empty_except_dict());
 #endif /* UNIV_SYNC_DEBUG */
 
 	goto table_loop;
@@ -1999,7 +1999,7 @@ lock_wait_or_error:
 	mtr_commit(&mtr);
 
 #ifdef UNIV_SYNC_DEBUG
-	ut_ad(sync_thread_levels_empty_gen(TRUE));
+	ut_ad(sync_thread_levels_empty_except_dict());
 #endif /* UNIV_SYNC_DEBUG */
 
 func_exit:
@@ -3229,8 +3229,8 @@ sel_restore_position_for_mysql(
 Pops a cached row for MySQL from the fetch cache. */
 UNIV_INLINE
 void
-row_sel_pop_cached_row_for_mysql(
-/*=============================*/
+row_sel_dequeue_cached_row_for_mysql(
+/*=================================*/
 	byte*		buf,		/*!< in/out: buffer where to copy the
 					row */
 	row_prebuilt_t*	prebuilt)	/*!< in: prebuilt struct */
@@ -3286,37 +3286,55 @@ row_sel_pop_cached_row_for_mysql(
 }
 
 /********************************************************************//**
+Initialise the prefetch cache. */
+UNIV_INLINE
+void
+row_sel_prefetch_cache_init(
+/*========================*/
+	row_prebuilt_t*	prebuilt)	/*!< in/out: prebuilt struct */
+{
+	ulint	i;
+	ulint	sz;
+	byte*	ptr;
+
+	/* Reserve space for the magic number. */
+	sz = UT_ARR_SIZE(prebuilt->fetch_cache) * (prebuilt->mysql_row_len + 8);
+	ptr = mem_alloc(sz);
+
+	for (i = 0; i < UT_ARR_SIZE(prebuilt->fetch_cache); i++) {
+
+		/* A user has reported memory corruption in these
+		buffers in Linux. Put magic numbers there to help
+		to track a possible bug. */
+
+		mach_write_to_4(ptr, ROW_PREBUILT_FETCH_MAGIC_N);
+		ptr += 4;
+
+		prebuilt->fetch_cache[i] = ptr;
+		ptr += prebuilt->mysql_row_len;
+
+		mach_write_to_4(ptr, ROW_PREBUILT_FETCH_MAGIC_N);
+		ptr += 4;
+	}
+}
+
+/********************************************************************//**
 Pushes a row for MySQL to the fetch cache. */
 UNIV_INLINE
 void
-row_sel_push_cache_row_for_mysql(
-/*=============================*/
+row_sel_enqueue_cache_row_for_mysql(
+/*================================*/
 	byte*		mysql_rec,	/*!< in/out: MySQL record */
 	row_prebuilt_t*	prebuilt)	/*!< in/out: prebuilt struct */
 {
 	ut_a(prebuilt->n_fetch_cached < MYSQL_FETCH_CACHE_SIZE);
 	ut_a(!prebuilt->templ_contains_blob);
 
-	if (UNIV_UNLIKELY(prebuilt->fetch_cache[0] == NULL)) {
-		ulint	i;
+	if (prebuilt->fetch_cache[0] == NULL) {
 		/* Allocate memory for the fetch cache */
 		ut_ad(prebuilt->n_fetch_cached == 0);
 
-		for (i = 0; i < MYSQL_FETCH_CACHE_SIZE; i++) {
-			byte*	buf;
-
-			/* A user has reported memory corruption in these
-			buffers in Linux. Put magic numbers there to help
-			to track a possible bug. */
-
-			buf = mem_alloc(prebuilt->mysql_row_len + 8);
-
-			prebuilt->fetch_cache[i] = buf + 4;
-
-			mach_write_to_4(buf, ROW_PREBUILT_FETCH_MAGIC_N);
-			mach_write_to_4(buf + 4 + prebuilt->mysql_row_len,
-					ROW_PREBUILT_FETCH_MAGIC_N);
-		}
+		row_sel_prefetch_cache_init(prebuilt);
 	}
 
 	ut_ad(prebuilt->fetch_cache_first == 0);
@@ -3550,8 +3568,6 @@ row_search_for_mysql(
 	rec_offs_init(offsets_);
 
 	ut_ad(index && pcur && search_tuple);
-	ut_ad(trx->mysql_thd == NULL
-	      || trx->mysql_thread_id == os_thread_get_curr_id());
 
 	if (UNIV_UNLIKELY(prebuilt->table->ibd_file_missing)) {
 		ut_print_timestamp(stderr);
@@ -3568,11 +3584,17 @@ row_search_for_mysql(
 			"InnoDB: how you can resolve the problem.\n",
 			prebuilt->table->name);
 
+#ifdef UNIV_SYNC_DEBUG
+		ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
+#endif /* UNIV_SYNC_DEBUG */
 		return(DB_ERROR);
 	}
 
 	if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
 
+#ifdef UNIV_SYNC_DEBUG
+		ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
+#endif /* UNIV_SYNC_DEBUG */
 		return(DB_MISSING_HISTORY);
 	}
 
@@ -3676,7 +3698,7 @@ row_search_for_mysql(
 			prebuilt->fetch_cache_first = 0;
 
 		} else if (UNIV_LIKELY(prebuilt->n_fetch_cached > 0)) {
-			row_sel_pop_cached_row_for_mysql(buf, prebuilt);
+			row_sel_dequeue_cached_row_for_mysql(buf, prebuilt);
 
 			prebuilt->n_rows_fetched++;
 
@@ -4682,7 +4704,7 @@ requires_clust_rec:
 			goto next_rec;
 		}
 
-		row_sel_push_cache_row_for_mysql(buf, prebuilt);
+		row_sel_enqueue_cache_row_for_mysql(buf, prebuilt);
 
 		if (prebuilt->n_fetch_cached < MYSQL_FETCH_CACHE_SIZE) {
 			goto next_rec;
@@ -4917,7 +4939,7 @@ normal_return:
 	mtr_commit(&mtr);
 
 	if (prebuilt->n_fetch_cached > 0) {
-		row_sel_pop_cached_row_for_mysql(buf, prebuilt);
+		row_sel_dequeue_cached_row_for_mysql(buf, prebuilt);
 
 		err = DB_SUCCESS;
 	}
@@ -4950,6 +4972,10 @@ func_exit:
 			prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT;
 		}
 	}
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
+#endif /* UNIV_SYNC_DEBUG */
 	return(err);
 }
 

=== modified file 'storage/innobase/row/row0uins.c'
--- a/storage/innobase/row/row0uins.c	2010-10-20 08:54:44 +0000
+++ b/storage/innobase/row/row0uins.c	2011-04-20 10:47:27 +0000
@@ -97,15 +97,12 @@ row_undo_ins_remove_clust_rec(
 
 	btr_cur = btr_pcur_get_btr_cur(&(node->pcur));
 
-	success = btr_cur_optimistic_delete(btr_cur, &mtr);
-
-	btr_pcur_commit_specify_mtr(&(node->pcur), &mtr);
-
-	if (success) {
-		trx_undo_rec_release(node->trx, node->undo_no);
-
-		return(DB_SUCCESS);
+	if (btr_cur_optimistic_delete(btr_cur, &mtr)) {
+		err = DB_SUCCESS;
+		goto func_exit;
 	}
+
+	btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
 retry:
 	/* If did not succeed, try pessimistic descent to tree */
 	mtr_start(&mtr);
@@ -135,8 +132,8 @@ retry:
 		goto retry;
 	}
 
-	btr_pcur_commit_specify_mtr(&(node->pcur), &mtr);
-
+func_exit:
+	btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
 	trx_undo_rec_release(node->trx, node->undo_no);
 
 	return(err);

=== modified file 'storage/innobase/row/row0upd.c'
--- a/storage/innobase/row/row0upd.c	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/row/row0upd.c	2011-04-20 10:47:27 +0000
@@ -2205,8 +2205,7 @@ exit_func:
 
 	if (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE) {
 
-		err = row_upd_clust_rec(node, index, thr, mtr);
-		return(err);
+		return(row_upd_clust_rec(node, index, thr, mtr));
 	}
 
 	row_upd_store_row(node);

=== added file 'storage/innobase/srv/srv0conc.c'
--- a/storage/innobase/srv/srv0conc.c	1970-01-01 00:00:00 +0000
+++ b/storage/innobase/srv/srv0conc.c	2011-04-18 02:17:16 +0000
@@ -0,0 +1,445 @@
+/*****************************************************************************
+
+Copyright (c) 2011, Oracle and/or its affiliates. All Rights Reserved.
+
+Portions of this file contain modifications contributed and copyrighted by
+Google, Inc. Those modifications are gratefully acknowledged and are described
+briefly in the InnoDB documentation. The contributions by Google are
+incorporated with their permission, and subject to the conditions contained in
+the file COPYING.Google.
+
+Portions of this file contain modifications contributed and copyrighted
+by Percona Inc.. Those modifications are
+gratefully acknowledged and are described briefly in the InnoDB
+documentation. The contributions by Percona Inc. are incorporated with
+their permission, and subject to the conditions contained in the file
+COPYING.Percona.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/**************************************************//**
+@file srv/srv0conc.c
+
+InnoDB concurrency manager
+
+Created 2011/04/18 Sunny Bains
+*******************************************************/
+
+#include "srv0srv.h"
+#include "sync0sync.h"
+#include "trx0trx.h"
+
+#include "mysql/plugin.h"
+#include "mysql/service_thd_wait.h"	/* MySQL callback functions */
+
+/** We are prepared for a situation that we have this many threads waiting for
+a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets the
+value. */
+
+UNIV_INTERN ulint	srv_max_n_threads	= 0;
+
+/** The following controls how many threads we let inside InnoDB concurrently:
+threads waiting for locks are not counted into the number because otherwise
+we could get a deadlock. MySQL creates a thread for each user session, and
+semaphore contention and convoy problems can occur withput this restriction.
+Value 10 should be good if there are less than 4 processors + 4 disks in the
+computer. Bigger computers need bigger values. Value 0 will disable the
+concurrency check. */
+
+UNIV_INTERN ulong	srv_thread_concurrency	= 0;
+
+/** Number of transactions that have declared_to_be_inside_innodb set.
+It used to be a non-error for this value to drop below zero temporarily.
+This is no longer true. We'll, however, keep the lint datatype to add
+assertions to catch any corner cases that we may have missed. */
+
+UNIV_INTERN lint	srv_conc_n_threads	= 0;
+
+/** This mutex protects srv_conc data structures */
+static os_fast_mutex_t	srv_conc_mutex;
+
+/** Number of OS threads waiting in the FIFO for a permission to enter
+InnoDB */
+static ulint		srv_conc_n_waiting_threads = 0;
+
+/** Slot for a thread waiting in the concurrency control queue. */
+typedef struct srv_conc_slot_struct	srv_conc_slot_t;
+
+/** Concurrency list node */
+typedef UT_LIST_NODE_T(srv_conc_slot_t)	srv_conc_node_t;
+
+struct srv_conc_slot_struct{
+	os_event_t	event;		/*!< event to wait */
+	ibool		reserved;	/*!< TRUE if slot
+					reserved */
+	ibool		wait_ended;	/*!< TRUE when another thread has
+					already set the event and the thread
+					in this slot is free to proceed; but
+					reserved may still be TRUE at that
+					point */
+	srv_conc_node_t	srv_conc_queue;	/*!< queue node */
+};
+
+/** Queue of threads waiting to get in */
+typedef UT_LIST_BASE_NODE_T(srv_conc_slot_t)	srv_conc_queue_t;
+
+static srv_conc_queue_t	srv_conc_queue;
+
+/** Array of wait slots */
+static srv_conc_slot_t*	srv_conc_slots;
+
+/* Number of times a thread is allowed to enter InnoDB within the same
+SQL query after it has once got the ticket at srv_conc_enter_innodb */
+#define SRV_FREE_TICKETS_TO_ENTER srv_n_free_tickets_to_enter
+#define SRV_THREAD_SLEEP_DELAY srv_thread_sleep_delay
+
+#ifdef UNIV_PFS_MUTEX
+/* Key to register srv_conc_mutex_key with performance schema */
+UNIV_INTERN mysql_pfs_key_t	srv_conc_mutex_key;
+#endif /* UNIV_PFS_MUTEX */
+
+
+/*********************************************************************//**
+Initialise the concurrency management data structures */
+void
+srv_conc_init(void)
+/*===============*/
+{
+	ulint		i;
+
+	/* Init the server concurrency restriction data structures */
+
+	os_fast_mutex_init(srv_conc_mutex_key, &srv_conc_mutex);
+
+	UT_LIST_INIT(srv_conc_queue);
+
+	srv_conc_slots = mem_zalloc(OS_THREAD_MAX_N * sizeof(*srv_conc_slots));
+
+	for (i = 0; i < OS_THREAD_MAX_N; i++) {
+		srv_conc_slot_t*	conc_slot = &srv_conc_slots[i];
+
+		conc_slot->event = os_event_create(NULL);
+		ut_a(conc_slot->event);
+	}
+}
+
+/*********************************************************************//**
+Free the concurrency management data structures */
+void
+srv_conc_free(void)
+/*===============*/
+{
+	os_fast_mutex_free(&srv_conc_mutex);
+	mem_free(srv_conc_slots);
+	srv_conc_slots = NULL;
+}
+
+/*********************************************************************//**
+Puts an OS thread to wait if there are too many concurrent threads
+(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
+UNIV_INTERN
+void
+srv_conc_enter_innodb(
+/*==================*/
+	trx_t*	trx)	/*!< in: transaction object associated with the
+			thread */
+{
+	ibool			has_slept = FALSE;
+	srv_conc_slot_t*	slot = NULL;
+	ulint			i;
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
+#endif /* UNIV_SYNC_DEBUG */
+
+	if (trx->mysql_thd != NULL
+	    && thd_is_replication_slave_thread(trx->mysql_thd)) {
+
+		UT_WAIT_FOR(srv_conc_n_threads
+			    < (lint)srv_thread_concurrency,
+			    srv_replication_delay * 1000);
+
+		return;
+	}
+
+	/* If trx has 'free tickets' to enter the engine left, then use one
+	such ticket */
+
+	if (trx->n_tickets_to_enter_innodb > 0) {
+		trx->n_tickets_to_enter_innodb--;
+
+		return;
+	}
+
+	os_fast_mutex_lock(&srv_conc_mutex);
+retry:
+	if (UNIV_UNLIKELY(trx->declared_to_be_inside_innodb)) {
+		os_fast_mutex_unlock(&srv_conc_mutex);
+		ut_print_timestamp(stderr);
+		fputs("  InnoDB: Error: trying to declare trx"
+		      " to enter InnoDB, but\n"
+		      "InnoDB: it already is declared.\n", stderr);
+		trx_print(stderr, trx, 0);
+		putc('\n', stderr);
+
+		return;
+	}
+
+	ut_ad(srv_conc_n_threads >= 0);
+
+	if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
+
+		srv_conc_n_threads++;
+		trx->declared_to_be_inside_innodb = TRUE;
+		trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
+
+		os_fast_mutex_unlock(&srv_conc_mutex);
+
+		return;
+	}
+
+	/* If the transaction is not holding resources, let it sleep
+	for SRV_THREAD_SLEEP_DELAY microseconds, and try again then */
+
+	if (!has_slept && !trx->has_search_latch
+	    && NULL == UT_LIST_GET_FIRST(trx->lock.trx_locks)) {
+
+		has_slept = TRUE; /* We let it sleep only once to avoid
+				starvation */
+
+		srv_conc_n_waiting_threads++;
+
+		os_fast_mutex_unlock(&srv_conc_mutex);
+
+		trx->op_info = "sleeping before joining InnoDB queue";
+
+		/* Peter Zaitsev suggested that we take the sleep away
+		altogether. But the sleep may be good in pathological
+		situations of lots of thread switches. Simply put some
+		threads aside for a while to reduce the number of thread
+		switches. */
+		if (SRV_THREAD_SLEEP_DELAY > 0) {
+			os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
+		}
+
+		trx->op_info = "";
+
+		os_fast_mutex_lock(&srv_conc_mutex);
+
+		srv_conc_n_waiting_threads--;
+
+		goto retry;
+	}
+
+	/* Too many threads inside: put the current thread to a queue */
+
+	for (i = 0; i < OS_THREAD_MAX_N; i++) {
+		slot = srv_conc_slots + i;
+
+		if (!slot->reserved) {
+
+			break;
+		}
+	}
+
+	if (i == OS_THREAD_MAX_N) {
+		/* Could not find a free wait slot, we must let the
+		thread enter */
+
+		srv_conc_n_threads++;
+		trx->declared_to_be_inside_innodb = TRUE;
+		trx->n_tickets_to_enter_innodb = 0;
+
+		os_fast_mutex_unlock(&srv_conc_mutex);
+
+		return;
+	}
+
+	/* Release possible search system latch this thread has */
+	if (trx->has_search_latch) {
+		trx_search_latch_release_if_reserved(trx);
+	}
+
+	/* Add to the queue */
+	slot->reserved = TRUE;
+	slot->wait_ended = FALSE;
+
+	UT_LIST_ADD_LAST(srv_conc_queue, srv_conc_queue, slot);
+
+	os_event_reset(slot->event);
+
+	srv_conc_n_waiting_threads++;
+
+	os_fast_mutex_unlock(&srv_conc_mutex);
+
+	/* Go to wait for the event; when a thread leaves InnoDB it will
+	release this thread */
+
+	ut_ad(!trx->has_search_latch);
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
+#endif /* UNIV_SYNC_DEBUG */
+	trx->op_info = "waiting in InnoDB queue";
+
+	thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_TABLE_LOCK);
+	os_event_wait(slot->event);
+	thd_wait_end(trx->mysql_thd);
+
+	trx->op_info = "";
+
+	os_fast_mutex_lock(&srv_conc_mutex);
+
+	srv_conc_n_waiting_threads--;
+
+	/* NOTE that the thread which released this thread already
+	incremented the thread counter on behalf of this thread */
+
+	slot->reserved = FALSE;
+
+	UT_LIST_REMOVE(srv_conc_queue, srv_conc_queue, slot);
+
+	trx->declared_to_be_inside_innodb = TRUE;
+	trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
+
+	os_fast_mutex_unlock(&srv_conc_mutex);
+}
+
+/*********************************************************************//**
+This lets a thread enter InnoDB regardless of the number of threads inside
+InnoDB. This must be called when a thread ends a lock wait. */
+UNIV_INTERN
+void
+srv_conc_force_enter_innodb(
+/*========================*/
+	trx_t*	trx)	/*!< in: transaction object associated with the
+			thread */
+{
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
+#endif /* UNIV_SYNC_DEBUG */
+
+	if (UNIV_LIKELY(!srv_thread_concurrency)) {
+
+		return;
+	}
+
+	ut_ad(srv_conc_n_threads >= 0);
+
+	os_fast_mutex_lock(&srv_conc_mutex);
+
+	srv_conc_n_threads++;
+	trx->declared_to_be_inside_innodb = TRUE;
+	trx->n_tickets_to_enter_innodb = 1;
+
+	os_fast_mutex_unlock(&srv_conc_mutex);
+}
+
+/*********************************************************************//**
+This must be called when a thread exits InnoDB in a lock wait or at the
+end of an SQL statement. */
+UNIV_INTERN
+void
+srv_conc_force_exit_innodb(
+/*=======================*/
+	trx_t*	trx)	/*!< in: transaction object associated with the
+			thread */
+{
+	srv_conc_slot_t*	slot	= NULL;
+
+	if (trx->mysql_thd != NULL
+	    && thd_is_replication_slave_thread(trx->mysql_thd)) {
+
+		return;
+	}
+
+	if (trx->declared_to_be_inside_innodb == FALSE) {
+
+		return;
+	}
+
+	os_fast_mutex_lock(&srv_conc_mutex);
+
+	ut_ad(srv_conc_n_threads > 0);
+	srv_conc_n_threads--;
+	trx->declared_to_be_inside_innodb = FALSE;
+	trx->n_tickets_to_enter_innodb = 0;
+
+	if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
+		/* Look for a slot where a thread is waiting and no other
+		thread has yet released the thread */
+
+		slot = UT_LIST_GET_FIRST(srv_conc_queue);
+
+		while (slot && slot->wait_ended == TRUE) {
+			slot = UT_LIST_GET_NEXT(srv_conc_queue, slot);
+		}
+
+		if (slot != NULL) {
+			slot->wait_ended = TRUE;
+
+			/* We increment the count on behalf of the released
+			thread */
+
+			srv_conc_n_threads++;
+		}
+	}
+
+	os_fast_mutex_unlock(&srv_conc_mutex);
+
+	if (slot != NULL) {
+		os_event_set(slot->event);
+	}
+
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
+#endif /* UNIV_SYNC_DEBUG */
+}
+
+/*********************************************************************//**
+This must be called when a thread exits InnoDB. */
+UNIV_INTERN
+void
+srv_conc_exit_innodb(
+/*=================*/
+	trx_t*	trx)	/*!< in: transaction object associated with the
+			thread */
+{
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
+#endif /* UNIV_SYNC_DEBUG */
+
+	if (trx->n_tickets_to_enter_innodb > 0) {
+		/* We will pretend the thread is still inside InnoDB though it
+		now leaves the InnoDB engine. In this way we save
+		a lot of semaphore operations. srv_conc_force_exit_innodb is
+		used to declare the thread definitely outside InnoDB. It
+		should be called when there is a lock wait or an SQL statement
+		ends. */
+
+		return;
+	}
+
+	srv_conc_force_exit_innodb(trx);
+}
+
+/*********************************************************************//**
+Get the count of threads waiting inside InnoDB. */
+UNIV_INTERN
+ulint
+srv_conc_get_waiting_threads(void)
+/*==============================*/
+{
+	return(srv_conc_n_waiting_threads);
+}

=== modified file 'storage/innobase/srv/srv0mon.c'
--- a/storage/innobase/srv/srv0mon.c	2011-03-09 07:32:36 +0000
+++ b/storage/innobase/srv/srv0mon.c	2011-04-14 06:31:44 +0000
@@ -526,6 +526,10 @@ static monitor_info_t	innodb_counter_inf
 	 " updates on delete marked record with externally stored field",
 	 0, 0, MONITOR_N_UPD_EXIST_EXTERN},
 
+	{"purge_invoked", "purge",
+	 "Number of purge was invoked",
+	 0, 0, MONITOR_PURGE_INVOKED},
+
 	{"purge_undo_log_pages", "purge",
 	 "Number of undo log pages handled by the purge",
 	 0, 0, MONITOR_PURGE_N_PAGE_HANDLED},

=== modified file 'storage/innobase/srv/srv0srv.c'
--- a/storage/innobase/srv/srv0srv.c	2011-03-30 12:02:53 +0000
+++ b/storage/innobase/srv/srv0srv.c	2011-04-19 04:17:07 +0000
@@ -112,6 +112,7 @@ UNIV_INTERN ulint	srv_max_file_format_at
 #if UNIV_FORMAT_A
 # error "UNIV_FORMAT_A must be 0!"
 #endif
+
 /** Place locks to records only i.e. do not use next-key locking except
 on duplicate key checking and foreign key checking */
 UNIV_INTERN ibool	srv_locks_unsafe_for_binlog = FALSE;
@@ -311,64 +312,11 @@ UNIV_INTERN export_struc export_vars;
 the user from forgetting the innodb_force_recovery keyword to my.cnf */
 
 UNIV_INTERN ulint	srv_force_recovery	= 0;
-/*-----------------------*/
-/* We are prepared for a situation that we have this many threads waiting for
-a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets the
-value. */
-
-UNIV_INTERN ulint	srv_max_n_threads	= 0;
-
-/* The following controls how many threads we let inside InnoDB concurrently:
-threads waiting for locks are not counted into the number because otherwise
-we could get a deadlock. MySQL creates a thread for each user session, and
-semaphore contention and convoy problems can occur withput this restriction.
-Value 10 should be good if there are less than 4 processors + 4 disks in the
-computer. Bigger computers need bigger values. Value 0 will disable the
-concurrency check. */
-
-UNIV_INTERN ulong	srv_thread_concurrency	= 0;
-
-/* number of transactions that have declared_to_be_inside_innodb set.
-It used to be a non-error for this value to drop below zero temporarily.
-This is no longer true. We'll, however, keep the lint datatype to add
-assertions to catch any corner cases that we may have missed. */
-UNIV_INTERN lint	srv_conc_n_threads	= 0;
-
-/* print all user-level transactions deadlocks to mysqld stderr */
-UNIV_INTERN my_bool	srv_print_all_deadlocks = FALSE;
 
-/* this mutex protects srv_conc data structures */
-static os_fast_mutex_t	srv_conc_mutex;
+/** Print all user-level transactions deadlocks to mysqld stderr */
 
-/* number of OS threads waiting in the FIFO for a permission to enter
-InnoDB */
-static ulint	srv_conc_n_waiting_threads = 0;
-
-typedef struct srv_conc_slot_struct	srv_conc_slot_t;
-struct srv_conc_slot_struct{
-	os_event_t			event;		/*!< event to wait */
-	ibool				reserved;	/*!< TRUE if slot
-							reserved */
-	ibool				wait_ended;	/*!< TRUE when another
-							thread has already set
-							the event and the
-							thread in this slot is
-							free to proceed; but
-							reserved may still be
-							TRUE at that point */
-	UT_LIST_NODE_T(srv_conc_slot_t)	srv_conc_queue;	/*!< queue node */
-};
+UNIV_INTERN my_bool	srv_print_all_deadlocks = FALSE;
 
-/* queue of threads waiting to get in */
-static UT_LIST_BASE_NODE_T(srv_conc_slot_t)	srv_conc_queue;
-/* array of wait slots */
-static srv_conc_slot_t* srv_conc_slots;
-
-/* Number of times a thread is allowed to enter InnoDB within the same
-SQL query after it has once got the ticket at srv_conc_enter_innodb */
-#define SRV_FREE_TICKETS_TO_ENTER srv_n_free_tickets_to_enter
-#define SRV_THREAD_SLEEP_DELAY srv_thread_sleep_delay
-/*-----------------------*/
 /* If the following is set to 1 then we do not run purge and insert buffer
 merge to completion before shutdown. If it is set to 2, do not even flush the
 buffer pool to data files at the shutdown: we effectively 'crash'
@@ -457,8 +405,6 @@ UNIV_INTERN mysql_pfs_key_t	srv_misc_tmp
 UNIV_INTERN mysql_pfs_key_t	srv_sys_mutex_key;
 /* Key to register srv_sys_t::tasks_mutex with performance schema */
 UNIV_INTERN mysql_pfs_key_t	srv_sys_tasks_mutex_key;
-/* Key to register srv_conc_mutex_key with performance schema */
-UNIV_INTERN mysql_pfs_key_t	srv_conc_mutex_key;
 #endif /* UNIV_PFS_MUTEX */
 
 /* Temporary file for innodb monitor output */
@@ -558,7 +504,7 @@ happening in the server which requires i
 thread. Such situations may be, for example, when flushing of dirty
 blocks is needed in the buffer pool or old version of database rows
 have to be cleaned away (purged). The user can configure a separate
-dedicated purge thread(s) too, in which case the master thread doesn't
+dedicated purge thread(s) too, in which case the master thread does not
 do any purging.
 
 The threads which we call user threads serve the queries of the MySQL
@@ -591,7 +537,7 @@ information is outdated for the time of
 the machine supports atomic swap.)
 
 The above solution with priority inheritance may become actual in the
-future, currently we don't implement any priority twiddling solution.
+future, currently we do not implement any priority twiddling solution.
 Our general aim is to reduce the contention of all mutexes by making
 them more fine grained.
 
@@ -640,16 +586,6 @@ UNIV_INTERN os_event_t	srv_monitor_event
 /** Event to signal the error thread */
 UNIV_INTERN os_event_t	srv_error_event;
 
-/*********************************************************************//**
-Asynchronous purge thread.
-@return	a dummy parameter */
-UNIV_INTERN
-os_thread_ret_t
-srv_purge_thread(
-/*=============*/
-	void*	arg __attribute__((unused)));	/*!< in: a dummy parameter
-						required by os_thread_create */
-
 /***********************************************************************
 Prints counters for work done by srv_master_thread. */
 static
@@ -793,8 +729,6 @@ srv_table_reserve_slot(
 	slot->suspended = FALSE;
 	slot->type = type;
 	ut_ad(srv_slot_get_type(slot) == type);
-	slot->id = os_thread_get_curr_id();
-	slot->handle = os_thread_get_curr();
 
 	return(slot);
 }
@@ -812,7 +746,6 @@ srv_suspend_thread(
 	srv_sys_mutex_enter();
 	ut_ad(slot->in_use);
 	ut_ad(!slot->suspended);
-	ut_ad(slot->id == os_thread_get_curr_id());
 
 	if (srv_print_thread_releases) {
 		fprintf(stderr,
@@ -873,10 +806,9 @@ srv_release_threads(
 
 			if (srv_print_thread_releases) {
 				fprintf(stderr,
-					"Releasing thread %lu type %lu"
+					"Releasing thread type %lu"
 					" from slot %lu\n",
-					(ulong) slot->id, (ulong) type,
-					(ulong) i);
+					(ulong) type, (ulong) i);
 			}
 
 			count++;
@@ -977,20 +909,7 @@ srv_init(void)
 
 	dict_ind_init();
 
-	/* Init the server concurrency restriction data structures */
-
-	os_fast_mutex_init(srv_conc_mutex_key, &srv_conc_mutex);
-
-	UT_LIST_INIT(srv_conc_queue);
-
-	srv_conc_slots = mem_zalloc(OS_THREAD_MAX_N * sizeof(*srv_conc_slots));
-
-	for (i = 0; i < OS_THREAD_MAX_N; i++) {
-		srv_conc_slot_t*	conc_slot = &srv_conc_slots[i];
-
-		conc_slot->event = os_event_create(NULL);
-		ut_a(conc_slot->event);
-	}
+	srv_conc_init();
 
 	/* Initialize some INFORMATION SCHEMA internal structures */
 	trx_i_s_cache_init(trx_i_s_cache);
@@ -1003,9 +922,7 @@ void
 srv_free(void)
 /*==========*/
 {
-	os_fast_mutex_free(&srv_conc_mutex);
-	mem_free(srv_conc_slots);
-	srv_conc_slots = NULL;
+	srv_conc_free();
 
 	/* The mutexes srv_sys->mutex and srv_sys->tasks_mutex should have
 	been freed by sync_close() already. */
@@ -1033,278 +950,6 @@ srv_general_init(void)
 	row_mysql_init();
 }
 
-/*======================= InnoDB Server FIFO queue =======================*/
-
-/*********************************************************************//**
-Puts an OS thread to wait if there are too many concurrent threads
-(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
-UNIV_INTERN
-void
-srv_conc_enter_innodb(
-/*==================*/
-	trx_t*	trx)	/*!< in: transaction object associated with the
-			thread */
-{
-	ibool			has_slept = FALSE;
-	srv_conc_slot_t*	slot	  = NULL;
-	ulint			i;
-
-	if (trx->mysql_thd != NULL
-	    && thd_is_replication_slave_thread(trx->mysql_thd)) {
-
-		UT_WAIT_FOR(srv_conc_n_threads
-			    < (lint)srv_thread_concurrency,
-			    srv_replication_delay * 1000);
-
-		return;
-	}
-
-	/* If trx has 'free tickets' to enter the engine left, then use one
-	such ticket */
-
-	if (trx->n_tickets_to_enter_innodb > 0) {
-		trx->n_tickets_to_enter_innodb--;
-
-		return;
-	}
-
-	os_fast_mutex_lock(&srv_conc_mutex);
-retry:
-	if (UNIV_UNLIKELY(trx->declared_to_be_inside_innodb)) {
-		os_fast_mutex_unlock(&srv_conc_mutex);
-		ut_print_timestamp(stderr);
-		fputs("  InnoDB: Error: trying to declare trx"
-		      " to enter InnoDB, but\n"
-		      "InnoDB: it already is declared.\n", stderr);
-		trx_print(stderr, trx, 0);
-		putc('\n', stderr);
-
-		return;
-	}
-
-	ut_ad(srv_conc_n_threads >= 0);
-
-	if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
-
-		srv_conc_n_threads++;
-		trx->declared_to_be_inside_innodb = TRUE;
-		trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
-
-		os_fast_mutex_unlock(&srv_conc_mutex);
-
-		return;
-	}
-
-	/* If the transaction is not holding resources, let it sleep
-	for SRV_THREAD_SLEEP_DELAY microseconds, and try again then */
-
-	if (!has_slept && !trx->has_search_latch
-	    && NULL == UT_LIST_GET_FIRST(trx->lock.trx_locks)) {
-
-		has_slept = TRUE; /* We let it sleep only once to avoid
-				  starvation */
-
-		srv_conc_n_waiting_threads++;
-
-		os_fast_mutex_unlock(&srv_conc_mutex);
-
-		trx->op_info = "sleeping before joining InnoDB queue";
-
-		/* Peter Zaitsev suggested that we take the sleep away
-		altogether. But the sleep may be good in pathological
-		situations of lots of thread switches. Simply put some
-		threads aside for a while to reduce the number of thread
-		switches. */
-		if (SRV_THREAD_SLEEP_DELAY > 0) {
-			os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-		}
-
-		trx->op_info = "";
-
-		os_fast_mutex_lock(&srv_conc_mutex);
-
-		srv_conc_n_waiting_threads--;
-
-		goto retry;
-	}
-
-	/* Too many threads inside: put the current thread to a queue */
-
-	for (i = 0; i < OS_THREAD_MAX_N; i++) {
-		slot = srv_conc_slots + i;
-
-		if (!slot->reserved) {
-
-			break;
-		}
-	}
-
-	if (i == OS_THREAD_MAX_N) {
-		/* Could not find a free wait slot, we must let the
-		thread enter */
-
-		srv_conc_n_threads++;
-		trx->declared_to_be_inside_innodb = TRUE;
-		trx->n_tickets_to_enter_innodb = 0;
-
-		os_fast_mutex_unlock(&srv_conc_mutex);
-
-		return;
-	}
-
-	/* Release possible search system latch this thread has */
-	if (trx->has_search_latch) {
-		trx_search_latch_release_if_reserved(trx);
-	}
-
-	/* Add to the queue */
-	slot->reserved = TRUE;
-	slot->wait_ended = FALSE;
-
-	UT_LIST_ADD_LAST(srv_conc_queue, srv_conc_queue, slot);
-
-	os_event_reset(slot->event);
-
-	srv_conc_n_waiting_threads++;
-
-	os_fast_mutex_unlock(&srv_conc_mutex);
-
-	/* Go to wait for the event; when a thread leaves InnoDB it will
-	release this thread */
-
-	trx->op_info = "waiting in InnoDB queue";
-
-	thd_wait_begin(trx->mysql_thd, THD_WAIT_ROW_TABLE_LOCK);
-	os_event_wait(slot->event);
-	thd_wait_end(trx->mysql_thd);
-
-	trx->op_info = "";
-
-	os_fast_mutex_lock(&srv_conc_mutex);
-
-	srv_conc_n_waiting_threads--;
-
-	/* NOTE that the thread which released this thread already
-	incremented the thread counter on behalf of this thread */
-
-	slot->reserved = FALSE;
-
-	UT_LIST_REMOVE(srv_conc_queue, srv_conc_queue, slot);
-
-	trx->declared_to_be_inside_innodb = TRUE;
-	trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
-
-	os_fast_mutex_unlock(&srv_conc_mutex);
-}
-
-/*********************************************************************//**
-This lets a thread enter InnoDB regardless of the number of threads inside
-InnoDB. This must be called when a thread ends a lock wait. */
-UNIV_INTERN
-void
-srv_conc_force_enter_innodb(
-/*========================*/
-	trx_t*	trx)	/*!< in: transaction object associated with the
-			thread */
-{
-	if (UNIV_LIKELY(!srv_thread_concurrency)) {
-
-		return;
-	}
-
-	ut_ad(srv_conc_n_threads >= 0);
-
-	os_fast_mutex_lock(&srv_conc_mutex);
-
-	srv_conc_n_threads++;
-	trx->declared_to_be_inside_innodb = TRUE;
-	trx->n_tickets_to_enter_innodb = 1;
-
-	os_fast_mutex_unlock(&srv_conc_mutex);
-}
-
-/*********************************************************************//**
-This must be called when a thread exits InnoDB in a lock wait or at the
-end of an SQL statement. */
-UNIV_INTERN
-void
-srv_conc_force_exit_innodb(
-/*=======================*/
-	trx_t*	trx)	/*!< in: transaction object associated with the
-			thread */
-{
-	srv_conc_slot_t*	slot	= NULL;
-
-	if (trx->mysql_thd != NULL
-	    && thd_is_replication_slave_thread(trx->mysql_thd)) {
-
-		return;
-	}
-
-	if (trx->declared_to_be_inside_innodb == FALSE) {
-
-		return;
-	}
-
-	os_fast_mutex_lock(&srv_conc_mutex);
-
-	ut_ad(srv_conc_n_threads > 0);
-	srv_conc_n_threads--;
-	trx->declared_to_be_inside_innodb = FALSE;
-	trx->n_tickets_to_enter_innodb = 0;
-
-	if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
-		/* Look for a slot where a thread is waiting and no other
-		thread has yet released the thread */
-
-		slot = UT_LIST_GET_FIRST(srv_conc_queue);
-
-		while (slot && slot->wait_ended == TRUE) {
-			slot = UT_LIST_GET_NEXT(srv_conc_queue, slot);
-		}
-
-		if (slot != NULL) {
-			slot->wait_ended = TRUE;
-
-			/* We increment the count on behalf of the released
-			thread */
-
-			srv_conc_n_threads++;
-		}
-	}
-
-	os_fast_mutex_unlock(&srv_conc_mutex);
-
-	if (slot != NULL) {
-		os_event_set(slot->event);
-	}
-}
-
-/*********************************************************************//**
-This must be called when a thread exits InnoDB. */
-UNIV_INTERN
-void
-srv_conc_exit_innodb(
-/*=================*/
-	trx_t*	trx)	/*!< in: transaction object associated with the
-			thread */
-{
-	if (trx->n_tickets_to_enter_innodb > 0) {
-		/* We will pretend the thread is still inside InnoDB though it
-		now leaves the InnoDB engine. In this way we save
-		a lot of semaphore operations. srv_conc_force_exit_innodb is
-		used to declare the thread definitely outside InnoDB. It
-		should be called when there is a lock wait or an SQL statement
-		ends. */
-
-		return;
-	}
-
-	srv_conc_force_exit_innodb(trx);
-}
-
-/*========================================================================*/
-
 /*********************************************************************//**
 Normalizes init parameter values to use units we use inside InnoDB.
 @return	DB_SUCCESS or error code */
@@ -1539,7 +1184,7 @@ srv_printf_innodb_monitor(
 	      "--------------\n", file);
 	fprintf(file, "%ld queries inside InnoDB, %lu queries in queue\n",
 		(long) srv_conc_n_threads,
-		(ulong) srv_conc_n_waiting_threads);
+		srv_conc_get_waiting_threads());
 
 	/* This is a dirty read, without holding trx_sys->read_view_mutex. */
 	fprintf(file, "%lu read views open inside InnoDB\n",
@@ -2079,7 +1724,7 @@ and wakes up the purge thread if it is s
 that there is a small chance that the purge thread stays suspended
 (we do not protect our operation with the srv_sys_t:mutex, for
 performance reasons). */
-static
+UNIV_INTERN
 void
 srv_wake_purge_thread_if_not_active(void)
 /*=====================================*/
@@ -2642,11 +2287,7 @@ suspend_thread:
 	os_event_wait(slot->event);
 
 	if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
-		/* This is only extra safety, the thread should exit
-		already when the event wait ends */
-
 		os_thread_exit(NULL);
-
 	}
 
 	goto loop;
@@ -2704,6 +2345,8 @@ srv_worker_thread(
 {
 	srv_slot_t*	slot;
 
+	ut_a(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);
+
 #ifdef UNIV_DEBUG_THREAD_CREATION
 	fprintf(stderr, "Worker thread starts, id %lu\n",
 		os_thread_pf(os_thread_get_curr_id()));
@@ -2757,6 +2400,59 @@ srv_worker_thread(
 }
 
 /*********************************************************************//**
+Do the actual purge operation. */
+static
+void
+srv_do_purge(
+/*=========*/
+	ulint		n_threads,	/*!< in: number of threads to use */
+	ulint		batch_size,	/*!< in: purge batch size */
+	ulint*		n_total_purged)	/*!< in/out: total pages purged */
+{
+	if (n_threads <= 1) {
+		ulint	n_pages_purged;
+
+		/* Purge until there are no more records to
+		purge and there is no change in configuration
+		or server state. */
+
+		do {
+			n_pages_purged = trx_purge(0, batch_size);
+
+			*n_total_purged += n_pages_purged;
+
+		} while (n_pages_purged > 0 && !srv_fast_shutdown);
+
+	} else {
+		ulint	n_pages_purged;
+
+		do {
+			n_pages_purged = trx_purge(n_threads, batch_size);
+
+			*n_total_purged += n_pages_purged;
+
+			/* During shutdown the worker threads can
+			exit when they detect a change in state.
+			Force the coordinator thread to do the purge
+			tasks from the work queue. */
+
+			while (srv_get_task_queue_length() > 0) {
+
+				ibool	success;
+
+				ut_a(srv_shutdown_state);
+
+				success = srv_task_execute();
+				ut_a(success);
+			}
+
+		} while (trx_sys->rseg_history_len > 100
+			 && srv_shutdown_state == SRV_SHUTDOWN_NONE
+			 && srv_fast_shutdown == 0);
+	}
+}
+
+/*********************************************************************//**
 Purge coordinator thread that schedules the purge tasks.
 @return	a dummy parameter */
 UNIV_INTERN
@@ -2767,6 +2463,8 @@ srv_purge_coordinator_thread(
 						required by os_thread_create */
 {
 	srv_slot_t*	slot;
+	ulint		retries = 0;
+	ulint           n_total_purged = ULINT_UNDEFINED;
 
 	ut_a(srv_n_purge_threads >= 1);
 
@@ -2790,119 +2488,56 @@ srv_purge_coordinator_thread(
 
 	srv_sys_mutex_exit();
 
-	for (;;) {
-		ulint		n_pages_purged;
-		ib_time_t	last_time = ut_time();
-		ulint		count = srv_sys->activity_count;
-		ulint		batch_size = srv_purge_batch_size;
-		ulint		sleep_ms = ut_rnd_gen_ulint() % 10000;
+	while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
 
-		if (srv_shutdown_state != SRV_SHUTDOWN_NONE
-		    && srv_fast_shutdown != 0) {
+		ulint	n_threads = srv_n_purge_threads;
+		ulint	batch_size = srv_purge_batch_size;
 
-			break;
+		if (srv_shutdown_state != SRV_SHUTDOWN_NONE) {
+
+			/* If shutdown is signalled, then switch
+			to single threaded purge. There are no user
+			threads to contended with and secondly purge
+			worker threads can exit silently, causing a
+			potential hang. We try and avoid that as much
+			as we can until the underlying problem is fixed
+			properly. */
+
+			n_threads = 1;
 		}
 
-		/* If number of threads is 1 then we let trx_purge() do
-		the actual purge for us. */
-		if (srv_n_purge_threads == 1) {
-
-			do {
-				n_pages_purged = trx_purge(0, batch_size);
-
-				/* FIXME: Do some black magic. This code
-				is purely guess work and needs to be tuned
-				properly after some benchmarking. */
-				if (srv_check_activity(count)) {
-					sleep_ms = 60000;
-					batch_size = srv_purge_batch_size;
-				} else if (n_pages_purged == 0) {
-					sleep_ms = 120000;
-					batch_size = srv_purge_batch_size;
-				} else {
-					sleep_ms = 0;
-					batch_size = 500;
-				}
-
-				/* No point in sleeping during shutdown. */
-				if (srv_shutdown_state == SRV_SHUTDOWN_NONE
-				    && sleep_ms > 0) {
-
-					os_thread_sleep(sleep_ms);
-				}
-
-				/* Take snapshot to check for user
-				activity at every second. */
-				if (ut_time() - last_time >= 1) {
-					count = srv_sys->activity_count;
-					last_time = ut_time();
-				}
+		/* If there are very few records to purge or the last
+		purge didn't purge any records then wait for activity.
+	        We peek at the history len without holding any mutex
+		because in the worst case we will end up waiting for
+		the next purge event. */
 
-			} while (n_pages_purged > 0 && srv_fast_shutdown == 0);
+		if (trx_sys->rseg_history_len < batch_size
+		    || (n_total_purged == 0
+			&& retries >= TRX_SYS_N_RSEGS)) {
 
-		} else {
-			do {
+			srv_suspend_thread(slot);
 
-				n_pages_purged = trx_purge(
-					srv_n_purge_threads, batch_size);
+			os_event_wait(slot->event);
 
-				/* During shutdown the worker threads can
-				exit when they detect a change in state.
-				Force the coordinator thread to do the purge
-				tasks from the work queue. */
-				while (srv_get_task_queue_length() > 0) {
-
-					ibool	success;
-
-					ut_a(srv_shutdown_state);
-
-					success = srv_task_execute();
-					ut_a(success);
-				}
-
-				/* No point in sleeping during shutdown. */
-				if (srv_shutdown_state == SRV_SHUTDOWN_NONE
-				    && sleep_ms > 0) {
-
-					os_thread_sleep(sleep_ms);
-				}
-
-				/* FIXME: Do some black magic. This code
-				is purely guess work and needs to be tuned
-				properly after some benchmarking. */
-				if (!srv_check_activity(count)
-				    && trx_sys->rseg_history_len > 500) {
-					sleep_ms = 0;
-					batch_size = 500;
-				} else {
-					sleep_ms = 60000;
-
-					if (n_pages_purged > 0) {
-						sleep_ms = 150000;
-					}
-
-					batch_size = srv_purge_batch_size;
-				}
-
-				/* Take snapshot to check for user
-				activity at every second. */
-				if (ut_time() - last_time >= 1) {
-					count = srv_sys->activity_count;
-					last_time = ut_time();
-				}
-
-			} while (trx_sys->rseg_history_len > 100
-				 && srv_shutdown_state == SRV_SHUTDOWN_NONE
-				 && srv_fast_shutdown == 0);
+			retries = 0;
 		}
 
-		/* Check if Slow shutdown and no more pages to purge. */
+		/* Check for shutdown and whether we should do purge at all. */
 		if (srv_shutdown_state != SRV_SHUTDOWN_NONE
-		    && srv_fast_shutdown == 0
-		    && n_pages_purged == 0) {
+		    || srv_fast_shutdown) {
 
 			break;
 		}
+
+		if (n_total_purged == 0 && retries <= TRX_SYS_N_RSEGS) {
+			++retries;
+		} else if (n_total_purged > 0) {
+			retries = 0;
+			n_total_purged = 0;
+		}
+
+		srv_do_purge(n_threads, batch_size, &n_total_purged);
 	}
 
 	/* The task queue should always be empty, independent of fast

=== modified file 'storage/innobase/srv/srv0start.c'
--- a/storage/innobase/srv/srv0start.c	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/srv/srv0start.c	2011-04-19 04:17:07 +0000
@@ -534,7 +534,7 @@ srv_calc_low32(
 
 /*********************************************************************//**
 Calculates the high 32 bits when a file size which is given as a number
-database pages is converted to the number of bytes.
+of database pages is converted to the number of bytes.
 @return	high 32 bytes of file size when expressed in bytes */
 static
 ulint
@@ -1678,10 +1678,6 @@ innobase_start_or_create_for_mysql(void)
 
 		srv_startup_is_before_trx_rollback_phase = FALSE;
 
-		/* Initialize the fsp free limit global variable in the log
-		system */
-		fsp_header_get_free_limit();
-
 		recv_recovery_from_archive_finish();
 #endif /* UNIV_LOG_ARCHIVE */
 	} else {
@@ -1739,10 +1735,6 @@ innobase_start_or_create_for_mysql(void)
 
 		trx_purge_sys_create(srv_n_purge_threads, ib_bh);
 
-		/* Initialize the fsp free limit global variable in the log
-		system */
-		fsp_header_get_free_limit();
-
 		/* recv_recovery_from_checkpoint_finish needs trx lists which
 		are initialized in trx_sys_init_at_db_start(). */
 
@@ -1869,7 +1861,8 @@ innobase_start_or_create_for_mysql(void)
 
 	/* If the user has requested a separate purge thread then
 	start the purge thread. */
-	if (srv_n_purge_threads >= 1) {
+	if (srv_n_purge_threads >= 1
+	    && srv_force_recovery < SRV_FORCE_NO_BACKGROUND) {
 
 		os_thread_create(
 			&srv_purge_coordinator_thread, NULL,
@@ -1890,7 +1883,9 @@ innobase_start_or_create_for_mysql(void)
 
 	/* Wait for the purge coordinator and master thread to startup. */
 
-	while (srv_shutdown_state == SRV_SHUTDOWN_NONE) {
+	while (srv_shutdown_state == SRV_SHUTDOWN_NONE
+	       && srv_force_recovery < SRV_FORCE_NO_BACKGROUND) {
+
 		if (srv_thread_has_reserved_slot(SRV_MASTER) == ULINT_UNDEFINED
 		    || (srv_n_purge_threads > 0
 			&& srv_thread_has_reserved_slot(SRV_PURGE)
@@ -2144,17 +2139,6 @@ innobase_shutdown_for_mysql(void)
 	The step 1 is the real InnoDB shutdown. The remaining steps 2 - ...
 	just free data structures after the shutdown. */
 
-
-	if (srv_fast_shutdown == 2) {
-		ut_print_timestamp(stderr);
-		fprintf(stderr,
-			"  InnoDB: MySQL has requested a very fast shutdown"
-			" without flushing "
-			"the InnoDB buffer pool to data files."
-			" At the next mysqld startup "
-			"InnoDB will do a crash recovery!\n");
-	}
-
 	logs_empty_and_mark_files_at_shutdown();
 
 	if (srv_conc_n_threads != 0) {
@@ -2169,17 +2153,9 @@ innobase_shutdown_for_mysql(void)
 
 	srv_shutdown_state = SRV_SHUTDOWN_EXIT_THREADS;
 
-	/* In a 'very fast' shutdown, we do not need to wait for these threads
-	to die; all which counts is that we flushed the log; a 'very fast'
-	shutdown is essentially a crash. */
-
-	if (srv_fast_shutdown == 2) {
-		return(DB_SUCCESS);
-	}
-
 	/* All threads end up waiting for certain events. Put those events
-	to the signaled state. Then the threads will exit themselves in
-	os_thread_event_wait(). */
+	to the signaled state. Then the threads will exit themselves after
+	os_event_wait(). */
 
 	for (i = 0; i < 1000; i++) {
 		/* NOTE: IF YOU CREATE THREADS IN INNODB, YOU MUST EXIT THEM

=== modified file 'storage/innobase/sync/sync0arr.c'
--- a/storage/innobase/sync/sync0arr.c	2011-03-30 12:02:53 +0000
+++ b/storage/innobase/sync/sync0arr.c	2011-04-12 13:27:46 +0000
@@ -122,8 +122,6 @@ struct sync_array_struct {
 	ulint		n_cells;	/*!< number of cells in the
 					wait array */
 	sync_cell_t*	array;		/*!< pointer to wait array */
-	ulint		protection;	/*!< this flag tells which
-					mutex protects the data */
 	mutex_t		mutex;		/*!< possible database mutex
 					protecting this data structure */
 	os_mutex_t	os_mutex;	/*!< Possible operating system mutex
@@ -133,16 +131,22 @@ struct sync_array_struct {
 					to prevent infinite recursion
 					in implementation, we fall back to
 					an OS mutex. */
-	ulint		sg_count;	/*!< count of how many times an
-					object has been signalled */
 	ulint		res_count;	/*!< count of cell reservations
 					since creation of the array */
 };
 
-#ifdef UNIV_PFS_MUTEX
-/* Key to register the mutex with performance schema */
-UNIV_INTERN mysql_pfs_key_t	syn_arr_mutex_key;
-#endif
+/** User configured sync array size */
+UNIV_INTERN ulong	srv_sync_array_size = 32;
+
+/** Locally stored copy of srv_sync_array_size */
+static	ulint		sync_array_size;
+
+/** The global array of wait cells for implementation of the database's own
+mutexes and read-write locks */
+static	sync_array_t**	sync_wait_array;
+
+/** count of how many times an object has been signalled */
+static ulint		sg_count;
 
 #ifdef UNIV_SYNC_DEBUG
 /******************************************************************//**
@@ -184,17 +188,7 @@ sync_array_enter(
 /*=============*/
 	sync_array_t*	arr)	/*!< in: sync wait array */
 {
-	ulint	protection;
-
-	protection = arr->protection;
-
-	if (protection == SYNC_ARRAY_OS_MUTEX) {
-		os_mutex_enter(arr->os_mutex);
-	} else if (protection == SYNC_ARRAY_MUTEX) {
-		mutex_enter(&(arr->mutex));
-	} else {
-		ut_error;
-	}
+	os_mutex_enter(arr->os_mutex);
 }
 
 /******************************************************************//**
@@ -205,17 +199,7 @@ sync_array_exit(
 /*============*/
 	sync_array_t*	arr)	/*!< in: sync wait array */
 {
-	ulint	protection;
-
-	protection = arr->protection;
-
-	if (protection == SYNC_ARRAY_OS_MUTEX) {
-		os_mutex_exit(arr->os_mutex);
-	} else if (protection == SYNC_ARRAY_MUTEX) {
-		mutex_exit(&(arr->mutex));
-	} else {
-		ut_error;
-	}
+	os_mutex_exit(arr->os_mutex);
 }
 
 /*******************************************************************//**
@@ -223,15 +207,12 @@ Creates a synchronization wait array. It
 which is automatically reserved when the functions operating on it
 are called.
 @return	own: created wait array */
-UNIV_INTERN
+static
 sync_array_t*
 sync_array_create(
 /*==============*/
-	ulint	n_cells,	/*!< in: number of cells in the array
+	ulint	n_cells)	/*!< in: number of cells in the array
 				to create */
-	ulint	protection)	/*!< in: either SYNC_ARRAY_OS_MUTEX or
-				SYNC_ARRAY_MUTEX: determines the type
-				of mutex protecting the data structure */
 {
 	ulint		sz;
 	sync_array_t*	arr;
@@ -247,46 +228,28 @@ sync_array_create(
 	memset(arr->array, 0x0, sz);
 
 	arr->n_cells = n_cells;
-	arr->protection = protection;
 
 	/* Then create the mutex to protect the wait array complex */
-	if (protection == SYNC_ARRAY_OS_MUTEX) {
-		arr->os_mutex = os_mutex_create();
-	} else if (protection == SYNC_ARRAY_MUTEX) {
-		mutex_create(syn_arr_mutex_key,
-			     &arr->mutex, SYNC_NO_ORDER_CHECK);
-	} else {
-		ut_error;
-	}
+	arr->os_mutex = os_mutex_create();
 
 	return(arr);
 }
 
 /******************************************************************//**
 Frees the resources in a wait array. */
-UNIV_INTERN
+static
 void
 sync_array_free(
 /*============*/
 	sync_array_t*	arr)	/*!< in, own: sync wait array */
 {
-	ulint		protection;
-
 	ut_a(arr->n_reserved == 0);
 
 	sync_array_validate(arr);
 
-	protection = arr->protection;
-
 	/* Release the mutex protecting the wait array complex */
 
-	if (protection == SYNC_ARRAY_OS_MUTEX) {
-		os_mutex_free(arr->os_mutex);
-	} else if (protection == SYNC_ARRAY_MUTEX) {
-		mutex_free(&(arr->mutex));
-	} else {
-		ut_error;
-	}
+	os_mutex_free(arr->os_mutex);
 
 	ut_free(arr->array);
 	ut_free(arr);
@@ -849,19 +812,14 @@ sync_array_free_cell(
 Increments the signalled count. */
 UNIV_INTERN
 void
-sync_array_object_signalled(
-/*========================*/
-	sync_array_t*	arr)	/*!< in: wait array */
+sync_array_object_signalled(void)
+/*=============================*/
 {
 #ifdef HAVE_ATOMIC_BUILTINS
-	(void) os_atomic_increment_ulint(&arr->sg_count, 1);
+	(void) os_atomic_increment_ulint(&sg_count, 1);
 #else
-	sync_array_enter(arr);
-
-	arr->sg_count++;
-
-	sync_array_exit(arr);
-#endif
+	++sg_count;
+#endif /* HAVE_ATOMIC_BUILTINS */
 }
 
 /**********************************************************************//**
@@ -872,57 +830,73 @@ function should be called about every 1
 Note that there's a race condition between this thread and mutex_exit
 changing the lock_word and calling signal_object, so sometimes this finds
 threads to wake up even when nothing has gone wrong. */
-UNIV_INTERN
+static
 void
-sync_arr_wake_threads_if_sema_free(void)
-/*====================================*/
+sync_array_wake_threads_if_sema_free_low(
+/*=====================================*/
+	sync_array_t*	arr)		/* in/out: wait array */
 {
-	sync_array_t*	arr	= sync_primary_wait_array;
-	sync_cell_t*	cell;
+	ulint		i = 0;
 	ulint		count;
-	ulint		i;
-	os_event_t      event;
 
 	sync_array_enter(arr);
 
-	i = 0;
-	count = 0;
-
-	while (count < arr->n_reserved) {
+	for (count = 0;  count < arr->n_reserved; ++i) {
+		sync_cell_t*	cell;
 
 		cell = sync_array_get_nth_cell(arr, i);
-		i++;
 
-		if (cell->wait_object == NULL) {
-			continue;
-		}
+		if (cell->wait_object != NULL) {
+
 			count++;
 
 			if (sync_arr_cell_can_wake_up(cell)) {
+				os_event_t      event;
 
-			event = sync_cell_get_event(cell);
+				event = sync_cell_get_event(cell);
 
-			os_event_set(event);
+				os_event_set(event);
+			}
 		}
-
 	}
 
 	sync_array_exit(arr);
 }
 
 /**********************************************************************//**
+If the wakeup algorithm does not work perfectly at semaphore relases,
+this function will do the waking (see the comment in mutex_exit). This
+function should be called about every 1 second in the server.
+
+Note that there's a race condition between this thread and mutex_exit
+changing the lock_word and calling signal_object, so sometimes this finds
+threads to wake up even when nothing has gone wrong. */
+UNIV_INTERN
+void
+sync_arr_wake_threads_if_sema_free(void)
+/*====================================*/
+{
+	ulint		i;
+
+	for (i = 0; i < sync_array_size; ++i) {
+
+		sync_array_wake_threads_if_sema_free_low(
+			sync_wait_array[i]);
+	}
+}
+
+/**********************************************************************//**
 Prints warnings of long semaphore waits to stderr.
 @return	TRUE if fatal semaphore wait threshold was exceeded */
-UNIV_INTERN
+static
 ibool
-sync_array_print_long_waits(
-/*========================*/
+sync_array_print_long_waits_low(
+/*============================*/
+	sync_array_t*	arr,	/*!< in: sync array instance */
 	os_thread_id_t*	waiter,	/*!< out: longest waiting thread */
-	const void**	sema)	/*!< out: longest-waited-for semaphore */
+	const void**	sema,	/*!< out: longest-waited-for semaphore */
+	ibool*		noticed)/*!< out: TRUE if long wait noticed */
 {
-	sync_cell_t*	cell;
-	ibool		old_val;
-	ibool		noticed = FALSE;
 	ulint		i;
 	ulint		fatal_timeout = srv_fatal_semaphore_wait_threshold;
 	ibool		fatal = FALSE;
@@ -940,12 +914,13 @@ sync_array_print_long_waits(
 # define SYNC_ARRAY_TIMEOUT	240
 #endif
 
-	for (i = 0; i < sync_primary_wait_array->n_cells; i++) {
+	for (i = 0; i < arr->n_cells; i++) {
 
-		double	diff;
-		void*	wait_object;
+		double		diff;
+		sync_cell_t*	cell;
+		void*		wait_object;
 
-		cell = sync_array_get_nth_cell(sync_primary_wait_array, i);
+		cell = sync_array_get_nth_cell(arr, i);
 
 		wait_object = cell->wait_object;
 
@@ -960,7 +935,7 @@ sync_array_print_long_waits(
 			fputs("InnoDB: Warning: a long semaphore wait:\n",
 			      stderr);
 			sync_array_cell_print(stderr, cell);
-			noticed = TRUE;
+			*noticed = TRUE;
 		}
 
 		if (diff > fatal_timeout) {
@@ -974,10 +949,43 @@ sync_array_print_long_waits(
 		}
 	}
 
+#undef SYNC_ARRAY_TIMEOUT
+
+	return(fatal);
+}
+
+/**********************************************************************//**
+Prints warnings of long semaphore waits to stderr.
+@return	TRUE if fatal semaphore wait threshold was exceeded */
+UNIV_INTERN
+ibool
+sync_array_print_long_waits(
+/*========================*/
+	os_thread_id_t*	waiter,	/*!< out: longest waiting thread */
+	const void**	sema)	/*!< out: longest-waited-for semaphore */
+{
+	ulint		i;
+	ibool		fatal = FALSE;
+	ibool		noticed = FALSE;
+
+	for (i = 0; i < sync_array_size; ++i) {
+
+		sync_array_t*	arr = sync_wait_array[i];
+
+		if (sync_array_print_long_waits_low(
+				arr, waiter, sema, &noticed)) {
+
+			fatal = TRUE;
+		}
+	}
+
 	if (noticed) {
+		ibool	old_val;
+
 		fprintf(stderr,
 			"InnoDB: ###### Starts InnoDB Monitor"
 			" for 30 secs to print diagnostic info:\n");
+
 		old_val = srv_print_innodb_monitor;
 
 		/* If some crucial semaphore is reserved, then also the InnoDB
@@ -1002,8 +1010,6 @@ sync_array_print_long_waits(
 			" to the standard error stream\n");
 	}
 
-#undef SYNC_ARRAY_TIMEOUT
-
 	return(fatal);
 }
 
@@ -1011,38 +1017,33 @@ sync_array_print_long_waits(
 Prints info of the wait array. */
 static
 void
-sync_array_output_info(
-/*===================*/
+sync_array_print_info_low(
+/*======================*/
 	FILE*		file,	/*!< in: file where to print */
-	sync_array_t*	arr)	/*!< in: wait array; NOTE! caller must own the
-				mutex */
+	sync_array_t*	arr)	/*!< in: wait array */
 {
-	sync_cell_t*	cell;
-	ulint		count;
 	ulint		i;
+	ulint		count = 0;
 
 	fprintf(file,
-		"OS WAIT ARRAY INFO: reservation count %ld, signal count %ld\n",
-						(long) arr->res_count, (long) arr->sg_count);
-	i = 0;
-	count = 0;
+		"OS WAIT ARRAY INFO: reservation count %ld\n",
+		(long) arr->res_count);
 
-	while (count < arr->n_reserved) {
+	for (i = 0; count < arr->n_reserved; ++i) {
+		sync_cell_t*	cell;
 
 		cell = sync_array_get_nth_cell(arr, i);
 
-	if (cell->wait_object != NULL) {
-		count++;
+		if (cell->wait_object != NULL) {
+			count++;
 			sync_array_cell_print(file, cell);
 		}
-
-		i++;
 	}
 }
 
 /**********************************************************************//**
 Prints info of the wait array. */
-UNIV_INTERN
+static
 void
 sync_array_print_info(
 /*==================*/
@@ -1051,7 +1052,94 @@ sync_array_print_info(
 {
 	sync_array_enter(arr);
 
-	sync_array_output_info(file, arr);
+	sync_array_print_info_low(file, arr);
 
 	sync_array_exit(arr);
 }
+
+/**********************************************************************//**
+Create the primary system wait array(s), they are protected by an OS mutex */
+UNIV_INTERN
+void
+sync_array_init(
+/*============*/
+	ulint		n_threads)		/*!< in: Number of slots to
+						create in all arrays */
+{
+	ulint		i;
+	ulint		n_slots;
+
+	ut_a(sync_wait_array == NULL);
+	ut_a(srv_sync_array_size > 0);
+	ut_a(n_threads > srv_sync_array_size);
+
+	sync_array_size = srv_sync_array_size;
+
+	/* We have to use ut_malloc() because the mutex infrastructure
+	hasn't been initialised yet. It is required by mem_alloc() and
+	the heap functions. */
+
+	sync_wait_array = ut_malloc(sizeof(*sync_wait_array) * sync_array_size);
+
+	n_slots = 1 + (n_threads - 1) / sync_array_size;
+
+	for (i = 0; i < sync_array_size; ++i) {
+
+		sync_wait_array[i] = sync_array_create(n_slots);
+	}
+}
+
+/**********************************************************************//**
+Close sync array wait sub-system. */
+UNIV_INTERN
+void
+sync_array_close(void)
+/*==================*/
+{
+	ulint		i;
+
+	for (i = 0; i < sync_array_size; ++i) {
+		sync_array_free(sync_wait_array[i]);
+	}
+
+	ut_free(sync_wait_array);
+	sync_wait_array = NULL;
+}
+
+/**********************************************************************//**
+Print info about the sync array(s). */
+UNIV_INTERN
+void
+sync_array_print(
+/*=============*/
+	FILE*		file)		/*!< in/out: Print to this stream */
+{
+	ulint		i;
+
+	for (i = 0; i < sync_array_size; ++i) {
+		sync_array_print_info(file, sync_wait_array[i]);
+	}
+
+	fprintf(file,
+		"OS WAIT ARRAY INFO: signal count %ld\n", (long) sg_count);
+
+}
+
+/**********************************************************************//**
+Get an instance of the sync wait array. */
+UNIV_INTERN
+sync_array_t*
+sync_array_get(void)
+/*================*/
+{
+	ulint		i;
+	static ulint	count;
+
+#ifdef HAVE_ATOMIC_BUILTINS
+	i = os_atomic_increment_ulint(&count, 1);
+#else
+	i = count++;
+#endif /* HAVE_ATOMIC_BUILTINS */
+
+	return(sync_wait_array[i % sync_array_size]);
+}

=== modified file 'storage/innobase/sync/sync0rw.c'
--- a/storage/innobase/sync/sync0rw.c	2011-02-28 07:59:28 +0000
+++ b/storage/innobase/sync/sync0rw.c	2011-04-12 01:21:37 +0000
@@ -381,8 +381,9 @@ rw_lock_s_lock_spin(
 	const char*	file_name, /*!< in: file name where lock requested */
 	ulint		line)	/*!< in: line where requested */
 {
-	ulint	 index;	/* index of the reserved wait cell */
-	ulint	 i = 0;	/* spin round count */
+	ulint		index;	/* index of the reserved wait cell */
+	ulint		i = 0;	/* spin round count */
+	sync_array_t*	sync_arr;
 
 	ut_ad(rw_lock_validate(lock));
 
@@ -425,17 +426,18 @@ lock_loop:
 
 		rw_s_spin_round_count += i;
 
-		sync_array_reserve_cell(sync_primary_wait_array,
-					lock, RW_LOCK_SHARED,
-					file_name, line,
-					&index);
+		sync_arr = sync_array_get();
+
+		sync_array_reserve_cell(
+			sync_arr, lock, RW_LOCK_SHARED,
+			file_name, line, &index);
 
 		/* Set waiters before checking lock_word to ensure wake-up
                 signal is sent. This may lead to some unnecessary signals. */
 		rw_lock_set_waiter_flag(lock);
 
 		if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-			sync_array_free_cell(sync_primary_wait_array, index);
+			sync_array_free_cell(sync_arr, index);
 			return; /* Success */
 		}
 
@@ -453,7 +455,7 @@ lock_loop:
 		lock->count_os_wait++;
 		rw_s_os_wait_count++;
 
-		sync_array_wait_event(sync_primary_wait_array, index);
+		sync_array_wait_event(sync_arr, index);
 
 		i = 0;
 		goto lock_loop;
@@ -495,8 +497,9 @@ rw_lock_x_lock_wait(
 	const char*	file_name,/*!< in: file name where lock requested */
 	ulint		line)	/*!< in: line where requested */
 {
-	ulint index;
-	ulint i = 0;
+	ulint		index;
+	ulint		i = 0;
+	sync_array_t*	sync_arr;
 
 	ut_ad(lock->lock_word <= 0);
 
@@ -511,14 +514,17 @@ rw_lock_x_lock_wait(
 
 		/* If there is still a reader, then go to sleep.*/
 		rw_x_spin_round_count += i;
+
+		sync_arr = sync_array_get();
+
+		sync_array_reserve_cell(
+			sync_arr, lock, RW_LOCK_WAIT_EX,
+			file_name, line, &index);
+
 		i = 0;
-		sync_array_reserve_cell(sync_primary_wait_array,
-					lock,
-					RW_LOCK_WAIT_EX,
-					file_name, line,
-					&index);
+
 		/* Check lock_word to ensure wake-up isn't missed.*/
-		if(lock->lock_word < 0) {
+		if (lock->lock_word < 0) {
 
 			/* these stats may not be accurate */
 			lock->count_os_wait++;
@@ -532,8 +538,7 @@ rw_lock_x_lock_wait(
 					       file_name, line);
 #endif
 
-			sync_array_wait_event(sync_primary_wait_array,
-					      index);
+			sync_array_wait_event(sync_arr, index);
 #ifdef UNIV_SYNC_DEBUG
 			rw_lock_remove_debug_info(lock, pass,
 					       RW_LOCK_WAIT_EX);
@@ -541,8 +546,7 @@ rw_lock_x_lock_wait(
                         /* It is possible to wake when lock_word < 0.
                         We must pass the while-loop check to proceed.*/
 		} else {
-			sync_array_free_cell(sync_primary_wait_array,
-					     index);
+			sync_array_free_cell(sync_arr, index);
 		}
 	}
 	rw_x_spin_round_count += i;
@@ -621,9 +625,10 @@ rw_lock_x_lock_func(
 	const char*	file_name,/*!< in: file name where lock requested */
 	ulint		line)	/*!< in: line where requested */
 {
-	ulint	index;	/*!< index of the reserved wait cell */
-	ulint	i;	/*!< spin round count */
-	ibool	spinning = FALSE;
+	ulint		i;	/*!< spin round count */
+	ulint		index;	/*!< index of the reserved wait cell */
+	sync_array_t*	sync_arr;
+	ibool		spinning = FALSE;
 
 	ut_ad(rw_lock_validate(lock));
 
@@ -671,18 +676,17 @@ lock_loop:
 			(ulong) lock->cline, (ulong) i);
 	}
 
-	sync_array_reserve_cell(sync_primary_wait_array,
-				lock,
-				RW_LOCK_EX,
-				file_name, line,
-				&index);
+	sync_arr = sync_array_get();
+
+	sync_array_reserve_cell(
+		sync_arr, lock, RW_LOCK_EX, file_name, line, &index);
 
 	/* Waiters must be set before checking lock_word, to ensure signal
 	is sent. This could lead to a few unnecessary wake-up signals. */
 	rw_lock_set_waiter_flag(lock);
 
 	if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
-		sync_array_free_cell(sync_primary_wait_array, index);
+		sync_array_free_cell(sync_arr, index);
 		return; /* Locking succeeded */
 	}
 
@@ -699,7 +703,7 @@ lock_loop:
 	lock->count_os_wait++;
 	rw_x_os_wait_count++;
 
-	sync_array_wait_event(sync_primary_wait_array, index);
+	sync_array_wait_event(sync_arr, index);
 
 	i = 0;
 	goto lock_loop;

=== modified file 'storage/innobase/sync/sync0sync.c'
--- a/storage/innobase/sync/sync0sync.c	2011-02-28 07:59:28 +0000
+++ b/storage/innobase/sync/sync0sync.c	2011-04-21 01:07:46 +0000
@@ -182,19 +182,15 @@ static ib_int64_t	mutex_os_wait_count		=
 monitoring. */
 UNIV_INTERN ib_int64_t	mutex_exit_count		= 0;
 
-/** The global array of wait cells for implementation of the database's own
-mutexes and read-write locks */
-UNIV_INTERN sync_array_t*	sync_primary_wait_array;
-
 /** This variable is set to TRUE when sync_init is called */
 UNIV_INTERN ibool	sync_initialized	= FALSE;
 
+#ifdef UNIV_SYNC_DEBUG
 /** An acquired mutex or rw-lock and its level in the latching order */
 typedef struct sync_level_struct	sync_level_t;
 /** Mutexes or rw-locks held by a thread */
 typedef struct sync_thread_struct	sync_thread_t;
 
-#ifdef UNIV_SYNC_DEBUG
 /** The latch levels currently owned by threads are stored in this data
 structure; the size of this array is OS_THREAD_MAX_N */
 
@@ -221,7 +217,6 @@ UNIV_INTERN mysql_pfs_key_t	mutex_list_m
 #ifdef UNIV_SYNC_DEBUG
 /** Latching order checks start when this is set TRUE */
 UNIV_INTERN ibool	sync_order_checks_on	= FALSE;
-#endif /* UNIV_SYNC_DEBUG */
 
 /** Number of slots reserved for each OS thread in the sync level array */
 static const ulint SYNC_THREAD_N_LEVELS = 10000;
@@ -258,6 +253,7 @@ struct sync_level_struct{
 					the ordinal value of the next free
 					element */
 };
+#endif /* UNIV_SYNC_DEBUG */
 
 /******************************************************************//**
 Creates, or rather, initializes a mutex object in a specified memory
@@ -488,8 +484,9 @@ mutex_spin_wait(
 					requested */
 	ulint		line)		/*!< in: line where requested */
 {
-	ulint	   index; /* index of the reserved wait cell */
-	ulint	   i;	  /* spin round count */
+	ulint		i;		/* spin round count */
+	ulint		index;		/* index of the reserved wait cell */
+	sync_array_t*	sync_arr;
 #ifdef UNIV_DEBUG
 	ib_int64_t lstart_time = 0, lfinish_time; /* for timing os_wait */
 	ulint ltime_diff;
@@ -577,8 +574,10 @@ spin_loop:
 		goto spin_loop;
 	}
 
-	sync_array_reserve_cell(sync_primary_wait_array, mutex,
-				SYNC_MUTEX, file_name, line, &index);
+	sync_arr = sync_array_get();
+
+	sync_array_reserve_cell(
+		sync_arr, mutex, SYNC_MUTEX, file_name, line, &index);
 
 	/* The memory order of the array reservation and the change in the
 	waiters field is important: when we suspend a thread, we first
@@ -593,7 +592,7 @@ spin_loop:
 		if (mutex_test_and_set(mutex) == 0) {
 			/* Succeeded! Free the reserved wait cell */
 
-			sync_array_free_cell(sync_primary_wait_array, index);
+			sync_array_free_cell(sync_arr, index);
 
 			ut_d(mutex->thread_id = os_thread_get_curr_id());
 #ifdef UNIV_SYNC_DEBUG
@@ -641,7 +640,7 @@ spin_loop:
 #endif /* UNIV_HOTBACKUP */
 #endif /* UNIV_DEBUG */
 
-	sync_array_wait_event(sync_primary_wait_array, index);
+	sync_array_wait_event(sync_arr, index);
 	goto mutex_loop;
 
 finish_timing:
@@ -674,7 +673,7 @@ mutex_signal_object(
 	/* The memory order of resetting the waiters field and
 	signaling the object is important. See LEMMA 1 above. */
 	os_event_set(mutex->event);
-	sync_array_object_signalled(sync_primary_wait_array);
+	sync_array_object_signalled();
 }
 
 #ifdef UNIV_SYNC_DEBUG
@@ -1021,9 +1020,7 @@ void*
 sync_thread_levels_nonempty_gen(
 /*============================*/
 	ibool	dict_mutex_allowed)	/*!< in: TRUE if dictionary mutex is
-					allowed to be owned by the thread,
-					also purge_is_running mutex is
-					allowed */
+					allowed to be owned by the thread */
 {
 	ulint		i;
 	sync_arr_t*	arr;
@@ -1070,14 +1067,61 @@ sync_thread_levels_nonempty_gen(
 }
 
 /******************************************************************//**
-Checks that the level array for the current thread is empty.
-@return	TRUE if empty */
+Checks if the level array for the current thread is empty,
+except for the btr_search_latch.
+@return	a latch, or NULL if empty except the exceptions specified below */
 UNIV_INTERN
-ibool
-sync_thread_levels_empty(void)
-/*==========================*/
+void*
+sync_thread_levels_nonempty_trx(
+/*============================*/
+	ibool	has_search_latch)
+				/*!< in: TRUE if and only if the thread
+				is supposed to hold btr_search_latch */
 {
-	return(sync_thread_levels_empty_gen(FALSE));
+	ulint		i;
+	sync_arr_t*	arr;
+	sync_thread_t*	thread_slot;
+
+	if (!sync_order_checks_on) {
+
+		return(NULL);
+	}
+
+	ut_a(!has_search_latch
+	     || sync_thread_levels_contains(SYNC_SEARCH_SYS));
+
+	mutex_enter(&sync_thread_mutex);
+
+	thread_slot = sync_thread_level_arrays_find_slot();
+
+	if (thread_slot == NULL) {
+
+		mutex_exit(&sync_thread_mutex);
+
+		return(NULL);
+	}
+
+	arr = thread_slot->levels;
+
+	for (i = 0; i < arr->n_elems; ++i) {
+		const sync_level_t*	slot;
+
+		slot = &arr->elems[i];
+
+		if (slot->latch != NULL
+		    && (!has_search_latch
+			|| slot->level != SYNC_SEARCH_SYS)) {
+
+			mutex_exit(&sync_thread_mutex);
+			ut_error;
+
+			return(slot->latch);
+		}
+	}
+
+	mutex_exit(&sync_thread_mutex);
+
+	return(NULL);
 }
 
 /******************************************************************//**
@@ -1277,8 +1321,7 @@ sync_thread_add_level(
 		ut_a(sync_thread_levels_contain(array, SYNC_RSEG));
 		break;
 	case SYNC_RSEG_HEADER_NEW:
-		ut_a(sync_thread_levels_contain(array, SYNC_LOCK_SYS)
-		     && sync_thread_levels_contain(array, SYNC_FSP_PAGE));
+		ut_a(sync_thread_levels_contain(array, SYNC_FSP_PAGE));
 		break;
 	case SYNC_TREE_NODE:
 		ut_a(sync_thread_levels_contain(array, SYNC_INDEX_TREE)
@@ -1454,11 +1497,8 @@ sync_init(void)
 
 	sync_initialized = TRUE;
 
-	/* Create the primary system wait array which is protected by an OS
-	mutex */
+	sync_array_init(OS_THREAD_MAX_N);
 
-	sync_primary_wait_array = sync_array_create(OS_THREAD_MAX_N,
-						    SYNC_ARRAY_OS_MUTEX);
 #ifdef UNIV_SYNC_DEBUG
 	/* Create the thread latch level array where the latch levels
 	are stored for each OS thread */
@@ -1531,7 +1571,7 @@ sync_close(void)
 {
 	mutex_t*	mutex;
 
-	sync_array_free(sync_primary_wait_array);
+	sync_array_close();
 
 	for (mutex = UT_LIST_GET_FIRST(mutex_list);
 	     mutex != NULL;
@@ -1614,7 +1654,7 @@ sync_print(
 	rw_lock_list_print_info(file);
 #endif /* UNIV_SYNC_DEBUG */
 
-	sync_array_print_info(file, sync_primary_wait_array);
+	sync_array_print(file);
 
 	sync_print_wait_info(file);
 }

=== modified file 'storage/innobase/trx/trx0purge.c'
--- a/storage/innobase/trx/trx0purge.c	2011-02-22 05:11:15 +0000
+++ b/storage/innobase/trx/trx0purge.c	2011-04-14 06:46:38 +0000
@@ -291,6 +291,8 @@ trx_purge_add_update_undo_to_history(
 	rw_lock_x_unlock(&trx_sys->lock);
 #endif /* HAVE_ATOMIC_BUILTINS */
 
+	srv_wake_purge_thread_if_not_active();
+
 	/* Write the trx number to the undo log header */
 	mlog_write_ull(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr);
 
@@ -1297,6 +1299,7 @@ run_synchronously:
 		trx_purge_truncate();
 	}
 
+	MONITOR_INC_VALUE(MONITOR_PURGE_INVOKED, 1);
 	MONITOR_INC_VALUE(MONITOR_PURGE_N_PAGE_HANDLED, n_pages_handled);
 
 	if (srv_print_thread_releases) {

=== modified file 'storage/innobase/trx/trx0roll.c'
--- a/storage/innobase/trx/trx0roll.c	2011-03-30 12:20:45 +0000
+++ b/storage/innobase/trx/trx0roll.c	2011-04-05 11:12:48 +0000
@@ -574,10 +574,6 @@ trx_rollback_active(
 		(ullint) trx->id,
 		(ulong) rows_to_undo, unit);
 
-	trx->mysql_thread_id = 0;
-
-	trx->mysql_process_no = 0;
-
 	if (trx_get_dict_operation(trx) != TRX_DICT_OP_NONE) {
 		row_mysql_lock_data_dictionary(trx);
 		dictionary_locked = TRUE;

=== modified file 'storage/innobase/trx/trx0sys.c'
--- a/storage/innobase/trx/trx0sys.c	2011-03-23 13:43:14 +0000
+++ b/storage/innobase/trx/trx0sys.c	2011-04-13 08:34:16 +0000
@@ -37,6 +37,7 @@ Created 3/26/1996 Heikki Tuuri
 #include "trx0rseg.h"
 #include "trx0undo.h"
 #include "srv0srv.h"
+#include "srv0start.h"
 #include "trx0purge.h"
 #include "log0log.h"
 #include "log0recv.h"
@@ -131,12 +132,15 @@ static const ulint	FILE_FORMAT_NAME_N
 /* Key to register the mutex with performance schema */
 UNIV_INTERN mysql_pfs_key_t	trx_doublewrite_mutex_key;
 UNIV_INTERN mysql_pfs_key_t	file_format_max_mutex_key;
-/* Key to register the trx_sys->lock with performance schema */
-UNIV_INTERN mysql_pfs_key_t	trx_sys_rw_lock_key;
 /* Key to register the trx_sys->read_view_mutex with performance schema */
 UNIV_INTERN mysql_pfs_key_t	read_view_mutex_key;
 #endif /* UNIV_PFS_MUTEX */
 
+#ifdef UNIV_PFS_RWLOCK
+/* Key to register the trx_sys->lock with performance schema */
+UNIV_INTERN mysql_pfs_key_t	trx_sys_rw_lock_key;
+#endif /* UNIV_PFS_RWLOCK */
+
 #ifndef UNIV_HOTBACKUP
 /** This is used to track the maximum file format id known to InnoDB. It's
 updated via SET GLOBAL innodb_file_format_max = 'x' or when we open
@@ -1425,23 +1429,6 @@ trx_sys_print_mysql_binlog_offset_from_p
 	}
 }
 
-
-/* THESE ARE COPIED FROM NON-HOTBACKUP PART OF THE INNODB SOURCE TREE
-   (This code duplicaton should be fixed at some point!)
-*/
-
-#define	TRX_SYS_SPACE	0	/* the SYSTEM tablespace */
-/* The offset of the file format tag on the trx system header page */
-#define TRX_SYS_FILE_FORMAT_TAG		(UNIV_PAGE_SIZE - 16)
-/* We use these random constants to reduce the probability of reading
-garbage (from previous versions) that maps to an actual format id. We
-use these as bit masks at the time of  reading and writing from/to disk. */
-#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW	3645922177UL
-#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH	2745987765UL
-
-/* END OF COPIED DEFINITIONS */
-
-
 /*****************************************************************//**
 Reads the file format id from the first system table space file.
 Even if the call succeeds and returns TRUE, the returned format id
@@ -1634,9 +1621,11 @@ trx_sys_close(void)
 /*===============*/
 {
 	ulint		i;
+	trx_t*		trx;
 	read_view_t*	view;
 
 	ut_ad(trx_sys != NULL);
+	ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS);
 
 	/* Check that all read views are closed except read view owned
 	by a purge. */
@@ -1671,6 +1660,14 @@ trx_sys_close(void)
 	trx_doublewrite = NULL;
 
 	rw_lock_x_lock(&trx_sys->lock);
+
+	/* Only prepared transactions may be left in the system. Free them. */
+	ut_a(UT_LIST_GET_LEN(trx_sys->trx_list) == trx_sys->n_prepared_trx);
+
+	while ((trx = UT_LIST_GET_FIRST(trx_sys->trx_list)) != NULL) {
+		trx_free_prepared(trx);
+	}
+
 	mutex_free(&trx_sys->read_view_mutex);
 
 	/* There can't be any active transactions. */
@@ -1710,10 +1707,9 @@ trx_sys_close(void)
 
 	trx_sys = NULL;
 }
-#endif /* !UNIV_HOTBACKUP */
 
 /*********************************************************************
-Check if there are any active transactions.
+Check if there are any active (non-prepared) transactions.
 @return total number of active transactions or 0 if none */
 UNIV_INTERN
 ulint
@@ -1725,7 +1721,9 @@ trx_sys_any_active_transactions(void)
 	rw_lock_s_lock(&trx_sys->lock);
 
 	total_trx = UT_LIST_GET_LEN(trx_sys->trx_list)
-	       	  + trx_n_mysql_transactions;
+		+ trx_sys->n_mysql_trx;
+	ut_a(total_trx >= trx_sys->n_prepared_trx);
+	total_trx -= trx_sys->n_prepared_trx;
 
 	rw_lock_s_unlock(&trx_sys->lock);
 
@@ -1759,3 +1757,4 @@ trx_sys_validate_trx_list(void)
 	return(TRUE);
 }
 #endif /* UNIV_DEBUG */
+#endif /* !UNIV_HOTBACKUP */

=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c	2011-03-24 12:24:08 +0000
+++ b/storage/innobase/trx/trx0trx.c	2011-04-18 11:09:37 +0000
@@ -49,10 +49,6 @@ Created 3/26/1996 Heikki Tuuri
 /** Dummy session used currently in MySQL interface */
 UNIV_INTERN sess_t*		trx_dummy_sess = NULL;
 
-/** Number of transactions currently allocated for MySQL: protected by
-trx_sys->lock */
-UNIV_INTERN ulint		trx_n_mysql_transactions = 0;
-
 #ifdef UNIV_PFS_MUTEX
 /* Key to register the mutex with performance schema */
 UNIV_INTERN mysql_pfs_key_t	trx_mutex_key;
@@ -96,7 +92,8 @@ trx_t*
 trx_create(void)
 /*============*/
 {
-	trx_t*	trx;
+	trx_t*		trx;
+	mem_heap_t*	heap;
 
 	trx = mem_zalloc(sizeof(*trx));
 
@@ -134,9 +131,15 @@ trx_create(void)
 
 	trx->op_info = "";
 
+	heap = mem_heap_create(sizeof(ib_vector_t) + sizeof(void*) * 8);
+
 	/* Remember to free the vector explicitly in trx_free(). */
-	trx->autoinc_locks = ib_vector_create(
-		mem_heap_create(sizeof(ib_vector_t) + sizeof(void*) * 4), 4);
+	trx->autoinc_locks = ib_vector_create(heap, 4);
+
+	/* Remember to free the vector explicitly in trx_free(). */
+	heap = mem_heap_create(sizeof(ib_vector_t) + sizeof(void*) * 128);
+
+	trx->lock.table_locks = ib_vector_create(heap, 32);
 
 	return(trx);
 }
@@ -171,17 +174,13 @@ trx_allocate_for_mysql(void)
 
 	rw_lock_x_lock(&trx_sys->lock);
 
-	++trx_n_mysql_transactions;
+	trx_sys->n_mysql_trx++;
 
 	ut_d(trx->in_mysql_trx_list = TRUE);
 	UT_LIST_ADD_FIRST(mysql_trx_list, trx_sys->mysql_trx_list, trx);
 
 	rw_lock_x_unlock(&trx_sys->lock);
 
-	trx->mysql_thread_id = os_thread_get_curr_id();
-
-	trx->mysql_process_no = os_proc_get_number();
-
 	return(trx);
 }
 
@@ -208,47 +207,11 @@ trx_free(
 /*=====*/
 	trx_t*	trx)	/*!< in, own: trx object */
 {
-	if (UNIV_UNLIKELY(trx->declared_to_be_inside_innodb)) {
-		ut_print_timestamp(stderr);
-		fputs("  InnoDB: Error: Freeing a trx which is declared"
-		      " to be processing\n"
-		      "InnoDB: inside InnoDB.\n", stderr);
-		trx_print(stderr, trx, 600);
-		putc('\n', stderr);
-
-		/* This is an error but not a fatal error. We must keep
-		the counters like srv_conc_n_threads accurate. */
-		srv_conc_force_exit_innodb(trx);
-	}
-
-	if (UNIV_UNLIKELY(trx->n_mysql_tables_in_use != 0
-			  || trx->mysql_n_tables_locked != 0)) {
-
-		ut_print_timestamp(stderr);
-		fprintf(stderr,
-			"  InnoDB: Error: MySQL is freeing a thd\n"
-			"InnoDB: though trx->n_mysql_tables_in_use is %lu\n"
-			"InnoDB: and trx->mysql_n_tables_locked is %lu.\n",
-			(ulong)trx->n_mysql_tables_in_use,
-			(ulong)trx->mysql_n_tables_locked);
-		trx_print(stderr, trx, 600);
-		ut_print_buf(stderr, trx, sizeof(trx_t));
-		putc('\n', stderr);
-	}
-
-	trx_mutex_enter(trx);
-
 	ut_a(trx->magic_n == TRX_MAGIC_N);
-
-	trx->magic_n = 11112222;
-
-	ut_a(trx->state == TRX_STATE_NOT_STARTED);
+	ut_ad(!trx->in_trx_list);
 
 	mutex_free(&trx->undo_mutex);
 
-	ut_a(trx->insert_undo == NULL);
-	ut_a(trx->update_undo == NULL);
-
 	if (trx->undo_no_arr != NULL) {
 		trx_undo_arr_free(trx->undo_no_arr);
 	}
@@ -270,15 +233,12 @@ trx_free(
 		mem_heap_free(trx->global_read_view_heap);
 	}
 
-	trx->global_read_view = NULL;
-
-	ut_a(trx->read_view == NULL);
-
 	ut_a(ib_vector_is_empty(trx->autoinc_locks));
 	/* We allocated a dedicated heap for the vector. */
 	ib_vector_free(trx->autoinc_locks);
 
-	trx_mutex_exit(trx);
+	/* We allocated a dedicated heap for the vector. */
+	ib_vector_free(trx->lock.table_locks);
 
 	mutex_free(&trx->mutex);
 
@@ -293,6 +253,61 @@ trx_free_for_background(
 /*====================*/
 	trx_t*	trx)	/*!< in, own: trx object */
 {
+	if (UNIV_UNLIKELY(trx->declared_to_be_inside_innodb)) {
+		ut_print_timestamp(stderr);
+		fputs("  InnoDB: Error: Freeing a trx which is declared"
+		      " to be processing\n"
+		      "InnoDB: inside InnoDB.\n", stderr);
+		trx_print(stderr, trx, 600);
+		putc('\n', stderr);
+
+		/* This is an error but not a fatal error. We must keep
+		the counters like srv_conc_n_threads accurate. */
+		srv_conc_force_exit_innodb(trx);
+	}
+
+	if (UNIV_UNLIKELY(trx->n_mysql_tables_in_use != 0
+			  || trx->mysql_n_tables_locked != 0)) {
+
+		ut_print_timestamp(stderr);
+		fprintf(stderr,
+			"  InnoDB: Error: MySQL is freeing a thd\n"
+			"InnoDB: though trx->n_mysql_tables_in_use is %lu\n"
+			"InnoDB: and trx->mysql_n_tables_locked is %lu.\n",
+			(ulong)trx->n_mysql_tables_in_use,
+			(ulong)trx->mysql_n_tables_locked);
+		trx_print(stderr, trx, 600);
+		ut_print_buf(stderr, trx, sizeof(trx_t));
+		putc('\n', stderr);
+	}
+
+	ut_a(trx->state == TRX_STATE_NOT_STARTED);
+	ut_a(trx->insert_undo == NULL);
+	ut_a(trx->update_undo == NULL);
+	ut_a(trx->read_view == NULL);
+
+	trx_free(trx);
+}
+
+/********************************************************************//**
+At shutdown, frees a transaction object that is in the PREPARED state. */
+UNIV_INTERN
+void
+trx_free_prepared(
+/*==============*/
+	trx_t*	trx)	/*!< in, own: trx object */
+{
+#ifdef UNIV_SYNC_DEBUG
+	ut_ad(rw_lock_own(&trx_sys->lock, RW_LOCK_EX));
+#endif /* UNIV_SYNC_DEBUG */
+
+	ut_a(trx_state_eq(trx, TRX_STATE_PREPARED));
+	ut_a(trx->magic_n == TRX_MAGIC_N);
+
+	trx_undo_free_prepared(trx);
+	ut_ad(trx->in_trx_list);
+	ut_d(trx->in_trx_list = FALSE);
+	UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
 	trx_free(trx);
 }
 
@@ -312,7 +327,7 @@ trx_free_for_mysql(
 
 	ut_ad(trx_sys_validate_trx_list());
 
-	--trx_n_mysql_transactions;
+	trx_sys->n_mysql_trx--;
 
 	rw_lock_x_unlock(&trx_sys->lock);
 
@@ -405,6 +420,7 @@ trx_resurrect_insert(
 			if (srv_force_recovery == 0) {
 
 				trx->state = TRX_STATE_PREPARED;
+				trx_sys->n_prepared_trx++;
 			} else {
 				fprintf(stderr,
 					"InnoDB: Since innodb_force_recovery"
@@ -463,6 +479,11 @@ trx_resurrect_update_in_prepared_state(
 			" was in the XA prepared state.\n", trx->id);
 
 		if (srv_force_recovery == 0) {
+			if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) {
+				trx_sys->n_prepared_trx++;
+			} else {
+				ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED));
+			}
 
 			trx->state = TRX_STATE_PREPARED;
 		} else {
@@ -554,7 +575,7 @@ trx_lists_init_at_db_start(void)
 			continue;
 		}
 
-		/* Ressurrect transactions that were doing inserts. */
+		/* Resurrect transactions that were doing inserts. */
 		for (undo = UT_LIST_GET_FIRST(rseg->insert_undo_list);
 		     undo != NULL;
 		     undo = UT_LIST_GET_NEXT(undo_list, undo)) {
@@ -613,7 +634,7 @@ trx_assign_rseg(
 	i = latest_rseg++;
         i %= max_undo_logs;
 
-	/* Note: The assumtion here is that there can't be any gaps in
+	/* Note: The assumption here is that there can't be any gaps in
 	the array. Once we implement more flexible rollback segment
 	management this may not hold. The assertion checks for that case. */
 
@@ -658,6 +679,9 @@ trx_start_low(
 	ut_a(trx->rseg == NULL);
 	trx->rseg = rseg;
 
+	ut_a(ib_vector_is_empty(trx->autoinc_locks));
+	ut_a(ib_vector_is_empty(trx->lock.table_locks));
+
 	rw_lock_x_lock(&trx_sys->lock);
 
 	/* If this transaction came from trx_allocate_for_mysql(),
@@ -854,6 +878,7 @@ trx_commit(
 	/* Remove the transaction from the list of active transactions
 	now that it no longer holds any user locks. */
 
+	ut_ad(trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY));
 	rw_lock_x_lock(&trx_sys->lock);
 	ut_ad(trx->in_trx_list);
 	ut_d(trx->in_trx_list = FALSE);
@@ -1301,11 +1326,6 @@ trx_print_low(
 	fprintf(f, ", state %lu", (ulong) trx->state);
 	ut_ad(0);
 state_ok:
-#ifdef UNIV_LINUX
-	fprintf(f, ", process no %lu", trx->mysql_process_no);
-#endif
-	fprintf(f, ", OS thread id %lu",
-		(ulong) os_thread_pf(trx->mysql_thread_id));
 
 	/* prevent a race condition */
 	op_info = trx->op_info;
@@ -1570,7 +1590,10 @@ trx_prepare(
 
 	/*--------------------------------------*/
 	ut_a(trx->state == TRX_STATE_ACTIVE);
+	rw_lock_x_lock(&trx_sys->lock);
 	trx->state = TRX_STATE_PREPARED;
+	trx_sys->n_prepared_trx++;
+	rw_lock_x_unlock(&trx_sys->lock);
 	/*--------------------------------------*/
 
 	if (lsn) {
@@ -1736,7 +1759,8 @@ trx_get_trx_by_xid(
 		of gtrid_length+bqual_length bytes should be
 		the same */
 
-		if (trx_state_eq(trx, TRX_STATE_PREPARED)
+		if (trx->is_recovered
+		    && trx_state_eq(trx, TRX_STATE_PREPARED)
 		    && xid->gtrid_length == trx->xid.gtrid_length
 		    && xid->bqual_length == trx->xid.bqual_length
 		    && memcmp(xid->data, trx->xid.data,

=== modified file 'storage/innobase/trx/trx0undo.c'
--- a/storage/innobase/trx/trx0undo.c	2011-03-08 19:14:42 +0000
+++ b/storage/innobase/trx/trx0undo.c	2011-04-12 08:07:43 +0000
@@ -36,6 +36,7 @@ Created 3/26/1996 Heikki Tuuri
 #include "trx0rseg.h"
 #include "trx0trx.h"
 #include "srv0srv.h"
+#include "srv0start.h"
 #include "trx0rec.h"
 #include "trx0purge.h"
 #include "srv0mon.h"
@@ -1983,4 +1984,28 @@ trx_undo_insert_cleanup(
 
 	mutex_exit(&(rseg->mutex));
 }
+
+/********************************************************************//**
+At shutdown, frees the undo logs of a PREPARED transaction. */
+UNIV_INTERN
+void
+trx_undo_free_prepared(
+/*===================*/
+	trx_t*	trx)	/*!< in/out: PREPARED transaction */
+{
+	ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS);
+
+	if (trx->update_undo) {
+		ut_a(trx->update_undo->state == TRX_UNDO_PREPARED);
+		UT_LIST_REMOVE(undo_list, trx->rseg->update_undo_list,
+			       trx->update_undo);
+		trx_undo_mem_free(trx->update_undo);
+	}
+	if (trx->insert_undo) {
+		ut_a(trx->insert_undo->state == TRX_UNDO_PREPARED);
+		UT_LIST_REMOVE(undo_list, trx->rseg->insert_undo_list,
+			       trx->insert_undo);
+		trx_undo_mem_free(trx->insert_undo);
+	}
+}
 #endif /* !UNIV_HOTBACKUP */

=== modified file 'storage/innobase/ut/ut0dbg.c'
--- a/storage/innobase/ut/ut0dbg.c	2011-02-25 09:27:27 +0000
+++ b/storage/innobase/ut/ut0dbg.c	2011-04-13 08:34:16 +0000
@@ -25,7 +25,9 @@ Created 1/30/1994 Heikki Tuuri
 
 #include "univ.i"
 #include "ut0dbg.h"
-#include "ha_prototypes.h"
+#ifndef UNIV_HOTBACKUP
+# include "ha_prototypes.h"
+#endif /* !UNIV_HOTBACKUP */
 
 #if defined(__GNUC__) && (__GNUC__ > 2)
 #else
@@ -56,7 +58,7 @@ ut_dbg_assertion_failed(
 	ut_print_timestamp(stderr);
 #ifdef UNIV_HOTBACKUP
 	fprintf(stderr, "  InnoDB: Assertion failure in file %s line %lu\n",
-		innobase_basename(file), line);
+		file, line);
 #else /* UNIV_HOTBACKUP */
 	fprintf(stderr,
 		"  InnoDB: Assertion failure in thread %lu"

=== modified file 'storage/innobase/ut/ut0ut.c'
--- a/storage/innobase/ut/ut0ut.c	2011-02-22 05:11:15 +0000
+++ b/storage/innobase/ut/ut0ut.c	2011-04-13 08:34:16 +0000
@@ -245,16 +245,16 @@ ut_print_timestamp(
 		(int)cal_tm.wMinute,
 		(int)cal_tm.wSecond);
 #else
-	struct tm  cal_tm;
 	struct tm* cal_tm_ptr;
 	time_t	   tm;
 
-	time(&tm);
-
 #ifdef HAVE_LOCALTIME_R
+	struct tm  cal_tm;
+	time(&tm);
 	localtime_r(&tm, &cal_tm);
 	cal_tm_ptr = &cal_tm;
 #else
+	time(&tm);
 	cal_tm_ptr = localtime(&tm);
 #endif
 	fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
@@ -288,16 +288,16 @@ ut_sprintf_timestamp(
 		(int)cal_tm.wMinute,
 		(int)cal_tm.wSecond);
 #else
-	struct tm  cal_tm;
 	struct tm* cal_tm_ptr;
 	time_t	   tm;
 
-	time(&tm);
-
 #ifdef HAVE_LOCALTIME_R
+	struct tm  cal_tm;
+	time(&tm);
 	localtime_r(&tm, &cal_tm);
 	cal_tm_ptr = &cal_tm;
 #else
+	time(&tm);
 	cal_tm_ptr = localtime(&tm);
 #endif
 	sprintf(buf, "%02d%02d%02d %2d:%02d:%02d",
@@ -333,16 +333,16 @@ ut_sprintf_timestamp_without_extra_chars
 		(int)cal_tm.wMinute,
 		(int)cal_tm.wSecond);
 #else
-	struct tm  cal_tm;
 	struct tm* cal_tm_ptr;
 	time_t	   tm;
 
-	time(&tm);
-
 #ifdef HAVE_LOCALTIME_R
+	struct tm  cal_tm;
+	time(&tm);
 	localtime_r(&tm, &cal_tm);
 	cal_tm_ptr = &cal_tm;
 #else
+	time(&tm);
 	cal_tm_ptr = localtime(&tm);
 #endif
 	sprintf(buf, "%02d%02d%02d_%2d_%02d_%02d",
@@ -374,16 +374,16 @@ ut_get_year_month_day(
 	*month = (ulint)cal_tm.wMonth;
 	*day = (ulint)cal_tm.wDay;
 #else
-	struct tm  cal_tm;
 	struct tm* cal_tm_ptr;
 	time_t	   tm;
 
-	time(&tm);
-
 #ifdef HAVE_LOCALTIME_R
+	struct tm  cal_tm;
+	time(&tm);
 	localtime_r(&tm, &cal_tm);
 	cal_tm_ptr = &cal_tm;
 #else
+	time(&tm);
 	cal_tm_ptr = localtime(&tm);
 #endif
 	*year = (ulint)cal_tm_ptr->tm_year + 1900;


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20110422030702-qfyjllsayjn1qy06.bundle
Thread
bzr push into mysql-trunk branch (chris.powers:3284 to 3285) Christopher Powers22 Apr