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_STATUS_H
26 #define TABLE_REPLICATION_APPLIER_STATUS_H
27 
28 /**
29   @file storage/perfschema/table_replication_applier_status.h
30   Table replication_applier_status (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 #ifndef ENUM_RPL_YES_NO
48 #define ENUM_RPL_YES_NO
49 /** enum values for Service_State field*/
50 enum enum_rpl_yes_no {
51   PS_RPL_YES= 1,
52   PS_RPL_NO
53 };
54 #endif
55 
56 /** A row in the table. */
57 struct st_row_applier_status {
58   char channel_name[CHANNEL_NAME_LENGTH];
59   uint channel_name_length;
60   enum_rpl_yes_no service_state;
61   uint remaining_delay;
62   bool remaining_delay_is_set;
63   ulong count_transactions_retries;
64 };
65 
66 /** Table PERFORMANCE_SCHEMA.replication_applier_status */
67 class table_replication_applier_status: public PFS_engine_table
68 {
69   typedef PFS_simple_index pos_t;
70 
71 private:
72   void make_row(Master_info *mi);
73 
74   /** Table share lock. */
75   static THR_LOCK m_table_lock;
76   /** Fields definition. */
77   static TABLE_FIELD_DEF m_field_def;
78   /** Current row */
79   st_row_applier_status m_row;
80   /** True is the current row exists. */
81   bool m_row_exists;
82   /** Current position. */
83   pos_t m_pos;
84   /** Next position. */
85   pos_t m_next_pos;
86 
87 protected:
88   /**
89     Read the current row values.
90     @param table            Table handle
91     @param buf              row buffer
92     @param fields           Table fields
93     @param read_all         true if all columns are read.
94   */
95 
96   virtual int read_row_values(TABLE *table,
97                               unsigned char *buf,
98                               Field **fields,
99                               bool read_all);
100 
101   table_replication_applier_status();
102 
103 public:
104   ~table_replication_applier_status();
105 
106   /** Table share. */
107   static PFS_engine_table_share m_share;
108   static PFS_engine_table* create();
109   static ha_rows get_row_count();
110   virtual int rnd_next();
111   virtual int rnd_pos(const void *pos);
112   virtual void reset_position(void);
113 
114 };
115 
116 /** @} */
117 #endif
118