MySQL 8.0.40
Source Code Documentation
rpl_info_file.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_FILE_H
25#define RPL_INFO_FILE_H
26
27#include <stddef.h>
28#include <sys/types.h>
29
30#include "my_inttypes.h"
31#include "my_io.h"
32#include "my_sys.h" // IO_CACHE
33#include "sql/rpl_info_handler.h" // Rpl_info_handler
34
35class Server_ids;
36
37/**
38 Defines a file handler.
39*/
41 friend class Rpl_info_factory;
42
43 public:
44 ~Rpl_info_file() override;
45
46 private:
47 /**
48 This uniquely identifies a file.
49
50 When introducing multi-master replication one needs to ensure
51 that files' names are unique. If tables are used, there is no
52 issue at all. It is highly recommend to avoid using files as
53 they do not provide an atomic behavior.
54 */
55 char info_fname[FN_REFLEN + 128];
56
57 /**
58 This is used to identified a name's pattern. For instance,
59 worker-relay-log.info.*.
60 */
62
63 /*
64 info_fd - file descriptor of the info file. set only during
65 initialization or clean up - safe to read anytime
66 */
68
69 /* IO_CACHE of the info file - set only during init or end */
71
72 /*
73 The flag indicates whether the file name include the instance number or not.
74 */
76
77 int do_init_info() override;
78 int do_init_info(uint instance) override;
80 enum_return_check do_check_info(uint instance) override;
81 void do_end_info() override;
82 int do_flush_info(const bool force) override;
83 int do_remove_info() override;
84 int do_clean_info() override;
85 /**
86 Returns the number of files that corresponds to param_info_fname.
87 If param_info_fname is a regular expression, @c expression is
88 set.
89
90 @param[in] nparam Number of fields in the file.
91 @param[in] param_pattern_fname File's name.
92 @param[in] indexed indicates whether the file is indexed and
93 if so there is a range to count in.
94 @param[in] nullable_bitmap bitmap that holds the fields that are
95 allowed to be `NULL`.
96 @param[out] counter Number of files found.
97
98 @retval false Success
99 @retval true Error
100 */
101 static bool do_count_info(const int nparam, const char *param_pattern_fname,
102 bool indexed, MY_BITMAP const *nullable_bitmap,
103 uint *counter);
104 static int do_reset_info(int const nparam, const char *param_pattern_fname,
105 bool name_indexed, MY_BITMAP const *nullable_bitmap);
106
107 int do_prepare_info_for_read() override;
108 int do_prepare_info_for_write() override;
109 bool do_set_info(const int pos, const char *value) override;
110 bool do_set_info(const int pos, const uchar *value,
111 const size_t size) override;
112 bool do_set_info(const int pos, const int value) override;
113 bool do_set_info(const int pos, const ulong value) override;
114 bool do_set_info(const int pos, const float value) override;
115 bool do_set_info(const int pos, const Server_ids *value) override;
116 /**
117 Setter needed to set nullable fields to `NULL`.
118
119 @param pos the index of the field to set to `NULL`.
120 @param value unused value, needed to desimbiguate polimorphism.
121
122 @return true if there was an error and false otherwise.
123 */
124 bool do_set_info(const int pos, const std::nullptr_t value) override;
125 /**
126 Setter needed to set nullable fields to `NULL`.
127
128 @param pos the index of the field to set to `NULL`.
129 @param value unused value, needed to desimbiguate polimorphism.
130 @param size unused value size, needed to desimbiguate polimorphism.
131
132 @return true if there was an error and false otherwise.
133 */
134 bool do_set_info(const int pos, const std::nullptr_t value,
135 const size_t size) override;
136 /**
137 Checks if the value returned from the read function is an actual error or
138 just the side-effect of a nullable field.
139
140 @param pos the position of the field to check.
141 @param n_read_bytes number of read bytes, returned from the read function.
142
143 @return `FIELD_VALUE_NOT_NULL` if the number of read bytes is bigger or
144 equal than 0 or the column is not nullable.
145 `FIELD_VALUE_IS_NULL` if the number of read bytes is 0 and the
146 columns is nullable.
147 `FAILURE` if the number of read bytes is lower than 0.
148 */
150 long n_read_bytes);
152 const int pos, char *value, const size_t size,
153 const char *default_value) override;
155 const int pos, uchar *value, const size_t size,
156 const uchar *default_value) override;
158 const int pos, int *value, const int default_value) override;
160 const int pos, ulong *value, const ulong default_value) override;
162 const int pos, float *value, const float default_value) override;
164 const int pos, Server_ids *value,
165 const Server_ids *default_value) override;
166 char *do_get_description_info() override;
167 uint do_get_rpl_info_type() override;
168
169 bool do_is_transactional() override;
170 bool do_update_is_transactional() override;
171
172 Rpl_info_file(int const nparam, const char *param_pattern_fname,
173 const char *param_info_fname, bool name_indexed,
174 MY_BITMAP const *nullable_bitmap);
175
178};
179#endif /* RPL_INFO_FILE_H */
Definition: rpl_info_factory.h:44
Defines a file handler.
Definition: rpl_info_file.h:40
uint do_get_rpl_info_type() override
Definition: rpl_info_file.cc:468
int do_prepare_info_for_read() override
Definition: rpl_info_file.cc:144
int do_clean_info() override
Definition: rpl_info_file.cc:286
static int do_reset_info(int const nparam, const char *param_pattern_fname, bool name_indexed, MY_BITMAP const *nullable_bitmap)
Definition: rpl_info_file.cc:294
File info_fd
Definition: rpl_info_file.h:67
bool do_set_info(const int pos, const char *value) override
Definition: rpl_info_file.cc:327
int do_flush_info(const bool force) override
Definition: rpl_info_file.cc:249
int do_init_info() override
Definition: rpl_info_file.cc:89
bool do_update_is_transactional() override
Definition: rpl_info_file.cc:466
static bool do_count_info(const int nparam, const char *param_pattern_fname, bool indexed, MY_BITMAP const *nullable_bitmap, uint *counter)
Returns the number of files that corresponds to param_info_fname.
Definition: rpl_info_file.cc:215
int do_remove_info() override
Definition: rpl_info_file.cc:273
char * do_get_description_info() override
Definition: rpl_info_file.cc:462
bool do_is_transactional() override
Definition: rpl_info_file.cc:464
Rpl_info_file(const Rpl_info_file &info)
int do_prepare_info_for_write() override
Definition: rpl_info_file.cc:151
void do_end_info() override
Definition: rpl_info_file.cc:263
Rpl_info_file & operator=(const Rpl_info_file &info)
char info_fname[FN_REFLEN+128]
This uniquely identifies a file.
Definition: rpl_info_file.h:55
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_file.cc:405
char pattern_fname[FN_REFLEN+128]
This is used to identified a name's pattern.
Definition: rpl_info_file.h:61
bool name_indexed
Definition: rpl_info_file.h:75
enum_return_check do_check_info() override
Definition: rpl_info_file.cc:191
~Rpl_info_file() override
Definition: rpl_info_file.cc:72
Rpl_info_handler::enum_field_get_status check_for_error(int pos, long n_read_bytes)
Checks if the value returned from the read function is an actual error or just the side-effect of a n...
Definition: rpl_info_file.cc:396
IO_CACHE info_file
Definition: rpl_info_file.h:70
Rpl_info_file(int const nparam, const char *param_pattern_fname, const char *param_info_fname, bool name_indexed, MY_BITMAP const *nullable_bitmap)
Definition: rpl_info_file.cc:60
Definition: rpl_info_handler.h:58
enum_field_get_status
Definition: rpl_info_handler.h:66
Definition: dynamic_ids.h:33
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:83
int File
Definition: my_io_bits.h:51
Common header for many mysys elements.
Log info(cout, "NOTE")
uint counter
Definition: mysqlimport.cc:54
enum_return_check
Definition: rpl_info_handler.h:51
Definition: my_sys.h:341
Definition: my_bitmap.h:43
unsigned int uint
Definition: uca9-dump.cc:75