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_SETUP_CONSUMERS_H
24 #define TABLE_SETUP_CONSUMERS_H
25 
26 /**
27   @file storage/perfschema/table_setup_consumers.h
28   Table SETUP_CONSUMERS (declarations).
29 */
30 
31 #include "pfs_column_types.h"
32 #include "pfs_engine_table.h"
33 
34 /**
35   @addtogroup Performance_schema_tables
36   @{
37 */
38 
39 /** A row of PERFORMANCE_SCHEMA.SETUP_CONSUMERS. */
40 struct row_setup_consumers
41 {
42   /** Column NAME. */
43   LEX_STRING m_name;
44   /** Column ENABLED. */
45   bool *m_enabled_ptr;
46   /** Hidden column, instrument refresh. */
47   bool m_instrument_refresh;
48   /** Hidden column, thread refresh. */
49   bool m_thread_refresh;
50 };
51 
52 /** Table PERFORMANCE_SCHEMA.SETUP_CONSUMERS. */
53 class table_setup_consumers : public PFS_engine_table
54 {
55 public:
56   /** Table share. */
57   static PFS_engine_table_share m_share;
58   static PFS_engine_table* create();
59   static ha_rows get_row_count();
60 
61   virtual int rnd_next();
62   virtual int rnd_pos(const void *pos);
63   virtual void reset_position(void);
64 
65 protected:
66   virtual int read_row_values(TABLE *table,
67                               unsigned char *buf,
68                               Field **fields,
69                               bool read_all);
70 
71   virtual int update_row_values(TABLE *table,
72                                 const unsigned char *old_buf,
73                                 unsigned char *new_buf,
74                                 Field **fields);
75 
76   table_setup_consumers();
77 
78 public:
~table_setup_consumers()79   ~table_setup_consumers()
80   {}
81 
82 private:
83   /** Table share lock. */
84   static THR_LOCK m_table_lock;
85   /** Fields definition. */
86   static TABLE_FIELD_DEF m_field_def;
87 
88   /** Current row. */
89   row_setup_consumers *m_row;
90   /** Current position. */
91   PFS_simple_index m_pos;
92   /** Next position. */
93   PFS_simple_index m_next_pos;
94 };
95 
96 /** @} */
97 #endif
98