From: Christopher Powers Date: February 11 2012 8:34pm Subject: bzr push into mysql-trunk-wl5767 branch (chris.powers:3427 to 3428) WL#5767 List-Archive: http://lists.mysql.com/commits/142838 Message-Id: <201202112031.q1BKVhIA024266@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3428 Christopher Powers 2012-02-11 WL#5767 PERFORMANCE_SCHEMA STATEMENT DIGEST - Fixed PB2 crash modified: storage/perfschema/pfs_digest.cc storage/perfschema/pfs_digest.h storage/perfschema/pfs_server.cc storage/perfschema/table_esms_by_digest.cc 3427 Christopher Powers 2012-02-10 WL#5767 PERFORMANCE_SCHEMA STATEMENT DIGEST - Added MYSQL_ADD_TOKEN() to PSI interface, replaced macro in sql_lex.cc - Added data flow comments to doxygen LLD in pfs.cc - Minor style changes in pfs_digest.cc modified: include/mysql/psi/mysql_statement.h sql/sql_lex.cc storage/perfschema/pfs.cc storage/perfschema/pfs_digest.cc storage/perfschema/table_events_statements.cc === modified file 'storage/perfschema/pfs_digest.cc' --- a/storage/perfschema/pfs_digest.cc 2012-02-10 23:14:57 +0000 +++ b/storage/perfschema/pfs_digest.cc 2012-02-11 20:33:44 +0000 @@ -56,7 +56,8 @@ <*><2> */ -unsigned int statements_digest_size= 0; +ulong digest_max= 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. */ @@ -74,24 +75,26 @@ static bool digest_hash_inited= false; Initialize table EVENTS_STATEMENTS_SUMMARY_BY_DIGEST. @param digest_sizing */ -int init_digest(unsigned int statements_digest_sizing) +int init_digest(const PFS_global_param *param) { unsigned int index; + digest_max= param->m_digest_sizing; + /* Allocate memory for statements_digest_stat_array based on performance_schema_digests_size values */ - statements_digest_size= statements_digest_sizing; + digest_max= param->m_digest_sizing; - if (statements_digest_size == 0) + if (digest_max == 0) return 0; statements_digest_stat_array= - PFS_MALLOC_ARRAY(statements_digest_size, PFS_statements_digest_stat, + PFS_MALLOC_ARRAY(digest_max, PFS_statements_digest_stat, MYF(MY_ZEROFILL)); - for (index= 0; index < statements_digest_size; index++) + for (index= 0; index < digest_max; index++) { statements_digest_stat_array[index].reset(); } @@ -219,7 +222,7 @@ find_or_create_digest(PFS_thread* thread digest_index++; - if(digest_index%statements_digest_size == 0) + if(digest_index % digest_max == 0) { /* Digest stat array is full. Now stat for all further @@ -297,7 +300,7 @@ void reset_esms_by_digest() return; /* Reset statements_digest_stat_array. */ - for (index= 0; index < statements_digest_size; index++) + for (index= 0; index < digest_max; index++) { statements_digest_stat_array[index].reset(); } === modified file 'storage/perfschema/pfs_digest.h' --- a/storage/perfschema/pfs_digest.h 2012-02-10 12:55:57 +0000 +++ b/storage/perfschema/pfs_digest.h 2012-02-11 20:33:44 +0000 @@ -31,6 +31,7 @@ extern bool flag_statements_digest; extern unsigned int statements_digest_size; extern unsigned int digest_index; +extern ulong digest_max; struct PFS_thread; /** @@ -67,7 +68,7 @@ struct PFS_statements_digest_stat void reset(); }; -int init_digest(unsigned int digest_sizing); +int init_digest(const PFS_global_param *param); void cleanup_digest(); int init_digest_hash(void); === modified file 'storage/perfschema/pfs_server.cc' --- a/storage/perfschema/pfs_server.cc 2012-01-31 06:34:29 +0000 +++ b/storage/perfschema/pfs_server.cc 2012-02-11 20:33:44 +0000 @@ -104,7 +104,7 @@ initialize_performance_schema(const PFS_ init_user_hash() || init_account(param) || init_account_hash() || - init_digest(param->m_digest_sizing) || + init_digest(param) || init_digest_hash()) { /* === modified file 'storage/perfschema/table_esms_by_digest.cc' --- a/storage/perfschema/table_esms_by_digest.cc 2012-02-03 11:38:42 +0000 +++ b/storage/perfschema/table_esms_by_digest.cc 2012-02-11 20:33:44 +0000 @@ -29,6 +29,7 @@ #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; @@ -227,20 +228,17 @@ int table_esms_by_digest::rnd_next(void) if(statements_digest_stat_array == NULL) return HA_ERR_END_OF_FILE; - m_pos.set_at(&m_next_pos); - digest_stat= &statements_digest_stat_array[m_pos.m_index]; - - /* - If byte_count is not 0 i.e. its a valid entry in stat array or - If it is a record at index 0 of statements_digest_stat_array, - make a new row. - */ - if(digest_stat->m_digest_storage.m_byte_count != 0 || - m_pos.m_index == 0) - { - make_row(digest_stat); - m_next_pos.set_after(&m_pos); - return 0; + 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_digest_storage.m_byte_count != 0) + { + make_row(digest_stat); + m_next_pos.set_after(&m_pos); + return 0; + } } return HA_ERR_END_OF_FILE; No bundle (reason: useless for push emails).