| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef TABLE_EWS_BY_THREAD_BY_EVENT_NAME_H |
| 25 |
#define TABLE_EWS_BY_THREAD_BY_EVENT_NAME_H |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#include <sys/types.h> |
| 33 |
|
| 34 |
#include "my_base.h" |
| 35 |
#include "my_inttypes.h" |
| 36 |
#include "storage/perfschema/pfs_engine_table.h" |
| 37 |
#include "storage/perfschema/table_helper.h" |
| 38 |
|
| 39 |
class Field; |
| 40 |
class Plugin_table; |
| 41 |
struct PFS_instr_class; |
| 42 |
struct PFS_thread; |
| 43 |
struct TABLE; |
| 44 |
struct THR_LOCK; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
class PFS_index_ews_by_thread_by_event_name : public PFS_engine_index { |
| 52 |
public: |
| 53 |
PFS_index_ews_by_thread_by_event_name() |
| 54 |
: PFS_engine_index(&m_key_1, &m_key_2), |
| 55 |
m_key_1("THREAD_ID"), |
| 56 |
m_key_2("EVENT_NAME") {} |
| 57 |
|
| 58 |
~PFS_index_ews_by_thread_by_event_name() override = default; |
| 59 |
|
| 60 |
virtual bool match(PFS_thread *pfs); |
| 61 |
virtual bool match_view(uint view); |
| 62 |
virtual bool match(PFS_instr_class *instr_class); |
| 63 |
|
| 64 |
private: |
| 65 |
PFS_key_thread_id m_key_1; |
| 66 |
PFS_key_event_name m_key_2; |
| 67 |
}; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
struct row_ews_by_thread_by_event_name { |
| 74 |
|
| 75 |
ulonglong m_thread_internal_id; |
| 76 |
|
| 77 |
PFS_event_name_row m_event_name; |
| 78 |
|
| 79 |
PFS_stat_row m_stat; |
| 80 |
}; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
struct pos_ews_by_thread_by_event_name : public PFS_triple_index, |
| 90 |
public PFS_instrument_view_constants { |
| 91 |
pos_ews_by_thread_by_event_name() : PFS_triple_index(0, FIRST_VIEW, 1) {} |
| 92 |
|
| 93 |
inline void reset() { |
| 94 |
m_index_1 = 0; |
| 95 |
m_index_2 = FIRST_VIEW; |
| 96 |
m_index_3 = 1; |
| 97 |
} |
| 98 |
|
| 99 |
inline void next_thread() { |
| 100 |
m_index_1++; |
| 101 |
m_index_2 = FIRST_VIEW; |
| 102 |
m_index_3 = 1; |
| 103 |
} |
| 104 |
|
| 105 |
inline bool has_more_view() { return (m_index_2 <= LAST_VIEW); } |
| 106 |
|
| 107 |
inline void next_view() { |
| 108 |
m_index_2++; |
| 109 |
m_index_3 = 1; |
| 110 |
} |
| 111 |
}; |
| 112 |
|
| 113 |
|
| 114 |
class table_ews_by_thread_by_event_name : public PFS_engine_table { |
| 115 |
public: |
| 116 |
|
| 117 |
static PFS_engine_table_share m_share; |
| 118 |
static PFS_engine_table *create(PFS_engine_table_share *); |
| 119 |
static int delete_all_rows(); |
| 120 |
static ha_rows get_row_count(); |
| 121 |
|
| 122 |
void reset_position() override; |
| 123 |
|
| 124 |
int rnd_next() override; |
| 125 |
int rnd_pos(const void *pos) override; |
| 126 |
|
| 127 |
int index_init(uint idx, bool sorted) override; |
| 128 |
int index_next() override; |
| 129 |
|
| 130 |
protected: |
| 131 |
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, |
| 132 |
bool read_all) override; |
| 133 |
|
| 134 |
table_ews_by_thread_by_event_name(); |
| 135 |
|
| 136 |
public: |
| 137 |
~table_ews_by_thread_by_event_name() override = default; |
| 138 |
|
| 139 |
protected: |
| 140 |
int make_row(PFS_thread *thread, PFS_instr_class *klass); |
| 141 |
|
| 142 |
private: |
| 143 |
|
| 144 |
static THR_LOCK m_table_lock; |
| 145 |
|
| 146 |
static Plugin_table m_table_def; |
| 147 |
|
| 148 |
|
| 149 |
row_ews_by_thread_by_event_name m_row; |
| 150 |
|
| 151 |
pos_ews_by_thread_by_event_name m_pos; |
| 152 |
|
| 153 |
pos_ews_by_thread_by_event_name m_next_pos; |
| 154 |
|
| 155 |
PFS_index_ews_by_thread_by_event_name *m_opened_index; |
| 156 |
}; |
| 157 |
|
| 158 |
|
| 159 |
#endif |