MySQL 9.1.0
Source Code Documentation
bootstrap_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 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 BOOTSTRAP_IMPL_H
25#define BOOTSTRAP_IMPL_H 1
26#include <string>
27
28#include "sql/sql_bootstrap.h" // MAX_BOOTSTRAP_QUERY_SIZE
29
30namespace bootstrap {
31
32/** Abstract interface to reading bootstrap commands */
34 public:
35 typedef void (*log_function_t)(const char *message);
36
37 /**
38 start processing the iterator
39 @retval false Success
40 @retval true failure
41 */
42 virtual bool begin(void) { return false; }
43
44 /**
45 Get the next query string.
46
47 @param[out] query return the query
48 @return one of the READ_BOOTSTRAP
49 */
50 virtual int next(std::string &query) = 0;
51
52 virtual void report_error_details(log_function_t log) = 0;
53
54 /** End processing the iterator */
55 virtual void end(void) {}
56
57 protected:
58 Command_iterator() = default;
59 ~Command_iterator() = default;
60};
61
62/** File bootstrap command reader */
64 public:
66 fgets_fn_t fgets_fn)
67 : m_input(input), m_fgets_fn(fgets_fn) {
69 }
71
72 int next(std::string &query) override;
73
74 void report_error_details(log_function_t log) override;
75
76 protected:
80};
81
82} // namespace bootstrap
83
84#endif /* BOOTSTRAP_IMPL_H */
Abstract interface to reading bootstrap commands.
Definition: bootstrap_impl.h:33
virtual void end(void)
End processing the iterator.
Definition: bootstrap_impl.h:55
void(* log_function_t)(const char *message)
Definition: bootstrap_impl.h:35
virtual int next(std::string &query)=0
Get the next query string.
virtual bool begin(void)
start processing the iterator
Definition: bootstrap_impl.h:42
virtual void report_error_details(log_function_t log)=0
File bootstrap command reader.
Definition: bootstrap_impl.h:63
fgets_fn_t m_fgets_fn
Definition: bootstrap_impl.h:79
int next(std::string &query) override
Get the next query string.
Definition: bootstrap.cc:73
File_command_iterator(const char *file_name, MYSQL_FILE *input, fgets_fn_t fgets_fn)
Definition: bootstrap_impl.h:65
void report_error_details(log_function_t log) override
Definition: bootstrap.cc:86
bootstrap_parser_state m_parser_state
Definition: bootstrap_impl.h:77
MYSQL_FILE * m_input
Definition: bootstrap_impl.h:78
static char * query
Definition: myisam_ftdump.cc:47
Definition: bootstrap.cc:71
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94
char *(* fgets_fn_t)(char *, size_t, MYSQL_FILE *, int *error)
Definition: sql_bootstrap.h:59
An instrumented FILE structure.
Definition: mysql_file.h:484
Definition: sql_bootstrap.h:90
void init(const char *filename)
Definition: sql_bootstrap.cc:39