List:Commits« Previous MessageNext Message »
From:Marc Alff Date:February 29 2012 5:01pm
Subject:bzr push into mysql-trunk branch (marc.alff:3704 to 3705) WL#5767
View as plain text  
 3705 Marc Alff	2012-02-29 [merge]
      WL#5767 PERFORMANCE SCHEMA STATEMENT DIGESTS
      
      Merge of mysql-trunk-wl5767 to mysql-trunk

    added:
      mysql-test/suite/perfschema/include/digest_cleanup.inc
      mysql-test/suite/perfschema/include/digest_execution.inc
      mysql-test/suite/perfschema/include/digest_setup.inc
      mysql-test/suite/perfschema/r/ddl_esms_by_digest.result
      mysql-test/suite/perfschema/r/digest_table_full.result
      mysql-test/suite/perfschema/r/dml_esms_by_digest.result
      mysql-test/suite/perfschema/r/start_server_no_digests.result
      mysql-test/suite/perfschema/r/statement_digest.result
      mysql-test/suite/perfschema/r/statement_digest_consumers.result
      mysql-test/suite/perfschema/r/statement_digest_consumers2.result
      mysql-test/suite/perfschema/r/statement_digest_long_query.result
      mysql-test/suite/perfschema/t/ddl_esms_by_digest.test
      mysql-test/suite/perfschema/t/digest_table_full-master.opt
      mysql-test/suite/perfschema/t/digest_table_full.test
      mysql-test/suite/perfschema/t/dml_esms_by_digest.test
      mysql-test/suite/perfschema/t/start_server_no_digests-master.opt
      mysql-test/suite/perfschema/t/start_server_no_digests.test
      mysql-test/suite/perfschema/t/statement_digest.test
      mysql-test/suite/perfschema/t/statement_digest_consumers-master.opt
      mysql-test/suite/perfschema/t/statement_digest_consumers.test
      mysql-test/suite/perfschema/t/statement_digest_consumers2-master.opt
      mysql-test/suite/perfschema/t/statement_digest_consumers2.test
      mysql-test/suite/perfschema/t/statement_digest_long_query-master.opt
      mysql-test/suite/perfschema/t/statement_digest_long_query.test
      mysql-test/suite/sys_vars/r/pfs_digests_size.result
      mysql-test/suite/sys_vars/t/pfs_digests_size-master_basic.opt
      mysql-test/suite/sys_vars/t/pfs_digests_size_basic.test
      storage/perfschema/gen_pfs_lex_token.cc
      storage/perfschema/pfs_digest.cc
      storage/perfschema/pfs_digest.h
      storage/perfschema/table_esms_by_digest.cc
      storage/perfschema/table_esms_by_digest.h
    modified:
      .bzrignore
      include/mysql/psi/mysql_statement.h
      include/mysql/psi/psi.h
      include/mysql/psi/psi_abi_v0.h.pp
      include/mysql/psi/psi_abi_v1.h.pp
      include/mysql/psi/psi_abi_v2.h.pp
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result*
      mysql-test/suite/perfschema/r/csv_table_io.result
      mysql-test/suite/perfschema/r/dml_handler.result
      mysql-test/suite/perfschema/r/dml_setup_consumers.result
      mysql-test/suite/perfschema/r/indexed_table_io.result
      mysql-test/suite/perfschema/r/information_schema.result
      mysql-test/suite/perfschema/r/innodb_table_io.result
      mysql-test/suite/perfschema/r/memory_table_io.result
      mysql-test/suite/perfschema/r/merge_table_io.result
      mysql-test/suite/perfschema/r/multi_table_io.result
      mysql-test/suite/perfschema/r/myisam_file_io.result
      mysql-test/suite/perfschema/r/myisam_table_io.result
      mysql-test/suite/perfschema/r/nesting.result
      mysql-test/suite/perfschema/r/ortho_iter.result
      mysql-test/suite/perfschema/r/part_table_io.result
      mysql-test/suite/perfschema/r/pfs_upgrade.result
      mysql-test/suite/perfschema/r/privilege_table_io.result
      mysql-test/suite/perfschema/r/rollback_table_io.result
      mysql-test/suite/perfschema/r/schema.result
      mysql-test/suite/perfschema/r/setup_consumers_defaults.result
      mysql-test/suite/perfschema/r/start_server_disable_idle.result
      mysql-test/suite/perfschema/r/start_server_disable_stages.result
      mysql-test/suite/perfschema/r/start_server_disable_statements.result
      mysql-test/suite/perfschema/r/start_server_disable_waits.result
      mysql-test/suite/perfschema/r/start_server_innodb.result
      mysql-test/suite/perfschema/r/start_server_no_account.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_host.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_socket_class.result
      mysql-test/suite/perfschema/r/start_server_no_socket_inst.result
      mysql-test/suite/perfschema/r/start_server_no_stage_class.result
      mysql-test/suite/perfschema/r/start_server_no_stages_history.result
      mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result
      mysql-test/suite/perfschema/r/start_server_no_statement_class.result
      mysql-test/suite/perfschema/r/start_server_no_statements_history.result
      mysql-test/suite/perfschema/r/start_server_no_statements_history_long.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_no_user.result
      mysql-test/suite/perfschema/r/start_server_no_waits_history.result
      mysql-test/suite/perfschema/r/start_server_no_waits_history_long.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
      mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_off.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result
      mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result
      mysql-test/suite/perfschema/r/table_schema.result
      mysql-test/suite/perfschema/r/temp_table_io.result
      mysql-test/suite/perfschema/r/trigger_table_io.result
      mysql-test/suite/perfschema/r/view_table_io.result
      mysys/psi_noop.c
      scripts/mysql_system_tables.sql
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_parse.cc
      sql/sys_vars.cc
      storage/perfschema/CMakeLists.txt
      storage/perfschema/ha_perfschema.cc
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_column_types.h
      storage/perfschema/pfs_engine_table.cc
      storage/perfschema/pfs_events_statements.h
      storage/perfschema/pfs_events_waits.h
      storage/perfschema/pfs_instr.cc
      storage/perfschema/pfs_instr.h
      storage/perfschema/pfs_server.cc
      storage/perfschema/pfs_server.h
      storage/perfschema/table_events_statements.cc
      storage/perfschema/table_events_statements.h
      storage/perfschema/table_helper.cc
      storage/perfschema/table_helper.h
      storage/perfschema/table_setup_consumers.cc
      storage/perfschema/unittest/pfs-t.cc
      storage/perfschema/unittest/stub_server_misc.h
 3704 Roy Lyseng	2012-02-29
      Bug#13726217: Crash in Item_ident::fix_after_pullout()
      
      The problem query contains three nested query blocks, denoted A, B
      and C. The resolution process is performed infix, so that the inner
      block C is resolved first. It is marked as const, and hence executed
      in the resolver phase. During execution, some temporary Item_field
      objects are created and added to the item tree. Going outwards,
      a semi-join transform merges the middle query block B into the outer
      query block A. In this process, Item::fix_after_pullout() is called
      on all inner items.
      
      However, the temporary Item_field objects attached to query block C
      were created without a name resolution context, which is essential
      for Item_ident::fix_after_pullout(). When attempting to access the
      context object, a crash occurs.
      
      The problem is fixed by ignoring objects with context == NULL, as
      they must be contained in an inner query block that is already
      executed.
      
      mysql-test/include/subquery_sj.inc
        Added test case for bug#13726217.
      
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_bka.result
      mysql-test/r/subquery_sj_all_bka_nixbnl.result
      mysql-test/r/subquery_sj_all_bkaunique.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_bka.result
      mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
      mysql-test/r/subquery_sj_dupsweed_bkaunique.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_bka.result
      mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
      mysql-test/r/subquery_sj_firstmatch_bkaunique.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_bka.result
      mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
      mysql-test/r/subquery_sj_loosescan_bkaunique.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_bka.result
      mysql-test/r/subquery_sj_mat_bka_nixbnl.result
      mysql-test/r/subquery_sj_mat_bkaunique.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_bka.result
      mysql-test/r/subquery_sj_none_bka_nixbnl.result
      mysql-test/r/subquery_sj_none_bkaunique.result
        Added test case results for bug#13726217.
      
      sql/item.cc
        In Item_ident::fix_after_pullout(), ignore objects without
        name resolution context.
      
      sql/item.h
        Added a comment.

    modified:
      mysql-test/include/subquery_sj.inc
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_bka.result
      mysql-test/r/subquery_sj_all_bka_nixbnl.result
      mysql-test/r/subquery_sj_all_bkaunique.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_bka.result
      mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
      mysql-test/r/subquery_sj_dupsweed_bkaunique.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_bka.result
      mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
      mysql-test/r/subquery_sj_firstmatch_bkaunique.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_bka.result
      mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
      mysql-test/r/subquery_sj_loosescan_bkaunique.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_bka.result
      mysql-test/r/subquery_sj_mat_bka_nixbnl.result
      mysql-test/r/subquery_sj_mat_bkaunique.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_bka.result
      mysql-test/r/subquery_sj_none_bka_nixbnl.result
      mysql-test/r/subquery_sj_none_bkaunique.result
      sql/item.cc
      sql/item.h
=== modified file '.bzrignore'
--- a/.bzrignore	2011-12-14 14:35:17 +0000
+++ b/.bzrignore	2012-01-16 05:37:16 +0000
@@ -3097,3 +3097,4 @@ Testing
 source_downloads
 client/mysql_plugin
 support-files/plugins.files
+storage/perfschema/pfs_lex_token.h

=== modified file 'include/mysql/psi/mysql_statement.h'
--- a/include/mysql/psi/mysql_statement.h	2011-07-05 08:15:52 +0000
+++ b/include/mysql/psi/mysql_statement.h	2012-02-10 23:14:57 +0000
@@ -42,6 +42,27 @@
 #endif
 
 #ifdef HAVE_PSI_STATEMENT_INTERFACE
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+  #define MYSQL_DIGEST_START(LOCKER) \
+    inline_mysql_digest_start(LOCKER)
+#else
+  #define MYSQL_DIGEST_START(LOCKER) \
+    NULL
+#endif
+#else
+  #define MYSQL_DIGEST_START(LOCKER) \
+    NULL
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+  #define MYSQL_ADD_TOKEN(LOCKER, T, Y) \
+    inline_mysql_add_token(LOCKER, T, Y)
+#else
+  #define MYSQL_ADD_TOKEN(LOCKER, T, Y) \
+    NULL
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
   #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN) \
     inline_mysql_start_statement(STATE, K, DB, DB_LEN, __FILE__, __LINE__)
 #else
@@ -104,6 +125,30 @@ static inline void inline_mysql_statemen
   PSI_CALL(register_statement)(category, info, count);
 }
 
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+static inline struct PSI_digest_locker *
+inline_mysql_digest_start(PSI_statement_locker *locker)
+{
+  PSI_digest_locker* digest_locker= NULL;
+
+  if (likely(locker != NULL))
+    digest_locker= PSI_CALL(digest_start)(locker);
+  return digest_locker;
+}
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+static inline struct PSI_digest_locker *
+inline_mysql_add_token(PSI_digest_locker *locker, uint token,
+                       void *yylval)
+{
+  if (likely(locker != NULL))
+    locker= PSI_CALL(digest_add_token)(locker, token,
+                                      (OPAQUE_LEX_YYSTYPE*)yylval);
+  return locker;
+}
+#endif
+
 static inline struct PSI_statement_locker *
 inline_mysql_start_statement(PSI_statement_locker_state *state,
                              PSI_statement_key key,

=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h	2012-02-16 09:51:14 +0000
+++ b/include/mysql/psi/psi.h	2012-02-23 23:27:02 +0000
@@ -26,6 +26,7 @@
 #define DISABLE_PSI_STAGE
 #define DISABLE_PSI_STATEMENT
 #define DISABLE_PSI_IDLE
+#define DISABLE_PSI_STATEMENT_DIGEST
 #endif /* EMBEDDED_LIBRARY */
 
 #ifndef MY_GLOBAL_INCLUDED
@@ -42,6 +43,18 @@
 C_MODE_START
 
 struct TABLE_SHARE;
+/*
+  There are 3 known bison parsers in the server:
+  - (1) the SQL parser itself, sql/sql_yacc.yy
+  - (2) storage/innobase/fts/fts0pars.y
+  - (3) storage/innobase/pars/pars0grm.y
+  What is instrumented here are the tokens from the SQL query text (1),
+  to make digests.
+  Now, to avoid name pollution and conflicts with different YYSTYPE definitions,
+  an opaque structure is used here.
+  The real type to use when invoking the digest api is LEX_YYSTYPE.
+*/
+struct OPAQUE_LEX_YYSTYPE;
 
 /**
   @file mysql/psi/psi.h
@@ -244,6 +257,17 @@ typedef struct PSI_bootstrap PSI_bootstr
 #endif
 
 /**
+  @def DISABLE_PSI_STATEMENT_DIGEST
+  Compiling option to disable the statement digest instrumentation.
+*/
+
+#ifndef DISABLE_PSI_STATEMENT
+#ifndef DISABLE_PSI_STATEMENT_DIGEST
+#define HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+#endif
+#endif
+
+/**
   @def DISABLE_PSI_SOCKET
   Compiling option to disable the statement instrumentation.
   @sa DISABLE_PSI_MUTEX
@@ -325,6 +349,13 @@ typedef struct PSI_file_locker PSI_file_
 struct PSI_socket_locker;
 typedef struct PSI_socket_locker PSI_socket_locker;
 
+/**
+  Interface for an instrumented statement digest operation.
+  This is an opaque structure.
+*/
+struct PSI_digest_locker;
+typedef struct PSI_digest_locker PSI_digest_locker;
+
 /** Operation performed on an instrumented mutex. */
 enum PSI_mutex_operation
 {
@@ -917,6 +948,27 @@ struct PSI_table_locker_state_v1
   uint m_index;
 };
 
+#define PSI_MAX_DIGEST_STORAGE_SIZE 1024
+
+/**
+  Structure to store token count/array for a statement
+  on which digest is to be calculated.
+*/
+struct PSI_digest_storage
+{
+  my_bool m_full;
+  int m_byte_count;
+  unsigned char m_token_array[PSI_MAX_DIGEST_STORAGE_SIZE];
+};
+typedef struct PSI_digest_storage PSI_digest_storage;
+
+struct PSI_digest_locker_state
+{
+  int m_last_id_index;
+  PSI_digest_storage m_digest_storage;
+};
+typedef struct PSI_digest_locker_state PSI_digest_locker_state;
+
 /**
   State data storage for @c get_thread_statement_locker_v1_t,
   @c get_thread_statement_locker_v1_t.
@@ -975,6 +1027,8 @@ struct PSI_statement_locker_state_v1
   ulong m_sort_rows;
   /** Metric, number of sort scans. */
   ulong m_sort_scan;
+  /** Statement digest. */
+  PSI_digest_locker_state m_digest_state;
 };
 
 /**
@@ -1810,6 +1864,12 @@ typedef void (*set_socket_info_v1_t)(str
 */
 typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
 
+typedef struct PSI_digest_locker * (*digest_start_v1_t)
+  (struct PSI_statement_locker *locker);
+
+typedef struct PSI_digest_locker* (*digest_add_token_v1_t)
+  (struct PSI_digest_locker *locker, uint token, struct OPAQUE_LEX_YYSTYPE *yylval);
+
 /**
   Performance Schema Interface, version 1.
   @since PSI_VERSION_1
@@ -2001,6 +2061,10 @@ struct PSI_v1
   set_socket_info_v1_t set_socket_info;
   /** @sa set_socket_thread_owner_v1_t. */
   set_socket_thread_owner_v1_t set_socket_thread_owner;
+  /** @sa digest_start_v1_t. */
+  digest_start_v1_t digest_start;
+  /** @sa digest_add_token_v1_t. */
+  digest_add_token_v1_t digest_add_token;
 };
 
 /** @} (end of group Group_PSI_v1) */

=== modified file 'include/mysql/psi/psi_abi_v0.h.pp'
--- a/include/mysql/psi/psi_abi_v0.h.pp	2012-01-06 09:03:53 +0000
+++ b/include/mysql/psi/psi_abi_v0.h.pp	2012-02-09 14:41:43 +0000
@@ -1,6 +1,7 @@
 #include "mysql/psi/psi.h"
 C_MODE_START
 struct TABLE_SHARE;
+struct OPAQUE_LEX_YYSTYPE;
 struct PSI_mutex;
 typedef struct PSI_mutex PSI_mutex;
 struct PSI_rwlock;

=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp	2012-01-06 09:03:53 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp	2012-02-23 23:27:02 +0000
@@ -1,6 +1,7 @@
 #include "mysql/psi/psi.h"
 C_MODE_START
 struct TABLE_SHARE;
+struct OPAQUE_LEX_YYSTYPE;
 struct PSI_mutex;
 typedef struct PSI_mutex PSI_mutex;
 struct PSI_rwlock;
@@ -38,6 +39,8 @@ struct PSI_file_locker;
 typedef struct PSI_file_locker PSI_file_locker;
 struct PSI_socket_locker;
 typedef struct PSI_socket_locker PSI_socket_locker;
+struct PSI_digest_locker;
+typedef struct PSI_digest_locker PSI_digest_locker;
 enum PSI_mutex_operation
 {
   PSI_MUTEX_LOCK= 0,
@@ -236,6 +239,19 @@ struct PSI_table_locker_state_v1
   void *m_wait;
   uint m_index;
 };
+struct PSI_digest_storage
+{
+  my_bool m_full;
+  int m_byte_count;
+  unsigned char m_token_array[1024];
+};
+typedef struct PSI_digest_storage PSI_digest_storage;
+struct PSI_digest_locker_state
+{
+  int m_last_id_index;
+  PSI_digest_storage m_digest_storage;
+};
+typedef struct PSI_digest_locker_state PSI_digest_locker_state;
 struct PSI_statement_locker_state_v1
 {
   my_bool m_discarded;
@@ -261,6 +277,7 @@ struct PSI_statement_locker_state_v1
   ulong m_sort_range;
   ulong m_sort_rows;
   ulong m_sort_scan;
+  PSI_digest_locker_state m_digest_state;
 };
 struct PSI_socket_locker_state_v1
 {
@@ -478,6 +495,10 @@ typedef void (*set_socket_info_v1_t)(str
                                      const struct sockaddr *addr,
                                      socklen_t addr_len);
 typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
+typedef struct PSI_digest_locker * (*digest_start_v1_t)
+  (struct PSI_statement_locker *locker);
+typedef struct PSI_digest_locker* (*digest_add_token_v1_t)
+  (struct PSI_digest_locker *locker, uint token, struct OPAQUE_LEX_YYSTYPE *yylval);
 struct PSI_v1
 {
   register_mutex_v1_t register_mutex;
@@ -573,6 +594,8 @@ struct PSI_v1
   set_socket_state_v1_t set_socket_state;
   set_socket_info_v1_t set_socket_info;
   set_socket_thread_owner_v1_t set_socket_thread_owner;
+  digest_start_v1_t digest_start;
+  digest_add_token_v1_t digest_add_token;
 };
 typedef struct PSI_v1 PSI;
 typedef struct PSI_mutex_info_v1 PSI_mutex_info;

=== modified file 'include/mysql/psi/psi_abi_v2.h.pp'
--- a/include/mysql/psi/psi_abi_v2.h.pp	2012-01-06 09:03:53 +0000
+++ b/include/mysql/psi/psi_abi_v2.h.pp	2012-02-21 18:27:58 +0000
@@ -1,6 +1,7 @@
 #include "mysql/psi/psi.h"
 C_MODE_START
 struct TABLE_SHARE;
+struct OPAQUE_LEX_YYSTYPE;
 struct PSI_mutex;
 typedef struct PSI_mutex PSI_mutex;
 struct PSI_rwlock;
@@ -38,6 +39,8 @@ struct PSI_file_locker;
 typedef struct PSI_file_locker PSI_file_locker;
 struct PSI_socket_locker;
 typedef struct PSI_socket_locker PSI_socket_locker;
+struct PSI_digest_locker;
+typedef struct PSI_digest_locker PSI_digest_locker;
 enum PSI_mutex_operation
 {
   PSI_MUTEX_LOCK= 0,

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2012-02-29 11:17:52 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2012-02-29 13:26:31 +0000
@@ -513,10 +513,15 @@ The following options may be given as th
  Default startup value for the global_instrumentation
  consumer.
  (Defaults to on; use --skip-performance-schema-consumer-global-instrumentation to disable.)
+ --performance-schema-consumer-statements-digest 
+ Default startup value for the statements_digest consumer.
+ (Defaults to on; use --skip-performance-schema-consumer-statements-digest to disable.)
  --performance-schema-consumer-thread-instrumentation 
  Default startup value for the thread_instrumentation
  consumer.
  (Defaults to on; use --skip-performance-schema-consumer-thread-instrumentation to disable.)
+ --performance-schema-digests-size=# 
+ Size of the statement digest.
  --performance-schema-events-stages-history-long-size=# 
  Number of rows in EVENTS_STAGES_HISTORY_LONG.
  --performance-schema-events-stages-history-size=# 
@@ -1047,7 +1052,9 @@ performance-schema-consumer-events-waits
 performance-schema-consumer-events-waits-history FALSE
 performance-schema-consumer-events-waits-history-long FALSE
 performance-schema-consumer-global-instrumentation TRUE
+performance-schema-consumer-statements-digest TRUE
 performance-schema-consumer-thread-instrumentation TRUE
+performance-schema-digests-size 200
 performance-schema-events-stages-history-long-size 10000
 performance-schema-events-stages-history-size 10
 performance-schema-events-statements-history-long-size 10000

=== modified file 'mysql-test/r/mysqld--help-win.result' (properties changed: +x to -x)
--- a/mysql-test/r/mysqld--help-win.result	2012-02-28 14:16:56 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2012-02-29 14:44:48 +0000
@@ -513,10 +513,15 @@ The following options may be given as th
  Default startup value for the global_instrumentation
  consumer.
  (Defaults to on; use --skip-performance-schema-consumer-global-instrumentation to disable.)
+ --performance-schema-consumer-statements-digest 
+ Default startup value for the statements_digest consumer.
+ (Defaults to on; use --skip-performance-schema-consumer-statements-digest to disable.)
  --performance-schema-consumer-thread-instrumentation 
  Default startup value for the thread_instrumentation
  consumer.
  (Defaults to on; use --skip-performance-schema-consumer-thread-instrumentation to disable.)
+ --performance-schema-digests-size=# 
+ Size of the statement digest.
  --performance-schema-events-stages-history-long-size=# 
  Number of rows in EVENTS_STAGES_HISTORY_LONG.
  --performance-schema-events-stages-history-size=# 
@@ -1055,7 +1060,9 @@ performance-schema-consumer-events-waits
 performance-schema-consumer-events-waits-history FALSE
 performance-schema-consumer-events-waits-history-long FALSE
 performance-schema-consumer-global-instrumentation TRUE
+performance-schema-consumer-statements-digest TRUE
 performance-schema-consumer-thread-instrumentation TRUE
+performance-schema-digests-size 200
 performance-schema-events-stages-history-long-size 10000
 performance-schema-events-stages-history-size 10
 performance-schema-events-statements-history-long-size 10000

=== added file 'mysql-test/suite/perfschema/include/digest_cleanup.inc'
--- a/mysql-test/suite/perfschema/include/digest_cleanup.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/include/digest_cleanup.inc	2012-02-12 21:48:28 +0000
@@ -0,0 +1,11 @@
+--echo ####################################
+--echo # CLEANUP
+--echo ####################################
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP DATABASE IF EXISTS statements_digest;
+--enable_warnings

=== added file 'mysql-test/suite/perfschema/include/digest_execution.inc'
--- a/mysql-test/suite/perfschema/include/digest_execution.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/include/digest_execution.inc	2012-02-20 13:32:56 +0000
@@ -0,0 +1,86 @@
+--echo ####################################
+--echo # EXECUTION
+--echo ####################################
+
+# -----------------------------------
+# SQL Queries to test normalizations.
+# -----------------------------------
+SELECT 1 FROM t1;
+SELECT 1 FROM `t1`;
+SELECT 1,2 FROM t1;
+SELECT 1, 2, 3, 4 FROM t1;
+SELECT 1 FROM t2;
+SELECT 1,2 FROM t2;
+SELECT 1, 2, 3, 4 FROM t2;
+
+# (NUM) => (#)
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+
+# (NUM,NUM) => (#,#)
+INSERT INTO t3 VALUES (1, 2);
+INSERT INTO t4 VALUES (1, 2);
+# (NUM,NUM,NUM) => (#,#)
+INSERT INTO t5 VALUES (1, 2, 3);
+
+# (NUM),(NUM) => (#),(#)
+INSERT INTO t1 VALUES (1), (2), (3);
+# (NUM),(NUM),(NUM) => (#),(#)
+INSERT INTO t1 VALUES (1), (2), (3), (4);
+
+# (NUM,NUM),(NUM,NUM) => (#,#),(#,#)
+INSERT INTO t3 VALUES (1, 2), (3, 4), (5, 6);
+# (NUM,NUM,NUM),(NUM,NUM,NUM),(NUM,NUM,NUM) => (#,#),(#,#)
+INSERT INTO t5 VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
+
+# -----------------------------------------------------------------------
+# Test case for handling spaces in statement.
+# -----------------------------------------------------------------------
+
+SELECT                                          1           +        1;
+
+# -----------------------------------------------------------------------
+# Test case for handling comments.
+# -----------------------------------------------------------------------
+
+# comment starting with "--"
+# TODO : SELECT 1; -- This comment continues to the end of line
+# comment starting from "#"
+SELECT 1; # This comment continues to the end of line
+
+# Inline comment
+SELECT 1 /* This is an inline comment */ + 1;
+
+# Multiple line comments
+ SELECT 1+
+ /*
+ this is a
+ multiple-line comment
+ */
+ 1;
+
+
+# -----------------------------------------------------------------------
+# Tests to show how the digest behaves with tokens that can have multiple
+# names (such as DATABASE = "DATABASE" or "SCHEMA", SUBSTRING, STD_SYM,
+# VARIANCE_SYM ... )
+# -----------------------------------------------------------------------
+
+--disable_warnings
+CREATE SCHEMA statements_digest_temp;
+DROP SCHEMA statements_digest_temp;
+CREATE DATABASE statements_digest_temp;
+DROP DATABASE statements_digest_temp;
+# TODO : add more
+--enable_warnings
+
+# -----------------------------------------------------------------------
+# Test case to show stats for statements giving ERRORS/WARNINGS, are also
+# captured.
+# -----------------------------------------------------------------------
+--ERROR ER_NO_SUCH_TABLE
+SELECT 1 from t11;
+create table t11 (c char(4));
+--ERROR ER_TABLE_EXISTS_ERROR
+create table t11 (c char(4));
+insert into t11 values("MySQL");

=== added file 'mysql-test/suite/perfschema/include/digest_setup.inc'
--- a/mysql-test/suite/perfschema/include/digest_setup.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/include/digest_setup.inc	2012-02-14 09:20:56 +0000
@@ -0,0 +1,21 @@
+# Making sure not to run when ps-protocol is set.
+--source ../include/no_protocol.inc
+
+--echo ####################################
+--echo # SETUP
+--echo ####################################
+# Database setup
+--disable_warnings
+CREATE DATABASE statements_digest;
+--enable_warnings
+USE statements_digest;
+
+# Table set up for queries
+--disable_warnings
+CREATE TABLE t1(a int);
+CREATE TABLE t2(a int);
+CREATE TABLE t3(a int, b int);
+CREATE TABLE t4(a int, b int);
+CREATE TABLE t5(a int, b int, c int);
+--enable_warnings
+

=== modified file 'mysql-test/suite/perfschema/r/csv_table_io.result'
--- a/mysql-test/suite/perfschema/r/csv_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/csv_table_io.result	2012-02-28 15:57:52 +0000
@@ -116,6 +116,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== added file 'mysql-test/suite/perfschema/r/ddl_esms_by_digest.result'
--- a/mysql-test/suite/perfschema/r/ddl_esms_by_digest.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/ddl_esms_by_digest.result	2011-06-07 10:23:30 +0000
@@ -0,0 +1,9 @@
+alter table performance_schema.events_statements_summary_by_digest
+add column foo integer;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
+truncate table performance_schema.events_statements_summary_by_digest;
+ALTER TABLE performance_schema.events_statements_summary_by_digest ADD INDEX test_index(DIGEST);
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
+CREATE UNIQUE INDEX test_index
+ON performance_schema.events_statements_summary_by_digest(DIGEST);
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'

=== added file 'mysql-test/suite/perfschema/r/digest_table_full.result'
--- a/mysql-test/suite/perfschema/r/digest_table_full.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/digest_table_full.result	2012-02-29 13:26:31 +0000
@@ -0,0 +1,94 @@
+####################################
+# SETUP
+####################################
+CREATE DATABASE statements_digest;
+USE statements_digest;
+CREATE TABLE t1(a int);
+CREATE TABLE t2(a int);
+CREATE TABLE t3(a int, b int);
+CREATE TABLE t4(a int, b int);
+CREATE TABLE t5(a int, b int, c int);
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+####################################
+# EXECUTION
+####################################
+SELECT 1 FROM t1;
+1
+SELECT 1 FROM `t1`;
+1
+SELECT 1,2 FROM t1;
+1	2
+SELECT 1, 2, 3, 4 FROM t1;
+1	2	3	4
+SELECT 1 FROM t2;
+1
+SELECT 1,2 FROM t2;
+1	2
+SELECT 1, 2, 3, 4 FROM t2;
+1	2	3	4
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t3 VALUES (1, 2);
+INSERT INTO t4 VALUES (1, 2);
+INSERT INTO t5 VALUES (1, 2, 3);
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (1), (2), (3), (4);
+INSERT INTO t3 VALUES (1, 2), (3, 4), (5, 6);
+INSERT INTO t5 VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
+SELECT                                          1           +        1;
+1           +        1
+2
+SELECT 1;
+1
+1
+SELECT 1 /* This is an inline comment */ + 1;
+1 /* This is an inline comment */ + 1
+2
+SELECT 1+
+/*
+this is a
+multiple-line comment
+*/
+1;
+1+
+/*
+this is a
+multiple-line comment
+*/
+1
+2
+CREATE SCHEMA statements_digest_temp;
+DROP SCHEMA statements_digest_temp;
+CREATE DATABASE statements_digest_temp;
+DROP DATABASE statements_digest_temp;
+SELECT 1 from t11;
+ERROR 42S02: Table 'statements_digest.t11' doesn't exist
+create table t11 (c char(4));
+create table t11 (c char(4));
+ERROR 42S01: Table 't11' already exists
+insert into t11 values("MySQL");
+Warnings:
+Warning	1265	Data truncated for column 'c' at row 1
+####################################
+# QUERYING PS STATEMENT DIGEST
+####################################
+SELECT DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+DIGEST	DIGEST_TEXT	COUNT_STAR	SUM_ROWS_AFFECTED	SUM_WARNINGS	SUM_ERRORS
+NULL	NULL	29	21	1	2
+98b2254389c9138db2aa32e607a5526a	TRUNCATE TABLE performance_schema . events_statements_summary_by_digest  	1	0	0	0
+SHOW VARIABLES LIKE "performance_schema_digests_size";
+Variable_name	Value
+performance_schema_digests_size	2
+SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_digest;
+COUNT(*)
+2
+####################################
+# CLEANUP
+####################################
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP DATABASE IF EXISTS statements_digest;

=== added file 'mysql-test/suite/perfschema/r/dml_esms_by_digest.result'
--- a/mysql-test/suite/perfschema/r/dml_esms_by_digest.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/dml_esms_by_digest.result	2012-02-02 12:04:43 +0000
@@ -0,0 +1,27 @@
+select * from performance_schema.events_statements_summary_by_digest
+where digest like 'XXYYZZ%' limit 1;
+DIGEST	DIGEST_TEXT	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT	SUM_LOCK_TIME	SUM_ERRORS	SUM_WARNINGS	SUM_ROWS_AFFECTED	SUM_ROWS_SENT	SUM_ROWS_EXAMINED	SUM_CREATED_TMP_DISK_TABLES	SUM_CREATED_TMP_TABLES	SUM_SELECT_FULL_JOIN	SUM_SELECT_FULL_RANGE_JOIN	SUM_SELECT_RANGE	SUM_SELECT_RANGE_CHECK	SUM_SELECT_SCAN	SUM_SORT_MERGE_PASSES	SUM_SORT_RANGE	SUM_SORT_ROWS	SUM_SORT_SCAN	SUM_NO_INDEX_USED	SUM_NO_GOOD_INDEX_USED	FIRST_SEEN	LAST_SEEN
+select * from performance_schema.events_statements_summary_by_digest
+where digest='XXYYZZ';
+DIGEST	DIGEST_TEXT	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT	SUM_LOCK_TIME	SUM_ERRORS	SUM_WARNINGS	SUM_ROWS_AFFECTED	SUM_ROWS_SENT	SUM_ROWS_EXAMINED	SUM_CREATED_TMP_DISK_TABLES	SUM_CREATED_TMP_TABLES	SUM_SELECT_FULL_JOIN	SUM_SELECT_FULL_RANGE_JOIN	SUM_SELECT_RANGE	SUM_SELECT_RANGE_CHECK	SUM_SELECT_SCAN	SUM_SORT_MERGE_PASSES	SUM_SORT_RANGE	SUM_SORT_ROWS	SUM_SORT_SCAN	SUM_NO_INDEX_USED	SUM_NO_GOOD_INDEX_USED	FIRST_SEEN	LAST_SEEN
+insert into performance_schema.events_statements_summary_by_digest
+set digest='XXYYZZ', count_star=1, sum_timer_wait=2, min_timer_wait=3,
+avg_timer_wait=4, max_timer_wait=5;
+ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'events_statements_summary_by_digest'
+update performance_schema.events_statements_summary_by_digest
+set count_star=12;
+ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'events_statements_summary_by_digest'
+update performance_schema.events_statements_summary_by_digest
+set count_star=12 where digest like "XXYYZZ";
+ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'events_statements_summary_by_digest'
+delete from performance_schema.events_statements_summary_by_digest
+where count_star=1;
+ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'events_statements_summary_by_digest'
+delete from performance_schema.events_statements_summary_by_digest;
+ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'events_statements_summary_by_digest'
+LOCK TABLES performance_schema.events_statements_summary_by_digest READ;
+ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'events_statements_summary_by_digest'
+UNLOCK TABLES;
+LOCK TABLES performance_schema.events_statements_summary_by_digest WRITE;
+ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'events_statements_summary_by_digest'
+UNLOCK TABLES;

=== modified file 'mysql-test/suite/perfschema/r/dml_handler.result'
--- a/mysql-test/suite/perfschema/r/dml_handler.result	2012-01-06 10:00:53 +0000
+++ b/mysql-test/suite/perfschema/r/dml_handler.result	2012-02-28 14:40:36 +0000
@@ -9,111 +9,114 @@ SELECT COUNT(*) FROM table_list INTO @ta
 # For each table in the performance schema, attempt HANDLER...OPEN,
 # which should fail with an error 1031, ER_ILLEGAL_HA.
 
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=49;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=50;
 HANDLER performance_schema.users OPEN;
 ERROR HY000: Table storage engine for 'users' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=48;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=49;
 HANDLER performance_schema.threads OPEN;
 ERROR HY000: Table storage engine for 'threads' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=47;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=48;
 HANDLER performance_schema.table_lock_waits_summary_by_table OPEN;
 ERROR HY000: Table storage engine for 'table_lock_waits_summary_by_table' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=46;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=47;
 HANDLER performance_schema.table_io_waits_summary_by_table OPEN;
 ERROR HY000: Table storage engine for 'table_io_waits_summary_by_table' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=45;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=46;
 HANDLER performance_schema.table_io_waits_summary_by_index_usage OPEN;
 ERROR HY000: Table storage engine for 'table_io_waits_summary_by_index_usage' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=44;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=45;
 HANDLER performance_schema.socket_summary_by_instance OPEN;
 ERROR HY000: Table storage engine for 'socket_summary_by_instance' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=43;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=44;
 HANDLER performance_schema.socket_summary_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'socket_summary_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=42;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=43;
 HANDLER performance_schema.socket_instances OPEN;
 ERROR HY000: Table storage engine for 'socket_instances' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=41;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=42;
 HANDLER performance_schema.setup_timers OPEN;
 ERROR HY000: Table storage engine for 'setup_timers' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=40;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=41;
 HANDLER performance_schema.setup_objects OPEN;
 ERROR HY000: Table storage engine for 'setup_objects' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=39;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=40;
 HANDLER performance_schema.setup_instruments OPEN;
 ERROR HY000: Table storage engine for 'setup_instruments' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=38;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=39;
 HANDLER performance_schema.setup_consumers OPEN;
 ERROR HY000: Table storage engine for 'setup_consumers' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=37;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=38;
 HANDLER performance_schema.setup_actors OPEN;
 ERROR HY000: Table storage engine for 'setup_actors' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=36;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=37;
 HANDLER performance_schema.rwlock_instances OPEN;
 ERROR HY000: Table storage engine for 'rwlock_instances' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=35;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=36;
 HANDLER performance_schema.performance_timers OPEN;
 ERROR HY000: Table storage engine for 'performance_timers' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=34;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=35;
 HANDLER performance_schema.objects_summary_global_by_type OPEN;
 ERROR HY000: Table storage engine for 'objects_summary_global_by_type' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=33;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=34;
 HANDLER performance_schema.mutex_instances OPEN;
 ERROR HY000: Table storage engine for 'mutex_instances' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=32;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=33;
 HANDLER performance_schema.hosts OPEN;
 ERROR HY000: Table storage engine for 'hosts' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=31;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=32;
 HANDLER performance_schema.host_cache OPEN;
 ERROR HY000: Table storage engine for 'host_cache' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=30;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=31;
 HANDLER performance_schema.file_summary_by_instance OPEN;
 ERROR HY000: Table storage engine for 'file_summary_by_instance' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=29;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=30;
 HANDLER performance_schema.file_summary_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'file_summary_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=28;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=29;
 HANDLER performance_schema.file_instances OPEN;
 ERROR HY000: Table storage engine for 'file_instances' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=27;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=28;
 HANDLER performance_schema.events_waits_summary_global_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_waits_summary_global_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=26;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=27;
 HANDLER performance_schema.events_waits_summary_by_user_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_waits_summary_by_user_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=25;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=26;
 HANDLER performance_schema.events_waits_summary_by_thread_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_waits_summary_by_thread_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=24;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=25;
 HANDLER performance_schema.events_waits_summary_by_instance OPEN;
 ERROR HY000: Table storage engine for 'events_waits_summary_by_instance' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=23;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=24;
 HANDLER performance_schema.events_waits_summary_by_host_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_waits_summary_by_host_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=22;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=23;
 HANDLER performance_schema.events_waits_summary_by_account_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_waits_summary_by_account_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=21;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=22;
 HANDLER performance_schema.events_waits_history_long OPEN;
 ERROR HY000: Table storage engine for 'events_waits_history_long' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=20;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=21;
 HANDLER performance_schema.events_waits_history OPEN;
 ERROR HY000: Table storage engine for 'events_waits_history' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=19;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=20;
 HANDLER performance_schema.events_waits_current OPEN;
 ERROR HY000: Table storage engine for 'events_waits_current' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=18;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=19;
 HANDLER performance_schema.events_statements_summary_global_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_statements_summary_global_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=17;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=18;
 HANDLER performance_schema.events_statements_summary_by_user_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_statements_summary_by_user_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=16;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=17;
 HANDLER performance_schema.events_statements_summary_by_thread_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_statements_summary_by_thread_by_event_name' doesn't have this option
-SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=15;
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=16;
 HANDLER performance_schema.events_statements_summary_by_host_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_statements_summary_by_host_by_event_name' doesn't have this option
+SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=15;
+HANDLER performance_schema.events_statements_summary_by_digest OPEN;
+ERROR HY000: Table storage engine for 'events_statements_summary_by_digest' doesn't have this option
 SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=14;
 HANDLER performance_schema.events_statements_summary_by_account_by_event_name OPEN;
 ERROR HY000: Table storage engine for 'events_statements_summary_by_account_by_event_name' doesn't have this option

=== modified file 'mysql-test/suite/perfschema/r/dml_setup_consumers.result'
--- a/mysql-test/suite/perfschema/r/dml_setup_consumers.result	2011-02-14 14:23:55 +0000
+++ b/mysql-test/suite/perfschema/r/dml_setup_consumers.result	2011-12-20 12:47:29 +0000
@@ -11,6 +11,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 select * from performance_schema.setup_consumers
 where name='events_waits_current';
 NAME	ENABLED
@@ -29,6 +30,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 select * from performance_schema.setup_consumers
 where enabled='NO';
 NAME	ENABLED

=== modified file 'mysql-test/suite/perfschema/r/indexed_table_io.result'
--- a/mysql-test/suite/perfschema/r/indexed_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/indexed_table_io.result	2012-02-28 15:57:52 +0000
@@ -129,6 +129,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/information_schema.result'
--- a/mysql-test/suite/perfschema/r/information_schema.result	2012-01-02 10:37:56 +0000
+++ b/mysql-test/suite/perfschema/r/information_schema.result	2012-02-28 14:40:36 +0000
@@ -16,6 +16,7 @@ performance_schema	events_statements_cur
 performance_schema	events_statements_history	def
 performance_schema	events_statements_history_long	def
 performance_schema	events_statements_summary_by_account_by_event_name	def
+performance_schema	events_statements_summary_by_digest	def
 performance_schema	events_statements_summary_by_host_by_event_name	def
 performance_schema	events_statements_summary_by_thread_by_event_name	def
 performance_schema	events_statements_summary_by_user_by_event_name	def
@@ -69,6 +70,7 @@ events_statements_current	BASE TABLE	PER
 events_statements_history	BASE TABLE	PERFORMANCE_SCHEMA
 events_statements_history_long	BASE TABLE	PERFORMANCE_SCHEMA
 events_statements_summary_by_account_by_event_name	BASE TABLE	PERFORMANCE_SCHEMA
+events_statements_summary_by_digest	BASE TABLE	PERFORMANCE_SCHEMA
 events_statements_summary_by_host_by_event_name	BASE TABLE	PERFORMANCE_SCHEMA
 events_statements_summary_by_thread_by_event_name	BASE TABLE	PERFORMANCE_SCHEMA
 events_statements_summary_by_user_by_event_name	BASE TABLE	PERFORMANCE_SCHEMA
@@ -122,6 +124,7 @@ events_statements_current	10	Dynamic
 events_statements_history	10	Dynamic
 events_statements_history_long	10	Dynamic
 events_statements_summary_by_account_by_event_name	10	Dynamic
+events_statements_summary_by_digest	10	Dynamic
 events_statements_summary_by_host_by_event_name	10	Dynamic
 events_statements_summary_by_thread_by_event_name	10	Dynamic
 events_statements_summary_by_user_by_event_name	10	Dynamic
@@ -175,6 +178,7 @@ events_statements_current	1000	0
 events_statements_history	1000	0
 events_statements_history_long	10000	0
 events_statements_summary_by_account_by_event_name	1000	0
+events_statements_summary_by_digest	1000	0
 events_statements_summary_by_host_by_event_name	1000	0
 events_statements_summary_by_thread_by_event_name	1000	0
 events_statements_summary_by_user_by_event_name	1000	0
@@ -198,7 +202,7 @@ objects_summary_global_by_type	1000	0
 performance_timers	5	0
 rwlock_instances	1000	0
 setup_actors	1	0
-setup_consumers	11	0
+setup_consumers	12	0
 setup_instruments	1000	0
 setup_objects	4	0
 setup_timers	4	0
@@ -228,6 +232,7 @@ events_statements_current	0	0
 events_statements_history	0	0
 events_statements_history_long	0	0
 events_statements_summary_by_account_by_event_name	0	0
+events_statements_summary_by_digest	0	0
 events_statements_summary_by_host_by_event_name	0	0
 events_statements_summary_by_thread_by_event_name	0	0
 events_statements_summary_by_user_by_event_name	0	0
@@ -281,6 +286,7 @@ events_statements_current	0	0	NULL
 events_statements_history	0	0	NULL
 events_statements_history_long	0	0	NULL
 events_statements_summary_by_account_by_event_name	0	0	NULL
+events_statements_summary_by_digest	0	0	NULL
 events_statements_summary_by_host_by_event_name	0	0	NULL
 events_statements_summary_by_thread_by_event_name	0	0	NULL
 events_statements_summary_by_user_by_event_name	0	0	NULL
@@ -334,6 +340,7 @@ events_statements_current	NULL	NULL	NULL
 events_statements_history	NULL	NULL	NULL
 events_statements_history_long	NULL	NULL	NULL
 events_statements_summary_by_account_by_event_name	NULL	NULL	NULL
+events_statements_summary_by_digest	NULL	NULL	NULL
 events_statements_summary_by_host_by_event_name	NULL	NULL	NULL
 events_statements_summary_by_thread_by_event_name	NULL	NULL	NULL
 events_statements_summary_by_user_by_event_name	NULL	NULL	NULL
@@ -387,6 +394,7 @@ events_statements_current	utf8_general_c
 events_statements_history	utf8_general_ci	NULL
 events_statements_history_long	utf8_general_ci	NULL
 events_statements_summary_by_account_by_event_name	utf8_general_ci	NULL
+events_statements_summary_by_digest	utf8_general_ci	NULL
 events_statements_summary_by_host_by_event_name	utf8_general_ci	NULL
 events_statements_summary_by_thread_by_event_name	utf8_general_ci	NULL
 events_statements_summary_by_user_by_event_name	utf8_general_ci	NULL
@@ -440,6 +448,7 @@ events_statements_current
 events_statements_history	
 events_statements_history_long	
 events_statements_summary_by_account_by_event_name	
+events_statements_summary_by_digest	
 events_statements_summary_by_host_by_event_name	
 events_statements_summary_by_thread_by_event_name	
 events_statements_summary_by_user_by_event_name	

=== modified file 'mysql-test/suite/perfschema/r/innodb_table_io.result'
--- a/mysql-test/suite/perfschema/r/innodb_table_io.result	2012-01-04 18:29:43 +0000
+++ b/mysql-test/suite/perfschema/r/innodb_table_io.result	2012-02-28 15:57:52 +0000
@@ -120,6 +120,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/memory_table_io.result'
--- a/mysql-test/suite/perfschema/r/memory_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/memory_table_io.result	2012-02-28 15:57:52 +0000
@@ -118,6 +118,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/merge_table_io.result'
--- a/mysql-test/suite/perfschema/r/merge_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/merge_table_io.result	2012-02-28 15:57:52 +0000
@@ -148,6 +148,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/multi_table_io.result'
--- a/mysql-test/suite/perfschema/r/multi_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/multi_table_io.result	2012-02-28 15:57:52 +0000
@@ -77,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/myisam_file_io.result'
--- a/mysql-test/suite/perfschema/r/myisam_file_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/myisam_file_io.result	2012-02-28 15:57:52 +0000
@@ -46,6 +46,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/myisam_table_io.result'
--- a/mysql-test/suite/perfschema/r/myisam_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/myisam_table_io.result	2012-02-28 15:57:52 +0000
@@ -116,6 +116,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/nesting.result'
--- a/mysql-test/suite/perfschema/r/nesting.result	2011-11-28 11:16:00 +0000
+++ b/mysql-test/suite/perfschema/r/nesting.result	2012-02-28 15:57:52 +0000
@@ -45,6 +45,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/ortho_iter.result'
--- a/mysql-test/suite/perfschema/r/ortho_iter.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/ortho_iter.result	2012-02-28 15:57:52 +0000
@@ -95,6 +95,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -127,6 +128,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/part_table_io.result'
--- a/mysql-test/suite/perfschema/r/part_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/part_table_io.result	2012-02-28 15:57:52 +0000
@@ -148,6 +148,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade.result	2012-02-07 14:35:13 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade.result	2012-02-28 14:40:36 +0000
@@ -48,18 +48,19 @@ ERROR 1050 (42S01) at line 779: Table 'e
 ERROR 1050 (42S01) at line 792: Table 'events_stages_summary_by_user_by_event_name' already exists
 ERROR 1050 (42S01) at line 806: Table 'events_stages_summary_by_account_by_event_name' already exists
 ERROR 1050 (42S01) at line 818: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 906: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 950: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 982: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 1014: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 1046: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 1079: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 1110: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 1128: Table 'users' already exists
-ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1558: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 864: Table 'events_statements_current' already exists
+ERROR 1050 (42S01) at line 910: Table 'events_statements_history' already exists
+ERROR 1050 (42S01) at line 956: Table 'events_statements_history_long' already exists
+ERROR 1050 (42S01) at line 988: Table 'events_statements_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 1020: Table 'events_statements_summary_by_host_by_event_name' already exists
+ERROR 1050 (42S01) at line 1052: Table 'events_statements_summary_by_user_by_event_name' already exists
+ERROR 1050 (42S01) at line 1085: Table 'events_statements_summary_by_account_by_event_name' already exists
+ERROR 1050 (42S01) at line 1116: Table 'events_statements_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 1125: Table 'hosts' already exists
+ERROR 1050 (42S01) at line 1134: Table 'users' already exists
+ERROR 1050 (42S01) at line 1144: Table 'accounts' already exists
+ERROR 1050 (42S01) at line 1178: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1598: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -112,18 +113,19 @@ ERROR 1050 (42S01) at line 779: Table 'e
 ERROR 1050 (42S01) at line 792: Table 'events_stages_summary_by_user_by_event_name' already exists
 ERROR 1050 (42S01) at line 806: Table 'events_stages_summary_by_account_by_event_name' already exists
 ERROR 1050 (42S01) at line 818: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 906: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 950: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 982: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 1014: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 1046: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 1079: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 1110: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 1128: Table 'users' already exists
-ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1558: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 864: Table 'events_statements_current' already exists
+ERROR 1050 (42S01) at line 910: Table 'events_statements_history' already exists
+ERROR 1050 (42S01) at line 956: Table 'events_statements_history_long' already exists
+ERROR 1050 (42S01) at line 988: Table 'events_statements_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 1020: Table 'events_statements_summary_by_host_by_event_name' already exists
+ERROR 1050 (42S01) at line 1052: Table 'events_statements_summary_by_user_by_event_name' already exists
+ERROR 1050 (42S01) at line 1085: Table 'events_statements_summary_by_account_by_event_name' already exists
+ERROR 1050 (42S01) at line 1116: Table 'events_statements_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 1125: Table 'hosts' already exists
+ERROR 1050 (42S01) at line 1134: Table 'users' already exists
+ERROR 1050 (42S01) at line 1144: Table 'accounts' already exists
+ERROR 1050 (42S01) at line 1178: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1598: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -174,18 +176,19 @@ ERROR 1050 (42S01) at line 779: Table 'e
 ERROR 1050 (42S01) at line 792: Table 'events_stages_summary_by_user_by_event_name' already exists
 ERROR 1050 (42S01) at line 806: Table 'events_stages_summary_by_account_by_event_name' already exists
 ERROR 1050 (42S01) at line 818: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 906: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 950: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 982: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 1014: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 1046: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 1079: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 1110: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 1128: Table 'users' already exists
-ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1558: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 864: Table 'events_statements_current' already exists
+ERROR 1050 (42S01) at line 910: Table 'events_statements_history' already exists
+ERROR 1050 (42S01) at line 956: Table 'events_statements_history_long' already exists
+ERROR 1050 (42S01) at line 988: Table 'events_statements_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 1020: Table 'events_statements_summary_by_host_by_event_name' already exists
+ERROR 1050 (42S01) at line 1052: Table 'events_statements_summary_by_user_by_event_name' already exists
+ERROR 1050 (42S01) at line 1085: Table 'events_statements_summary_by_account_by_event_name' already exists
+ERROR 1050 (42S01) at line 1116: Table 'events_statements_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 1125: Table 'hosts' already exists
+ERROR 1050 (42S01) at line 1134: Table 'users' already exists
+ERROR 1050 (42S01) at line 1144: Table 'accounts' already exists
+ERROR 1050 (42S01) at line 1178: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1598: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -236,18 +239,19 @@ ERROR 1050 (42S01) at line 779: Table 'e
 ERROR 1050 (42S01) at line 792: Table 'events_stages_summary_by_user_by_event_name' already exists
 ERROR 1050 (42S01) at line 806: Table 'events_stages_summary_by_account_by_event_name' already exists
 ERROR 1050 (42S01) at line 818: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 906: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 950: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 982: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 1014: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 1046: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 1079: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 1110: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 1128: Table 'users' already exists
-ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1558: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 864: Table 'events_statements_current' already exists
+ERROR 1050 (42S01) at line 910: Table 'events_statements_history' already exists
+ERROR 1050 (42S01) at line 956: Table 'events_statements_history_long' already exists
+ERROR 1050 (42S01) at line 988: Table 'events_statements_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 1020: Table 'events_statements_summary_by_host_by_event_name' already exists
+ERROR 1050 (42S01) at line 1052: Table 'events_statements_summary_by_user_by_event_name' already exists
+ERROR 1050 (42S01) at line 1085: Table 'events_statements_summary_by_account_by_event_name' already exists
+ERROR 1050 (42S01) at line 1116: Table 'events_statements_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 1125: Table 'hosts' already exists
+ERROR 1050 (42S01) at line 1134: Table 'users' already exists
+ERROR 1050 (42S01) at line 1144: Table 'accounts' already exists
+ERROR 1050 (42S01) at line 1178: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1598: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -298,18 +302,19 @@ ERROR 1050 (42S01) at line 779: Table 'e
 ERROR 1050 (42S01) at line 792: Table 'events_stages_summary_by_user_by_event_name' already exists
 ERROR 1050 (42S01) at line 806: Table 'events_stages_summary_by_account_by_event_name' already exists
 ERROR 1050 (42S01) at line 818: Table 'events_stages_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 862: Table 'events_statements_current' already exists
-ERROR 1050 (42S01) at line 906: Table 'events_statements_history' already exists
-ERROR 1050 (42S01) at line 950: Table 'events_statements_history_long' already exists
-ERROR 1050 (42S01) at line 982: Table 'events_statements_summary_by_thread_by_event_name' already exists
-ERROR 1050 (42S01) at line 1014: Table 'events_statements_summary_by_host_by_event_name' already exists
-ERROR 1050 (42S01) at line 1046: Table 'events_statements_summary_by_user_by_event_name' already exists
-ERROR 1050 (42S01) at line 1079: Table 'events_statements_summary_by_account_by_event_name' already exists
-ERROR 1050 (42S01) at line 1110: Table 'events_statements_summary_global_by_event_name' already exists
-ERROR 1050 (42S01) at line 1119: Table 'hosts' already exists
-ERROR 1050 (42S01) at line 1128: Table 'users' already exists
-ERROR 1050 (42S01) at line 1138: Table 'accounts' already exists
-ERROR 1644 (HY000) at line 1558: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 864: Table 'events_statements_current' already exists
+ERROR 1050 (42S01) at line 910: Table 'events_statements_history' already exists
+ERROR 1050 (42S01) at line 956: Table 'events_statements_history_long' already exists
+ERROR 1050 (42S01) at line 988: Table 'events_statements_summary_by_thread_by_event_name' already exists
+ERROR 1050 (42S01) at line 1020: Table 'events_statements_summary_by_host_by_event_name' already exists
+ERROR 1050 (42S01) at line 1052: Table 'events_statements_summary_by_user_by_event_name' already exists
+ERROR 1050 (42S01) at line 1085: Table 'events_statements_summary_by_account_by_event_name' already exists
+ERROR 1050 (42S01) at line 1116: Table 'events_statements_summary_global_by_event_name' already exists
+ERROR 1050 (42S01) at line 1125: Table 'hosts' already exists
+ERROR 1050 (42S01) at line 1134: Table 'users' already exists
+ERROR 1050 (42S01) at line 1144: Table 'accounts' already exists
+ERROR 1050 (42S01) at line 1178: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1598: 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/privilege_table_io.result'
--- a/mysql-test/suite/perfschema/r/privilege_table_io.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/privilege_table_io.result	2012-02-28 15:57:52 +0000
@@ -20,6 +20,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -52,6 +53,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -105,6 +107,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/rollback_table_io.result'
--- a/mysql-test/suite/perfschema/r/rollback_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/rollback_table_io.result	2012-02-28 15:57:52 +0000
@@ -58,6 +58,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/schema.result'
--- a/mysql-test/suite/perfschema/r/schema.result	2012-02-14 09:42:07 +0000
+++ b/mysql-test/suite/perfschema/r/schema.result	2012-02-28 14:40:36 +0000
@@ -21,6 +21,7 @@ events_statements_current
 events_statements_history
 events_statements_history_long
 events_statements_summary_by_account_by_event_name
+events_statements_summary_by_digest
 events_statements_summary_by_host_by_event_name
 events_statements_summary_by_thread_by_event_name
 events_statements_summary_by_user_by_event_name
@@ -180,6 +181,8 @@ events_statements_current	CREATE TABLE `
   `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
   `LOCK_TIME` bigint(20) unsigned NOT NULL,
   `SQL_TEXT` longtext,
+  `DIGEST` varchar(32) DEFAULT NULL,
+  `DIGEST_TEXT` longtext,
   `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
@@ -222,6 +225,8 @@ events_statements_history	CREATE TABLE `
   `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
   `LOCK_TIME` bigint(20) unsigned NOT NULL,
   `SQL_TEXT` longtext,
+  `DIGEST` varchar(32) DEFAULT NULL,
+  `DIGEST_TEXT` longtext,
   `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
@@ -264,6 +269,8 @@ events_statements_history_long	CREATE TA
   `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
   `LOCK_TIME` bigint(20) unsigned NOT NULL,
   `SQL_TEXT` longtext,
+  `DIGEST` varchar(32) DEFAULT NULL,
+  `DIGEST_TEXT` longtext,
   `CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
   `OBJECT_TYPE` varchar(64) DEFAULT NULL,
   `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,

=== modified file 'mysql-test/suite/perfschema/r/setup_consumers_defaults.result'
--- a/mysql-test/suite/perfschema/r/setup_consumers_defaults.result	2011-11-21 21:02:04 +0000
+++ b/mysql-test/suite/perfschema/r/setup_consumers_defaults.result	2011-12-20 12:47:29 +0000
@@ -10,6 +10,7 @@ events_waits_current	NO
 events_waits_history	YES
 events_waits_history_long	NO
 global_instrumentation	YES
+statements_digest	YES
 thread_instrumentation	YES
 SELECT @@performance_schema_consumer_events_stages_current;
 ERROR HY000: Unknown system variable 'performance_schema_consumer_events_stages_current'

=== modified file 'mysql-test/suite/perfschema/r/start_server_disable_idle.result'
--- a/mysql-test/suite/perfschema/r/start_server_disable_idle.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_disable_idle.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_disable_stages.result'
--- a/mysql-test/suite/perfschema/r/start_server_disable_stages.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_disable_stages.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_disable_statements.result'
--- a/mysql-test/suite/perfschema/r/start_server_disable_statements.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_disable_statements.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_disable_waits.result'
--- a/mysql-test/suite/perfschema/r/start_server_disable_waits.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_disable_waits.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_innodb.result'
--- a/mysql-test/suite/perfschema/r/start_server_innodb.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_innodb.result	2012-02-28 15:57:52 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -104,6 +105,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_account.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_account.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_account.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	0
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== added file 'mysql-test/suite/perfschema/r/start_server_no_digests.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_digests.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_digests.result	2012-02-20 13:32:56 +0000
@@ -0,0 +1,92 @@
+####################################
+# SETUP
+####################################
+CREATE DATABASE statements_digest;
+USE statements_digest;
+CREATE TABLE t1(a int);
+CREATE TABLE t2(a int);
+CREATE TABLE t3(a int, b int);
+CREATE TABLE t4(a int, b int);
+CREATE TABLE t5(a int, b int, c int);
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+####################################
+# EXECUTION
+####################################
+SELECT 1 FROM t1;
+1
+SELECT 1 FROM `t1`;
+1
+SELECT 1,2 FROM t1;
+1	2
+SELECT 1, 2, 3, 4 FROM t1;
+1	2	3	4
+SELECT 1 FROM t2;
+1
+SELECT 1,2 FROM t2;
+1	2
+SELECT 1, 2, 3, 4 FROM t2;
+1	2	3	4
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t3 VALUES (1, 2);
+INSERT INTO t4 VALUES (1, 2);
+INSERT INTO t5 VALUES (1, 2, 3);
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (1), (2), (3), (4);
+INSERT INTO t3 VALUES (1, 2), (3, 4), (5, 6);
+INSERT INTO t5 VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
+SELECT                                          1           +        1;
+1           +        1
+2
+SELECT 1;
+1
+1
+SELECT 1 /* This is an inline comment */ + 1;
+1 /* This is an inline comment */ + 1
+2
+SELECT 1+
+/*
+this is a
+multiple-line comment
+*/
+1;
+1+
+/*
+this is a
+multiple-line comment
+*/
+1
+2
+CREATE SCHEMA statements_digest_temp;
+DROP SCHEMA statements_digest_temp;
+CREATE DATABASE statements_digest_temp;
+DROP DATABASE statements_digest_temp;
+SELECT 1 from t11;
+ERROR 42S02: Table 'statements_digest.t11' doesn't exist
+create table t11 (c char(4));
+create table t11 (c char(4));
+ERROR 42S01: Table 't11' already exists
+insert into t11 values("MySQL");
+Warnings:
+Warning	1265	Data truncated for column 'c' at row 1
+####################################
+# QUERYING PS STATEMENT DIGEST
+####################################
+SELECT DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+DIGEST	DIGEST_TEXT	COUNT_STAR	SUM_ROWS_AFFECTED	SUM_WARNINGS	SUM_ERRORS
+SHOW VARIABLES LIKE "performance_schema_digests_size";
+Variable_name	Value
+performance_schema_digests_size	0
+SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_digest;
+COUNT(*)
+0
+####################################
+# CLEANUP
+####################################
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP DATABASE IF EXISTS statements_digest;

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_host.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_host.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_host.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_socket_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_socket_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_stage_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_stage_class.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_stage_class.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_stages_history.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	0
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	0
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_statement_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_statement_class.result	2012-01-02 10:37:56 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_statement_class.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_statements_history.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	0

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== 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	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_user.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_user.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_user.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_waits_history.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_waits_history.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000

=== modified file 'mysql-test/suite/perfschema/r/start_server_nothing.result'
--- a/mysql-test/suite/perfschema/r/start_server_nothing.result	2012-01-02 10:37:56 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_nothing.result	2012-02-28 14:40:36 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 0
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	0
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	0
 performance_schema_events_stages_history_size	0
 performance_schema_events_statements_history_long_size	0
@@ -103,6 +104,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	0
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	0
 performance_schema_events_stages_history_size	0
 performance_schema_events_statements_history_long_size	0
@@ -155,6 +157,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 select * from performance_schema.setup_timers;
 NAME	TIMER_NAME
 idle	MICROSECOND
@@ -182,11 +185,11 @@ USER	EVENT_NAME	COUNT_STAR	SUM_TIMER_WAI
 select * from performance_schema.events_stages_summary_global_by_event_name;
 EVENT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
 select * from performance_schema.events_statements_current;
-THREAD_ID	EVENT_ID	END_EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	LOCK_TIME	SQL_TEXT	CURRENT_SCHEMA	OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_INSTANCE_BEGIN	MYSQL_ERRNO	RETURNED_SQLSTATE	MESSAGE_TEXT	ERRORS	WARNINGS	ROWS_AFFECTED	ROWS_SENT	ROWS_EXAMINED	CREATED_TMP_DISK_TABLES	CREATED_TMP_TABLES	SELECT_FULL_JOIN	SELECT_FULL_RANGE_JOIN	SELECT_RANGE	SELECT_RANGE_CHECK	SELECT_SCAN	SORT_MERGE_PASSES	SORT_RANGE	SORT_ROWS	SORT_SCAN	NO_INDEX_USED	NO_GOOD_INDEX_USED	NESTING_EVENT_ID	NESTING_EVENT_TYPE
+THREAD_ID	EVENT_ID	END_EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	LOCK_TIME	SQL_TEXT	DIGEST	DIGEST_TEXT	CURRENT_SCHEMA	OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_INSTANCE_BEGIN	MYSQL_ERRNO	RETURNED_SQLSTATE	MESSAGE_TEXT	ERRORS	WARNINGS	ROWS_AFFECTED	ROWS_SENT	ROWS_EXAMINED	CREATED_TMP_DISK_TABLES	CREATED_TMP_TABLES	SELECT_FULL_JOIN	SELECT_FULL_RANGE_JOIN	SELECT_RANGE	SELECT_RANGE_CHECK	SELECT_SCAN	SORT_MERGE_PASSES	SORT_RANGE	SORT_ROWS	SORT_SCAN	NO_INDEX_USED	NO_GOOD_INDEX_USED	NESTING_EVENT_ID	NESTING_EVENT_TYPE
 select * from performance_schema.events_statements_history;
-THREAD_ID	EVENT_ID	END_EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	LOCK_TIME	SQL_TEXT	CURRENT_SCHEMA	OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_INSTANCE_BEGIN	MYSQL_ERRNO	RETURNED_SQLSTATE	MESSAGE_TEXT	ERRORS	WARNINGS	ROWS_AFFECTED	ROWS_SENT	ROWS_EXAMINED	CREATED_TMP_DISK_TABLES	CREATED_TMP_TABLES	SELECT_FULL_JOIN	SELECT_FULL_RANGE_JOIN	SELECT_RANGE	SELECT_RANGE_CHECK	SELECT_SCAN	SORT_MERGE_PASSES	SORT_RANGE	SORT_ROWS	SORT_SCAN	NO_INDEX_USED	NO_GOOD_INDEX_USED	NESTING_EVENT_ID	NESTING_EVENT_TYPE
+THREAD_ID	EVENT_ID	END_EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	LOCK_TIME	SQL_TEXT	DIGEST	DIGEST_TEXT	CURRENT_SCHEMA	OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_INSTANCE_BEGIN	MYSQL_ERRNO	RETURNED_SQLSTATE	MESSAGE_TEXT	ERRORS	WARNINGS	ROWS_AFFECTED	ROWS_SENT	ROWS_EXAMINED	CREATED_TMP_DISK_TABLES	CREATED_TMP_TABLES	SELECT_FULL_JOIN	SELECT_FULL_RANGE_JOIN	SELECT_RANGE	SELECT_RANGE_CHECK	SELECT_SCAN	SORT_MERGE_PASSES	SORT_RANGE	SORT_ROWS	SORT_SCAN	NO_INDEX_USED	NO_GOOD_INDEX_USED	NESTING_EVENT_ID	NESTING_EVENT_TYPE
 select * from performance_schema.events_statements_history_long;
-THREAD_ID	EVENT_ID	END_EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	LOCK_TIME	SQL_TEXT	CURRENT_SCHEMA	OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_INSTANCE_BEGIN	MYSQL_ERRNO	RETURNED_SQLSTATE	MESSAGE_TEXT	ERRORS	WARNINGS	ROWS_AFFECTED	ROWS_SENT	ROWS_EXAMINED	CREATED_TMP_DISK_TABLES	CREATED_TMP_TABLES	SELECT_FULL_JOIN	SELECT_FULL_RANGE_JOIN	SELECT_RANGE	SELECT_RANGE_CHECK	SELECT_SCAN	SORT_MERGE_PASSES	SORT_RANGE	SORT_ROWS	SORT_SCAN	NO_INDEX_USED	NO_GOOD_INDEX_USED	NESTING_EVENT_ID	NESTING_EVENT_TYPE
+THREAD_ID	EVENT_ID	END_EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	LOCK_TIME	SQL_TEXT	DIGEST	DIGEST_TEXT	CURRENT_SCHEMA	OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_INSTANCE_BEGIN	MYSQL_ERRNO	RETURNED_SQLSTATE	MESSAGE_TEXT	ERRORS	WARNINGS	ROWS_AFFECTED	ROWS_SENT	ROWS_EXAMINED	CREATED_TMP_DISK_TABLES	CREATED_TMP_TABLES	SELECT_FULL_JOIN	SELECT_FULL_RANGE_JOIN	SELECT_RANGE	SELECT_RANGE_CHECK	SELECT_SCAN	SORT_MERGE_PASSES	SORT_RANGE	SORT_ROWS	SORT_SCAN	NO_INDEX_USED	NO_GOOD_INDEX_USED	NESTING_EVENT_ID	NESTING_EVENT_TYPE
 select * from performance_schema.events_statements_summary_by_account_by_event_name;
 USER	HOST	EVENT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT	SUM_LOCK_TIME	SUM_ERRORS	SUM_WARNINGS	SUM_ROWS_AFFECTED	SUM_ROWS_SENT	SUM_ROWS_EXAMINED	SUM_CREATED_TMP_DISK_TABLES	SUM_CREATED_TMP_TABLES	SUM_SELECT_FULL_JOIN	SUM_SELECT_FULL_RANGE_JOIN	SUM_SELECT_RANGE	SUM_SELECT_RANGE_CHECK	SUM_SELECT_SCAN	SUM_SORT_MERGE_PASSES	SUM_SORT_RANGE	SUM_SORT_ROWS	SUM_SORT_SCAN	SUM_NO_INDEX_USED	SUM_NO_GOOD_INDEX_USED
 select * from performance_schema.events_statements_summary_by_host_by_event_name;

=== modified file 'mysql-test/suite/perfschema/r/start_server_off.result'
--- a/mysql-test/suite/perfschema/r/start_server_off.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_off.result	2012-02-28 15:57:52 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 0
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	OFF
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -104,6 +105,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -135,6 +137,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	NO
 thread_instrumentation	NO
+statements_digest	YES
 select * from performance_schema.setup_instruments;
 NAME	ENABLED	TIMED
 select * from performance_schema.setup_actors;

=== modified file 'mysql-test/suite/perfschema/r/start_server_on.result'
--- a/mysql-test/suite/perfschema/r/start_server_on.result	2012-02-28 11:07:43 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_on.result	2012-02-28 15:57:52 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-11
+12
 select count(*) > 3 from performance_schema.setup_instruments;
 count(*) > 3
 1
@@ -70,6 +70,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -104,6 +105,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== added file 'mysql-test/suite/perfschema/r/statement_digest.result'
--- a/mysql-test/suite/perfschema/r/statement_digest.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest.result	2012-02-29 13:26:31 +0000
@@ -0,0 +1,108 @@
+####################################
+# SETUP
+####################################
+CREATE DATABASE statements_digest;
+USE statements_digest;
+CREATE TABLE t1(a int);
+CREATE TABLE t2(a int);
+CREATE TABLE t3(a int, b int);
+CREATE TABLE t4(a int, b int);
+CREATE TABLE t5(a int, b int, c int);
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+####################################
+# EXECUTION
+####################################
+SELECT 1 FROM t1;
+1
+SELECT 1 FROM `t1`;
+1
+SELECT 1,2 FROM t1;
+1	2
+SELECT 1, 2, 3, 4 FROM t1;
+1	2	3	4
+SELECT 1 FROM t2;
+1
+SELECT 1,2 FROM t2;
+1	2
+SELECT 1, 2, 3, 4 FROM t2;
+1	2	3	4
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t3 VALUES (1, 2);
+INSERT INTO t4 VALUES (1, 2);
+INSERT INTO t5 VALUES (1, 2, 3);
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (1), (2), (3), (4);
+INSERT INTO t3 VALUES (1, 2), (3, 4), (5, 6);
+INSERT INTO t5 VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
+SELECT                                          1           +        1;
+1           +        1
+2
+SELECT 1;
+1
+1
+SELECT 1 /* This is an inline comment */ + 1;
+1 /* This is an inline comment */ + 1
+2
+SELECT 1+
+/*
+this is a
+multiple-line comment
+*/
+1;
+1+
+/*
+this is a
+multiple-line comment
+*/
+1
+2
+CREATE SCHEMA statements_digest_temp;
+DROP SCHEMA statements_digest_temp;
+CREATE DATABASE statements_digest_temp;
+DROP DATABASE statements_digest_temp;
+SELECT 1 from t11;
+ERROR 42S02: Table 'statements_digest.t11' doesn't exist
+create table t11 (c char(4));
+create table t11 (c char(4));
+ERROR 42S01: Table 't11' already exists
+insert into t11 values("MySQL");
+Warnings:
+Warning	1265	Data truncated for column 'c' at row 1
+####################################
+# QUERYING PS STATEMENT DIGEST
+####################################
+SELECT DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+DIGEST	DIGEST_TEXT	COUNT_STAR	SUM_ROWS_AFFECTED	SUM_WARNINGS	SUM_ERRORS
+98b2254389c9138db2aa32e607a5526a	TRUNCATE TABLE performance_schema . events_statements_summary_by_digest  	1	0	0	0
+aeca1dd924c789795998cb2e95060848	SELECT ? FROM t1  	1	0	0	0
+b230ab0cdb9fec1811eb9ad58cab38e5	SELECT ? FROM `t1`  	1	0	0	0
+20a8fd7cf206ac4c0fda3e6caac5aa42	SELECT ?, ... FROM t1  	2	0	0	0
+9a9fc7f2777c3e93dea2cce7fd256801	SELECT ? FROM t2  	1	0	0	0
+922f9d3aed4e59a6109e5ae056d89cca	SELECT ?, ... FROM t2  	2	0	0	0
+5dd78fd7d0329e1c5d29b8ae46a4a7bb	INSERT INTO t1 VALUES (?)  	1	1	0	0
+c82da13e32f68b575c2bfae7ede4daea	INSERT INTO t2 VALUES (?)  	1	1	0	0
+fc4cfb7cbd4c37abc34d2715c4efe645	INSERT INTO t3 VALUES (...)  	1	1	0	0
+d7563bb28b7902b7ac9034e2f8380b8b	INSERT INTO t4 VALUES (...)  	1	1	0	0
+ed0bc38d2e346451f5b4dda63359c83c	INSERT INTO t5 VALUES (...)  	1	1	0	0
+1f140dc2fbef33b8eaf60899cf1160eb	INSERT INTO t1 VALUES (?) /* , ... */  	2	7	0	0
+4d9cde9070e0731563b5eedd1efbf81d	INSERT INTO t3 VALUES (...) /* , ... */  	1	3	0	0
+53fafa986af9c348adba7838d14750dd	INSERT INTO t5 VALUES (...) /* , ... */  	1	3	0	0
+9bb39fc1aec59fb2b873c00cffb62b53	SELECT ? + ?  	3	0	0	0
+32c34d5ee6777725e3c49812d5cd8b35	SELECT ?  	1	0	0	0
+30046d97cfdc44c95bdaa7f3987d0a20	CREATE SCHEMA statements_digest_temp  	2	2	0	0
+8e40e6461f3ab4454ddb8f21b5cda3ba	DROP SCHEMA statements_digest_temp  	2	0	0	0
+f908d67147dc082b58a9b359085bbf81	SELECT ? FROM t11  	1	0	0	1
+3e30262707d8e21f9a109410d315ed77	CREATE TABLE t11 ( c CHARACTER (?) )  	2	0	0	1
+d9a2eb4d437c55eae640ef11377cd804	INSERT INTO t11 VALUES (?)  	1	1	1	0
+8d3e4f4d9073b57378d795487beac66b	SHOW WARNINGS  	1	0	0	0
+####################################
+# CLEANUP
+####################################
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP DATABASE IF EXISTS statements_digest;

=== added file 'mysql-test/suite/perfschema/r/statement_digest_consumers.result'
--- a/mysql-test/suite/perfschema/r/statement_digest_consumers.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers.result	2012-02-29 13:26:31 +0000
@@ -0,0 +1,123 @@
+####################################
+# SETUP
+####################################
+CREATE DATABASE statements_digest;
+USE statements_digest;
+CREATE TABLE t1(a int);
+CREATE TABLE t2(a int);
+CREATE TABLE t3(a int, b int);
+CREATE TABLE t4(a int, b int);
+CREATE TABLE t5(a int, b int, c int);
+SELECT * FROM performance_schema.setup_consumers;
+NAME	ENABLED
+events_stages_current	YES
+events_stages_history	YES
+events_stages_history_long	YES
+events_statements_current	NO
+events_statements_history	YES
+events_statements_history_long	YES
+events_waits_current	YES
+events_waits_history	YES
+events_waits_history_long	YES
+global_instrumentation	YES
+thread_instrumentation	YES
+statements_digest	YES
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+####################################
+# EXECUTION
+####################################
+SELECT 1 FROM t1;
+1
+SELECT 1 FROM `t1`;
+1
+SELECT 1,2 FROM t1;
+1	2
+SELECT 1, 2, 3, 4 FROM t1;
+1	2	3	4
+SELECT 1 FROM t2;
+1
+SELECT 1,2 FROM t2;
+1	2
+SELECT 1, 2, 3, 4 FROM t2;
+1	2	3	4
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t3 VALUES (1, 2);
+INSERT INTO t4 VALUES (1, 2);
+INSERT INTO t5 VALUES (1, 2, 3);
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (1), (2), (3), (4);
+INSERT INTO t3 VALUES (1, 2), (3, 4), (5, 6);
+INSERT INTO t5 VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
+SELECT                                          1           +        1;
+1           +        1
+2
+SELECT 1;
+1
+1
+SELECT 1 /* This is an inline comment */ + 1;
+1 /* This is an inline comment */ + 1
+2
+SELECT 1+
+/*
+this is a
+multiple-line comment
+*/
+1;
+1+
+/*
+this is a
+multiple-line comment
+*/
+1
+2
+CREATE SCHEMA statements_digest_temp;
+DROP SCHEMA statements_digest_temp;
+CREATE DATABASE statements_digest_temp;
+DROP DATABASE statements_digest_temp;
+SELECT 1 from t11;
+ERROR 42S02: Table 'statements_digest.t11' doesn't exist
+create table t11 (c char(4));
+create table t11 (c char(4));
+ERROR 42S01: Table 't11' already exists
+insert into t11 values("MySQL");
+Warnings:
+Warning	1265	Data truncated for column 'c' at row 1
+####################################
+# QUERYING PS STATEMENT DIGEST
+####################################
+SELECT digest, digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
+digest	digest_text	count_star
+98b2254389c9138db2aa32e607a5526a	TRUNCATE TABLE performance_schema . events_statements_summary_by_digest  	1
+aeca1dd924c789795998cb2e95060848	SELECT ? FROM t1  	1
+b230ab0cdb9fec1811eb9ad58cab38e5	SELECT ? FROM `t1`  	1
+20a8fd7cf206ac4c0fda3e6caac5aa42	SELECT ?, ... FROM t1  	2
+9a9fc7f2777c3e93dea2cce7fd256801	SELECT ? FROM t2  	1
+922f9d3aed4e59a6109e5ae056d89cca	SELECT ?, ... FROM t2  	2
+5dd78fd7d0329e1c5d29b8ae46a4a7bb	INSERT INTO t1 VALUES (?)  	1
+c82da13e32f68b575c2bfae7ede4daea	INSERT INTO t2 VALUES (?)  	1
+fc4cfb7cbd4c37abc34d2715c4efe645	INSERT INTO t3 VALUES (...)  	1
+d7563bb28b7902b7ac9034e2f8380b8b	INSERT INTO t4 VALUES (...)  	1
+ed0bc38d2e346451f5b4dda63359c83c	INSERT INTO t5 VALUES (...)  	1
+1f140dc2fbef33b8eaf60899cf1160eb	INSERT INTO t1 VALUES (?) /* , ... */  	2
+4d9cde9070e0731563b5eedd1efbf81d	INSERT INTO t3 VALUES (...) /* , ... */  	1
+53fafa986af9c348adba7838d14750dd	INSERT INTO t5 VALUES (...) /* , ... */  	1
+9bb39fc1aec59fb2b873c00cffb62b53	SELECT ? + ?  	3
+32c34d5ee6777725e3c49812d5cd8b35	SELECT ?  	1
+30046d97cfdc44c95bdaa7f3987d0a20	CREATE SCHEMA statements_digest_temp  	2
+8e40e6461f3ab4454ddb8f21b5cda3ba	DROP SCHEMA statements_digest_temp  	2
+f908d67147dc082b58a9b359085bbf81	SELECT ? FROM t11  	1
+3e30262707d8e21f9a109410d315ed77	CREATE TABLE t11 ( c CHARACTER (?) )  	2
+d9a2eb4d437c55eae640ef11377cd804	INSERT INTO t11 VALUES (?)  	1
+8d3e4f4d9073b57378d795487beac66b	SHOW WARNINGS  	1
+SELECT digest, digest_text FROM performance_schema.events_statements_current;
+digest	digest_text
+####################################
+# CLEANUP
+####################################
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP DATABASE IF EXISTS statements_digest;

=== added file 'mysql-test/suite/perfschema/r/statement_digest_consumers2.result'
--- a/mysql-test/suite/perfschema/r/statement_digest_consumers2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers2.result	2012-02-20 13:32:56 +0000
@@ -0,0 +1,102 @@
+####################################
+# SETUP
+####################################
+CREATE DATABASE statements_digest;
+USE statements_digest;
+CREATE TABLE t1(a int);
+CREATE TABLE t2(a int);
+CREATE TABLE t3(a int, b int);
+CREATE TABLE t4(a int, b int);
+CREATE TABLE t5(a int, b int, c int);
+SELECT * FROM performance_schema.setup_consumers;
+NAME	ENABLED
+events_stages_current	YES
+events_stages_history	YES
+events_stages_history_long	YES
+events_statements_current	YES
+events_statements_history	YES
+events_statements_history_long	YES
+events_waits_current	YES
+events_waits_history	YES
+events_waits_history_long	YES
+global_instrumentation	YES
+thread_instrumentation	YES
+statements_digest	NO
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+####################################
+# EXECUTION
+####################################
+SELECT 1 FROM t1;
+1
+SELECT 1 FROM `t1`;
+1
+SELECT 1,2 FROM t1;
+1	2
+SELECT 1, 2, 3, 4 FROM t1;
+1	2	3	4
+SELECT 1 FROM t2;
+1
+SELECT 1,2 FROM t2;
+1	2
+SELECT 1, 2, 3, 4 FROM t2;
+1	2	3	4
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t3 VALUES (1, 2);
+INSERT INTO t4 VALUES (1, 2);
+INSERT INTO t5 VALUES (1, 2, 3);
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (1), (2), (3), (4);
+INSERT INTO t3 VALUES (1, 2), (3, 4), (5, 6);
+INSERT INTO t5 VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
+SELECT                                          1           +        1;
+1           +        1
+2
+SELECT 1;
+1
+1
+SELECT 1 /* This is an inline comment */ + 1;
+1 /* This is an inline comment */ + 1
+2
+SELECT 1+
+/*
+this is a
+multiple-line comment
+*/
+1;
+1+
+/*
+this is a
+multiple-line comment
+*/
+1
+2
+CREATE SCHEMA statements_digest_temp;
+DROP SCHEMA statements_digest_temp;
+CREATE DATABASE statements_digest_temp;
+DROP DATABASE statements_digest_temp;
+SELECT 1 from t11;
+ERROR 42S02: Table 'statements_digest.t11' doesn't exist
+create table t11 (c char(4));
+create table t11 (c char(4));
+ERROR 42S01: Table 't11' already exists
+insert into t11 values("MySQL");
+Warnings:
+Warning	1265	Data truncated for column 'c' at row 1
+####################################
+# QUERYING PS STATEMENT DIGEST
+####################################
+SELECT digest, digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
+digest	digest_text	count_star
+SELECT digest, digest_text FROM performance_schema.events_statements_current;
+digest	digest_text
+NULL	NULL
+####################################
+# CLEANUP
+####################################
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP DATABASE IF EXISTS statements_digest;

=== added file 'mysql-test/suite/perfschema/r/statement_digest_long_query.result'
--- a/mysql-test/suite/perfschema/r/statement_digest_long_query.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_long_query.result	2012-02-29 13:26:31 +0000
@@ -0,0 +1,12 @@
+USE performance_schema;
+truncate table events_statements_summary_by_digest;
+SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1!
 +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1;
+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
+511
+####################################
+# QUERYING PS STATEMENT DIGEST
+####################################
+SELECT digest, digest_text, count_star FROM events_statements_summary_by_digest;
+digest	digest_text	count_star
+1cba5c4e13d82f35b8af233a4418015c	TRUNCATE TABLE events_statements_summary_by_digest  	1
+f401f781fbd7471a78b3cd6660580063	SELECT ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + !
 ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ...	1

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -27,6 +27,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -42,6 +43,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -74,6 +76,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1718,6 +1721,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1717,6 +1720,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -27,6 +27,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -42,6 +43,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -74,6 +76,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1718,6 +1721,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1717,6 +1720,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -25,6 +25,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -40,6 +41,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -72,6 +74,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1792,6 +1795,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -24,6 +24,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -39,6 +40,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -71,6 +73,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1829,6 +1832,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -25,6 +25,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -40,6 +41,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -72,6 +74,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1792,6 +1795,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -24,6 +24,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -39,6 +40,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -71,6 +73,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1829,6 +1832,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_off.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_off.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_off.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	NO
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1717,6 +1720,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -27,6 +27,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -42,6 +43,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -74,6 +76,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1718,6 +1721,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1717,6 +1720,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -27,6 +27,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -42,6 +43,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -74,6 +76,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1718,6 +1721,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1717,6 +1720,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -29,6 +29,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -44,6 +45,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -76,6 +78,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1720,6 +1723,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -28,6 +28,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -43,6 +44,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -75,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1719,6 +1722,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -29,6 +29,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -44,6 +45,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -76,6 +78,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1720,6 +1723,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -28,6 +28,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -43,6 +44,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -75,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1719,6 +1722,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -27,6 +27,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -42,6 +43,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -74,6 +76,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1756,6 +1759,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1774,6 +1777,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -27,6 +27,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -42,6 +43,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -74,6 +76,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1756,6 +1759,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1774,6 +1777,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -29,6 +29,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -44,6 +45,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -76,6 +78,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1720,6 +1723,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -28,6 +28,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -43,6 +44,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -75,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1719,6 +1722,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -29,6 +29,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -44,6 +45,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -76,6 +78,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1720,6 +1723,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -28,6 +28,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -43,6 +44,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -75,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1719,6 +1722,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -29,6 +29,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -44,6 +45,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -76,6 +78,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1720,6 +1723,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -28,6 +28,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -43,6 +44,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -75,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1719,6 +1722,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -29,6 +29,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -44,6 +45,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -76,6 +78,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1720,6 +1723,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -28,6 +28,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	NO
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -43,6 +44,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -75,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1719,6 +1722,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -27,6 +27,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -42,6 +43,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -74,6 +76,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1756,6 +1759,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1774,6 +1777,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -27,6 +27,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -42,6 +43,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -74,6 +76,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1756,6 +1759,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -26,6 +26,7 @@ events_waits_history	YES
 events_waits_history_long	YES
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -41,6 +42,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -73,6 +75,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1774,6 +1777,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result	2012-02-28 15:57:52 +0000
@@ -29,6 +29,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -44,6 +45,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -76,6 +78,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1720,6 +1723,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result	2012-02-28 15:57:52 +0000
@@ -28,6 +28,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -43,6 +44,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -75,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1719,6 +1722,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result	2012-02-28 15:57:52 +0000
@@ -29,6 +29,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -44,6 +45,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -76,6 +78,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1720,6 +1723,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result	2011-12-16 14:35:48 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result	2012-02-28 15:57:52 +0000
@@ -28,6 +28,7 @@ events_waits_history	NO
 events_waits_history_long	NO
 global_instrumentation	YES
 thread_instrumentation	YES
+statements_digest	YES
 flush tables;
 truncate performance_schema.objects_summary_global_by_type;
 truncate performance_schema.table_io_waits_summary_by_index_usage;
@@ -43,6 +44,7 @@ show variables like "performance_schema%
 Variable_name	Value
 performance_schema	ON
 performance_schema_accounts_size	100
+performance_schema_digests_size	200
 performance_schema_events_stages_history_long_size	1000
 performance_schema_events_stages_history_size	10
 performance_schema_events_statements_history_long_size	1000
@@ -75,6 +77,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0
@@ -1719,6 +1722,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/table_schema.result'
--- a/mysql-test/suite/perfschema/r/table_schema.result	2012-02-14 09:42:07 +0000
+++ b/mysql-test/suite/perfschema/r/table_schema.result	2012-02-28 14:40:36 +0000
@@ -82,34 +82,36 @@ def	performance_schema	events_statements
 def	performance_schema	events_statements_current	TIMER_WAIT	8	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_current	LOCK_TIME	9	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_current	SQL_TEXT	10	NULL	YES	longtext	4294967295	4294967295	NULL	NULL	NULL	utf8	utf8_general_ci	longtext			select,insert,update,references	
-def	performance_schema	events_statements_current	CURRENT_SCHEMA	11	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_current	OBJECT_TYPE	12	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_current	OBJECT_SCHEMA	13	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_current	OBJECT_NAME	14	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_current	OBJECT_INSTANCE_BEGIN	15	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	MYSQL_ERRNO	16	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
-def	performance_schema	events_statements_current	RETURNED_SQLSTATE	17	NULL	YES	varchar	5	15	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(5)			select,insert,update,references	
-def	performance_schema	events_statements_current	MESSAGE_TEXT	18	NULL	YES	varchar	128	384	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(128)			select,insert,update,references	
-def	performance_schema	events_statements_current	ERRORS	19	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	WARNINGS	20	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	ROWS_AFFECTED	21	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	ROWS_SENT	22	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	ROWS_EXAMINED	23	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	CREATED_TMP_DISK_TABLES	24	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	CREATED_TMP_TABLES	25	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SELECT_FULL_JOIN	26	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SELECT_FULL_RANGE_JOIN	27	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SELECT_RANGE	28	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SELECT_RANGE_CHECK	29	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SELECT_SCAN	30	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SORT_MERGE_PASSES	31	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SORT_RANGE	32	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SORT_ROWS	33	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	SORT_SCAN	34	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	NO_INDEX_USED	35	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	NO_GOOD_INDEX_USED	36	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	NESTING_EVENT_ID	37	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_current	NESTING_EVENT_TYPE	38	NULL	YES	enum	9	27	NULL	NULL	NULL	utf8	utf8_general_ci	enum('STATEMENT','STAGE','WAIT')			select,insert,update,references	
+def	performance_schema	events_statements_current	DIGEST	11	NULL	YES	varchar	32	96	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(32)			select,insert,update,references	
+def	performance_schema	events_statements_current	DIGEST_TEXT	12	NULL	YES	longtext	4294967295	4294967295	NULL	NULL	NULL	utf8	utf8_general_ci	longtext			select,insert,update,references	
+def	performance_schema	events_statements_current	CURRENT_SCHEMA	13	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_current	OBJECT_TYPE	14	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_current	OBJECT_SCHEMA	15	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_current	OBJECT_NAME	16	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_current	OBJECT_INSTANCE_BEGIN	17	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	MYSQL_ERRNO	18	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
+def	performance_schema	events_statements_current	RETURNED_SQLSTATE	19	NULL	YES	varchar	5	15	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(5)			select,insert,update,references	
+def	performance_schema	events_statements_current	MESSAGE_TEXT	20	NULL	YES	varchar	128	384	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(128)			select,insert,update,references	
+def	performance_schema	events_statements_current	ERRORS	21	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	WARNINGS	22	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	ROWS_AFFECTED	23	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	ROWS_SENT	24	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	ROWS_EXAMINED	25	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	CREATED_TMP_DISK_TABLES	26	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	CREATED_TMP_TABLES	27	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SELECT_FULL_JOIN	28	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SELECT_FULL_RANGE_JOIN	29	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SELECT_RANGE	30	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SELECT_RANGE_CHECK	31	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SELECT_SCAN	32	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SORT_MERGE_PASSES	33	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SORT_RANGE	34	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SORT_ROWS	35	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	SORT_SCAN	36	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	NO_INDEX_USED	37	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	NO_GOOD_INDEX_USED	38	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	NESTING_EVENT_ID	39	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_current	NESTING_EVENT_TYPE	40	NULL	YES	enum	9	27	NULL	NULL	NULL	utf8	utf8_general_ci	enum('STATEMENT','STAGE','WAIT')			select,insert,update,references	
 def	performance_schema	events_statements_history	THREAD_ID	1	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
 def	performance_schema	events_statements_history	EVENT_ID	2	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_history	END_EVENT_ID	3	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
@@ -120,34 +122,36 @@ def	performance_schema	events_statements
 def	performance_schema	events_statements_history	TIMER_WAIT	8	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_history	LOCK_TIME	9	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_history	SQL_TEXT	10	NULL	YES	longtext	4294967295	4294967295	NULL	NULL	NULL	utf8	utf8_general_ci	longtext			select,insert,update,references	
-def	performance_schema	events_statements_history	CURRENT_SCHEMA	11	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_history	OBJECT_TYPE	12	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_history	OBJECT_SCHEMA	13	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_history	OBJECT_NAME	14	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_history	OBJECT_INSTANCE_BEGIN	15	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	MYSQL_ERRNO	16	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
-def	performance_schema	events_statements_history	RETURNED_SQLSTATE	17	NULL	YES	varchar	5	15	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(5)			select,insert,update,references	
-def	performance_schema	events_statements_history	MESSAGE_TEXT	18	NULL	YES	varchar	128	384	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(128)			select,insert,update,references	
-def	performance_schema	events_statements_history	ERRORS	19	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	WARNINGS	20	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	ROWS_AFFECTED	21	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	ROWS_SENT	22	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	ROWS_EXAMINED	23	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	CREATED_TMP_DISK_TABLES	24	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	CREATED_TMP_TABLES	25	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SELECT_FULL_JOIN	26	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SELECT_FULL_RANGE_JOIN	27	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SELECT_RANGE	28	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SELECT_RANGE_CHECK	29	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SELECT_SCAN	30	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SORT_MERGE_PASSES	31	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SORT_RANGE	32	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SORT_ROWS	33	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	SORT_SCAN	34	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	NO_INDEX_USED	35	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	NO_GOOD_INDEX_USED	36	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	NESTING_EVENT_ID	37	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history	NESTING_EVENT_TYPE	38	NULL	YES	enum	9	27	NULL	NULL	NULL	utf8	utf8_general_ci	enum('STATEMENT','STAGE','WAIT')			select,insert,update,references	
+def	performance_schema	events_statements_history	DIGEST	11	NULL	YES	varchar	32	96	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(32)			select,insert,update,references	
+def	performance_schema	events_statements_history	DIGEST_TEXT	12	NULL	YES	longtext	4294967295	4294967295	NULL	NULL	NULL	utf8	utf8_general_ci	longtext			select,insert,update,references	
+def	performance_schema	events_statements_history	CURRENT_SCHEMA	13	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_history	OBJECT_TYPE	14	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_history	OBJECT_SCHEMA	15	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_history	OBJECT_NAME	16	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_history	OBJECT_INSTANCE_BEGIN	17	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	MYSQL_ERRNO	18	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
+def	performance_schema	events_statements_history	RETURNED_SQLSTATE	19	NULL	YES	varchar	5	15	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(5)			select,insert,update,references	
+def	performance_schema	events_statements_history	MESSAGE_TEXT	20	NULL	YES	varchar	128	384	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(128)			select,insert,update,references	
+def	performance_schema	events_statements_history	ERRORS	21	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	WARNINGS	22	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	ROWS_AFFECTED	23	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	ROWS_SENT	24	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	ROWS_EXAMINED	25	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	CREATED_TMP_DISK_TABLES	26	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	CREATED_TMP_TABLES	27	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SELECT_FULL_JOIN	28	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SELECT_FULL_RANGE_JOIN	29	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SELECT_RANGE	30	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SELECT_RANGE_CHECK	31	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SELECT_SCAN	32	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SORT_MERGE_PASSES	33	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SORT_RANGE	34	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SORT_ROWS	35	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	SORT_SCAN	36	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	NO_INDEX_USED	37	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	NO_GOOD_INDEX_USED	38	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	NESTING_EVENT_ID	39	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history	NESTING_EVENT_TYPE	40	NULL	YES	enum	9	27	NULL	NULL	NULL	utf8	utf8_general_ci	enum('STATEMENT','STAGE','WAIT')			select,insert,update,references	
 def	performance_schema	events_statements_history_long	THREAD_ID	1	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
 def	performance_schema	events_statements_history_long	EVENT_ID	2	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_history_long	END_EVENT_ID	3	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
@@ -158,34 +162,36 @@ def	performance_schema	events_statements
 def	performance_schema	events_statements_history_long	TIMER_WAIT	8	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_history_long	LOCK_TIME	9	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_history_long	SQL_TEXT	10	NULL	YES	longtext	4294967295	4294967295	NULL	NULL	NULL	utf8	utf8_general_ci	longtext			select,insert,update,references	
-def	performance_schema	events_statements_history_long	CURRENT_SCHEMA	11	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_history_long	OBJECT_TYPE	12	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_history_long	OBJECT_SCHEMA	13	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_history_long	OBJECT_NAME	14	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
-def	performance_schema	events_statements_history_long	OBJECT_INSTANCE_BEGIN	15	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	MYSQL_ERRNO	16	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
-def	performance_schema	events_statements_history_long	RETURNED_SQLSTATE	17	NULL	YES	varchar	5	15	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(5)			select,insert,update,references	
-def	performance_schema	events_statements_history_long	MESSAGE_TEXT	18	NULL	YES	varchar	128	384	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(128)			select,insert,update,references	
-def	performance_schema	events_statements_history_long	ERRORS	19	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	WARNINGS	20	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	ROWS_AFFECTED	21	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	ROWS_SENT	22	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	ROWS_EXAMINED	23	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	CREATED_TMP_DISK_TABLES	24	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	CREATED_TMP_TABLES	25	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SELECT_FULL_JOIN	26	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SELECT_FULL_RANGE_JOIN	27	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SELECT_RANGE	28	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SELECT_RANGE_CHECK	29	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SELECT_SCAN	30	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SORT_MERGE_PASSES	31	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SORT_RANGE	32	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SORT_ROWS	33	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	SORT_SCAN	34	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	NO_INDEX_USED	35	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	NO_GOOD_INDEX_USED	36	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	NESTING_EVENT_ID	37	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
-def	performance_schema	events_statements_history_long	NESTING_EVENT_TYPE	38	NULL	YES	enum	9	27	NULL	NULL	NULL	utf8	utf8_general_ci	enum('STATEMENT','STAGE','WAIT')			select,insert,update,references	
+def	performance_schema	events_statements_history_long	DIGEST	11	NULL	YES	varchar	32	96	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(32)			select,insert,update,references	
+def	performance_schema	events_statements_history_long	DIGEST_TEXT	12	NULL	YES	longtext	4294967295	4294967295	NULL	NULL	NULL	utf8	utf8_general_ci	longtext			select,insert,update,references	
+def	performance_schema	events_statements_history_long	CURRENT_SCHEMA	13	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_history_long	OBJECT_TYPE	14	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_history_long	OBJECT_SCHEMA	15	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_history_long	OBJECT_NAME	16	NULL	YES	varchar	64	192	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(64)			select,insert,update,references	
+def	performance_schema	events_statements_history_long	OBJECT_INSTANCE_BEGIN	17	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	MYSQL_ERRNO	18	NULL	YES	int	NULL	NULL	10	0	NULL	NULL	NULL	int(11)			select,insert,update,references	
+def	performance_schema	events_statements_history_long	RETURNED_SQLSTATE	19	NULL	YES	varchar	5	15	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(5)			select,insert,update,references	
+def	performance_schema	events_statements_history_long	MESSAGE_TEXT	20	NULL	YES	varchar	128	384	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(128)			select,insert,update,references	
+def	performance_schema	events_statements_history_long	ERRORS	21	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	WARNINGS	22	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	ROWS_AFFECTED	23	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	ROWS_SENT	24	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	ROWS_EXAMINED	25	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	CREATED_TMP_DISK_TABLES	26	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	CREATED_TMP_TABLES	27	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SELECT_FULL_JOIN	28	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SELECT_FULL_RANGE_JOIN	29	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SELECT_RANGE	30	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SELECT_RANGE_CHECK	31	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SELECT_SCAN	32	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SORT_MERGE_PASSES	33	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SORT_RANGE	34	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SORT_ROWS	35	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	SORT_SCAN	36	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	NO_INDEX_USED	37	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	NO_GOOD_INDEX_USED	38	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	NESTING_EVENT_ID	39	NULL	YES	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_history_long	NESTING_EVENT_TYPE	40	NULL	YES	enum	9	27	NULL	NULL	NULL	utf8	utf8_general_ci	enum('STATEMENT','STAGE','WAIT')			select,insert,update,references	
 def	performance_schema	events_statements_summary_by_account_by_event_name	USER	1	NULL	YES	char	16	48	NULL	NULL	NULL	utf8	utf8_bin	char(16)			select,insert,update,references	
 def	performance_schema	events_statements_summary_by_account_by_event_name	HOST	2	NULL	YES	char	60	180	NULL	NULL	NULL	utf8	utf8_bin	char(60)			select,insert,update,references	
 def	performance_schema	events_statements_summary_by_account_by_event_name	EVENT_NAME	3	NULL	NO	varchar	128	384	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(128)			select,insert,update,references	
@@ -213,6 +219,34 @@ def	performance_schema	events_statements
 def	performance_schema	events_statements_summary_by_account_by_event_name	SUM_SORT_SCAN	25	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_summary_by_account_by_event_name	SUM_NO_INDEX_USED	26	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
 def	performance_schema	events_statements_summary_by_account_by_event_name	SUM_NO_GOOD_INDEX_USED	27	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	DIGEST	1	NULL	YES	varchar	32	96	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(32)			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	DIGEST_TEXT	2	NULL	YES	longtext	4294967295	4294967295	NULL	NULL	NULL	utf8	utf8_general_ci	longtext			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	COUNT_STAR	3	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_TIMER_WAIT	4	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	MIN_TIMER_WAIT	5	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	AVG_TIMER_WAIT	6	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	MAX_TIMER_WAIT	7	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_LOCK_TIME	8	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_ERRORS	9	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_WARNINGS	10	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_ROWS_AFFECTED	11	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_ROWS_SENT	12	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_ROWS_EXAMINED	13	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_CREATED_TMP_DISK_TABLES	14	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_CREATED_TMP_TABLES	15	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SELECT_FULL_JOIN	16	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SELECT_FULL_RANGE_JOIN	17	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SELECT_RANGE	18	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SELECT_RANGE_CHECK	19	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SELECT_SCAN	20	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SORT_MERGE_PASSES	21	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SORT_RANGE	22	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SORT_ROWS	23	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_SORT_SCAN	24	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_NO_INDEX_USED	25	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	SUM_NO_GOOD_INDEX_USED	26	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	FIRST_SEEN	27	0000-00-00 00:00:00	NO	timestamp	NULL	NULL	NULL	NULL	0	NULL	NULL	timestamp			select,insert,update,references	
+def	performance_schema	events_statements_summary_by_digest	LAST_SEEN	28	0000-00-00 00:00:00	NO	timestamp	NULL	NULL	NULL	NULL	0	NULL	NULL	timestamp			select,insert,update,references	
 def	performance_schema	events_statements_summary_by_host_by_event_name	HOST	1	NULL	YES	char	60	180	NULL	NULL	NULL	utf8	utf8_bin	char(60)			select,insert,update,references	
 def	performance_schema	events_statements_summary_by_host_by_event_name	EVENT_NAME	2	NULL	NO	varchar	128	384	NULL	NULL	NULL	utf8	utf8_general_ci	varchar(128)			select,insert,update,references	
 def	performance_schema	events_statements_summary_by_host_by_event_name	COUNT_STAR	3	NULL	NO	bigint	NULL	NULL	20	0	NULL	NULL	NULL	bigint(20) unsigned			select,insert,update,references	

=== modified file 'mysql-test/suite/perfschema/r/temp_table_io.result'
--- a/mysql-test/suite/perfschema/r/temp_table_io.result	2012-01-04 18:29:43 +0000
+++ b/mysql-test/suite/perfschema/r/temp_table_io.result	2012-02-28 15:57:52 +0000
@@ -89,6 +89,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/trigger_table_io.result'
--- a/mysql-test/suite/perfschema/r/trigger_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/trigger_table_io.result	2012-02-28 15:57:52 +0000
@@ -174,6 +174,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== modified file 'mysql-test/suite/perfschema/r/view_table_io.result'
--- a/mysql-test/suite/perfschema/r/view_table_io.result	2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/view_table_io.result	2012-02-28 15:57:52 +0000
@@ -125,6 +125,7 @@ Variable_name	Value
 Performance_schema_accounts_lost	0
 Performance_schema_cond_classes_lost	0
 Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
 Performance_schema_file_classes_lost	0
 Performance_schema_file_handles_lost	0
 Performance_schema_file_instances_lost	0

=== added file 'mysql-test/suite/perfschema/t/ddl_esms_by_digest.test'
--- a/mysql-test/suite/perfschema/t/ddl_esms_by_digest.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/ddl_esms_by_digest.test	2011-06-07 10:23:30 +0000
@@ -0,0 +1,33 @@
+# Copyright (c) 2008, 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,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_summary_by_digest
+  add column foo integer;
+
+truncate table performance_schema.events_statements_summary_by_digest;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_summary_by_digest ADD INDEX test_index(DIGEST);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+  ON performance_schema.events_statements_summary_by_digest(DIGEST);
+

=== added file 'mysql-test/suite/perfschema/t/digest_table_full-master.opt'
--- a/mysql-test/suite/perfschema/t/digest_table_full-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/digest_table_full-master.opt	2012-02-16 14:58:41 +0000
@@ -0,0 +1 @@
+--performance-schema-digests-size=2

=== added file 'mysql-test/suite/perfschema/t/digest_table_full.test'
--- a/mysql-test/suite/perfschema/t/digest_table_full.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/digest_table_full.test	2012-02-20 13:32:56 +0000
@@ -0,0 +1,32 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest when
+# statement-digest-size is 0
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+       SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+
+
+# Expect no digest
+SHOW VARIABLES LIKE "performance_schema_digests_size";
+SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_digest;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc
+

=== added file 'mysql-test/suite/perfschema/t/dml_esms_by_digest.test'
--- a/mysql-test/suite/perfschema/t/dml_esms_by_digest.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/dml_esms_by_digest.test	2011-06-13 11:54:30 +0000
@@ -0,0 +1,56 @@
+# Copyright (c) 2009, 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,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#--disable_result_log 
+select * from performance_schema.events_statements_summary_by_digest
+  where digest like 'XXYYZZ%' limit 1;
+
+select * from performance_schema.events_statements_summary_by_digest
+  where digest='XXYYZZ';
+#--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_summary_by_digest
+  set digest='XXYYZZ', count_star=1, sum_timer_wait=2, min_timer_wait=3,
+  avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_digest
+  set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_digest
+  set count_star=12 where digest like "XXYYZZ";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_digest
+  where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_digest;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_digest READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_digest WRITE;
+UNLOCK TABLES;
+

=== added file 'mysql-test/suite/perfschema/t/start_server_no_digests-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_digests-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_digests-master.opt	2012-01-16 19:07:57 +0000
@@ -0,0 +1 @@
+--performance-schema-digests-size=0

=== added file 'mysql-test/suite/perfschema/t/start_server_no_digests.test'
--- a/mysql-test/suite/perfschema/t/start_server_no_digests.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_digests.test	2012-02-20 13:32:56 +0000
@@ -0,0 +1,32 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest when
+# statement-digest-size is 0
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+       SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+
+
+# Expect no digest
+SHOW VARIABLES LIKE "performance_schema_digests_size";
+SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_digest;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc
+

=== added file 'mysql-test/suite/perfschema/t/statement_digest.test'
--- a/mysql-test/suite/perfschema/t/statement_digest.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/statement_digest.test	2012-02-20 13:32:56 +0000
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema statement Digests.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+       SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc

=== added file 'mysql-test/suite/perfschema/t/statement_digest_consumers-master.opt'
--- a/mysql-test/suite/perfschema/t/statement_digest_consumers-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/statement_digest_consumers-master.opt	2012-02-10 10:13:58 +0000
@@ -0,0 +1,2 @@
+--performance_schema_consumer_statements_digest=1
+--performance_schema_consumer_events_statements_current=0

=== added file 'mysql-test/suite/perfschema/t/statement_digest_consumers.test'
--- a/mysql-test/suite/perfschema/t/statement_digest_consumers.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/statement_digest_consumers.test	2012-02-12 21:48:28 +0000
@@ -0,0 +1,35 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest in combination of different
+# consumers enabled/disabled
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+# -----------------------------------------
+# Consumer                      State      |
+# -----------------------------------------
+# statements_digest             Disabled   |
+# events_statement_current      Enabled    |
+# -----------------------------------------
+
+SELECT * FROM performance_schema.setup_consumers;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT digest, digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
+SELECT digest, digest_text FROM performance_schema.events_statements_current;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc

=== added file 'mysql-test/suite/perfschema/t/statement_digest_consumers2-master.opt'
--- a/mysql-test/suite/perfschema/t/statement_digest_consumers2-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/statement_digest_consumers2-master.opt	2012-02-10 10:13:58 +0000
@@ -0,0 +1,2 @@
+--performance_schema_consumer_statements_digest=0
+--performance_schema_consumer_events_statements_current=1

=== added file 'mysql-test/suite/perfschema/t/statement_digest_consumers2.test'
--- a/mysql-test/suite/perfschema/t/statement_digest_consumers2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/statement_digest_consumers2.test	2012-02-12 21:48:28 +0000
@@ -0,0 +1,37 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest in combination of different
+# consumers enabled/disabled
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+# -----------------------------------------
+# Consumer                      State      |
+# -----------------------------------------
+# statements_digest             Enabled    |
+# events_statement_current      Disabled   |
+# global_implementation         Disabled ? |
+# thread_implementation         Disabled ? |
+# -----------------------------------------
+
+SELECT * FROM performance_schema.setup_consumers;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT digest, digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
+SELECT digest, digest_text FROM performance_schema.events_statements_current;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc

=== added file 'mysql-test/suite/perfschema/t/statement_digest_long_query-master.opt'
--- a/mysql-test/suite/perfschema/t/statement_digest_long_query-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/statement_digest_long_query-master.opt	2012-02-12 21:48:28 +0000
@@ -0,0 +1 @@
+--thread_stack=655360

=== added file 'mysql-test/suite/perfschema/t/statement_digest_long_query.test'
--- a/mysql-test/suite/perfschema/t/statement_digest_long_query.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/statement_digest_long_query.test	2012-02-14 09:20:56 +0000
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema statement Digests.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/no_protocol.inc
+
+USE performance_schema;
+truncate table events_statements_summary_by_digest;
+
+# -----------------------------------------------------------------------
+# Test to show how the digest behaves with long queries, when the token
+# stream is truncated (digest text should end with "...")
+# NOTE: For this test case to run, we need to start mysql server
+# with bigger stack using "--thread_stack=#" option.
+# -----------------------------------------------------------------------
+SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1!
 +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1;
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT digest, digest_text, count_star FROM events_statements_summary_by_digest;

=== added file 'mysql-test/suite/sys_vars/r/pfs_digests_size.result'
--- a/mysql-test/suite/sys_vars/r/pfs_digests_size.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/pfs_digests_size.result	2011-06-13 11:54:30 +0000
@@ -0,0 +1,23 @@
+select @@global.performance_schema_digests_size;
+@@global.performance_schema_digests_size
+200
+select @@session.performance_schema_digests_size;
+ERROR HY000: Variable 'performance_schema_digests_size' is a GLOBAL variable
+show global variables like 'performance_schema_digests_size';
+Variable_name	Value
+performance_schema_digests_size	200
+show session variables like 'performance_schema_digests_size';
+Variable_name	Value
+performance_schema_digests_size	200
+select * from information_schema.global_variables
+where variable_name='performance_schema_digests_size';
+VARIABLE_NAME	VARIABLE_VALUE
+PERFORMANCE_SCHEMA_DIGESTS_SIZE	200
+select * from information_schema.session_variables
+where variable_name='performance_schema_digests_size';
+VARIABLE_NAME	VARIABLE_VALUE
+PERFORMANCE_SCHEMA_DIGESTS_SIZE	200
+set global performance_schema_digests_size=1;
+ERROR HY000: Variable 'performance_schema_digests_size' is a read only variable
+set session performance_schema_digests_size=1;
+ERROR HY000: Variable 'performance_schema_digests_size' is a read only variable

=== added file 'mysql-test/suite/sys_vars/t/pfs_digests_size-master_basic.opt'
--- a/mysql-test/suite/sys_vars/t/pfs_digests_size-master_basic.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/pfs_digests_size-master_basic.opt	2011-06-13 11:54:30 +0000
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance-schema-digests-size=200

=== added file 'mysql-test/suite/sys_vars/t/pfs_digests_size_basic.test'
--- a/mysql-test/suite/sys_vars/t/pfs_digests_size_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/pfs_digests_size_basic.test	2011-06-13 11:54:30 +0000
@@ -0,0 +1,47 @@
+# Copyright (C) 2010 Sun Microsystems, Inc.
+#
+# 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
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# Only global
+#
+
+select @@global.performance_schema_digests_size;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.performance_schema_digests_size;
+
+show global variables like 'performance_schema_digests_size';
+
+show session variables like 'performance_schema_digests_size';
+
+select * from information_schema.global_variables
+  where variable_name='performance_schema_digests_size';
+
+select * from information_schema.session_variables
+  where variable_name='performance_schema_digests_size';
+
+#
+# Read-only
+#
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set global performance_schema_digests_size=1;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set session performance_schema_digests_size=1;
+

=== modified file 'mysys/psi_noop.c'
--- a/mysys/psi_noop.c	2012-01-06 09:03:53 +0000
+++ b/mysys/psi_noop.c	2012-02-12 20:08:11 +0000
@@ -439,7 +439,7 @@ static void start_stage_noop(PSI_stage_k
   return;
 }
 
-static void end_stage_noop()
+static void end_stage_noop(void)
 {
   return;
 }
@@ -607,6 +607,20 @@ static void set_socket_thread_owner_noop
   return;
 }
 
+static struct PSI_digest_locker*
+digest_start_noop(PSI_statement_locker *locker NNN)
+{
+  return NULL;
+}
+
+static PSI_digest_locker*
+digest_add_token_noop(PSI_digest_locker *locker NNN,
+                      uint token NNN,
+                      struct OPAQUE_LEX_YYSTYPE *yylval NNN)
+{
+  return NULL;
+}
+
 static PSI PSI_noop=
 {
   register_mutex_noop,
@@ -700,7 +714,9 @@ static PSI PSI_noop=
   end_socket_wait_noop,
   set_socket_state_noop,
   set_socket_info_noop,
-  set_socket_thread_owner_noop
+  set_socket_thread_owner_noop,
+  digest_start_noop,
+  digest_add_token_noop
 };
 
 /**

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2012-02-28 11:07:43 +0000
+++ b/scripts/mysql_system_tables.sql	2012-02-28 14:40:36 +0000
@@ -1174,6 +1174,8 @@ SET @cmd="CREATE TABLE performance_schem
   "TIMER_WAIT BIGINT unsigned,"
   "LOCK_TIME bigint unsigned not null,"
   "SQL_TEXT LONGTEXT,"
+  "DIGEST VARCHAR(32),"
+  "DIGEST_TEXT LONGTEXT,"
   "CURRENT_SCHEMA VARCHAR(64),"
   "OBJECT_TYPE VARCHAR(64),"
   "OBJECT_SCHEMA VARCHAR(64),"
@@ -1224,6 +1226,8 @@ SET @cmd="CREATE TABLE performance_schem
   "TIMER_WAIT BIGINT unsigned,"
   "LOCK_TIME bigint unsigned not null,"
   "SQL_TEXT LONGTEXT,"
+  "DIGEST VARCHAR(32),"
+  "DIGEST_TEXT LONGTEXT,"
   "CURRENT_SCHEMA VARCHAR(64),"
   "OBJECT_TYPE VARCHAR(64),"
   "OBJECT_SCHEMA VARCHAR(64),"
@@ -1274,6 +1278,8 @@ SET @cmd="CREATE TABLE performance_schem
   "TIMER_WAIT BIGINT unsigned,"
   "LOCK_TIME bigint unsigned not null,"
   "SQL_TEXT LONGTEXT,"
+  "DIGEST VARCHAR(32),"
+  "DIGEST_TEXT LONGTEXT,"
   "CURRENT_SCHEMA VARCHAR(64),"
   "OBJECT_TYPE VARCHAR(64),"
   "OBJECT_SCHEMA VARCHAR(64),"
@@ -1545,6 +1551,46 @@ PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;
 
+--
+-- TABLE EVENTS_STATEMENTS_SUMMARY_BY_DIGEST
+--
+
+SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest("
+  "DIGEST VARCHAR(32),"
+  "DIGEST_TEXT LONGTEXT,"
+  "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,"
+  "SUM_LOCK_TIME BIGINT unsigned not null,"
+  "SUM_ERRORS BIGINT unsigned not null,"
+  "SUM_WARNINGS BIGINT unsigned not null,"
+  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
+  "SUM_ROWS_SENT BIGINT unsigned not null,"
+  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
+  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
+  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
+  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
+  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
+  "SUM_SELECT_RANGE BIGINT unsigned not null,"
+  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
+  "SUM_SELECT_SCAN BIGINT unsigned not null,"
+  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
+  "SUM_SORT_RANGE BIGINT unsigned not null,"
+  "SUM_SORT_ROWS BIGINT unsigned not null,"
+  "SUM_SORT_SCAN BIGINT unsigned not null,"
+  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
+  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null,"
+  "FIRST_SEEN TIMESTAMP(0) default 0,"
+  "LAST_SEEN TIMESTAMP(0) default 0"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+
+
+SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
 
 CREATE TABLE IF NOT EXISTS proxies_priv (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Proxied_host char(60) binary DEFAULT '' NOT NULL, Proxied_user char(16) binary DEFAULT '' NOT NULL, With_grant BOOL DEFAULT 0 NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY Host (Host,User,Proxied_host,Proxied_user), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges';
 

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2012-02-29 11:17:52 +0000
+++ b/sql/sql_lex.cc	2012-02-29 13:26:31 +0000
@@ -31,6 +31,7 @@
 #include "sql_show.h"                  // append_identifier
 #include "sql_select.h"                // JOIN
 #include "sql_optimizer.h"             // JOIN
+#include <mysql/psi/mysql_statement.h>
 
 static int lex_one_token(void *arg, void *yythd);
 
@@ -900,6 +901,7 @@ int MYSQLlex(void *arg, void *yythd)
     lip->lookahead_token= -1;
     *yylval= *(lip->lookahead_yylval);
     lip->lookahead_yylval= NULL;
+    lip->m_digest_psi= MYSQL_ADD_TOKEN(lip->m_digest_psi, token, yylval);
     return token;
   }
 
@@ -917,8 +919,12 @@ int MYSQLlex(void *arg, void *yythd)
     token= lex_one_token(arg, yythd);
     switch(token) {
     case CUBE_SYM:
+      lip->m_digest_psi= MYSQL_ADD_TOKEN(lip->m_digest_psi, WITH_CUBE_SYM,
+                                         yylval);
       return WITH_CUBE_SYM;
     case ROLLUP_SYM:
+      lip->m_digest_psi= MYSQL_ADD_TOKEN(lip->m_digest_psi, WITH_ROLLUP_SYM,
+                                         yylval);
       return WITH_ROLLUP_SYM;
     default:
       /*
@@ -927,6 +933,7 @@ int MYSQLlex(void *arg, void *yythd)
       lip->lookahead_yylval= lip->yylval;
       lip->yylval= NULL;
       lip->lookahead_token= token;
+      lip->m_digest_psi= MYSQL_ADD_TOKEN(lip->m_digest_psi, WITH, yylval);
       return WITH;
     }
     break;
@@ -934,6 +941,7 @@ int MYSQLlex(void *arg, void *yythd)
     break;
   }
 
+  lip->m_digest_psi= MYSQL_ADD_TOKEN(lip->m_digest_psi, token, yylval);
   return token;
 }
 

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2012-02-29 11:17:52 +0000
+++ b/sql/sql_lex.h	2012-02-29 13:26:31 +0000
@@ -2028,7 +2028,7 @@ public:
     DBUG_ASSERT(m_ptr > m_tok_start);
     return (uint) ((m_ptr - m_tok_start) - 1);
   }
-
+   
   /** Get the utf8-body string. */
   const char *get_body_utf8_str()
   {
@@ -2187,6 +2187,11 @@ public:
     NOTE: this member must be used within MYSQLlex() function only.
   */
   CHARSET_INFO *m_underscore_cs;
+
+  /**
+    Current statement digest instrumentation. 
+  */
+  PSI_digest_locker* m_digest_psi;
 };
 
 /* The state of the lex parsing. This is saved in the THD struct */

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2012-02-28 11:07:43 +0000
+++ b/sql/sql_parse.cc	2012-02-28 14:40:36 +0000
@@ -7787,6 +7787,11 @@ bool parse_sql(THD *thd,
 
   thd->m_parser_state= parser_state;
 
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+  /* Start Digest */
+  thd->m_parser_state->m_lip.m_digest_psi= MYSQL_DIGEST_START(thd->m_statement_psi);
+#endif
+
   /* Parse the query. */
 
   bool mysql_parse_status= MYSQLparse(thd) != 0;

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2012-02-29 11:17:52 +0000
+++ b/sql/sys_vars.cc	2012-02-29 13:26:31 +0000
@@ -247,6 +247,13 @@ static Sys_var_mybool Sys_pfs_consumer_t
        CMD_LINE(OPT_ARG), DEFAULT(TRUE),
        PFS_TRAILING_PROPERTIES);
 
+static Sys_var_mybool Sys_pfs_consumer_statement_digest(
+       "performance_schema_consumer_statements_digest",
+       "Default startup value for the statements_digest consumer.",
+       READ_ONLY NOT_VISIBLE GLOBAL_VAR(pfs_param.m_consumer_statement_digest_enabled),
+       CMD_LINE(OPT_ARG), DEFAULT(TRUE),
+       PFS_TRAILING_PROPERTIES);
+
 static Sys_var_ulong Sys_pfs_events_waits_history_long_size(
        "performance_schema_events_waits_history_long_size",
        "Number of rows in EVENTS_WAITS_HISTORY_LONG.",
@@ -480,6 +487,14 @@ static Sys_var_ulong Sys_pfs_events_stat
        DEFAULT(PFS_STATEMENTS_HISTORY_SIZE),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
+static Sys_var_ulong Sys_pfs_digest_size(
+       "performance_schema_digests_size",
+       "Size of the statement digest.",
+       READ_ONLY GLOBAL_VAR(pfs_param.m_digest_sizing),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 200),
+       DEFAULT(PFS_DIGEST_SIZE),
+       BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
 #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
 
 static Sys_var_ulong Sys_auto_increment_increment(

=== modified file 'storage/perfschema/CMakeLists.txt'
--- a/storage/perfschema/CMakeLists.txt	2012-01-02 10:37:56 +0000
+++ b/storage/perfschema/CMakeLists.txt	2012-02-28 14:40:36 +0000
@@ -21,11 +21,30 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}
 
 ADD_DEFINITIONS(-DMYSQL_SERVER)
 
+# Gen_pfs_lex_token
+ADD_EXECUTABLE(gen_pfs_lex_token gen_pfs_lex_token.cc)
+# gen_pfs_lex_token itself depends on ${CMAKE_CURRENT_BINARY_DIR}/sql/sql_yacc.h
+ADD_DEPENDENCIES(gen_pfs_lex_token GenServerSource)
+
+ADD_CUSTOM_COMMAND(
+  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pfs_lex_token.h
+  COMMAND gen_pfs_lex_token > pfs_lex_token.h
+  DEPENDS gen_pfs_lex_token
+)
+
+SET(PFS_GEN_SOURCES
+  ${CMAKE_CURRENT_BINARY_DIR}/pfs_lex_token.h
+)
+
+SET_SOURCE_FILES_PROPERTIES(${PFS_GEN_SOURCES} PROPERTIES GENERATED 1)
+
 #
 # Maintainer: keep this list sorted, to avoid merge collisions.
 # Tip: ls -1 *.h, ls -1 *.cc
 #
-SET(PERFSCHEMA_SOURCES ha_perfschema.h
+SET(PERFSCHEMA_SOURCES
+${PFS_GEN_SOURCES}
+ha_perfschema.h
 cursor_by_account.h
 cursor_by_host.h
 cursor_by_thread.h
@@ -37,6 +56,7 @@ pfs_column_types.h
 pfs_column_values.h
 pfs_con_slice.h
 pfs_defaults.h
+pfs_digest.h
 pfs_engine_table.h
 pfs_events.h
 pfs_events_stages.h
@@ -63,6 +83,7 @@ table_esgs_by_user_by_event_name.h
 table_esgs_global_by_event_name.h
 table_esms_by_account_by_event_name.h
 table_esms_by_host_by_event_name.h
+table_esms_by_digest.h
 table_esms_by_thread_by_event_name.h
 table_esms_by_user_by_event_name.h
 table_esms_global_by_event_name.h
@@ -109,6 +130,7 @@ pfs_check.cc
 pfs_column_values.cc
 pfs_con_slice.cc
 pfs_defaults.cc
+pfs_digest.cc
 pfs_engine_table.cc
 pfs_events_stages.cc
 pfs_events_statements.cc
@@ -132,6 +154,7 @@ table_esgs_by_user_by_event_name.cc
 table_esgs_global_by_event_name.cc
 table_esms_by_account_by_event_name.cc
 table_esms_by_host_by_event_name.cc
+table_esms_by_digest.cc
 table_esms_by_thread_by_event_name.cc
 table_esms_by_user_by_event_name.cc
 table_esms_global_by_event_name.cc

=== added file 'storage/perfschema/gen_pfs_lex_token.cc'
--- a/storage/perfschema/gen_pfs_lex_token.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/gen_pfs_lex_token.cc	2012-02-06 02:41:36 +0000
@@ -0,0 +1,265 @@
+/*
+   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   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,
+   51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#include <my_global.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/* We only need the tokens here */
+#define YYSTYPE_IS_DECLARED
+#include <../sql/sql_yacc.h>
+#include <lex.h>
+
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
+/*
+  This is a tool used during build only,
+  so MY_MAX_TOKEN does not need to be exact,
+  only big enough to hold:
+  - 256 character terminal tokens
+  - YYNTOKENS named terminal tokens
+  from bison.
+  See also YYMAXUTOK.
+*/
+#define MY_MAX_TOKEN 1000
+struct gen_lex_token_string
+{
+  const char *m_token_string;
+  int m_token_length;
+};
+
+gen_lex_token_string compiled_token_array[MY_MAX_TOKEN];
+int max_token_seen= 0;
+
+char char_tokens[256];
+
+int tok_pfs_generic_value= 0;
+int tok_pfs_generic_value_list= 0;
+int tok_pfs_row_single_value= 0;
+int tok_pfs_row_single_value_list= 0;
+int tok_pfs_row_multiple_value= 0;
+int tok_pfs_row_multiple_value_list= 0;
+int tok_pfs_unused= 0;
+
+void set_token(int tok, const char *str)
+{
+  if (tok <= 0)
+  {
+    fprintf(stderr, "Bad token found\n");
+    exit(1);
+  }
+
+  if (tok > max_token_seen)
+  {
+    max_token_seen= tok;
+  }
+
+  if (max_token_seen >= MY_MAX_TOKEN)
+  {
+    fprintf(stderr, "Added that many new keywords ? Increase MY_MAX_TOKEN\n");
+    exit(1);
+  }
+
+  compiled_token_array[tok].m_token_string= str;
+  compiled_token_array[tok].m_token_length= strlen(str);
+}
+
+void compute_tokens()
+{
+  int tok;
+  unsigned int i;
+  char *str;
+
+  /*
+    Default value.
+  */
+  for (tok= 0; tok < MY_MAX_TOKEN; tok++)
+  {
+    compiled_token_array[tok].m_token_string= "(unknown)";
+    compiled_token_array[tok].m_token_length= 9;
+  }
+
+  /*
+    Tokens made of just one terminal character
+  */
+  for (tok=0; tok < 256; tok++)
+  {
+    str= & char_tokens[tok];
+    str[0]= (char) tok;
+    compiled_token_array[tok].m_token_string= str;
+    compiled_token_array[tok].m_token_length= 1;
+  }
+
+  max_token_seen= 255;
+
+  /*
+    String terminal tokens, used in sql_yacc.yy
+  */
+  set_token(NEG, "~");
+  set_token(TABLE_REF_PRIORITY, "TABLE_REF_PRIORITY");
+
+  /*
+    Tokens hard coded in sql_lex.cc
+  */
+
+  set_token(WITH_CUBE_SYM, "WITH CUBE");
+  set_token(WITH_ROLLUP_SYM, "WITH ROLLUP");
+  set_token(NOT2_SYM, "!");
+  set_token(OR2_SYM, "|");
+  set_token(PARAM_MARKER, "?");
+  set_token(SET_VAR, ":=");
+  set_token(UNDERSCORE_CHARSET, "(_charset)");
+  set_token(END_OF_INPUT, "");
+
+  /*
+    Values.
+    These tokens are all normalized later,
+    so this strings will never be displayed.
+  */
+  set_token(BIN_NUM, "(bin)");
+  set_token(DECIMAL_NUM, "(decimal)");
+  set_token(FLOAT_NUM, "(float)");
+  set_token(HEX_NUM, "(hex)");
+  set_token(LEX_HOSTNAME, "(hostname)");
+  set_token(LONG_NUM, "(long)");
+  set_token(NUM, "(num)");
+  set_token(TEXT_STRING, "(text)");
+  set_token(NCHAR_STRING, "(nchar)");
+  set_token(ULONGLONG_NUM, "(ulonglong)");
+
+  /*
+    Identifiers.
+  */
+  set_token(IDENT, "(id)");
+  set_token(IDENT_QUOTED, "(id_quoted)");
+
+  /*
+    Unused tokens
+  */
+  set_token(LOCATOR_SYM, "LOCATOR");
+  set_token(SERVER_OPTIONS, "SERVER_OPTIONS");
+  set_token(UDF_RETURNS_SYM, "UDF_RETURNS");
+
+  /*
+    See symbols[] in sql/lex.h
+  */
+  for (i= 0; i< sizeof(symbols)/sizeof(symbols[0]); i++)
+  {
+    set_token(symbols[i].tok, symbols[i].name);
+  }
+
+  /*
+    See sql_functions[] in sql/lex.h
+  */
+  for (i= 0; i< sizeof(sql_functions)/sizeof(sql_functions[0]); i++)
+  {
+    set_token(sql_functions[i].tok, sql_functions[i].name);
+  }
+
+  /*
+    Additional FAKE tokens,
+    used internally to normalize a digest text.
+  */
+
+  max_token_seen++;
+  tok_pfs_generic_value= max_token_seen;
+  set_token(tok_pfs_generic_value, "?");
+
+  max_token_seen++;
+  tok_pfs_generic_value_list= max_token_seen;
+  set_token(tok_pfs_generic_value_list, "?, ...");
+
+  max_token_seen++;
+  tok_pfs_row_single_value= max_token_seen;
+  set_token(tok_pfs_row_single_value, "(?)");
+
+  max_token_seen++;
+  tok_pfs_row_single_value_list= max_token_seen;
+  set_token(tok_pfs_row_single_value_list, "(?) /* , ... */");
+
+  max_token_seen++;
+  tok_pfs_row_multiple_value= max_token_seen;
+  set_token(tok_pfs_row_multiple_value, "(...)");
+
+  max_token_seen++;
+  tok_pfs_row_multiple_value_list= max_token_seen;
+  set_token(tok_pfs_row_multiple_value_list, "(...) /* , ... */");
+
+  max_token_seen++;
+  tok_pfs_unused= max_token_seen;
+  set_token(tok_pfs_unused, "UNUSED");
+}
+
+void print_tokens()
+{
+  int tok;
+
+  printf("lex_token_string lex_token_array[]=\n");
+  printf("{\n");
+  printf("/* PART 1: character tokens. */\n");
+
+  for (tok= 0; tok<256; tok++)
+  {
+    printf("/* %03d */  { \"\\x%02x\", 1},\n", tok, tok);
+  }
+
+  printf("/* PART 2: named tokens. */\n");
+
+  for (tok= 256; tok<= max_token_seen; tok++)
+  {
+    printf("/* %03d */  { \"%s\", %d},\n",
+           tok,
+           compiled_token_array[tok].m_token_string,
+           compiled_token_array[tok].m_token_length);
+  }
+
+  printf("/* DUMMY */ { \"\", 0}\n");
+  printf("};\n");
+
+  printf("/* PFS specific tokens. */\n");
+  printf("#define TOK_PFS_GENERIC_VALUE %d\n", tok_pfs_generic_value);
+  printf("#define TOK_PFS_GENERIC_VALUE_LIST %d\n", tok_pfs_generic_value_list);
+  printf("#define TOK_PFS_ROW_SINGLE_VALUE %d\n", tok_pfs_row_single_value);
+  printf("#define TOK_PFS_ROW_SINGLE_VALUE_LIST %d\n", tok_pfs_row_single_value_list);
+  printf("#define TOK_PFS_ROW_MULTIPLE_VALUE %d\n", tok_pfs_row_multiple_value);
+  printf("#define TOK_PFS_ROW_MULTIPLE_VALUE_LIST %d\n", tok_pfs_row_multiple_value_list);
+  printf("#define TOK_PFS_UNUSED %d\n", tok_pfs_unused);
+}
+
+int main(int argc,char **argv)
+{
+  puts("/*");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2011"));
+  puts("*/");
+
+  printf("/*\n");
+  printf("  This file is generated, do not edit.\n");
+  printf("  See file storage/perfschema/gen_pfs_lex_token.cc.\n");
+  printf("*/\n");
+  printf("struct lex_token_string\n");
+  printf("{\n");
+  printf("  const char *m_token_string;\n");
+  printf("  int m_token_length;\n");
+  printf("};\n");
+  printf("typedef struct lex_token_string lex_token_string;\n");
+
+  compute_tokens();
+  print_tokens();
+
+  return 0;
+}
+

=== modified file 'storage/perfschema/ha_perfschema.cc'
--- a/storage/perfschema/ha_perfschema.cc	2012-02-16 09:51:14 +0000
+++ b/storage/perfschema/ha_perfschema.cc	2012-02-28 15:57:52 +0000
@@ -164,6 +164,8 @@ static struct st_mysql_show_var pfs_stat
     (char*) &stage_class_lost, SHOW_LONG},
   {"Performance_schema_statement_classes_lost",
     (char*) &statement_class_lost, SHOW_LONG},
+  {"Performance_schema_digest_lost",
+    (char*) &digest_lost, SHOW_LONG},
   {NullS, NullS, SHOW_LONG}
 };
 

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2012-02-16 09:51:14 +0000
+++ b/storage/perfschema/pfs.cc	2012-02-29 14:43:11 +0000
@@ -39,6 +39,7 @@
 #include "pfs_setup_object.h"
 #include "sql_error.h"
 #include "sp_head.h"
+#include "pfs_digest.h"
 
 /**
   @page PAGE_PERFORMANCE_SCHEMA The Performance Schema main page
@@ -964,7 +965,12 @@ static inline int mysql_mutex_lock(...)
   - [E] EVENTS_STAGES_SUMMARY_GLOBAL_BY_EVENT_NAME,
         @c table_esgs_global_by_event_name::make_row()
 
-  @section IMPL_STATEMENT Implementation for statements aggregates
+@section IMPL_STATEMENT Implementation for statements consumers
+
+  For statements, the tables that contains individual event data are:
+  - EVENTS_STATEMENTS_CURRENT
+  - EVENTS_STATEMENTS_HISTORY
+  - EVENTS_STATEMENTS_HISTORY_LONG
 
   For statements, the tables that contains aggregated data are:
   - EVENTS_STATEMENTS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
@@ -972,6 +978,7 @@ static inline int mysql_mutex_lock(...)
   - EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME
   - EVENTS_STATEMENTS_SUMMARY_BY_USER_BY_EVENT_NAME
   - EVENTS_STATEMENTS_SUMMARY_GLOBAL_BY_EVENT_NAME
+  - EVENTS_STATEMENTS_SUMMARY_BY_DIGEST
 
 @verbatim
   statement_locker(T, S)
@@ -992,12 +999,25 @@ static inline int mysql_mutex_lock(...)
    |    .    .    |
    |    .    .    | [4-RESET]
    | 2d .    .    |
-1b |----+----+----+-> pfs_stage_class(S)      =====>> [E]
+1b |----+----+----+-> pfs_statement_class(S)  =====>> [E]
+   |
+1c |-> pfs_thread(T).statement_current(S)     =====>> [F]
+   |
+1d |-> pfs_thread(T).statement_history(S)     =====>> [G]
+   |
+1e |-> statement_history_long(S)              =====>> [H]
+   |
+1f |-> statement_digest(S)                    =====>> [I]
 
 @endverbatim
 
   Implemented as:
   - [1] @c start_statement_v1(), end_statement_v1()
+       (1a, 1b) is an aggregation by EVENT_NAME,
+        (1c, 1d, 1e) is an aggregation by TIME,
+        (1f) is an aggregation by DIGEST
+        all of these are orthogonal,
+        and implemented in end_statement_v1().
   - [2] @c delete_thread_v1(), @c aggregate_thread_statements()
   - [3] @c PFS_account::aggregate_statements()
   - [4] @c PFS_host::aggregate_statements()
@@ -1011,6 +1031,17 @@ static inline int mysql_mutex_lock(...)
         @c table_esms_by_host_by_event_name::make_row()
   - [E] EVENTS_STATEMENTS_SUMMARY_GLOBAL_BY_EVENT_NAME,
         @c table_esms_global_by_event_name::make_row()
+  - [F] EVENTS_STATEMENTS_CURRENT,
+        @c table_events_statements_current::rnd_next(),
+        @c table_events_statements_common::make_row()
+  - [G] EVENTS_STATEMENTS_HISTORY,
+        @c table_events_statements_history::rnd_next(),
+        @c table_events_statements_common::make_row()
+  - [H] EVENTS_STATEMENTS_HISTORY_LONG,
+        @c table_events_statements_history_long::rnd_next(),
+        @c table_events_statements_common::make_row()
+  - [I] EVENTS_STATEMENTS_SUMMARY_BY_DIGEST
+        @c table_esms_by_digest::make_row()
 */
 
 /**
@@ -1026,13 +1057,6 @@ static inline int mysql_mutex_lock(...)
   @ingroup Performance_schema_implementation
 */
 
-/** TIMED bit in the state flags bitfield. */
-#define STATE_FLAG_TIMED (1<<0)
-/** THREAD bit in the state flags bitfield. */
-#define STATE_FLAG_THREAD (1<<1)
-/** EVENT bit in the state flags bitfield. */
-#define STATE_FLAG_EVENT (1<<2)
-
 pthread_key(PFS_thread*, THR_PFS);
 bool THR_PFS_initialized= false;
 
@@ -4210,6 +4234,7 @@ get_thread_statement_locker_v1(PSI_state
       pfs->m_sort_scan= 0;
       pfs->m_no_index_used= 0;
       pfs->m_no_good_index_used= 0;
+      digest_reset(& pfs->m_digest_storage);
 
       /* New stages will have this statement as parent */
       PFS_events_stages *child_stage= & pfs_thread->m_stage_current;
@@ -4235,6 +4260,13 @@ get_thread_statement_locker_v1(PSI_state
       flags= 0;
   }
 
+  if (flag_statements_digest)
+  {
+    flags|= STATE_FLAG_DIGEST;
+    state->m_digest_state.m_last_id_index= 0;
+    digest_reset(& state->m_digest_state.m_digest_storage);
+  }
+
   state->m_discarded= false;
   state->m_class= klass;
   state->m_flags= flags;
@@ -4513,6 +4545,13 @@ static void end_statement_v1(PSI_stateme
   PFS_statement_stat *event_name_array;
   uint index= klass->m_event_name_index;
   PFS_statement_stat *stat;
+  
+  /*
+   Capture statement stats by digest.
+  */
+  PSI_digest_storage *digest_storage= NULL;
+  PFS_statement_stat *digest_stat= NULL;
+
   if (flags & STATE_FLAG_THREAD)
   {
     PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
@@ -4521,6 +4560,16 @@ static void end_statement_v1(PSI_stateme
     /* Aggregate to EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME */
     stat= & event_name_array[index];
 
+    if (flags & STATE_FLAG_DIGEST)
+    {
+      digest_storage= &state->m_digest_state.m_digest_storage;
+
+      /* 
+        Populate PFS_statements_digest_stat with computed digest information.
+      */
+      digest_stat= find_or_create_digest(thread, digest_storage);
+    }
+
     if (flags & STATE_FLAG_EVENT)
     {
       PFS_events_statements *pfs= reinterpret_cast<PFS_events_statements*> (state->m_statement);
@@ -4552,6 +4601,18 @@ static void end_statement_v1(PSI_stateme
 
       pfs->m_timer_end= timer_end;
       pfs->m_end_event_id= thread->m_event_id;
+
+      if (flags & STATE_FLAG_DIGEST)
+      {
+        /*
+          The following columns in events_statement_current:
+          - DIGEST,
+          - DIGEST_TEXT
+          are computed from the digest storage.
+        */
+        digest_copy(& pfs->m_digest_storage, digest_storage);
+      }
+
       if (flag_events_statements_history)
         insert_events_statements_history(thread, pfs);
       if (flag_events_statements_history_long)
@@ -4563,6 +4624,23 @@ static void end_statement_v1(PSI_stateme
   }
   else
   {
+    if (flags & STATE_FLAG_DIGEST)
+    {
+      PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+
+      /* An instrumented thread is required, for LF_PINS. */
+      if (thread != NULL)
+      {
+        /* Set digest stat. */
+        digest_storage= &state->m_digest_state.m_digest_storage;
+
+        /* 
+          Populate PFS_statements_digest_stat with computed digest information.
+        */
+        digest_stat= find_or_create_digest(thread, digest_storage);
+      }
+    }
+
     event_name_array= global_instr_class_statements_array;
     /* Aggregate to EVENTS_STATEMENTS_SUMMARY_GLOBAL_BY_EVENT_NAME */
     stat= & event_name_array[index];
@@ -4596,19 +4674,61 @@ static void end_statement_v1(PSI_stateme
   stat->m_no_index_used+= state->m_no_index_used;
   stat->m_no_good_index_used+= state->m_no_good_index_used;
 
-  switch(da->status())
+  if (digest_stat != NULL)
+  {
+    if (flags & STATE_FLAG_TIMED)
+    {
+      digest_stat->aggregate_value(wait_time);
+    }
+    else
+    {
+      digest_stat->aggregate_counted();
+    }
+  
+    digest_stat->m_lock_time+= state->m_lock_time;
+    digest_stat->m_rows_sent+= state->m_rows_sent;
+    digest_stat->m_rows_examined+= state->m_rows_examined;
+    digest_stat->m_created_tmp_disk_tables+= state->m_created_tmp_disk_tables;
+    digest_stat->m_created_tmp_tables+= state->m_created_tmp_tables;
+    digest_stat->m_select_full_join+= state->m_select_full_join;
+    digest_stat->m_select_full_range_join+= state->m_select_full_range_join;
+    digest_stat->m_select_range+= state->m_select_range;
+    digest_stat->m_select_range_check+= state->m_select_range_check;
+    digest_stat->m_select_scan+= state->m_select_scan;
+    digest_stat->m_sort_merge_passes+= state->m_sort_merge_passes;
+    digest_stat->m_sort_range+= state->m_sort_range;
+    digest_stat->m_sort_rows+= state->m_sort_rows;
+    digest_stat->m_sort_scan+= state->m_sort_scan;
+    digest_stat->m_no_index_used+= state->m_no_index_used;
+    digest_stat->m_no_good_index_used+= state->m_no_good_index_used;
+  }
+
+  switch (da->status())
   {
     case Diagnostics_area::DA_EMPTY:
       break;
     case Diagnostics_area::DA_OK:
       stat->m_rows_affected+= da->affected_rows();
       stat->m_warning_count+= da->statement_warn_count();
+      if (digest_stat != NULL)
+      {
+        digest_stat->m_rows_affected+= da->affected_rows();
+        digest_stat->m_warning_count+= da->statement_warn_count();
+      }
       break;
     case Diagnostics_area::DA_EOF:
       stat->m_warning_count+= da->statement_warn_count();
+      if (digest_stat != NULL)
+      {
+        digest_stat->m_warning_count+= da->statement_warn_count();
+      }
       break;
     case Diagnostics_area::DA_ERROR:
       stat->m_error_count++;
+      if (digest_stat != NULL)
+      {
+        digest_stat->m_error_count++;
+      }
       break;
     case Diagnostics_area::DA_DISABLED:
       break;
@@ -4846,7 +4966,9 @@ PSI_v1 PFS_v1=
   end_socket_wait_v1,
   set_socket_state_v1,
   set_socket_info_v1,
-  set_socket_thread_owner_v1
+  set_socket_thread_owner_v1,
+  pfs_digest_start_v1,
+  pfs_digest_add_token_v1
 };
 
 static void* get_interface(int version)

=== modified file 'storage/perfschema/pfs_column_types.h'
--- a/storage/perfschema/pfs_column_types.h	2011-07-08 21:31:33 +0000
+++ b/storage/perfschema/pfs_column_types.h	2011-09-06 12:24:04 +0000
@@ -53,6 +53,12 @@
 /** Size of the SOURCE columns. */
 #define COL_SOURCE_SIZE 64
 
+/** Size of the DIGEST columns. */
+#define COL_DIGEST_SIZE 64
+
+/** Size of the DIGEST_TEXT columns. */
+#define COL_DIGEST_TEXT_SIZE 1024
+
 /**
   Enum values for the TIMER_NAME columns.
   This enum is found in the following tables:

=== added file 'storage/perfschema/pfs_digest.cc'
--- a/storage/perfschema/pfs_digest.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/pfs_digest.cc	2012-02-28 15:57:52 +0000
@@ -0,0 +1,677 @@
+/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  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,
+  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+/**
+  @file storage/perfschema/pfs_digest.h
+  Statement Digest data structures (implementation).
+*/
+
+/*
+  This code needs extra visibility in the lexer structures
+*/
+
+#include "my_global.h"
+#include "my_sys.h"
+#include "pfs_instr.h"
+#include "pfs_digest.h"
+#include "pfs_global.h"
+#include "table_helper.h"
+#include "my_md5.h"
+#include "sql_lex.h"
+#include "sql_get_diagnostics.h"
+#include <string.h>
+
+/* Generated code */
+#include "../sql/sql_yacc.h"
+#include "../storage/perfschema/pfs_lex_token.h"
+
+/* Name pollution from sql/sql_lex.h */
+#ifdef LEX_YYSTYPE
+#undef LEX_YYSTYPE
+#endif
+
+#define LEX_YYSTYPE YYSTYPE
+
+/**
+  Token array : 
+  Token array is an array of bytes to store tokens recieved during parsing.
+  Following is the way token array is formed.
+     
+      ...<non-id-token><non-id-token><id-token><id_len><id_text>...
+
+  For Ex:
+  SELECT * FROM T1;
+  <SELECT_TOKEN><*><FROM_TOKEN><ID_TOKEN><2><T1>
+*/
+
+ulong digest_max= 0;
+ulong digest_lost= 0;
+
+
+/** EVENTS_STATEMENTS_HISTORY_LONG circular buffer. */
+PFS_statements_digest_stat *statements_digest_stat_array= NULL;
+/** Consumer flag for table EVENTS_STATEMENTS_SUMMARY_BY_DIGEST. */
+bool flag_statements_digest= true;
+/** 
+  Current index in Stat array where new record is to be inserted.
+  index 0 is reserved for "all else" case when entire array is full.
+*/
+volatile uint32 digest_index= 1;
+
+static LF_HASH digest_hash;
+static bool digest_hash_inited= false;
+
+/**
+  Initialize table EVENTS_STATEMENTS_SUMMARY_BY_DIGEST.
+  @param digest_sizing      
+*/
+int init_digest(const PFS_global_param *param)
+{
+  unsigned int index;
+
+  /*
+    Allocate memory for statements_digest_stat_array based on
+    performance_schema_digests_size values
+  */
+  digest_max= param->m_digest_sizing;
+  digest_lost= 0;
+
+  if (digest_max == 0)
+    return 0;
+
+  statements_digest_stat_array=
+    PFS_MALLOC_ARRAY(digest_max, PFS_statements_digest_stat,
+                     MYF(MY_ZEROFILL));
+  if (unlikely(statements_digest_stat_array == NULL))
+    return 1;
+
+  for (index= 0; index < digest_max; index++)
+  {
+    statements_digest_stat_array[index].reset_data();
+  }
+
+  return 0;
+}
+
+/** Cleanup table EVENTS_STATEMENTS_SUMMARY_BY_DIGEST. */
+void cleanup_digest(void)
+{
+  /*  Free memory allocated to statements_digest_stat_array. */
+  pfs_free(statements_digest_stat_array);
+  statements_digest_stat_array= NULL;
+}
+
+C_MODE_START
+static uchar *digest_hash_get_key(const uchar *entry, size_t *length,
+                                  my_bool)
+{
+  const PFS_statements_digest_stat * const *typed_entry;
+  const PFS_statements_digest_stat *digest;
+  const void *result;
+  typed_entry= reinterpret_cast<const PFS_statements_digest_stat*const*>(entry);
+  DBUG_ASSERT(typed_entry != NULL);
+  digest= *typed_entry;
+  DBUG_ASSERT(digest != NULL);
+  *length= PFS_MD5_SIZE; 
+  result= digest->m_digest_hash.m_md5;
+  return const_cast<uchar*> (reinterpret_cast<const uchar*> (result));
+}
+C_MODE_END
+
+
+/**
+  Initialize the digest hash.
+  @return 0 on success
+*/
+int init_digest_hash(void)
+{
+  if (! digest_hash_inited)
+  {
+    lf_hash_init(&digest_hash, sizeof(PFS_statements_digest_stat*),
+                 LF_HASH_UNIQUE, 0, 0, digest_hash_get_key,
+                 &my_charset_bin);
+    digest_hash_inited= true;
+  }
+  return 0;
+}
+
+void cleanup_digest_hash(void)
+{
+  if (digest_hash_inited)
+  {
+    lf_hash_destroy(&digest_hash);
+    digest_hash_inited= false;
+  }
+}
+
+static LF_PINS* get_digest_hash_pins(PFS_thread *thread)
+{
+  if (unlikely(thread->m_digest_hash_pins == NULL))
+  {
+    if (!digest_hash_inited)
+      return NULL;
+    thread->m_digest_hash_pins= lf_hash_get_pins(&digest_hash);
+  }
+  return thread->m_digest_hash_pins;
+}
+
+PFS_statement_stat*
+find_or_create_digest(PFS_thread* thread,
+                      PSI_digest_storage* digest_storage)
+{
+  if (statements_digest_stat_array == NULL)
+    return NULL;
+
+  if (digest_storage->m_byte_count <= 0)
+    return NULL;
+
+  LF_PINS *pins= get_digest_hash_pins(thread);
+  if (unlikely(pins == NULL))
+    return NULL;
+
+  /* Compute MD5 Hash of the tokens received. */
+  PFS_digest_hash md5;
+  compute_md5_hash((char *) md5.m_md5,
+                   (char *) digest_storage->m_token_array,
+                   digest_storage->m_byte_count);
+
+  unsigned char* hash_key= md5.m_md5;
+
+  int res;
+  ulong safe_index;
+  uint retry_count= 0;
+  const uint retry_max= 3;
+  PFS_statements_digest_stat **entry;
+  PFS_statements_digest_stat *pfs= NULL;
+
+  ulonglong now= my_micro_time();
+
+search:
+
+  /* Lookup LF_HASH using this new key. */
+  entry= reinterpret_cast<PFS_statements_digest_stat**>
+    (lf_hash_search(&digest_hash, pins,
+                    hash_key, PFS_MD5_SIZE));
+
+  if (entry && (entry != MY_ERRPTR))
+  {
+    /* If digest already exists, update stats and return. */
+    pfs= *entry;
+    pfs->m_last_seen= now;
+    lf_hash_search_unpin(pins);
+    return & pfs->m_stat;
+  }
+
+  lf_hash_search_unpin(pins);
+
+  /* Dirty read of digest_index */
+  if (digest_index == 0)
+  {
+    /*  digest_stat array is full. Add stat at index 0 and return. */
+    pfs= &statements_digest_stat_array[0];
+
+    if (pfs->m_first_seen == 0)
+      pfs->m_first_seen= now;
+    pfs->m_last_seen= now;
+    return & pfs->m_stat;
+  }
+
+  safe_index= PFS_atomic::add_u32(& digest_index, 1);
+  if (safe_index >= digest_max)
+  {
+    /* The digest array is now full. */
+    digest_index= 0;
+    pfs= &statements_digest_stat_array[0];
+
+    if (pfs->m_first_seen == 0)
+      pfs->m_first_seen= now;
+    pfs->m_last_seen= now;
+    return & pfs->m_stat;
+  }
+
+  /* Add a new record in digest stat array. */
+  pfs= &statements_digest_stat_array[safe_index];
+
+  /* Copy digest hash/LF Hash search key. */
+  memcpy(pfs->m_digest_hash.m_md5, md5.m_md5, PFS_MD5_SIZE);
+
+  /*
+    Copy digest storage to statement_digest_stat_array so that it could be
+    used later to generate digest text.
+  */
+  digest_copy(& pfs->m_digest_storage, digest_storage);
+
+  pfs->m_first_seen= now;
+  pfs->m_last_seen= now;
+
+  res= lf_hash_insert(&digest_hash, pins, &pfs);
+  if (likely(res == 0))
+  {
+    return & pfs->m_stat;
+  }
+
+  if (res > 0)
+  {
+    /* Duplicate insert by another thread */
+    if (++retry_count > retry_max)
+    {
+      /* Avoid infinite loops */
+      digest_lost++;
+      return NULL;
+    }
+    goto search;
+  }
+
+  /* OOM in lf_hash_insert */
+  digest_lost++;
+  return NULL;
+}
+
+void purge_digest(PFS_thread* thread, unsigned char* hash_key)
+{
+  LF_PINS *pins= get_digest_hash_pins(thread);
+  if (unlikely(pins == NULL))
+    return;
+
+  PFS_statements_digest_stat **entry;
+
+  /* Lookup LF_HASH using this new key. */
+  entry= reinterpret_cast<PFS_statements_digest_stat**>
+    (lf_hash_search(&digest_hash, pins,
+                    hash_key, PFS_MD5_SIZE));
+
+  if (entry && (entry != MY_ERRPTR))
+  { 
+    lf_hash_delete(&digest_hash, pins,
+                   hash_key, PFS_MD5_SIZE);
+  }
+  lf_hash_search_unpin(pins);
+  return;
+}
+
+void PFS_statements_digest_stat::reset_data()
+{
+  digest_reset(& m_digest_storage);
+  m_stat.reset();
+  m_first_seen= 0;
+  m_last_seen= 0;
+}
+
+void PFS_statements_digest_stat::reset_index(PFS_thread *thread)
+{
+  /* Only remove entries that exists in the HASH index. */
+  if (m_digest_storage.m_byte_count > 0)
+  {
+    purge_digest(thread, m_digest_hash.m_md5);
+  }
+}
+
+void reset_esms_by_digest()
+{
+  uint index;
+
+  if (statements_digest_stat_array == NULL)
+    return;
+
+  PFS_thread *thread= PFS_thread::get_current_thread();
+  if (unlikely(thread == NULL))
+    return;
+
+  /* Reset statements_digest_stat_array. */
+  for (index= 0; index < digest_max; index++)
+  {
+    statements_digest_stat_array[index].reset_index(thread);
+    statements_digest_stat_array[index].reset_data();
+  }
+
+  /* 
+    Reset index which indicates where the next calculated digest information
+    to be inserted in statements_digest_stat_array.
+  */
+  digest_index= 1;
+}
+
+/*
+  Iterate token array and updates digest_text.
+*/
+void get_digest_text(char* digest_text, PSI_digest_storage* digest_storage)
+{
+  bool truncated= false;
+  int byte_count= digest_storage->m_byte_count;
+  int need_bytes;
+  uint tok= 0;
+  char *id_string;
+  int id_length;
+  int current_byte= 0;
+  lex_token_string *tok_data;
+  /* -4 is to make sure extra space for '...' and a '\0' at the end. */
+  int available_bytes_to_write= COL_DIGEST_TEXT_SIZE - 4;
+
+  DBUG_ASSERT(byte_count <= PSI_MAX_DIGEST_STORAGE_SIZE);
+
+  while ((current_byte < byte_count) &&
+         (available_bytes_to_write > 0) &&
+         (! truncated))
+  {
+    current_byte= read_token(digest_storage, current_byte, &tok);
+    tok_data= & lex_token_array[tok];
+    
+    switch (tok)
+    {
+    /* All identifiers are printed with their name. */
+    case IDENT:
+      current_byte= read_identifier(digest_storage, current_byte,
+                                    & id_string, & id_length);
+      need_bytes= id_length + 1; /* <id> space */
+      if (need_bytes <= available_bytes_to_write)
+      {
+        if (id_length > 0)
+        {
+          strncpy(digest_text, id_string, id_length);
+          digest_text+= id_length;
+        }
+        *digest_text= ' ';
+        digest_text++;
+        available_bytes_to_write-= need_bytes;
+      }
+      else
+      {
+        truncated= true;
+      }
+      break;
+    case IDENT_QUOTED:
+      current_byte= read_identifier(digest_storage, current_byte,
+                                    & id_string, & id_length);
+      need_bytes= id_length + 3; /* quote <id> quote space  */
+      if (need_bytes <= available_bytes_to_write)
+      {
+        *digest_text= '`';
+        digest_text++;
+        if (id_length > 0)
+        {
+          strncpy(digest_text, id_string, id_length);
+          digest_text+= id_length;
+        }
+        *digest_text= '`';
+        digest_text++;
+        *digest_text= ' ';
+        digest_text++;
+        available_bytes_to_write-= need_bytes;
+      }
+      else
+      {
+        truncated= true;
+      }
+      break;
+
+    /* Everything else is printed as is. */
+    default:
+      /* 
+        Make sure not to overflow digest_text buffer while writing
+        this token string.
+        +1 is to make sure extra space for ' '.
+      */
+      int tok_length= tok_data->m_token_length;
+      need_bytes= tok_length + 1;
+
+      if (need_bytes <= available_bytes_to_write)
+      {
+        strncpy(digest_text,
+                tok_data->m_token_string,
+                tok_length);
+        digest_text+= tok_length;
+        *digest_text= ' ';
+        digest_text++;
+        available_bytes_to_write-= need_bytes;
+      }
+      else
+      {
+        truncated= true;
+      }
+    }
+  }
+
+  /* Truncate digest text in case of long queries. */
+  if (digest_storage->m_full || truncated)
+  {
+    strcpy(digest_text, "...");
+    digest_text+= 3;
+  }
+
+  *digest_text= '\0';
+}
+
+static inline uint peek_token(const PSI_digest_storage *digest, int index)
+{
+  uint token;
+  DBUG_ASSERT(index >= 0);
+  DBUG_ASSERT(index + PFS_SIZE_OF_A_TOKEN <= digest->m_byte_count);
+  DBUG_ASSERT(digest->m_byte_count <=  PSI_MAX_DIGEST_STORAGE_SIZE);
+
+  token= ((digest->m_token_array[index + 1])<<8) | digest->m_token_array[index];
+  return token;
+}
+
+/**
+  Function to read last two tokens from token array. If an identifier
+  is found, do not look for token after that.
+*/
+static inline void peek_last_two_tokens(const PSI_digest_storage* digest_storage,
+                                        int last_id_index, uint *t1, uint *t2)
+{
+  int byte_count= digest_storage->m_byte_count;
+
+  if (last_id_index <= byte_count - PFS_SIZE_OF_A_TOKEN)
+  {
+    /* Take last token. */
+    *t1= peek_token(digest_storage, byte_count - PFS_SIZE_OF_A_TOKEN);
+  }
+  else
+  {
+    *t1= TOK_PFS_UNUSED;
+  }
+
+  if (last_id_index <= byte_count - 2*PFS_SIZE_OF_A_TOKEN)
+  {
+    /* Take 2nd token from last. */
+    *t2= peek_token(digest_storage, byte_count - 2 * PFS_SIZE_OF_A_TOKEN);
+  }
+  else
+  {
+    *t2= TOK_PFS_UNUSED;
+  }
+}
+
+struct PSI_digest_locker* pfs_digest_start_v1(PSI_statement_locker *locker)
+{
+  PSI_statement_locker_state *statement_state;
+  statement_state= reinterpret_cast<PSI_statement_locker_state*> (locker);
+  DBUG_ASSERT(statement_state != NULL);
+
+  if (statement_state->m_discarded)
+    return NULL;
+
+  if (statement_state->m_flags & STATE_FLAG_DIGEST)
+  {
+    PSI_digest_locker_state *digest_state;
+    digest_state= &statement_state->m_digest_state;
+    return reinterpret_cast<PSI_digest_locker*> (digest_state);
+  }
+
+  return NULL;
+}
+
+PSI_digest_locker* pfs_digest_add_token_v1(PSI_digest_locker *locker,
+                                           uint token,
+                                           OPAQUE_LEX_YYSTYPE *yylval)
+{
+  PSI_digest_locker_state *state= NULL;
+  PSI_digest_storage      *digest_storage= NULL;
+
+  state= reinterpret_cast<PSI_digest_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+
+  digest_storage= &state->m_digest_storage;
+
+  if (digest_storage->m_full)
+    return NULL;
+
+  /* 
+    Take last_token 2 tokens collected till now. These tokens will be used
+    in reduce for normalisation. Make sure not to consider ID tokens in reduce.
+  */
+  uint last_token;
+  uint last_token2;
+  
+  peek_last_two_tokens(digest_storage, state->m_last_id_index,
+                       &last_token, &last_token2);
+
+  switch (token)
+  {
+    case BIN_NUM:
+    case DECIMAL_NUM:
+    case FLOAT_NUM:
+    case HEX_NUM:
+    case LEX_HOSTNAME:
+    case LONG_NUM:
+    case NUM:
+    case TEXT_STRING:
+    case NCHAR_STRING:
+    case ULONGLONG_NUM:
+    {
+      /*
+        REDUCE:
+        TOK_PFS_GENERIC_VALUE := BIN_NUM | DECIMAL_NUM | ... | ULONGLONG_NUM
+      */
+      token= TOK_PFS_GENERIC_VALUE;
+
+      if ((last_token2 == TOK_PFS_GENERIC_VALUE ||
+           last_token2 == TOK_PFS_GENERIC_VALUE_LIST) &&
+          (last_token == ','))
+      {
+        /*
+          REDUCE:
+          TOK_PFS_GENERIC_VALUE_LIST :=
+            TOK_PFS_GENERIC_VALUE ',' TOK_PFS_GENERIC_VALUE
+          
+          REDUCE:
+          TOK_PFS_GENERIC_VALUE_LIST :=
+            TOK_PFS_GENERIC_VALUE_LIST ',' TOK_PFS_GENERIC_VALUE
+        */
+        digest_storage->m_byte_count-= 2*PFS_SIZE_OF_A_TOKEN;
+        token= TOK_PFS_GENERIC_VALUE_LIST;
+      }
+      /*
+        Add this token or the resulting reduce to digest storage.
+      */
+      store_token(digest_storage, token);
+      break;
+    }
+    case ')':
+    {
+      if (last_token == TOK_PFS_GENERIC_VALUE &&
+          last_token2 == '(') 
+      { 
+        /*
+          REDUCE:
+          TOK_PFS_ROW_SINGLE_VALUE :=
+            '(' TOK_PFS_GENERIC_VALUE ')' 
+        */
+        digest_storage->m_byte_count-= 2*PFS_SIZE_OF_A_TOKEN;
+        token= TOK_PFS_ROW_SINGLE_VALUE;
+      
+        /* Read last two tokens again */
+        peek_last_two_tokens(digest_storage, state->m_last_id_index,
+                             &last_token, &last_token2);
+
+        if ((last_token2 == TOK_PFS_ROW_SINGLE_VALUE ||
+             last_token2 == TOK_PFS_ROW_SINGLE_VALUE_LIST) &&
+            (last_token == ','))
+        {
+          /*
+            REDUCE:
+            TOK_PFS_ROW_SINGLE_VALUE_LIST := 
+              TOK_PFS_ROW_SINGLE_VALUE ',' TOK_PFS_ROW_SINGLE_VALUE
+
+            REDUCE:
+            TOK_PFS_ROW_SINGLE_VALUE_LIST := 
+              TOK_PFS_ROW_SINGLE_VALUE_LIST ',' TOK_PFS_ROW_SINGLE_VALUE
+          */
+          digest_storage->m_byte_count-= 2*PFS_SIZE_OF_A_TOKEN;
+          token= TOK_PFS_ROW_SINGLE_VALUE_LIST;
+        }
+      }
+      else if (last_token == TOK_PFS_GENERIC_VALUE_LIST &&
+               last_token2 == '(') 
+      {
+        /*
+          REDUCE:
+          TOK_PFS_ROW_MULTIPLE_VALUE :=
+            '(' TOK_PFS_GENERIC_VALUE_LIST ')'
+        */
+        digest_storage->m_byte_count-= 2*PFS_SIZE_OF_A_TOKEN;
+        token= TOK_PFS_ROW_MULTIPLE_VALUE;
+
+        /* Read last two tokens again */
+        peek_last_two_tokens(digest_storage, state->m_last_id_index,
+                             &last_token, &last_token2);
+
+        if ((last_token2 == TOK_PFS_ROW_MULTIPLE_VALUE ||
+             last_token2 == TOK_PFS_ROW_MULTIPLE_VALUE_LIST) &&
+            (last_token == ','))
+        {
+          /*
+            REDUCE:
+            TOK_PFS_ROW_MULTIPLE_VALUE_LIST :=
+              TOK_PFS_ROW_MULTIPLE_VALUE ',' TOK_PFS_ROW_MULTIPLE_VALUE
+
+            REDUCE:
+            TOK_PFS_ROW_MULTIPLE_VALUE_LIST :=
+              TOK_PFS_ROW_MULTIPLE_VALUE_LIST ',' TOK_PFS_ROW_MULTIPLE_VALUE
+          */
+          digest_storage->m_byte_count-= 2*PFS_SIZE_OF_A_TOKEN;
+          token= TOK_PFS_ROW_MULTIPLE_VALUE_LIST;
+        }
+      }
+      /*
+        Add this token or the resulting reduce to digest storage.
+      */
+      store_token(digest_storage, token);
+      break;
+    }
+    case IDENT:
+    case IDENT_QUOTED:
+    {
+      LEX_YYSTYPE *lex_token= (LEX_YYSTYPE*) yylval;
+      char *yytext= lex_token->lex_str.str;
+      int yylen= lex_token->lex_str.length;
+
+      /* Add this token and identifier string to digest storage. */
+      store_token_identifier(digest_storage, token, yylen, yytext);
+
+      /* Update the index of last identifier found. */
+      state->m_last_id_index= digest_storage->m_byte_count;
+      break;
+    }
+    default:
+    {
+      /* Add this token to digest storage. */
+      store_token(digest_storage, token);
+      break;
+    }
+  }
+
+  return locker;
+}

=== added file 'storage/perfschema/pfs_digest.h'
--- a/storage/perfschema/pfs_digest.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/pfs_digest.h	2012-02-28 15:57:52 +0000
@@ -0,0 +1,221 @@
+/* Copyright (c) 2011, 2012, 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,
+  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_DIGEST_H
+#define PFS_DIGEST_H
+
+/**
+  @file storage/perfschema/pfs_digest.h
+  Statement Digest data structures (declarations).
+*/
+
+#include "pfs_column_types.h"
+#include "lf.h"
+#include "pfs_stat.h"
+
+#define PFS_SIZE_OF_A_TOKEN 2
+
+extern bool flag_statements_digest;
+extern ulong digest_max;
+extern ulong digest_lost;
+struct PFS_thread;
+
+/* Fixed, per MD5 hash. */
+#define PFS_MD5_SIZE 16
+
+/**
+  Structure to store a MD5 hash value (digest) for a statement.
+*/
+struct PFS_digest_hash
+{
+  unsigned char m_md5[PFS_MD5_SIZE];
+};
+
+/** A statement digest stat record. */
+struct PFS_statements_digest_stat
+{
+  /**
+    Digest MD5 Hash.
+  */
+  PFS_digest_hash m_digest_hash;
+
+  /**
+    Digest Storage.
+  */
+  PSI_digest_storage m_digest_storage;
+
+  /**
+    Statement stat.
+  */
+  PFS_statement_stat m_stat;
+
+  /**
+    First Seen/last seen.
+  */
+  ulonglong m_first_seen;
+  ulonglong m_last_seen;
+
+  /** Reset data for this record. */
+  void reset_data();
+  /** Reset data and remove index for this record. */
+  void reset_index(PFS_thread *thread);
+};
+
+int init_digest(const PFS_global_param *param);
+void cleanup_digest();
+
+int init_digest_hash(void);
+void cleanup_digest_hash(void);
+PFS_statement_stat* find_or_create_digest(PFS_thread*,
+                                          PSI_digest_storage*);
+
+void get_digest_text(char* digest_text, PSI_digest_storage*);
+
+void reset_esms_by_digest();
+
+/* Exposing the data directly, for iterators. */
+extern PFS_statements_digest_stat *statements_digest_stat_array;
+
+/* Instrumentation callbacks for pfs.cc */
+
+struct PSI_digest_locker* pfs_digest_start_v1(PSI_statement_locker *locker);
+PSI_digest_locker* pfs_digest_add_token_v1(PSI_digest_locker *locker,
+                                           uint token,
+                                           OPAQUE_LEX_YYSTYPE *yylval);
+
+static inline void digest_reset(PSI_digest_storage *digest)
+{
+  digest->m_full= false;
+  digest->m_byte_count= 0;
+}
+
+static inline void digest_copy(PSI_digest_storage *to, const PSI_digest_storage *from)
+{
+  if (from->m_byte_count > 0)
+  {
+    to->m_full= from->m_full;
+    to->m_byte_count= from->m_byte_count;
+    DBUG_ASSERT(to->m_byte_count <= PSI_MAX_DIGEST_STORAGE_SIZE);
+    memcpy(to->m_token_array, from->m_token_array, to->m_byte_count);
+  }
+  else
+  {
+    DBUG_ASSERT(! from->m_full);
+    DBUG_ASSERT(from->m_byte_count == 0);
+    to->m_full= false;
+    to->m_byte_count= 0;
+  }
+}
+
+/** 
+  Function to read a single token from token array.
+*/
+inline int read_token(PSI_digest_storage *digest_storage,
+                      int index, uint *tok)
+{
+  DBUG_ASSERT(index <= digest_storage->m_byte_count);
+  DBUG_ASSERT(digest_storage->m_byte_count <= PSI_MAX_DIGEST_STORAGE_SIZE);
+
+  if (index + PFS_SIZE_OF_A_TOKEN <= digest_storage->m_byte_count)
+  {
+    unsigned char *src= & digest_storage->m_token_array[index];
+    *tok= src[0] | (src[1] << 8);
+    return index + PFS_SIZE_OF_A_TOKEN;
+  }
+
+  /* The input byte stream is exhausted. */
+  *tok= 0;
+  return PSI_MAX_DIGEST_STORAGE_SIZE + 1;
+}
+
+/**
+  Function to store a single token in token array.
+*/
+inline void store_token(PSI_digest_storage* digest_storage, uint token)
+{
+  DBUG_ASSERT(digest_storage->m_byte_count >= 0);
+  DBUG_ASSERT(digest_storage->m_byte_count <= PSI_MAX_DIGEST_STORAGE_SIZE);
+
+  if (digest_storage->m_byte_count + PFS_SIZE_OF_A_TOKEN <= PSI_MAX_DIGEST_STORAGE_SIZE)
+  {
+    unsigned char* dest= & digest_storage->m_token_array[digest_storage->m_byte_count];
+    dest[0]= token & 0xff;
+    dest[1]= (token >> 8) & 0xff;
+    digest_storage->m_byte_count+= PFS_SIZE_OF_A_TOKEN; 
+  }
+  else
+  {
+    digest_storage->m_full= true;
+  }
+}
+
+/**
+  Function to read an identifier from token array.
+*/
+inline int read_identifier(PSI_digest_storage* digest_storage,
+                           int index, char ** id_string, int *id_length)
+{
+  int new_index;
+  DBUG_ASSERT(index <= digest_storage->m_byte_count);
+  DBUG_ASSERT(digest_storage->m_byte_count <= PSI_MAX_DIGEST_STORAGE_SIZE);
+
+  /*
+    token + length + string are written in an atomic way,
+    so we do always expect a length + string here
+  */
+  unsigned char *src= & digest_storage->m_token_array[index];
+  uint length= src[0] | (src[1] << 8);
+  *id_string= (char *) (src + 2);
+  *id_length= length;
+
+  new_index= index + PFS_SIZE_OF_A_TOKEN + length;
+  DBUG_ASSERT(new_index <= digest_storage->m_byte_count);
+  return new_index;
+}
+
+/**
+  Function to store an identifier in token array.
+*/
+inline void store_token_identifier(PSI_digest_storage* digest_storage,
+                                   uint token,
+                                   uint id_length, const char *id_name)
+{
+  DBUG_ASSERT(digest_storage->m_byte_count >= 0);
+  DBUG_ASSERT(digest_storage->m_byte_count <= PSI_MAX_DIGEST_STORAGE_SIZE);
+
+  uint bytes_needed= 2 * PFS_SIZE_OF_A_TOKEN + id_length;
+  if (digest_storage->m_byte_count + bytes_needed <= PSI_MAX_DIGEST_STORAGE_SIZE)
+  {
+    unsigned char* dest= & digest_storage->m_token_array[digest_storage->m_byte_count];
+    /* Write the token */
+    dest[0]= token & 0xff;
+    dest[1]= (token >> 8) & 0xff;
+    /* Write the string length */
+    dest[2]= id_length & 0xff;
+    dest[3]= (id_length >> 8) & 0xff;
+    /* Write the string data */
+    if (id_length > 0)
+    {
+      strncpy((char *)(dest + 4), id_name, id_length);
+    }
+    digest_storage->m_byte_count+= bytes_needed; 
+  }
+  else
+  {
+    digest_storage->m_full= true;
+  }
+}
+
+#endif

=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc	2012-02-24 00:57:57 +0000
+++ b/storage/perfschema/pfs_engine_table.cc	2012-02-28 14:40:36 +0000
@@ -60,6 +60,7 @@
 #include "table_esms_by_user_by_event_name.h"
 #include "table_esms_by_account_by_event_name.h"
 #include "table_esms_global_by_event_name.h"
+#include "table_esms_by_digest.h"
 
 #include "table_users.h"
 #include "table_accounts.h"
@@ -76,6 +77,7 @@
 #include "pfs_setup_actor.h"
 #include "pfs_setup_object.h"
 #include "pfs_global.h"
+#include "pfs_digest.h"
 
 #include "sql_base.h"                           // close_thread_tables
 #include "lock.h"                               // MYSQL_LOCK_IGNORE_TIMEOUT
@@ -132,6 +134,7 @@ static PFS_engine_table_share *all_share
   &table_esms_by_user_by_event_name::m_share,
   &table_esms_by_host_by_event_name::m_share,
   &table_esms_global_by_event_name::m_share,
+  &table_esms_by_digest::m_share,
 
   &table_users::m_share,
   &table_accounts::m_share,
@@ -1315,11 +1318,24 @@ bool pfs_show_status(handlerton *hton, T
       size= socket_max * sizeof(PFS_socket);
       total_memory+= size;
       break;
+    case 134:
+      name= "events_statements_summary_by_digest.row_size";
+      size= sizeof(PFS_statements_digest_stat);
+      break;
+    case 135:
+      name= "events_statements_summary_by_digest.row_count";
+      size= digest_max;
+      break;
+    case 136:
+      name= "events_statements_summary_by_digest.memory";
+      size= digest_max * sizeof(PFS_statements_digest_stat);
+      total_memory+= size;
+      break;    
     /*
       This case must be last,
       for aggregation in total_memory.
     */
-    case 134:
+    case 137:
       name= "performance_schema.memory";
       size= total_memory;
       /* This will fail if something is not advertised here */

=== modified file 'storage/perfschema/pfs_events_statements.h'
--- a/storage/perfschema/pfs_events_statements.h	2011-07-07 19:06:44 +0000
+++ b/storage/perfschema/pfs_events_statements.h	2012-02-21 18:27:58 +0000
@@ -23,6 +23,7 @@
 
 #include "pfs_column_types.h"
 #include "pfs_events.h"
+#include "pfs_digest.h"
 
 struct PFS_thread;
 struct PFS_account;
@@ -43,7 +44,7 @@ struct PFS_events_statements : public PF
 
   /** Locked time. */
   ulonglong m_lock_time;
-
+  
   /** Diagnostics area, message text. */
   char m_message_text[MYSQL_ERRMSG_SIZE+1];
   /** Diagnostics area, error number. */
@@ -87,6 +88,8 @@ struct PFS_events_statements : public PF
   ulonglong m_no_index_used;
   /** Optimizer metric, number of 'no good index used'. */
   ulonglong m_no_good_index_used;
+  /** Statement digest. */
+  PSI_digest_storage m_digest_storage;
 };
 
 void insert_events_statements_history(PFS_thread *thread, PFS_events_statements *statement);

=== modified file 'storage/perfschema/pfs_events_waits.h'
--- a/storage/perfschema/pfs_events_waits.h	2011-08-11 03:11:58 +0000
+++ b/storage/perfschema/pfs_events_waits.h	2012-02-21 18:27:58 +0000
@@ -96,6 +96,15 @@ struct PFS_events_waits : public PFS_eve
   ulong m_flags;
 };
 
+/** TIMED bit in the state flags bitfield. */
+#define STATE_FLAG_TIMED (1<<0)
+/** THREAD bit in the state flags bitfield. */
+#define STATE_FLAG_THREAD (1<<1)
+/** EVENT bit in the state flags bitfield. */
+#define STATE_FLAG_EVENT (1<<2)
+/** DIGEST bit in the state flags bitfield. */
+#define STATE_FLAG_DIGEST (1<<3)
+
 void insert_events_waits_history(PFS_thread *thread, PFS_events_waits *wait);
 
 void insert_events_waits_history_long(PFS_events_waits *wait);

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2012-01-06 09:03:53 +0000
+++ b/storage/perfschema/pfs_instr.cc	2012-02-23 23:27:02 +0000
@@ -836,6 +836,7 @@ PFS_thread* create_thread(PFS_thread_cla
         pfs->m_user_hash_pins= NULL;
         pfs->m_account_hash_pins= NULL;
         pfs->m_host_hash_pins= NULL;
+        pfs->m_digest_hash_pins= NULL;
 
         pfs->m_username_length= 0;
         pfs->m_hostname_length= 0;
@@ -1025,6 +1026,11 @@ void destroy_thread(PFS_thread *pfs)
     lf_hash_put_pins(pfs->m_host_hash_pins);
     pfs->m_host_hash_pins= NULL;
   }
+  if (pfs->m_digest_hash_pins)
+  {
+    lf_hash_put_pins(pfs->m_digest_hash_pins);
+    pfs->m_digest_hash_pins= NULL;
+  }
   pfs->m_lock.allocated_to_free();
 }
 

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2012-01-06 09:03:53 +0000
+++ b/storage/perfschema/pfs_instr.h	2012-02-23 23:27:02 +0000
@@ -397,6 +397,8 @@ struct PFS_thread : PFS_connection_slice
   LF_PINS *m_user_hash_pins;
   /** Pins for account_hash. */
   LF_PINS *m_account_hash_pins;
+  /** Pins for digest_hash. */
+  LF_PINS *m_digest_hash_pins;
   /** Internal thread identifier, unique. */
   ulong m_thread_internal_id;
   /** Parent internal thread identifier. */

=== modified file 'storage/perfschema/pfs_server.cc'
--- a/storage/perfschema/pfs_server.cc	2012-01-26 17:49:01 +0000
+++ b/storage/perfschema/pfs_server.cc	2012-02-11 20:33:44 +0000
@@ -36,6 +36,7 @@
 #include "pfs_user.h"
 #include "pfs_account.h"
 #include "pfs_defaults.h"
+#include "pfs_digest.h"
 
 PFS_global_param pfs_param;
 
@@ -102,7 +103,9 @@ initialize_performance_schema(const PFS_
       init_user(param) ||
       init_user_hash() ||
       init_account(param) ||
-      init_account_hash())
+      init_account_hash() ||
+      init_digest(param) ||
+      init_digest_hash())
   {
     /*
       The performance schema initialization failed.
@@ -126,6 +129,7 @@ initialize_performance_schema(const PFS_
   flag_events_waits_history_long=      param->m_consumer_events_waits_history_long_enabled;
   flag_global_instrumentation=         param->m_consumer_global_instrumentation_enabled;
   flag_thread_instrumentation=         param->m_consumer_thread_instrumentation_enabled;
+  flag_statements_digest=              param->m_consumer_statement_digest_enabled;
 
   install_default_setup(&PFS_bootstrap);
   return &PFS_bootstrap;
@@ -177,6 +181,7 @@ static void cleanup_performance_schema(v
   cleanup_user_hash();
   cleanup_account();
   cleanup_account_hash();
+  cleanup_digest();
   PFS_atomic::cleanup();
 */
 }

=== modified file 'storage/perfschema/pfs_server.h'
--- a/storage/perfschema/pfs_server.h	2011-11-17 21:44:20 +0000
+++ b/storage/perfschema/pfs_server.h	2011-12-19 19:08:09 +0000
@@ -105,6 +105,9 @@
 #ifndef PFS_STATEMENTS_STACK_SIZE
   #define PFS_STATEMENTS_STACK_SIZE 10
 #endif
+#ifndef PFS_DIGEST_SIZE
+  #define PFS_DIGEST_SIZE 200
+#endif
 
 /** Performance schema global sizing parameters. */
 struct PFS_global_param
@@ -123,6 +126,7 @@ struct PFS_global_param
   bool m_consumer_events_waits_history_long_enabled;
   bool m_consumer_global_instrumentation_enabled;
   bool m_consumer_thread_instrumentation_enabled;
+  bool m_consumer_statement_digest_enabled;
 
   /** Default instrument configuration option. */
   char *m_pfs_instrument;
@@ -234,6 +238,8 @@ struct PFS_global_param
   ulong m_events_statements_history_sizing;
   /** Maximum number of rows in table EVENTS_STATEMENTS_HISTORY_LONG. */
   ulong m_events_statements_history_long_sizing;
+  /** Maximum number of digests to be captured */
+  ulong m_digest_sizing;
 };
 
 /**

=== added file 'storage/perfschema/table_esms_by_digest.cc'
--- a/storage/perfschema/table_esms_by_digest.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_esms_by_digest.cc	2012-02-23 23:27:02 +0000
@@ -0,0 +1,325 @@
+/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  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_esms_by_digest.cc
+  Table EVENTS_STATEMENTS_SUMMARY_GLOBAL_BY_DIGEST (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_esms_by_digest.h"
+#include "pfs_global.h"
+#include "pfs_instr.h"
+#include "pfs_timer.h"
+#include "pfs_visitor.h"
+#include "table_esms_by_digest.h"
+#include "pfs_digest.h"
+
+THR_LOCK table_esms_by_digest::m_table_lock;
+
+static const TABLE_FIELD_TYPE field_types[]=
+{
+  {
+    { C_STRING_WITH_LEN("DIGEST") },
+    { C_STRING_WITH_LEN("varchar(32)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("DIGEST_TEXT") },
+    { C_STRING_WITH_LEN("longtext") },
+    { 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("SUM_LOCK_TIME") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_ERRORS") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_WARNINGS") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_ROWS_AFFECTED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_ROWS_SENT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_ROWS_EXAMINED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_CREATED_TMP_DISK_TABLES") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_CREATED_TMP_TABLES") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SELECT_FULL_JOIN") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SELECT_FULL_RANGE_JOIN") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SELECT_RANGE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SELECT_RANGE_CHECK") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SELECT_SCAN") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SORT_MERGE_PASSES") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SORT_RANGE") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SORT_ROWS") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_SORT_SCAN") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_NO_INDEX_USED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_NO_GOOD_INDEX_USED") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("FIRST_SEEN") },
+    { C_STRING_WITH_LEN("timestamp") },
+    { NULL, 0}
+  },
+  { 
+    { C_STRING_WITH_LEN("LAST_SEEN") },
+    { C_STRING_WITH_LEN("timestamp") },
+    { NULL, 0}
+  }
+};
+
+TABLE_FIELD_DEF
+table_esms_by_digest::m_field_def=
+{ 28, field_types };
+
+PFS_engine_table_share
+table_esms_by_digest::m_share=
+{
+  { C_STRING_WITH_LEN("events_statements_summary_by_digest") },
+  &pfs_truncatable_acl,
+  table_esms_by_digest::create,
+  NULL, /* write_row */
+  table_esms_by_digest::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_esms_by_digest::create(void)
+{
+  return new table_esms_by_digest();
+}
+
+int
+table_esms_by_digest::delete_all_rows(void)
+{
+  reset_esms_by_digest();
+  return 0;
+}
+
+table_esms_by_digest::table_esms_by_digest()
+  : PFS_engine_table(&m_share, &m_pos),
+    m_row_exists(false), m_pos(0), m_next_pos(0)
+{}
+
+void table_esms_by_digest::reset_position(void)
+{
+  m_pos= 0;
+  m_next_pos= 0;
+}
+
+int table_esms_by_digest::rnd_next(void)
+{
+  PFS_statements_digest_stat* digest_stat;
+
+  if (statements_digest_stat_array == NULL)
+    return HA_ERR_END_OF_FILE;
+
+  for (m_pos.set_at(&m_next_pos);
+       m_pos.m_index < digest_max;
+       m_pos.next())
+  {
+    digest_stat= &statements_digest_stat_array[m_pos.m_index];
+    if (digest_stat->m_first_seen != 0)
+    {
+      make_row(digest_stat);
+      m_next_pos.set_after(&m_pos);
+      return 0;
+    }
+  }
+
+  return HA_ERR_END_OF_FILE;
+}
+
+int
+table_esms_by_digest::rnd_pos(const void *pos)
+{
+  PFS_statements_digest_stat* digest_stat;
+
+  if (statements_digest_stat_array == NULL)
+    return HA_ERR_END_OF_FILE;
+
+  set_position(pos);
+  digest_stat= &statements_digest_stat_array[m_pos.m_index];
+
+  if (digest_stat->m_first_seen != 0)
+  {
+    make_row(digest_stat);
+    return 0;
+  }
+
+  return HA_ERR_RECORD_DELETED;
+}
+
+
+void table_esms_by_digest::make_row(PFS_statements_digest_stat* digest_stat)
+{
+  m_row_exists= false;
+  m_row.m_first_seen= digest_stat->m_first_seen;
+  m_row.m_last_seen= digest_stat->m_last_seen;
+  m_row.m_digest.make_row(digest_stat);
+
+  /*
+    Get statements stats.
+  */
+  time_normalizer *normalizer= time_normalizer::get(statement_timer);
+  m_row.m_stat.set(normalizer, & digest_stat->m_stat);
+
+  m_row_exists= true;
+}
+
+int table_esms_by_digest
+::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. It indicates how many fields could be null
+    in the table.
+  */
+  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: /* DIGEST */
+      case 1: /* DIGEST_TEXT */
+        m_row.m_digest.set_field(f->field_index, f);
+        break;
+      case 26: /* FIRST_SEEN */
+        set_field_timestamp(f, m_row.m_first_seen);
+        break;
+      case 27: /* LAST_SEEN */
+        set_field_timestamp(f, m_row.m_last_seen);
+        break;
+      default: /* 1, ... COUNT/SUM/MIN/AVG/MAX */
+        m_row.m_stat.set_field(f->field_index - 2, f);
+        break;
+      }
+    }
+  }
+
+  return 0;
+}
+

=== added file 'storage/perfschema/table_esms_by_digest.h'
--- a/storage/perfschema/table_esms_by_digest.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_esms_by_digest.h	2012-02-02 12:04:43 +0000
@@ -0,0 +1,95 @@
+/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  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_ESMS_BY_DIGEST_H
+#define TABLE_ESMS_BY_DIGEST_H
+
+/**
+  @file storage/perfschema/table_esms_by_digest.h
+  Table EVENTS_STATEMENTS_SUMMARY_BY_DIGEST (declarations).
+*/
+
+#include "table_helper.h"
+#include "pfs_digest.h"
+
+/**
+  @addtogroup Performance_schema_tables
+  @{
+*/
+
+/**
+  A row of table
+  PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST.
+*/
+struct row_esms_by_digest
+{
+  /** Columns DIGEST/DIGEST_TEXT. */
+  PFS_digest_row m_digest;
+
+  /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
+  PFS_statement_stat_row m_stat;
+
+  /** Column FIRST_SEEN. */
+  ulonglong m_first_seen;
+  /** Column LAST_SEEN. */
+  ulonglong m_last_seen;
+};
+
+/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST. */
+class table_esms_by_digest : 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_esms_by_digest();
+
+public:
+  ~table_esms_by_digest()
+  {}
+
+protected:
+  void make_row(PFS_statements_digest_stat*);
+
+private:
+  /** Table share lock. */
+  static THR_LOCK m_table_lock;
+  /** Fields definition. */
+  static TABLE_FIELD_DEF m_field_def;
+
+  /** Current row. */
+  row_esms_by_digest 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

=== modified file 'storage/perfschema/table_events_statements.cc'
--- a/storage/perfschema/table_events_statements.cc	2012-01-24 23:42:36 +0000
+++ b/storage/perfschema/table_events_statements.cc	2012-02-29 14:43:11 +0000
@@ -27,6 +27,7 @@
 #include "pfs_timer.h"
 #include "sp_head.h" /* TYPE_ENUM_FUNCTION, ... */
 #include "table_helper.h"
+#include "my_md5.h"
 
 THR_LOCK table_events_statements_current::m_table_lock;
 
@@ -83,6 +84,16 @@ static const TABLE_FIELD_TYPE field_type
     { NULL, 0}
   },
   {
+    { C_STRING_WITH_LEN("DIGEST") },
+    { C_STRING_WITH_LEN("varchar(32)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("DIGEST_TEXT") },
+    { C_STRING_WITH_LEN("longtext") },
+    { NULL, 0}
+  },
+  {
     { C_STRING_WITH_LEN("CURRENT_SCHEMA") },
     { C_STRING_WITH_LEN("varchar(64)") },
     { NULL, 0}
@@ -226,7 +237,7 @@ static const TABLE_FIELD_TYPE field_type
 
 TABLE_FIELD_DEF
 table_events_statements_current::m_field_def=
-{38 , field_types };
+{40 , field_types };
 
 PFS_engine_table_share
 table_events_statements_current::m_share=
@@ -355,6 +366,31 @@ void table_events_statements_common::mak
   m_row.m_sort_scan= statement->m_sort_scan;
   m_row.m_no_index_used= statement->m_no_index_used;
   m_row.m_no_good_index_used= statement->m_no_good_index_used;
+  /* 
+    Filling up statement digest information.
+  */
+  PSI_digest_storage *digest= & statement->m_digest_storage;
+  if (digest->m_byte_count > 0)
+  {
+    PFS_digest_hash md5;
+    compute_md5_hash((char *) md5.m_md5,
+                     (char *) digest->m_token_array,
+                     digest->m_byte_count);
+
+    /* Generate the DIGEST string from the MD5 digest  */
+    MD5_HASH_TO_STRING(md5.m_md5,
+                       m_row.m_digest.m_digest);
+    m_row.m_digest.m_digest_length= MD5_HASH_TO_STRING_LENGTH;
+
+    /* Generate the DIGEST_TEXT string from the token array */
+    get_digest_text(m_row.m_digest.m_digest_text, digest);
+    m_row.m_digest.m_digest_text_length= strlen(m_row.m_digest.m_digest_text);
+  }
+  else
+  {
+    m_row.m_digest.m_digest_length= 0;
+    m_row.m_digest.m_digest_text_length= 0;
+  }
 
   m_row_exists= true;
   return;
@@ -372,9 +408,10 @@ int table_events_statements_common::read
     return HA_ERR_RECORD_DELETED;
 
   /* Set the null bits */
-  DBUG_ASSERT(table->s->null_bytes == 2);
+  DBUG_ASSERT(table->s->null_bytes == 3);
   buf[0]= 0;
   buf[1]= 0;
+  buf[2]= 0;
 
   for (; (f= *fields) ; fields++)
   {
@@ -430,101 +467,115 @@ int table_events_statements_common::read
         else
           f->set_null();
         break;
-      case 10: /* CURRENT_SCHEMA */
+      case 10: /* DIGEST */
+        if (m_row.m_digest.m_digest_length > 0)
+          set_field_varchar_utf8(f, m_row.m_digest.m_digest,
+                                 m_row.m_digest.m_digest_length);
+        else
+          f->set_null();
+        break;
+      case 11: /* DIGEST_TEXT */
+        if (m_row.m_digest.m_digest_text_length > 0)
+           set_field_longtext_utf8(f, m_row.m_digest.m_digest_text,
+                                   m_row.m_digest.m_digest_text_length);
+        else
+          f->set_null();
+        break;
+      case 12: /* CURRENT_SCHEMA */
         if (m_row.m_current_schema_name_length)
           set_field_varchar_utf8(f, m_row.m_current_schema_name, m_row.m_current_schema_name_length);
         else
           f->set_null();
         break;
-      case 11: /* OBJECT_TYPE */
+      case 13: /* OBJECT_TYPE */
         f->set_null();
         break;
-      case 12: /* OBJECT_SCHEMA */
+      case 14: /* OBJECT_SCHEMA */
         f->set_null();
         break;
-      case 13: /* OBJECT_NAME */
+      case 15: /* OBJECT_NAME */
         f->set_null();
         break;
-      case 14: /* OBJECT_INSTANCE_BEGIN */
+      case 16: /* OBJECT_INSTANCE_BEGIN */
         f->set_null();
         break;
-      case 15: /* MYSQL_ERRNO */
+      case 17: /* MYSQL_ERRNO */
         set_field_ulong(f, m_row.m_sql_errno);
         break;
-      case 16: /* RETURNED_SQLSTATE */
+      case 18: /* RETURNED_SQLSTATE */
         if (m_row.m_sqlstate[0] != 0)
           set_field_varchar_utf8(f, m_row.m_sqlstate, SQLSTATE_LENGTH);
         else
           f->set_null();
         break;
-      case 17: /* MESSAGE_TEXT */
+      case 19: /* MESSAGE_TEXT */
         len= strlen(m_row.m_message_text);
         if (len)
           set_field_varchar_utf8(f, m_row.m_message_text, len);
         else
           f->set_null();
         break;
-      case 18: /* ERRORS */
+      case 20: /* ERRORS */
         set_field_ulonglong(f, m_row.m_error_count);
         break;
-      case 19: /* WARNINGS */
+      case 21: /* WARNINGS */
         set_field_ulonglong(f, m_row.m_warning_count);
         break;
-      case 20: /* ROWS_AFFECTED */
+      case 22: /* ROWS_AFFECTED */
         set_field_ulonglong(f, m_row.m_rows_affected);
         break;
-      case 21: /* ROWS_SENT */
+      case 23: /* ROWS_SENT */
         set_field_ulonglong(f, m_row.m_rows_sent);
         break;
-      case 22: /* ROWS_EXAMINED */
+      case 24: /* ROWS_EXAMINED */
         set_field_ulonglong(f, m_row.m_rows_examined);
         break;
-      case 23: /* CREATED_TMP_DISK_TABLES */
+      case 25: /* CREATED_TMP_DISK_TABLES */
         set_field_ulonglong(f, m_row.m_created_tmp_disk_tables);
         break;
-      case 24: /* CREATED_TMP_TABLES */
+      case 26: /* CREATED_TMP_TABLES */
         set_field_ulonglong(f, m_row.m_created_tmp_tables);
         break;
-      case 25: /* SELECT_FULL_JOIN */
+      case 27: /* SELECT_FULL_JOIN */
         set_field_ulonglong(f, m_row.m_select_full_join);
         break;
-      case 26: /* SELECT_FULL_RANGE_JOIN */
+      case 28: /* SELECT_FULL_RANGE_JOIN */
         set_field_ulonglong(f, m_row.m_select_full_range_join);
         break;
-      case 27: /* SELECT_RANGE */
+      case 29: /* SELECT_RANGE */
         set_field_ulonglong(f, m_row.m_select_range);
         break;
-      case 28: /* SELECT_RANGE_CHECK */
+      case 30: /* SELECT_RANGE_CHECK */
         set_field_ulonglong(f, m_row.m_select_range_check);
         break;
-      case 29: /* SELECT_SCAN */
+      case 31: /* SELECT_SCAN */
         set_field_ulonglong(f, m_row.m_select_scan);
         break;
-      case 30: /* SORT_MERGE_PASSES */
+      case 32: /* SORT_MERGE_PASSES */
         set_field_ulonglong(f, m_row.m_sort_merge_passes);
         break;
-      case 31: /* SORT_RANGE */
+      case 33: /* SORT_RANGE */
         set_field_ulonglong(f, m_row.m_sort_range);
         break;
-      case 32: /* SORT_ROWS */
+      case 34: /* SORT_ROWS */
         set_field_ulonglong(f, m_row.m_sort_rows);
         break;
-      case 33: /* SORT_SCAN */
+      case 35: /* SORT_SCAN */
         set_field_ulonglong(f, m_row.m_sort_scan);
         break;
-      case 34: /* NO_INDEX_USED */
+      case 36: /* NO_INDEX_USED */
         set_field_ulonglong(f, m_row.m_no_index_used);
         break;
-      case 35: /* NO_GOOD_INDEX_USED */
+      case 37: /* NO_GOOD_INDEX_USED */
         set_field_ulonglong(f, m_row.m_no_good_index_used);
         break;
-      case 36: /* NESTING_EVENT_ID */
+      case 38: /* NESTING_EVENT_ID */
         if (m_row.m_nesting_event_id != 0)
           set_field_ulonglong(f, m_row.m_nesting_event_id);
         else
           f->set_null();
         break;
-      case 37: /* NESTING_EVENT_TYPE */
+      case 39: /* NESTING_EVENT_TYPE */
         if (m_row.m_nesting_event_id != 0)
           set_field_enum(f, m_row.m_nesting_event_type);
         else

=== modified file 'storage/perfschema/table_events_statements.h'
--- a/storage/perfschema/table_events_statements.h	2012-01-24 23:42:36 +0000
+++ b/storage/perfschema/table_events_statements.h	2012-02-23 23:27:02 +0000
@@ -24,6 +24,7 @@
 #include "pfs_column_types.h"
 #include "pfs_engine_table.h"
 #include "pfs_events_statements.h"
+#include "table_helper.h"
 
 struct PFS_thread;
 
@@ -63,6 +64,8 @@ struct row_events_statements
   uint m_source_length;
   /** Column SQL_TEXT. */
   char m_sqltext[COL_INFO_SIZE];
+  /** Column DIGEST and DIGEST_TEXT. */
+  PFS_digest_row m_digest;
   /** Length in bytes of @c m_info. */
   uint m_sqltext_length;
   /** Column CURRENT_SCHEMA. */

=== modified file 'storage/perfschema/table_helper.cc'
--- a/storage/perfschema/table_helper.cc	2011-05-07 00:40:25 +0000
+++ b/storage/perfschema/table_helper.cc	2012-02-23 23:27:02 +0000
@@ -101,6 +101,62 @@ void PFS_account_row::set_field(uint ind
   }
 }
 
+int PFS_digest_row::make_row(PFS_statements_digest_stat* pfs)
+{
+  /*
+    "0" value for byte_count indicates special entry i.e. aggregated
+    stats at index 0 of statements_digest_stat_array. So do not calculate
+    digest/digest_text as it should always be "NULL".
+  */
+  if (pfs->m_digest_storage.m_byte_count != 0)
+  {
+    /*
+      Calculate digest from MD5 HASH collected to be shown as
+      DIGEST in this row.
+    */
+    MD5_HASH_TO_STRING(pfs->m_digest_hash.m_md5, m_digest);
+    m_digest_length= MD5_HASH_TO_STRING_LENGTH;
+
+    /* 
+      Caclulate digest_text information from the token array collected
+      to be shown as DIGEST_TEXT column.
+    */ 
+    get_digest_text(m_digest_text, &pfs->m_digest_storage);
+    m_digest_text_length= strlen(m_digest_text);
+  }
+  else
+  {
+    m_digest_length= 0;
+    m_digest_text_length= 0;
+  }
+  
+  return 0;
+}
+
+void PFS_digest_row::set_field(uint index, Field *f)
+{
+  switch (index)
+  {
+    case 0: /* DIGEST */
+      if (m_digest_length > 0)
+        PFS_engine_table::set_field_varchar_utf8(f, m_digest,
+                                                 m_digest_length);
+      else
+        f->set_null();
+      break;
+    case 1: /* DIGEST_TEXT */
+      if (m_digest_text_length > 0)
+        PFS_engine_table::set_field_longtext_utf8(f, m_digest_text,
+                                                  m_digest_text_length);
+      else
+        f->set_null();
+      break;
+    default:
+      DBUG_ASSERT(false);
+      break;
+  }
+}
+
 int PFS_object_row::make_row(PFS_table_share *pfs)
 {
   m_object_type= pfs->get_object_type();

=== modified file 'storage/perfschema/table_helper.h'
--- a/storage/perfschema/table_helper.h	2011-09-02 20:03:36 +0000
+++ b/storage/perfschema/table_helper.h	2012-02-21 18:27:58 +0000
@@ -21,6 +21,21 @@
 #include "pfs_timer.h"
 #include "pfs_engine_table.h"
 #include "pfs_instr_class.h"
+#include "pfs_digest.h"
+
+/*
+  Write MD5 hash value in a string to be used 
+  as DIGEST for the statement.
+*/
+#define MD5_HASH_TO_STRING(_hash, _str)                    \
+  sprintf(_str, "%02x%02x%02x%02x%02x%02x%02x%02x"         \
+                "%02x%02x%02x%02x%02x%02x%02x%02x",        \
+          _hash[0], _hash[1], _hash[2], _hash[3],          \
+          _hash[4], _hash[5], _hash[6], _hash[7],          \
+          _hash[8], _hash[9], _hash[10], _hash[11],        \
+          _hash[12], _hash[13], _hash[14], _hash[15])
+
+#define MD5_HASH_TO_STRING_LENGTH 32
 
 struct PFS_host;
 struct PFS_user;
@@ -108,6 +123,24 @@ struct PFS_account_row
   /** Set a table field from the row. */
   void set_field(uint index, Field *f);
 };
+
+/** Row fragment for columns DIGEST, DIGEST_TEXT. */
+struct PFS_digest_row
+{
+  /** Column DIGEST. */
+  char m_digest[COL_DIGEST_SIZE];
+  /** Length in bytes of @c m_digest. */
+  uint m_digest_length;
+  /** Column DIGEST_TEXT. */
+  char m_digest_text[COL_DIGEST_TEXT_SIZE];
+  /** Length in bytes of @c m_digest_text. */
+  uint m_digest_text_length;
+
+  /** Build a row from a memory buffer. */
+  int make_row(PFS_statements_digest_stat*);
+  /** Set a table field from the row. */
+  void set_field(uint index, Field *f);
+};
 
 /** Row fragment for column EVENT_NAME. */
 struct PFS_event_name_row

=== modified file 'storage/perfschema/table_setup_consumers.cc'
--- a/storage/perfschema/table_setup_consumers.cc	2011-07-06 18:58:53 +0000
+++ b/storage/perfschema/table_setup_consumers.cc	2011-12-19 19:08:09 +0000
@@ -23,8 +23,9 @@
 #include "table_setup_consumers.h"
 #include "pfs_instr.h"
 #include "pfs_events_waits.h"
+#include "pfs_digest.h"
 
-#define COUNT_SETUP_CONSUMERS 11
+#define COUNT_SETUP_CONSUMERS 12
 static row_setup_consumers all_setup_consumers_data[COUNT_SETUP_CONSUMERS]=
 {
   {
@@ -81,6 +82,11 @@ static row_setup_consumers all_setup_con
     { C_STRING_WITH_LEN("thread_instrumentation") },
     &flag_thread_instrumentation,
     false
+  },
+  {
+    { C_STRING_WITH_LEN("statements_digest") },
+    &flag_statements_digest,
+    false
   }
 };
 

=== modified file 'storage/perfschema/unittest/pfs-t.cc'
--- a/storage/perfschema/unittest/pfs-t.cc	2012-01-06 09:03:53 +0000
+++ b/storage/perfschema/unittest/pfs-t.cc	2012-01-09 09:09:26 +0000
@@ -110,6 +110,7 @@ void test_bootstrap()
   param.m_statement_class_sizing= 0;
   param.m_events_statements_history_sizing= 0;
   param.m_events_statements_history_long_sizing= 0;
+  param.m_digest_sizing= 0;
 
   boot= initialize_performance_schema(& param);
   ok(boot != NULL, "boot");
@@ -166,6 +167,7 @@ PSI * load_perfschema()
   param.m_statement_class_sizing= 0;
   param.m_events_statements_history_sizing= 0;
   param.m_events_statements_history_long_sizing= 0;
+  param.m_digest_sizing= 0;
 
   /* test_bootstrap() covered this, assuming it just works */
   boot= initialize_performance_schema(& param);
@@ -1506,6 +1508,7 @@ void test_event_name_index()
   param.m_statement_class_sizing= 0;
   param.m_events_statements_history_sizing= 0;
   param.m_events_statements_history_long_sizing= 0;
+  param.m_digest_sizing= 0;
 
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;

=== modified file 'storage/perfschema/unittest/stub_server_misc.h'
--- a/storage/perfschema/unittest/stub_server_misc.h	2010-12-02 15:05:07 +0000
+++ b/storage/perfschema/unittest/stub_server_misc.h	2012-02-20 20:56:20 +0000
@@ -22,3 +22,7 @@ volatile bool ready_to_exit= false;
 uint lower_case_table_names= 0;
 CHARSET_INFO *files_charset_info= NULL;
 
+extern "C" void compute_md5_hash(char *, const char *, int)
+{
+}
+

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (marc.alff:3704 to 3705) WL#5767Marc Alff5 Mar