MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
table_esgs_global_by_event_name.cc
Go to the documentation of this file.
1 /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
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 as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
21 #include "my_global.h"
22 #include "my_pthread.h"
23 #include "pfs_instr_class.h"
24 #include "pfs_column_types.h"
25 #include "pfs_column_values.h"
27 #include "pfs_global.h"
28 #include "pfs_instr.h"
29 #include "pfs_timer.h"
30 #include "pfs_visitor.h"
31 
32 THR_LOCK table_esgs_global_by_event_name::m_table_lock;
33 
34 static const TABLE_FIELD_TYPE field_types[]=
35 {
36  {
37  { C_STRING_WITH_LEN("EVENT_NAME") },
38  { C_STRING_WITH_LEN("varchar(128)") },
39  { NULL, 0}
40  },
41  {
42  { C_STRING_WITH_LEN("COUNT_STAR") },
43  { C_STRING_WITH_LEN("bigint(20)") },
44  { NULL, 0}
45  },
46  {
47  { C_STRING_WITH_LEN("SUM_TIMER_WAIT") },
48  { C_STRING_WITH_LEN("bigint(20)") },
49  { NULL, 0}
50  },
51  {
52  { C_STRING_WITH_LEN("MIN_TIMER_WAIT") },
53  { C_STRING_WITH_LEN("bigint(20)") },
54  { NULL, 0}
55  },
56  {
57  { C_STRING_WITH_LEN("AVG_TIMER_WAIT") },
58  { C_STRING_WITH_LEN("bigint(20)") },
59  { NULL, 0}
60  },
61  {
62  { C_STRING_WITH_LEN("MAX_TIMER_WAIT") },
63  { C_STRING_WITH_LEN("bigint(20)") },
64  { NULL, 0}
65  }
66 };
67 
69 table_esgs_global_by_event_name::m_field_def=
70 { 6, field_types };
71 
74 {
75  { C_STRING_WITH_LEN("events_stages_summary_global_by_event_name") },
77  table_esgs_global_by_event_name::create,
78  NULL, /* write_row */
79  table_esgs_global_by_event_name::delete_all_rows,
80  NULL, /* get_row_count */
81  1000, /* records */
82  sizeof(PFS_simple_index),
83  &m_table_lock,
84  &m_field_def,
85  false /* checked */
86 };
87 
89 table_esgs_global_by_event_name::create(void)
90 {
92 }
93 
94 int
95 table_esgs_global_by_event_name::delete_all_rows(void)
96 {
102  return 0;
103 }
104 
105 table_esgs_global_by_event_name::table_esgs_global_by_event_name()
106  : PFS_engine_table(&m_share, &m_pos),
107  m_row_exists(false), m_pos(1), m_next_pos(1)
108 {}
109 
111 {
112  m_pos= 1;
113  m_next_pos= 1;
114 }
115 
117 {
119  return 0;
120 }
121 
123 {
124  PFS_stage_class *stage_class;
125 
126  if (global_instr_class_stages_array == NULL)
127  return HA_ERR_END_OF_FILE;
128 
129  m_pos.set_at(&m_next_pos);
130 
131  stage_class= find_stage_class(m_pos.m_index);
132  if (stage_class)
133  {
134  make_row(stage_class);
135  m_next_pos.set_after(&m_pos);
136  return 0;
137  }
138 
139  return HA_ERR_END_OF_FILE;
140 }
141 
142 int
144 {
145  PFS_stage_class *stage_class;
146 
147  set_position(pos);
148 
149  if (global_instr_class_stages_array == NULL)
150  return HA_ERR_END_OF_FILE;
151 
152  stage_class=find_stage_class(m_pos.m_index);
153  if (stage_class)
154  {
155  make_row(stage_class);
156  return 0;
157  }
158 
159  return HA_ERR_RECORD_DELETED;
160 }
161 
162 
163 void table_esgs_global_by_event_name
164 ::make_row(PFS_stage_class *klass)
165 {
166  m_row.m_event_name.make_row(klass);
167 
168  PFS_connection_stage_visitor visitor(klass);
169  PFS_connection_iterator::visit_global(true, /* hosts */
170  false, /* users */
171  true, true, & visitor);
172 
173  m_row.m_stat.set(m_normalizer, & visitor.m_stat);
174  m_row_exists= true;
175 }
176 
178 ::read_row_values(TABLE *table, unsigned char *, Field **fields,
179  bool read_all)
180 {
181  Field *f;
182 
183  if (unlikely(! m_row_exists))
184  return HA_ERR_RECORD_DELETED;
185 
186  /* Set the null bits */
187  DBUG_ASSERT(table->s->null_bytes == 0);
188 
189  for (; (f= *fields) ; fields++)
190  {
191  if (read_all || bitmap_is_set(table->read_set, f->field_index))
192  {
193  switch(f->field_index)
194  {
195  case 0: /* NAME */
196  m_row.m_event_name.set_field(f);
197  break;
198  default: /* 1, ... COUNT/SUM/MIN/AVG/MAX */
199  m_row.m_stat.set_field(f->field_index - 1, f);
200  break;
201  }
202  }
203  }
204 
205  return 0;
206 }
207