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