MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
table_file_summary_by_event_name.cc
1 /* Copyright (c) 2008, 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 Foundation,
14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 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_visitor.h"
29 
30 THR_LOCK table_file_summary_by_event_name::m_table_lock;
31 
32 static const TABLE_FIELD_TYPE field_types[]=
33 {
34  {
35  { C_STRING_WITH_LEN("EVENT_NAME") },
36  { C_STRING_WITH_LEN("varchar(128)") },
37  { NULL, 0}
38  },
39  {
40  { C_STRING_WITH_LEN("COUNT_STAR") },
41  { C_STRING_WITH_LEN("bigint(20)") },
42  { NULL, 0}
43  },
44  {
45  { C_STRING_WITH_LEN("SUM_TIMER_WAIT") },
46  { C_STRING_WITH_LEN("bigint(20)") },
47  { NULL, 0}
48  },
49  {
50  { C_STRING_WITH_LEN("MIN_TIMER_WAIT") },
51  { C_STRING_WITH_LEN("bigint(20)") },
52  { NULL, 0}
53  },
54  {
55  { C_STRING_WITH_LEN("AVG_TIMER_WAIT") },
56  { C_STRING_WITH_LEN("bigint(20)") },
57  { NULL, 0}
58  },
59  {
60  { C_STRING_WITH_LEN("MAX_TIMER_WAIT") },
61  { C_STRING_WITH_LEN("bigint(20)") },
62  { NULL, 0}
63  },
64 
66  {
67  { C_STRING_WITH_LEN("COUNT_READ") },
68  { C_STRING_WITH_LEN("bigint(20)") },
69  { NULL, 0}
70  },
71  {
72  { C_STRING_WITH_LEN("SUM_TIMER_READ") },
73  { C_STRING_WITH_LEN("bigint(20)") },
74  { NULL, 0}
75  },
76  {
77  { C_STRING_WITH_LEN("MIN_TIMER_READ") },
78  { C_STRING_WITH_LEN("bigint(20)") },
79  { NULL, 0}
80  },
81  {
82  { C_STRING_WITH_LEN("AVG_TIMER_READ") },
83  { C_STRING_WITH_LEN("bigint(20)") },
84  { NULL, 0}
85  },
86  {
87  { C_STRING_WITH_LEN("MAX_TIMER_READ") },
88  { C_STRING_WITH_LEN("bigint(20)") },
89  { NULL, 0}
90  },
91  {
92  { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_READ") },
93  { C_STRING_WITH_LEN("bigint(20)") },
94  { NULL, 0}
95  },
96 
98  {
99  { C_STRING_WITH_LEN("COUNT_WRITE") },
100  { C_STRING_WITH_LEN("bigint(20)") },
101  { NULL, 0}
102  },
103  {
104  { C_STRING_WITH_LEN("SUM_TIMER_WRITE") },
105  { C_STRING_WITH_LEN("bigint(20)") },
106  { NULL, 0}
107  },
108  {
109  { C_STRING_WITH_LEN("MIN_TIMER_WRITE") },
110  { C_STRING_WITH_LEN("bigint(20)") },
111  { NULL, 0}
112  },
113  {
114  { C_STRING_WITH_LEN("AVG_TIMER_WRITE") },
115  { C_STRING_WITH_LEN("bigint(20)") },
116  { NULL, 0}
117  },
118  {
119  { C_STRING_WITH_LEN("MAX_TIMER_WRITE") },
120  { C_STRING_WITH_LEN("bigint(20)") },
121  { NULL, 0}
122  },
123  {
124  { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_WRITE") },
125  { C_STRING_WITH_LEN("bigint(20)") },
126  { NULL, 0}
127  },
128 
130  {
131  { C_STRING_WITH_LEN("COUNT_MISC") },
132  { C_STRING_WITH_LEN("bigint(20)") },
133  { NULL, 0}
134  },
135  {
136  { C_STRING_WITH_LEN("SUM_TIMER_MISC") },
137  { C_STRING_WITH_LEN("bigint(20)") },
138  { NULL, 0}
139  },
140  {
141  { C_STRING_WITH_LEN("MIN_TIMER_MISC") },
142  { C_STRING_WITH_LEN("bigint(20)") },
143  { NULL, 0}
144  },
145  {
146  { C_STRING_WITH_LEN("AVG_TIMER_MISC") },
147  { C_STRING_WITH_LEN("bigint(20)") },
148  { NULL, 0}
149  },
150  {
151  { C_STRING_WITH_LEN("MAX_TIMER_MISC") },
152  { C_STRING_WITH_LEN("bigint(20)") },
153  { NULL, 0}
154  }
155 };
156 
158 table_file_summary_by_event_name::m_field_def=
159 { 23, field_types };
160 
163 {
164  { C_STRING_WITH_LEN("file_summary_by_event_name") },
166  &table_file_summary_by_event_name::create,
167  NULL, /* write_row */
168  table_file_summary_by_event_name::delete_all_rows,
169  NULL, /* get_row_count */
170  1000, /* records */
171  sizeof(PFS_simple_index),
172  &m_table_lock,
173  &m_field_def,
174  false /* checked */
175 };
176 
177 PFS_engine_table* table_file_summary_by_event_name::create(void)
178 {
180 }
181 
182 int table_file_summary_by_event_name::delete_all_rows(void)
183 {
186  return 0;
187 }
188 
189 table_file_summary_by_event_name::table_file_summary_by_event_name()
190  : PFS_engine_table(&m_share, &m_pos),
191  m_pos(1), m_next_pos(1)
192 {}
193 
195 {
196  m_pos.m_index= 1;
197  m_next_pos.m_index= 1;
198 }
199 
201 {
202  PFS_file_class *file_class;
203 
204  m_pos.set_at(&m_next_pos);
205 
206  file_class= find_file_class(m_pos.m_index);
207  if (file_class)
208  {
209  make_row(file_class);
210  m_next_pos.set_after(&m_pos);
211  return 0;
212  }
213 
214  return HA_ERR_END_OF_FILE;
215 }
216 
218 {
219  PFS_file_class *file_class;
220 
221  set_position(pos);
222 
223  file_class= find_file_class(m_pos.m_index);
224  if (file_class)
225  {
226  make_row(file_class);
227  return 0;
228  }
229 
230  return HA_ERR_RECORD_DELETED;
231 }
232 
237 void table_file_summary_by_event_name::make_row(PFS_file_class *file_class)
238 {
239  m_row.m_event_name.make_row(file_class);
240 
242  PFS_instance_iterator::visit_file_instances(file_class, &visitor);
243 
245 
246  /* Collect timer and byte count stats */
247  m_row.m_io_stat.set(normalizer, &visitor.m_file_io_stat);
248  m_row_exists= true;
249 
250 }
251 
252 int table_file_summary_by_event_name::read_row_values(TABLE *table,
253  unsigned char *,
254  Field **fields,
255  bool read_all)
256 {
257  Field *f;
258 
259  if (unlikely(!m_row_exists))
260  return HA_ERR_RECORD_DELETED;
261 
262  /* Set the null bits */
263  DBUG_ASSERT(table->s->null_bytes == 0);
264 
265  for (; (f= *fields) ; fields++)
266  {
267  if (read_all || bitmap_is_set(table->read_set, f->field_index))
268  {
269  switch(f->field_index)
270  {
271  case 0: /* EVENT_NAME */
272  m_row.m_event_name.set_field(f);
273  break;
274  case 1: /* COUNT_STAR */
275  set_field_ulonglong(f, m_row.m_io_stat.m_all.m_waits.m_count);
276  break;
277  case 2: /* SUM_TIMER_WAIT */
278  set_field_ulonglong(f, m_row.m_io_stat.m_all.m_waits.m_sum);
279  break;
280  case 3: /* MIN_TIMER_WAIT */
281  set_field_ulonglong(f, m_row.m_io_stat.m_all.m_waits.m_min);
282  break;
283  case 4: /* AVG_TIMER_WAIT */
284  set_field_ulonglong(f, m_row.m_io_stat.m_all.m_waits.m_avg);
285  break;
286  case 5: /* MAX_TIMER_WAIT */
287  set_field_ulonglong(f, m_row.m_io_stat.m_all.m_waits.m_max);
288  break;
289 
290  case 6: /* COUNT_READ */
291  set_field_ulonglong(f, m_row.m_io_stat.m_read.m_waits.m_count);
292  break;
293  case 7: /* SUM_TIMER_READ */
294  set_field_ulonglong(f, m_row.m_io_stat.m_read.m_waits.m_sum);
295  break;
296  case 8: /* MIN_TIMER_READ */
297  set_field_ulonglong(f, m_row.m_io_stat.m_read.m_waits.m_min);
298  break;
299  case 9: /* AVG_TIMER_READ */
300  set_field_ulonglong(f, m_row.m_io_stat.m_read.m_waits.m_avg);
301  break;
302  case 10: /* MAX_TIMER_READ */
303  set_field_ulonglong(f, m_row.m_io_stat.m_read.m_waits.m_max);
304  break;
305  case 11: /* SUM_NUMBER_OF_BYTES_READ */
306  set_field_ulonglong(f, m_row.m_io_stat.m_read.m_bytes);
307  break;
308 
309  case 12: /* COUNT_WRITE */
310  set_field_ulonglong(f, m_row.m_io_stat.m_write.m_waits.m_count);
311  break;
312  case 13: /* SUM_TIMER_WRITE */
313  set_field_ulonglong(f, m_row.m_io_stat.m_write.m_waits.m_sum);
314  break;
315  case 14: /* MIN_TIMER_WRITE */
316  set_field_ulonglong(f, m_row.m_io_stat.m_write.m_waits.m_min);
317  break;
318  case 15: /* AVG_TIMER_WRITE */
319  set_field_ulonglong(f, m_row.m_io_stat.m_write.m_waits.m_avg);
320  break;
321  case 16: /* MAX_TIMER_WRITE */
322  set_field_ulonglong(f, m_row.m_io_stat.m_write.m_waits.m_max);
323  break;
324  case 17: /* SUM_NUMBER_OF_BYTES_WRITE */
325  set_field_ulonglong(f, m_row.m_io_stat.m_write.m_bytes);
326  break;
327 
328  case 18: /* COUNT_MISC */
329  set_field_ulonglong(f, m_row.m_io_stat.m_misc.m_waits.m_count);
330  break;
331  case 19: /* SUM_TIMER_MISC */
332  set_field_ulonglong(f, m_row.m_io_stat.m_misc.m_waits.m_sum);
333  break;
334  case 20: /* MIN_TIMER_MISC */
335  set_field_ulonglong(f, m_row.m_io_stat.m_misc.m_waits.m_min);
336  break;
337  case 21: /* AVG_TIMER_MISC */
338  set_field_ulonglong(f, m_row.m_io_stat.m_misc.m_waits.m_avg);
339  break;
340  case 22: /* MAX_TIMER_MISC */
341  set_field_ulonglong(f, m_row.m_io_stat.m_misc.m_waits.m_max);
342  break;
343 
344  default:
345  DBUG_ASSERT(false);
346  break;
347  }
348  } // if
349  } // for
350 
351  return 0;
352 }