1/* Copyright (c) 2008, 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 Foundation,
14 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15
16#ifndef TABLE_SETUP_INSTRUMENTS_H
17#define TABLE_SETUP_INSTRUMENTS_H
18
19/**
20 @file storage/perfschema/table_setup_instruments.h
21 Table SETUP_INSTRUMENTS (declarations).
22*/
23
24#include "pfs_instr_class.h"
25#include "pfs_engine_table.h"
26
27/**
28 @addtogroup Performance_schema_tables
29 @{
30*/
31
32/** A row of PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS. */
33struct row_setup_instruments
34{
35 /** Columns NAME, ENABLED, TIMED. */
36 PFS_instr_class *m_instr_class;
37};
38
39/** Position of a cursor on PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS. */
40struct pos_setup_instruments : public PFS_double_index
41{
42 static const uint FIRST_VIEW= 1;
43 static const uint VIEW_MUTEX= 1;
44 static const uint VIEW_RWLOCK= 2;
45 static const uint VIEW_COND= 3;
46 static const uint VIEW_THREAD= 4;
47 static const uint VIEW_FILE= 5;
48 static const uint VIEW_TABLE= 6;
49 static const uint VIEW_STAGE= 7;
50 static const uint VIEW_STATEMENT= 8;
51 static const uint VIEW_SOCKET= 9;
52 static const uint VIEW_IDLE= 10;
53 static const uint LAST_VIEW= 10;
54
55 pos_setup_instruments()
56 : PFS_double_index(FIRST_VIEW, 1)
57 {}
58
59 inline void reset(void)
60 {
61 m_index_1= FIRST_VIEW;
62 m_index_2= 1;
63 }
64
65 inline bool has_more_view(void)
66 { return (m_index_1 <= LAST_VIEW); }
67
68 inline void next_view(void)
69 {
70 m_index_1++;
71 m_index_2= 1;
72 }
73};
74
75/** Table PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS. */
76class table_setup_instruments : public PFS_engine_table
77{
78public:
79 /** Table share. */
80 static PFS_engine_table_share m_share;
81 static PFS_engine_table* create();
82
83 virtual int rnd_next();
84 virtual int rnd_pos(const void *pos);
85 virtual void reset_position(void);
86
87protected:
88 virtual int read_row_values(TABLE *table,
89 unsigned char *buf,
90 Field **fields,
91 bool read_all);
92
93 virtual int update_row_values(TABLE *table,
94 const unsigned char *old_buf,
95 const unsigned char *new_buf,
96 Field **fields);
97
98 table_setup_instruments();
99
100public:
101 ~table_setup_instruments()
102 {}
103
104private:
105 void make_row(PFS_instr_class *klass);
106
107 /** Table share lock. */
108 static THR_LOCK m_table_lock;
109
110 /** Current row. */
111 row_setup_instruments m_row;
112 /** Current position. */
113 pos_setup_instruments m_pos;
114 /** Next position. */
115 pos_setup_instruments m_next_pos;
116};
117
118/** @} */
119#endif
120