List:Commits« Previous MessageNext Message »
From:Mayank Prasad Date:February 20 2012 1:33pm
Subject:bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3440 to 3441) WL#5767
View as plain text  
 3441 Mayank Prasad	2012-02-20
      WL#5767 : Performance Schema, Statements Digest.
      
      Details:
       - Modified code to capture statements giving ERROR/WARNINGS.
       - Added code to collect stats of ERROR/WARNING/ROW_AFFECTED counts.
       - Added/Modified test cases accordingly.

    modified:
      mysql-test/suite/perfschema/include/digest_execution.inc
      mysql-test/suite/perfschema/r/digest_table_full.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/t/digest_table_full.test
      mysql-test/suite/perfschema/t/start_server_no_digests.test
      mysql-test/suite/perfschema/t/statement_digest.test
      storage/perfschema/pfs.cc
 3440 Mayank Prasad	2012-02-16
      WL#5767 : Performanc Schema, Statements Digest.
      
      Details:
       - Modifed code to show stats stored at index 0.
       - added a new test case for displaying index 0 stat when 
      digest table is full.

    added:
      mysql-test/suite/perfschema/r/digest_table_full.result
      mysql-test/suite/perfschema/t/digest_table_full-master.opt
      mysql-test/suite/perfschema/t/digest_table_full.test
    modified:
      mysql-test/suite/perfschema/include/digest_execution.inc
      storage/perfschema/table_esms_by_digest.cc
=== modified file 'mysql-test/suite/perfschema/include/digest_execution.inc'
--- a/mysql-test/suite/perfschema/include/digest_execution.inc	2012-02-16 14:58:41 +0000
+++ b/mysql-test/suite/perfschema/include/digest_execution.inc	2012-02-20 13:32:56 +0000
@@ -73,3 +73,14 @@ 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");

=== modified file 'mysql-test/suite/perfschema/r/digest_table_full.result'
--- a/mysql-test/suite/perfschema/r/digest_table_full.result	2012-02-16 14:58:41 +0000
+++ b/mysql-test/suite/perfschema/r/digest_table_full.result	2012-02-20 13:32:56 +0000
@@ -61,13 +61,22 @@ 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
-NULL	NULL	24
-29570e463ee5c23d	TRUNCATE TABLE performance_schema . events_statements_summary_by_digest  	1
+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
+29570e463ee5c23d	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

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_digests.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_digests.result	2012-02-16 12:57:06 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_digests.result	2012-02-20 13:32:56 +0000
@@ -61,11 +61,20 @@ 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, 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

=== modified file 'mysql-test/suite/perfschema/r/statement_digest.result'
--- a/mysql-test/suite/perfschema/r/statement_digest.result	2012-02-16 12:57:06 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest.result	2012-02-20 13:32:56 +0000
@@ -61,29 +61,42 @@ 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
-29570e463ee5c23d	TRUNCATE TABLE performance_schema . events_statements_summary_by_digest  	1
-043b89731c01112f	SELECT ? FROM t1  	1
-454eba8b93c9ca0a	SELECT ? FROM `t1`  	1
-d7ee0ef93ad9fa8d	SELECT ?, ... FROM t1  	2
-a9a476e33c41ccf6	SELECT ? FROM t2  	1
-e0ec2ba9bfa25ce9	SELECT ?, ... FROM t2  	2
-9483370b7bfe3e5b	INSERT INTO t1 VALUES (?)  	1
-5a02f8af17096ad0	INSERT INTO t2 VALUES (?)  	1
-778782a1f7a22d3e	INSERT INTO t3 VALUES (...)  	1
-ba86d7d93b0f147d	INSERT INTO t4 VALUES (...)  	1
-d6451ffacc7e94dd	INSERT INTO t5 VALUES (...)  	1
-7fcb81b5cb6a8b88	INSERT INTO t1 VALUES (?) /* , ... */  	2
-0bac26f67845225a	INSERT INTO t3 VALUES (...) /* , ... */  	1
-ef74a0ff15482a27	INSERT INTO t5 VALUES (...) /* , ... */  	1
-21c8d94778536808	SELECT ? + ?  	3
-9b5972abc531b21c	SELECT ?  	1
-49d23ec9aebe975b	CREATE SCHEMA statements_digest_temp  	2
-d42c9738d3d96889	DROP SCHEMA statements_digest_temp  	2
+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
+29570e463ee5c23d	TRUNCATE TABLE performance_schema . events_statements_summary_by_digest  	1	0	0	0
+043b89731c01112f	SELECT ? FROM t1  	1	0	0	0
+454eba8b93c9ca0a	SELECT ? FROM `t1`  	1	0	0	0
+d7ee0ef93ad9fa8d	SELECT ?, ... FROM t1  	2	0	0	0
+a9a476e33c41ccf6	SELECT ? FROM t2  	1	0	0	0
+e0ec2ba9bfa25ce9	SELECT ?, ... FROM t2  	2	0	0	0
+9483370b7bfe3e5b	INSERT INTO t1 VALUES (?)  	1	1	0	0
+5a02f8af17096ad0	INSERT INTO t2 VALUES (?)  	1	1	0	0
+778782a1f7a22d3e	INSERT INTO t3 VALUES (...)  	1	1	0	0
+ba86d7d93b0f147d	INSERT INTO t4 VALUES (...)  	1	1	0	0
+d6451ffacc7e94dd	INSERT INTO t5 VALUES (...)  	1	1	0	0
+7fcb81b5cb6a8b88	INSERT INTO t1 VALUES (?) /* , ... */  	2	7	0	0
+0bac26f67845225a	INSERT INTO t3 VALUES (...) /* , ... */  	1	3	0	0
+ef74a0ff15482a27	INSERT INTO t5 VALUES (...) /* , ... */  	1	3	0	0
+21c8d94778536808	SELECT ? + ?  	3	0	0	0
+9b5972abc531b21c	SELECT ?  	1	0	0	0
+49d23ec9aebe975b	CREATE SCHEMA statements_digest_temp  	2	2	0	0
+d42c9738d3d96889	DROP SCHEMA statements_digest_temp  	2	0	0	0
+8bfbc5ac3b54dcc9	SELECT ? FROM t11  	1	0	0	1
+5d0009fe38bf1af6	CREATE TABLE t11 ( c CHARACTER (?) )  	2	0	0	1
+fe1467341bb94010	INSERT INTO t11 VALUES (?)  	1	1	1	0
+69029853781ad4cf	SHOW WARNINGS  	1	0	0	0
 ####################################
 # CLEANUP
 ####################################

=== modified file 'mysql-test/suite/perfschema/r/statement_digest_consumers.result'
--- a/mysql-test/suite/perfschema/r/statement_digest_consumers.result	2012-02-16 12:57:06 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers.result	2012-02-20 13:32:56 +0000
@@ -75,6 +75,14 @@ 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
 ####################################
@@ -98,6 +106,10 @@ ef74a0ff15482a27	INSERT INTO t5 VALUES (
 9b5972abc531b21c	SELECT ?  	1
 49d23ec9aebe975b	CREATE SCHEMA statements_digest_temp  	2
 d42c9738d3d96889	DROP SCHEMA statements_digest_temp  	2
+8bfbc5ac3b54dcc9	SELECT ? FROM t11  	1
+5d0009fe38bf1af6	CREATE TABLE t11 ( c CHARACTER (?) )  	2
+fe1467341bb94010	INSERT INTO t11 VALUES (?)  	1
+69029853781ad4cf	SHOW WARNINGS  	1
 SELECT digest, digest_text FROM performance_schema.events_statements_current;
 digest	digest_text
 ####################################

=== modified file 'mysql-test/suite/perfschema/r/statement_digest_consumers2.result'
--- a/mysql-test/suite/perfschema/r/statement_digest_consumers2.result	2012-02-16 12:57:06 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers2.result	2012-02-20 13:32:56 +0000
@@ -75,6 +75,14 @@ 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
 ####################################

=== modified file 'mysql-test/suite/perfschema/t/digest_table_full.test'
--- a/mysql-test/suite/perfschema/t/digest_table_full.test	2012-02-16 14:58:41 +0000
+++ b/mysql-test/suite/perfschema/t/digest_table_full.test	2012-02-20 13:32:56 +0000
@@ -19,7 +19,8 @@ TRUNCATE TABLE performance_schema.events
 --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, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+       SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
 
 
 # Expect no digest

=== modified file 'mysql-test/suite/perfschema/t/start_server_no_digests.test'
--- a/mysql-test/suite/perfschema/t/start_server_no_digests.test	2012-02-12 21:48:28 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_digests.test	2012-02-20 13:32:56 +0000
@@ -19,7 +19,8 @@ TRUNCATE TABLE performance_schema.events
 --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, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+       SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
 
 
 # Expect no digest

=== modified file 'mysql-test/suite/perfschema/t/statement_digest.test'
--- a/mysql-test/suite/perfschema/t/statement_digest.test	2012-02-12 21:48:28 +0000
+++ b/mysql-test/suite/perfschema/t/statement_digest.test	2012-02-20 13:32:56 +0000
@@ -16,7 +16,8 @@ TRUNCATE TABLE performance_schema.events
 --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, 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

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2012-02-16 11:50:07 +0000
+++ b/storage/perfschema/pfs.cc	2012-02-20 13:32:56 +0000
@@ -4551,26 +4551,22 @@ static void end_statement_v1(PSI_stateme
     /* Aggregate to EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME */
     stat= & event_name_array[index];
 
-    /* Do not calculate digest if statement is not successful. */
-    if(!da->is_error())
-    {
-      /* Set digest stat. */
-      digest_storage= &state->m_digest_state.m_digest_storage;
+    /* Set digest stat. */
+    digest_storage= &state->m_digest_state.m_digest_storage;
 
-      /* Calculate MD5 Hash of the tokens received. */
-      PFS_digest_hash digest_hash;
-      MY_MD5_HASH(digest_hash.m_md5,
-                  (unsigned char *)digest_storage->m_token_array,
-                  (uint) sizeof(digest_storage->m_token_array));
-
-      /* 
-        Populate PFS_statements_digest_stat with computed digest information.
-      */
-      digest_stat_ptr= find_or_create_digest(thread, digest_hash, digest_storage);
-      if(digest_stat_ptr)
-      {
-        digest_stat= &(digest_stat_ptr->m_stat);
-      }
+    /* Calculate MD5 Hash of the tokens received. */
+    PFS_digest_hash digest_hash;
+    MY_MD5_HASH(digest_hash.m_md5,
+                (unsigned char *)digest_storage->m_token_array,
+                (uint) sizeof(digest_storage->m_token_array));
+
+    /* 
+      Populate PFS_statements_digest_stat with computed digest information.
+    */
+    digest_stat_ptr= find_or_create_digest(thread, digest_hash, digest_storage);
+    if(digest_stat_ptr)
+    {
+      digest_stat= &(digest_stat_ptr->m_stat);
     }
 
     if (flags & STATE_FLAG_EVENT)
@@ -4618,11 +4614,9 @@ static void end_statement_v1(PSI_stateme
   }
   else
   {
-    PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
-    DBUG_ASSERT(thread != NULL);
+    PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
 
-    /* Do not calculate digest if statement is not successful. */
-    if(!da->is_error())
+    if(thread)
     {
       /* Set digest stat. */
       digest_storage= &state->m_digest_state.m_digest_storage;
@@ -4704,7 +4698,7 @@ static void end_statement_v1(PSI_stateme
     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())
   {
@@ -4713,12 +4707,25 @@ static void end_statement_v1(PSI_stateme
     case Diagnostics_area::DA_OK:
       stat->m_rows_affected+= da->affected_rows();
       stat->m_warning_count+= da->statement_warn_count();
+      if(digest_stat)
+      {
+        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)
+      {
+        digest_stat->m_warning_count+= da->statement_warn_count();
+      }
       break;
     case Diagnostics_area::DA_ERROR:
       stat->m_error_count++;
+      if(digest_stat)
+      {
+        digest_stat->m_error_count++;
+      }
       break;
     case Diagnostics_area::DA_DISABLED:
       break;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3440 to 3441) WL#5767Mayank Prasad20 Feb