List:Commits« Previous MessageNext Message »
From:Mayank Prasad Date:January 17 2012 10:16am
Subject:bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3417 to 3418) WL#5767
View as plain text  
 3418 Mayank Prasad	2012-01-17
      WL#5767 : Performance Schema, Statements Digest.
      
      Details:
       - Added code for handling INDEX 0 entries i.e. DIGEST=NULL
         entries when digest table is full. All records would be aggregated 
         at index 0.
       - Added/Modified test cases/result.
       - Few code cleanup.

    modified:
      mysql-test/suite/perfschema/r/start_server_no_digests.result
      mysql-test/suite/perfschema/r/statements_digest.result
      mysql-test/suite/perfschema/r/statements_digest_long_query.result
      mysql-test/suite/perfschema/t/start_server_no_digests.test
      mysql-test/suite/perfschema/t/statements_digest_long_query.test
      storage/perfschema/pfs_digest.cc
      storage/perfschema/table_esms_by_digest.cc
      storage/perfschema/table_helper.cc
 3417 Mayank Prasad	2012-01-17
      WL#5767: Statements Digest, Performance Schema.
      
      Details:
       - Added multiple test cases suggested by Mark.
       - Fixed few issues, found in unit testing.

    added:
      mysql-test/suite/perfschema/r/start_server_no_digests.result
      mysql-test/suite/perfschema/r/statements_digest_long_query.result
      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/statements_digest_long_query-master.opt
      mysql-test/suite/perfschema/t/statements_digest_long_query.test
    modified:
      mysql-test/suite/perfschema/r/statements_digest.result
      mysql-test/suite/perfschema/t/statements_digest.test
      storage/perfschema/pfs_digest.cc
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_digests.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_digests.result	2012-01-16 19:07:57 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_digests.result	2012-01-17 10:15:06 +0000
@@ -77,3 +77,9 @@ drop table if exists t3;
 drop table if exists t4;
 drop table if exists t5;
 drop database if exists statements_digest;
+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

=== modified file 'mysql-test/suite/perfschema/r/statements_digest.result'
--- a/mysql-test/suite/perfschema/r/statements_digest.result	2012-01-16 19:07:57 +0000
+++ b/mysql-test/suite/perfschema/r/statements_digest.result	2012-01-17 10:15:06 +0000
@@ -67,6 +67,7 @@ drop database statements_digest_temp;
 use performance_schema;
 select DIGEST, DIGEST_TEXT, COUNT_STAR from events_statements_summary_by_digest;
 DIGEST	DIGEST_TEXT	COUNT_STAR
+NULL	NULL	0
 560c2f53c356e1db	TRUNCATE TABLE performance_schema . events_statements_summa  	1
 c4cdaf6f814e367d	SELECT # FROM t1  	1
 58681943ba1f6965	SELECT #,# FROM t1  	2

=== modified file 'mysql-test/suite/perfschema/r/statements_digest_long_query.result'
--- a/mysql-test/suite/perfschema/r/statements_digest_long_query.result	2012-01-16 19:07:57 +0000
+++ b/mysql-test/suite/perfschema/r/statements_digest_long_query.result	2012-01-17 10:15:06 +0000
@@ -1,16 +1,13 @@
+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
 ####################################
-use performance_schema;
 select DIGEST, DIGEST_TEXT, COUNT_STAR from events_statements_summary_by_digest;
 DIGEST	DIGEST_TEXT	COUNT_STAR
-53d366fdef334a13	SHOW SLAVE STATUS  	1
-1d209183a31878c9	SELECT # = #  	1
-7ba62db17590c5f8	CREATE DEFINER = `root` @ `localhost` PROCEDURE `check_testcase_perfsch ( ) BEGIN IF ( ( SELECT COUNT ( * ) FROM information_schema . engines WHERE ENGINE = # AND support = # ) = # ) THEN BEGIN BEGIN DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END ; SELECT * FROM performance_schema . setup_instruments WHERE enabled = # ORDER BY NAME ; END ; SELECT * FROM performance_schema . setup_consumers ORDER BY NAME ; SELECT * FROM performance_schema . setup_actors ORDER BY SYSTEM_USER , HOST ; SELECT * FROM performance_schema . setup_objects ORDER BY OBJECT_TYPE , OBJECT_SCHEMA , OBJECT_NAME ; END ; END IF ; END  	2
-f94aaadffce30475	SELECT version ( ) LIKE # AS #  	1
-facecdf9454ad82c	SELECT COUNT ( * ) FROM information_schema . engines WHERE ( support = # OR support = # ) AND ENGINE = #  	1
+NULL	NULL	0
+553022034e2aab0f	TRUNCATE TABLE events_statements_summa  	1
 ba5a568f3d3dcc06	SELECT # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + !
 # + # + # + # + # + # + # + # + # + # + # + # + # ...	1
-33c8d4d29d3c02f3	USE performance_schema  	1

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_digests.test'
--- a/mysql-test/suite/perfschema/t/start_server_no_digests.test	2012-01-16 19:07:57 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_digests.test	2012-01-17 10:15:06 +0000
@@ -7,4 +7,8 @@
 
 --source include/not_embedded.inc
 --source include/have_perfschema.inc
---source suite/perfschema/t/statements_digest.test
+--source ./suite/perfschema/t/statements_digest.test
+
+# Expect no digest
+show variables like "performance_schema_digests_size";
+select count(*) from performance_schema.events_statements_summary_by_digest;

=== modified file 'mysql-test/suite/perfschema/t/statements_digest_long_query.test'
--- a/mysql-test/suite/perfschema/t/statements_digest_long_query.test	2012-01-16 19:07:57 +0000
+++ b/mysql-test/suite/perfschema/t/statements_digest_long_query.test	2012-01-17 10:15:06 +0000
@@ -5,6 +5,9 @@
 --source include/not_embedded.inc
 --source include/have_perfschema.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 "...") 
@@ -16,5 +19,4 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
 --echo ####################################
 --echo # QUERYING PS STATEMENT DIGEST
 --echo ####################################
-use performance_schema;
 select DIGEST, DIGEST_TEXT, COUNT_STAR from events_statements_summary_by_digest;

=== modified file 'storage/perfschema/pfs_digest.cc'
--- a/storage/perfschema/pfs_digest.cc	2012-01-16 19:07:57 +0000
+++ b/storage/perfschema/pfs_digest.cc	2012-01-17 10:15:06 +0000
@@ -182,7 +182,6 @@ int init_digest(unsigned int statements_
   for (index= 0; index < statements_digest_size; index++)
   statements_digest_stat_array[index].m_stat.reset();
 
-
   return (statements_digest_stat_array ? 0 : 1);
 }
 
@@ -284,7 +283,6 @@ find_or_create_digest(PFS_thread* thread
         digest_stat array is full. Add stat at index 0 and return.
       */
       pfs= &statements_digest_stat_array[0];
-      //TODO
       return pfs;
     }
 
@@ -340,7 +338,29 @@ find_or_create_digest(PFS_thread* thread
  
 void reset_esms_by_digest()
 {
-  /*TBD*/ 
+  uint index;
+
+  if(statements_digest_stat_array == NULL)
+    return;
+
+  /*
+    Reset statements_digest_stat_array.
+  */
+  for (index= 0; index < statements_digest_size; index++)
+  {
+    statements_digest_stat_array[index].m_digest[0]= '\0';
+    statements_digest_stat_array[index].m_digest_length= 0;
+    statements_digest_stat_array[index].m_digest_text[0]= '\0';;
+    statements_digest_stat_array[index].m_digest_text_length= 0;
+    statements_digest_stat_array[index].m_md5_hash.m_md5[0]= '\0';
+    statements_digest_stat_array[index].m_stat.reset();
+  }
+
+  /* 
+    Reset index which indicates where the next calculated digest informationi
+    to be inserted in statements_digest_stat_array.
+  */
+  digest_index= 1;
 }
 
 /*
@@ -425,7 +445,7 @@ struct PSI_digest_locker* pfs_digest_sta
   */
   if(!locker || !(flag_thread_instrumentation && flag_events_statements_current)
              || (!flag_statements_digest)
-             || (!statements_digest_size))
+             || (!statements_digest_stat_array))
   {
     return NULL;
   }
@@ -493,8 +513,8 @@ void pfs_digest_add_token_v1(PSI_digest_
   }
 
   /* 
-     Take last_token 3 tokens collected till now. These tokens will be used
-     in reduce for normalisation. Make sure not to consider ID tokens in reduce.
+    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 = TOK_PFS_UNUSED;
   uint last_token2= TOK_PFS_UNUSED;

=== modified file 'storage/perfschema/table_esms_by_digest.cc'
--- a/storage/perfschema/table_esms_by_digest.cc	2011-12-29 12:08:32 +0000
+++ b/storage/perfschema/table_esms_by_digest.cc	2012-01-17 10:15:06 +0000
@@ -196,39 +196,19 @@ table_esms_by_digest::create(void)
 int
 table_esms_by_digest::delete_all_rows(void)
 {
-  uint index;
-
-  /*
-    Reset statements_digest_stat_array.
-  */
-  for (index= 0; index < statements_digest_size; index++)
-  {
-    statements_digest_stat_array[index].m_digest[0]= '\0';
-    statements_digest_stat_array[index].m_digest_length= 0;
-    statements_digest_stat_array[index].m_digest_text[0]= '\0';;
-    statements_digest_stat_array[index].m_digest_text_length= 0;
-    statements_digest_stat_array[index].m_md5_hash.m_md5[0]= '\0';
-    statements_digest_stat_array[index].m_stat.reset();
-  }
-
-  /* 
-     Reset index which indicates where the next calculated digest informationi
-     to be inserted in statements_digest_stat_array.
-  */
-  digest_index= 1;
-
+  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(1), m_next_pos(1)
+    m_row_exists(false), m_pos(0), m_next_pos(0)
 {}
 
 void table_esms_by_digest::reset_position(void)
 {
-  m_pos= 1;
-  m_next_pos= 1;
+  m_pos= 0;
+  m_next_pos= 0;
 }
 
 int table_esms_by_digest::rnd_next(void)
@@ -242,10 +222,12 @@ int table_esms_by_digest::rnd_next(void)
   digest_stat= &statements_digest_stat_array[m_pos.m_index];
 
   /* 
-    If digest information exist for this record,
+    If digest information exist for this record or
+    If it is a record at index 0 of statements_digest_stat_array,
     make a new row.
   */
-  if(digest_stat->m_digest_text[0] != '\0')
+  if(digest_stat->m_digest_text[0] != '\0' ||
+     m_pos.m_index == 0)
   {
     make_row(digest_stat);
     m_next_pos.set_after(&m_pos);
@@ -264,10 +246,12 @@ table_esms_by_digest::rnd_pos(const void
   digest_stat= &statements_digest_stat_array[m_pos.m_index];
 
   /* 
-    If digest information exist for this record,
+    If digest information exist for this record or
+    If it is a record at index 0 of statements_digest_stat_array,
     make a new row.
   */
-  if(digest_stat->m_digest_text[0] != '\0')
+  if(digest_stat->m_digest_text[0] != '\0' ||
+     m_pos.m_index == 0)
   {
     make_row(digest_stat);
     return 0;

=== modified file 'storage/perfschema/table_helper.cc'
--- a/storage/perfschema/table_helper.cc	2011-11-18 14:39:33 +0000
+++ b/storage/perfschema/table_helper.cc	2012-01-17 10:15:06 +0000
@@ -103,18 +103,38 @@ void PFS_account_row::set_field(uint ind
 
 int PFS_digest_row::make_row(PFS_statements_digest_stat* pfs)
 {
-  MD5_HASH_TO_STRING(pfs->m_md5_hash.m_md5, pfs->m_digest);
-  pfs->m_digest_length= 16;
-  
-  memcpy(m_digest, pfs->m_digest, sizeof(m_digest));
-  m_digest_length= 16;
-
+  /*
+    Copy digest text from statements_digest_stat_array to be shown as
+    DIGEST_TEXT in this row.
+  */
   m_digest_text_length= pfs->m_digest_text_length;
   if (m_digest_text_length > sizeof(m_digest_text))
     return 1;
   if (m_digest_text_length > 0)
     memcpy(m_digest_text, pfs->m_digest_text, sizeof(m_digest_text));
-
+ 
+  /*
+    "NULL" value for digest text indicates special entry i.e. aggregated
+    stats at index 0 of statements_digest_stat_array. So do not calculate
+    digest as it should always be "NULL".
+  */
+  if(m_digest_text_length != 0 &&
+     pfs->m_digest_text[0] != '\0') 
+  {
+    MD5_HASH_TO_STRING(pfs->m_md5_hash.m_md5, pfs->m_digest);
+    pfs->m_digest_length= 16;
+    /*
+      Copy digest from statements_digest_stat_array to be shown as
+      DIGEST in this row.
+    */
+    m_digest_length= pfs->m_digest_length;
+    memcpy(m_digest, pfs->m_digest, sizeof(m_digest));
+  }
+  else
+  {
+    m_digest_length= 0;
+  }
+  
   return 0;
 }
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3417 to 3418) WL#5767Mayank Prasad17 Jan