1/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16#ifndef TABLE_EWS_BY_THREAD_BY_EVENT_NAME_H
17#define TABLE_EWS_BY_THREAD_BY_EVENT_NAME_H
18
19/**
20 @file storage/perfschema/table_ews_by_thread_by_event_name.h
21 Table EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (declarations).
22*/
23
24#include "pfs_column_types.h"
25#include "pfs_engine_table.h"
26#include "pfs_instr_class.h"
27#include "pfs_instr.h"
28#include "table_helper.h"
29
30/**
31 @addtogroup Performance_schema_tables
32 @{
33*/
34
35/**
36 A row of table
37 PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
38*/
39struct row_ews_by_thread_by_event_name
40{
41 /** Column THREAD_ID. */
42 ulonglong m_thread_internal_id;
43 /** Column EVENT_NAME. */
44 PFS_event_name_row m_event_name;
45 /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
46 PFS_stat_row m_stat;
47};
48
49/**
50 Position of a cursor on
51 PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
52 Index 1 on thread (0 based)
53 Index 2 on instrument view
54 Index 3 on instrument class (1 based)
55*/
56struct pos_ews_by_thread_by_event_name
57: public PFS_triple_index, public PFS_instrument_view_constants
58{
59 pos_ews_by_thread_by_event_name()
60 : PFS_triple_index(0, FIRST_VIEW, 1)
61 {}
62
63 inline void reset(void)
64 {
65 m_index_1= 0;
66 m_index_2= FIRST_VIEW;
67 m_index_3= 1;
68 }
69
70 inline bool has_more_thread(void)
71 { return (m_index_1 < thread_max); }
72
73 inline void next_thread(void)
74 {
75 m_index_1++;
76 m_index_2= FIRST_VIEW;
77 m_index_3= 1;
78 }
79
80 inline bool has_more_view(void)
81 { return (m_index_2 <= LAST_VIEW); }
82
83 inline void next_view(void)
84 {
85 m_index_2++;
86 m_index_3= 1;
87 }
88};
89
90/** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME. */
91class table_ews_by_thread_by_event_name : public PFS_engine_table
92{
93public:
94 /** Table share */
95 static PFS_engine_table_share m_share;
96 static PFS_engine_table* create();
97 static int delete_all_rows();
98
99 virtual int rnd_next();
100 virtual int rnd_pos(const void *pos);
101 virtual void reset_position(void);
102
103protected:
104 virtual int read_row_values(TABLE *table,
105 unsigned char *buf,
106 Field **fields,
107 bool read_all);
108
109 table_ews_by_thread_by_event_name();
110
111public:
112 ~table_ews_by_thread_by_event_name()
113 {}
114
115protected:
116 void make_row(PFS_thread *thread, PFS_instr_class *klass);
117
118private:
119 /** Table share lock. */
120 static THR_LOCK m_table_lock;
121
122 /** Current row. */
123 row_ews_by_thread_by_event_name m_row;
124 /** True is the current row exists. */
125 bool m_row_exists;
126 /** Current position. */
127 pos_ews_by_thread_by_event_name m_pos;
128 /** Next position. */
129 pos_ews_by_thread_by_event_name m_next_pos;
130};
131
132/** @} */
133#endif
134