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_IO_WAIT_SUMMARY_BY_INDEX_USAGE_H
17#define TABLE_IO_WAIT_SUMMARY_BY_INDEX_USAGE_H
18
19/**
20 @file storage/perfschema/table_tiws_by_index_usage.h
21 Table TABLE_IO_WAIT_SUMMARY_BY_INDEX_USAGE (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.TABLE_IO_WAIT_SUMMARY_BY_INDEX.
38*/
39struct row_tiws_by_index_usage
40{
41 /** Column OBJECT_TYPE, SCHEMA_NAME, OBJECT_NAME, INDEX_NAME. */
42 PFS_index_row m_index;
43 /** Columns COUNT/SUM/MIN/AVG/MAX (+_READ, +WRITE). */
44 PFS_table_io_stat_row m_stat;
45};
46
47/**
48 Position of a cursor on
49 PERFORMANCE_SCHEMA.TABLE_IO_WAIT_SUMMARY_BY_INDEX.
50 Index 1 on table_share_array (0 based)
51 Index 2 on index (0 based)
52*/
53struct pos_tiws_by_index_usage : public PFS_double_index
54{
55 pos_tiws_by_index_usage()
56 : PFS_double_index(0, 0)
57 {}
58
59 inline void reset(void)
60 {
61 m_index_1= 0;
62 m_index_2= 0;
63 }
64
65 inline bool has_more_table(void)
66 {
67 return (m_index_1 < table_share_max);
68 }
69
70 inline void next_table(void)
71 {
72 m_index_1++;
73 m_index_2= 0;
74 }
75};
76
77/** Table PERFORMANCE_SCHEMA.TABLE_IO_WAIT_SUMMARY_BY_INDEX. */
78class table_tiws_by_index_usage : public PFS_engine_table
79{
80public:
81 /** Table share */
82 static PFS_engine_table_share m_share;
83 static PFS_engine_table* create();
84 static int delete_all_rows();
85
86 virtual int rnd_init(bool scan);
87 virtual int rnd_next();
88 virtual int rnd_pos(const void *pos);
89 virtual void reset_position(void);
90
91protected:
92 virtual int read_row_values(TABLE *table,
93 unsigned char *buf,
94 Field **fields,
95 bool read_all);
96
97 table_tiws_by_index_usage();
98
99public:
100 ~table_tiws_by_index_usage()
101 {}
102
103protected:
104 void make_row(PFS_table_share *table_share, uint index);
105
106private:
107 /** Table share lock. */
108 static THR_LOCK m_table_lock;
109
110 /** Current row. */
111 row_tiws_by_index_usage m_row;
112 /** True is the current row exists. */
113 bool m_row_exists;
114 /** Current position. */
115 pos_tiws_by_index_usage m_pos;
116 /** Next position. */
117 pos_tiws_by_index_usage m_next_pos;
118};
119
120/** @} */
121#endif
122