1 | /* Copyright (c) 2010, 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 Street, Fifth Floor, Boston, MA 02110-1301, USA */ |
15 | |
16 | #ifndef TABLE_OBJECTS_SUMMARY_GLOBAL_BY_TYPE_H |
17 | #define TABLE_OBJECTS_SUMMARY_GLOBAL_BY_TYPE_H |
18 | |
19 | /** |
20 | @file storage/perfschema/table_os_global_by_type.h |
21 | Table OBJECTS_SUMMARY_GLOBAL_BY_TYPE (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.OBJECTS_SUMMARY_GLOBAL_BY_TYPE. |
38 | */ |
39 | struct row_os_global_by_type |
40 | { |
41 | /** Column OBJECT_TYPE. */ |
42 | enum_object_type m_object_type; |
43 | /** Column SCHEMA_NAME. */ |
44 | char m_schema_name[NAME_LEN]; |
45 | /** Length in bytes of @c m_schema_name. */ |
46 | uint m_schema_name_length; |
47 | /** Column OBJECT_NAME. */ |
48 | char m_object_name[NAME_LEN]; |
49 | /** Length in bytes of @c m_object_name. */ |
50 | uint m_object_name_length; |
51 | /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */ |
52 | PFS_stat_row m_stat; |
53 | }; |
54 | |
55 | /** |
56 | Position of a cursor on |
57 | PERFORMANCE_SCHEMA.OBJECTS_SUMMARY_GLOBAL_BY_TYPE. |
58 | Index 1 on object type |
59 | Index 2 on object instance (0 based) |
60 | */ |
61 | struct pos_os_global_by_type : public PFS_double_index, |
62 | public PFS_object_view_constants |
63 | { |
64 | pos_os_global_by_type() |
65 | : PFS_double_index(FIRST_VIEW, 0) |
66 | {} |
67 | |
68 | inline void reset(void) |
69 | { |
70 | m_index_1= FIRST_VIEW; |
71 | m_index_2= 0; |
72 | } |
73 | |
74 | inline bool has_more_view(void) |
75 | { return (m_index_1 <= LAST_VIEW); } |
76 | |
77 | inline void next_view(void) |
78 | { |
79 | m_index_1++; |
80 | m_index_2= 0; |
81 | } |
82 | }; |
83 | |
84 | /** Table PERFORMANCE_SCHEMA.OBJECTS_SUMMARY_GLOBAL_BY_TYPE. */ |
85 | class table_os_global_by_type : public PFS_engine_table |
86 | { |
87 | public: |
88 | /** Table share */ |
89 | static PFS_engine_table_share m_share; |
90 | static PFS_engine_table* create(); |
91 | static int delete_all_rows(); |
92 | |
93 | virtual int rnd_next(); |
94 | virtual int rnd_pos(const void *pos); |
95 | virtual void reset_position(void); |
96 | |
97 | protected: |
98 | virtual int read_row_values(TABLE *table, |
99 | unsigned char *buf, |
100 | Field **fields, |
101 | bool read_all); |
102 | |
103 | table_os_global_by_type(); |
104 | |
105 | public: |
106 | ~table_os_global_by_type() |
107 | {} |
108 | |
109 | protected: |
110 | void make_row(PFS_table_share *table_share); |
111 | |
112 | private: |
113 | /** Table share lock. */ |
114 | static THR_LOCK m_table_lock; |
115 | |
116 | /** Current row. */ |
117 | row_os_global_by_type m_row; |
118 | /** True is the current row exists. */ |
119 | bool m_row_exists; |
120 | /** Current position. */ |
121 | pos_os_global_by_type m_pos; |
122 | /** Next position. */ |
123 | pos_os_global_by_type m_next_pos; |
124 | }; |
125 | |
126 | |
127 | /** @} */ |
128 | #endif |
129 | |