21 #include "my_global.h"
22 #include "my_pthread.h"
31 THR_LOCK table_events_waits_current::m_table_lock;
36 { C_STRING_WITH_LEN(
"THREAD_ID") },
37 { C_STRING_WITH_LEN(
"bigint(20)") },
41 { C_STRING_WITH_LEN(
"EVENT_ID") },
42 { C_STRING_WITH_LEN(
"bigint(20)") },
46 { C_STRING_WITH_LEN(
"END_EVENT_ID") },
47 { C_STRING_WITH_LEN(
"bigint(20)") },
51 { C_STRING_WITH_LEN(
"EVENT_NAME") },
52 { C_STRING_WITH_LEN(
"varchar(128)") },
56 { C_STRING_WITH_LEN(
"SOURCE") },
57 { C_STRING_WITH_LEN(
"varchar(64)") },
61 { C_STRING_WITH_LEN(
"TIMER_START") },
62 { C_STRING_WITH_LEN(
"bigint(20)") },
66 { C_STRING_WITH_LEN(
"TIMER_END") },
67 { C_STRING_WITH_LEN(
"bigint(20)") },
71 { C_STRING_WITH_LEN(
"TIMER_WAIT") },
72 { C_STRING_WITH_LEN(
"bigint(20)") },
76 { C_STRING_WITH_LEN(
"SPINS") },
77 { C_STRING_WITH_LEN(
"int(10)") },
81 { C_STRING_WITH_LEN(
"OBJECT_SCHEMA") },
82 { C_STRING_WITH_LEN(
"varchar(64)") },
86 { C_STRING_WITH_LEN(
"OBJECT_NAME") },
87 { C_STRING_WITH_LEN(
"varchar(512)") },
91 { C_STRING_WITH_LEN(
"INDEX_NAME") },
92 { C_STRING_WITH_LEN(
"varchar(64)") },
96 { C_STRING_WITH_LEN(
"OBJECT_TYPE") },
97 { C_STRING_WITH_LEN(
"varchar(64)") },
101 { C_STRING_WITH_LEN(
"OBJECT_INSTANCE_BEGIN") },
102 { C_STRING_WITH_LEN(
"bigint(20)") },
106 { C_STRING_WITH_LEN(
"NESTING_EVENT_ID") },
107 { C_STRING_WITH_LEN(
"bigint(20)") },
111 { C_STRING_WITH_LEN(
"NESTING_EVENT_TYPE") },
112 { C_STRING_WITH_LEN(
"enum(\'STATEMENT\',\'STAGE\',\'WAIT\'") },
116 { C_STRING_WITH_LEN(
"OPERATION") },
117 { C_STRING_WITH_LEN(
"varchar(32)") },
121 { C_STRING_WITH_LEN(
"NUMBER_OF_BYTES") },
122 { C_STRING_WITH_LEN(
"bigint(20)") },
126 { C_STRING_WITH_LEN(
"FLAGS") },
127 { C_STRING_WITH_LEN(
"int(10)") },
133 table_events_waits_current::m_field_def=
139 { C_STRING_WITH_LEN(
"events_waits_current") },
141 &table_events_waits_current::create,
143 &table_events_waits_current::delete_all_rows,
152 THR_LOCK table_events_waits_history::m_table_lock;
157 { C_STRING_WITH_LEN(
"events_waits_history") },
159 &table_events_waits_history::create,
161 &table_events_waits_history::delete_all_rows,
166 &table_events_waits_current::m_field_def,
170 THR_LOCK table_events_waits_history_long::m_table_lock;
175 { C_STRING_WITH_LEN(
"events_waits_history_long") },
177 &table_events_waits_history_long::create,
179 &table_events_waits_history_long::delete_all_rows,
184 &table_events_waits_current::m_field_def,
188 table_events_waits_common::table_events_waits_common
194 void table_events_waits_common::clear_object_columns()
204 int table_events_waits_common::make_table_object_columns(
volatile PFS_events_waits *wait)
210 if (unlikely(safe_table_share == NULL))
242 uint safe_key_count= sanitize_index_count(safe_table_share->
m_key_count);
243 if (safe_index < safe_key_count)
266 int table_events_waits_common::make_file_object_columns(
volatile PFS_events_waits *wait)
271 if (unlikely(safe_file == NULL))
298 int table_events_waits_common::make_socket_object_columns(
volatile PFS_events_waits *wait)
303 if (unlikely(safe_socket == NULL))
317 char ip_str[INET6_ADDRSTRLEN+1];
327 int port_len= int10_to_str(port, (port_str+1), 10) - port_str + 1;
337 memcpy(name, ip_str, ip_len);
338 memcpy(name + ip_len, port_str, port_len);
365 const char *safe_source_file;
369 if (unlikely(safe_thread == NULL))
401 case WAIT_CLASS_IDLE:
402 clear_object_columns();
403 safe_class= sanitize_idle_class(wait->
m_class);
405 case WAIT_CLASS_MUTEX:
406 clear_object_columns();
409 case WAIT_CLASS_RWLOCK:
410 clear_object_columns();
413 case WAIT_CLASS_COND:
414 clear_object_columns();
417 case WAIT_CLASS_TABLE:
418 if (make_table_object_columns(wait))
420 safe_class= sanitize_table_class(wait->
m_class);
422 case WAIT_CLASS_FILE:
423 if (make_file_object_columns(wait))
427 case WAIT_CLASS_SOCKET:
428 if (make_socket_object_columns(wait))
437 if (unlikely(safe_class == NULL))
458 if (unlikely(safe_source_file == NULL))
496 static const LEX_STRING operation_names_map[]=
499 { C_STRING_WITH_LEN(
"lock") },
500 { C_STRING_WITH_LEN(
"try_lock") },
503 { C_STRING_WITH_LEN(
"read_lock") },
504 { C_STRING_WITH_LEN(
"write_lock") },
505 { C_STRING_WITH_LEN(
"try_read_lock") },
506 { C_STRING_WITH_LEN(
"try_write_lock") },
509 { C_STRING_WITH_LEN(
"wait") },
510 { C_STRING_WITH_LEN(
"timed_wait") },
513 { C_STRING_WITH_LEN(
"create") },
514 { C_STRING_WITH_LEN(
"create") },
515 { C_STRING_WITH_LEN(
"open") },
516 { C_STRING_WITH_LEN(
"open") },
517 { C_STRING_WITH_LEN(
"close") },
518 { C_STRING_WITH_LEN(
"close") },
519 { C_STRING_WITH_LEN(
"read") },
520 { C_STRING_WITH_LEN(
"write") },
521 { C_STRING_WITH_LEN(
"seek") },
522 { C_STRING_WITH_LEN(
"tell") },
523 { C_STRING_WITH_LEN(
"flush") },
524 { C_STRING_WITH_LEN(
"stat") },
525 { C_STRING_WITH_LEN(
"stat") },
526 { C_STRING_WITH_LEN(
"chsize") },
527 { C_STRING_WITH_LEN(
"delete") },
528 { C_STRING_WITH_LEN(
"rename") },
529 { C_STRING_WITH_LEN(
"sync") },
532 { C_STRING_WITH_LEN(
"fetch") },
533 { C_STRING_WITH_LEN(
"insert") },
534 { C_STRING_WITH_LEN(
"update") },
535 { C_STRING_WITH_LEN(
"delete") },
538 { C_STRING_WITH_LEN(
"read normal") },
539 { C_STRING_WITH_LEN(
"read with shared locks") },
540 { C_STRING_WITH_LEN(
"read high priority") },
541 { C_STRING_WITH_LEN(
"read no inserts") },
542 { C_STRING_WITH_LEN(
"write allow write") },
543 { C_STRING_WITH_LEN(
"write concurrent insert") },
544 { C_STRING_WITH_LEN(
"write delayed") },
545 { C_STRING_WITH_LEN(
"write low priority") },
546 { C_STRING_WITH_LEN(
"write normal") },
547 { C_STRING_WITH_LEN(
"read external") },
548 { C_STRING_WITH_LEN(
"write external") },
551 { C_STRING_WITH_LEN(
"create") },
552 { C_STRING_WITH_LEN(
"connect") },
553 { C_STRING_WITH_LEN(
"bind") },
554 { C_STRING_WITH_LEN(
"close") },
555 { C_STRING_WITH_LEN(
"send") },
556 { C_STRING_WITH_LEN(
"recv") },
557 { C_STRING_WITH_LEN(
"sendto") },
558 { C_STRING_WITH_LEN(
"recvfrom") },
559 { C_STRING_WITH_LEN(
"sendmsg") },
560 { C_STRING_WITH_LEN(
"recvmsg") },
561 { C_STRING_WITH_LEN(
"seek") },
562 { C_STRING_WITH_LEN(
"opt") },
563 { C_STRING_WITH_LEN(
"stat") },
564 { C_STRING_WITH_LEN(
"shutdown") },
565 { C_STRING_WITH_LEN(
"select") },
568 { C_STRING_WITH_LEN(
"idle") }
581 array_elements(operation_names_map));
584 return HA_ERR_RECORD_DELETED;
587 DBUG_ASSERT(table->s->null_bytes == 2);
599 for (; (f= *fields) ; fields++)
601 if (read_all || bitmap_is_set(table->read_set, f->field_index))
603 switch(f->field_index)
727 table_events_waits_current::table_events_waits_current()
729 m_pos(), m_next_pos()
743 for (m_pos.
set_at(&m_next_pos);
761 #ifdef ONLY_SHOW_ONE_WAIT
771 if (safe_current == top_wait)
780 if (wait >= safe_current)
800 return HA_ERR_END_OF_FILE;
813 return HA_ERR_RECORD_DELETED;
815 #ifdef ONLY_SHOW_ONE_WAIT
817 return HA_ERR_RECORD_DELETED;
825 if (safe_current == top_wait)
829 return HA_ERR_RECORD_DELETED;
834 if (wait >= safe_current)
835 return HA_ERR_RECORD_DELETED;
842 return HA_ERR_RECORD_DELETED;
848 int table_events_waits_current::delete_all_rows(
void)
859 table_events_waits_history::table_events_waits_history()
861 m_pos(), m_next_pos()
876 return HA_ERR_END_OF_FILE;
878 for (m_pos.
set_at(&m_next_pos);
921 return HA_ERR_END_OF_FILE;
935 return HA_ERR_RECORD_DELETED;
941 return HA_ERR_RECORD_DELETED;
946 return HA_ERR_RECORD_DELETED;
952 int table_events_waits_history::delete_all_rows(
void)
963 table_events_waits_history_long::table_events_waits_history_long()
965 m_pos(0), m_next_pos(0)
979 if (events_waits_history_long_size == 0)
980 return HA_ERR_END_OF_FILE;
983 limit= events_waits_history_long_size;
1000 return HA_ERR_END_OF_FILE;
1008 if (events_waits_history_long_size == 0)
1009 return HA_ERR_RECORD_DELETED;
1014 limit= events_waits_history_long_size;
1019 return HA_ERR_RECORD_DELETED;
1024 return HA_ERR_RECORD_DELETED;
1030 int table_events_waits_history_long::delete_all_rows(
void)