MySQL  8.0.27
Source Code Documentation
rpl_info_table.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 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
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 
34 class Server_ids;
35 struct 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  Speciffically, "schema"."table".
69  */
70  char *description;
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  */
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,
135  ulonglong *counter);
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  @param[out] counter Number of entries found.
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:43
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:798
uint do_get_rpl_info_type() override
Definition: rpl_info_table.cc:647
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:273
int do_flush_info(const bool force) override
Flushes and syncs in-memory information into a stable storage.
Definition: rpl_info_table.cc:172
Rpl_info_handler::enum_field_get_status do_get_info(const int pos, uchar *value, const size_t size, const uchar *default_value) override
int do_prepare_info_for_read() override
Definition: rpl_info_table.cc:633
Rpl_info_table(const Rpl_info_table &info)
int do_prepare_info_for_write() override
Definition: rpl_info_table.cc:643
bool do_update_is_transactional() override
Definition: rpl_info_table.cc:802
int do_clean_info() override
Definition: rpl_info_table.cc:275
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:708
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:335
Rpl_info_table & operator=(const Rpl_info_table &info)
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:56
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:103
Rpl_info_handler::enum_field_get_status do_get_info(const int pos, Server_ids *value, const Server_ids *default_value) override
void do_end_info() override
Definition: rpl_info_table.cc:631
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:93
enum_return_check do_check_info() override
Definition: rpl_info_table.cc:422
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:527
bool do_is_transactional() override
Definition: rpl_info_table.cc:800
bool do_set_info(const int pos, const char *value) override
Definition: rpl_info_table.cc:649
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:834
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:583
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
char * pos
Definition: do_ctype.cc:76
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
unsigned char uchar
Definition: my_inttypes.h:51
Log info(cout, "NOTE")
uint counter
Definition: mysqlimport.cc:53
const string value("\"Value\"")
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:41
Definition: table.h:1394
unsigned int uint
Definition: uca-dump.cc:29