| 1 | /* Copyright (c) 2010, 2023, Oracle and/or its affiliates. |
| 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, version 2.0, |
| 5 | as published by the Free Software Foundation. |
| 6 | |
| 7 | This program is also distributed with certain software (including |
| 8 | but not limited to OpenSSL) that is licensed under separate terms, |
| 9 | as designated in a particular file or component or in included license |
| 10 | documentation. The authors of MySQL hereby grant you an additional |
| 11 | permission to link the program and your derivative works with the |
| 12 | separately licensed software that they have included with MySQL. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License, version 2.0, for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program; if not, write to the Free Software |
| 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ |
| 22 | |
| 23 | /** |
| 24 | @file storage/perfschema/table_esgs_global_by_event_name.cc |
| 25 | Table EVENTS_STAGES_SUMMARY_GLOBAL_BY_EVENT_NAME (implementation). |
| 26 | */ |
| 27 | |
| 28 | #include "my_global.h"cxx . . $ `<file>/include/my_global.h`/ |
| 29 | #include "my_thread.h"cxx . . $ `<file>/storage/perfschema/my_thread.h`/ |
| 30 | #include "pfs_instr_class.h"cxx . . $ `<file>/storage/perfschema/pfs_instr_class.h`/ |
| 31 | #include "pfs_column_types.h"cxx . . $ `<file>/storage/perfschema/pfs_column_types.h`/ |
| 32 | #include "pfs_column_values.h"cxx . . $ `<file>/storage/perfschema/pfs_column_values.h`/ |
| 33 | #include "table_esgs_global_by_event_name.h"cxx . . $ `<file>/storage/perfschema/table_esgs_global_by_event_name.h`/ |
| 34 | #include "pfs_global.h"cxx . . $ `<file>/storage/perfschema/pfs_global.h`/ |
| 35 | #include "pfs_instr.h"cxx . . $ `<file>/storage/perfschema/pfs_instr.h`/ |
| 36 | #include "pfs_timer.h"cxx . . $ `<file>/storage/perfschema/pfs_timer.h`/ |
| 37 | #include "pfs_visitor.h"cxx . . $ `<file>/storage/perfschema/pfs_visitor.h`/ |
| 38 | #include "field.h"cxx . . $ `<file>/sql/field.h`/ |
| 39 | |
| 40 | THR_LOCK table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::m_table_lockcxx . . $ table_esgs_global_by_event_name#m_table_lock.; |
| 41 | |
| 42 | PFS_engine_table_share_statecxx . . $ PFS_engine_table_share_state# |
| 43 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::m_share_statecxx . . $ table_esgs_global_by_event_name#m_share_state. = { |
| 44 | false /* m_checked */ |
| 45 | }; |
| 46 | |
| 47 | PFS_engine_table_sharecxx . . $ PFS_engine_table_share# |
| 48 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::m_sharecxx . . $ table_esgs_global_by_event_name#m_share.= |
| 49 | { |
| 50 | { C_STRING_WITH_LENcxx . . $ `include/m_string.h:212:9`!("events_stages_summary_global_by_event_name") }, |
| 51 | &pfs_truncatable_aclcxx . . $ pfs_truncatable_acl., |
| 52 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::createcxx . . $ table_esgs_global_by_event_name#create(314e88453c9d561a)., |
| 53 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, /* write_row */ |
| 54 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::delete_all_rowscxx . . $ table_esgs_global_by_event_name#delete_all_rows(b126dc7c1de90089)., |
| 55 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::get_row_countcxx . . $ table_esgs_global_by_event_name#get_row_count(73266883b0c7072b)., |
| 56 | sizeof(PFS_simple_indexcxx . . $ PFS_simple_index#), |
| 57 | &m_table_lockcxx . . $ table_esgs_global_by_event_name#m_table_lock., |
| 58 | { C_STRING_WITH_LENcxx . . $ `include/m_string.h:212:9`!("CREATE TABLE events_stages_summary_global_by_event_name(" |
| 59 | "EVENT_NAME VARCHAR(128) not null comment 'Event name.'," |
| 60 | "COUNT_STAR BIGINT unsigned not null comment 'Number of summarized events, which includes all timed and untimed events.'," |
| 61 | "SUM_TIMER_WAIT BIGINT unsigned not null comment 'Total wait time of the timed summarized events.'," |
| 62 | "MIN_TIMER_WAIT BIGINT unsigned not null comment 'Minimum wait time of the timed summarized events.'," |
| 63 | "AVG_TIMER_WAIT BIGINT unsigned not null comment 'Average wait time of the timed summarized events.'," |
| 64 | "MAX_TIMER_WAIT BIGINT unsigned not null comment 'Maximum wait time of the timed summarized events.')") }, |
| 65 | false, /* m_perpetual */ |
| 66 | false, /* m_optional */ |
| 67 | &m_share_statecxx . . $ table_esgs_global_by_event_name#m_share_state. |
| 68 | }; |
| 69 | |
| 70 | PFS_engine_tablecxx . . $ PFS_engine_table#* |
| 71 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::createcxx . . $ table_esgs_global_by_event_name#create(314e88453c9d561a).(void) |
| 72 | { |
| 73 | return new table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#(); |
| 74 | } |
| 75 | |
| 76 | int |
| 77 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::delete_all_rowscxx . . $ table_esgs_global_by_event_name#delete_all_rows(b126dc7c1de90089).(void) |
| 78 | { |
| 79 | reset_events_stages_by_threadcxx . . $ reset_events_stages_by_thread(49f6e7a06ebc5aa8).(); |
| 80 | reset_events_stages_by_accountcxx . . $ reset_events_stages_by_account(49f6e7a06ebc5aa8).(); |
| 81 | reset_events_stages_by_usercxx . . $ reset_events_stages_by_user(49f6e7a06ebc5aa8).(); |
| 82 | reset_events_stages_by_hostcxx . . $ reset_events_stages_by_host(49f6e7a06ebc5aa8).(); |
| 83 | reset_events_stages_globalcxx . . $ reset_events_stages_global(49f6e7a06ebc5aa8).(); |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | ha_rowscxx . . $ ha_rows# |
| 88 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::get_row_countcxx . . $ table_esgs_global_by_event_name#get_row_count(73266883b0c7072b).(void) |
| 89 | { |
| 90 | return stage_class_maxcxx . . $ stage_class_max.; |
| 91 | } |
| 92 | |
| 93 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#table_esgs_global_by_event_name(49f6e7a06ebc5aa8).() |
| 94 | : PFS_engine_tablecxx . . $ PFS_engine_table#(&m_sharecxx . . $ table_esgs_global_by_event_name#m_share., &m_poscxx . . $ table_esgs_global_by_event_name#m_pos.), |
| 95 | m_row_existscxx . . $ table_esgs_global_by_event_name#m_row_exists.(false), m_poscxx . . $ table_esgs_global_by_event_name#m_pos.(1), m_next_poscxx . . $ table_esgs_global_by_event_name#m_next_pos.(1) |
| 96 | {} |
| 97 | |
| 98 | void table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::reset_positioncxx . . $ table_esgs_global_by_event_name#reset_position(49f6e7a06ebc5aa8).(void) |
| 99 | { |
| 100 | m_poscxx . . $ table_esgs_global_by_event_name#m_pos.=cxx . . $ PFS_simple_index#`operator=`(8ece759316cf0976). 1cxx . . $ PFS_simple_index#PFS_simple_index(cb2f890c2fdad230).; |
| 101 | m_next_poscxx . . $ table_esgs_global_by_event_name#m_next_pos.=cxx . . $ PFS_simple_index#`operator=`(8ece759316cf0976). 1cxx . . $ PFS_simple_index#PFS_simple_index(cb2f890c2fdad230).; |
| 102 | } |
| 103 | |
| 104 | int table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::rnd_initcxx . . $ table_esgs_global_by_event_name#rnd_init(73da94e76e6bd037).(bool scan) |
| 105 | { |
| 106 | m_normalizercxx . . $ PFS_engine_table#m_normalizer.= time_normalizercxx . . $ time_normalizer#::getcxx . . $ time_normalizer#get(56f77a1d18576d07).(stage_timercxx . . $ stage_timer.); |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | int table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::rnd_nextcxx . . $ table_esgs_global_by_event_name#rnd_next(b126dc7c1de90089).(void) |
| 111 | { |
| 112 | PFS_stage_classcxx . . $ PFS_stage_class# *stage_class; |
| 113 | |
| 114 | if (global_instr_class_stages_arraycxx . . $ global_instr_class_stages_array. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 115 | return HA_ERR_END_OF_FILEcxx . . $ `include/my_base.h:482:9`!; |
| 116 | |
| 117 | m_poscxx . . $ table_esgs_global_by_event_name#m_pos..set_atcxx . . $ PFS_simple_index#set_at(97e92d3e1fc2a673).(&m_next_poscxx . . $ table_esgs_global_by_event_name#m_next_pos.); |
| 118 | |
| 119 | stage_class= find_stage_classcxx . . $ find_stage_class(ddf388436eb5d620).(m_poscxx . . $ table_esgs_global_by_event_name#m_pos..m_indexcxx . . $ PFS_simple_index#m_index.); |
| 120 | if (stage_class) |
| 121 | { |
| 122 | make_rowcxx . . $ table_esgs_global_by_event_name#make_row(7d75152ee78c61f1).(stage_class); |
| 123 | m_next_poscxx . . $ table_esgs_global_by_event_name#m_next_pos..set_aftercxx . . $ PFS_simple_index#set_after(97e92d3e1fc2a673).(&m_poscxx . . $ table_esgs_global_by_event_name#m_pos.); |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | return HA_ERR_END_OF_FILEcxx . . $ `include/my_base.h:482:9`!; |
| 128 | } |
| 129 | |
| 130 | int |
| 131 | table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name#::rnd_poscxx . . $ table_esgs_global_by_event_name#rnd_pos(aa284d429d6986c8).(const void *pos) |
| 132 | { |
| 133 | PFS_stage_classcxx . . $ PFS_stage_class# *stage_class; |
| 134 | |
| 135 | set_positioncxx . . $ PFS_engine_table#set_position(e4289f82fef2c2f9).(pos); |
| 136 | |
| 137 | if (global_instr_class_stages_arraycxx . . $ global_instr_class_stages_array. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 138 | return HA_ERR_END_OF_FILEcxx . . $ `include/my_base.h:482:9`!; |
| 139 | |
| 140 | stage_class=find_stage_classcxx . . $ find_stage_class(ddf388436eb5d620).(m_poscxx . . $ table_esgs_global_by_event_name#m_pos..m_indexcxx . . $ PFS_simple_index#m_index.); |
| 141 | if (stage_class) |
| 142 | { |
| 143 | make_rowcxx . . $ table_esgs_global_by_event_name#make_row(7d75152ee78c61f1).(stage_class); |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | return HA_ERR_RECORD_DELETEDcxx . . $ `include/my_base.h:479:9`!; |
| 148 | } |
| 149 | |
| 150 | |
| 151 | void table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name# |
| 152 | ::make_rowcxx . . $ table_esgs_global_by_event_name#make_row(7d75152ee78c61f1).(PFS_stage_classcxx . . $ PFS_stage_class# *klass) |
| 153 | { |
| 154 | m_rowcxx . . $ table_esgs_global_by_event_name#m_row..m_event_namecxx . . $ row_esgs_global_by_event_name#m_event_name..make_rowcxx . . $ PFS_event_name_row#make_row(b4cc58497f13b22c).(klass); |
| 155 | |
| 156 | PFS_connection_stage_visitorcxx . . $ PFS_connection_stage_visitor# visitorcxx . . $ PFS_connection_stage_visitor#PFS_connection_stage_visitor(7d75152ee78c61f1).(klass); |
| 157 | PFS_connection_iteratorcxx . . $ PFS_connection_iterator#::visit_globalcxx . . $ PFS_connection_iterator#visit_global(7f828f9bf181cde8).(true, /* hosts */ |
| 158 | false, /* users */ |
| 159 | true, /* accounts */ |
| 160 | true, /* threads */ |
| 161 | false, /* THDs */ |
| 162 | & visitor); |
| 163 | |
| 164 | m_rowcxx . . $ table_esgs_global_by_event_name#m_row..m_statcxx . . $ row_esgs_global_by_event_name#m_stat..setcxx . . $ PFS_stage_stat_row#set(c0241e917de54600).(m_normalizercxx . . $ PFS_engine_table#m_normalizer., & visitor.m_statcxx . . $ PFS_connection_stage_visitor#m_stat.); |
| 165 | m_row_existscxx . . $ table_esgs_global_by_event_name#m_row_exists.= true; |
| 166 | } |
| 167 | |
| 168 | int table_esgs_global_by_event_namecxx . . $ table_esgs_global_by_event_name# |
| 169 | ::read_row_valuescxx . . $ table_esgs_global_by_event_name#read_row_values(139ec8e2a7764e1).(TABLEcxx . . $ TABLE# *table, unsigned char *, Fieldcxx . . $ Field# **fields, |
| 170 | bool read_all) |
| 171 | { |
| 172 | Fieldcxx . . $ Field# *f; |
| 173 | |
| 174 | if (unlikelycxx . . $ `include/my_global.h:361:9`!(! m_row_exists)) |
| 175 | return HA_ERR_RECORD_DELETEDcxx . . $ `include/my_base.h:479:9`!; |
| 176 | |
| 177 | /* Set the null bits */ |
| 178 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(table->s->null_bytes == 0); |
| 179 | |
| 180 | for (; (f= *fields) ; fields++) |
| 181 | { |
| 182 | if (read_all || bitmap_is_set(table->read_setcxx . . $ TABLE#read_set., f->field_indexcxx . . $ Field#field_index.)) |
| 183 | { |
| 184 | switch(f->field_indexcxx . . $ Field#field_index.) |
| 185 | { |
| 186 | case 0: /* NAME */ |
| 187 | m_rowcxx . . $ table_esgs_global_by_event_name#m_row..m_event_namecxx . . $ row_esgs_global_by_event_name#m_event_name..set_fieldcxx . . $ PFS_event_name_row#set_field(42c390a4298f5e0).(f); |
| 188 | break; |
| 189 | default: /* 1, ... COUNT/SUM/MIN/AVG/MAX */ |
| 190 | m_rowcxx . . $ table_esgs_global_by_event_name#m_row..m_statcxx . . $ row_esgs_global_by_event_name#m_stat..set_fieldcxx . . $ PFS_stage_stat_row#set_field(d4d38aba05377c48).(f->field_indexcxx . . $ Field#field_index. - 1, f); |
| 191 | break; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | return 0; |
| 197 | } |
| 198 |