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_GLOBAL_BY_EVENT_NAME_H
17#define TABLE_EWS_GLOBAL_BY_EVENT_NAME_H
18
19/**
20 @file storage/perfschema/table_ews_global_by_event_name.h
21 Table EVENTS_WAITS_SUMMARY_GLOBAL_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_GLOBAL_BY_EVENT_NAME.
38*/
39struct row_ews_global_by_event_name
40{
41 /** Column EVENT_NAME. */
42 PFS_event_name_row m_event_name;
43 /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
44 PFS_stat_row m_stat;
45};
46
47/**
48 Position of a cursor on
49 PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME.
50 Index 1 on instrument view
51 Index 2 on instrument class (1 based)
52*/
53struct pos_ews_global_by_event_name
54: public PFS_double_index, public PFS_instrument_view_constants
55{
56 pos_ews_global_by_event_name()
57 : PFS_double_index(FIRST_VIEW, 1)
58 {}
59
60 inline void reset(void)
61 {
62 m_index_1= FIRST_VIEW;
63 m_index_2= 1;
64 }
65
66 inline bool has_more_view(void)
67 { return (m_index_1 <= LAST_VIEW); }
68
69 inline void next_view(void)
70 {
71 m_index_1++;
72 m_index_2= 1;
73 }
74};
75
76/** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME. */
77class table_ews_global_by_event_name : public PFS_engine_table
78{
79public:
80 /** Table share */
81 static PFS_engine_table_share m_share;
82 static PFS_engine_table* create();
83 static int delete_all_rows();
84
85 virtual int rnd_next();
86 virtual int rnd_pos(const void *pos);
87 virtual void reset_position(void);
88
89protected:
90 virtual int read_row_values(TABLE *table,
91 unsigned char *buf,
92 Field **fields,
93 bool read_all);
94
95 table_ews_global_by_event_name();
96
97public:
98 ~table_ews_global_by_event_name()
99 {}
100
101protected:
102 void make_mutex_row(PFS_mutex_class *klass);
103 void make_rwlock_row(PFS_rwlock_class *klass);
104 void make_cond_row(PFS_cond_class *klass);
105 void make_file_row(PFS_file_class *klass);
106 void make_table_io_row(PFS_instr_class *klass);
107 void make_table_lock_row(PFS_instr_class *klass);
108 void make_socket_row(PFS_socket_class *klass);
109 void make_idle_row(PFS_instr_class *klass);
110
111private:
112 /** Table share lock. */
113 static THR_LOCK m_table_lock;
114
115 /** Current row. */
116 row_ews_global_by_event_name m_row;
117 /** True is the current row exists. */
118 bool m_row_exists;
119 /** Current position. */
120 pos_ews_global_by_event_name m_pos;
121 /** Next position. */
122 pos_ews_global_by_event_name m_next_pos;
123};
124
125/** @} */
126#endif
127