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_OBJECTS_H
24 #define TABLE_SETUP_OBJECTS_H
25 
26 /**
27   @file storage/perfschema/table_setup_objects.h
28   Table SETUP_OBJECTS (declarations).
29 */
30 
31 #include "pfs_engine_table.h"
32 #include "table_helper.h"
33 
34 struct PFS_setup_object;
35 
36 /**
37   @addtogroup Performance_schema_tables
38   @{
39 */
40 
41 /** A row of PERFORMANCE_SCHEMA.SETUP_OBJECTS. */
42 struct row_setup_objects
43 {
44   /** Column OBJECT_TYPE. */
45   enum_object_type m_object_type;
46   /** Column SCHEMA_NAME. */
47   char m_schema_name[NAME_LEN];
48   /** Length in bytes of @c m_schema_name. */
49   uint m_schema_name_length;
50   /** Column OBJECT_NAME. */
51   char m_object_name[NAME_LEN];
52   /** Length in bytes of @c m_object_name. */
53   uint m_object_name_length;
54   /** Column ENABLED. */
55   bool *m_enabled_ptr;
56   /** Column TIMED. */
57   bool *m_timed_ptr;
58 };
59 
60 /** Table PERFORMANCE_SCHEMA.SETUP_OBJECTS. */
61 class table_setup_objects : public PFS_engine_table
62 {
63 public:
64   /** Table share. */
65   static PFS_engine_table_share m_share;
66   /** Table builder. */
67   static PFS_engine_table* create();
68   static int write_row(TABLE *table, unsigned char *buf, Field **fields);
69   static int delete_all_rows();
70   static ha_rows get_row_count();
71 
72   virtual int rnd_next();
73   virtual int rnd_pos(const void *pos);
74   virtual void reset_position(void);
75 
76 protected:
77   virtual int read_row_values(TABLE *table,
78                               unsigned char *buf,
79                               Field **fields,
80                               bool read_all);
81 
82   virtual int update_row_values(TABLE *table,
83                                 const unsigned char *old_buf,
84                                 unsigned char *new_buf,
85                                 Field **fields);
86 
87   virtual int delete_row_values(TABLE *table,
88                                 const unsigned char *buf,
89                                 Field **fields);
90 
91   table_setup_objects();
92 
93 public:
~table_setup_objects()94   ~table_setup_objects()
95   {}
96 
97 private:
98   void make_row(PFS_setup_object *pfs);
99 
100   /** Table share lock. */
101   static THR_LOCK m_table_lock;
102   /** Fields definition. */
103   static TABLE_FIELD_DEF m_field_def;
104 
105   /** Current row. */
106   row_setup_objects m_row;
107   /** True is the current row exists. */
108   bool m_row_exists;
109   /** Current position. */
110   PFS_simple_index m_pos;
111   /** Next position. */
112   PFS_simple_index m_next_pos;
113 };
114 
115 /** @} */
116 #endif
117