3444 Marc Alff 2012-02-21
Code cleanup
modified:
include/mysql/psi/psi.h
include/mysql/psi/psi_abi_v1.h.pp
include/mysql/psi/psi_abi_v2.h.pp
mysql-test/suite/perfschema/r/digest_table_full.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_long_query.result
storage/perfschema/pfs.cc
storage/perfschema/pfs_digest.cc
storage/perfschema/pfs_digest.h
storage/perfschema/pfs_events_statements.h
storage/perfschema/pfs_events_waits.h
storage/perfschema/table_events_statements.cc
storage/perfschema/table_helper.cc
storage/perfschema/table_helper.h
3443 Marc Alff 2012-02-20
Post merge cleanup: integration with recent changes in sql/ related to MD5.
modified:
mysql-test/suite/perfschema/r/digest_table_full.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_long_query.result
storage/perfschema/pfs.cc
storage/perfschema/pfs_digest.cc
storage/perfschema/pfs_digest.h
storage/perfschema/unittest/stub_server_misc.h
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h 2012-02-20 18:05:15 +0000
+++ b/include/mysql/psi/psi.h 2012-02-21 18:27:58 +0000
@@ -261,9 +261,11 @@ typedef struct PSI_bootstrap PSI_bootstr
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
@@ -946,21 +948,26 @@ 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.
*/
-typedef struct {
- my_bool m_full;
- int m_byte_count;
- char m_token_array[1024];
- } PFS_digest_storage;
+struct PSI_digest_storage
+{
+ my_bool m_full;
+ int m_byte_count;
+ char m_token_array[PSI_MAX_DIGEST_STORAGE_SIZE];
+};
+typedef struct PSI_digest_storage PSI_digest_storage;
-struct PSI_digest_locker_state_v1
+struct PSI_digest_locker_state
{
int m_last_id_index;
- PFS_digest_storage m_digest_storage;
+ 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,
@@ -1020,7 +1027,8 @@ struct PSI_statement_locker_state_v1
ulong m_sort_rows;
/** Metric, number of sort scans. */
ulong m_sort_scan;
- struct PSI_digest_locker_state_v1 m_digest_state;
+ /** Statement digest. */
+ PSI_digest_locker_state m_digest_state;
};
/**
@@ -2246,7 +2254,6 @@ typedef struct PSI_file_locker_state_v1
typedef struct PSI_table_locker_state_v1 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
-typedef struct PSI_digest_locker_state_v1 PSI_digest_locker_state;
#endif
#ifdef USE_PSI_2
@@ -2267,7 +2274,6 @@ typedef struct PSI_file_locker_state_v2
typedef struct PSI_table_locker_state_v2 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
-typedef struct PSI_digest_locker_state_v2 PSI_digest_locker_state;
#endif
#else /* HAVE_PSI_INTERFACE */
=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp 2012-02-12 22:05:27 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp 2012-02-21 18:27:58 +0000
@@ -239,16 +239,19 @@ struct PSI_table_locker_state_v1
void *m_wait;
uint m_index;
};
-typedef struct {
- my_bool m_full;
- int m_byte_count;
- char m_token_array[1024];
- } PFS_digest_storage;
-struct PSI_digest_locker_state_v1
+struct PSI_digest_storage
+{
+ my_bool m_full;
+ int m_byte_count;
+ char m_token_array[1024];
+};
+typedef struct PSI_digest_storage PSI_digest_storage;
+struct PSI_digest_locker_state
{
int m_last_id_index;
- PFS_digest_storage m_digest_storage;
+ 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;
@@ -274,7 +277,7 @@ struct PSI_statement_locker_state_v1
ulong m_sort_range;
ulong m_sort_rows;
ulong m_sort_scan;
- struct PSI_digest_locker_state_v1 m_digest_state;
+ PSI_digest_locker_state m_digest_state;
};
struct PSI_socket_locker_state_v1
{
@@ -611,6 +614,5 @@ typedef struct PSI_file_locker_state_v1
typedef struct PSI_table_locker_state_v1 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
-typedef struct PSI_digest_locker_state_v1 PSI_digest_locker_state;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END
=== modified file 'include/mysql/psi/psi_abi_v2.h.pp'
--- a/include/mysql/psi/psi_abi_v2.h.pp 2012-02-12 22:05:27 +0000
+++ b/include/mysql/psi/psi_abi_v2.h.pp 2012-02-21 18:27:58 +0000
@@ -210,6 +210,5 @@ typedef struct PSI_file_locker_state_v2
typedef struct PSI_table_locker_state_v2 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
-typedef struct PSI_digest_locker_state_v2 PSI_digest_locker_state;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END
=== modified file 'mysql-test/suite/perfschema/r/digest_table_full.result'
--- a/mysql-test/suite/perfschema/r/digest_table_full.result 2012-02-20 20:56:20 +0000
+++ b/mysql-test/suite/perfschema/r/digest_table_full.result 2012-02-21 18:27:58 +0000
@@ -76,7 +76,7 @@ SELECT DIGEST, DIGEST_TEXT, COUNT_STAR,
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
-f7ab835f907f396b TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1 0 0 0
+f7ab835f907f396baeb2c5e6e605929b 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/statement_digest.result'
--- a/mysql-test/suite/perfschema/r/statement_digest.result 2012-02-20 20:56:20 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest.result 2012-02-21 18:27:58 +0000
@@ -75,28 +75,28 @@ Warning 1265 Data truncated for column '
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
-f7ab835f907f396b TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1 0 0 0
-0431ac94abde6328 SELECT ? FROM t1 1 0 0 0
-d798ff4be98e0d26 SELECT ? FROM `t1` 1 0 0 0
-d5016618084cd788 SELECT ?, ... FROM t1 2 0 0 0
-6f08c6cdf2afab43 SELECT ? FROM t2 1 0 0 0
-4fef50eb0b2f2fbc SELECT ?, ... FROM t2 2 0 0 0
-c4335f4ded28cdc3 INSERT INTO t1 VALUES (?) 1 1 0 0
-b015c102ab03f4bc INSERT INTO t2 VALUES (?) 1 1 0 0
-f83d4b46c3fe5ff9 INSERT INTO t3 VALUES (...) 1 1 0 0
-b81724d2cfa0ab7f INSERT INTO t4 VALUES (...) 1 1 0 0
-960035d85bc6d14f INSERT INTO t5 VALUES (...) 1 1 0 0
-6ee7554974d2ffa1 INSERT INTO t1 VALUES (?) /* , ... */ 2 7 0 0
-827ec3eb62c9f2ed INSERT INTO t3 VALUES (...) /* , ... */ 1 3 0 0
-55e9e1b918c4e559 INSERT INTO t5 VALUES (...) /* , ... */ 1 3 0 0
-d055f262b12b2384 SELECT ? + ? 3 0 0 0
-de392358e87965c3 SELECT ? 1 0 0 0
-d8bde89f42443bc5 CREATE SCHEMA statements_digest_temp 2 2 0 0
-5f49c045f89918f9 DROP SCHEMA statements_digest_temp 2 0 0 0
-04bbba67445b1f70 SELECT ? FROM t11 1 0 0 1
-60be4562b0114c30 CREATE TABLE t11 ( c CHARACTER (?) ) 2 0 0 1
-b1115cec4d694e11 INSERT INTO t11 VALUES (?) 1 1 1 0
-2ff7a4150e76c272 SHOW WARNINGS 1 0 0 0
+f7ab835f907f396baeb2c5e6e605929b TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1 0 0 0
+0431ac94abde6328653ad7c73f14d029 SELECT ? FROM t1 1 0 0 0
+d798ff4be98e0d2613b5d055f70cec1e SELECT ? FROM `t1` 1 0 0 0
+d5016618084cd788c9098d2e0260a9f0 SELECT ?, ... FROM t1 2 0 0 0
+6f08c6cdf2afab43864454acffa74758 SELECT ? FROM t2 1 0 0 0
+4fef50eb0b2f2fbc0d6e65c1ce6deeef SELECT ?, ... FROM t2 2 0 0 0
+c4335f4ded28cdc34f7903b443dcf022 INSERT INTO t1 VALUES (?) 1 1 0 0
+b015c102ab03f4bccdfb32f01589af49 INSERT INTO t2 VALUES (?) 1 1 0 0
+f83d4b46c3fe5ff99035ff92b367422f INSERT INTO t3 VALUES (...) 1 1 0 0
+b81724d2cfa0ab7f2ba1e05d6bf925ed INSERT INTO t4 VALUES (...) 1 1 0 0
+960035d85bc6d14f454362580d6e5454 INSERT INTO t5 VALUES (...) 1 1 0 0
+6ee7554974d2ffa1ab5bd9549339e3e5 INSERT INTO t1 VALUES (?) /* , ... */ 2 7 0 0
+827ec3eb62c9f2eddd602524a535abcf INSERT INTO t3 VALUES (...) /* , ... */ 1 3 0 0
+55e9e1b918c4e559684d4297de2bdbd9 INSERT INTO t5 VALUES (...) /* , ... */ 1 3 0 0
+d055f262b12b2384248d1f132e7b9fea SELECT ? + ? 3 0 0 0
+de392358e87965c3f5da40056c9629a3 SELECT ? 1 0 0 0
+d8bde89f42443bc5632dfafe3f4c34f7 CREATE SCHEMA statements_digest_temp 2 2 0 0
+5f49c045f89918f9cd317263aa694c53 DROP SCHEMA statements_digest_temp 2 0 0 0
+04bbba67445b1f70cc44467ccc9d2b23 SELECT ? FROM t11 1 0 0 1
+60be4562b0114c30639771d1b123cf00 CREATE TABLE t11 ( c CHARACTER (?) ) 2 0 0 1
+b1115cec4d694e118d0ee714c44bb998 INSERT INTO t11 VALUES (?) 1 1 1 0
+2ff7a4150e76c272e5ebf9e66e0ddd10 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-20 20:56:20 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers.result 2012-02-21 18:27:58 +0000
@@ -88,28 +88,28 @@ Warning 1265 Data truncated for column '
####################################
SELECT digest, digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
digest digest_text count_star
-f7ab835f907f396b TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1
-0431ac94abde6328 SELECT ? FROM t1 1
-d798ff4be98e0d26 SELECT ? FROM `t1` 1
-d5016618084cd788 SELECT ?, ... FROM t1 2
-6f08c6cdf2afab43 SELECT ? FROM t2 1
-4fef50eb0b2f2fbc SELECT ?, ... FROM t2 2
-c4335f4ded28cdc3 INSERT INTO t1 VALUES (?) 1
-b015c102ab03f4bc INSERT INTO t2 VALUES (?) 1
-f83d4b46c3fe5ff9 INSERT INTO t3 VALUES (...) 1
-b81724d2cfa0ab7f INSERT INTO t4 VALUES (...) 1
-960035d85bc6d14f INSERT INTO t5 VALUES (...) 1
-6ee7554974d2ffa1 INSERT INTO t1 VALUES (?) /* , ... */ 2
-827ec3eb62c9f2ed INSERT INTO t3 VALUES (...) /* , ... */ 1
-55e9e1b918c4e559 INSERT INTO t5 VALUES (...) /* , ... */ 1
-d055f262b12b2384 SELECT ? + ? 3
-de392358e87965c3 SELECT ? 1
-d8bde89f42443bc5 CREATE SCHEMA statements_digest_temp 2
-5f49c045f89918f9 DROP SCHEMA statements_digest_temp 2
-04bbba67445b1f70 SELECT ? FROM t11 1
-60be4562b0114c30 CREATE TABLE t11 ( c CHARACTER (?) ) 2
-b1115cec4d694e11 INSERT INTO t11 VALUES (?) 1
-2ff7a4150e76c272 SHOW WARNINGS 1
+f7ab835f907f396baeb2c5e6e605929b TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1
+0431ac94abde6328653ad7c73f14d029 SELECT ? FROM t1 1
+d798ff4be98e0d2613b5d055f70cec1e SELECT ? FROM `t1` 1
+d5016618084cd788c9098d2e0260a9f0 SELECT ?, ... FROM t1 2
+6f08c6cdf2afab43864454acffa74758 SELECT ? FROM t2 1
+4fef50eb0b2f2fbc0d6e65c1ce6deeef SELECT ?, ... FROM t2 2
+c4335f4ded28cdc34f7903b443dcf022 INSERT INTO t1 VALUES (?) 1
+b015c102ab03f4bccdfb32f01589af49 INSERT INTO t2 VALUES (?) 1
+f83d4b46c3fe5ff99035ff92b367422f INSERT INTO t3 VALUES (...) 1
+b81724d2cfa0ab7f2ba1e05d6bf925ed INSERT INTO t4 VALUES (...) 1
+960035d85bc6d14f454362580d6e5454 INSERT INTO t5 VALUES (...) 1
+6ee7554974d2ffa1ab5bd9549339e3e5 INSERT INTO t1 VALUES (?) /* , ... */ 2
+827ec3eb62c9f2eddd602524a535abcf INSERT INTO t3 VALUES (...) /* , ... */ 1
+55e9e1b918c4e559684d4297de2bdbd9 INSERT INTO t5 VALUES (...) /* , ... */ 1
+d055f262b12b2384248d1f132e7b9fea SELECT ? + ? 3
+de392358e87965c3f5da40056c9629a3 SELECT ? 1
+d8bde89f42443bc5632dfafe3f4c34f7 CREATE SCHEMA statements_digest_temp 2
+5f49c045f89918f9cd317263aa694c53 DROP SCHEMA statements_digest_temp 2
+04bbba67445b1f70cc44467ccc9d2b23 SELECT ? FROM t11 1
+60be4562b0114c30639771d1b123cf00 CREATE TABLE t11 ( c CHARACTER (?) ) 2
+b1115cec4d694e118d0ee714c44bb998 INSERT INTO t11 VALUES (?) 1
+2ff7a4150e76c272e5ebf9e66e0ddd10 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_long_query.result'
--- a/mysql-test/suite/perfschema/r/statement_digest_long_query.result 2012-02-20 20:56:20 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_long_query.result 2012-02-21 18:27:58 +0000
@@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
####################################
SELECT digest, digest_text, count_star FROM events_statements_summary_by_digest;
digest digest_text count_star
-4b653d085960e08d TRUNCATE TABLE events_statements_summary_by_digest 1
-2dd9d11451985e28 SELECT ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + !
? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ... 1
+4b653d085960e08d033c67cb23748eb3 TRUNCATE TABLE events_statements_summary_by_digest 1
+2dd9d11451985e288ffd7f2cdefc28e2 SELECT ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + !
? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ... 1
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2012-02-20 20:56:20 +0000
+++ b/storage/perfschema/pfs.cc 2012-02-21 18:27:58 +0000
@@ -1042,13 +1042,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;
@@ -4226,7 +4219,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;
- pfs->m_statement_digest_stat_ptr= NULL;
+ digest_reset(& pfs->m_digest_storage);
/* New stages will have this statement as parent */
PFS_events_stages *child_stage= & pfs_thread->m_stage_current;
@@ -4252,6 +4245,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;
@@ -4273,11 +4273,6 @@ get_thread_statement_locker_v1(PSI_state
state->m_no_index_used= 0;
state->m_no_good_index_used= 0;
- state->m_digest_state.m_last_id_index= 0;
- state->m_digest_state.m_digest_storage.m_byte_count= 0;
- state->m_digest_state.m_digest_storage.m_token_array[0]= '\0';
- state->m_digest_state.m_digest_storage.m_full= false;
-
return reinterpret_cast<PSI_statement_locker*> (state);
}
@@ -4539,7 +4534,7 @@ static void end_statement_v1(PSI_stateme
/*
Capture statement stats by digest.
*/
- PFS_digest_storage *digest_storage= NULL;
+ PSI_digest_storage *digest_storage= NULL;
PFS_statement_stat *digest_stat= NULL;
PFS_statements_digest_stat* digest_stat_ptr= NULL;
@@ -4595,8 +4590,19 @@ static void end_statement_v1(PSI_stateme
pfs->m_timer_end= timer_end;
pfs->m_end_event_id= thread->m_event_id;
- pfs->m_statement_digest_stat_ptr= digest_stat_ptr;
-
+ PSI_digest_storage *from= & state->m_digest_state.m_digest_storage;
+
+ if (from->m_byte_count > 0)
+ {
+ /*
+ The following columns in events_statement_current:
+ - DIGEST,
+ - DIGEST_TEXT
+ are computed from the digest storage.
+ */
+ digest_copy(& pfs->m_digest_storage, from);
+ }
+
if (flag_events_statements_history)
insert_events_statements_history(thread, pfs);
if (flag_events_statements_history_long)
=== modified file 'storage/perfschema/pfs_digest.cc'
--- a/storage/perfschema/pfs_digest.cc 2012-02-20 20:56:20 +0000
+++ b/storage/perfschema/pfs_digest.cc 2012-02-21 18:27:58 +0000
@@ -121,7 +121,7 @@ static uchar *digest_hash_get_key(const
DBUG_ASSERT(typed_entry != NULL);
digest= *typed_entry;
DBUG_ASSERT(digest != NULL);
- *length= 16;
+ *length= PFS_MD5_SIZE;
result= digest->m_digest_hash.m_md5;
return const_cast<uchar*> (reinterpret_cast<const uchar*> (result));
}
@@ -166,15 +166,17 @@ static LF_PINS* get_digest_hash_pins(PFS
PFS_statements_digest_stat*
find_or_create_digest(PFS_thread* thread,
- PFS_digest_storage* digest_storage)
+ 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);
- /* There shoulod be at least one token. */
- if(unlikely(pins == NULL) ||
- !(digest_storage->m_byte_count >= PFS_SIZE_OF_A_TOKEN))
- {
+ if (unlikely(pins == NULL))
return NULL;
- }
/* Compute MD5 Hash of the tokens received. */
PFS_digest_hash md5;
@@ -192,7 +194,7 @@ find_or_create_digest(PFS_thread* thread
/* Lookup LF_HASH using this new key. */
entry= reinterpret_cast<PFS_statements_digest_stat**>
(lf_hash_search(&digest_hash, pins,
- hash_key, 16));
+ hash_key, PFS_MD5_SIZE));
if(!entry)
{
@@ -210,17 +212,14 @@ find_or_create_digest(PFS_thread* thread
/* Add a new record in digest stat array. */
pfs= &statements_digest_stat_array[digest_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.
*/
- pfs->m_digest_storage.m_byte_count= digest_storage->m_byte_count;
- pfs->m_digest_storage.m_full= digest_storage->m_full;
- /* Copy token array. */
- memcpy(pfs->m_digest_storage.m_token_array, digest_storage->m_token_array,
- PFS_MAX_DIGEST_STORAGE_SIZE);
- /* Copy digest hash/LF Hash search key. */
- memcpy(pfs->m_digest_hash.m_md5, md5.m_md5, 16);
+ digest_copy(& pfs->m_digest_storage, digest_storage);
pfs->m_first_seen= now;
pfs->m_last_seen= now;
@@ -270,12 +269,12 @@ void purge_digest(PFS_thread* thread, un
/* Lookup LF_HASH using this new key. */
entry= reinterpret_cast<PFS_statements_digest_stat**>
(lf_hash_search(&digest_hash, pins,
- hash_key, 16));
+ hash_key, PFS_MD5_SIZE));
if(entry && (entry != MY_ERRPTR))
{
lf_hash_delete(&digest_hash, pins,
- hash_key, 16);
+ hash_key, PFS_MD5_SIZE);
}
lf_hash_search_unpin(pins);
return;
@@ -287,12 +286,9 @@ void PFS_statements_digest_stat::reset()
if (unlikely(thread == NULL))
return;
- m_digest_storage.m_byte_count= 0;
- m_digest_storage.m_token_array[0]= '\0';
- m_digest_storage.m_full= false;
+ digest_reset(& m_digest_storage);
m_stat.reset();
purge_digest(thread, m_digest_hash.m_md5);
- m_digest_hash.m_md5[0]= '\0';
m_first_seen= 0;
m_last_seen= 0;
}
@@ -320,7 +316,7 @@ void reset_esms_by_digest()
/*
Iterate token array and updates digest_text.
*/
-void get_digest_text(char* digest_text, PFS_digest_storage* digest_storage)
+void get_digest_text(char* digest_text, PSI_digest_storage* digest_storage)
{
uint tok= 0;
int current_byte= 0;
@@ -332,7 +328,7 @@ void get_digest_text(char* digest_text,
/* -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 <= PFS_MAX_DIGEST_STORAGE_SIZE);
+ DBUG_ASSERT(byte_count <= PSI_MAX_DIGEST_STORAGE_SIZE);
while(current_byte < byte_count &&
available_bytes_to_write > 0)
@@ -393,39 +389,66 @@ void get_digest_text(char* digest_text,
*digest_text= '\0';
}
-struct PSI_digest_locker* pfs_digest_start_v1(PSI_statement_locker *locker)
+static inline uint peek_token(const PSI_digest_storage *digest, int index)
{
- PSI_statement_locker_state *statement_state= NULL;
- PSI_digest_locker_state *state= NULL;
- PFS_digest_storage *digest_storage= NULL;
-
- /*
- If current statement is not instrumented
- or if statement_digest consumer is not enabled.
- */
- if(!locker || !(flag_thread_instrumentation)
- || (!flag_statements_digest)
- || (!statements_digest_stat_array))
+ unsigned short sh;
+ 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);
+
+ sh= ((0x00ff & digest->m_token_array[index + 1])<<8) | (0x00ff & digest->m_token_array[index]);
+ return (uint) sh;
+}
+
+/**
+ 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)
{
- return NULL;
+ /* 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);
- state= &statement_state->m_digest_state;
- DBUG_ASSERT(state != NULL);
-
- digest_storage= &state->m_digest_storage;
+ if (statement_state->m_discarded)
+ return NULL;
- /* Initialize token array and token count. */
- digest_storage->m_byte_count= PFS_MAX_DIGEST_STORAGE_SIZE;
- state->m_last_id_index= 0;
- while(digest_storage->m_byte_count)
- digest_storage->m_token_array[--digest_storage->m_byte_count]= 0;
- digest_storage->m_full= false;
+ 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 reinterpret_cast<PSI_digest_locker*> (state);
+ return NULL;
}
PSI_digest_locker* pfs_digest_add_token_v1(PSI_digest_locker *locker,
@@ -433,17 +456,14 @@ PSI_digest_locker* pfs_digest_add_token_
OPAQUE_LEX_YYSTYPE *yylval)
{
PSI_digest_locker_state *state= NULL;
- PFS_digest_storage *digest_storage= NULL;
-
- if(!locker)
- return 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( PFS_MAX_DIGEST_STORAGE_SIZE - digest_storage->m_byte_count <
+ if( PSI_MAX_DIGEST_STORAGE_SIZE - digest_storage->m_byte_count <
PFS_SIZE_OF_A_TOKEN)
{
digest_storage->m_full= true;
@@ -454,10 +474,11 @@ PSI_digest_locker* pfs_digest_add_token_
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;
+ uint last_token;
+ uint last_token2;
- read_last_two_tokens(digest_storage, state->m_last_id_index, &last_token, &last_token2);
+ peek_last_two_tokens(digest_storage, state->m_last_id_index,
+ &last_token, &last_token2);
switch (token)
{
@@ -514,7 +535,7 @@ PSI_digest_locker* pfs_digest_add_token_
token= TOK_PFS_ROW_SINGLE_VALUE;
/* Read last two tokens again */
- read_last_two_tokens(digest_storage, state->m_last_id_index, &last_token, &last_token2);
+ 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) &&
@@ -545,7 +566,7 @@ PSI_digest_locker* pfs_digest_add_token_
token= TOK_PFS_ROW_MULTIPLE_VALUE;
/* Read last two tokens again */
- read_last_two_tokens(digest_storage, state->m_last_id_index, &last_token, &last_token2);
+ 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) &&
=== modified file 'storage/perfschema/pfs_digest.h'
--- a/storage/perfschema/pfs_digest.h 2012-02-20 20:56:20 +0000
+++ b/storage/perfschema/pfs_digest.h 2012-02-21 18:27:58 +0000
@@ -25,7 +25,6 @@
#include "lf.h"
#include "pfs_stat.h"
-#define PFS_MAX_DIGEST_STORAGE_SIZE 1024
#define PFS_SIZE_OF_A_TOKEN 2
extern bool flag_statements_digest;
@@ -34,12 +33,16 @@ extern unsigned int digest_index;
extern ulong digest_max;
struct PFS_thread;
+/* Fixed, per MD5 hash. */
+#define PFS_MD5_SIZE 16
+
/**
Structure to store a MD5 hash value (digest) for a statement.
*/
-struct {
- unsigned char m_md5[16];
- }typedef PFS_digest_hash;
+struct PFS_digest_hash
+{
+ unsigned char m_md5[PFS_MD5_SIZE];
+};
/** A statement digest stat record. */
struct PFS_statements_digest_stat
@@ -52,7 +55,7 @@ struct PFS_statements_digest_stat
/**
Digest Storage.
*/
- PFS_digest_storage m_digest_storage;
+ PSI_digest_storage m_digest_storage;
/**
Statement stat.
@@ -74,9 +77,9 @@ void cleanup_digest();
int init_digest_hash(void);
void cleanup_digest_hash(void);
PFS_statements_digest_stat* find_or_create_digest(PFS_thread*,
- PFS_digest_storage*);
+ PSI_digest_storage*);
-void get_digest_text(char* digest_text, PFS_digest_storage*);
+void get_digest_text(char* digest_text, PSI_digest_storage*);
void reset_esms_by_digest();
@@ -90,13 +93,27 @@ PSI_digest_locker* pfs_digest_add_token_
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)
+{
+ 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);
+}
+
/**
Function to read a single token from token array.
*/
inline void read_token(uint *tok, int *index, char *src)
{
unsigned short sh;
- int remaining_bytes= PFS_MAX_DIGEST_STORAGE_SIZE - *index;
+ int remaining_bytes= PSI_MAX_DIGEST_STORAGE_SIZE - *index;
DBUG_ASSERT(remaining_bytes >= 0);
/* Make sure we have enough space to read a token from.
@@ -112,12 +129,12 @@ inline void read_token(uint *tok, int *i
/**
Function to store a single token in token array.
*/
-inline void store_token(PFS_digest_storage* digest_storage, uint token)
+inline void store_token(PSI_digest_storage* digest_storage, uint token)
{
char* dest= digest_storage->m_token_array;
int* index= &digest_storage->m_byte_count;
unsigned short sh= (unsigned short)token;
- int remaining_bytes= PFS_MAX_DIGEST_STORAGE_SIZE - *index;
+ int remaining_bytes= PSI_MAX_DIGEST_STORAGE_SIZE - *index;
DBUG_ASSERT(remaining_bytes >= 0);
/* Make sure we have enough space to write a token to. */
@@ -137,7 +154,7 @@ inline void read_identifier(char **dest,
uint available_bytes_to_write, uint offset)
{
uint length;
- int remaining_bytes= PFS_MAX_DIGEST_STORAGE_SIZE - *index;
+ int remaining_bytes= PSI_MAX_DIGEST_STORAGE_SIZE - *index;
DBUG_ASSERT(remaining_bytes >= 0);
/*
Read ID's length.
@@ -164,12 +181,12 @@ inline void read_identifier(char **dest,
/**
Function to store an identifier in token array.
*/
-inline void store_identifier(PFS_digest_storage* digest_storage,
+inline void store_identifier(PSI_digest_storage* digest_storage,
uint id_length, char *id_name)
{
char* dest= digest_storage->m_token_array;
int* index= &digest_storage->m_byte_count;
- int remaining_bytes= PFS_MAX_DIGEST_STORAGE_SIZE - *index;
+ int remaining_bytes= PSI_MAX_DIGEST_STORAGE_SIZE - *index;
DBUG_ASSERT(remaining_bytes >= 0);
/*
@@ -189,30 +206,4 @@ inline void store_identifier(PFS_digest_
}
}
-/**
- Function to read last two tokens from token array. If an identifier
- is found, do not look for token after that.
-*/
-inline void read_last_two_tokens(PFS_digest_storage* digest_storage,
- int last_id_index, uint *t1, uint *t2)
-{
- int last_token_index;
- int byte_count= digest_storage->m_byte_count;
-
- if(last_id_index <= byte_count - PFS_SIZE_OF_A_TOKEN)
- {
- /* Take last token. */
- last_token_index= byte_count - PFS_SIZE_OF_A_TOKEN;
- DBUG_ASSERT(last_token_index >= 0);
- read_token(t1, &last_token_index, digest_storage->m_token_array);
- }
- if(last_id_index <= byte_count - 2*PFS_SIZE_OF_A_TOKEN)
- {
- /* Take 2nd token from last. */
- last_token_index= byte_count - 2*PFS_SIZE_OF_A_TOKEN;
- DBUG_ASSERT(last_token_index >= 0);
- read_token(t2, &last_token_index, digest_storage->m_token_array);
- }
-}
-
#endif
=== modified file 'storage/perfschema/pfs_events_statements.h'
--- a/storage/perfschema/pfs_events_statements.h 2012-02-10 12:55:57 +0000
+++ b/storage/perfschema/pfs_events_statements.h 2012-02-21 18:27:58 +0000
@@ -88,8 +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 stat */
- struct PFS_statements_digest_stat* m_statement_digest_stat_ptr;
+ /** 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/table_events_statements.cc'
--- a/storage/perfschema/table_events_statements.cc 2012-02-10 23:14:57 +0000
+++ b/storage/perfschema/table_events_statements.cc 2012-02-21 18:27:58 +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;
@@ -368,16 +369,21 @@ void table_events_statements_common::mak
/*
Filling up statement digest information.
*/
- PFS_statements_digest_stat *pfs= statement->m_statement_digest_stat_ptr;
- if(pfs && pfs->m_digest_storage.m_byte_count != 0)
+ PSI_digest_storage *digest= & statement->m_digest_storage;
+ if (digest->m_byte_count > 0)
{
- /* Generate the DIGEST text string from the MD5 digest */
- MD5_HASH_TO_STRING(pfs->m_digest_hash.m_md5,
+ PFS_digest_hash md5;
+ compute_md5_hash((char*) md5.m_md5,
+ 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= 16;
+ 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, &pfs->m_digest_storage);
+ 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
=== modified file 'storage/perfschema/table_helper.cc'
--- a/storage/perfschema/table_helper.cc 2012-02-06 12:08:15 +0000
+++ b/storage/perfschema/table_helper.cc 2012-02-21 18:27:58 +0000
@@ -115,7 +115,7 @@ int PFS_digest_row::make_row(PFS_stateme
DIGEST in this row.
*/
MD5_HASH_TO_STRING(pfs->m_digest_hash.m_md5, m_digest);
- m_digest_length= 16;
+ m_digest_length= MD5_HASH_TO_STRING_LENGTH;
/*
Caclulate digest_text information from the token array collected
=== modified file 'storage/perfschema/table_helper.h'
--- a/storage/perfschema/table_helper.h 2011-11-23 12:56:12 +0000
+++ b/storage/perfschema/table_helper.h 2012-02-21 18:27:58 +0000
@@ -23,11 +23,11 @@
#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) \
- /*
- Write MD5 hash value in a string to be used
- as DIGEST for the statement.
- */ \
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], \
@@ -35,6 +35,8 @@
_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;
struct PFS_account;
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-wl5767 branch (marc.alff:3443 to 3444) | Marc Alff | 22 Feb |