summaryrefslogtreecommitdiff
path: root/storage/perfschema/table_esgs_by_host_by_event_name.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/perfschema/table_esgs_by_host_by_event_name.cc')
-rw-r--r--storage/perfschema/table_esgs_by_host_by_event_name.cc50
1 files changed, 31 insertions, 19 deletions
diff --git a/storage/perfschema/table_esgs_by_host_by_event_name.cc b/storage/perfschema/table_esgs_by_host_by_event_name.cc
index 86cc2eb1b86..1d3f6126862 100644
--- a/storage/perfschema/table_esgs_by_host_by_event_name.cc
+++ b/storage/perfschema/table_esgs_by_host_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2012, 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,7 +26,7 @@
*/
#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"
@@ -34,6 +34,8 @@
#include "pfs_global.h"
#include "pfs_account.h"
#include "pfs_visitor.h"
+#include "pfs_buffer_container.h"
+#include "field.h"
THR_LOCK table_esgs_by_host_by_event_name::m_table_lock;
@@ -45,8 +47,7 @@ table_esgs_by_host_by_event_name::m_share=
table_esgs_by_host_by_event_name::create,
NULL, /* write_row */
table_esgs_by_host_by_event_name::delete_all_rows,
- NULL, /* get_row_count */
- 1000, /* records */
+ table_esgs_by_host_by_event_name::get_row_count,
sizeof(pos_esgs_by_host_by_event_name),
&m_table_lock,
{ C_STRING_WITH_LEN("CREATE TABLE events_stages_summary_by_host_by_event_name("
@@ -56,7 +57,8 @@ table_esgs_by_host_by_event_name::m_share=
"SUM_TIMER_WAIT BIGINT unsigned not null,"
"MIN_TIMER_WAIT BIGINT unsigned not null,"
"AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null)") }
+ "MAX_TIMER_WAIT BIGINT unsigned not null)") },
+ false /* perpetual */
};
PFS_engine_table*
@@ -74,6 +76,12 @@ table_esgs_by_host_by_event_name::delete_all_rows(void)
return 0;
}
+ha_rows
+table_esgs_by_host_by_event_name::get_row_count(void)
+{
+ return global_host_container.get_row_count() * stage_class_max;
+}
+
table_esgs_by_host_by_event_name::table_esgs_by_host_by_event_name()
: PFS_engine_table(&m_share, &m_pos),
m_row_exists(false), m_pos(), m_next_pos()
@@ -95,13 +103,14 @@ int table_esgs_by_host_by_event_name::rnd_next(void)
{
PFS_host *host;
PFS_stage_class *stage_class;
+ bool has_more_host= true;
for (m_pos.set_at(&m_next_pos);
- m_pos.has_more_host();
+ has_more_host;
m_pos.next_host())
{
- host= &host_array[m_pos.m_index_1];
- if (host->m_lock.is_populated())
+ host= global_host_container.get(m_pos.m_index_1, & has_more_host);
+ if (host != NULL)
{
stage_class= find_stage_class(m_pos.m_index_2);
if (stage_class)
@@ -123,17 +132,16 @@ table_esgs_by_host_by_event_name::rnd_pos(const void *pos)
PFS_stage_class *stage_class;
set_position(pos);
- DBUG_ASSERT(m_pos.m_index_1 < host_max);
- host= &host_array[m_pos.m_index_1];
- if (! host->m_lock.is_populated())
- return HA_ERR_RECORD_DELETED;
-
- stage_class= find_stage_class(m_pos.m_index_2);
- if (stage_class)
+ host= global_host_container.get(m_pos.m_index_1);
+ if (host != NULL)
{
- make_row(host, stage_class);
- return 0;
+ stage_class= find_stage_class(m_pos.m_index_2);
+ if (stage_class)
+ {
+ make_row(host, stage_class);
+ return 0;
+ }
}
return HA_ERR_RECORD_DELETED;
@@ -142,7 +150,7 @@ table_esgs_by_host_by_event_name::rnd_pos(const void *pos)
void table_esgs_by_host_by_event_name
::make_row(PFS_host *host, PFS_stage_class *klass)
{
- pfs_lock lock;
+ pfs_optimistic_state lock;
m_row_exists= false;
host->m_lock.begin_optimistic_lock(&lock);
@@ -153,7 +161,11 @@ void table_esgs_by_host_by_event_name
m_row.m_event_name.make_row(klass);
PFS_connection_stage_visitor visitor(klass);
- PFS_connection_iterator::visit_host(host, true, true, & visitor);
+ PFS_connection_iterator::visit_host(host,
+ true, /* accounts */
+ true, /* threads */
+ false, /* THDs */
+ & visitor);
if (! host->m_lock.end_optimistic_lock(&lock))
return;