List:Commits« Previous MessageNext Message »
From:Marc Alff Date:December 9 2010 4:18pm
Subject:bzr push into mysql-trunk-wl5379 branch (marc.alff:3210 to 3211) WL#5371
WL#5379 WL#5420
View as plain text  
 3211 Marc Alff	2010-12-09
      WL#5371 PERFORMANCE_SCHEMA Instrumenting Table Locks
      WL#5379 PERFORMANCE SCHEMA TABLE / INDEX IO SUMMARY
      WL#5420 PERFORMANCE SCHEMA TABLE LOCK WAIT SUMMARY
      
      Implementation of table io and table lock aggregates.

    added:
      storage/perfschema/table_tiws_by_index_usage.cc
      storage/perfschema/table_tiws_by_index_usage.h
      storage/perfschema/table_tiws_by_table.cc
      storage/perfschema/table_tiws_by_table.h
      storage/perfschema/table_tlws_by_table.cc
      storage/perfschema/table_tlws_by_table.h
    modified:
      include/mysql/psi/mysql_table.h
      include/mysql/psi/psi.h
      include/mysql/psi/psi_abi_v1.h.pp
      include/mysql/psi/psi_abi_v2.h.pp
      mysql-test/suite/perfschema/include/schema.inc
      mysql-test/suite/perfschema/include/start_server_common.inc
      mysql-test/suite/perfschema/r/func_file_io.result
      mysql-test/suite/perfschema/r/information_schema.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result
      mysql-test/suite/perfschema/r/schema_lc0.result
      mysql-test/suite/perfschema/r/schema_lc1.result
      mysql-test/suite/perfschema/r/schema_lc2.result
      mysql-test/suite/perfschema/r/start_server_no_cond_class.result
      mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
      mysql-test/suite/perfschema/r/start_server_no_file_class.result
      mysql-test/suite/perfschema/r/start_server_no_file_inst.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
      mysql-test/suite/perfschema/r/start_server_no_setup_actors.result
      mysql-test/suite/perfschema/r/start_server_no_setup_objects.result
      mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
      mysql-test/suite/perfschema/r/start_server_no_table_inst.result
      mysql-test/suite/perfschema/r/start_server_no_thread_class.result
      mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
      mysql-test/suite/perfschema/r/start_server_nothing.result
      mysql-test/suite/perfschema/r/start_server_off.result
      mysql-test/suite/perfschema/r/start_server_on.result
      mysys/thr_lock.c
      scripts/mysql_system_tables.sql
      sql/handler.cc
      storage/perfschema/CMakeLists.txt
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_column_types.h
      storage/perfschema/pfs_engine_table.cc
      storage/perfschema/pfs_events_waits.cc
      storage/perfschema/pfs_events_waits.h
      storage/perfschema/pfs_instr.cc
      storage/perfschema/pfs_instr.h
      storage/perfschema/pfs_instr_class.cc
      storage/perfschema/pfs_instr_class.h
      storage/perfschema/pfs_lock.h
      storage/perfschema/pfs_stat.h
      storage/perfschema/table_events_waits.cc
      storage/perfschema/table_events_waits.h
      storage/perfschema/table_ews_global_by_event_name.cc
      storage/perfschema/table_ews_global_by_event_name.h
      storage/perfschema/table_helper.h
      storage/perfschema/table_os_global_by_type.cc
      storage/perfschema/table_setup_instruments.cc
 3210 Marc Alff	2010-12-09
      New tree

    modified:
      .bzr-mysql/default.conf
=== modified file 'include/mysql/psi/mysql_table.h'
--- a/include/mysql/psi/mysql_table.h	2010-07-26 17:20:27 +0000
+++ b/include/mysql/psi/mysql_table.h	2010-12-09 16:17:13 +0000
@@ -36,8 +36,10 @@
   Do not use a ';' after this macro
   @param LOCKER the locker
   @param STATE the locker state
-  @sa MYSQL_START_TABLE_WAIT.
-  @sa MYSQL_END_TABLE_WAIT.
+  @sa MYSQL_START_TABLE_IO_WAIT.
+  @sa MYSQL_END_TABLE_IO_WAIT.
+  @sa MYSQL_START_TABLE_LOCK_WAIT.
+  @sa MYSQL_END_TABLE_LOCK_WAIT.
 */
 #ifdef HAVE_PSI_INTERFACE
   #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \
@@ -48,8 +50,8 @@
 #endif
 
 /**
-  @def MYSQL_START_TABLE_WAIT
-  Instrumentation helper for table waits.
+  @def MYSQL_START_TABLE_IO_WAIT
+  Instrumentation helper for table io_waits.
   This instrumentation marks the start of a wait event.
   @param LOCKER the locker
   @param STATE the locker state
@@ -60,59 +62,128 @@
   @sa MYSQL_END_TABLE_WAIT.
 */
 #ifdef HAVE_PSI_INTERFACE
-  #define MYSQL_START_TABLE_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS) \
-    LOCKER= inline_mysql_start_table_wait(STATE, PSI, \
-                                          OP, INDEX, FLAGS, __FILE__, __LINE__)
+  #define MYSQL_START_TABLE_IO_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS) \
+    LOCKER= inline_mysql_start_table_io_wait(STATE, PSI, \
+                                             OP, INDEX, __FILE__, __LINE__)
 #else
-  #define MYSQL_START_TABLE_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS) \
+  #define MYSQL_START_TABLE_IO_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS) \
     do {} while (0)
 #endif
 
 /**
-  @def MYSQL_END_TABLE_WAIT
-  Instrumentation helper for table waits.
+  @def MYSQL_END_TABLE_IO_WAIT
+  Instrumentation helper for table io waits.
   This instrumentation marks the end of a wait event.
   @param LOCKER the locker
-  @sa MYSQL_START_TABLE_WAIT.
+  @sa MYSQL_START_TABLE_IO_WAIT.
 */
 #ifdef HAVE_PSI_INTERFACE
-  #define MYSQL_END_TABLE_WAIT(LOCKER) \
-    inline_mysql_end_table_wait(LOCKER)
+  #define MYSQL_END_TABLE_IO_WAIT(LOCKER) \
+    inline_mysql_end_table_io_wait(LOCKER)
 #else
-  #define MYSQL_END_TABLE_WAIT(LOCKER) \
+  #define MYSQL_END_TABLE_IO_WAIT(LOCKER) \
     do {} while (0)
 #endif
 
 #ifdef HAVE_PSI_INTERFACE
 /**
-  Instrumentation calls for MYSQL_START_TABLE_WAIT.
-  @sa MYSQL_START_TABLE_WAIT.
+  Instrumentation calls for MYSQL_START_TABLE_IO_WAIT.
+  @sa MYSQL_END_TABLE_IO_WAIT.
 */
 static inline struct PSI_table_locker *
-inline_mysql_start_table_wait(PSI_table_locker_state *state,
-                              struct PSI_table *psi, enum PSI_table_operation op,
-                              uint index, ulong flags,
-                              const char *src_file, int src_line)
+inline_mysql_start_table_io_wait(PSI_table_locker_state *state,
+                                 struct PSI_table *psi,
+                                 enum PSI_table_io_operation op,
+                                 uint index,
+                                 const char *src_file, int src_line)
 {
   struct PSI_table_locker *locker= NULL;
   if (likely(PSI_server && psi))
   {
-    locker= PSI_server->get_thread_table_locker(state, psi, op, flags);
+    locker= PSI_server->get_thread_table_io_locker(state, psi, op, index);
     if (likely(locker != NULL))
-      PSI_server->start_table_wait(locker, index, src_file, src_line);
+      PSI_server->start_table_io_wait(locker, src_file, src_line);
   }
   return locker;
 }
 
 /**
-  Instrumentation calls for MYSQL_END_TABLE_WAIT.
-  @sa MYSQL_END_TABLE_WAIT.
+  Instrumentation calls for MYSQL_END_TABLE_IO_WAIT.
+  @sa MYSQL_START_TABLE_IO_WAIT.
+*/
+static inline void
+inline_mysql_end_table_io_wait(struct PSI_table_locker *locker)
+{
+  if (likely(locker != NULL))
+    PSI_server->end_table_io_wait(locker);
+}
+#endif
+
+/**
+  @def MYSQL_START_TABLE_LOCK_WAIT
+  Instrumentation helper for table lock waits.
+  This instrumentation marks the start of a wait event.
+  @param LOCKER the locker
+  @param STATE the locker state
+  @param PSI the instrumented table
+  @param OP the table operation to be performed
+  @param FLAGS per table operation flags.
+  @sa MYSQL_END_TABLE_LOCK_WAIT.
+*/
+#ifdef HAVE_PSI_INTERFACE
+  #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
+    LOCKER= inline_mysql_start_table_lock_wait(STATE, PSI, \
+                                               OP, FLAGS, __FILE__, __LINE__)
+#else
+  #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
+    do {} while (0)
+#endif
+
+/**
+  @def MYSQL_END_TABLE_LOCK_WAIT
+  Instrumentation helper for table lock waits.
+  This instrumentation marks the end of a wait event.
+  @param LOCKER the locker
+  @sa MYSQL_START_TABLE_LOCK_WAIT.
+*/
+#ifdef HAVE_PSI_INTERFACE
+  #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
+    inline_mysql_end_table_lock_wait(LOCKER)
+#else
+  #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
+    do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_INTERFACE
+/**
+  Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
+  @sa MYSQL_END_TABLE_LOCK_WAIT.
+*/
+static inline struct PSI_table_locker *
+inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
+                                   struct PSI_table *psi,
+                                   enum PSI_table_lock_operation op,
+                                   ulong flags, const char *src_file, int src_line)
+{
+  struct PSI_table_locker *locker= NULL;
+  if (likely(PSI_server && psi))
+  {
+    locker= PSI_server->get_thread_table_lock_locker(state, psi, op, flags);
+    if (likely(locker != NULL))
+      PSI_server->start_table_lock_wait(locker, src_file, src_line);
+  }
+  return locker;
+}
+
+/**
+  Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
+  @sa MYSQL_START_TABLE_LOCK_WAIT.
 */
 static inline void
-inline_mysql_end_table_wait(struct PSI_table_locker *locker)
+inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
 {
   if (likely(locker != NULL))
-    PSI_server->end_table_wait(locker);
+    PSI_server->end_table_lock_wait(locker);
 }
 #endif
 

=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h	2010-07-30 09:02:32 +0000
+++ b/include/mysql/psi/psi.h	2010-12-09 16:17:13 +0000
@@ -237,21 +237,26 @@ enum PSI_file_operation
   PSI_FILE_SYNC= 16
 };
 
-/** Operation performed on an instrumented table. */
-enum PSI_table_operation
+/** IO operation performed on an instrumented table. */
+enum PSI_table_io_operation
 {
-  /** Table lock, in the server layer. */
-  PSI_TABLE_LOCK= 0,
-  /** Table lock, in the storage engine layer. */
-  PSI_TABLE_EXTERNAL_LOCK= 1,
   /** Row fetch. */
-  PSI_TABLE_FETCH_ROW= 2,
+  PSI_TABLE_FETCH_ROW= 0,
   /** Row write. */
-  PSI_TABLE_WRITE_ROW= 3,
+  PSI_TABLE_WRITE_ROW= 1,
   /** Row update. */
-  PSI_TABLE_UPDATE_ROW= 4,
+  PSI_TABLE_UPDATE_ROW= 2,
   /** Row delete. */
-  PSI_TABLE_DELETE_ROW= 5
+  PSI_TABLE_DELETE_ROW= 3
+};
+
+/** Lock operation performed on an instrumented table. */
+enum PSI_table_lock_operation
+{
+  /** Table lock, in the server layer. */
+  PSI_TABLE_LOCK= 0,
+  /** Table lock, in the storage engine layer. */
+  PSI_TABLE_EXTERNAL_LOCK= 1,
 };
 
 /**
@@ -572,13 +577,15 @@ struct PSI_file_locker_state_v1
 };
 
 /**
-  State data storage for @c get_thread_table_locker_v1_t.
+  State data storage for @c get_thread_table_io_locker_v1_t,
+  @c get_thread_table_lock_locker_v1_t.
   This structure provide temporary storage to a table locker.
   The content of this structure is considered opaque,
   the fields are only hints of what an implementation
   of the psi interface can use.
   This memory is provided by the instrumented code for performance reasons.
-  @sa get_thread_table_locker_v1_t
+  @sa get_thread_table_io_locker_v1_t
+  @sa get_thread_table_lock_locker_v1_t
 */
 struct PSI_table_locker_state_v1
 {
@@ -588,20 +595,20 @@ struct PSI_table_locker_state_v1
   struct PSI_table *m_table;
   /** Current table share. */
   struct PSI_table_share *m_table_share;
-  /** Instrumentation class. */
-  void *m_class;
   /** Current thread. */
   struct PSI_thread *m_thread;
   /** Timer start. */
   ulonglong m_timer_start;
   /** Timer function. */
   ulonglong (*m_timer)(void);
-  /** Current operation. */
-  enum PSI_table_operation m_operation;
-  /** Current table io index. */
+  /** Current io operation. */
+  enum PSI_table_io_operation m_io_operation;
+  /**
+    Implementation specific.
+    For table io, the table io index.
+    For table lock, the lock type.
+  */
   uint m_index;
-  /** Current table lock index. */
-  uint m_lock_index;
   /** Source file. */
   const char* m_src_file;
   /** Source line number. */
@@ -896,16 +903,28 @@ typedef struct PSI_cond_locker* (*get_th
    enum PSI_cond_operation op);
 
 /**
-  Get a table instrumentation locker.
+  Get a table instrumentation io locker.
+  @param state data storage for the locker
+  @param table the instrumented table to lock
+  @param op the operation to be performed
+  @param index the index used if any, or MAX_KEY
+  @return a table locker, or NULL
+*/
+typedef struct PSI_table_locker* (*get_thread_table_io_locker_v1_t)
+  (struct PSI_table_locker_state_v1 *state,
+   struct PSI_table *table, enum PSI_table_io_operation op, uint index);
+
+/**
+  Get a table instrumentation lock locker.
   @param state data storage for the locker
   @param table the instrumented table to lock
   @param op the operation to be performed
   @param flags Per operation flags
   @return a table locker, or NULL
 */
-typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t)
+typedef struct PSI_table_locker* (*get_thread_table_lock_locker_v1_t)
   (struct PSI_table_locker_state_v1 *state,
-   struct PSI_table *table, enum PSI_table_operation op, ulong flags);
+   struct PSI_table *table, enum PSI_table_lock_operation op, ulong flags);
 
 /**
   Get a file instrumentation locker, for opening or creating a file.
@@ -1035,20 +1054,34 @@ typedef void (*end_cond_wait_v1_t)
   (struct PSI_cond_locker *locker, int rc);
 
 /**
-  Record a table instrumentation wait start event.
+  Record a table instrumentation io wait start event.
+  @param locker a table locker for the running thread
+  @param file the source file name
+  @param line the source line number
+*/
+typedef void (*start_table_io_wait_v1_t)
+  (struct PSI_table_locker *locker, const char *src_file, uint src_line);
+
+/**
+  Record a table instrumentation io wait end event.
+  @param locker a table locker for the running thread
+*/
+typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
+
+/**
+  Record a table instrumentation lock wait start event.
   @param locker a table locker for the running thread
-  @param index the index used if any, or MAX_KEY
   @param file the source file name
   @param line the source line number
 */
-typedef void (*start_table_wait_v1_t)
-  (struct PSI_table_locker *locker, uint index, const char *src_file, uint src_line);
+typedef void (*start_table_lock_wait_v1_t)
+  (struct PSI_table_locker *locker, const char *src_file, uint src_line);
 
 /**
-  Record a table instrumentation wait end event.
+  Record a table instrumentation lock wait end event.
   @param locker a table locker for the running thread
 */
-typedef void (*end_table_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
 
 /**
   Start a file instrumentation open operation.
@@ -1176,8 +1209,10 @@ struct PSI_v1
   get_thread_rwlock_locker_v1_t get_thread_rwlock_locker;
   /** @sa get_thread_cond_locker_v1_t. */
   get_thread_cond_locker_v1_t get_thread_cond_locker;
-  /** @sa get_thread_table_locker_v1_t. */
-  get_thread_table_locker_v1_t get_thread_table_locker;
+  /** @sa get_thread_table_io_locker_v1_t. */
+  get_thread_table_io_locker_v1_t get_thread_table_io_locker;
+  /** @sa get_thread_table_lock_locker_v1_t. */
+  get_thread_table_lock_locker_v1_t get_thread_table_lock_locker;
   /** @sa get_thread_file_name_locker_v1_t. */
   get_thread_file_name_locker_v1_t get_thread_file_name_locker;
   /** @sa get_thread_file_stream_locker_v1_t. */
@@ -1208,10 +1243,14 @@ struct PSI_v1
   start_cond_wait_v1_t start_cond_wait;
   /** @sa end_cond_wait_v1_t. */
   end_cond_wait_v1_t end_cond_wait;
-  /** @sa start_table_wait_v1_t. */
-  start_table_wait_v1_t start_table_wait;
-  /** @sa end_table_wait_v1_t. */
-  end_table_wait_v1_t end_table_wait;
+  /** @sa start_table_io_wait_v1_t. */
+  start_table_io_wait_v1_t start_table_io_wait;
+  /** @sa end_table_io_wait_v1_t. */
+  end_table_io_wait_v1_t end_table_io_wait;
+  /** @sa start_table_lock_wait_v1_t. */
+  start_table_lock_wait_v1_t start_table_lock_wait;
+  /** @sa end_table_lock_wait_v1_t. */
+  end_table_lock_wait_v1_t end_table_lock_wait;
   /** @sa start_file_open_wait_v1_t. */
   start_file_open_wait_v1_t start_file_open_wait;
   /** @sa end_file_open_wait_v1_t. */

=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp	2010-07-30 09:02:32 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp	2010-12-09 16:17:13 +0000
@@ -54,14 +54,17 @@ enum PSI_file_operation
   PSI_FILE_RENAME= 15,
   PSI_FILE_SYNC= 16
 };
-enum PSI_table_operation
+enum PSI_table_io_operation
+{
+  PSI_TABLE_FETCH_ROW= 0,
+  PSI_TABLE_WRITE_ROW= 1,
+  PSI_TABLE_UPDATE_ROW= 2,
+  PSI_TABLE_DELETE_ROW= 3
+};
+enum PSI_table_lock_operation
 {
   PSI_TABLE_LOCK= 0,
   PSI_TABLE_EXTERNAL_LOCK= 1,
-  PSI_TABLE_FETCH_ROW= 2,
-  PSI_TABLE_WRITE_ROW= 3,
-  PSI_TABLE_UPDATE_ROW= 4,
-  PSI_TABLE_DELETE_ROW= 5
 };
 typedef unsigned int PSI_mutex_key;
 typedef unsigned int PSI_rwlock_key;
@@ -153,13 +156,11 @@ struct PSI_table_locker_state_v1
   uint m_flags;
   struct PSI_table *m_table;
   struct PSI_table_share *m_table_share;
-  void *m_class;
   struct PSI_thread *m_thread;
   ulonglong m_timer_start;
   ulonglong (*m_timer)(void);
-  enum PSI_table_operation m_operation;
+  enum PSI_table_io_operation m_io_operation;
   uint m_index;
-  uint m_lock_index;
   const char* m_src_file;
   int m_src_line;
   void *m_wait;
@@ -226,9 +227,12 @@ typedef struct PSI_cond_locker* (*get_th
   (struct PSI_cond_locker_state_v1 *state,
    struct PSI_cond *cond, struct PSI_mutex *mutex,
    enum PSI_cond_operation op);
-typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t)
+typedef struct PSI_table_locker* (*get_thread_table_io_locker_v1_t)
+  (struct PSI_table_locker_state_v1 *state,
+   struct PSI_table *table, enum PSI_table_io_operation op, uint index);
+typedef struct PSI_table_locker* (*get_thread_table_lock_locker_v1_t)
   (struct PSI_table_locker_state_v1 *state,
-   struct PSI_table *table, enum PSI_table_operation op, ulong flags);
+   struct PSI_table *table, enum PSI_table_lock_operation op, ulong flags);
 typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t)
   (struct PSI_file_locker_state_v1 *state,
    PSI_file_key key, enum PSI_file_operation op, const char *name,
@@ -263,9 +267,12 @@ typedef void (*start_cond_wait_v1_t)
   (struct PSI_cond_locker *locker, const char *src_file, uint src_line);
 typedef void (*end_cond_wait_v1_t)
   (struct PSI_cond_locker *locker, int rc);
-typedef void (*start_table_wait_v1_t)
-  (struct PSI_table_locker *locker, uint index, const char *src_file, uint src_line);
-typedef void (*end_table_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*start_table_io_wait_v1_t)
+  (struct PSI_table_locker *locker, const char *src_file, uint src_line);
+typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*start_table_lock_wait_v1_t)
+  (struct PSI_table_locker *locker, const char *src_file, uint src_line);
+typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
 typedef struct PSI_file* (*start_file_open_wait_v1_t)
   (struct PSI_file_locker *locker, const char *src_file, uint src_line);
 typedef void (*end_file_open_wait_v1_t)(struct PSI_file_locker *locker);
@@ -312,7 +319,8 @@ struct PSI_v1
   get_thread_mutex_locker_v1_t get_thread_mutex_locker;
   get_thread_rwlock_locker_v1_t get_thread_rwlock_locker;
   get_thread_cond_locker_v1_t get_thread_cond_locker;
-  get_thread_table_locker_v1_t get_thread_table_locker;
+  get_thread_table_io_locker_v1_t get_thread_table_io_locker;
+  get_thread_table_lock_locker_v1_t get_thread_table_lock_locker;
   get_thread_file_name_locker_v1_t get_thread_file_name_locker;
   get_thread_file_stream_locker_v1_t get_thread_file_stream_locker;
   get_thread_file_descriptor_locker_v1_t get_thread_file_descriptor_locker;
@@ -328,8 +336,10 @@ struct PSI_v1
   end_rwlock_wrwait_v1_t end_rwlock_wrwait;
   start_cond_wait_v1_t start_cond_wait;
   end_cond_wait_v1_t end_cond_wait;
-  start_table_wait_v1_t start_table_wait;
-  end_table_wait_v1_t end_table_wait;
+  start_table_io_wait_v1_t start_table_io_wait;
+  end_table_io_wait_v1_t end_table_io_wait;
+  start_table_lock_wait_v1_t start_table_lock_wait;
+  end_table_lock_wait_v1_t end_table_lock_wait;
   start_file_open_wait_v1_t start_file_open_wait;
   end_file_open_wait_v1_t end_file_open_wait;
   end_file_open_wait_and_bind_to_descriptor_v1_t

=== modified file 'include/mysql/psi/psi_abi_v2.h.pp'
--- a/include/mysql/psi/psi_abi_v2.h.pp	2010-07-23 17:08:41 +0000
+++ b/include/mysql/psi/psi_abi_v2.h.pp	2010-12-09 16:17:13 +0000
@@ -54,14 +54,17 @@ enum PSI_file_operation
   PSI_FILE_RENAME= 15,
   PSI_FILE_SYNC= 16
 };
-enum PSI_table_operation
+enum PSI_table_io_operation
+{
+  PSI_TABLE_FETCH_ROW= 0,
+  PSI_TABLE_WRITE_ROW= 1,
+  PSI_TABLE_UPDATE_ROW= 2,
+  PSI_TABLE_DELETE_ROW= 3
+};
+enum PSI_table_lock_operation
 {
   PSI_TABLE_LOCK= 0,
   PSI_TABLE_EXTERNAL_LOCK= 1,
-  PSI_TABLE_FETCH_ROW= 2,
-  PSI_TABLE_WRITE_ROW= 3,
-  PSI_TABLE_UPDATE_ROW= 4,
-  PSI_TABLE_DELETE_ROW= 5
 };
 typedef unsigned int PSI_mutex_key;
 typedef unsigned int PSI_rwlock_key;

=== modified file 'mysql-test/suite/perfschema/include/schema.inc'
--- a/mysql-test/suite/perfschema/include/schema.inc	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/include/schema.inc	2010-12-09 16:17:13 +0000
@@ -42,5 +42,8 @@ show create table setup_consumers;
 show create table setup_instruments;
 show create table setup_objects;
 show create table setup_timers;
+show create table table_io_waits_summary_by_index_usage;
+show create table table_io_waits_summary_by_table;
+show create table table_lock_waits_summary_by_table;
 show create table threads;
 

=== modified file 'mysql-test/suite/perfschema/include/start_server_common.inc'
--- a/mysql-test/suite/perfschema/include/start_server_common.inc	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/include/start_server_common.inc	2010-12-09 16:17:13 +0000
@@ -20,7 +20,8 @@ show databases;
 select count(*) from performance_schema.performance_timers;
 select count(*) from performance_schema.setup_consumers;
 # wait/io/table/sql/handler is a native instrument
-select count(*) > 1 from performance_schema.setup_instruments;
+# wait/lock/table/sql/handler is a native instrument
+select count(*) > 2 from performance_schema.setup_instruments;
 select count(*) from performance_schema.setup_timers;
 
 # Make sure we don't crash, no matter what the starting parameters are
@@ -45,6 +46,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 --enable_result_log
 

=== modified file 'mysql-test/suite/perfschema/r/func_file_io.result'
--- a/mysql-test/suite/perfschema/r/func_file_io.result	2010-11-18 16:34:56 +0000
+++ b/mysql-test/suite/perfschema/r/func_file_io.result	2010-12-09 16:17:13 +0000
@@ -67,17 +67,17 @@ SELECT * FROM performance_schema.events_
 WHERE TIMER_WAIT != NULL
 OR TIMER_START != NULL
 OR TIMER_END != NULL;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	INDEX_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
 SELECT * FROM performance_schema.events_waits_history
 WHERE TIMER_WAIT != NULL
 OR TIMER_START != NULL
 OR TIMER_END != NULL;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	INDEX_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
 SELECT * FROM performance_schema.events_waits_current
 WHERE TIMER_WAIT != NULL
 OR TIMER_START != NULL
 OR TIMER_END != NULL;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	INDEX_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
 UPDATE performance_schema.setup_instruments SET timed = 'YES';
 SELECT * FROM t1 WHERE id < 4;
 id	b

=== modified file 'mysql-test/suite/perfschema/r/information_schema.result'
--- a/mysql-test/suite/perfschema/r/information_schema.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/information_schema.result	2010-12-09 16:17:13 +0000
@@ -21,6 +21,9 @@ performance_schema	setup_consumers	def
 performance_schema	setup_instruments	def
 performance_schema	setup_objects	def
 performance_schema	setup_timers	def
+performance_schema	table_io_waits_summary_by_index_usage	def
+performance_schema	table_io_waits_summary_by_table	def
+performance_schema	table_lock_waits_summary_by_table	def
 performance_schema	threads	def
 select lower(TABLE_NAME), TABLE_TYPE, ENGINE
 from information_schema.tables
@@ -45,6 +48,9 @@ setup_consumers	BASE TABLE	PERFORMANCE_S
 setup_instruments	BASE TABLE	PERFORMANCE_SCHEMA
 setup_objects	BASE TABLE	PERFORMANCE_SCHEMA
 setup_timers	BASE TABLE	PERFORMANCE_SCHEMA
+table_io_waits_summary_by_index_usage	BASE TABLE	PERFORMANCE_SCHEMA
+table_io_waits_summary_by_table	BASE TABLE	PERFORMANCE_SCHEMA
+table_lock_waits_summary_by_table	BASE TABLE	PERFORMANCE_SCHEMA
 threads	BASE TABLE	PERFORMANCE_SCHEMA
 select lower(TABLE_NAME), VERSION, ROW_FORMAT
 from information_schema.tables
@@ -69,6 +75,9 @@ setup_consumers	10	Dynamic
 setup_instruments	10	Dynamic
 setup_objects	10	Dynamic
 setup_timers	10	Dynamic
+table_io_waits_summary_by_index_usage	10	Dynamic
+table_io_waits_summary_by_table	10	Dynamic
+table_lock_waits_summary_by_table	10	Dynamic
 threads	10	Dynamic
 select lower(TABLE_NAME), TABLE_ROWS, AVG_ROW_LENGTH
 from information_schema.tables
@@ -93,6 +102,9 @@ setup_consumers	5	0
 setup_instruments	1000	0
 setup_objects	3	0
 setup_timers	1	0
+table_io_waits_summary_by_index_usage	1000	0
+table_io_waits_summary_by_table	1000	0
+table_lock_waits_summary_by_table	1000	0
 threads	1000	0
 select lower(TABLE_NAME), DATA_LENGTH, MAX_DATA_LENGTH
 from information_schema.tables
@@ -117,6 +129,9 @@ setup_consumers	0	0
 setup_instruments	0	0
 setup_objects	0	0
 setup_timers	0	0
+table_io_waits_summary_by_index_usage	0	0
+table_io_waits_summary_by_table	0	0
+table_lock_waits_summary_by_table	0	0
 threads	0	0
 select lower(TABLE_NAME), INDEX_LENGTH, DATA_FREE, AUTO_INCREMENT
 from information_schema.tables
@@ -141,6 +156,9 @@ setup_consumers	0	0	NULL
 setup_instruments	0	0	NULL
 setup_objects	0	0	NULL
 setup_timers	0	0	NULL
+table_io_waits_summary_by_index_usage	0	0	NULL
+table_io_waits_summary_by_table	0	0	NULL
+table_lock_waits_summary_by_table	0	0	NULL
 threads	0	0	NULL
 select lower(TABLE_NAME), CREATE_TIME, UPDATE_TIME, CHECK_TIME
 from information_schema.tables
@@ -165,6 +183,9 @@ setup_consumers	NULL	NULL	NULL
 setup_instruments	NULL	NULL	NULL
 setup_objects	NULL	NULL	NULL
 setup_timers	NULL	NULL	NULL
+table_io_waits_summary_by_index_usage	NULL	NULL	NULL
+table_io_waits_summary_by_table	NULL	NULL	NULL
+table_lock_waits_summary_by_table	NULL	NULL	NULL
 threads	NULL	NULL	NULL
 select lower(TABLE_NAME), TABLE_COLLATION, CHECKSUM
 from information_schema.tables
@@ -189,6 +210,9 @@ setup_consumers	utf8_general_ci	NULL
 setup_instruments	utf8_general_ci	NULL
 setup_objects	utf8_general_ci	NULL
 setup_timers	utf8_general_ci	NULL
+table_io_waits_summary_by_index_usage	utf8_general_ci	NULL
+table_io_waits_summary_by_table	utf8_general_ci	NULL
+table_lock_waits_summary_by_table	utf8_general_ci	NULL
 threads	utf8_general_ci	NULL
 select lower(TABLE_NAME), TABLE_COMMENT
 from information_schema.tables
@@ -213,4 +237,7 @@ setup_consumers	
 setup_instruments	
 setup_objects	
 setup_timers	
+table_io_waits_summary_by_index_usage	
+table_io_waits_summary_by_table	
+table_lock_waits_summary_by_table	
 threads	

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result	2010-11-24 08:34:13 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result	2010-12-09 16:17:13 +0000
@@ -9,26 +9,29 @@ show tables like "user_table";
 Tables_in_performance_schema (user_table)
 user_table
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -42,26 +45,29 @@ show tables like "user_view";
 Tables_in_performance_schema (user_view)
 user_view
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -73,26 +79,29 @@ create procedure test.user_proc()
 select "Not supposed to be here";
 update mysql.proc set db='performance_schema' where name='user_proc';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -104,26 +113,29 @@ create function test.user_func() returns
 return 0;
 update mysql.proc set db='performance_schema' where name='user_func';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -135,26 +147,29 @@ create event test.user_event on schedule
 select "not supposed to be here";
 update mysql.event set db='performance_schema' where name='user_event';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result	2010-11-24 08:34:13 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result	2010-12-09 16:17:13 +0000
@@ -9,26 +9,29 @@ show tables like "user_table";
 Tables_in_performance_schema (user_table)
 user_table
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -42,26 +45,29 @@ show tables like "user_view";
 Tables_in_performance_schema (user_view)
 user_view
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -73,26 +79,29 @@ create procedure test.user_proc()
 select "Not supposed to be here";
 update mysql.proc set db='performance_schema' where name='user_proc';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -104,26 +113,29 @@ create function test.user_func() returns
 return 0;
 update mysql.proc set db='performance_schema' where name='user_func';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -135,26 +147,29 @@ create event test.user_event on schedule
 select "not supposed to be here";
 update mysql.event set db='performance_schema' where name='user_event';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result	2010-11-24 08:34:13 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result	2010-12-09 16:17:13 +0000
@@ -9,26 +9,29 @@ show tables like "user_table";
 Tables_in_performance_schema (user_table)
 user_table
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -42,26 +45,29 @@ show tables like "user_view";
 Tables_in_performance_schema (user_view)
 user_view
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -73,26 +79,29 @@ create procedure test.user_proc()
 select "Not supposed to be here";
 update mysql.proc set db='performance_schema' where name='user_proc';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -104,26 +113,29 @@ create function test.user_func() returns
 return 0;
 update mysql.proc set db='performance_schema' where name='user_func';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -135,26 +147,29 @@ create event test.user_event on schedule
 select "not supposed to be here";
 update mysql.event set db='performance_schema' where name='user_event';
 ERROR 1050 (42S01) at line 70: Table 'cond_instances' already exists
-ERROR 1050 (42S01) at line 92: Table 'events_waits_current' already exists
-ERROR 1050 (42S01) at line 114: Table 'events_waits_history' already exists
-ERROR 1050 (42S01) at line 136: Table 'events_waits_history_long' already exists
-ERROR 1050 (42S01) at line 149: Table 'events_waits_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 162: Table 'events_waits_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 174: Table 'events_waits_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 183: Table 'file_instances' already exists
-ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
-ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
-ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
-ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
-ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 313: Table 'threads' already exists
-ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 93: Table 'events_waits_current' already exists
+ERROR 1050 (42S01) at line 116: Table 'events_waits_history' already exists
+ERROR 1050 (42S01) at line 139: Table 'events_waits_history_long' already exists
+ERROR 1050 (42S01) at line 152: Table 'events_waits_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 165: Table 'events_waits_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 177: Table 'events_waits_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 186: Table 'file_instances' already exists
+ERROR 1050 (42S01) at line 197: Table 'file_summary_by_event_name' already exists
+ERROR 1050 (42S01) at line 209: Table 'file_summary_by_instance' already exists
+ERROR 1050 (42S01) at line 218: Table 'mutex_instances' already exists
+ERROR 1050 (42S01) at line 232: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 242: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 252: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 261: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 269: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 278: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 288: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 296: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 341: Table 'table_io_waits_summary_by_index_usage' already exists
+ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
+ERROR 1050 (42S01) at line 484: Table 'threads' already exists
+ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/schema_lc0.result'
--- a/mysql-test/suite/perfschema/r/schema_lc0.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc0.result	2010-12-09 16:17:13 +0000
@@ -26,6 +26,9 @@ setup_consumers
 setup_instruments
 setup_objects
 setup_timers
+table_io_waits_summary_by_index_usage
+table_io_waits_summary_by_table
+table_lock_waits_summary_by_table
 threads
 show create table cond_instances;
 Table	Create Table
@@ -46,10 +49,11 @@ events_waits_current	CREATE TABLE `event
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -66,10 +70,11 @@ events_waits_history	CREATE TABLE `event
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -86,10 +91,11 @@ events_waits_history_long	CREATE TABLE `
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -220,6 +226,168 @@ setup_timers	CREATE TABLE `setup_timers`
   `NAME` varchar(64) NOT NULL,
   `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_io_waits_summary_by_index_usage;
+Table	Create Table
+table_io_waits_summary_by_index_usage	CREATE TABLE `table_io_waits_summary_by_index_usage` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_io_waits_summary_by_table;
+Table	Create Table
+table_io_waits_summary_by_table	CREATE TABLE `table_io_waits_summary_by_table` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_lock_waits_summary_by_table;
+Table	Create Table
+table_lock_waits_summary_by_table	CREATE TABLE `table_lock_waits_summary_by_table` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table threads;
 Table	Create Table
 threads	CREATE TABLE `threads` (

=== modified file 'mysql-test/suite/perfschema/r/schema_lc1.result'
--- a/mysql-test/suite/perfschema/r/schema_lc1.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc1.result	2010-12-09 16:17:13 +0000
@@ -26,6 +26,9 @@ setup_consumers
 setup_instruments
 setup_objects
 setup_timers
+table_io_waits_summary_by_index_usage
+table_io_waits_summary_by_table
+table_lock_waits_summary_by_table
 threads
 show create table cond_instances;
 Table	Create Table
@@ -46,10 +49,11 @@ events_waits_current	CREATE TABLE `event
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -66,10 +70,11 @@ events_waits_history	CREATE TABLE `event
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -86,10 +91,11 @@ events_waits_history_long	CREATE TABLE `
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -220,6 +226,168 @@ setup_timers	CREATE TABLE `setup_timers`
   `NAME` varchar(64) NOT NULL,
   `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_io_waits_summary_by_index_usage;
+Table	Create Table
+table_io_waits_summary_by_index_usage	CREATE TABLE `table_io_waits_summary_by_index_usage` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_io_waits_summary_by_table;
+Table	Create Table
+table_io_waits_summary_by_table	CREATE TABLE `table_io_waits_summary_by_table` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_lock_waits_summary_by_table;
+Table	Create Table
+table_lock_waits_summary_by_table	CREATE TABLE `table_lock_waits_summary_by_table` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table threads;
 Table	Create Table
 threads	CREATE TABLE `threads` (

=== modified file 'mysql-test/suite/perfschema/r/schema_lc2.result'
--- a/mysql-test/suite/perfschema/r/schema_lc2.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc2.result	2010-12-09 16:17:13 +0000
@@ -26,6 +26,9 @@ setup_consumers
 setup_instruments
 setup_objects
 setup_timers
+table_io_waits_summary_by_index_usage
+table_io_waits_summary_by_table
+table_lock_waits_summary_by_table
 threads
 show create table cond_instances;
 Table	Create Table
@@ -46,10 +49,11 @@ events_waits_current	CREATE TABLE `event
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -66,10 +70,11 @@ events_waits_history	CREATE TABLE `event
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -86,10 +91,11 @@ events_waits_history_long	CREATE TABLE `
   `SPINS` int(10) unsigned DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_NAME` varchar(512) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
+  `OPERATION` varchar(32) NOT NULL,
   `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
   `FLAGS` int(10) unsigned DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
@@ -220,6 +226,168 @@ setup_timers	CREATE TABLE `setup_timers`
   `NAME` varchar(64) NOT NULL,
   `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_io_waits_summary_by_index_usage;
+Table	Create Table
+table_io_waits_summary_by_index_usage	CREATE TABLE `table_io_waits_summary_by_index_usage` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `INDEX_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_io_waits_summary_by_table;
+Table	Create Table
+table_io_waits_summary_by_table	CREATE TABLE `table_io_waits_summary_by_table` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_FETCH` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_FETCH` bigint(20) unsigned NOT NULL,
+  `COUNT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_UPDATE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_UPDATE` bigint(20) unsigned NOT NULL,
+  `COUNT_DELETE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_DELETE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_DELETE` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table table_lock_waits_summary_by_table;
+Table	Create Table
+table_lock_waits_summary_by_table	CREATE TABLE `table_lock_waits_summary_by_table` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_NORMAL` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_WITH_SHARED_LOCKS` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_HIGH_PRIORITY` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_NO_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_READ_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_ALLOW_WRITE` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_CONCURRENT_INSERT` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_DELAYED` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_LOW_PRIORITY` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_NORMAL` bigint(20) unsigned NOT NULL,
+  `COUNT_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WRITE_EXTERNAL` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table threads;
 Table	Create Table
 threads	CREATE TABLE `threads` (

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_actors.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_objects.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result	2010-11-15 15:04:34 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_hdl.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_nothing.result'
--- a/mysql-test/suite/perfschema/r/start_server_nothing.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_nothing.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 0
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value
@@ -82,6 +85,7 @@ performance_schema_setup_objects_size	0
 select * from performance_schema.setup_instruments;
 NAME	ENABLED	TIMED
 wait/io/table/sql/handler	YES	YES
+wait/lock/table/sql/handler	YES	YES
 select TIMER_NAME from performance_schema.performance_timers;
 TIMER_NAME
 CYCLE
@@ -102,11 +106,11 @@ wait	CYCLE
 select * from performance_schema.cond_instances;
 NAME	OBJECT_INSTANCE_BEGIN
 select * from performance_schema.events_waits_current;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	INDEX_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
 select * from performance_schema.events_waits_history;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	INDEX_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
 select * from performance_schema.events_waits_history_long;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	INDEX_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
 select * from performance_schema.events_waits_summary_by_instance;
 EVENT_NAME	OBJECT_INSTANCE_BEGIN	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
 select * from performance_schema.events_waits_summary_by_thread_by_event_name;
@@ -114,6 +118,7 @@ THREAD_ID	EVENT_NAME	COUNT_STAR	SUM_TIME
 select * from performance_schema.events_waits_summary_global_by_event_name;
 EVENT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
 wait/io/table/sql/handler	0	0	0	0	0
+wait/lock/table/sql/handler	0	0	0	0	0
 select * from performance_schema.file_instances;
 FILE_NAME	EVENT_NAME	OPEN_COUNT
 select * from performance_schema.file_summary_by_event_name;

=== modified file 'mysql-test/suite/perfschema/r/start_server_off.result'
--- a/mysql-test/suite/perfschema/r/start_server_off.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_off.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 0
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysql-test/suite/perfschema/r/start_server_on.result'
--- a/mysql-test/suite/perfschema/r/start_server_on.result	2010-11-15 07:40:07 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_on.result	2010-12-09 16:17:13 +0000
@@ -11,8 +11,8 @@ count(*)
 select count(*) from performance_schema.setup_consumers;
 count(*)
 5
-select count(*) > 1 from performance_schema.setup_instruments;
-count(*) > 1
+select count(*) > 2 from performance_schema.setup_instruments;
+count(*) > 2
 1
 select count(*) from performance_schema.setup_timers;
 count(*)
@@ -36,6 +36,9 @@ select * from performance_schema.setup_c
 select * from performance_schema.setup_instruments;
 select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
+select * from performance_schema.table_io_waits_summary_by_index_usage;
+select * from performance_schema.table_io_waits_summary_by_table;
+select * from performance_schema.table_lock_waits_summary_by_table;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
 Variable_name	Value

=== modified file 'mysys/thr_lock.c'
--- a/mysys/thr_lock.c	2010-09-01 13:05:01 +0000
+++ b/mysys/thr_lock.c	2010-12-09 16:17:13 +0000
@@ -551,8 +551,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_I
   data->type=lock_type;
   data->owner= owner;                           /* Must be reset ! */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, data->m_psi,
-                         PSI_TABLE_LOCK, 0, lock_type);
+  MYSQL_START_TABLE_LOCK_WAIT(locker, &state, data->m_psi,
+                              PSI_TABLE_LOCK, lock_type);
 
   mysql_mutex_lock(&lock->mutex);
   DBUG_PRINT("lock",("data: 0x%lx  thread: 0x%lx  lock: 0x%lx  type: %d",
@@ -784,11 +784,11 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_I
   }
   /* Can't get lock yet;  Wait for it */
   result= wait_for_lock(wait_queue, data, 0, lock_wait_timeout);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_LOCK_WAIT(locker);
   DBUG_RETURN(result);
 end:
   mysql_mutex_unlock(&lock->mutex);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_LOCK_WAIT(locker);
   DBUG_RETURN(result);
 }
 

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2010-12-02 15:05:07 +0000
+++ b/scripts/mysql_system_tables.sql	2010-12-09 16:17:13 +0000
@@ -198,10 +198,11 @@ SET @cmd="CREATE TABLE performance_schem
   "SPINS INTEGER unsigned,"
   "OBJECT_SCHEMA VARCHAR(64),"
   "OBJECT_NAME VARCHAR(512),"
+  "INDEX_NAME VARCHAR(64),"
   "OBJECT_TYPE VARCHAR(64),"
   "OBJECT_INSTANCE_BEGIN BIGINT not null,"
   "NESTING_EVENT_ID BIGINT unsigned,"
-  "OPERATION VARCHAR(16) not null,"
+  "OPERATION VARCHAR(32) not null,"
   "NUMBER_OF_BYTES BIGINT unsigned,"
   "FLAGS INTEGER unsigned"
   ")ENGINE=PERFORMANCE_SCHEMA;";
@@ -226,10 +227,11 @@ SET @cmd="CREATE TABLE performance_schem
   "SPINS INTEGER unsigned,"
   "OBJECT_SCHEMA VARCHAR(64),"
   "OBJECT_NAME VARCHAR(512),"
+  "INDEX_NAME VARCHAR(64),"
   "OBJECT_TYPE VARCHAR(64),"
   "OBJECT_INSTANCE_BEGIN BIGINT not null,"
   "NESTING_EVENT_ID BIGINT unsigned,"
-  "OPERATION VARCHAR(16) not null,"
+  "OPERATION VARCHAR(32) not null,"
   "NUMBER_OF_BYTES BIGINT unsigned,"
   "FLAGS INTEGER unsigned"
   ")ENGINE=PERFORMANCE_SCHEMA;";
@@ -254,10 +256,11 @@ SET @cmd="CREATE TABLE performance_schem
   "SPINS INTEGER unsigned,"
   "OBJECT_SCHEMA VARCHAR(64),"
   "OBJECT_NAME VARCHAR(512),"
+  "INDEX_NAME VARCHAR(64),"
   "OBJECT_TYPE VARCHAR(64),"
   "OBJECT_INSTANCE_BEGIN BIGINT not null,"
   "NESTING_EVENT_ID BIGINT unsigned,"
-  "OPERATION VARCHAR(16) not null,"
+  "OPERATION VARCHAR(32) not null,"
   "NUMBER_OF_BYTES BIGINT unsigned,"
   "FLAGS INTEGER unsigned"
   ")ENGINE=PERFORMANCE_SCHEMA;";
@@ -515,6 +518,192 @@ EXECUTE stmt;
 DROP PREPARE stmt;
 
 --
+-- TABLE TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE
+--
+
+SET @cmd="CREATE TABLE performance_schema.table_io_waits_summary_by_index_usage("
+  "OBJECT_TYPE VARCHAR(64),"
+  "OBJECT_SCHEMA VARCHAR(64),"
+  "OBJECT_NAME VARCHAR(64),"
+  "INDEX_NAME VARCHAR(64),"
+  "COUNT_STAR BIGINT unsigned not null,"
+  "SUM_TIMER_WAIT BIGINT unsigned not null,"
+  "MIN_TIMER_WAIT BIGINT unsigned not null,"
+  "AVG_TIMER_WAIT BIGINT unsigned not null,"
+  "MAX_TIMER_WAIT BIGINT unsigned not null,"
+  "COUNT_READ BIGINT unsigned not null,"
+  "SUM_TIMER_READ BIGINT unsigned not null,"
+  "MIN_TIMER_READ BIGINT unsigned not null,"
+  "AVG_TIMER_READ BIGINT unsigned not null,"
+  "MAX_TIMER_READ BIGINT unsigned not null,"
+  "COUNT_WRITE BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE BIGINT unsigned not null,"
+  "COUNT_FETCH BIGINT unsigned not null,"
+  "SUM_TIMER_FETCH BIGINT unsigned not null,"
+  "MIN_TIMER_FETCH BIGINT unsigned not null,"
+  "AVG_TIMER_FETCH BIGINT unsigned not null,"
+  "MAX_TIMER_FETCH BIGINT unsigned not null,"
+  "COUNT_INSERT BIGINT unsigned not null,"
+  "SUM_TIMER_INSERT BIGINT unsigned not null,"
+  "MIN_TIMER_INSERT BIGINT unsigned not null,"
+  "AVG_TIMER_INSERT BIGINT unsigned not null,"
+  "MAX_TIMER_INSERT BIGINT unsigned not null,"
+  "COUNT_UPDATE BIGINT unsigned not null,"
+  "SUM_TIMER_UPDATE BIGINT unsigned not null,"
+  "MIN_TIMER_UPDATE BIGINT unsigned not null,"
+  "AVG_TIMER_UPDATE BIGINT unsigned not null,"
+  "MAX_TIMER_UPDATE BIGINT unsigned not null,"
+  "COUNT_DELETE BIGINT unsigned not null,"
+  "SUM_TIMER_DELETE BIGINT unsigned not null,"
+  "MIN_TIMER_DELETE BIGINT unsigned not null,"
+  "AVG_TIMER_DELETE BIGINT unsigned not null,"
+  "MAX_TIMER_DELETE BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+
+SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+--
+-- TABLE TABLE_IO_WAITS_SUMMARY_BY_TABLE
+--
+
+SET @cmd="CREATE TABLE performance_schema.table_io_waits_summary_by_table("
+  "OBJECT_TYPE VARCHAR(64),"
+  "OBJECT_SCHEMA VARCHAR(64),"
+  "OBJECT_NAME VARCHAR(64),"
+  "COUNT_STAR BIGINT unsigned not null,"
+  "SUM_TIMER_WAIT BIGINT unsigned not null,"
+  "MIN_TIMER_WAIT BIGINT unsigned not null,"
+  "AVG_TIMER_WAIT BIGINT unsigned not null,"
+  "MAX_TIMER_WAIT BIGINT unsigned not null,"
+  "COUNT_READ BIGINT unsigned not null,"
+  "SUM_TIMER_READ BIGINT unsigned not null,"
+  "MIN_TIMER_READ BIGINT unsigned not null,"
+  "AVG_TIMER_READ BIGINT unsigned not null,"
+  "MAX_TIMER_READ BIGINT unsigned not null,"
+  "COUNT_WRITE BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE BIGINT unsigned not null,"
+  "COUNT_FETCH BIGINT unsigned not null,"
+  "SUM_TIMER_FETCH BIGINT unsigned not null,"
+  "MIN_TIMER_FETCH BIGINT unsigned not null,"
+  "AVG_TIMER_FETCH BIGINT unsigned not null,"
+  "MAX_TIMER_FETCH BIGINT unsigned not null,"
+  "COUNT_INSERT BIGINT unsigned not null,"
+  "SUM_TIMER_INSERT BIGINT unsigned not null,"
+  "MIN_TIMER_INSERT BIGINT unsigned not null,"
+  "AVG_TIMER_INSERT BIGINT unsigned not null,"
+  "MAX_TIMER_INSERT BIGINT unsigned not null,"
+  "COUNT_UPDATE BIGINT unsigned not null,"
+  "SUM_TIMER_UPDATE BIGINT unsigned not null,"
+  "MIN_TIMER_UPDATE BIGINT unsigned not null,"
+  "AVG_TIMER_UPDATE BIGINT unsigned not null,"
+  "MAX_TIMER_UPDATE BIGINT unsigned not null,"
+  "COUNT_DELETE BIGINT unsigned not null,"
+  "SUM_TIMER_DELETE BIGINT unsigned not null,"
+  "MIN_TIMER_DELETE BIGINT unsigned not null,"
+  "AVG_TIMER_DELETE BIGINT unsigned not null,"
+  "MAX_TIMER_DELETE BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+
+SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+--
+-- TABLE TABLE_LOCK_WAITS_SUMMARY_BY_TABLE
+--
+
+SET @cmd="CREATE TABLE performance_schema.table_lock_waits_summary_by_table("
+  "OBJECT_TYPE VARCHAR(64),"
+  "OBJECT_SCHEMA VARCHAR(64),"
+  "OBJECT_NAME VARCHAR(64),"
+  "COUNT_STAR BIGINT unsigned not null,"
+  "SUM_TIMER_WAIT BIGINT unsigned not null,"
+  "MIN_TIMER_WAIT BIGINT unsigned not null,"
+  "AVG_TIMER_WAIT BIGINT unsigned not null,"
+  "MAX_TIMER_WAIT BIGINT unsigned not null,"
+  "COUNT_READ BIGINT unsigned not null,"
+  "SUM_TIMER_READ BIGINT unsigned not null,"
+  "MIN_TIMER_READ BIGINT unsigned not null,"
+  "AVG_TIMER_READ BIGINT unsigned not null,"
+  "MAX_TIMER_READ BIGINT unsigned not null,"
+  "COUNT_WRITE BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE BIGINT unsigned not null,"
+  "COUNT_READ_NORMAL BIGINT unsigned not null,"
+  "SUM_TIMER_READ_NORMAL BIGINT unsigned not null,"
+  "MIN_TIMER_READ_NORMAL BIGINT unsigned not null,"
+  "AVG_TIMER_READ_NORMAL BIGINT unsigned not null,"
+  "MAX_TIMER_READ_NORMAL BIGINT unsigned not null,"
+  "COUNT_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
+  "SUM_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
+  "MIN_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
+  "AVG_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
+  "MAX_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
+  "COUNT_READ_HIGH_PRIORITY BIGINT unsigned not null,"
+  "SUM_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
+  "MIN_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
+  "AVG_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
+  "MAX_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
+  "COUNT_READ_NO_INSERT BIGINT unsigned not null,"
+  "SUM_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
+  "MIN_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
+  "AVG_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
+  "MAX_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
+  "COUNT_READ_EXTERNAL BIGINT unsigned not null,"
+  "SUM_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
+  "MIN_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
+  "AVG_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
+  "MAX_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
+  "COUNT_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
+  "COUNT_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
+  "COUNT_WRITE_DELAYED BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE_DELAYED BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE_DELAYED BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE_DELAYED BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE_DELAYED BIGINT unsigned not null,"
+  "COUNT_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
+  "COUNT_WRITE_NORMAL BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
+  "COUNT_WRITE_EXTERNAL BIGINT unsigned not null,"
+  "SUM_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
+  "MIN_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
+  "AVG_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
+  "MAX_TIMER_WRITE_EXTERNAL BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+
+SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+--
 -- TABLE THREADS
 --
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2010-11-18 16:34:56 +0000
+++ b/sql/handler.cc	2010-12-09 16:17:13 +0000
@@ -2216,10 +2216,10 @@ int handler::ha_rnd_next(uchar *buf)
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
   result= rnd_next(buf);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2228,10 +2228,10 @@ int handler::ha_rnd_pos(uchar *buf, ucha
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
   result= rnd_pos(buf, pos);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2242,10 +2242,10 @@ int handler::ha_index_read_map(uchar *bu
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, active_index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, active_index, 0);
   result= index_read_map(buf, key, keypart_map, find_flag);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2256,10 +2256,10 @@ int handler::ha_index_read_idx_map(uchar
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, index, 0);
   result= index_read_idx_map(buf, index, key, keypart_map, find_flag);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2268,10 +2268,10 @@ int handler::ha_index_next(uchar * buf)
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, active_index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, active_index, 0);
   result= index_next(buf);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2280,10 +2280,10 @@ int handler::ha_index_prev(uchar * buf)
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, active_index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, active_index, 0);
   result= index_prev(buf);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2292,10 +2292,10 @@ int handler::ha_index_first(uchar * buf)
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, active_index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, active_index, 0);
   result= index_first(buf);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2304,10 +2304,10 @@ int handler::ha_index_last(uchar * buf)
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, active_index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, active_index, 0);
   result= index_last(buf);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2316,10 +2316,10 @@ int handler::ha_index_next_same(uchar *b
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, active_index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, active_index, 0);
   result= index_next_same(buf, key, keylen);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2329,10 +2329,10 @@ int handler::ha_index_read(uchar *buf, c
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, active_index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, active_index, 0);
   result= index_read(buf, key, key_len, find_flag);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -2341,10 +2341,10 @@ int handler::ha_index_read_last(uchar *b
   int result;
   MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_FETCH_ROW, active_index, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_FETCH_ROW, active_index, 0);
   result= index_read_last(buf, key, key_len);
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   return result;
 }
 
@@ -5755,15 +5755,15 @@ int handler::ha_external_lock(THD *thd, 
     }
   }
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_EXTERNAL_LOCK, MAX_KEY, lock_type);
+  MYSQL_START_TABLE_LOCK_WAIT(locker, &state, m_psi,
+                              PSI_TABLE_EXTERNAL_LOCK, lock_type);
   /*
     We cache the table flags if the locking succeeded. Otherwise, we
     keep them as they were when they were fetched in ha_open().
   */
   int error= external_lock(thd, lock_type);
 
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_LOCK_WAIT(locker);
 
   if (error == 0)
   {
@@ -5830,12 +5830,12 @@ int handler::ha_write_row(uchar *buf)
 
   MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_WRITE_ROW, MAX_KEY, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_WRITE_ROW, MAX_KEY, 0);
 
   error= write_row(buf);
 
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   MYSQL_INSERT_ROW_DONE(error);
   if (unlikely(error))
     DBUG_RETURN(error);
@@ -5861,12 +5861,12 @@ int handler::ha_update_row(const uchar *
   MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_UPDATE_ROW, MAX_KEY, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_UPDATE_ROW, MAX_KEY, 0);
 
   error= update_row(old_data, new_data);
 
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   MYSQL_UPDATE_ROW_DONE(error);
   if (unlikely(error))
     return error;
@@ -5884,12 +5884,12 @@ int handler::ha_delete_row(const uchar *
   MYSQL_DELETE_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
 
-  MYSQL_START_TABLE_WAIT(locker, &state, m_psi,
-                         PSI_TABLE_DELETE_ROW, MAX_KEY, 0);
+  MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
+                            PSI_TABLE_DELETE_ROW, MAX_KEY, 0);
 
   error= delete_row(buf);
 
-  MYSQL_END_TABLE_WAIT(locker);
+  MYSQL_END_TABLE_IO_WAIT(locker);
   MYSQL_DELETE_ROW_DONE(error);
   if (unlikely(error))
     return error;

=== modified file 'storage/perfschema/CMakeLists.txt'
--- a/storage/perfschema/CMakeLists.txt	2010-09-23 16:08:54 +0000
+++ b/storage/perfschema/CMakeLists.txt	2010-12-09 16:17:13 +0000
@@ -55,6 +55,9 @@ SET(PERFSCHEMA_SOURCES ha_perfschema.h
   table_setup_timers.h
   table_sync_instances.h
   table_threads.h
+  table_tiws_by_index_usage.h
+  table_tiws_by_table.h
+  table_tlws_by_table.h
   ha_perfschema.cc
   pfs.cc
   pfs_column_values.cc
@@ -85,6 +88,9 @@ SET(PERFSCHEMA_SOURCES ha_perfschema.h
   table_setup_timers.cc
   table_sync_instances.cc
   table_threads.cc
+  table_tiws_by_index_usage.cc
+  table_tiws_by_table.cc
+  table_tlws_by_table.cc
   pfs_atomic.cc
   pfs_check.cc
 )

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2010-10-25 14:43:00 +0000
+++ b/storage/perfschema/pfs.cc	2010-12-09 16:17:13 +0000
@@ -19,6 +19,8 @@
 */
 
 #include "my_global.h"
+#include "thr_lock.h"
+#include "mysql/psi/psi.h"
 #include "my_pthread.h"
 #include "sql_const.h"
 #include "pfs.h"
@@ -710,13 +712,13 @@ static inline int mysql_mutex_lock(...)
         |
         | [3]
         |
-        |-> pfs_user_host(U, H).event_name(M) =====>> [D], [E], [F]
+     3a |-> pfs_user_host(U, H).event_name(M) =====>> [D], [E], [F]
         |    |
         |    | [4]
         |    |
-        |----+-> pfs_user(U).event_name(M)    =====>> [E]
+     3b |----+-> pfs_user(U).event_name(M)    =====>> [E]
         |    |
-        |----+-> pfs_host(H).event_name(M)    =====>> [F]
+     3c |----+-> pfs_host(H).event_name(M)    =====>> [F]
 @endverbatim
 
   How to read this diagram:
@@ -860,18 +862,18 @@ static inline int mysql_mutex_lock(...)
    | [1]
    |
    |-> pfs_table(Tb)                          =====>> [B], [C], [D]
-   |    |
-   |    | [2]
-   |    |
-   |    |-> pfs_table_share(Tb.share)         =====>> [C], [D]
-   |
-   |-> pfs_thread(T).event_name(Tb)           =====>> [A]
         |
-       ...
+        | [2]
+        |
+        |-> pfs_table_share(Tb.share)         =====>> [C], [D]
+        |
+        |-> pfs_thread(T).event_name(Tb)      =====>> [A]
+             |
+            ...
 @endverbatim
 
   Implemented as:
-  - [1] @c get_thread_table_locker_v1(), @c start_table_wait_v1(), @c end_table_wait_v1()
+  - [1] @c get_thread_table_io_locker_v1(), @c start_table_io_wait_v1(), @c end_table_io_wait_v1()
   - [2] @c close_table_v1()
   - [A] EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME,
         @c table_ews_by_thread_by_event_name::make_row()
@@ -951,38 +953,35 @@ static enum_operation_type file_operatio
 
 /**
   Conversion map from PSI_table_operation to enum_operation_type.
-  Indexed by enum PSI_table_operation.
+  Indexed by enum PSI_table_io_operation.
 */
-static enum_operation_type table_operation_map[]=
+static enum_operation_type table_io_operation_map[]=
 {
-  OPERATION_TYPE_TABLE_LOCK,
-  OPERATION_TYPE_TABLE_EXTERNAL_LOCK,
   OPERATION_TYPE_TABLE_FETCH,
   OPERATION_TYPE_TABLE_WRITE_ROW,
   OPERATION_TYPE_TABLE_UPDATE_ROW,
   OPERATION_TYPE_TABLE_DELETE_ROW
 };
 
-static void aggregate_table(PFS_table *pfs)
+/**
+  Conversion map from enum PFS_TL_LOCK_TYPE to enum_operation_type.
+  Indexed by enum PFS_TL_LOCK_TYPE.
+*/
+static enum_operation_type table_lock_operation_map[]=
 {
-  DBUG_ASSERT(pfs);
-  PFS_table_share *table_share= pfs->m_share;
-  DBUG_ASSERT(table_share);
+  OPERATION_TYPE_TL_READ_NORMAL, /* PFS_TL_READ */
+  OPERATION_TYPE_TL_READ_WITH_SHARED_LOCKS, /* PFS_TL_READ_WITH_SHARED_LOCKS */
+  OPERATION_TYPE_TL_READ_HIGH_PRIORITY, /* PFS_TL_READ_HIGH_PRIORITY */
+  OPERATION_TYPE_TL_READ_NO_INSERTS, /* PFS_TL_READ_NO_INSERT */
+  OPERATION_TYPE_TL_WRITE_ALLOW_WRITE, /* PFS_TL_WRITE_ALLOW_WRITE */
+  OPERATION_TYPE_TL_WRITE_CONCURRENT_INSERT, /* PFS_TL_WRITE_CONCURRENT_INSERT */
+  OPERATION_TYPE_TL_WRITE_DELAYED, /* PFS_TL_WRITE_DELAYED */
+  OPERATION_TYPE_TL_WRITE_LOW_PRIORITY, /* PFS_TL_WRITE_LOW_PRIORITY */
+  OPERATION_TYPE_TL_WRITE_NORMAL, /* PFS_TL_WRITE */
+  OPERATION_TYPE_TL_READ_EXTERNAL, /* PFS_TL_READ_EXTERNAL */
+  OPERATION_TYPE_TL_WRITE_EXTERNAL /* PFS_TL_WRITE_EXTERNAL */
+};
 
-  /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME */
-  PFS_thread *thread= pfs->m_opening_thread;
-  DBUG_ASSERT(thread != NULL);
-  PFS_single_stat *event_name_array;
-  uint index;
-  event_name_array= thread->m_instr_class_wait_stats;
-
-  index= global_table_io_class.m_event_name_index;
-  pfs->m_table_stat.sum_io(& event_name_array[index]);
-
-  /* Aggregate to TABLE_IO_SUMMARY, TABLE_LOCK_SUMMARY */
-  table_share->m_table_stat.aggregate(&pfs->m_table_stat);
-  pfs->m_table_stat.reset();
-}
 
 /**
   Build the prefix name of a class of instruments in a category.
@@ -1197,7 +1196,7 @@ static PSI_table_share*
 get_table_share_v1(my_bool temporary, TABLE_SHARE *share)
 {
   /* Do not instrument this table is all table instruments are disabled. */
-  if (! global_table_io_class.m_enabled)
+  if (! global_table_io_class.m_enabled && ! global_table_lock_class.m_enabled)
     return NULL;
   /* An instrumented thread is required, for LF_PINS. */
   PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
@@ -1260,7 +1259,7 @@ static void close_table_v1(PSI_table *ta
 {
   PFS_table *pfs= reinterpret_cast<PFS_table*> (table);
   DBUG_ASSERT(pfs);
-  aggregate_table(pfs);
+  pfs->aggregate();
   destroy_table(pfs);
 }
 
@@ -1924,16 +1923,60 @@ get_thread_cond_locker_v1(PSI_cond_locke
   return reinterpret_cast<PSI_cond_locker*> (state);
 }
 
+static inline PFS_TL_LOCK_TYPE lock_flags_to_lock_type(uint flags)
+{
+  enum thr_lock_type value= static_cast<enum thr_lock_type> (flags);
+
+  switch (value)
+  {
+    case TL_READ:
+      return PFS_TL_READ;
+    case TL_READ_WITH_SHARED_LOCKS:
+      return PFS_TL_READ_WITH_SHARED_LOCKS;
+    case TL_READ_HIGH_PRIORITY:
+      return PFS_TL_READ_HIGH_PRIORITY;
+    case TL_READ_NO_INSERT:
+      return PFS_TL_READ_NO_INSERT;
+    case TL_WRITE_ALLOW_WRITE:
+      return PFS_TL_WRITE_ALLOW_WRITE;
+    case TL_WRITE_CONCURRENT_INSERT:
+      return PFS_TL_WRITE_CONCURRENT_INSERT;
+    case TL_WRITE_DELAYED:
+      return PFS_TL_WRITE_DELAYED;
+    case TL_WRITE_LOW_PRIORITY:
+      return PFS_TL_WRITE_LOW_PRIORITY;
+    case TL_WRITE:
+      return PFS_TL_WRITE;
+
+    case TL_WRITE_ONLY:
+    case TL_IGNORE:
+    case TL_UNLOCK:
+    case TL_READ_DEFAULT:
+    case TL_WRITE_DEFAULT:
+    default:
+      DBUG_ASSERT(false);
+  }
+
+  /* Dead code */
+  return PFS_TL_READ;
+}
+
+static inline PFS_TL_LOCK_TYPE external_lock_flags_to_lock_type(uint flags)
+{
+  DBUG_ASSERT(flags == F_RDLCK || flags == F_WRLCK);
+  return (flags == F_RDLCK ? PFS_TL_READ_EXTERNAL : PFS_TL_WRITE_EXTERNAL);
+}
+
 /**
   Implementation of the table instrumentation interface.
-  @sa PSI_v1::get_thread_table_locker.
+  @sa PSI_v1::get_thread_table_io_locker.
 */
 static PSI_table_locker*
-get_thread_table_locker_v1(PSI_table_locker_state *state,
-                           PSI_table *table, PSI_table_operation op, ulong op_flags)
+get_thread_table_io_locker_v1(PSI_table_locker_state *state,
+                              PSI_table *table, PSI_table_io_operation op, uint index)
 {
   DBUG_ASSERT(static_cast<int> (op) >= 0);
-  DBUG_ASSERT(static_cast<uint> (op) < array_elements(table_operation_map));
+  DBUG_ASSERT(static_cast<uint> (op) < array_elements(table_io_operation_map));
   DBUG_ASSERT(state != NULL);
   PFS_table *pfs_table= reinterpret_cast<PFS_table*> (table);
   DBUG_ASSERT(pfs_table != NULL);
@@ -1941,6 +1984,10 @@ get_thread_table_locker_v1(PSI_table_loc
 
   if (! flag_global_instrumentation)
     return NULL;
+
+  if (! global_table_io_class.m_enabled)
+    return NULL;
+
   PFS_table_share *share= pfs_table->m_share;
   if (unlikely(setup_objects_version != share->m_setup_objects_version))
   {
@@ -1962,25 +2009,137 @@ get_thread_table_locker_v1(PSI_table_loc
     return NULL;
 
   PFS_instr_class *klass;
+  klass= &global_table_io_class;
+
+  register uint flags;
+
+  if (flag_thread_instrumentation)
+  {
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    if (! pfs_thread->m_enabled)
+      return NULL;
+    state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
+    flags= STATE_FLAG_THREAD;
+
+    if (klass->m_timed && share->m_timed)
+      flags|= STATE_FLAG_TIMED;
+
+    if (flag_events_waits_current)
+    {
+      if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
+      {
+        locker_lost++;
+        return NULL;
+      }
+      PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+      state->m_wait= wait;
+      flags|= STATE_FLAG_WAIT;
+
+      wait->m_thread= pfs_thread;
+      wait->m_class= klass;
+      wait->m_timer_start= 0;
+      wait->m_timer_end= 0;
+      wait->m_object_instance_addr= pfs_table->m_identity;
+      wait->m_event_id= pfs_thread->m_event_id++;
+      wait->m_operation= table_io_operation_map[static_cast<int> (op)];
+      wait->m_flags= 0;
+      wait->m_object_type= share->get_object_type();
+      wait->m_weak_table_share= share;
+      wait->m_weak_version= share->get_version();
+      wait->m_index= index;
+      wait->m_wait_class= WAIT_CLASS_TABLE;
+
+      pfs_thread->m_events_waits_count++;
+    }
+    /* TODO: consider a shortcut here */
+  }
+  else
+  {
+    if (klass->m_timed && share->m_timed)
+    {
+      flags= STATE_FLAG_TIMED;
+    }
+    else
+    {
+      /* TODO: consider a shortcut here */
+      flags= 0;
+    }
+  }
+
+  state->m_flags= flags;
+  state->m_table= table;
+  state->m_io_operation= op;
+  state->m_index= index;
+  return reinterpret_cast<PSI_table_locker*> (state);
+}
+
+/**
+  Implementation of the table instrumentation interface.
+  @sa PSI_v1::get_thread_table_lock_locker.
+*/
+static PSI_table_locker*
+get_thread_table_lock_locker_v1(PSI_table_locker_state *state,
+                                PSI_table *table, PSI_table_lock_operation op, ulong op_flags)
+{
+  DBUG_ASSERT(state != NULL);
+  PFS_table *pfs_table= reinterpret_cast<PFS_table*> (table);
+  DBUG_ASSERT(pfs_table != NULL);
+  DBUG_ASSERT(pfs_table->m_share != NULL);
+
+  DBUG_ASSERT((op == PSI_TABLE_LOCK) || (op == PSI_TABLE_EXTERNAL_LOCK));
+
+  if (! flag_global_instrumentation)
+    return NULL;
+
+  if (! global_table_lock_class.m_enabled)
+    return NULL;
+
+  PFS_table_share *share= pfs_table->m_share;
+  if (unlikely(setup_objects_version != share->m_setup_objects_version))
+  {
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    /* Refresh the enabled and timed flags from SETUP_OBJECTS */
+    share->m_setup_objects_version= setup_objects_version;
+    lookup_setup_object(pfs_thread,
+                        OBJECT_TYPE_TABLE, /* even for temporary tables */
+                        share->m_schema_name,
+                        share->m_schema_name_length,
+                        share->m_table_name,
+                        share->m_table_name_length,
+                        & share->m_enabled,
+                        & share->m_timed);
+  }
+  if (! share->m_enabled)
+    return NULL;
+
+  PFS_instr_class *klass;
+  PFS_TL_LOCK_TYPE lock_type;
+  klass= &global_table_lock_class;
 
   switch (op)
   {
     case PSI_TABLE_LOCK:
+      lock_type= lock_flags_to_lock_type(op_flags);
+      break;
     case PSI_TABLE_EXTERNAL_LOCK:
-      return NULL;
-    case PSI_TABLE_FETCH_ROW:
-    case PSI_TABLE_WRITE_ROW:
-    case PSI_TABLE_UPDATE_ROW:
-    case PSI_TABLE_DELETE_ROW:
-      if (! global_table_io_class.m_enabled)
+      /*
+        See the handler::external_lock() API design,
+        there is no handler::external_unlock().
+      */
+      if (op_flags == F_UNLCK)
         return NULL;
-      klass= &global_table_io_class;
+      lock_type= external_lock_flags_to_lock_type(op_flags);
       break;
     default:
-      klass= NULL;
+      lock_type= PFS_TL_READ;
       DBUG_ASSERT(false);
   }
 
+  DBUG_ASSERT((uint) lock_type < array_elements(table_lock_operation_map));
 
   register uint flags;
 
@@ -1994,7 +2153,7 @@ get_thread_table_locker_v1(PSI_table_loc
     state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
     flags= STATE_FLAG_THREAD;
 
-    if (share->m_timed)
+    if (klass->m_timed && share->m_timed)
       flags|= STATE_FLAG_TIMED;
 
     if (flag_events_waits_current)
@@ -2014,43 +2173,34 @@ get_thread_table_locker_v1(PSI_table_loc
       wait->m_timer_end= 0;
       wait->m_object_instance_addr= pfs_table->m_identity;
       wait->m_event_id= pfs_thread->m_event_id++;
-      wait->m_operation= table_operation_map[static_cast<int> (op)];
-      wait->m_flags= op_flags;
+      wait->m_operation= table_lock_operation_map[lock_type];
+      wait->m_flags= 0;
       wait->m_object_type= share->get_object_type();
-      wait->m_schema_name= share->m_schema_name;
-      wait->m_schema_name_length= share->m_schema_name_length;
-      wait->m_object_name= share->m_table_name;
-      wait->m_object_name_length= share->m_table_name_length;
+      wait->m_weak_table_share= share;
+      wait->m_weak_version= share->get_version();
+      wait->m_index= 0;
       wait->m_wait_class= WAIT_CLASS_TABLE;
 
       pfs_thread->m_events_waits_count++;
     }
+    /* TODO: consider a shortcut here */
   }
   else
   {
-    if (share->m_timed)
+    if (klass->m_timed && share->m_timed)
     {
       flags= STATE_FLAG_TIMED;
     }
     else
     {
-#ifdef LATER
-      /*
-        Complete shortcut.
-      */
-      PFS_table *pfs_table= reinterpret_cast<PFS_table *> (table);
-      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
-      pfs_table->m_wait_stat.aggregate_counted();
-      return NULL;
-#endif
+      /* TODO: consider a shortcut here */
       flags= 0;
     }
   }
 
   state->m_flags= flags;
   state->m_table= table;
-  state->m_class= klass;
-  state->m_operation= op;
+  state->m_index= lock_type;
   return reinterpret_cast<PSI_table_locker*> (state);
 }
 
@@ -2117,8 +2267,8 @@ get_thread_file_name_locker_v1(PSI_file_
     wait->m_timer_start= 0;
     wait->m_timer_end= 0;
     wait->m_object_instance_addr= pfs_file;
-    wait->m_object_name= pfs_file->m_filename;
-    wait->m_object_name_length= pfs_file->m_filename_length;
+    wait->m_weak_file= pfs_file;
+    wait->m_weak_version= pfs_file->get_version();
     wait->m_event_id= pfs_thread->m_event_id++;
     wait->m_operation= file_operation_map[static_cast<int> (op)];
     wait->m_wait_class= WAIT_CLASS_FILE;
@@ -2189,8 +2339,8 @@ get_thread_file_stream_locker_v1(PSI_fil
       wait->m_timer_start= 0;
       wait->m_timer_end= 0;
       wait->m_object_instance_addr= pfs_file;
-      wait->m_object_name= pfs_file->m_filename;
-      wait->m_object_name_length= pfs_file->m_filename_length;
+      wait->m_weak_file= pfs_file;
+      wait->m_weak_version= pfs_file->get_version();
       wait->m_event_id= pfs_thread->m_event_id++;
       wait->m_operation= file_operation_map[static_cast<int> (op)];
       wait->m_wait_class= WAIT_CLASS_FILE;
@@ -2292,8 +2442,8 @@ get_thread_file_descriptor_locker_v1(PSI
       wait->m_timer_start= 0;
       wait->m_timer_end= 0;
       wait->m_object_instance_addr= pfs_file;
-      wait->m_object_name= pfs_file->m_filename;
-      wait->m_object_name_length= pfs_file->m_filename_length;
+      wait->m_weak_file= pfs_file;
+      wait->m_weak_version= pfs_file->get_version();
       wait->m_event_id= pfs_thread->m_event_id++;
       wait->m_operation= file_operation_map[static_cast<int> (op)];
       wait->m_wait_class= WAIT_CLASS_FILE;
@@ -2843,10 +2993,10 @@ static void end_cond_wait_v1(PSI_cond_lo
 
 /**
   Implementation of the table instrumentation interface.
-  @sa PSI_v1::start_table_wait.
+  @sa PSI_v1::start_table_io_wait.
 */
-static void start_table_wait_v1(PSI_table_locker* locker, uint index,
-                                const char *src_file, uint src_line)
+static void start_table_io_wait_v1(PSI_table_locker* locker,
+                                   const char *src_file, uint src_line)
 {
   ulonglong timer_start= 0;
   PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
@@ -2869,15 +3019,13 @@ static void start_table_wait_v1(PSI_tabl
     wait->m_source_file= src_file;
     wait->m_source_line= src_line;
   }
-
-  state->m_index= index;
 }
 
 /**
   Implementation of the table instrumentation interface.
-  @sa PSI_v1::end_table_wait.
+  @sa PSI_v1::end_table_io_wait.
 */
-static void end_table_wait_v1(PSI_table_locker* locker)
+static void end_table_io_wait_v1(PSI_table_locker* locker)
 {
   PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
   DBUG_ASSERT(state != NULL);
@@ -2886,35 +3034,26 @@ static void end_table_wait_v1(PSI_table_
 
   PFS_table *table= reinterpret_cast<PFS_table *> (state->m_table);
   DBUG_ASSERT(table != NULL);
-  PFS_instr_class *klass= reinterpret_cast<PFS_instr_class *> (state->m_class);
-  DBUG_ASSERT(klass != NULL);
 
   PFS_single_stat *stat;
 
-  switch (state->m_operation)
+  DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
+              (state->m_index == MAX_KEY));
+
+  switch (state->m_io_operation)
   {
   case PSI_TABLE_FETCH_ROW:
-    DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
-                (state->m_index == MAX_KEY));
     stat= & table->m_table_stat.m_index_stat[state->m_index].m_fetch;
     break;
   case PSI_TABLE_WRITE_ROW:
-    DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
-                (state->m_index == MAX_KEY));
     stat= & table->m_table_stat.m_index_stat[state->m_index].m_insert;
     break;
   case PSI_TABLE_UPDATE_ROW:
-    DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
-                (state->m_index == MAX_KEY));
     stat= & table->m_table_stat.m_index_stat[state->m_index].m_update;
     break;
   case PSI_TABLE_DELETE_ROW:
-    DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
-                (state->m_index == MAX_KEY));
     stat= & table->m_table_stat.m_index_stat[state->m_index].m_delete;
     break;
-  case PSI_TABLE_LOCK:
-  case PSI_TABLE_EXTERNAL_LOCK:
   default:
     DBUG_ASSERT(false);
     stat= NULL;
@@ -2934,38 +3073,98 @@ static void end_table_wait_v1(PSI_table_
     stat->aggregate_counted();
   }
 
-  if (flags & STATE_FLAG_THREAD)
+  if (flags & STATE_FLAG_WAIT)
   {
+    DBUG_ASSERT(flags & STATE_FLAG_THREAD);
     PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
     DBUG_ASSERT(thread != NULL);
 
-    PFS_single_stat *event_name_array;
-    event_name_array= thread->m_instr_class_wait_stats;
-    uint index= klass->m_event_name_index;
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
 
-    if (flags & STATE_FLAG_TIMED)
-    {
-      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
-      event_name_array[index].aggregate_timed(wait_time);
-    }
-    else
-    {
-      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
-      event_name_array[index].aggregate_counted();
-    }
+    wait->m_timer_end= timer_end;
+    if (flag_events_waits_history)
+      insert_events_waits_history(thread, wait);
+    if (flag_events_waits_history_long)
+      insert_events_waits_history_long(wait);
+    thread->m_events_waits_count--;
+  }
+}
 
-    if (flags & STATE_FLAG_WAIT)
-    {
-      PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
-      DBUG_ASSERT(wait != NULL);
+/**
+  Implementation of the table instrumentation interface.
+  @sa PSI_v1::start_table_lock_wait.
+*/
+static void start_table_lock_wait_v1(PSI_table_locker* locker,
+                                     const char *src_file, uint src_line)
+{
+  ulonglong timer_start= 0;
+  PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
 
-      wait->m_timer_end= timer_end;
-      if (flag_events_waits_history)
-        insert_events_waits_history(thread, wait);
-      if (flag_events_waits_history_long)
-        insert_events_waits_history_long(wait);
-      thread->m_events_waits_count--;
-    }
+  register uint flags= state->m_flags;
+
+  if (flags & STATE_FLAG_TIMED)
+  {
+    timer_start= get_timer_raw_value_and_function(wait_timer, & state->m_timer);
+    state->m_timer_start= timer_start;
+  }
+
+  if (flags & STATE_FLAG_WAIT)
+  {
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_start= timer_start;
+    wait->m_source_file= src_file;
+    wait->m_source_line= src_line;
+  }
+}
+
+/**
+  Implementation of the table instrumentation interface.
+  @sa PSI_v1::end_table_lock_wait.
+*/
+static void end_table_lock_wait_v1(PSI_table_locker* locker)
+{
+  PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+  ulonglong timer_end= 0;
+  ulonglong wait_time= 0;
+
+  PFS_table *table= reinterpret_cast<PFS_table *> (state->m_table);
+  DBUG_ASSERT(table != NULL);
+
+  PFS_single_stat *stat= & table->m_table_stat.m_lock_stat.m_stat[state->m_index];
+
+  register uint flags= state->m_flags;
+
+  if (flags & STATE_FLAG_TIMED)
+  {
+    timer_end= state->m_timer();
+    wait_time= timer_end - state->m_timer_start;
+    stat->aggregate_timed(wait_time);
+  }
+  else
+  {
+    stat->aggregate_counted();
+  }
+
+  if (flags & STATE_FLAG_WAIT)
+  {
+    DBUG_ASSERT(flags & STATE_FLAG_THREAD);
+    PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+    DBUG_ASSERT(thread != NULL);
+
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_end= timer_end;
+    if (flag_events_waits_history)
+      insert_events_waits_history(thread, wait);
+    if (flag_events_waits_history_long)
+      insert_events_waits_history_long(wait);
+    thread->m_events_waits_count--;
   }
 }
 
@@ -3192,7 +3391,8 @@ PSI_v1 PFS_v1=
   get_thread_mutex_locker_v1,
   get_thread_rwlock_locker_v1,
   get_thread_cond_locker_v1,
-  get_thread_table_locker_v1,
+  get_thread_table_io_locker_v1,
+  get_thread_table_lock_locker_v1,
   get_thread_file_name_locker_v1,
   get_thread_file_stream_locker_v1,
   get_thread_file_descriptor_locker_v1,
@@ -3208,8 +3408,10 @@ PSI_v1 PFS_v1=
   end_rwlock_wrwait_v1,
   start_cond_wait_v1,
   end_cond_wait_v1,
-  start_table_wait_v1,
-  end_table_wait_v1,
+  start_table_io_wait_v1,
+  end_table_io_wait_v1,
+  start_table_lock_wait_v1,
+  end_table_lock_wait_v1,
   start_file_open_wait_v1,
   end_file_open_wait_v1,
   end_file_open_wait_and_bind_to_descriptor_v1,

=== modified file 'storage/perfschema/pfs_column_types.h'
--- a/storage/perfschema/pfs_column_types.h	2010-07-23 17:08:41 +0000
+++ b/storage/perfschema/pfs_column_types.h	2010-12-09 16:17:13 +0000
@@ -38,6 +38,9 @@
 /** Size of the OBJECT_NAME columns. */
 #define COL_OBJECT_NAME_SIZE 64
 
+/** Size of the INDEX_NAME columns. */
+#define COL_INDEX_NAME_SIZE 64
+
 /** Size of the SOURCE columns. */
 #define COL_SOURCE_SIZE 64
 
@@ -82,17 +85,21 @@ enum enum_yes_no
 */
 enum enum_operation_type
 {
+  /* Mutex operations */
   OPERATION_TYPE_LOCK= 1,
   OPERATION_TYPE_TRYLOCK= 2,
 
+  /* Rwlock operations */
   OPERATION_TYPE_READLOCK= 3,
   OPERATION_TYPE_WRITELOCK= 4,
   OPERATION_TYPE_TRYREADLOCK= 5,
   OPERATION_TYPE_TRYWRITELOCK= 6,
 
+  /* Cond operations */
   OPERATION_TYPE_WAIT= 7,
   OPERATION_TYPE_TIMEDWAIT= 8,
 
+  /* File operations */
   OPERATION_TYPE_FILECREATE= 9,
   OPERATION_TYPE_FILECREATETMP= 10,
   OPERATION_TYPE_FILEOPEN= 11,
@@ -111,15 +118,27 @@ enum enum_operation_type
   OPERATION_TYPE_FILERENAME= 24,
   OPERATION_TYPE_FILESYNC= 25,
 
-  OPERATION_TYPE_TABLE_LOCK= 26,
-  OPERATION_TYPE_TABLE_EXTERNAL_LOCK= 27,
-  OPERATION_TYPE_TABLE_FETCH= 28,
-  OPERATION_TYPE_TABLE_WRITE_ROW= 29,
-  OPERATION_TYPE_TABLE_UPDATE_ROW= 30,
-  OPERATION_TYPE_TABLE_DELETE_ROW= 31
+  /* Table io operations */
+  OPERATION_TYPE_TABLE_FETCH= 26,
+  OPERATION_TYPE_TABLE_WRITE_ROW= 27,
+  OPERATION_TYPE_TABLE_UPDATE_ROW= 28,
+  OPERATION_TYPE_TABLE_DELETE_ROW= 29,
+
+  /* Table lock operations */
+  OPERATION_TYPE_TL_READ_NORMAL= 30,
+  OPERATION_TYPE_TL_READ_WITH_SHARED_LOCKS= 31,
+  OPERATION_TYPE_TL_READ_HIGH_PRIORITY= 32,
+  OPERATION_TYPE_TL_READ_NO_INSERTS= 33,
+  OPERATION_TYPE_TL_WRITE_ALLOW_WRITE= 34,
+  OPERATION_TYPE_TL_WRITE_CONCURRENT_INSERT= 35,
+  OPERATION_TYPE_TL_WRITE_DELAYED= 36,
+  OPERATION_TYPE_TL_WRITE_LOW_PRIORITY= 37,
+  OPERATION_TYPE_TL_WRITE_NORMAL= 38,
+  OPERATION_TYPE_TL_READ_EXTERNAL= 39,
+  OPERATION_TYPE_TL_WRITE_EXTERNAL= 40,
 };
 #define FIRST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_LOCK))
-#define LAST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_TABLE_DELETE_ROW))
+#define LAST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_TL_WRITE_EXTERNAL))
 #define COUNT_OPERATION_TYPE (LAST_OPERATION_TYPE - FIRST_OPERATION_TYPE + 1)
 
 enum enum_object_type

=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/pfs_engine_table.cc	2010-12-09 16:17:13 +0000
@@ -35,6 +35,9 @@
 #include "table_file_instances.h"
 #include "table_file_summary.h"
 #include "table_threads.h"
+#include "table_tiws_by_index_usage.h"
+#include "table_tiws_by_table.h"
+#include "table_tlws_by_table.h"
 
 /* For show status */
 #include "pfs_column_values.h"
@@ -73,6 +76,9 @@ static PFS_engine_table_share *all_share
   &table_setup_objects::m_share,
   &table_setup_timers::m_share,
   &table_threads::m_share,
+  &table_tiws_by_index_usage::m_share,
+  &table_tiws_by_table::m_share,
+  &table_tlws_by_table::m_share,
   NULL
 };
 

=== modified file 'storage/perfschema/pfs_events_waits.cc'
--- a/storage/perfschema/pfs_events_waits.cc	2010-09-23 16:08:54 +0000
+++ b/storage/perfschema/pfs_events_waits.cc	2010-12-09 16:17:13 +0000
@@ -168,3 +168,75 @@ void reset_events_waits_history_long(voi
     wait->m_wait_class= NO_WAIT_CLASS;
 }
 
+void reset_table_waits_by_table()
+{
+  PFS_table_share *pfs= table_share_array;
+  PFS_table_share *pfs_last= pfs + table_share_max;
+
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    if (pfs->m_lock.is_populated())
+      pfs->aggregate();
+  }
+}
+
+void reset_table_io_waits_by_table()
+{
+  PFS_table_share *pfs= table_share_array;
+  PFS_table_share *pfs_last= pfs + table_share_max;
+
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    if (pfs->m_lock.is_populated())
+      pfs->aggregate_io();
+  }
+}
+
+void reset_table_lock_waits_by_table()
+{
+  PFS_table_share *pfs= table_share_array;
+  PFS_table_share *pfs_last= pfs + table_share_max;
+
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    if (pfs->m_lock.is_populated())
+      pfs->aggregate_lock();
+  }
+}
+
+void reset_table_waits_by_table_handle()
+{
+  PFS_table *pfs= table_array;
+  PFS_table *pfs_last= pfs + table_max;
+
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    if (pfs->m_lock.is_populated())
+      pfs->sanitized_aggregate();
+  }
+}
+
+void reset_table_io_waits_by_table_handle()
+{
+  PFS_table *pfs= table_array;
+  PFS_table *pfs_last= pfs + table_max;
+
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    if (pfs->m_lock.is_populated())
+      pfs->sanitized_aggregate_io();
+  }
+}
+
+void reset_table_lock_waits_by_table_handle()
+{
+  PFS_table *pfs= table_array;
+  PFS_table *pfs_last= pfs + table_max;
+
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    if (pfs->m_lock.is_populated())
+      pfs->sanitized_aggregate_lock();
+  }
+}
+

=== modified file 'storage/perfschema/pfs_events_waits.h'
--- a/storage/perfschema/pfs_events_waits.h	2010-09-23 16:08:54 +0000
+++ b/storage/perfschema/pfs_events_waits.h	2010-12-09 16:17:13 +0000
@@ -31,6 +31,7 @@ struct PFS_table;
 struct PFS_file;
 struct PFS_thread;
 struct PFS_instr_class;
+struct PFS_table_share;
 
 /** Class of a wait event. */
 enum events_waits_class
@@ -43,21 +44,6 @@ enum events_waits_class
   WAIT_CLASS_FILE
 };
 
-/** Target object a wait event is waiting on. */
-union events_waits_target
-{
-  /** Mutex waited on. */
-  PFS_mutex *m_mutex;
-  /** RWLock waited on. */
-  PFS_rwlock *m_rwlock;
-  /** Condition waited on. */
-  PFS_cond *m_cond;
-  /** Table waited on. */
-  PFS_table *m_table;
-  /** File waited on. */
-  PFS_file *m_file;
-};
-
 /** A wait event record. */
 struct PFS_events_waits
 {
@@ -91,16 +77,14 @@ struct PFS_events_waits
     This member is populated only if m_timed is true.
   */
   ulonglong m_timer_end;
-  /** Schema name. */
-  const char *m_schema_name;
-  /** Length in bytes of @c m_schema_name. */
-  uint m_schema_name_length;
   /** Object type */
   enum_object_type m_object_type;
-  /** Object name. */
-  const char *m_object_name;
-  /** Length in bytes of @c m_object_name. */
-  uint m_object_name_length;
+  /** Table share, for table operations only. */
+  PFS_table_share *m_weak_table_share;
+  /** File, for file operations only. */
+  PFS_file *m_weak_file;
+  /** For weak pointers, target object version. */
+  uint32 m_weak_version;
   /** Address in memory of the object instance waited on. */
   const void *m_object_instance_addr;
   /** Location of the instrumentation in the source code (file name). */
@@ -145,5 +129,12 @@ void reset_events_waits_current();
 void reset_events_waits_history();
 void reset_events_waits_history_long();
 
+void reset_table_waits_by_table();
+void reset_table_io_waits_by_table();
+void reset_table_lock_waits_by_table();
+void reset_table_waits_by_table_handle();
+void reset_table_io_waits_by_table_handle();
+void reset_table_lock_waits_by_table_handle();
+
 #endif
 

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2010-12-02 16:38:55 +0000
+++ b/storage/perfschema/pfs_instr.cc	2010-12-09 16:17:13 +0000
@@ -1034,6 +1034,110 @@ PFS_table* create_table(PFS_table_share 
   return NULL;
 }
 
+void PFS_table::sanitized_aggregate(void)
+{
+  /*
+    This thread could be a TRUNCATE on an aggregated summary table,
+    and not own the table handle.
+  */
+  PFS_table_share *safe_share= sanitize_table_share(m_share);
+  PFS_thread *safe_thread= sanitize_thread(m_opening_thread);
+  if (safe_share != NULL && safe_thread != NULL)
+    safe_aggregate(& m_table_stat, safe_share, safe_thread);
+}
+
+void PFS_table::sanitized_aggregate_io(void)
+{
+  PFS_table_share *safe_share= sanitize_table_share(m_share);
+  PFS_thread *safe_thread= sanitize_thread(m_opening_thread);
+  if (safe_share != NULL && safe_thread != NULL)
+    safe_aggregate_io(& m_table_stat, safe_share, safe_thread);
+}
+
+void PFS_table::sanitized_aggregate_lock(void)
+{
+  PFS_table_share *safe_share= sanitize_table_share(m_share);
+  PFS_thread *safe_thread= sanitize_thread(m_opening_thread);
+  if (safe_share != NULL && safe_thread != NULL)
+    safe_aggregate_lock(& m_table_stat, safe_share, safe_thread);
+}
+
+void PFS_table::safe_aggregate(PFS_table_stat *table_stat,
+                               PFS_table_share *table_share,
+                               PFS_thread *thread)
+{
+  DBUG_ASSERT(table_stat != NULL);
+  DBUG_ASSERT(table_share != NULL);
+  DBUG_ASSERT(thread != NULL);
+
+  if (flag_thread_instrumentation && thread->m_enabled)
+  {
+    PFS_single_stat *event_name_array;
+    uint index;
+    event_name_array= thread->m_instr_class_wait_stats;
+
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (for wait/io/table/sql/handler) */
+    index= global_table_io_class.m_event_name_index;
+    table_stat->sum_io(& event_name_array[index]);
+
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (for wait/lock/table/sql/handler) */
+    index= global_table_lock_class.m_event_name_index;
+    table_stat->sum_lock(& event_name_array[index]);
+  }
+
+  /* Aggregate to TABLE_IO_SUMMARY, TABLE_LOCK_SUMMARY */
+  table_share->m_table_stat.aggregate(table_stat);
+  table_stat->reset();
+}
+
+void PFS_table::safe_aggregate_io(PFS_table_stat *table_stat,
+                                  PFS_table_share *table_share,
+                                  PFS_thread *thread)
+{
+  DBUG_ASSERT(table_stat != NULL);
+  DBUG_ASSERT(table_share != NULL);
+  DBUG_ASSERT(thread != NULL);
+
+  if (flag_thread_instrumentation && thread->m_enabled)
+  {
+    PFS_single_stat *event_name_array;
+    uint index;
+    event_name_array= thread->m_instr_class_wait_stats;
+
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (for wait/io/table/sql/handler) */
+    index= global_table_io_class.m_event_name_index;
+    table_stat->sum_io(& event_name_array[index]);
+  }
+
+  /* Aggregate to TABLE_IO_SUMMARY */
+  table_share->m_table_stat.aggregate_io(table_stat);
+  table_stat->reset();
+}
+
+void PFS_table::safe_aggregate_lock(PFS_table_stat *table_stat,
+                                    PFS_table_share *table_share,
+                                    PFS_thread *thread)
+{
+  DBUG_ASSERT(table_stat != NULL);
+  DBUG_ASSERT(table_share != NULL);
+  DBUG_ASSERT(thread != NULL);
+
+  if (flag_thread_instrumentation && thread->m_enabled)
+  {
+    PFS_single_stat *event_name_array;
+    uint index;
+    event_name_array= thread->m_instr_class_wait_stats;
+
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (for wait/lock/table/sql/handler) */
+    index= global_table_lock_class.m_event_name_index;
+    table_stat->sum_lock(& event_name_array[index]);
+  }
+
+  /* Aggregate to TABLE_LOCK_SUMMARY */
+  table_share->m_table_stat.aggregate_lock(table_stat);
+  table_stat->reset();
+}
+
 /**
   Destroy instrumentation for a table instance.
   @param pfs                          the table to destroy

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/pfs_instr.h	2010-12-09 16:17:13 +0000
@@ -118,6 +118,9 @@ struct PFS_cond : public PFS_instr
 /** Instrumented File and FILE implementation. @see PSI_file. */
 struct PFS_file : public PFS_instr
 {
+  uint32 get_version()
+  { return m_lock.get_version(); }
+
   /** File name. */
   char m_filename[FN_REFLEN];
   /** File name length in bytes. */
@@ -131,6 +134,36 @@ struct PFS_file : public PFS_instr
 /** Instrumented table implementation. @see PSI_table. */
 struct PFS_table
 {
+public:
+  /**
+    Aggregate this table handle statistics to the parents.
+    Only use this method for handles owned by the calling code.
+    @sa sanitized_aggregate.
+  */
+  void aggregate(void)
+  { return safe_aggregate(& m_table_stat, m_share, m_opening_thread); }
+
+  /**
+    Aggregate this table handle statistics to the parents.
+    This method is safe to call on handles not owned by the calling code.
+    @sa aggregate
+    @sa sanitized_aggregate_io
+    @sa sanitized_aggregate_lock
+  */
+  void sanitized_aggregate(void);
+
+  /**
+    Aggregate this table handle io statistics to the parents.
+    This method is safe to call on handles not owned by the calling code.
+  */
+  void sanitized_aggregate_io(void);
+
+  /**
+    Aggregate this table handle lock statistics to the parents.
+    This method is safe to call on handles not owned by the calling code.
+  */
+  void sanitized_aggregate_lock(void);
+
   /** Internal lock. */
   pfs_lock m_lock;
   /** Owner. */
@@ -141,6 +174,17 @@ struct PFS_table
   const void *m_identity;
   /** Table statistics. */
   PFS_table_stat m_table_stat;
+
+private:
+  static void safe_aggregate(PFS_table_stat *stat,
+                             PFS_table_share *safe_share,
+                             PFS_thread *safe_thread);
+  static void safe_aggregate_io(PFS_table_stat *stat,
+                                PFS_table_share *safe_share,
+                                PFS_thread *safe_thread);
+  static void safe_aggregate_lock(PFS_table_stat *stat,
+                                  PFS_table_share *safe_share,
+                                  PFS_thread *safe_thread);
 };
 
 /**

=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/pfs_instr_class.cc	2010-12-09 16:17:13 +0000
@@ -108,6 +108,7 @@ static PFS_thread_class *thread_class_ar
 PFS_table_share *table_share_array= NULL;
 
 PFS_instr_class global_table_io_class;
+PFS_instr_class global_table_lock_class;
 
 /**
   Hash index for instrumented table shares.
@@ -146,7 +147,7 @@ void init_event_name_sizing(const PFS_gl
   cond_class_start= rwlock_class_start + param->m_rwlock_class_sizing;
   file_class_start= cond_class_start + param->m_cond_class_sizing;
   table_class_start= file_class_start + param->m_file_class_sizing;
-  max_instrument_class= table_class_start + 1; /* global table io */
+  max_instrument_class= table_class_start + 2; /* global table io, lock */
 
   memcpy(global_table_io_class.m_name, "wait/io/table/sql/handler", 25);
   global_table_io_class.m_name_length= 25;
@@ -154,8 +155,14 @@ void init_event_name_sizing(const PFS_gl
   global_table_io_class.m_enabled= true;
   global_table_io_class.m_timed= true;
   global_table_io_class.m_event_name_index= table_class_start;
-}
 
+  memcpy(global_table_lock_class.m_name, "wait/lock/table/sql/handler", 27);
+  global_table_lock_class.m_name_length= 27;
+  global_table_lock_class.m_flags= 0;
+  global_table_lock_class.m_enabled= true;
+  global_table_lock_class.m_timed= true;
+  global_table_lock_class.m_event_name_index= table_class_start + 1;
+}
 
 /**
   Initialize the instrument synch class buffers.
@@ -334,10 +341,12 @@ void cleanup_table_share_hash(void)
 */
 LF_PINS* get_table_share_hash_pins(PFS_thread *thread)
 {
-  if (! table_share_hash_inited)
-    return NULL;
   if (unlikely(thread->m_table_share_hash_pins == NULL))
+  {
+    if (! table_share_hash_inited)
+      return NULL;
     thread->m_table_share_hash_pins= lf_hash_get_pins(&table_share_hash);
+  }
   return thread->m_table_share_hash_pins;
 }
 
@@ -758,12 +767,15 @@ PFS_instr_class *find_table_class(uint i
 {
   if (index == 1)
     return & global_table_io_class;
+  if (index == 2)
+    return & global_table_lock_class;
   return NULL;
 }
 
 PFS_instr_class *sanitize_table_class(PFS_instr_class *unsafe)
 {
-  if (likely(& global_table_io_class == unsafe))
+  if (likely((& global_table_io_class == unsafe) ||
+             (& global_table_lock_class == unsafe)))
     return unsafe;
   return NULL;
 }
@@ -945,6 +957,22 @@ search:
   return NULL;
 }
 
+void PFS_table_share::aggregate_io(void)
+{
+  uint index= global_table_io_class.m_event_name_index;
+  PFS_single_stat *table_io_total= & global_instr_class_waits_array[index];
+  m_table_stat.sum_io(table_io_total);
+  m_table_stat.reset_io();
+}
+
+void PFS_table_share::aggregate_lock(void)
+{
+  uint index= global_table_lock_class.m_event_name_index;
+  PFS_single_stat *table_lock_total= & global_instr_class_waits_array[index];
+  m_table_stat.sum_lock(table_lock_total);
+  m_table_stat.reset_lock();
+}
+
 void release_table_share(PFS_table_share *pfs)
 {
   DBUG_ASSERT(pfs->get_refcount() > 0);

=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/pfs_instr_class.h	2010-12-09 16:17:13 +0000
@@ -188,11 +188,23 @@ struct PFS_table_key
 struct PFS_table_share
 {
 public:
+  uint32 get_version()
+  { return m_lock.get_version(); }
+
   enum_object_type get_object_type()
   {
     return (enum_object_type) m_key.m_hash_key[0];
   }
 
+  void aggregate_io(void);
+  void aggregate_lock(void);
+
+  inline void aggregate(void)
+  {
+    aggregate_io();
+    aggregate_lock();
+  }
+
   inline void init_refcount(void)
   {
     PFS_atomic::store_32(& m_refcount, 1);
@@ -232,7 +244,7 @@ public:
   /** True if this table instrument is timed. */
   bool m_timed;
   bool m_purge;
-  /** Table io statistics. */
+  /** Table statistics. */
   PFS_table_stat m_table_stat;
   /** Number of indexes. */
   uint m_key_count;
@@ -250,6 +262,12 @@ private:
 */
 extern PFS_instr_class global_table_io_class;
 
+/**
+  Instrument controlling all table lock.
+  This instrument is used with table SETUP_OBJECTS.
+*/
+extern PFS_instr_class global_table_lock_class;
+
 struct PFS_file;
 
 /** Instrumentation metadata for a file. */

=== modified file 'storage/perfschema/pfs_lock.h'
--- a/storage/perfschema/pfs_lock.h	2010-11-21 13:48:44 +0000
+++ b/storage/perfschema/pfs_lock.h	2010-12-09 16:17:13 +0000
@@ -194,6 +194,11 @@ struct pfs_lock
             (copy->m_state == PFS_atomic::load_32(&m_state)) &&
             (copy->m_state == PFS_LOCK_ALLOCATED));
   }
+
+  uint32 get_version()
+  {
+    return PFS_atomic::load_u32(&m_version);
+  }
 };
 
 

=== modified file 'storage/perfschema/pfs_stat.h'
--- a/storage/perfschema/pfs_stat.h	2010-09-23 16:08:54 +0000
+++ b/storage/perfschema/pfs_stat.h	2010-12-09 16:17:13 +0000
@@ -179,6 +179,56 @@ struct PFS_table_io_stat
   }
 };
 
+enum PFS_TL_LOCK_TYPE
+{
+  /* Locks from enum thr_lock */
+  PFS_TL_READ= 0,
+  PFS_TL_READ_WITH_SHARED_LOCKS= 1,
+  PFS_TL_READ_HIGH_PRIORITY= 2,
+  PFS_TL_READ_NO_INSERT= 3,
+  PFS_TL_WRITE_ALLOW_WRITE= 4,
+  PFS_TL_WRITE_CONCURRENT_INSERT= 5,
+  PFS_TL_WRITE_DELAYED= 6,
+  PFS_TL_WRITE_LOW_PRIORITY= 7,
+  PFS_TL_WRITE= 8,
+
+  /* Locks for handler::ha_external_lock() */
+  PFS_TL_READ_EXTERNAL= 9,
+  PFS_TL_WRITE_EXTERNAL= 10
+};
+
+#define COUNT_PFS_TL_LOCK_TYPE 11
+
+struct PFS_table_lock_stat
+{
+  PFS_single_stat m_stat[COUNT_PFS_TL_LOCK_TYPE];
+
+  inline void reset(void)
+  {
+    PFS_single_stat *pfs= & m_stat[0];
+    PFS_single_stat *pfs_last= & m_stat[COUNT_PFS_TL_LOCK_TYPE];
+    for ( ; pfs < pfs_last ; pfs++)
+      pfs->reset();
+  }
+
+  inline void aggregate(const PFS_table_lock_stat *stat)
+  {
+    PFS_single_stat *pfs= & m_stat[0];
+    PFS_single_stat *pfs_last= & m_stat[COUNT_PFS_TL_LOCK_TYPE];
+    const PFS_single_stat *pfs_from= & stat->m_stat[0];
+    for ( ; pfs < pfs_last ; pfs++, pfs_from++)
+      pfs->aggregate(pfs_from);
+  }
+
+  inline void sum(PFS_single_stat *result)
+  {
+    PFS_single_stat *pfs= & m_stat[0];
+    PFS_single_stat *pfs_last= & m_stat[COUNT_PFS_TL_LOCK_TYPE];
+    for ( ; pfs < pfs_last ; pfs++)
+      result->aggregate(pfs);
+  }
+};
+
 /** Statistics for TABLE usage. */
 struct PFS_table_stat
 {
@@ -189,8 +239,13 @@ struct PFS_table_stat
   */
   PFS_table_io_stat m_index_stat[MAX_KEY + 1];
 
-  /** Reset table statistic. */
-  inline void reset(void)
+  /**
+    Statistics, per lock type.
+  */
+  PFS_table_lock_stat m_lock_stat;
+
+  /** Reset table io statistic. */
+  inline void reset_io(void)
   {
     PFS_table_io_stat *stat= & m_index_stat[0];
     PFS_table_io_stat *stat_last= & m_index_stat[MAX_KEY + 1];
@@ -198,7 +253,20 @@ struct PFS_table_stat
       stat->reset();
   }
 
-  inline void aggregate(const PFS_table_stat *stat)
+  /** Reset table lock statistic. */
+  inline void reset_lock(void)
+  {
+    m_lock_stat.reset();
+  }
+
+  /** Reset table statistic. */
+  inline void reset(void)
+  {
+    reset_io();
+    reset_lock();
+  }
+
+  inline void aggregate_io(const PFS_table_stat *stat)
   {
     PFS_table_io_stat *to_stat= & m_index_stat[0];
     PFS_table_io_stat *to_stat_last= & m_index_stat[MAX_KEY + 1];
@@ -207,6 +275,17 @@ struct PFS_table_stat
       to_stat->aggregate(from_stat);
   }
 
+  inline void aggregate_lock(const PFS_table_stat *stat)
+  {
+    m_lock_stat.aggregate(& stat->m_lock_stat);
+  }
+
+  inline void aggregate(const PFS_table_stat *stat)
+  {
+    aggregate_io(stat);
+    aggregate_lock(stat);
+  }
+
   inline void sum_io(PFS_single_stat *result)
   {
     PFS_table_io_stat *stat= & m_index_stat[0];
@@ -215,10 +294,15 @@ struct PFS_table_stat
       stat->sum(result);
   }
 
+  inline void sum_lock(PFS_single_stat *result)
+  {
+    m_lock_stat.sum(result);
+  }
+
   inline void sum(PFS_single_stat *result)
   {
     sum_io(result);
-    /* sum_lock(result); */
+    sum_lock(result);
   }
 };
 

=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/table_events_waits.cc	2010-12-09 16:17:13 +0000
@@ -81,6 +81,11 @@ static const TABLE_FIELD_TYPE field_type
     { NULL, 0}
   },
   {
+    { C_STRING_WITH_LEN("INDEX_NAME") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
     { C_STRING_WITH_LEN("OBJECT_TYPE") },
     { C_STRING_WITH_LEN("varchar(64)") },
     { NULL, 0}
@@ -97,7 +102,7 @@ static const TABLE_FIELD_TYPE field_type
   },
   {
     { C_STRING_WITH_LEN("OPERATION") },
-    { C_STRING_WITH_LEN("varchar(16)") },
+    { C_STRING_WITH_LEN("varchar(32)") },
     { NULL, 0}
   },
   {
@@ -114,7 +119,7 @@ static const TABLE_FIELD_TYPE field_type
 
 TABLE_FIELD_DEF
 table_events_waits_current::m_field_def=
-{ 16, field_types };
+{ 17, field_types };
 
 PFS_engine_table_share
 table_events_waits_current::m_share=
@@ -180,6 +185,98 @@ void table_events_waits_common::clear_ob
   m_row.m_object_type_length= 0;
   m_row.m_object_schema_length= 0;
   m_row.m_object_name_length= 0;
+  m_row.m_index_name_length= 0;
+}
+
+int table_events_waits_common::make_table_object_columns(volatile PFS_events_waits *wait)
+{
+  uint safe_index;
+  PFS_table_share *safe_table_share;
+
+  safe_table_share= sanitize_table_share(wait->m_weak_table_share);
+  if (unlikely(safe_table_share == NULL))
+    return 1;
+
+  if (wait->m_object_type == OBJECT_TYPE_TABLE)
+  {
+    m_row.m_object_type= "TABLE";
+    m_row.m_object_type_length= 5;
+  }
+  else
+  {
+    m_row.m_object_type= "TEMPORARY TABLE";
+    m_row.m_object_type_length= 15;
+  }
+
+  if (safe_table_share->get_version() == wait->m_weak_version)
+  {
+    /* OBJECT SCHEMA */
+    m_row.m_object_schema_length= safe_table_share->m_schema_name_length;
+    if (unlikely((m_row.m_object_schema_length == 0) ||
+                 (m_row.m_object_schema_length > sizeof(m_row.m_object_schema))))
+      return 1;
+    memcpy(m_row.m_object_schema, safe_table_share->m_schema_name, m_row.m_object_schema_length);
+
+    /* OBJECT NAME */
+    m_row.m_object_name_length= safe_table_share->m_table_name_length;
+    if (unlikely((m_row.m_object_name_length == 0) ||
+                 (m_row.m_object_name_length > sizeof(m_row.m_object_name))))
+      return 1;
+    memcpy(m_row.m_object_name, safe_table_share->m_table_name, m_row.m_object_name_length);
+
+    /* INDEX NAME */
+    safe_index= wait->m_index;
+    if (safe_index < MAX_KEY && safe_index < safe_table_share->m_key_count)
+    {
+      PFS_table_key *key= & safe_table_share->m_keys[safe_index];
+      m_row.m_index_name_length= key->m_name_length;
+      if (unlikely((m_row.m_index_name_length == 0) ||
+                   (m_row.m_index_name_length > sizeof(m_row.m_index_name))))
+        return 1;
+      memcpy(m_row.m_index_name, key->m_name, m_row.m_index_name_length);
+    }
+    else
+      m_row.m_index_name_length= 0;
+  }
+  else
+  {
+    m_row.m_object_schema_length= 0;
+    m_row.m_object_name_length= 0;
+    m_row.m_index_name_length= 0;
+  }
+
+  return 0;
+}
+
+int table_events_waits_common::make_file_object_columns(volatile PFS_events_waits *wait)
+{
+  PFS_file *safe_file;
+
+  safe_file= sanitize_file(wait->m_weak_file);
+  if (unlikely(safe_file == NULL))
+    return 1;
+
+  m_row.m_object_type= "FILE";
+  m_row.m_object_type_length= 4;
+  m_row.m_object_schema_length= 0;
+
+  if (safe_file->get_version() == wait->m_weak_version)
+  {
+    /* OBJECT NAME */
+    m_row.m_object_name_length= safe_file->m_filename_length;
+    if (unlikely((m_row.m_object_name_length == 0) ||
+                 (m_row.m_object_name_length > sizeof(m_row.m_object_name))))
+      return 1;
+    memcpy(m_row.m_object_name, safe_file->m_filename, m_row.m_object_name_length);
+  }
+  else
+  {
+    m_row.m_object_name_length= 0;
+  }
+
+  m_row.m_index_name_length= 0;
+
+  return 0;
 }
 
 /**
@@ -198,9 +295,6 @@ void table_events_waits_common::make_row
   PFS_instr_class *safe_class;
   const char *base;
   const char *safe_source_file;
-  const char *safe_table_schema_name;
-  const char *safe_table_object_name;
-  const char *safe_file_name;
 
   m_row_exists= false;
   safe_thread= sanitize_thread(pfs_thread);
@@ -249,43 +343,13 @@ void table_events_waits_common::make_row
     safe_class= sanitize_cond_class((PFS_cond_class*) wait->m_class);
     break;
   case WAIT_CLASS_TABLE:
-    if (wait->m_object_type == OBJECT_TYPE_TABLE)
-    {
-      m_row.m_object_type= "TABLE";
-      m_row.m_object_type_length= 5;
-    }
-    else
-    {
-      m_row.m_object_type= "TEMPORARY TABLE";
-      m_row.m_object_type_length= 15;
-    }
-    m_row.m_object_schema_length= wait->m_schema_name_length;
-    safe_table_schema_name= sanitize_table_schema_name(wait->m_schema_name);
-    if (unlikely((m_row.m_object_schema_length == 0) ||
-                 (m_row.m_object_schema_length > sizeof(m_row.m_object_schema)) ||
-                 (safe_table_schema_name == NULL)))
-      return;
-    memcpy(m_row.m_object_schema, safe_table_schema_name, m_row.m_object_schema_length);
-    m_row.m_object_name_length= wait->m_object_name_length;
-    safe_table_object_name= sanitize_table_object_name(wait->m_object_name);
-    if (unlikely((m_row.m_object_name_length == 0) ||
-                 (m_row.m_object_name_length > sizeof(m_row.m_object_name)) ||
-                 (safe_table_object_name == NULL)))
+    if (make_table_object_columns(wait))
       return;
-    memcpy(m_row.m_object_name, safe_table_object_name, m_row.m_object_name_length);
     safe_class= sanitize_table_class(wait->m_class);
     break;
   case WAIT_CLASS_FILE:
-    m_row.m_object_type= "FILE";
-    m_row.m_object_type_length= 4;
-    m_row.m_object_schema_length= 0;
-    m_row.m_object_name_length= wait->m_object_name_length;
-    safe_file_name= sanitize_file_name(wait->m_object_name);
-    if (unlikely((m_row.m_object_name_length == 0) ||
-                 (m_row.m_object_name_length > sizeof(m_row.m_object_name)) ||
-                 (safe_file_name == NULL)))
+    if (make_file_object_columns(wait))
       return;
-    memcpy(m_row.m_object_name, safe_file_name, m_row.m_object_name_length);
     safe_class= sanitize_file_class((PFS_file_class*) wait->m_class);
     break;
   case NO_WAIT_CLASS:
@@ -389,13 +453,24 @@ static const LEX_STRING operation_names_
   { C_STRING_WITH_LEN("rename") },
   { C_STRING_WITH_LEN("sync") },
 
-  /* Table operations */
-  { C_STRING_WITH_LEN("lock") },
-  { C_STRING_WITH_LEN("external lock") },
+  /* Table io operations */
   { C_STRING_WITH_LEN("fetch") },
   { C_STRING_WITH_LEN("insert") }, /* write row */
   { C_STRING_WITH_LEN("update") }, /* update row */
-  { C_STRING_WITH_LEN("delete") }  /* delete row */
+  { C_STRING_WITH_LEN("delete") }, /* delete row */
+
+  /* Table lock operations */
+  { C_STRING_WITH_LEN("read normal") },
+  { C_STRING_WITH_LEN("read with shared locks") },
+  { C_STRING_WITH_LEN("read high priority") },
+  { C_STRING_WITH_LEN("read no inserts") },
+  { C_STRING_WITH_LEN("write allow write") },
+  { C_STRING_WITH_LEN("write concurrent insert") },
+  { C_STRING_WITH_LEN("write delayed") },
+  { C_STRING_WITH_LEN("write low priority") },
+  { C_STRING_WITH_LEN("write normal") },
+  { C_STRING_WITH_LEN("read external") },
+  { C_STRING_WITH_LEN("write external") }
 };
 
 
@@ -483,7 +558,16 @@ int table_events_waits_common::read_row_
         else
           f->set_null();
         break;
-      case 10: /* OBJECT_TYPE */
+      case 10: /* INDEX_NAME */
+        if (m_row.m_index_name_length > 0)
+        {
+          set_field_varchar_utf8(f, m_row.m_index_name,
+                                 m_row.m_index_name_length);
+        }
+        else
+          f->set_null();
+        break;
+      case 11: /* OBJECT_TYPE */
         if (m_row.m_object_type)
         {
           set_field_varchar_utf8(f, m_row.m_object_type,
@@ -492,21 +576,21 @@ int table_events_waits_common::read_row_
         else
           f->set_null();
         break;
-      case 11: /* OBJECT_INSTANCE */
+      case 12: /* OBJECT_INSTANCE */
         set_field_ulonglong(f, m_row.m_object_instance_addr);
         break;
-      case 12: /* NESTING_EVENT_ID */
+      case 13: /* NESTING_EVENT_ID */
 #ifdef HAVE_NESTED_EVENTS
         set_field_ulonglong(f, m_row.m_nesting_event_id);
 #else
         f->set_null();
 #endif
         break;
-      case 13: /* OPERATION */
+      case 14: /* OPERATION */
         operation= &operation_names_map[(int) m_row.m_operation - 1];
         set_field_varchar_utf8(f, operation->str, operation->length);
         break;
-      case 14: /* NUMBER_OF_BYTES */
+      case 15: /* NUMBER_OF_BYTES */
         if ((m_row.m_operation == OPERATION_TYPE_FILEREAD) ||
             (m_row.m_operation == OPERATION_TYPE_FILEWRITE) ||
             (m_row.m_operation == OPERATION_TYPE_FILECHSIZE))
@@ -514,12 +598,8 @@ int table_events_waits_common::read_row_
         else
           f->set_null();
         break;
-      case 15: /* FLAGS */
-        if ((m_row.m_operation == OPERATION_TYPE_TABLE_LOCK) ||
-            (m_row.m_operation == OPERATION_TYPE_TABLE_EXTERNAL_LOCK))
-          set_field_ulong(f, m_row.m_flags);
-        else
-          f->set_null();
+      case 16: /* FLAGS */
+        f->set_null();
         break;
       default:
         DBUG_ASSERT(false);

=== modified file 'storage/perfschema/table_events_waits.h'
--- a/storage/perfschema/table_events_waits.h	2010-10-04 18:27:08 +0000
+++ b/storage/perfschema/table_events_waits.h	2010-12-09 16:17:13 +0000
@@ -63,6 +63,10 @@ struct row_events_waits
   char m_object_name[COL_OBJECT_NAME_EXTENDED_SIZE];
   /** Length in bytes of @c m_object_name. */
   uint m_object_name_length;
+  /** Column INDEX_NAME. */
+  char m_index_name[COL_INDEX_NAME_SIZE];
+  /** Length in bytes of @c m_index_name. */
+  uint m_index_name_length;
   /** Column OBJECT_INSTANCE_BEGIN. */
   intptr m_object_instance_addr;
   /** Column SOURCE. */
@@ -135,6 +139,8 @@ protected:
   {}
 
   void clear_object_columns();
+  int make_table_object_columns(volatile PFS_events_waits *wait);
+  int make_file_object_columns(volatile PFS_events_waits *wait);
 
   void make_row(bool thread_own_wait, PFS_thread *pfs_thread,
                 volatile PFS_events_waits *wait);

=== modified file 'storage/perfschema/table_ews_global_by_event_name.cc'
--- a/storage/perfschema/table_ews_global_by_event_name.cc	2010-11-15 07:40:07 +0000
+++ b/storage/perfschema/table_ews_global_by_event_name.cc	2010-12-09 16:17:13 +0000
@@ -94,7 +94,8 @@ int
 table_ews_global_by_event_name::delete_all_rows(void)
 {
   reset_events_waits_by_instance();
-  /* FIXME: table io */
+  reset_table_waits_by_table_handle();
+  reset_table_waits_by_table();
   reset_global_wait_stat();
   return 0;
 }
@@ -169,6 +170,12 @@ int table_ews_global_by_event_name::rnd_
         m_next_pos.set_after(&m_pos);
         return 0;
       }
+      if (m_pos.m_index_2 == 2)
+      {
+        make_table_lock_row(&global_table_lock_class);
+        m_next_pos.set_after(&m_pos);
+        return 0;
+      }
       break;
     default:
       break;
@@ -226,8 +233,12 @@ table_ews_global_by_event_name::rnd_pos(
     }
     break;
   case pos_ews_global_by_event_name::VIEW_TABLE:
-    DBUG_ASSERT(m_pos.m_index_2 == 1);
-    make_table_io_row(&global_table_io_class);
+    DBUG_ASSERT(m_pos.m_index_2 >= 1);
+    DBUG_ASSERT(m_pos.m_index_2 <= 2);
+    if (m_pos.m_index_2 == 1)
+      make_table_io_row(&global_table_io_class);
+    else
+      make_table_lock_row(&global_table_lock_class);
     break;
   }
 
@@ -459,6 +470,48 @@ void table_ews_global_by_event_name
   m_row_exists= true;
 }
 
+void table_ews_global_by_event_name
+::make_table_lock_row(PFS_instr_class *klass)
+{
+  m_row.m_name= klass->m_name;
+  m_row.m_name_length= klass->m_name_length;
+  uint index= klass->m_event_name_index;
+  PFS_single_stat cumulated_stat= global_instr_class_waits_array[index];
+
+  /* For all the table shares ... */
+  PFS_table_share *share= table_share_array;
+  PFS_table_share *share_last= table_share_array + table_share_max;
+  for ( ; share < share_last; share++)
+  {
+    if (share->m_lock.is_populated())
+    {
+      /* Aggregate lock stats */
+      share->m_table_stat.sum_lock(& cumulated_stat);
+    }
+  }
+
+  /* For all the table handles ... */
+  PFS_table *table= table_array;
+  PFS_table *table_last= table_array + table_max;
+  for ( ; table < table_last; table++)
+  {
+    if (table->m_lock.is_populated())
+    {
+      PFS_table_share *safe_share= sanitize_table_share(table->m_share);
+
+      if (likely(safe_share != NULL))
+      {
+        /* Aggregate lock stats */
+        table->m_table_stat.sum_lock(& cumulated_stat);
+      }
+    }
+  }
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+  m_row_exists= true;
+}
+
 int table_ews_global_by_event_name
 ::read_row_values(TABLE *table, unsigned char *, Field **fields,
                   bool read_all)

=== modified file 'storage/perfschema/table_ews_global_by_event_name.h'
--- a/storage/perfschema/table_ews_global_by_event_name.h	2010-09-23 16:08:54 +0000
+++ b/storage/perfschema/table_ews_global_by_event_name.h	2010-12-09 16:17:13 +0000
@@ -111,6 +111,7 @@ protected:
   void make_cond_row(PFS_cond_class *klass);
   void make_file_row(PFS_file_class *klass);
   void make_table_io_row(PFS_instr_class *klass);
+  void make_table_lock_row(PFS_instr_class *klass);
 
 private:
   /** Table share lock. */

=== modified file 'storage/perfschema/table_helper.h'
--- a/storage/perfschema/table_helper.h	2010-09-24 18:21:22 +0000
+++ b/storage/perfschema/table_helper.h	2010-12-09 16:17:13 +0000
@@ -124,6 +124,64 @@ struct PFS_table_io_stat_row
   }
 };
 
+struct PFS_table_lock_stat_row
+{
+  PFS_stat_row m_all;
+  PFS_stat_row m_all_read;
+  PFS_stat_row m_all_write;
+  PFS_stat_row m_read_normal;
+  PFS_stat_row m_read_with_shared_locks;
+  PFS_stat_row m_read_high_priority;
+  PFS_stat_row m_read_no_insert;
+  PFS_stat_row m_read_external;
+  PFS_stat_row m_write_allow_write;
+  PFS_stat_row m_write_concurrent_insert;
+  PFS_stat_row m_write_delayed;
+  PFS_stat_row m_write_low_priority;
+  PFS_stat_row m_write_normal;
+  PFS_stat_row m_write_external;
+
+  inline void set(time_normalizer *normalizer, const PFS_table_lock_stat *stat)
+  {
+    PFS_single_stat all_read;
+    PFS_single_stat all_write;
+    PFS_single_stat all;
+
+    m_read_normal.set(normalizer, & stat->m_stat[PFS_TL_READ]);
+    m_read_with_shared_locks.set(normalizer, & stat->m_stat[PFS_TL_READ_WITH_SHARED_LOCKS]);
+    m_read_high_priority.set(normalizer, & stat->m_stat[PFS_TL_READ_HIGH_PRIORITY]);
+    m_read_no_insert.set(normalizer, & stat->m_stat[PFS_TL_READ_NO_INSERT]);
+    m_read_external.set(normalizer, & stat->m_stat[PFS_TL_READ_EXTERNAL]);
+
+    all_read.aggregate(& stat->m_stat[PFS_TL_READ]);
+    all_read.aggregate(& stat->m_stat[PFS_TL_READ_WITH_SHARED_LOCKS]);
+    all_read.aggregate(& stat->m_stat[PFS_TL_READ_HIGH_PRIORITY]);
+    all_read.aggregate(& stat->m_stat[PFS_TL_READ_NO_INSERT]);
+    all_read.aggregate(& stat->m_stat[PFS_TL_READ_EXTERNAL]);
+
+    m_write_allow_write.set(normalizer, & stat->m_stat[PFS_TL_WRITE_ALLOW_WRITE]);
+    m_write_concurrent_insert.set(normalizer, & stat->m_stat[PFS_TL_WRITE_CONCURRENT_INSERT]);
+    m_write_delayed.set(normalizer, & stat->m_stat[PFS_TL_WRITE_DELAYED]);
+    m_write_low_priority.set(normalizer, & stat->m_stat[PFS_TL_WRITE_LOW_PRIORITY]);
+    m_write_normal.set(normalizer, & stat->m_stat[PFS_TL_WRITE]);
+    m_write_external.set(normalizer, & stat->m_stat[PFS_TL_WRITE_EXTERNAL]);
+
+    all_write.aggregate(& stat->m_stat[PFS_TL_WRITE_ALLOW_WRITE]);
+    all_write.aggregate(& stat->m_stat[PFS_TL_WRITE_CONCURRENT_INSERT]);
+    all_write.aggregate(& stat->m_stat[PFS_TL_WRITE_DELAYED]);
+    all_write.aggregate(& stat->m_stat[PFS_TL_WRITE_LOW_PRIORITY]);
+    all_write.aggregate(& stat->m_stat[PFS_TL_WRITE]);
+    all_write.aggregate(& stat->m_stat[PFS_TL_WRITE_EXTERNAL]);
+
+    all.aggregate(& all_read);
+    all.aggregate(& all_write);
+
+    m_all_read.set(normalizer, & all_read);
+    m_all_write.set(normalizer, & all_write);
+    m_all.set(normalizer, & all);
+  }
+};
+
 void set_field_object_type(Field *f, enum_object_type object_type);
 
 /** @} */

=== modified file 'storage/perfschema/table_os_global_by_type.cc'
--- a/storage/perfschema/table_os_global_by_type.cc	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/table_os_global_by_type.cc	2010-12-09 16:17:13 +0000
@@ -101,7 +101,8 @@ table_os_global_by_type::create(void)
 int
 table_os_global_by_type::delete_all_rows(void)
 {
-  reset_per_thread_wait_stat();
+  reset_table_waits_by_table_handle();
+  reset_table_waits_by_table();
   return 0;
 }
 

=== modified file 'storage/perfschema/table_setup_instruments.cc'
--- a/storage/perfschema/table_setup_instruments.cc	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/table_setup_instruments.cc	2010-12-09 16:17:13 +0000
@@ -85,66 +85,40 @@ void table_setup_instruments::reset_posi
 
 int table_setup_instruments::rnd_next(void)
 {
-  PFS_mutex_class *mutex_class;
-  PFS_rwlock_class *rwlock_class;
-  PFS_cond_class *cond_class;
-  PFS_file_class *file_class;
-  PFS_instr_class *table_class;
+  PFS_instr_class *instr_class;
 
   for (m_pos.set_at(&m_next_pos);
        m_pos.has_more_view();
        m_pos.next_view())
   {
-    switch (m_pos.m_index_1) {
+    switch (m_pos.m_index_1)
+    {
     case pos_setup_instruments::VIEW_MUTEX:
-      mutex_class= find_mutex_class(m_pos.m_index_2);
-      if (mutex_class)
-      {
-        make_row(mutex_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
+      instr_class= find_mutex_class(m_pos.m_index_2);
       break;
     case pos_setup_instruments::VIEW_RWLOCK:
-      rwlock_class= find_rwlock_class(m_pos.m_index_2);
-      if (rwlock_class)
-      {
-        make_row(rwlock_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
+      instr_class= find_rwlock_class(m_pos.m_index_2);
       break;
     case pos_setup_instruments::VIEW_COND:
-      cond_class= find_cond_class(m_pos.m_index_2);
-      if (cond_class)
-      {
-        make_row(cond_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
+      instr_class= find_cond_class(m_pos.m_index_2);
       break;
     case pos_setup_instruments::VIEW_THREAD:
-      /* Reserved for WL#4674, PERFORMANCE_SCHEMA Setup For Actors. */
+      /* Not used yet  */
+      instr_class= NULL;
       break;
     case pos_setup_instruments::VIEW_FILE:
-      file_class= find_file_class(m_pos.m_index_2);
-      if (file_class)
-      {
-        make_row(file_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
+      instr_class= find_file_class(m_pos.m_index_2);
       break;
     case pos_setup_instruments::VIEW_TABLE:
-      table_class= find_table_class(m_pos.m_index_2);
-      if (table_class)
-      {
-        make_row(table_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
+      instr_class= find_table_class(m_pos.m_index_2);
       break;
     }
+    if (instr_class)
+    {
+      make_row(instr_class);
+      m_next_pos.set_after(&m_pos);
+      return 0;
+    }
   }
 
   return HA_ERR_END_OF_FILE;
@@ -152,59 +126,37 @@ int table_setup_instruments::rnd_next(vo
 
 int table_setup_instruments::rnd_pos(const void *pos)
 {
-  PFS_mutex_class *mutex_class;
-  PFS_rwlock_class *rwlock_class;
-  PFS_cond_class *cond_class;
-  PFS_file_class *file_class;
-  PFS_instr_class *table_class;
+  PFS_instr_class *instr_class;
 
   set_position(pos);
 
-  switch (m_pos.m_index_1) {
+  switch (m_pos.m_index_1)
+  {
   case pos_setup_instruments::VIEW_MUTEX:
-    mutex_class= find_mutex_class(m_pos.m_index_2);
-    if (mutex_class)
-    {
-      make_row(mutex_class);
-      return 0;
-    }
+    instr_class= find_mutex_class(m_pos.m_index_2);
     break;
   case pos_setup_instruments::VIEW_RWLOCK:
-    rwlock_class= find_rwlock_class(m_pos.m_index_2);
-    if (rwlock_class)
-    {
-      make_row(rwlock_class);
-      return 0;
-    }
+    instr_class= find_rwlock_class(m_pos.m_index_2);
     break;
   case pos_setup_instruments::VIEW_COND:
-    cond_class= find_cond_class(m_pos.m_index_2);
-    if (cond_class)
-    {
-      make_row(cond_class);
-      return 0;
-    }
+    instr_class= find_cond_class(m_pos.m_index_2);
     break;
   case pos_setup_instruments::VIEW_THREAD:
-    /* Reserved for WL#4674, PERFORMANCE_SCHEMA Setup For Actors. */
+    /* Not used yet */
+    instr_class= NULL;
     break;
   case pos_setup_instruments::VIEW_FILE:
-    file_class= find_file_class(m_pos.m_index_2);
-    if (file_class)
-    {
-      make_row(file_class);
-      return 0;
-    }
+    instr_class= find_file_class(m_pos.m_index_2);
     break;
   case pos_setup_instruments::VIEW_TABLE:
-    table_class= find_table_class(m_pos.m_index_2);
-    if (table_class)
-    {
-      make_row(table_class);
-      return 0;
-    }
+    instr_class= find_table_class(m_pos.m_index_2);
     break;
   }
+  if (instr_class)
+  {
+    make_row(instr_class);
+    return 0;
+  }
 
   return HA_ERR_RECORD_DELETED;
 }

=== added file 'storage/perfschema/table_tiws_by_index_usage.cc'
--- a/storage/perfschema/table_tiws_by_index_usage.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_tiws_by_index_usage.cc	2010-12-09 16:17:13 +0000
@@ -0,0 +1,533 @@
+/* Copyright (c) 2010, 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
+  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 storage/perfschema/table_tiws_by_index_usage.cc
+  Table TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE (implementation).
+*/
+
+#include "my_global.h"
+#include "my_pthread.h"
+#include "pfs_instr_class.h"
+#include "pfs_column_types.h"
+#include "pfs_column_values.h"
+#include "table_tiws_by_index_usage.h"
+#include "pfs_global.h"
+
+THR_LOCK table_tiws_by_index_usage::m_table_lock;
+
+static const TABLE_FIELD_TYPE field_types[]=
+{
+  {
+    { C_STRING_WITH_LEN("OBJECT_TYPE") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_SCHEMA") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_NAME") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("INDEX_NAME") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_STAR") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  }
+};
+
+TABLE_FIELD_DEF
+table_tiws_by_index_usage::m_field_def=
+{ 39, field_types };
+
+PFS_engine_table_share
+table_tiws_by_index_usage::m_share=
+{
+  { C_STRING_WITH_LEN("table_io_waits_summary_by_index_usage") },
+  &pfs_truncatable_acl,
+  table_tiws_by_index_usage::create,
+  NULL, /* write_row */
+  table_tiws_by_index_usage::delete_all_rows,
+  NULL, /* get_row_count */
+  1000, /* records */
+  sizeof(pos_tiws_by_index_usage),
+  &m_table_lock,
+  &m_field_def,
+  false /* checked */
+};
+
+PFS_engine_table*
+table_tiws_by_index_usage::create(void)
+{
+  return new table_tiws_by_index_usage();
+}
+
+int
+table_tiws_by_index_usage::delete_all_rows(void)
+{
+  reset_table_io_waits_by_table_handle();
+  reset_table_io_waits_by_table();
+  return 0;
+}
+
+table_tiws_by_index_usage::table_tiws_by_index_usage()
+  : PFS_engine_table(&m_share, &m_pos),
+    m_row_exists(false), m_pos(), m_next_pos()
+{}
+
+void table_tiws_by_index_usage::reset_position(void)
+{
+  m_pos.reset();
+  m_next_pos.reset();
+}
+
+int table_tiws_by_index_usage::rnd_next(void)
+{
+  PFS_table_share *table_share;
+
+  for (m_pos.set_at(&m_next_pos);
+       m_pos.has_more_table();
+       m_pos.next_table())
+  {
+    table_share= &table_share_array[m_pos.m_index_1];
+    if (table_share->m_lock.is_populated())
+    {
+      if (m_pos.m_index_2 < table_share->m_key_count)
+      {
+        make_row(table_share, m_pos.m_index_2);
+        m_next_pos.set_after(&m_pos);
+        return 0;
+      }
+      if (m_pos.m_index_2 <= MAX_KEY)
+      {
+        m_pos.m_index_2= MAX_KEY;
+        make_row(table_share, m_pos.m_index_2);
+        m_next_pos.set_after(&m_pos);
+        return 0;
+      }
+    }
+  }
+
+  return HA_ERR_END_OF_FILE;
+}
+
+int
+table_tiws_by_index_usage::rnd_pos(const void *pos)
+{
+  PFS_table_share *table_share;
+
+  set_position(pos);
+
+  table_share= &table_share_array[m_pos.m_index_1];
+  if (table_share->m_lock.is_populated())
+  {
+    if (m_pos.m_index_2 < table_share->m_key_count)
+    {
+      make_row(table_share, m_pos.m_index_2);
+      return 0;
+    }
+    if (m_pos.m_index_2 == MAX_KEY)
+    {
+      make_row(table_share, m_pos.m_index_2);
+      return 0;
+    }
+  }
+
+  return HA_ERR_RECORD_DELETED;
+}
+
+void table_tiws_by_index_usage::make_row(PFS_table_share *share, uint index)
+{
+  pfs_lock lock;
+  PFS_table_io_stat cumulated_stat;
+
+  m_row_exists= false;
+
+  share->m_lock.begin_optimistic_lock(&lock);
+
+  m_row.m_object_type= share->get_object_type();
+  memcpy(m_row.m_schema_name, share->m_schema_name, share->m_schema_name_length);
+  m_row.m_schema_name_length= share->m_schema_name_length;
+  memcpy(m_row.m_object_name, share->m_table_name, share->m_table_name_length);
+  m_row.m_object_name_length= share->m_table_name_length;
+  if (index < MAX_KEY)
+  {
+    PFS_table_key *key= &share->m_keys[index];
+    memcpy(m_row.m_index_name, key->m_name, key->m_name_length);
+    m_row.m_index_name_length= key->m_name_length;
+  }
+  else
+    m_row.m_index_name_length= 0;
+
+  cumulated_stat= share->m_table_stat.m_index_stat[index];
+
+  if (! share->m_lock.end_optimistic_lock(&lock))
+    return;
+
+  m_row_exists= true;
+
+  if (share->get_refcount() > 1)
+  {
+    /* For all the table handles still opened ... */
+    PFS_table *table= table_array;
+    PFS_table *table_last= table_array + table_max;
+    for ( ; table < table_last ; table++)
+    {
+      if ((table->m_share == share) && (table->m_lock.is_populated()))
+      {
+        /*
+          If the opened table handle is for this table share,
+          aggregate the table handle statistics.
+        */
+        cumulated_stat.aggregate(&table->m_table_stat.m_index_stat[index]);
+      }
+    }
+  }
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+}
+
+int table_tiws_by_index_usage::read_row_values(TABLE *table,
+                                         unsigned char *buf,
+                                         Field **fields,
+                                         bool read_all)
+{
+  Field *f;
+
+  if (unlikely(! m_row_exists))
+    return HA_ERR_RECORD_DELETED;
+
+  /* Set the null bits */
+  DBUG_ASSERT(table->s->null_bytes == 1);
+  buf[0]= 0;
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (read_all || bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* OBJECT_TYPE */
+        set_field_object_type(f, m_row.m_object_type);
+        break;
+      case 1: /* SCHEMA_NAME */
+        set_field_varchar_utf8(f, m_row.m_schema_name,
+                               m_row.m_schema_name_length);
+        break;
+      case 2: /* OBJECT_NAME */
+        set_field_varchar_utf8(f, m_row.m_object_name,
+                               m_row.m_object_name_length);
+        break;
+      case 3: /* INDEX_NAME */
+        if (m_row.m_index_name_length > 0)
+          set_field_varchar_utf8(f, m_row.m_index_name,
+                                 m_row.m_index_name_length);
+        else
+          f->set_null();
+        break;
+      case 4: /* COUNT_STAR */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_count);
+        break;
+      case 5: /* SUM */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_sum);
+        break;
+      case 6: /* MIN */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_min);
+        break;
+      case 7: /* AVG */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_avg);
+        break;
+      case 8: /* MAX */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_max);
+        break;
+      case 9: /* COUNT_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_count);
+        break;
+      case 10: /* SUM_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_sum);
+        break;
+      case 11: /* MIN_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_min);
+        break;
+      case 12: /* AVG_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_avg);
+        break;
+      case 13: /* MAX_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_max);
+        break;
+      case 14: /* COUNT_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_count);
+        break;
+      case 15: /* SUM_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_sum);
+        break;
+      case 16: /* MIN_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_min);
+        break;
+      case 17: /* AVG_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_avg);
+        break;
+      case 18: /* MAX_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_max);
+        break;
+      case 19: /* COUNT_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_count);
+        break;
+      case 20: /* SUM_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_sum);
+        break;
+      case 21: /* MIN_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_min);
+        break;
+      case 22: /* AVG_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_avg);
+        break;
+      case 23: /* MAX_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_max);
+        break;
+      case 24: /* COUNT_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_count);
+        break;
+      case 25: /* SUM_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_sum);
+        break;
+      case 26: /* MIN_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_min);
+        break;
+      case 27: /* AVG_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_avg);
+        break;
+      case 28: /* MAX_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_max);
+        break;
+      case 29: /* COUNT_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_count);
+        break;
+      case 30: /* SUM_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_sum);
+        break;
+      case 31: /* MIN_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_min);
+        break;
+      case 32: /* AVG_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_avg);
+        break;
+      case 33: /* MAX_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_max);
+        break;
+      case 34: /* COUNT_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_count);
+        break;
+      case 35: /* SUM_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_sum);
+        break;
+      case 36: /* MIN_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_min);
+        break;
+      case 37: /* AVG_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_avg);
+        break;
+      case 38: /* MAX_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_max);
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  return 0;
+}
+

=== added file 'storage/perfschema/table_tiws_by_index_usage.h'
--- a/storage/perfschema/table_tiws_by_index_usage.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_tiws_by_index_usage.h	2010-12-09 16:17:13 +0000
@@ -0,0 +1,134 @@
+/* Copyright (c) 2010, 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
+  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 */
+
+#ifndef TABLE_IO_WAIT_SUMMARY_BY_INDEX_USAGE_H
+#define TABLE_IO_WAIT_SUMMARY_BY_INDEX_USAGE_H
+
+/**
+  @file storage/perfschema/table_tiws_by_index_usage.h
+  Table TABLE_IO_WAIT_SUMMARY_BY_INDEX_USAGE (declarations).
+*/
+
+#include "pfs_column_types.h"
+#include "pfs_engine_table.h"
+#include "pfs_instr_class.h"
+#include "pfs_instr.h"
+#include "table_helper.h"
+
+/**
+  @addtogroup Performance_schema_tables
+  @{
+*/
+
+/**
+  A row of table
+  PERFORMANCE_SCHEMA.TABLE_IO_WAIT_SUMMARY_BY_INDEX.
+*/
+struct row_tiws_by_index_usage
+{
+  /** Column OBJECT_TYPE. */
+  enum_object_type m_object_type;
+  /** Column SCHEMA_NAME. */
+  char m_schema_name[NAME_LEN];
+  /** Length in bytes of @c m_schema_name. */
+  uint m_schema_name_length;
+  /** Column OBJECT_NAME. */
+  char m_object_name[NAME_LEN];
+  /** Length in bytes of @c m_object_name. */
+  uint m_object_name_length;
+  /** Column INDEX_NAME. */
+  char m_index_name[NAME_LEN];
+  /** Length in bytes of @c m_index_name. */
+  uint m_index_name_length;
+  /** Columns COUNT/SUM/MIN/AVG/MAX (+_READ, +WRITE). */
+  PFS_table_io_stat_row m_stat;
+};
+
+/**
+  Position of a cursor on
+  PERFORMANCE_SCHEMA.TABLE_IO_WAIT_SUMMARY_BY_INDEX.
+  Index 1 on table_share_array (0 based)
+  Index 2 on index (0 based)
+*/
+struct pos_tiws_by_index_usage : public PFS_double_index
+{
+  pos_tiws_by_index_usage()
+    : PFS_double_index(0, 0)
+  {}
+
+  inline void reset(void)
+  {
+    m_index_1= 0;
+    m_index_2= 0;
+  }
+
+  inline bool has_more_table(void)
+  {
+    return (m_index_1 < table_share_max);
+  }
+
+  inline void next_table(void)
+  {
+    m_index_1++;
+    m_index_2= 0;
+  }
+};
+
+/** Table PERFORMANCE_SCHEMA.TABLE_IO_WAIT_SUMMARY_BY_INDEX. */
+class table_tiws_by_index_usage : public PFS_engine_table
+{
+public:
+  /** Table share */
+  static PFS_engine_table_share m_share;
+  static PFS_engine_table* create();
+  static int delete_all_rows();
+
+  virtual int rnd_next();
+  virtual int rnd_pos(const void *pos);
+  virtual void reset_position(void);
+
+protected:
+  virtual int read_row_values(TABLE *table,
+                              unsigned char *buf,
+                              Field **fields,
+                              bool read_all);
+
+  table_tiws_by_index_usage();
+
+public:
+  ~table_tiws_by_index_usage()
+  {}
+
+protected:
+  void make_row(PFS_table_share *table_share, uint index);
+
+private:
+  /** Table share lock. */
+  static THR_LOCK m_table_lock;
+  /** Fields definition. */
+  static TABLE_FIELD_DEF m_field_def;
+
+  /** Current row. */
+  row_tiws_by_index_usage m_row;
+  /** True is the current row exists. */
+  bool m_row_exists;
+  /** Current position. */
+  pos_tiws_by_index_usage m_pos;
+  /** Next position. */
+  pos_tiws_by_index_usage m_next_pos;
+};
+
+/** @} */
+#endif

=== added file 'storage/perfschema/table_tiws_by_table.cc'
--- a/storage/perfschema/table_tiws_by_table.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_tiws_by_table.cc	2010-12-09 16:17:13 +0000
@@ -0,0 +1,507 @@
+/* Copyright (c) 2010, 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
+  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 storage/perfschema/table_tiws_by_table.cc
+  Table TABLE_IO_WAITS_SUMMARY_BY_TABLE (implementation).
+*/
+
+#include "my_global.h"
+#include "my_pthread.h"
+#include "pfs_instr_class.h"
+#include "pfs_column_types.h"
+#include "pfs_column_values.h"
+#include "table_tiws_by_table.h"
+#include "pfs_global.h"
+
+THR_LOCK table_tiws_by_table::m_table_lock;
+
+static const TABLE_FIELD_TYPE field_types[]=
+{
+  {
+    { C_STRING_WITH_LEN("OBJECT_TYPE") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_SCHEMA") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_NAME") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_STAR") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_FETCH") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_UPDATE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_DELETE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  }
+};
+
+TABLE_FIELD_DEF
+table_tiws_by_table::m_field_def=
+{ 38, field_types };
+
+PFS_engine_table_share
+table_tiws_by_table::m_share=
+{
+  { C_STRING_WITH_LEN("table_io_waits_summary_by_table") },
+  &pfs_truncatable_acl,
+  table_tiws_by_table::create,
+  NULL, /* write_row */
+  table_tiws_by_table::delete_all_rows,
+  NULL, /* get_row_count */
+  1000, /* records */
+  sizeof(PFS_simple_index),
+  &m_table_lock,
+  &m_field_def,
+  false /* checked */
+};
+
+PFS_engine_table*
+table_tiws_by_table::create(void)
+{
+  return new table_tiws_by_table();
+}
+
+int
+table_tiws_by_table::delete_all_rows(void)
+{
+  reset_table_io_waits_by_table_handle();
+  reset_table_io_waits_by_table();
+  return 0;
+}
+
+table_tiws_by_table::table_tiws_by_table()
+  : PFS_engine_table(&m_share, &m_pos),
+    m_row_exists(false), m_pos(0), m_next_pos(0)
+{}
+
+void table_tiws_by_table::reset_position(void)
+{
+  m_pos.m_index= 0;
+  m_next_pos.m_index= 0;
+}
+
+int table_tiws_by_table::rnd_next(void)
+{
+  PFS_table_share *table_share;
+
+  for (m_pos.set_at(&m_next_pos);
+       m_pos.m_index < table_share_max;
+       m_pos.m_index++)
+  {
+    table_share= &table_share_array[m_pos.m_index];
+    if (table_share->m_lock.is_populated())
+    {
+      make_row(table_share);
+      m_next_pos.set_after(&m_pos);
+      return 0;
+    }
+  }
+
+  return HA_ERR_END_OF_FILE;
+}
+
+int
+table_tiws_by_table::rnd_pos(const void *pos)
+{
+  PFS_table_share *table_share;
+
+  set_position(pos);
+
+  table_share= &table_share_array[m_pos.m_index];
+  if (table_share->m_lock.is_populated())
+  {
+    make_row(table_share);
+    return 0;
+  }
+
+  return HA_ERR_RECORD_DELETED;
+}
+
+void table_tiws_by_table::make_row(PFS_table_share *share)
+{
+  pfs_lock lock;
+  PFS_table_io_stat cumulated_stat;
+  uint index;
+
+  m_row_exists= false;
+
+  share->m_lock.begin_optimistic_lock(&lock);
+
+  m_row.m_object_type= share->get_object_type();
+  memcpy(m_row.m_schema_name, share->m_schema_name, share->m_schema_name_length);
+  m_row.m_schema_name_length= share->m_schema_name_length;
+  memcpy(m_row.m_object_name, share->m_table_name, share->m_table_name_length);
+  m_row.m_object_name_length= share->m_table_name_length;
+
+  /* Aggregate index stats */
+  for (index= 0; index <= share->m_key_count; index++)
+    cumulated_stat.aggregate(& share->m_table_stat.m_index_stat[index]);
+
+  /** Aggregate global stats */
+  cumulated_stat.aggregate(& share->m_table_stat.m_index_stat[MAX_KEY]);
+
+  if (! share->m_lock.end_optimistic_lock(&lock))
+    return;
+
+  m_row_exists= true;
+
+  if (share->get_refcount() > 1)
+  {
+    /* For all the table handles still opened ... */
+    PFS_table *table= table_array;
+    PFS_table *table_last= table_array + table_max;
+    for ( ; table < table_last ; table++)
+    {
+      if ((table->m_share == share) && (table->m_lock.is_populated()))
+      {
+        /*
+          If the opened table handle is for this table share,
+          aggregate the table handle statistics.
+        */
+
+        /* Aggregate index stats */
+        for (index= 0; index <= share->m_key_count; index++)
+          cumulated_stat.aggregate(& table->m_table_stat.m_index_stat[index]);
+
+        /** Aggregate global stats */
+        cumulated_stat.aggregate(& table->m_table_stat.m_index_stat[MAX_KEY]);
+      }
+    }
+  }
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+}
+
+int table_tiws_by_table::read_row_values(TABLE *table,
+                                        unsigned char *buf,
+                                        Field **fields,
+                                        bool read_all)
+{
+  Field *f;
+
+  if (unlikely(! m_row_exists))
+    return HA_ERR_RECORD_DELETED;
+
+  /* Set the null bits */
+  DBUG_ASSERT(table->s->null_bytes == 1);
+  buf[0]= 0;
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (read_all || bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* OBJECT_TYPE */
+        set_field_object_type(f, m_row.m_object_type);
+        break;
+      case 1: /* SCHEMA_NAME */
+        set_field_varchar_utf8(f, m_row.m_schema_name,
+                               m_row.m_schema_name_length);
+        break;
+      case 2: /* OBJECT_NAME */
+        set_field_varchar_utf8(f, m_row.m_object_name,
+                               m_row.m_object_name_length);
+        break;
+      case 3: /* COUNT_STAR */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_count);
+        break;
+      case 4: /* SUM */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_sum);
+        break;
+      case 5: /* MIN */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_min);
+        break;
+      case 6: /* AVG */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_avg);
+        break;
+      case 7: /* MAX */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_max);
+        break;
+      case 8: /* COUNT_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_count);
+        break;
+      case 9: /* SUM_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_sum);
+        break;
+      case 10: /* MIN_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_min);
+        break;
+      case 11: /* AVG_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_avg);
+        break;
+      case 12: /* MAX_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_max);
+        break;
+      case 13: /* COUNT_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_count);
+        break;
+      case 14: /* SUM_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_sum);
+        break;
+      case 15: /* MIN_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_min);
+        break;
+      case 16: /* AVG_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_avg);
+        break;
+      case 17: /* MAX_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_max);
+        break;
+      case 18: /* COUNT_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_count);
+        break;
+      case 19: /* SUM_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_sum);
+        break;
+      case 20: /* MIN_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_min);
+        break;
+      case 21: /* AVG_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_avg);
+        break;
+      case 22: /* MAX_FETCH */
+        set_field_ulonglong(f, m_row.m_stat.m_fetch.m_max);
+        break;
+      case 23: /* COUNT_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_count);
+        break;
+      case 24: /* SUM_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_sum);
+        break;
+      case 25: /* MIN_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_min);
+        break;
+      case 26: /* AVG_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_avg);
+        break;
+      case 27: /* MAX_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_insert.m_max);
+        break;
+      case 28: /* COUNT_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_count);
+        break;
+      case 29: /* SUM_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_sum);
+        break;
+      case 30: /* MIN_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_min);
+        break;
+      case 31: /* AVG_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_avg);
+        break;
+      case 32: /* MAX_UPDATE */
+        set_field_ulonglong(f, m_row.m_stat.m_update.m_max);
+        break;
+      case 33: /* COUNT_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_count);
+        break;
+      case 34: /* SUM_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_sum);
+        break;
+      case 35: /* MIN_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_min);
+        break;
+      case 36: /* AVG_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_avg);
+        break;
+      case 37: /* MAX_DELETE */
+        set_field_ulonglong(f, m_row.m_stat.m_delete.m_max);
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  return 0;
+}
+

=== added file 'storage/perfschema/table_tiws_by_table.h'
--- a/storage/perfschema/table_tiws_by_table.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_tiws_by_table.h	2010-12-09 16:17:13 +0000
@@ -0,0 +1,100 @@
+/* Copyright (c) 2010, 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
+  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 */
+
+#ifndef TABLE_IO_WAITS_SUMMARY_BY_TABLE_H
+#define TABLE_IO_WAITS_SUMMARY_BY_TABLE_H
+
+/**
+  @file storage/perfschema/table_tiws_by_table.h
+  Table TABLE_IO_WAITS_SUMMARY_BY_TABLE (declarations).
+*/
+
+#include "pfs_column_types.h"
+#include "pfs_engine_table.h"
+#include "pfs_instr_class.h"
+#include "pfs_instr.h"
+#include "table_helper.h"
+
+/**
+  @addtogroup Performance_schema_tables
+  @{
+*/
+
+/**
+  A row of table
+  PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE.
+*/
+struct row_tiws_by_table
+{
+  /** Column OBJECT_TYPE. */
+  enum_object_type m_object_type;
+  /** Column SCHEMA_NAME. */
+  char m_schema_name[NAME_LEN];
+  /** Length in bytes of @c m_schema_name. */
+  uint m_schema_name_length;
+  /** Column OBJECT_NAME. */
+  char m_object_name[NAME_LEN];
+  /** Length in bytes of @c m_object_name. */
+  uint m_object_name_length;
+  /** Columns COUNT/SUM/MIN/AVG/MAX (+_READ, +WRITE). */
+  PFS_table_io_stat_row m_stat;
+};
+
+/** Table PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE. */
+class table_tiws_by_table : public PFS_engine_table
+{
+public:
+  /** Table share */
+  static PFS_engine_table_share m_share;
+  static PFS_engine_table* create();
+  static int delete_all_rows();
+
+  virtual int rnd_next();
+  virtual int rnd_pos(const void *pos);
+  virtual void reset_position(void);
+
+protected:
+  virtual int read_row_values(TABLE *table,
+                              unsigned char *buf,
+                              Field **fields,
+                              bool read_all);
+
+  table_tiws_by_table();
+
+public:
+  ~table_tiws_by_table()
+  {}
+
+protected:
+  void make_row(PFS_table_share *table_share);
+
+private:
+  /** Table share lock. */
+  static THR_LOCK m_table_lock;
+  /** Fields definition. */
+  static TABLE_FIELD_DEF m_field_def;
+
+  /** Current row. */
+  row_tiws_by_table m_row;
+  /** True is the current row exists. */
+  bool m_row_exists;
+  /** Current position. */
+  PFS_simple_index m_pos;
+  /** Next position. */
+  PFS_simple_index m_next_pos;
+};
+
+/** @} */
+#endif

=== added file 'storage/perfschema/table_tlws_by_table.cc'
--- a/storage/perfschema/table_tlws_by_table.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_tlws_by_table.cc	2010-12-09 16:17:13 +0000
@@ -0,0 +1,790 @@
+/* Copyright (c) 2010, 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
+  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 storage/perfschema/table_tlws_by_table.cc
+  Table TABLE_LOCK_WAITS_SUMMARY_BY_TABLE (implementation).
+*/
+
+#include "my_global.h"
+#include "my_pthread.h"
+#include "pfs_instr_class.h"
+#include "pfs_column_types.h"
+#include "pfs_column_values.h"
+#include "table_tlws_by_table.h"
+#include "pfs_global.h"
+
+THR_LOCK table_tlws_by_table::m_table_lock;
+
+static const TABLE_FIELD_TYPE field_types[]=
+{
+  {
+    { C_STRING_WITH_LEN("OBJECT_TYPE") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_SCHEMA") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_NAME") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_STAR") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_READ") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_READ_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_READ_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_READ_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_READ_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_READ_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_READ_WITH_SHARED_LOCKS") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_READ_WITH_SHARED_LOCKS") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_READ_WITH_SHARED_LOCKS") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_READ_WITH_SHARED_LOCKS") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_READ_WITH_SHARED_LOCKS") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_READ_HIGH_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_READ_HIGH_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_READ_HIGH_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_READ_HIGH_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_READ_HIGH_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_READ_NO_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_READ_NO_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_READ_NO_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_READ_NO_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_READ_NO_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_READ_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_READ_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_READ_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_READ_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_READ_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE_ALLOW_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE_ALLOW_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE_ALLOW_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE_ALLOW_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE_ALLOW_WRITE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE_CONCURRENT_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE_CONCURRENT_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE_CONCURRENT_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE_CONCURRENT_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE_CONCURRENT_INSERT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE_DELAYED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE_DELAYED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE_DELAYED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE_DELAYED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE_DELAYED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE_LOW_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE_LOW_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE_LOW_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE_LOW_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE_LOW_PRIORITY") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE_NORMAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_WRITE_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WRITE_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WRITE_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WRITE_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WRITE_EXTERNAL") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  }
+};
+
+TABLE_FIELD_DEF
+table_tlws_by_table::m_field_def=
+{ 73, field_types };
+
+PFS_engine_table_share
+table_tlws_by_table::m_share=
+{
+  { C_STRING_WITH_LEN("table_lock_waits_summary_by_table") },
+  &pfs_truncatable_acl,
+  table_tlws_by_table::create,
+  NULL, /* write_row */
+  table_tlws_by_table::delete_all_rows,
+  NULL, /* get_row_count */
+  1000, /* records */
+  sizeof(PFS_simple_index),
+  &m_table_lock,
+  &m_field_def,
+  false /* checked */
+};
+
+PFS_engine_table*
+table_tlws_by_table::create(void)
+{
+  return new table_tlws_by_table();
+}
+
+int
+table_tlws_by_table::delete_all_rows(void)
+{
+  reset_table_lock_waits_by_table_handle();
+  reset_table_lock_waits_by_table();
+  return 0;
+}
+
+table_tlws_by_table::table_tlws_by_table()
+  : PFS_engine_table(&m_share, &m_pos),
+    m_row_exists(false), m_pos(0), m_next_pos(0)
+{}
+
+void table_tlws_by_table::reset_position(void)
+{
+  m_pos.m_index= 0;
+  m_next_pos.m_index= 0;
+}
+
+int table_tlws_by_table::rnd_next(void)
+{
+  PFS_table_share *table_share;
+
+  for (m_pos.set_at(&m_next_pos);
+       m_pos.m_index < table_share_max;
+       m_pos.m_index++)
+  {
+    table_share= &table_share_array[m_pos.m_index];
+    if (table_share->m_lock.is_populated())
+    {
+      make_row(table_share);
+      m_next_pos.set_after(&m_pos);
+      return 0;
+    }
+  }
+
+  return HA_ERR_END_OF_FILE;
+}
+
+int
+table_tlws_by_table::rnd_pos(const void *pos)
+{
+  PFS_table_share *table_share;
+
+  set_position(pos);
+
+  table_share= &table_share_array[m_pos.m_index];
+  if (table_share->m_lock.is_populated())
+  {
+    make_row(table_share);
+    return 0;
+  }
+
+  return HA_ERR_RECORD_DELETED;
+}
+
+void table_tlws_by_table::make_row(PFS_table_share *share)
+{
+  pfs_lock lock;
+  PFS_table_lock_stat cumulated_stat;
+
+  m_row_exists= false;
+
+  share->m_lock.begin_optimistic_lock(&lock);
+
+  m_row.m_object_type= share->get_object_type();
+  memcpy(m_row.m_schema_name, share->m_schema_name, share->m_schema_name_length);
+  m_row.m_schema_name_length= share->m_schema_name_length;
+  memcpy(m_row.m_object_name, share->m_table_name, share->m_table_name_length);
+  m_row.m_object_name_length= share->m_table_name_length;
+
+  /** Aggregate global stats */
+  cumulated_stat.aggregate(& share->m_table_stat.m_lock_stat);
+
+  if (! share->m_lock.end_optimistic_lock(&lock))
+    return;
+
+  m_row_exists= true;
+
+  if (share->get_refcount() > 1)
+  {
+    /* For all the table handles still opened ... */
+    PFS_table *table= table_array;
+    PFS_table *table_last= table_array + table_max;
+    for ( ; table < table_last ; table++)
+    {
+      if ((table->m_share == share) && (table->m_lock.is_populated()))
+      {
+        /*
+          If the opened table handle is for this table share,
+          aggregate the table handle statistics.
+        */
+
+        /** Aggregate global stats */
+        cumulated_stat.aggregate(& table->m_table_stat.m_lock_stat);
+      }
+    }
+  }
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+}
+
+int table_tlws_by_table::read_row_values(TABLE *table,
+                                         unsigned char *buf,
+                                         Field **fields,
+                                         bool read_all)
+{
+  Field *f;
+
+  if (unlikely(! m_row_exists))
+    return HA_ERR_RECORD_DELETED;
+
+  /* Set the null bits */
+  DBUG_ASSERT(table->s->null_bytes == 1);
+  buf[0]= 0;
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (read_all || bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* OBJECT_TYPE */
+        set_field_object_type(f, m_row.m_object_type);
+        break;
+      case 1: /* SCHEMA_NAME */
+        set_field_varchar_utf8(f, m_row.m_schema_name,
+                               m_row.m_schema_name_length);
+        break;
+      case 2: /* OBJECT_NAME */
+        set_field_varchar_utf8(f, m_row.m_object_name,
+                               m_row.m_object_name_length);
+        break;
+      case 3: /* COUNT_STAR */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_count);
+        break;
+      case 4: /* SUM_TIMER */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_sum);
+        break;
+      case 5: /* MIN_TIMER */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_min);
+        break;
+      case 6: /* AVG_TIMER */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_avg);
+        break;
+      case 7: /* MAX_TIMER */
+        set_field_ulonglong(f, m_row.m_stat.m_all.m_max);
+        break;
+      case 8: /* COUNT_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_count);
+        break;
+      case 9: /* SUM_TIMER_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_sum);
+        break;
+      case 10: /* MIN_TIMER_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_min);
+        break;
+      case 11: /* AVG_TIMER_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_avg);
+        break;
+      case 12: /* MAX_TIMER_READ */
+        set_field_ulonglong(f, m_row.m_stat.m_all_read.m_max);
+        break;
+      case 13: /* COUNT_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_count);
+        break;
+      case 14: /* SUM_TIMER_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_sum);
+        break;
+      case 15: /* MIN_TIMER_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_min);
+        break;
+      case 16: /* AVG_TIMER_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_avg);
+        break;
+      case 17: /* MAX_TIMER_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_all_write.m_max);
+        break;
+
+      case 18: /* COUNT_READ_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_normal.m_count);
+        break;
+      case 19: /* SUM_TIMER_READ_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_normal.m_sum);
+        break;
+      case 20: /* MIN_TIMER_READ_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_normal.m_min);
+        break;
+      case 21: /* AVG_TIMER_READ_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_normal.m_avg);
+        break;
+      case 22: /* MAX_TIMER_READ_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_normal.m_max);
+        break;
+
+      case 23: /* COUNT_READ_WITH_SHARED_LOCKS */
+        set_field_ulonglong(f, m_row.m_stat.m_read_with_shared_locks.m_count);
+        break;
+      case 24: /* SUM_TIMER_READ_WITH_SHARED_LOCKS */
+        set_field_ulonglong(f, m_row.m_stat.m_read_with_shared_locks.m_sum);
+        break;
+      case 25: /* MIN_TIMER_READ_WITH_SHARED_LOCKS */
+        set_field_ulonglong(f, m_row.m_stat.m_read_with_shared_locks.m_min);
+        break;
+      case 26: /* AVG_TIMER_READ_WITH_SHARED_LOCKS */
+        set_field_ulonglong(f, m_row.m_stat.m_read_with_shared_locks.m_avg);
+        break;
+      case 27: /* MAX_TIMER_READ_WITH_SHARED_LOCKS */
+        set_field_ulonglong(f, m_row.m_stat.m_read_with_shared_locks.m_max);
+        break;
+
+      case 28: /* COUNT_READ_HIGH_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_read_high_priority.m_count);
+        break;
+      case 29: /* SUM_TIMER_READ_HIGH_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_read_high_priority.m_sum);
+        break;
+      case 30: /* MIN_TIMER_READ_HIGH_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_read_high_priority.m_min);
+        break;
+      case 31: /* AVG_TIMER_READ_HIGH_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_read_high_priority.m_avg);
+        break;
+      case 32: /* MAX_TIMER_READ_HIGH_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_read_high_priority.m_max);
+        break;
+
+      case 33: /* COUNT_READ_NO_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_read_no_insert.m_count);
+        break;
+      case 34: /* SUM_TIMER_READ_NO_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_read_no_insert.m_sum);
+        break;
+      case 35: /* MIN_TIMER_READ_NO_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_read_no_insert.m_min);
+        break;
+      case 36: /* AVG_TIMER_READ_NO_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_read_no_insert.m_avg);
+        break;
+      case 37: /* MAX_TIMER_READ_NO_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_read_no_insert.m_max);
+        break;
+
+      case 38: /* COUNT_READ_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_external.m_count);
+        break;
+      case 39: /* SUM_TIMER_READ_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_external.m_sum);
+        break;
+      case 40: /* MIN_TIMER_READ_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_external.m_min);
+        break;
+      case 41: /* AVG_TIMER_READ_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_external.m_avg);
+        break;
+      case 42: /* MAX_TIMER_READ_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_read_external.m_max);
+        break;
+
+      case 43: /* COUNT_WRITE_ALLOW_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_write_allow_write.m_count);
+        break;
+      case 44: /* SUM_TIMER_WRITE_ALLOW_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_write_allow_write.m_sum);
+        break;
+      case 45: /* MIN_TIMER_WRITE_ALLOW_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_write_allow_write.m_min);
+        break;
+      case 46: /* AVG_TIMER_WRITE_ALLOW_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_write_allow_write.m_avg);
+        break;
+      case 47: /* MAX_TIMER_WRITE_ALLOW_WRITE */
+        set_field_ulonglong(f, m_row.m_stat.m_write_allow_write.m_max);
+        break;
+
+      case 48: /* COUNT_WRITE_CONCURRENT_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_write_concurrent_insert.m_count);
+        break;
+      case 49: /* SUM_TIMER_WRITE_CONCURRENT_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_write_concurrent_insert.m_sum);
+        break;
+      case 50: /* MIN_TIMER_WRITE_CONCURRENT_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_write_concurrent_insert.m_min);
+        break;
+      case 51: /* AVG_TIMER_WRITE_CONCURRENT_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_write_concurrent_insert.m_avg);
+        break;
+      case 52: /* MAX_TIMER_WRITE_CONCURRENT_INSERT */
+        set_field_ulonglong(f, m_row.m_stat.m_write_concurrent_insert.m_max);
+        break;
+
+      case 53: /* COUNT_WRITE_DELAYED */
+        set_field_ulonglong(f, m_row.m_stat.m_write_delayed.m_count);
+        break;
+      case 54: /* SUM_TIMER_WRITE_DELAYED */
+        set_field_ulonglong(f, m_row.m_stat.m_write_delayed.m_sum);
+        break;
+      case 55: /* MIN_TIMER_WRITE_DELAYED */
+        set_field_ulonglong(f, m_row.m_stat.m_write_delayed.m_min);
+        break;
+      case 56: /* AVG_TIMER_WRITE_DELAYED */
+        set_field_ulonglong(f, m_row.m_stat.m_write_delayed.m_avg);
+        break;
+      case 57: /* MAX_TIMER_WRITE_DELAYED */
+        set_field_ulonglong(f, m_row.m_stat.m_write_delayed.m_max);
+        break;
+
+      case 58: /* COUNT_WRITE_LOW_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_write_low_priority.m_count);
+        break;
+      case 59: /* SUM_TIMER_WRITE_LOW_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_write_low_priority.m_sum);
+        break;
+      case 60: /* MIN_TIMER_WRITE_LOW_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_write_low_priority.m_min);
+        break;
+      case 61: /* AVG_TIMER_WRITE_LOW_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_write_low_priority.m_avg);
+        break;
+      case 62: /* MAX_TIMER_WRITE_LOW_PRIORITY */
+        set_field_ulonglong(f, m_row.m_stat.m_write_low_priority.m_max);
+        break;
+
+      case 63: /* COUNT_WRITE_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_normal.m_count);
+        break;
+      case 64: /* SUM_TIMER_WRITE_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_normal.m_sum);
+        break;
+      case 65: /* MIN_TIMER_WRITE_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_normal.m_min);
+        break;
+      case 66: /* AVG_TIMER_WRITE_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_normal.m_avg);
+        break;
+      case 67: /* MAX_TIMER_WRITE_NORMAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_normal.m_max);
+        break;
+
+      case 68: /* COUNT_WRITE_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_external.m_count);
+        break;
+      case 69: /* SUM_TIMER_WRITE_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_external.m_sum);
+        break;
+      case 70: /* MIN_TIMER_WRITE_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_external.m_min);
+        break;
+      case 71: /* AVG_TIMER_WRITE_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_external.m_avg);
+        break;
+      case 72: /* MAX_TIMER_WRITE_EXTERNAL */
+        set_field_ulonglong(f, m_row.m_stat.m_write_external.m_max);
+        break;
+
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  return 0;
+}
+

=== added file 'storage/perfschema/table_tlws_by_table.h'
--- a/storage/perfschema/table_tlws_by_table.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_tlws_by_table.h	2010-12-09 16:17:13 +0000
@@ -0,0 +1,100 @@
+/* Copyright (c) 2010, 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
+  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 */
+
+#ifndef TABLE_LOCK_WAITS_SUMMARY_BY_TABLE_H
+#define TABLE_LOCK_WAITS_SUMMARY_BY_TABLE_H
+
+/**
+  @file storage/perfschema/table_tlws_by_table.h
+  Table TABLE_LOCK_WAITS_SUMMARY_BY_TABLE (declarations).
+*/
+
+#include "pfs_column_types.h"
+#include "pfs_engine_table.h"
+#include "pfs_instr_class.h"
+#include "pfs_instr.h"
+#include "table_helper.h"
+
+/**
+  @addtogroup Performance_schema_tables
+  @{
+*/
+
+/**
+  A row of table
+  PERFORMANCE_SCHEMA.TABLE_LOCK_WAITS_SUMMARY_BY_TABLE.
+*/
+struct row_tlws_by_table
+{
+  /** Column OBJECT_TYPE. */
+  enum_object_type m_object_type;
+  /** Column SCHEMA_NAME. */
+  char m_schema_name[NAME_LEN];
+  /** Length in bytes of @c m_schema_name. */
+  uint m_schema_name_length;
+  /** Column OBJECT_NAME. */
+  char m_object_name[NAME_LEN];
+  /** Length in bytes of @c m_object_name. */
+  uint m_object_name_length;
+  /** Columns COUNT/SUM/MIN/AVG/MAX READ/WRITE/READ_NORMAL/etc. */
+  PFS_table_lock_stat_row m_stat;
+};
+
+/** Table PERFORMANCE_SCHEMA.TABLE_LOCK_WAITS_SUMMARY_BY_TABLE. */
+class table_tlws_by_table : public PFS_engine_table
+{
+public:
+  /** Table share */
+  static PFS_engine_table_share m_share;
+  static PFS_engine_table* create();
+  static int delete_all_rows();
+
+  virtual int rnd_next();
+  virtual int rnd_pos(const void *pos);
+  virtual void reset_position(void);
+
+protected:
+  virtual int read_row_values(TABLE *table,
+                              unsigned char *buf,
+                              Field **fields,
+                              bool read_all);
+
+  table_tlws_by_table();
+
+public:
+  ~table_tlws_by_table()
+  {}
+
+protected:
+  void make_row(PFS_table_share *table_share);
+
+private:
+  /** Table share lock. */
+  static THR_LOCK m_table_lock;
+  /** Fields definition. */
+  static TABLE_FIELD_DEF m_field_def;
+
+  /** Current row. */
+  row_tlws_by_table m_row;
+  /** True is the current row exists. */
+  bool m_row_exists;
+  /** Current position. */
+  PFS_simple_index m_pos;
+  /** Next position. */
+  PFS_simple_index m_next_pos;
+};
+
+/** @} */
+#endif

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5379 branch (marc.alff:3210 to 3211) WL#5371WL#5379 WL#5420Marc Alff9 Dec