diff options
author | Sergei Golubchik <serg@mariadb.org> | 2019-12-10 15:35:00 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-03-10 19:24:22 +0100 |
commit | 0ea717f51a152afdb3791195c4a25ee0baa2faac (patch) | |
tree | 0eb10fc1413d1583ffdec2c18a66491d7befeec2 /storage/perfschema/table_esms_by_user_by_event_name.cc | |
parent | dfe6e914e58472159f34a8a4c9288ff61eac479f (diff) | |
download | mariadb-git-0ea717f51a152afdb3791195c4a25ee0baa2faac.tar.gz |
P_S 5.7.28
Diffstat (limited to 'storage/perfschema/table_esms_by_user_by_event_name.cc')
-rw-r--r-- | storage/perfschema/table_esms_by_user_by_event_name.cc | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/storage/perfschema/table_esms_by_user_by_event_name.cc b/storage/perfschema/table_esms_by_user_by_event_name.cc index f8708ac9a14..c0517748b99 100644 --- a/storage/perfschema/table_esms_by_user_by_event_name.cc +++ b/storage/perfschema/table_esms_by_user_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,14 +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_user_by_event_name.h" #include "pfs_global.h" -#include "pfs_account.h" #include "pfs_visitor.h" +#include "pfs_buffer_container.h" +#include "field.h" THR_LOCK table_esms_by_user_by_event_name::m_table_lock; @@ -45,12 +46,11 @@ table_esms_by_user_by_event_name::m_share= table_esms_by_user_by_event_name::create, NULL, /* write_row */ table_esms_by_user_by_event_name::delete_all_rows, - NULL, /* get_row_count */ - 1000, /* records */ + table_esms_by_user_by_event_name::get_row_count, sizeof(pos_esms_by_user_by_event_name), &m_table_lock, { C_STRING_WITH_LEN("CREATE TABLE events_statements_summary_by_user_by_event_name(" - "USER CHAR(16) collate utf8_bin default null," + "USER CHAR(" USERNAME_CHAR_LENGTH_STR ") collate utf8_bin default null," "EVENT_NAME VARCHAR(128) not null," "COUNT_STAR BIGINT unsigned not null," "SUM_TIMER_WAIT BIGINT unsigned not null," @@ -75,7 +75,8 @@ table_esms_by_user_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* @@ -93,6 +94,12 @@ table_esms_by_user_by_event_name::delete_all_rows(void) return 0; } +ha_rows +table_esms_by_user_by_event_name::get_row_count(void) +{ + return global_user_container.get_row_count() * statement_class_max; +} + table_esms_by_user_by_event_name::table_esms_by_user_by_event_name() : PFS_engine_table(&m_share, &m_pos), m_row_exists(false), m_pos(), m_next_pos() @@ -114,13 +121,14 @@ int table_esms_by_user_by_event_name::rnd_next(void) { PFS_user *user; PFS_statement_class *statement_class; + bool has_more_user= true; for (m_pos.set_at(&m_next_pos); - m_pos.has_more_user(); + has_more_user; m_pos.next_user()) { - user= &user_array[m_pos.m_index_1]; - if (user->m_lock.is_populated()) + user= global_user_container.get(m_pos.m_index_1, & has_more_user); + if (user != NULL) { statement_class= find_statement_class(m_pos.m_index_2); if (statement_class) @@ -142,17 +150,16 @@ table_esms_by_user_by_event_name::rnd_pos(const void *pos) PFS_statement_class *statement_class; set_position(pos); - DBUG_ASSERT(m_pos.m_index_1 < user_max); - user= &user_array[m_pos.m_index_1]; - if (! user->m_lock.is_populated()) - return HA_ERR_RECORD_DELETED; - - statement_class= find_statement_class(m_pos.m_index_2); - if (statement_class) + user= global_user_container.get(m_pos.m_index_1); + if (user != NULL) { - make_row(user, statement_class); - return 0; + statement_class= find_statement_class(m_pos.m_index_2); + if (statement_class) + { + make_row(user, statement_class); + return 0; + } } return HA_ERR_RECORD_DELETED; @@ -161,7 +168,7 @@ table_esms_by_user_by_event_name::rnd_pos(const void *pos) void table_esms_by_user_by_event_name ::make_row(PFS_user *user, PFS_statement_class *klass) { - pfs_lock lock; + pfs_optimistic_state lock; m_row_exists= false; if (klass->is_mutable()) @@ -175,7 +182,11 @@ void table_esms_by_user_by_event_name m_row.m_event_name.make_row(klass); PFS_connection_statement_visitor visitor(klass); - PFS_connection_iterator::visit_user(user, true, true, & visitor); + PFS_connection_iterator::visit_user(user, + true, /* accounts */ + true, /* threads */ + false, /* THDs */ + & visitor); if (! user->m_lock.end_optimistic_lock(&lock)) return; |