| 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 Street, Fifth Floor, Boston, MA 02110-1301, USA */ |
| 15 | |
| 16 | #ifndef TABLE_EWS_BY_USER_BY_EVENT_NAME_H |
| 17 | #define TABLE_EWS_BY_USER_BY_EVENT_NAME_H |
| 18 | |
| 19 | /** |
| 20 | @file storage/perfschema/table_ews_by_user_by_event_name.h |
| 21 | Table EVENTS_WAITS_SUMMARY_BY_USER_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 "pfs_user.h" |
| 29 | #include "table_helper.h" |
| 30 | |
| 31 | /** |
| 32 | @addtogroup Performance_schema_tables |
| 33 | @{ |
| 34 | */ |
| 35 | |
| 36 | /** |
| 37 | A row of table |
| 38 | PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_USER_BY_EVENT_NAME. |
| 39 | */ |
| 40 | struct row_ews_by_user_by_event_name |
| 41 | { |
| 42 | /** Column USER. */ |
| 43 | PFS_user_row m_user; |
| 44 | /** Column EVENT_NAME. */ |
| 45 | PFS_event_name_row m_event_name; |
| 46 | /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */ |
| 47 | PFS_stat_row m_stat; |
| 48 | }; |
| 49 | |
| 50 | /** |
| 51 | Position of a cursor on |
| 52 | PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_USER_BY_EVENT_NAME. |
| 53 | Index 1 on user (0 based) |
| 54 | Index 2 on instrument view |
| 55 | Index 3 on instrument class (1 based) |
| 56 | */ |
| 57 | struct pos_ews_by_user_by_event_name |
| 58 | : public PFS_triple_index, public PFS_instrument_view_constants |
| 59 | { |
| 60 | pos_ews_by_user_by_event_name() |
| 61 | : PFS_triple_index(0, FIRST_VIEW, 1) |
| 62 | {} |
| 63 | |
| 64 | inline void reset(void) |
| 65 | { |
| 66 | m_index_1= 0; |
| 67 | m_index_2= FIRST_VIEW; |
| 68 | m_index_3= 1; |
| 69 | } |
| 70 | |
| 71 | inline bool has_more_user(void) |
| 72 | { return (m_index_1 < user_max); } |
| 73 | |
| 74 | inline void next_user(void) |
| 75 | { |
| 76 | m_index_1++; |
| 77 | m_index_2= FIRST_VIEW; |
| 78 | m_index_3= 1; |
| 79 | } |
| 80 | |
| 81 | inline bool has_more_view(void) |
| 82 | { return (m_index_2 <= LAST_VIEW); } |
| 83 | |
| 84 | inline void next_view(void) |
| 85 | { |
| 86 | m_index_2++; |
| 87 | m_index_3= 1; |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | /** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_USER_BY_EVENT_NAME. */ |
| 92 | class table_ews_by_user_by_event_name : public PFS_engine_table |
| 93 | { |
| 94 | public: |
| 95 | /** Table share */ |
| 96 | static PFS_engine_table_share m_share; |
| 97 | static PFS_engine_table* create(); |
| 98 | static int delete_all_rows(); |
| 99 | |
| 100 | virtual int rnd_next(); |
| 101 | virtual int rnd_pos(const void *pos); |
| 102 | virtual void reset_position(void); |
| 103 | |
| 104 | protected: |
| 105 | virtual int read_row_values(TABLE *table, |
| 106 | unsigned char *buf, |
| 107 | Field **fields, |
| 108 | bool read_all); |
| 109 | |
| 110 | table_ews_by_user_by_event_name(); |
| 111 | |
| 112 | public: |
| 113 | ~table_ews_by_user_by_event_name() |
| 114 | {} |
| 115 | |
| 116 | protected: |
| 117 | void make_row(PFS_user *user, PFS_instr_class *klass); |
| 118 | |
| 119 | private: |
| 120 | /** Table share lock. */ |
| 121 | static THR_LOCK m_table_lock; |
| 122 | |
| 123 | /** Current row. */ |
| 124 | row_ews_by_user_by_event_name m_row; |
| 125 | /** True is the current row exists. */ |
| 126 | bool m_row_exists; |
| 127 | /** Current position. */ |
| 128 | pos_ews_by_user_by_event_name m_pos; |
| 129 | /** Next position. */ |
| 130 | pos_ews_by_user_by_event_name m_next_pos; |
| 131 | }; |
| 132 | |
| 133 | /** @} */ |
| 134 | #endif |
| 135 | |