Skip to content

Commit 0069e96

Browse files
committed
MDEV-37530: CI Round 2 & Early Feedback
* Rename files and classes to match the MariaDB code style * Fix compile issues on different setups * Fix RESET REPLICA * Kludge-fix `4294967.040` due to MDEV-35879. This nit is becoming a blocker if I continue on this route…
1 parent 3ba73e6 commit 0069e96

File tree

12 files changed

+188
-185
lines changed

12 files changed

+188
-185
lines changed

sql/rpl_info_file.hh renamed to sql/rpl_info_file.h

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020

2121
#include <cstdint> // uintN_t
2222
#include <charconv> // std::from/to_chars and other helpers
23-
#include <functional> // superclass of InfoFile::mem_fn
24-
#include <my_sys.h> // IO_CACHE
25-
#include <my_global.h> // FN_REFLEN
23+
#include <functional> // superclass of Info_file::Mem_fn
24+
#include <my_sys.h> // IO_CACHE, FN_REFLEN, ...
2625

2726

28-
namespace IntIOCache
27+
namespace Int_IO_CACHE
2928
{
3029
/** Number of fully-utilized decimal digits plus
3130
* the partially-utilized digit (e.g., the 2's place in "2147483647")
@@ -89,15 +88,15 @@ namespace IntIOCache
8988

9089

9190
/**
92-
This common superclass of @ref MasterInfoFile and
93-
@ref RelayLogInfoFile provides them common code for saving
91+
This common superclass of @ref Master_info_file and
92+
@ref Relay_log_info_file provides them common code for saving
9493
and loading fields in their MySQL line-based sections.
95-
As only the @ref MasterInfoFile has a MariaDB `key=value`
94+
As only the @ref Master_info_file has a MariaDB `key=value`
9695
section with a mix of explicit and `DEFAULT`-able fields,
97-
code for those are in @ref MasterInfoFile instead.
96+
code for those are in @ref Master_info_file instead.
9897
9998
Each field is an instance of an implementation
100-
of the @ref InfoFile::Persistent interface.
99+
of the @ref Info_file::Persistent interface.
101100
C++ templates enables code reuse for those implementation structs, but
102101
templates are not suitable for the conventional header/implementation split.
103102
Thus, this and derived files are header-only units (methods are `inline`).
@@ -106,7 +105,7 @@ namespace IntIOCache
106105
[C++20 modules](https://en.cppreference.com/w/cpp/language/modules.html)
107106
can supercede headers and their `#include` guards.
108107
*/
109-
struct InfoFile
108+
struct Info_file
110109
{
111110
IO_CACHE file;
112111

@@ -133,10 +132,10 @@ struct InfoFile
133132

134133
/** Integer Field
135134
@tparam I signed or unsigned integer type
136-
@see MasterInfoFile::OptionalIntField
135+
@see Master_info_file::Optional_int_field
137136
version with `DEFAULT` (not a subclass)
138137
*/
139-
template<typename I> struct IntField: Persistent
138+
template<typename I> struct Int_field: Persistent
140139
{
141140
I value;
142141
operator I() { return value; }
@@ -146,13 +145,13 @@ struct InfoFile
146145
return *this;
147146
}
148147
virtual bool load_from(IO_CACHE *file) override
149-
{ return IntIOCache::from_chars(file, value); }
148+
{ return Int_IO_CACHE::from_chars(file, value); }
150149
virtual void save_to(IO_CACHE *file) override
151-
{ return IntIOCache::to_chars(file, value); }
150+
{ return Int_IO_CACHE::to_chars(file, value); }
152151
};
153152

154153
/// Null-Terminated String (usually file name) Field
155-
template<size_t size= FN_REFLEN> struct StringField: Persistent
154+
template<size_t size= FN_REFLEN> struct String_field: Persistent
156155
{
157156
char buf[size];
158157
virtual operator const char *() { return buf; }
@@ -188,65 +187,65 @@ struct InfoFile
188187
};
189188

190189

191-
virtual ~InfoFile()= default;
190+
virtual ~Info_file()= default;
192191
virtual bool load_from_file()= 0;
193192
virtual void save_to_file()= 0;
194193

195194
protected:
196195

197196
/**
198-
std::mem_fn()-like nullable replacement for
197+
std::Mem_fn()-like nullable replacement for
199198
[member pointer upcasting](https://wg21.link/P0149R3)
200199
*/
201-
struct mem_fn: std::function<Persistent &(InfoFile *self)>
200+
struct Mem_fn: std::function<Persistent &(Info_file *self)>
202201
{
202+
using List= const std::initializer_list<Mem_fn>;
203203
/// Null Constructor
204-
mem_fn(nullptr_t null= nullptr):
205-
std::function<Persistent &(InfoFile *)>(null) {}
204+
Mem_fn(nullptr_t null= nullptr):
205+
std::function<Persistent &(Info_file *)>(null) {}
206206
/** Non-Null Constructor
207-
@tparam T CRTP subclass of InfoFile
207+
@tparam T CRTP subclass of Info_file
208208
@tparam M @ref Persistent subclass of the member
209209
@param pm member pointer
210210
*/
211-
template<class T, typename M> mem_fn(M T::* pm):
212-
std::function<Persistent &(InfoFile *)>(
213-
[pm](InfoFile *self) -> Persistent &
214-
{ return self->*static_cast<M InfoFile::*>(pm); }
211+
template<class T, typename M> Mem_fn(M T::* pm):
212+
std::function<Persistent &(Info_file *)>(
213+
[pm](Info_file *self) -> Persistent &
214+
{ return self->*static_cast<M Info_file::*>(pm); }
215215
) {}
216216
};
217217

218218
/**
219219
(Re)load the MySQL line-based section from the @ref file
220220
@param fields
221221
List of wrapped member pointers to fields. The first element must be a
222-
file name @ref StringField to be unambiguous with the line count line.
222+
file name @ref String_field to be unambiguous with the line count line.
223223
@param default_lines
224224
We cannot simply read lines until EOF as all versions
225225
of MySQL/MariaDB may generate more lines than needed.
226-
Therefore, starting with MySQL/MariaDB 4.1.x for @ref MasterInfoFile and
227-
5.6.x for @ref RelayLogInfoFile, the first line of the file is number of
228-
one-line-per-field lines in the file, including this line count itself.
226+
Therefore, starting with MySQL/MariaDB 4.1.x for @ref Master_info_file and
227+
5.6.x for @ref Relay_log_info_file, the first line of the file is number
228+
of one-line-per-field lines in the file, including this line count itself.
229229
This parameter specifies the number of effective lines before those
230230
versions (i.e., not counting the line count line if it was to have one),
231231
where the first line is a filename with extension
232232
(either contains a `.` or is entirely empty) rather than an integer.
233233
@return `false` if the file has parsed successfully or `true` if error
234234
*/
235-
bool load_from_file(std::initializer_list<mem_fn> fields,
236-
size_t default_lines)
235+
bool load_from_file(Mem_fn::List fields, size_t default_lines)
237236
{
238237
/**
239238
The first row is temporarily stored in the first field. If it is a line
240239
count and not a log name (new format), the second row will overwrite it.
241240
*/
242-
auto &field1= dynamic_cast<StringField<> &>((*(fields.begin()))(this));
241+
auto &field1= dynamic_cast<String_field<> &>((*(fields.begin()))(this));
243242
if (field1.load_from(&file))
244243
return true;
245244
size_t lines;
246245
std::from_chars_result result= std::from_chars(
247246
field1.buf, &field1.buf[sizeof(field1.buf)], lines);
248247
// Skip the first field in the for loop if that line was not a line count.
249-
size_t i= result.ec != IntIOCache::ERRC_OK || *(result.ptr) != '\0';
248+
size_t i= result.ec != Int_IO_CACHE::ERRC_OK || *(result.ptr) != '\0';
250249
/**
251250
Set the default after parsing: While std::from_chars() does not replace
252251
the output if it failed, it does replace if the line is not fully spent.
@@ -258,7 +257,7 @@ struct InfoFile
258257
int c;
259258
if (i < fields.size()) // line known in the ` list
260259
{
261-
const mem_fn &pm= fields.begin()[i];
260+
const Mem_fn &pm= fields.begin()[i];
262261
if (static_cast<bool>(pm))
263262
{
264263
if (pm(this).load_from(&file))
@@ -268,7 +267,7 @@ struct InfoFile
268267
}
269268
/*
270269
Count and discard unrecognized lines.
271-
This is especially to prepare for @ref MasterInfoFile for MariaDB 10.0+,
270+
This is especially to prepare for @ref Master_info_file for MariaDB 10.0+,
272271
which reserves a bunch of lines before its unique `key=value` section
273272
to accomodate any future line-based (old-style) additions in MySQL.
274273
(This will make moving from MariaDB to MySQL easier by not
@@ -291,7 +290,7 @@ struct InfoFile
291290
This reservation provides some compatibility
292291
should MySQL adds more line-based fields.
293292
*/
294-
void save_to_file(std::initializer_list<mem_fn> fields, size_t lines)
293+
void save_to_file(Mem_fn::List fields, size_t lines)
295294
{
296295
DBUG_ASSERT(lines >= fields.size());
297296
my_b_seek(&file, 0);
@@ -301,9 +300,9 @@ struct InfoFile
301300
But these garbage don't matter thanks to the number
302301
of effective lines in the first line of the file.
303302
*/
304-
IntIOCache::to_chars(&file, lines);
303+
Int_IO_CACHE::to_chars(&file, lines);
305304
my_b_write_byte(&file, '\n');
306-
for (const mem_fn &pm: fields)
305+
for (const Mem_fn &pm: fields)
307306
{
308307
if (static_cast<bool>(pm))
309308
pm(this).save_to(&file);
@@ -312,7 +311,7 @@ struct InfoFile
312311
/*
313312
Pad additional reserved lines:
314313
(1 for the line count line + field count) inclusive -> max line inclusive
315-
= field count exclusive <- max line inclusive
314+
= field count exclusive <- max line inclusive
316315
*/
317316
for (; lines > fields.size(); --lines)
318317
my_b_write_byte(&file, '\n');

0 commit comments

Comments
 (0)