diff options
Diffstat (limited to 'storage/perfschema/table_esms_by_thread_by_event_name.cc')
-rw-r--r-- | storage/perfschema/table_esms_by_thread_by_event_name.cc | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/storage/perfschema/table_esms_by_thread_by_event_name.cc b/storage/perfschema/table_esms_by_thread_by_event_name.cc index 0a7cf46986c..306edc769c8 100644 --- a/storage/perfschema/table_esms_by_thread_by_event_name.cc +++ b/storage/perfschema/table_esms_by_thread_by_event_name.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -26,13 +26,15 @@ */ #include "my_global.h" -#include "my_pthread.h" +#include "my_thread.h" #include "pfs_instr_class.h" #include "pfs_column_types.h" #include "pfs_column_values.h" #include "table_esms_by_thread_by_event_name.h" #include "pfs_global.h" #include "pfs_visitor.h" +#include "pfs_buffer_container.h" +#include "field.h" THR_LOCK table_esms_by_thread_by_event_name::m_table_lock; @@ -44,8 +46,7 @@ table_esms_by_thread_by_event_name::m_share= table_esms_by_thread_by_event_name::create, NULL, /* write_row */ table_esms_by_thread_by_event_name::delete_all_rows, - NULL, /* get_row_count */ - 1000, /* records */ + table_esms_by_thread_by_event_name::get_row_count, sizeof(pos_esms_by_thread_by_event_name), &m_table_lock, { C_STRING_WITH_LEN("CREATE TABLE events_statements_summary_by_thread_by_event_name(" @@ -74,7 +75,8 @@ table_esms_by_thread_by_event_name::m_share= "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)") }, + false /* perpetual */ }; PFS_engine_table* @@ -90,6 +92,12 @@ table_esms_by_thread_by_event_name::delete_all_rows(void) return 0; } +ha_rows +table_esms_by_thread_by_event_name::get_row_count(void) +{ + return global_thread_container.get_row_count() * statement_class_max; +} + table_esms_by_thread_by_event_name::table_esms_by_thread_by_event_name() : PFS_engine_table(&m_share, &m_pos), m_row_exists(false), m_pos(), m_next_pos() @@ -111,18 +119,14 @@ int table_esms_by_thread_by_event_name::rnd_next(void) { PFS_thread *thread; PFS_statement_class *statement_class; + bool has_more_thread= true; for (m_pos.set_at(&m_next_pos); - m_pos.has_more_thread(); + has_more_thread; m_pos.next_thread()) { - thread= &thread_array[m_pos.m_index_1]; - - /* - Important note: the thread scan is the outer loop (index 1), - to minimize the number of calls to atomic operations. - */ - if (thread->m_lock.is_populated()) + thread= global_thread_container.get(m_pos.m_index_1, & has_more_thread); + if (thread != NULL) { statement_class= find_statement_class(m_pos.m_index_2); if (statement_class) @@ -144,17 +148,16 @@ table_esms_by_thread_by_event_name::rnd_pos(const void *pos) PFS_statement_class *statement_class; set_position(pos); - DBUG_ASSERT(m_pos.m_index_1 < thread_max); - thread= &thread_array[m_pos.m_index_1]; - if (! thread->m_lock.is_populated()) - return HA_ERR_RECORD_DELETED; - - statement_class= find_statement_class(m_pos.m_index_2); - if (statement_class) + thread= global_thread_container.get(m_pos.m_index_1); + if (thread != NULL) { - make_row(thread, statement_class); - return 0; + statement_class= find_statement_class(m_pos.m_index_2); + if (statement_class) + { + make_row(thread, statement_class); + return 0; + } } return HA_ERR_RECORD_DELETED; @@ -163,7 +166,7 @@ table_esms_by_thread_by_event_name::rnd_pos(const void *pos) void table_esms_by_thread_by_event_name ::make_row(PFS_thread *thread, PFS_statement_class *klass) { - pfs_lock lock; + pfs_optimistic_state lock; m_row_exists= false; if (klass->is_mutable()) |