1 /* Copyright (c) 2008, 2021, 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 Foundation,
21   51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22 
23 #ifndef TABLE_EVENTS_WAITS_SUMMARY_H
24 #define TABLE_EVENTS_WAITS_SUMMARY_H
25 
26 /**
27   @file storage/perfschema/table_events_waits_summary.h
28   Table EVENTS_WAITS_SUMMARY_BY_xxx (declarations).
29 */
30 
31 #include "pfs_column_types.h"
32 #include "pfs_engine_table.h"
33 #include "pfs_instr_class.h"
34 #include "pfs_instr.h"
35 #include "table_all_instr.h"
36 #include "table_helper.h"
37 
38 /**
39   @addtogroup Performance_schema_tables
40   @{
41 */
42 
43 /** A row of PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_INSTANCE. */
44 struct row_events_waits_summary_by_instance
45 {
46   /** Column EVENT_NAME. */
47   const char *m_name;
48   /** Length in bytes of @c m_name. */
49   uint m_name_length;
50   /** Column OBJECT_INSTANCE_BEGIN. */
51   intptr m_object_instance_addr;
52   /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
53   PFS_stat_row m_stat;
54 };
55 
56 /** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_INSTANCE. */
57 class table_events_waits_summary_by_instance : public table_all_instr
58 {
59 public:
60   /** Table share */
61   static PFS_engine_table_share m_share;
62   static PFS_engine_table* create();
63   static int delete_all_rows();
64 
65 protected:
66   void make_instr_row(PFS_instr *pfs, PFS_instr_class *klass,
67                       const void *object_instance_begin,
68                       PFS_single_stat *pfs_stat);
69   virtual void make_mutex_row(PFS_mutex *pfs);
70   virtual void make_rwlock_row(PFS_rwlock *pfs);
71   virtual void make_cond_row(PFS_cond *pfs);
72   virtual void make_file_row(PFS_file *pfs);
73   virtual void make_socket_row(PFS_socket *pfs);
74 
75   virtual int read_row_values(TABLE *table,
76                               unsigned char *buf,
77                               Field **fields,
78                               bool read_all);
79 
80   table_events_waits_summary_by_instance();
81 
82 public:
~table_events_waits_summary_by_instance()83   ~table_events_waits_summary_by_instance()
84   {}
85 
86 private:
87   /** Table share lock. */
88   static THR_LOCK m_table_lock;
89   /** Fields definition. */
90   static TABLE_FIELD_DEF m_field_def;
91 
92   /** Current row. */
93   row_events_waits_summary_by_instance m_row;
94   /** True if the current row exists. */
95   bool m_row_exists;
96 };
97 
98 /** @} */
99 #endif
100