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