| 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_EVENTS_WAITS_H |
| 17 | #define TABLE_EVENTS_WAITS_H |
| 18 | |
| 19 | /** |
| 20 | @file storage/perfschema/table_events_waits.h |
| 21 | Table EVENTS_WAITS_xxx (declarations). |
| 22 | */ |
| 23 | |
| 24 | #include "pfs_column_types.h" |
| 25 | #include "pfs_engine_table.h" |
| 26 | #include "pfs_events_waits.h" |
| 27 | |
| 28 | struct PFS_thread; |
| 29 | |
| 30 | /** |
| 31 | @addtogroup Performance_schema_tables |
| 32 | @{ |
| 33 | */ |
| 34 | |
| 35 | /** A row of table_events_waits_common. */ |
| 36 | struct row_events_waits |
| 37 | { |
| 38 | /** Column THREAD_ID. */ |
| 39 | ulonglong m_thread_internal_id; |
| 40 | /** Column EVENT_ID. */ |
| 41 | ulonglong m_event_id; |
| 42 | /** Column END_EVENT_ID. */ |
| 43 | ulonglong m_end_event_id; |
| 44 | /** Column NESTING_EVENT_ID. */ |
| 45 | ulonglong m_nesting_event_id; |
| 46 | /** Column NESTING_EVENT_TYPE. */ |
| 47 | enum_event_type m_nesting_event_type; |
| 48 | /** Column EVENT_NAME. */ |
| 49 | const char *m_name; |
| 50 | /** Length in bytes of @c m_name. */ |
| 51 | uint m_name_length; |
| 52 | /** Column TIMER_START. */ |
| 53 | ulonglong m_timer_start; |
| 54 | /** Column TIMER_END. */ |
| 55 | ulonglong m_timer_end; |
| 56 | /** Column TIMER_WAIT. */ |
| 57 | ulonglong m_timer_wait; |
| 58 | /** Column OBJECT_TYPE. */ |
| 59 | const char *m_object_type; |
| 60 | /** Length in bytes of @c m_object_type. */ |
| 61 | uint m_object_type_length; |
| 62 | /** Column OBJECT_SCHEMA. */ |
| 63 | char m_object_schema[COL_OBJECT_SCHEMA_SIZE]; |
| 64 | /** Length in bytes of @c m_object_schema. */ |
| 65 | uint m_object_schema_length; |
| 66 | /** Column OBJECT_NAME. */ |
| 67 | char m_object_name[COL_OBJECT_NAME_EXTENDED_SIZE]; |
| 68 | /** Length in bytes of @c m_object_name. */ |
| 69 | uint m_object_name_length; |
| 70 | /** Column INDEX_NAME. */ |
| 71 | char m_index_name[COL_INDEX_NAME_SIZE]; |
| 72 | /** Length in bytes of @c m_index_name. */ |
| 73 | uint m_index_name_length; |
| 74 | /** Column OBJECT_INSTANCE_BEGIN. */ |
| 75 | intptr m_object_instance_addr; |
| 76 | /** Column SOURCE. */ |
| 77 | char m_source[COL_SOURCE_SIZE]; |
| 78 | /** Length in bytes of @c m_source. */ |
| 79 | uint m_source_length; |
| 80 | /** Column OPERATION. */ |
| 81 | enum_operation_type m_operation; |
| 82 | /** Column NUMBER_OF_BYTES. */ |
| 83 | ulonglong m_number_of_bytes; |
| 84 | /** Column FLAGS. */ |
| 85 | uint m_flags; |
| 86 | }; |
| 87 | |
| 88 | /** Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_WAITS_CURRENT. */ |
| 89 | struct pos_events_waits_current : public PFS_double_index |
| 90 | { |
| 91 | pos_events_waits_current() |
| 92 | : PFS_double_index(0, 0) |
| 93 | {} |
| 94 | |
| 95 | inline void reset(void) |
| 96 | { |
| 97 | m_index_1= 0; |
| 98 | m_index_2= 0; |
| 99 | } |
| 100 | |
| 101 | inline void next_thread(void) |
| 102 | { |
| 103 | m_index_1++; |
| 104 | m_index_2= 0; |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | /** Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_WAITS_HISTORY. */ |
| 109 | struct pos_events_waits_history : public PFS_double_index |
| 110 | { |
| 111 | pos_events_waits_history() |
| 112 | : PFS_double_index(0, 0) |
| 113 | {} |
| 114 | |
| 115 | inline void reset(void) |
| 116 | { |
| 117 | m_index_1= 0; |
| 118 | m_index_2= 0; |
| 119 | } |
| 120 | |
| 121 | inline void next_thread(void) |
| 122 | { |
| 123 | m_index_1++; |
| 124 | m_index_2= 0; |
| 125 | } |
| 126 | }; |
| 127 | |
| 128 | /** |
| 129 | Adapter, for table sharing the structure of |
| 130 | PERFORMANCE_SCHEMA.EVENTS_WAITS_CURRENT. |
| 131 | */ |
| 132 | class table_events_waits_common : public PFS_engine_table |
| 133 | { |
| 134 | protected: |
| 135 | virtual int read_row_values(TABLE *table, |
| 136 | unsigned char *buf, |
| 137 | Field **fields, |
| 138 | bool read_all); |
| 139 | |
| 140 | table_events_waits_common(const PFS_engine_table_share *share, void *pos); |
| 141 | |
| 142 | ~table_events_waits_common() |
| 143 | {} |
| 144 | |
| 145 | void clear_object_columns(); |
| 146 | int make_table_object_columns(volatile PFS_events_waits *wait); |
| 147 | int make_file_object_columns(volatile PFS_events_waits *wait); |
| 148 | int make_socket_object_columns(volatile PFS_events_waits *wait); |
| 149 | |
| 150 | void make_row(bool thread_own_wait, PFS_thread *pfs_thread, |
| 151 | volatile PFS_events_waits *wait); |
| 152 | |
| 153 | /** Current row. */ |
| 154 | row_events_waits m_row; |
| 155 | /** True if the current row exists. */ |
| 156 | bool m_row_exists; |
| 157 | }; |
| 158 | |
| 159 | /** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_CURRENT. */ |
| 160 | class table_events_waits_current : public table_events_waits_common |
| 161 | { |
| 162 | public: |
| 163 | /** Table share */ |
| 164 | static PFS_engine_table_share m_share; |
| 165 | static PFS_engine_table* create(); |
| 166 | static int delete_all_rows(); |
| 167 | |
| 168 | virtual int rnd_next(); |
| 169 | virtual int rnd_pos(const void *pos); |
| 170 | virtual void reset_position(void); |
| 171 | |
| 172 | protected: |
| 173 | table_events_waits_current(); |
| 174 | |
| 175 | public: |
| 176 | ~table_events_waits_current() |
| 177 | {} |
| 178 | |
| 179 | private: |
| 180 | friend class table_events_waits_history; |
| 181 | friend class table_events_waits_history_long; |
| 182 | |
| 183 | /** Table share lock. */ |
| 184 | static THR_LOCK m_table_lock; |
| 185 | |
| 186 | /** Current position. */ |
| 187 | pos_events_waits_current m_pos; |
| 188 | /** Next position. */ |
| 189 | pos_events_waits_current m_next_pos; |
| 190 | }; |
| 191 | |
| 192 | /** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_HISTORY. */ |
| 193 | class table_events_waits_history : public table_events_waits_common |
| 194 | { |
| 195 | public: |
| 196 | /** Table share */ |
| 197 | static PFS_engine_table_share m_share; |
| 198 | static PFS_engine_table* create(); |
| 199 | static int delete_all_rows(); |
| 200 | |
| 201 | virtual int rnd_next(); |
| 202 | virtual int rnd_pos(const void *pos); |
| 203 | virtual void reset_position(void); |
| 204 | |
| 205 | protected: |
| 206 | table_events_waits_history(); |
| 207 | |
| 208 | public: |
| 209 | ~table_events_waits_history() |
| 210 | {} |
| 211 | |
| 212 | private: |
| 213 | /** Table share lock. */ |
| 214 | static THR_LOCK m_table_lock; |
| 215 | |
| 216 | /** Current position. */ |
| 217 | pos_events_waits_history m_pos; |
| 218 | /** Next position. */ |
| 219 | pos_events_waits_history m_next_pos; |
| 220 | }; |
| 221 | |
| 222 | /** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_HISTORY_LONG. */ |
| 223 | class table_events_waits_history_long : public table_events_waits_common |
| 224 | { |
| 225 | public: |
| 226 | /** Table share */ |
| 227 | static PFS_engine_table_share m_share; |
| 228 | static PFS_engine_table* create(); |
| 229 | static int delete_all_rows(); |
| 230 | |
| 231 | virtual int rnd_next(); |
| 232 | virtual int rnd_pos(const void *pos); |
| 233 | virtual void reset_position(void); |
| 234 | |
| 235 | protected: |
| 236 | table_events_waits_history_long(); |
| 237 | |
| 238 | public: |
| 239 | ~table_events_waits_history_long() |
| 240 | {} |
| 241 | |
| 242 | private: |
| 243 | /** Table share lock. */ |
| 244 | static THR_LOCK m_table_lock; |
| 245 | |
| 246 | /** Current position. */ |
| 247 | PFS_simple_index m_pos; |
| 248 | /** Next position. */ |
| 249 | PFS_simple_index m_next_pos; |
| 250 | }; |
| 251 | |
| 252 | /** @} */ |
| 253 | #endif |
| 254 | |