1 /* Copyright (c) 2010, 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
21   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
22 
23 #ifndef TABLE_ETS_GLOBAL_BY_EVENT_NAME_H
24 #define TABLE_ETS_GLOBAL_BY_EVENT_NAME_H
25 
26 /**
27   @file storage/perfschema/table_ets_global_by_event_name.h
28   Table EVENTS_TRANSACTIONS_SUMMARY_GLOBAL_BY_EVENT_NAME (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_helper.h"
36 
37 /**
38   @addtogroup Performance_schema_tables
39   @{
40 */
41 
42 /**
43   A row of table
44   PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_SUMMARY_GLOBAL_BY_EVENT_NAME.
45 */
46 struct row_ets_global_by_event_name
47 {
48   /** Column EVENT_NAME. */
49   PFS_event_name_row m_event_name;
50   /**
51     Columns COUNT_STAR, SUM/MIN/AVG/MAX_TIMER_WAIT,
52     COUNT_READ_WRITE, SUM/MIN/AVG/MAX_TIMER_READ_WRITE,
53     COUNT_READ_ONLY, SUM/MIN/AVG/MAX_TIMER_READ_ONLY
54   */
55   PFS_transaction_stat_row m_stat;
56 };
57 
58 /** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_SUMMARY_GLOBAL_BY_EVENT_NAME. */
59 class table_ets_global_by_event_name : public PFS_engine_table
60 {
61 public:
62   /** Table share */
63   static PFS_engine_table_share m_share;
64   static PFS_engine_table* create();
65   static int delete_all_rows();
66   static ha_rows get_row_count();
67 
68   virtual int rnd_init(bool scan);
69   virtual int rnd_next();
70   virtual int rnd_pos(const void *pos);
71   virtual void reset_position(void);
72 
73 protected:
74   virtual int read_row_values(TABLE *table,
75                               unsigned char *buf,
76                               Field **fields,
77                               bool read_all);
78 
79   table_ets_global_by_event_name();
80 
81 public:
~table_ets_global_by_event_name()82   ~table_ets_global_by_event_name()
83   {}
84 
85 protected:
86   void make_row(PFS_transaction_class *klass);
87 
88 private:
89   /** Table share lock. */
90   static THR_LOCK m_table_lock;
91   /** Fields definition. */
92   static TABLE_FIELD_DEF m_field_def;
93 
94   /** Current row. */
95   row_ets_global_by_event_name m_row;
96   /** True is the current row exists. */
97   bool m_row_exists;
98   /** Current position. */
99   PFS_simple_index m_pos;
100   /** Next position. */
101   PFS_simple_index m_next_pos;
102 };
103 
104 /** @} */
105 #endif
106