21 #include "my_global.h"
22 #include "my_pthread.h"
32 THR_LOCK table_events_statements_current::m_table_lock;
37 { C_STRING_WITH_LEN(
"THREAD_ID") },
38 { C_STRING_WITH_LEN(
"bigint(20)") },
42 { C_STRING_WITH_LEN(
"EVENT_ID") },
43 { C_STRING_WITH_LEN(
"bigint(20)") },
47 { C_STRING_WITH_LEN(
"END_EVENT_ID") },
48 { C_STRING_WITH_LEN(
"bigint(20)") },
52 { C_STRING_WITH_LEN(
"EVENT_NAME") },
53 { C_STRING_WITH_LEN(
"varchar(128)") },
57 { C_STRING_WITH_LEN(
"SOURCE") },
58 { C_STRING_WITH_LEN(
"varchar(64)") },
62 { C_STRING_WITH_LEN(
"TIMER_START") },
63 { C_STRING_WITH_LEN(
"bigint(20)") },
67 { C_STRING_WITH_LEN(
"TIMER_END") },
68 { C_STRING_WITH_LEN(
"bigint(20)") },
72 { C_STRING_WITH_LEN(
"TIMER_WAIT") },
73 { C_STRING_WITH_LEN(
"bigint(20)") },
77 { C_STRING_WITH_LEN(
"LOCK_TIME") },
78 { C_STRING_WITH_LEN(
"bigint(20)") },
82 { C_STRING_WITH_LEN(
"SQL_TEXT") },
83 { C_STRING_WITH_LEN(
"longtext") },
87 { C_STRING_WITH_LEN(
"DIGEST") },
88 { C_STRING_WITH_LEN(
"varchar(32)") },
92 { C_STRING_WITH_LEN(
"DIGEST_TEXT") },
93 { C_STRING_WITH_LEN(
"longtext") },
97 { C_STRING_WITH_LEN(
"CURRENT_SCHEMA") },
98 { C_STRING_WITH_LEN(
"varchar(64)") },
102 { C_STRING_WITH_LEN(
"OBJECT_TYPE") },
103 { C_STRING_WITH_LEN(
"varchar(64)") },
107 { C_STRING_WITH_LEN(
"OBJECT_SCHEMA") },
108 { C_STRING_WITH_LEN(
"varchar(64)") },
112 { C_STRING_WITH_LEN(
"OBJECT_NAME") },
113 { C_STRING_WITH_LEN(
"varchar(64)") },
117 { C_STRING_WITH_LEN(
"OBJECT_INSTANCE_BEGIN") },
118 { C_STRING_WITH_LEN(
"bigint") },
122 { C_STRING_WITH_LEN(
"MYSQL_ERRNO") },
123 { C_STRING_WITH_LEN(
"int(11)") },
127 { C_STRING_WITH_LEN(
"RETURNED_SQLSTATE") },
128 { C_STRING_WITH_LEN(
"varchar(5)") },
132 { C_STRING_WITH_LEN(
"MESSAGE_TEXT") },
133 { C_STRING_WITH_LEN(
"varchar(128)") },
137 { C_STRING_WITH_LEN(
"ERRORS") },
138 { C_STRING_WITH_LEN(
"bigint") },
142 { C_STRING_WITH_LEN(
"WARNINGS") },
143 { C_STRING_WITH_LEN(
"bigint") },
147 { C_STRING_WITH_LEN(
"ROWS_AFFECTED") },
148 { C_STRING_WITH_LEN(
"bigint") },
152 { C_STRING_WITH_LEN(
"ROWS_SENT") },
153 { C_STRING_WITH_LEN(
"bigint") },
157 { C_STRING_WITH_LEN(
"ROWS_EXAMINED") },
158 { C_STRING_WITH_LEN(
"bigint") },
162 { C_STRING_WITH_LEN(
"CREATED_TMP_DISK_TABLES") },
163 { C_STRING_WITH_LEN(
"bigint") },
167 { C_STRING_WITH_LEN(
"CREATED_TMP_TABLES") },
168 { C_STRING_WITH_LEN(
"bigint") },
172 { C_STRING_WITH_LEN(
"SELECT_FULL_JOIN") },
173 { C_STRING_WITH_LEN(
"bigint") },
177 { C_STRING_WITH_LEN(
"SELECT_FULL_RANGE_JOIN") },
178 { C_STRING_WITH_LEN(
"bigint") },
182 { C_STRING_WITH_LEN(
"SELECT_RANGE") },
183 { C_STRING_WITH_LEN(
"bigint") },
187 { C_STRING_WITH_LEN(
"SELECT_RANGE_CHECK") },
188 { C_STRING_WITH_LEN(
"bigint") },
192 { C_STRING_WITH_LEN(
"SELECT_SCAN") },
193 { C_STRING_WITH_LEN(
"bigint") },
197 { C_STRING_WITH_LEN(
"SORT_MERGE_PASSES") },
198 { C_STRING_WITH_LEN(
"bigint") },
202 { C_STRING_WITH_LEN(
"SORT_RANGE") },
203 { C_STRING_WITH_LEN(
"bigint") },
207 { C_STRING_WITH_LEN(
"SORT_ROWS") },
208 { C_STRING_WITH_LEN(
"bigint") },
212 { C_STRING_WITH_LEN(
"SORT_SCAN") },
213 { C_STRING_WITH_LEN(
"bigint") },
217 { C_STRING_WITH_LEN(
"NO_INDEX_USED") },
218 { C_STRING_WITH_LEN(
"bigint") },
222 { C_STRING_WITH_LEN(
"NO_GOOD_INDEX_USED") },
223 { C_STRING_WITH_LEN(
"bigint") },
227 { C_STRING_WITH_LEN(
"NESTING_EVENT_ID") },
228 { C_STRING_WITH_LEN(
"bigint(20)") },
232 { C_STRING_WITH_LEN(
"NESTING_EVENT_TYPE") },
233 { C_STRING_WITH_LEN(
"enum(\'STATEMENT\',\'STAGE\',\'WAIT\'") },
239 table_events_statements_current::m_field_def=
245 { C_STRING_WITH_LEN(
"events_statements_current") },
247 &table_events_statements_current::create,
249 &table_events_statements_current::delete_all_rows,
258 THR_LOCK table_events_statements_history::m_table_lock;
263 { C_STRING_WITH_LEN(
"events_statements_history") },
265 &table_events_statements_history::create,
267 &table_events_statements_history::delete_all_rows,
272 &table_events_statements_current::m_field_def,
276 THR_LOCK table_events_statements_history_long::m_table_lock;
281 { C_STRING_WITH_LEN(
"events_statements_history_long") },
283 &table_events_statements_history_long::create,
285 &table_events_statements_history_long::delete_all_rows,
290 &table_events_statements_current::m_field_def,
294 table_events_statements_common::table_events_statements_common
307 const char *safe_source_file;
313 if (unlikely(klass == NULL))
338 if (unlikely(safe_source_file == NULL))
341 base= base_name(safe_source_file);
374 int safe_byte_count= digest->m_byte_count;
375 if (safe_byte_count > 0 &&
376 safe_byte_count <= PSI_MAX_DIGEST_STORAGE_SIZE)
380 (
char *) digest->m_token_array,
384 MD5_HASH_TO_STRING(md5.m_md5,
414 return HA_ERR_RECORD_DELETED;
417 DBUG_ASSERT(table->s->null_bytes == 3);
422 for (; (f= *fields) ; fields++)
424 if (read_all || bitmap_is_set(table->read_set, f->field_index))
426 switch(f->field_index)
603 table_events_statements_current::table_events_statements_current()
605 m_pos(), m_next_pos()
625 for (m_pos.
set_at(&m_next_pos);
639 if (safe_events_statements_count == 0)
648 if (m_pos.
m_index_2 >= safe_events_statements_count)
652 statement= &pfs_thread->m_statement_stack[m_pos.
m_index_2];
659 return HA_ERR_END_OF_FILE;
672 return HA_ERR_RECORD_DELETED;
676 if (safe_events_statements_count == 0)
680 return HA_ERR_RECORD_DELETED;
685 if (m_pos.
m_index_2 >= safe_events_statements_count)
686 return HA_ERR_RECORD_DELETED;
691 statement= &pfs_thread->m_statement_stack[m_pos.
m_index_2];
693 if (statement->
m_class == NULL)
694 return HA_ERR_RECORD_DELETED;
700 int table_events_statements_current::delete_all_rows(
void)
711 table_events_statements_history::table_events_statements_history()
713 m_pos(), m_next_pos()
734 return HA_ERR_END_OF_FILE;
736 for (m_pos.
set_at(&m_next_pos);
763 if (statement->
m_class != NULL)
772 return HA_ERR_END_OF_FILE;
786 return HA_ERR_RECORD_DELETED;
792 return HA_ERR_RECORD_DELETED;
796 if (statement->
m_class == NULL)
797 return HA_ERR_RECORD_DELETED;
803 int table_events_statements_history::delete_all_rows(
void)
814 table_events_statements_history_long::table_events_statements_history_long()
816 m_pos(0), m_next_pos(0)
836 if (events_statements_history_long_size == 0)
837 return HA_ERR_END_OF_FILE;
840 limit= events_statements_history_long_size;
848 if (statement->
m_class != NULL)
857 return HA_ERR_END_OF_FILE;
865 if (events_statements_history_long_size == 0)
866 return HA_ERR_RECORD_DELETED;
871 limit= events_statements_history_long_size;
876 return HA_ERR_RECORD_DELETED;
880 if (statement->
m_class == NULL)
881 return HA_ERR_RECORD_DELETED;
887 int table_events_statements_history_long::delete_all_rows(
void)