3423 Mayank Prasad 2012-02-02
WL#5767 Performance Schema, Statements Digest
Details:
- Implemented FIRST_SEEN/LAST_SEEN, Column. Getting Wrong
dates, need to see.
- Changed Digest COLUMN size from varchar(64) to varchar(32).
- tried to fix statements_digest_long_query by specifying
big value of thread_stack.
modified:
mysql-test/suite/perfschema/r/dml_esms_by_digest.result
mysql-test/suite/perfschema/r/pfs_upgrade.result
mysql-test/suite/perfschema/r/schema.result
mysql-test/suite/perfschema/r/table_schema.result
mysql-test/suite/perfschema/t/statements_digest_long_query-master.opt
scripts/mysql_system_tables.sql
storage/perfschema/pfs_digest.cc
storage/perfschema/pfs_digest.h
storage/perfschema/pfs_engine_table.cc
storage/perfschema/pfs_engine_table.h
storage/perfschema/table_esms_by_digest.cc
storage/perfschema/table_esms_by_digest.h
storage/perfschema/table_events_statements.cc
3422 Mayank Prasad 2012-02-02
WL#5767 Performance Schema, Statements Digest
Details:
- Moved digest text calculation (get_digest_text call) from
"during statement execution" to "during querying digest table".
modified:
storage/perfschema/pfs_digest.cc
storage/perfschema/pfs_digest.h
storage/perfschema/table_esms_by_digest.cc
storage/perfschema/table_events_statements.cc
storage/perfschema/table_helper.cc
=== modified file 'mysql-test/suite/perfschema/r/dml_esms_by_digest.result'
--- a/mysql-test/suite/perfschema/r/dml_esms_by_digest.result 2011-06-13 11:54:30 +0000
+++ b/mysql-test/suite/perfschema/r/dml_esms_by_digest.result 2012-02-02 12:04:43 +0000
@@ -1,9 +1,9 @@
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
+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
+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;
=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade.result 2012-01-16 05:37:16 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade.result 2012-02-02 12:04:43 +0000
@@ -58,8 +58,8 @@ ERROR 1050 (42S01) at line 1081: Table '
ERROR 1050 (42S01) at line 1090: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1099: Table 'users' already exists
ERROR 1050 (42S01) at line 1109: Table 'accounts' already exists
-ERROR 1050 (42S01) at line 1141: Table 'events_statements_summary_by_digest' already exists
-ERROR 1644 (HY000) at line 1561: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 1143: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1563: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
show tables like "user_table";
Tables_in_performance_schema (user_table)
@@ -122,8 +122,8 @@ ERROR 1050 (42S01) at line 1081: Table '
ERROR 1050 (42S01) at line 1090: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1099: Table 'users' already exists
ERROR 1050 (42S01) at line 1109: Table 'accounts' already exists
-ERROR 1050 (42S01) at line 1141: Table 'events_statements_summary_by_digest' already exists
-ERROR 1644 (HY000) at line 1561: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 1143: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1563: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
show tables like "user_view";
Tables_in_performance_schema (user_view)
@@ -184,8 +184,8 @@ ERROR 1050 (42S01) at line 1081: Table '
ERROR 1050 (42S01) at line 1090: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1099: Table 'users' already exists
ERROR 1050 (42S01) at line 1109: Table 'accounts' already exists
-ERROR 1050 (42S01) at line 1141: Table 'events_statements_summary_by_digest' already exists
-ERROR 1644 (HY000) at line 1561: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 1143: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1563: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
select name from mysql.proc where db='performance_schema';
name
@@ -246,8 +246,8 @@ ERROR 1050 (42S01) at line 1081: Table '
ERROR 1050 (42S01) at line 1090: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1099: Table 'users' already exists
ERROR 1050 (42S01) at line 1109: Table 'accounts' already exists
-ERROR 1050 (42S01) at line 1141: Table 'events_statements_summary_by_digest' already exists
-ERROR 1644 (HY000) at line 1561: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 1143: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1563: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
select name from mysql.proc where db='performance_schema';
name
@@ -308,8 +308,8 @@ ERROR 1050 (42S01) at line 1081: Table '
ERROR 1050 (42S01) at line 1090: Table 'hosts' already exists
ERROR 1050 (42S01) at line 1099: Table 'users' already exists
ERROR 1050 (42S01) at line 1109: Table 'accounts' already exists
-ERROR 1050 (42S01) at line 1141: Table 'events_statements_summary_by_digest' already exists
-ERROR 1644 (HY000) at line 1561: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 1143: Table 'events_statements_summary_by_digest' already exists
+ERROR 1644 (HY000) at line 1563: Unexpected content found in the performance_schema database.
FATAL ERROR: Upgrade failed
select name from mysql.event where db='performance_schema';
name
=== modified file 'mysql-test/suite/perfschema/r/schema.result'
--- a/mysql-test/suite/perfschema/r/schema.result 2011-11-23 12:56:12 +0000
+++ b/mysql-test/suite/perfschema/r/schema.result 2012-02-02 12:04:43 +0000
@@ -180,7 +180,7 @@ events_statements_current CREATE TABLE `
`TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
`LOCK_TIME` bigint(20) unsigned NOT NULL,
`SQL_TEXT` longtext,
- `DIGEST` varchar(64) DEFAULT NULL,
+ `DIGEST` varchar(32) DEFAULT NULL,
`DIGEST_TEXT` longtext,
`CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
`OBJECT_TYPE` varchar(64) DEFAULT NULL,
@@ -224,7 +224,7 @@ events_statements_history CREATE TABLE `
`TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
`LOCK_TIME` bigint(20) unsigned NOT NULL,
`SQL_TEXT` longtext,
- `DIGEST` varchar(64) DEFAULT NULL,
+ `DIGEST` varchar(32) DEFAULT NULL,
`DIGEST_TEXT` longtext,
`CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
`OBJECT_TYPE` varchar(64) DEFAULT NULL,
@@ -268,7 +268,7 @@ 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(64) DEFAULT NULL,
+ `DIGEST` varchar(32) DEFAULT NULL,
`DIGEST_TEXT` longtext,
`CURRENT_SCHEMA` varchar(64) DEFAULT NULL,
`OBJECT_TYPE` varchar(64) DEFAULT NULL,
=== modified file 'mysql-test/suite/perfschema/r/table_schema.result'
--- a/mysql-test/suite/perfschema/r/table_schema.result 2011-12-05 13:12:47 +0000
+++ b/mysql-test/suite/perfschema/r/table_schema.result 2012-02-02 12:04:43 +0000
@@ -82,7 +82,7 @@ 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 DIGEST 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 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
@@ -122,7 +122,7 @@ 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 DIGEST 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 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
@@ -162,7 +162,7 @@ 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 DIGEST 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 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
@@ -219,7 +219,7 @@ 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 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) 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
@@ -245,6 +245,8 @@ def performance_schema events_statements
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.000000 NO timestamp NULL NULL NULL NULL 6 NULL NULL timestamp(6) select,insert,update,references
+def performance_schema events_statements_summary_by_digest LAST_SEEN 28 0000-00-00 00:00:00.000000 NO timestamp NULL NULL NULL NULL 6 NULL NULL timestamp(6) 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/t/statements_digest_long_query-master.opt'
--- a/mysql-test/suite/perfschema/t/statements_digest_long_query-master.opt 2012-01-16 19:07:57 +0000
+++ b/mysql-test/suite/perfschema/t/statements_digest_long_query-master.opt 2012-02-02 12:04:43 +0000
@@ -1 +1 @@
---thread_stack=327680
+--thread_stack=655360
=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql 2012-01-23 07:25:50 +0000
+++ b/scripts/mysql_system_tables.sql 2012-02-02 12:04:43 +0000
@@ -1133,7 +1133,7 @@ SET @cmd="CREATE TABLE performance_schem
"TIMER_WAIT BIGINT unsigned,"
"LOCK_TIME bigint unsigned not null,"
"SQL_TEXT LONGTEXT,"
- "DIGEST VARCHAR(64),"
+ "DIGEST VARCHAR(32),"
"DIGEST_TEXT LONGTEXT,"
"CURRENT_SCHEMA VARCHAR(64),"
"OBJECT_TYPE VARCHAR(64),"
@@ -1185,7 +1185,7 @@ SET @cmd="CREATE TABLE performance_schem
"TIMER_WAIT BIGINT unsigned,"
"LOCK_TIME bigint unsigned not null,"
"SQL_TEXT LONGTEXT,"
- "DIGEST VARCHAR(64),"
+ "DIGEST VARCHAR(32),"
"DIGEST_TEXT LONGTEXT,"
"CURRENT_SCHEMA VARCHAR(64),"
"OBJECT_TYPE VARCHAR(64),"
@@ -1237,7 +1237,7 @@ SET @cmd="CREATE TABLE performance_schem
"TIMER_WAIT BIGINT unsigned,"
"LOCK_TIME bigint unsigned not null,"
"SQL_TEXT LONGTEXT,"
- "DIGEST VARCHAR(64),"
+ "DIGEST VARCHAR(32),"
"DIGEST_TEXT LONGTEXT,"
"CURRENT_SCHEMA VARCHAR(64),"
"OBJECT_TYPE VARCHAR(64),"
@@ -1515,7 +1515,7 @@ DROP PREPARE stmt;
--
SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest("
- "DIGEST VARCHAR(64),"
+ "DIGEST VARCHAR(32),"
"DIGEST_TEXT LONGTEXT,"
"COUNT_STAR BIGINT unsigned not null,"
"SUM_TIMER_WAIT BIGINT unsigned not null,"
@@ -1540,7 +1540,9 @@ SET @cmd="CREATE TABLE performance_schem
"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"
+ "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null,"
+ "FIRST_SEEN TIMESTAMP(6) default 0,"
+ "LAST_SEEN TIMESTAMP(6) default 0"
")ENGINE=PERFORMANCE_SCHEMA;";
=== modified file 'storage/perfschema/pfs_digest.cc'
--- a/storage/perfschema/pfs_digest.cc 2012-02-02 08:15:42 +0000
+++ b/storage/perfschema/pfs_digest.cc 2012-02-02 12:04:43 +0000
@@ -262,6 +262,8 @@ find_or_create_digest(PFS_thread* thread
PFS_statements_digest_stat **entry;
PFS_statements_digest_stat *pfs= NULL;
+ ulonglong now= my_micro_time();
+
/* Lookup LF_HASH using this new key. */
entry= reinterpret_cast<PFS_statements_digest_stat**>
(lf_hash_search(&digest_hash, pins,
@@ -272,12 +274,15 @@ find_or_create_digest(PFS_thread* thread
/*
If statement digest entry doesn't exist.
*/
- if(digest_index==0)
+ 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;
}
@@ -292,11 +297,16 @@ find_or_create_digest(PFS_thread* thread
*/
pfs->m_digest_storage.m_byte_count= digest_storage->m_byte_count;
pfs->m_digest_storage.m_last_id_index= digest_storage->m_last_id_index;
- memcpy(pfs->m_digest_storage.m_token_array, digest_storage->m_token_array, PFS_MAX_DIGEST_STORAGE_SIZE);
- memcpy(pfs->m_digest_storage.m_digest_hash.m_md5, digest_storage->m_digest_hash.m_md5, 16);
+ memcpy(pfs->m_digest_storage.m_token_array, digest_storage->m_token_array,
+ PFS_MAX_DIGEST_STORAGE_SIZE);
+ memcpy(pfs->m_digest_storage.m_digest_hash.m_md5,
+ digest_storage->m_digest_hash.m_md5, 16);
/* Set digest hash/LF Hash search key. */
memcpy(pfs->m_md5_hash.m_md5, hash_key, 16);
+
+ pfs->m_first_seen= now;
+ pfs->m_last_seen= now;
/* Increment index. */
digest_index++;
@@ -304,7 +314,7 @@ find_or_create_digest(PFS_thread* thread
if(digest_index%statements_digest_size == 0)
{
/*
- Digest stat array is full. Now all stat for all further
+ Digest stat array is full. Now stat for all further
entries will go into index 0.
*/
digest_index= 0;
@@ -324,9 +334,10 @@ find_or_create_digest(PFS_thread* thread
else if (entry && (entry != MY_ERRPTR))
{
/*
- If stmt digest already exists, update stat and return
+ If stmt digest already exists, update stat and return.
*/
pfs= *entry;
+ pfs->m_last_seen= now;
lf_hash_search_unpin(pins);
return pfs;
}
@@ -348,6 +359,8 @@ void reset_esms_by_digest()
{
statements_digest_stat_array[index].m_md5_hash.m_md5[0]= '\0';
statements_digest_stat_array[index].m_stat.reset();
+ statements_digest_stat_array[index].m_first_seen= 0;
+ statements_digest_stat_array[index].m_last_seen= 0;
}
/*
=== modified file 'storage/perfschema/pfs_digest.h'
--- a/storage/perfschema/pfs_digest.h 2012-02-02 08:15:42 +0000
+++ b/storage/perfschema/pfs_digest.h 2012-02-02 12:04:43 +0000
@@ -67,6 +67,12 @@ struct PFS_statements_digest_stat
Statement stat.
*/
PFS_statement_stat m_stat;
+
+ /**
+ First Seen/last seen.
+ */
+ ulonglong m_first_seen;
+ ulonglong m_last_seen;
};
=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc 2012-01-31 06:34:29 +0000
+++ b/storage/perfschema/pfs_engine_table.cc 2012-02-02 12:04:43 +0000
@@ -508,6 +508,16 @@ void PFS_engine_table::set_field_enum(Fi
f2->store_type(value);
}
+void PFS_engine_table::set_field_timestamp(Field *f, ulonglong value)
+{
+ struct timeval tm;
+ tm.tv_sec= (long) value / 1000000;
+ tm.tv_usec= (long) value % 1000000;
+ DBUG_ASSERT(f->real_type() == MYSQL_TYPE_TIMESTAMP2);
+ Field_timestampf *f2= (Field_timestampf*) f;
+ f2->store_timestamp(& tm);
+}
+
ulonglong PFS_engine_table::get_field_enum(Field *f)
{
DBUG_ASSERT(f->real_type() == MYSQL_TYPE_ENUM);
=== modified file 'storage/perfschema/pfs_engine_table.h'
--- a/storage/perfschema/pfs_engine_table.h 2012-01-24 23:42:36 +0000
+++ b/storage/perfschema/pfs_engine_table.h 2012-02-02 12:04:43 +0000
@@ -120,6 +120,12 @@ public:
*/
static void set_field_enum(Field *f, ulonglong value);
/**
+ Helper, assign a value to a timestamp field.
+ @param f the field to set
+ @param value the value to assign
+ */
+ static void set_field_timestamp(Field *f, ulonglong value);
+ /**
Helper, read a value from an enum field.
@param f the field to read
@return the field value
=== modified file 'storage/perfschema/table_esms_by_digest.cc'
--- a/storage/perfschema/table_esms_by_digest.cc 2012-02-02 08:15:42 +0000
+++ b/storage/perfschema/table_esms_by_digest.cc 2012-02-02 12:04:43 +0000
@@ -36,7 +36,7 @@ static const TABLE_FIELD_TYPE field_type
{
{
{ C_STRING_WITH_LEN("DIGEST") },
- { C_STRING_WITH_LEN("varchar(64)") },
+ { C_STRING_WITH_LEN("varchar(32)") },
{ NULL, 0}
},
{
@@ -163,12 +163,22 @@ static const TABLE_FIELD_TYPE field_type
{ 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=
-{ 26, field_types };
+{ 28, field_types };
PFS_engine_table_share
table_esms_by_digest::m_share=
@@ -263,6 +273,8 @@ table_esms_by_digest::rnd_pos(const void
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);
/*
@@ -300,6 +312,12 @@ int table_esms_by_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;
=== modified file 'storage/perfschema/table_esms_by_digest.h'
--- a/storage/perfschema/table_esms_by_digest.h 2011-12-05 18:32:34 +0000
+++ b/storage/perfschema/table_esms_by_digest.h 2012-02-02 12:04:43 +0000
@@ -35,11 +35,16 @@
*/
struct row_esms_by_digest
{
- /** Columns TBD. Adding few dummy as of now. */
+ /** 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. */
=== modified file 'storage/perfschema/table_events_statements.cc'
--- a/storage/perfschema/table_events_statements.cc 2012-02-02 08:15:42 +0000
+++ b/storage/perfschema/table_events_statements.cc 2012-02-02 12:04:43 +0000
@@ -84,7 +84,7 @@ static const TABLE_FIELD_TYPE field_type
},
{
{ C_STRING_WITH_LEN("DIGEST") },
- { C_STRING_WITH_LEN("varchar(64)") },
+ { C_STRING_WITH_LEN("varchar(32)") },
{ NULL, 0}
},
{
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3422 to 3423) WL#5767 | Mayank Prasad | 2 Feb |