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