MySQL 8.3.0
Source Code Documentation
rpl_info_table.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 2023, 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
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef RPL_INFO_TABLE_H
24#define RPL_INFO_TABLE_H
25
26#include <stddef.h>
27#include <sys/types.h>
28
29#include "lex_string.h"
30#include "my_inttypes.h"
31#include "sql/rpl_info_handler.h" // Rpl_info_handler
32
34class Server_ids;
35struct TABLE;
36
37/**
38 Methods to find information in a table:
39
40 FIND_SCAN does a index scan and stops at n-th occurrence.
41
42 FIND_KEY retrieves the index entry previous populated at
43 values if there is any.
44*/
46
48 friend class Rpl_info_factory;
49
50 public:
51 ~Rpl_info_table() override;
52
53 private:
54 /**
55 This property identifies the name of the schema where a
56 replication table is created.
57 */
59
60 /**
61 This property identifies the name of a replication
62 table.
63 */
65
66 /**
67 This property represents a description of the repository.
68 Specifically, "schema"."table".
69 */
71
72 /**
73 This property represents the amount of fields in the repository
74 primary key.
75 */
77
78 /**
79 This property identifies the indexes of the primary keys fields
80 in the table.
81 */
82 const uint *m_pk_field_indexes;
83
84 /**
85 This is a pointer to a class that facilitates manipulation
86 of replication tables.
87 */
89
90 /**
91 Identifies if a table is transactional or non-transactional.
92 This is used to provide a crash-safe behaviour.
93 */
95
96 int do_init_info() override;
97 int do_init_info(uint instance) override;
98 int do_init_info(enum_find_method method, uint instance);
100 enum_return_check do_check_info(uint instance) override;
101 void do_end_info() override;
102
103 /**
104 Flushes and syncs in-memory information into a stable storage.
105
106 @param[in] force If enabled ignore syncing after flushing options such as
107 relay-log-info-sync and master-info-sync and always sync
108
109 @retval 0 Success
110 @retval nonzero Failure This can happen if there is an error writing the
111 table, or if replica_preserve_commit_order is
112 enabled and a previous transaction has failed. In
113 both cases, the error has been reported already.
114 */
115 int do_flush_info(const bool force) override;
116 int do_remove_info() override;
117 int do_clean_info() override;
118 /**
119 Returns the number of entries in the table identified by:
120 param_schema.param_table.
121
122 @param[in] nparam Number of fields in the table.
123 @param[in] param_schema Table's schema.
124 @param[in] param_table Table's name.
125 @param[in] nullable_bitmap bitmap that holds the fields that are
126 allowed to be `NULL`-
127 @param[out] counter Number of entries found.
128
129 @retval false Success
130 @retval true Error
131 */
132 static bool do_count_info(uint nparam, const char *param_schema,
133 const char *param_table,
134 MY_BITMAP const *nullable_bitmap,
136 /**
137 Returns if the table is being used, meaning it contains at least a
138 line or some concurrency related error was returned when looking at
139 the table identified by: param_schema.param_table
140
141 @param[in] nparam Number of fields in the table.
142 @param[in] param_schema Table's schema.
143 @param[in] param_table Table's name.
144 @param[in] nullable_bitmap bitmap that holds the fields that are
145 allowed to be `NULL`-
146
147 @retval a pair of booleans
148 First element is true if an error occurred, false otherwise.
149 Second element is true if the table is not empty or an access error
150 occurred meaning someone else is accessing it. False if the table
151 is empty.
152 */
153 static std::pair<bool, bool> table_in_use(uint nparam,
154 const char *param_schema,
155 const char *param_table,
156 MY_BITMAP const *nullable_bitmap);
157
158 static int do_reset_info(uint nparam, const char *param_schema,
159 const char *param_table, const char *channel_name,
160 MY_BITMAP const *nullable_bitmap);
161 int do_prepare_info_for_read() override;
162 int do_prepare_info_for_write() override;
163
164 bool do_set_info(const int pos, const char *value) override;
165 bool do_set_info(const int pos, const uchar *value,
166 const size_t size) override;
167 bool do_set_info(const int pos, const int value) override;
168 bool do_set_info(const int pos, const ulong value) override;
169 bool do_set_info(const int pos, const float value) override;
170 bool do_set_info(const int pos, const Server_ids *value) override;
171 /**
172 Setter needed to set nullable fields to `NULL`.
173
174 @param pos the index of the field to set to `NULL`.
175 @param value unused value, needed to desimbiguate polimorphism.
176
177 @return true if there was an error and false otherwise.
178 */
179 bool do_set_info(const int pos, const std::nullptr_t value) override;
180 /**
181 Setter needed to set nullable fields to `NULL`.
182
183 @param pos the index of the field to set to `NULL`.
184 @param value unused value, needed to desimbiguate polimorphism.
185 @param size unused value size, needed to desimbiguate polimorphism.
186
187 @return true if there was an error and false otherwise.
188 */
189 bool do_set_info(const int pos, const std::nullptr_t value,
190 const size_t size) override;
192 const int pos, char *value, const size_t size,
193 const char *default_value) override;
195 const int pos, uchar *value, const size_t size,
196 const uchar *default_value) override;
198 const int pos, int *value, const int default_value) override;
200 const int pos, ulong *value, const ulong default_value) override;
202 const int pos, float *value, const float default_value) override;
204 const int pos, Server_ids *value,
205 const Server_ids *default_value) override;
206 char *do_get_description_info() override;
207
208 bool do_is_transactional() override;
209 bool do_update_is_transactional() override;
210 uint do_get_rpl_info_type() override;
211
212 /**
213 Verify if the table primary key fields are at the expected (column)
214 position.
215
216 @param table The table handle where the verification will be done.
217
218 @return false if the table primary key fields are fine.
219 @return true if problems were found with table primary key fields.
220 */
222
223 Rpl_info_table(uint nparam, const char *param_schema, const char *param_table,
224 const uint param_n_pk_fields = 0,
225 const uint *param_pk_field_indexes = nullptr,
226 MY_BITMAP const *nullable_bitmap = nullptr);
227
230};
231#endif /* RPL_INFO_TABLE_H */
Definition: rpl_info_factory.h:40
Definition: rpl_info_handler.h:57
enum_field_get_status
Definition: rpl_info_handler.h:65
Definition: rpl_info_table_access.h:37
Definition: rpl_info_table.h:47
char * do_get_description_info() override
Definition: rpl_info_table.cc:802
uint do_get_rpl_info_type() override
Definition: rpl_info_table.cc:651
bool is_transactional
Identifies if a table is transactional or non-transactional.
Definition: rpl_info_table.h:94
int do_remove_info() override
Definition: rpl_info_table.cc:275
int do_flush_info(const bool force) override
Flushes and syncs in-memory information into a stable storage.
Definition: rpl_info_table.cc:174
Rpl_info_table & operator=(const Rpl_info_table &info)
int do_prepare_info_for_read() override
Definition: rpl_info_table.cc:637
Rpl_info_table(const Rpl_info_table &info)
int do_prepare_info_for_write() override
Definition: rpl_info_table.cc:647
bool do_update_is_transactional() override
Definition: rpl_info_table.cc:806
int do_clean_info() override
Definition: rpl_info_table.cc:277
LEX_STRING str_schema
This property identifies the name of the schema where a replication table is created.
Definition: rpl_info_table.h:58
Rpl_info_handler::enum_field_get_status do_get_info(const int pos, char *value, const size_t size, const char *default_value) override
Definition: rpl_info_table.cc:712
static int do_reset_info(uint nparam, const char *param_schema, const char *param_table, const char *channel_name, MY_BITMAP const *nullable_bitmap)
Removes records belonging to the channel_name parameter's channel.
Definition: rpl_info_table.cc:337
LEX_STRING str_table
This property identifies the name of a replication table.
Definition: rpl_info_table.h:64
char * description
This property represents a description of the repository.
Definition: rpl_info_table.h:70
Rpl_info_table(uint nparam, const char *param_schema, const char *param_table, const uint param_n_pk_fields=0, const uint *param_pk_field_indexes=nullptr, MY_BITMAP const *nullable_bitmap=nullptr)
Definition: rpl_info_table.cc:58
Rpl_info_table_access * access
This is a pointer to a class that facilitates manipulation of replication tables.
Definition: rpl_info_table.h:88
int do_init_info() override
Definition: rpl_info_table.cc:105
void do_end_info() override
Definition: rpl_info_table.cc:635
const uint * m_pk_field_indexes
This property identifies the indexes of the primary keys fields in the table.
Definition: rpl_info_table.h:82
~Rpl_info_table() override
Definition: rpl_info_table.cc:95
enum_return_check do_check_info() override
Definition: rpl_info_table.cc:426
static bool do_count_info(uint nparam, const char *param_schema, const char *param_table, MY_BITMAP const *nullable_bitmap, ulonglong *counter)
Returns the number of entries in the table identified by: param_schema.param_table.
Definition: rpl_info_table.cc:531
bool do_is_transactional() override
Definition: rpl_info_table.cc:804
bool do_set_info(const int pos, const char *value) override
Definition: rpl_info_table.cc:653
bool verify_table_primary_key_fields(TABLE *table)
Verify if the table primary key fields are at the expected (column) position.
Definition: rpl_info_table.cc:838
static std::pair< bool, bool > table_in_use(uint nparam, const char *param_schema, const char *param_table, MY_BITMAP const *nullable_bitmap)
Returns if the table is being used, meaning it contains at least a line or some concurrency related e...
Definition: rpl_info_table.cc:587
uint m_n_pk_fields
This property represents the amount of fields in the repository primary key.
Definition: rpl_info_table.h:76
Definition: dynamic_ids.h:32
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
unsigned char uchar
Definition: my_inttypes.h:51
uint counter
Definition: mysqlimport.cc:57
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
enum_return_check
Definition: rpl_info_handler.h:50
enum_find_method
Methods to find information in a table:
Definition: rpl_info_table.h:45
@ FIND_SCAN
Definition: rpl_info_table.h:45
@ FIND_KEY
Definition: rpl_info_table.h:45
Definition: mysql_lex_string.h:34
Definition: my_bitmap.h:42
Definition: table.h:1403