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_ESMS_BY_THREAD_BY_EVENT_NAME_H
17#define TABLE_ESMS_BY_THREAD_BY_EVENT_NAME_H
18
19/**
20 @file storage/perfschema/table_esms_by_thread_by_event_name.h
21 Table EVENTS_STATEMENTS_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_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
38*/
39struct row_esms_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_statement_stat_row m_stat;
47};
48
49/**
50 Position of a cursor on
51 PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
52 Index 1 on thread (0 based).
53 Index 2 on statement class (1 based).
54*/
55struct pos_esms_by_thread_by_event_name
56: public PFS_double_index, public PFS_instrument_view_constants
57{
58 pos_esms_by_thread_by_event_name()
59 : PFS_double_index(0, 1)
60 {}
61
62 inline void reset(void)
63 {
64 m_index_1= 0;
65 m_index_2= 1;
66 }
67
68 inline bool has_more_thread(void)
69 { return (m_index_1 < thread_max); }
70
71 inline void next_thread(void)
72 {
73 m_index_1++;
74 m_index_2= 1;
75 }
76
77 inline void next_statement(void)
78 {
79 m_index_2++;
80 }
81};
82
83/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME. */
84class table_esms_by_thread_by_event_name : public PFS_engine_table
85{
86public:
87 /** Table share */
88 static PFS_engine_table_share m_share;
89 static PFS_engine_table* create();
90 static int delete_all_rows();
91
92 virtual int rnd_init(bool scan);
93 virtual int rnd_next();
94 virtual int rnd_pos(const void *pos);
95 virtual void reset_position(void);
96
97protected:
98 virtual int read_row_values(TABLE *table,
99 unsigned char *buf,
100 Field **fields,
101 bool read_all);
102
103 table_esms_by_thread_by_event_name();
104
105public:
106 ~table_esms_by_thread_by_event_name()
107 {}
108
109protected:
110 void make_row(PFS_thread *thread, PFS_statement_class *klass);
111
112private:
113 /** Table share lock. */
114 static THR_LOCK m_table_lock;
115
116 /** Current row. */
117 row_esms_by_thread_by_event_name m_row;
118 /** True is the current row exists. */
119 bool m_row_exists;
120 /** Current position. */
121 pos_esms_by_thread_by_event_name m_pos;
122 /** Next position. */
123 pos_esms_by_thread_by_event_name m_next_pos;
124};
125
126/** @} */
127#endif
128