1 /*
2    Copyright (c) 2013, 2021, Oracle and/or its affiliates.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
23 
24 
25 #ifndef TABLE_REPLICATION_APPLIER_CONFIGURATION_H
26 #define TABLE_REPLICATION_APPLIER_CONFIGURATION_H
27 
28 /**
29   @file storage/perfschema/table_replication_applier_configuration.h
30   Table replication_applier_configuration (declarations).
31 */
32 
33 #include "pfs_column_types.h"
34 #include "pfs_engine_table.h"
35 #include "rpl_mi.h"
36 #include "mysql_com.h"
37 #include "rpl_msr.h"
38 #include "rpl_info.h"  /*CHANNEL_NAME_LENGTH*/
39 
40 class Master_info;
41 
42 /**
43   @addtogroup Performance_schema_tables
44   @{
45 */
46 
47 /** A row in the table*/
48 struct st_row_applier_config {
49   char channel_name[CHANNEL_NAME_LENGTH];
50   uint channel_name_length;
51   time_t desired_delay;
52   bool desired_delay_is_set;
53 };
54 
55 /** Table PERFORMANCE_SCHEMA.replication_applier_configuration */
56 class table_replication_applier_configuration: public PFS_engine_table
57 {
58   typedef PFS_simple_index pos_t;
59 
60 private:
61   void make_row(Master_info *mi);
62 
63   /** Table share lock. */
64   static THR_LOCK m_table_lock;
65   /** Fields definition. */
66   static TABLE_FIELD_DEF m_field_def;
67   /** Current row */
68   st_row_applier_config m_row;
69   /** True is the current row exists. */
70   bool m_row_exists;
71   /** Current position. */
72   pos_t m_pos;
73   /** Next position. */
74   pos_t m_next_pos;
75 
76 protected:
77   /**
78     Read the current row values.
79     @param table            Table handle
80     @param buf              row buffer
81     @param fields           Table fields
82     @param read_all         true if all columns are read.
83   */
84 
85   virtual int read_row_values(TABLE *table,
86                               unsigned char *buf,
87                               Field **fields,
88                               bool read_all);
89 
90   table_replication_applier_configuration();
91 
92 public:
93   ~table_replication_applier_configuration();
94 
95   /** Table share. */
96   static PFS_engine_table_share m_share;
97   static PFS_engine_table* create();
98   static ha_rows get_row_count();
99   virtual int rnd_next();
100   virtual int rnd_pos(const void *pos);
101   virtual void reset_position(void);
102 
103 };
104 
105 /** @} */
106 #endif
107