MySQL  8.0.27
Source Code Documentation
sql_bootstrap.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 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 SQL_BOOTSTRAP_H
24 #define SQL_BOOTSTRAP_H
25 
26 #include <stddef.h>
27 #include <functional>
28 
29 #include "map_helpers.h"
30 
31 struct MYSQL_FILE;
32 
33 /**
34  The maximum size of a bootstrap query.
35  Increase this size if parsing a longer query during bootstrap is necessary.
36  The longest query in use depends on the documentation content,
37  see the file fill_help_tables.sql
38 */
39 #define MAX_BOOTSTRAP_QUERY_SIZE 74000
40 /**
41  The maximum size of a bootstrap query, expressed in a single line.
42  Do not increase this size, use the multiline syntax instead.
43 */
44 #define MAX_BOOTSTRAP_LINE_SIZE 74000
45 
56 };
57 
58 typedef char *(*fgets_fn_t)(char *, size_t, MYSQL_FILE *, int *error);
59 
61  /** Delimiter is ';' */
63  /** Delimiter is "$$" */
65 };
66 
68  /** Parsing sql code. */
70  /** Parsing a 'literal' string. */
72  /** Parsing a "literal" string. */
74  /** Parsing a "--" comment. */
76  /** Parsing a '/''*' comment. */
78  /** Parsing a '#' comment. */
80 };
81 
83  void init();
84 
85  size_t m_line;
86  size_t m_column;
87 };
88 
90  // This buffer may be rather large,
91  // so we allocate it on the heap to save stack space.
92  // This struct is also used by the standalone 'comp_sql' tool,
93  // so we use plain malloc/free rather than my_() to avoid dependency on mysys.
96 
97  typedef void (*log_function_t)(const char *message);
98 
99  void init(const char *filename);
101 
104 
105  const char *m_filename;
109 
115 };
116 
117 int read_bootstrap_query(char *query, size_t *query_length, MYSQL_FILE *input,
118  fgets_fn_t fgets_fn, bootstrap_parser_state *state);
119 
120 #endif
std::unique_ptr< T, Free_deleter > unique_ptr_free
std::unique_ptr, but with free as deleter.
Definition: map_helpers.h:104
static char * query
Definition: myisam_ftdump.cc:44
Log error(cerr, "ERROR")
const char * filename
Definition: pfs_example_component_population.cc:64
code_parsing_state
Definition: sql_bootstrap.h:67
@ IN_SLASH_STAR_COMMENT
Parsing a '/''*' comment.
Definition: sql_bootstrap.h:77
@ IN_DOUBLE_QUOTE
Parsing a "literal" string.
Definition: sql_bootstrap.h:73
@ IN_SINGLE_QUOTE
Parsing a 'literal' string.
Definition: sql_bootstrap.h:71
@ NORMAL
Parsing sql code.
Definition: sql_bootstrap.h:69
@ IN_POUND_COMMENT
Parsing a '#' comment.
Definition: sql_bootstrap.h:79
@ IN_DASH_DASH_COMMENT
Parsing a "--" comment.
Definition: sql_bootstrap.h:75
delimiter_state
Definition: sql_bootstrap.h:60
@ DELIMITER_DOLLAR_DOLLAR
Delimiter is "$$".
Definition: sql_bootstrap.h:64
@ DELIMITER_SEMICOLON
Delimiter is ';'.
Definition: sql_bootstrap.h:62
char *(* fgets_fn_t)(char *, size_t, MYSQL_FILE *, int *error)
Definition: sql_bootstrap.h:58
int read_bootstrap_query(char *query, size_t *query_length, MYSQL_FILE *input, fgets_fn_t fgets_fn, bootstrap_parser_state *state)
Definition: sql_bootstrap.cc:108
bootstrap_error
Definition: sql_bootstrap.h:46
@ READ_BOOTSTRAP_EOF
Definition: sql_bootstrap.h:48
@ READ_BOOTSTRAP_DQ_NOT_TERMINATED
Definition: sql_bootstrap.h:52
@ READ_BOOTSTRAP_SUCCESS
Definition: sql_bootstrap.h:47
@ READ_BOOTSTRAP_COMMENT_NOT_TERMINATED
Definition: sql_bootstrap.h:53
@ READ_BOOTSTRAP_IO
Definition: sql_bootstrap.h:49
@ READ_BOOTSTRAP_SQ_NOT_TERMINATED
Definition: sql_bootstrap.h:51
@ READ_BOOTSTRAP_DELIMITER
Definition: sql_bootstrap.h:50
@ READ_BOOTSTRAP_QUERY_SIZE
Definition: sql_bootstrap.h:54
@ READ_BOOTSTRAP_ERROR
Definition: sql_bootstrap.h:55
An instrumented FILE structure.
Definition: mysql_file.h:482
Definition: sql_bootstrap.h:82
void init()
Definition: sql_bootstrap.cc:33
size_t m_line
Definition: sql_bootstrap.h:85
size_t m_column
Definition: sql_bootstrap.h:86
Definition: sql_bootstrap.h:89
enum bootstrap_error m_last_error
Definition: sql_bootstrap.h:107
void init(const char *filename)
Definition: sql_bootstrap.cc:38
size_t m_unget_buffer_length
Definition: sql_bootstrap.h:95
delimiter_state m_delimiter
Definition: sql_bootstrap.h:102
bootstrap_parser_position m_last_delimiter
Definition: sql_bootstrap.h:110
const char * m_filename
Definition: sql_bootstrap.h:105
bootstrap_parser_position m_last_query_start
Definition: sql_bootstrap.h:114
void(* log_function_t)(const char *message)
Definition: sql_bootstrap.h:97
bootstrap_parser_position m_last_open_comment
Definition: sql_bootstrap.h:113
unique_ptr_free< char > m_unget_buffer
Definition: sql_bootstrap.h:94
void report_error_details(log_function_t log)
Definition: sql_bootstrap.cc:54
bootstrap_parser_position m_last_open_double_quote
Definition: sql_bootstrap.h:112
int m_io_sub_error
Definition: sql_bootstrap.h:108
code_parsing_state m_code_state
Definition: sql_bootstrap.h:103
bootstrap_parser_position m_last_open_single_quote
Definition: sql_bootstrap.h:111
size_t m_current_line
Definition: sql_bootstrap.h:106