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