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