| 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_MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME_H |
| 25 |
#define TABLE_MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME_H |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#include <sys/types.h> |
| 33 |
|
| 34 |
#include "my_base.h" |
| 35 |
#include "storage/perfschema/pfs_engine_table.h" |
| 36 |
#include "storage/perfschema/table_helper.h" |
| 37 |
|
| 38 |
class Field; |
| 39 |
class Plugin_table; |
| 40 |
struct PFS_builtin_memory_class; |
| 41 |
struct PFS_instr_class; |
| 42 |
struct PFS_memory_class; |
| 43 |
struct TABLE; |
| 44 |
struct THR_LOCK; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
class PFS_index_mems_global_by_event_name : public PFS_engine_index { |
| 52 |
public: |
| 53 |
PFS_index_mems_global_by_event_name() |
| 54 |
: PFS_engine_index(&m_key), m_key("EVENT_NAME") {} |
| 55 |
|
| 56 |
~PFS_index_mems_global_by_event_name() override = default; |
| 57 |
|
| 58 |
virtual bool match(PFS_instr_class *instr_class); |
| 59 |
|
| 60 |
private: |
| 61 |
PFS_key_event_name m_key; |
| 62 |
}; |
| 63 |
|
| 64 |
|
| 65 |
struct row_mems_global_by_event_name { |
| 66 |
|
| 67 |
PFS_event_name_row m_event_name; |
| 68 |
|
| 69 |
PFS_memory_stat_row m_stat; |
| 70 |
}; |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
struct pos_mems_global_by_event_name : public PFS_double_index { |
| 79 |
static const uint FIRST_VIEW = 1; |
| 80 |
static const uint VIEW_BUILTIN_MEMORY = 1; |
| 81 |
static const uint VIEW_MEMORY = 2; |
| 82 |
static const uint LAST_VIEW = 2; |
| 83 |
|
| 84 |
pos_mems_global_by_event_name() : PFS_double_index(FIRST_VIEW, 1) {} |
| 85 |
|
| 86 |
inline void reset() { |
| 87 |
m_index_1 = FIRST_VIEW; |
| 88 |
m_index_2 = 1; |
| 89 |
} |
| 90 |
|
| 91 |
inline bool has_more_view() { return (m_index_1 <= LAST_VIEW); } |
| 92 |
|
| 93 |
inline void next_view() { |
| 94 |
m_index_1++; |
| 95 |
m_index_2 = 1; |
| 96 |
} |
| 97 |
}; |
| 98 |
|
| 99 |
|
| 100 |
class table_mems_global_by_event_name : public PFS_engine_table { |
| 101 |
typedef pos_mems_global_by_event_name pos_t; |
| 102 |
|
| 103 |
public: |
| 104 |
|
| 105 |
static PFS_engine_table_share m_share; |
| 106 |
static PFS_engine_table *create(PFS_engine_table_share *); |
| 107 |
static int delete_all_rows(); |
| 108 |
static ha_rows get_row_count(); |
| 109 |
|
| 110 |
void reset_position() override; |
| 111 |
|
| 112 |
int rnd_next() override; |
| 113 |
int rnd_pos(const void *pos) override; |
| 114 |
|
| 115 |
int index_init(uint idx, bool sorted) override; |
| 116 |
int index_next() override; |
| 117 |
|
| 118 |
private: |
| 119 |
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, |
| 120 |
bool read_all) override; |
| 121 |
|
| 122 |
table_mems_global_by_event_name(); |
| 123 |
|
| 124 |
public: |
| 125 |
~table_mems_global_by_event_name() override = default; |
| 126 |
|
| 127 |
private: |
| 128 |
int make_row(PFS_builtin_memory_class *klass); |
| 129 |
int make_row(PFS_memory_class *klass); |
| 130 |
|
| 131 |
|
| 132 |
static THR_LOCK m_table_lock; |
| 133 |
|
| 134 |
static Plugin_table m_table_def; |
| 135 |
|
| 136 |
|
| 137 |
row_mems_global_by_event_name m_row; |
| 138 |
|
| 139 |
pos_t m_pos; |
| 140 |
|
| 141 |
pos_t m_next_pos; |
| 142 |
|
| 143 |
PFS_index_mems_global_by_event_name *m_opened_index; |
| 144 |
}; |
| 145 |
|
| 146 |
|
| 147 |
#endif |