MySQL  8.0.19
Source Code Documentation
parse_file.h
Go to the documentation of this file.
1 /* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
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 _PARSE_FILE_H_
24 #define _PARSE_FILE_H_
25 
26 #include <stddef.h>
27 #include <sys/types.h>
28 
29 #include "lex_string.h"
30 #include "my_inttypes.h"
31 
32 struct MEM_ROOT;
33 
34 #define PARSE_FILE_TIMESTAMPLENGTH 19
35 
37  FILE_OPTIONS_STRING, /**< String (LEX_STRING) */
38  FILE_OPTIONS_ESTRING, /**< Escaped string (LEX_STRING) */
39  FILE_OPTIONS_ULONGLONG, /**< ulonglong parameter (ulonglong) */
40  FILE_OPTIONS_TIMESTAMP, /**< timestamp (LEX_STRING have to be
41  allocated with length 20 (19+1) */
42  FILE_OPTIONS_STRLIST, /**< list of escaped strings
43  (List<LEX_STRING>) */
44  FILE_OPTIONS_ULLLIST /**< list of ulonglong values
45  (List<ulonglong>) */
46 };
47 
48 struct File_option {
49  LEX_CSTRING name; /**< Name of the option */
50  size_t offset; /**< offset to base address of value */
51  file_opt_type type; /**< Option type */
52 };
53 
54 /**
55  This hook used to catch no longer supported keys and process them for
56  backward compatibility.
57 */
58 
60  public:
61  Unknown_key_hook() {} /* Remove gcc warning */
62  virtual ~Unknown_key_hook() {} /* Remove gcc warning */
63  virtual bool process_unknown_string(const char *&unknown_key, uchar *base,
64  MEM_ROOT *mem_root, const char *end) = 0;
65 };
66 
67 /**
68  Dummy hook for parsers which do not need hook for unknown keys.
69 */
71  public:
72  File_parser_dummy_hook() {} /* Remove gcc warning */
73  bool process_unknown_string(const char *&unknown_key, uchar *, MEM_ROOT *,
74  const char *) override;
75 };
76 
78 
79 bool get_file_options_ulllist(const char *&ptr, const char *end,
80  const char *line, uchar *base,
81  File_option *parameter, MEM_ROOT *mem_root);
82 
83 class File_parser;
84 
86  bool bad_format_errors);
87 
88 class File_parser {
89  const char *start, *end;
91  bool content_ok;
92 
93  public:
95  file_type.str = 0;
96  file_type.length = 0;
97  }
98 
99  bool ok() { return content_ok; }
100  const LEX_CSTRING &type() const { return file_type; }
101  bool parse(uchar *base, MEM_ROOT *mem_root, struct File_option *parameters,
102  uint required, Unknown_key_hook *hook) const;
103 
104  friend File_parser *sql_parse_prepare(const LEX_STRING *file_name,
106  bool bad_format_errors);
107 };
108 #endif /* _PARSE_FILE_H_ */
Unknown_key_hook::~Unknown_key_hook
virtual ~Unknown_key_hook()
Definition: parse_file.h:62
MYSQL_LEX_CSTRING
Definition: mysql_lex_string.h:39
File_parser::type
const LEX_CSTRING & type() const
Definition: parse_file.h:100
File_option::type
file_opt_type type
Option type.
Definition: parse_file.h:51
sql_parse_prepare
File_parser * sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, bool bad_format_errors)
Prepare frm to parse (read to memory).
Definition: parse_file.cc:61
File_parser::ok
bool ok()
Definition: parse_file.h:99
get_file_options_ulllist
bool get_file_options_ulllist(const char *&ptr, const char *end, const char *line, uchar *base, File_option *parameter, MEM_ROOT *mem_root)
Parser for FILE_OPTIONS_ULLLIST type value.
Definition: parse_file.cc:288
MYSQL_LEX_CSTRING::length
size_t length
Definition: mysql_lex_string.h:41
File_option::offset
size_t offset
offset to base address of value
Definition: parse_file.h:50
File_parser_dummy_hook::File_parser_dummy_hook
File_parser_dummy_hook()
Definition: parse_file.h:72
File_option
Definition: parse_file.h:48
mem_root
static MEM_ROOT mem_root
Definition: client_plugin.cc:109
File_parser_dummy_hook
Dummy hook for parsers which do not need hook for unknown keys.
Definition: parse_file.h:70
File_parser::sql_parse_prepare
friend File_parser * sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, bool bad_format_errors)
Prepare frm to parse (read to memory).
Definition: parse_file.cc:61
Unknown_key_hook::process_unknown_string
virtual bool process_unknown_string(const char *&unknown_key, uchar *base, MEM_ROOT *mem_root, const char *end)=0
Unknown_key_hook
This hook used to catch no longer supported keys and process them for backward compatibility.
Definition: parse_file.h:59
FILE_OPTIONS_ULONGLONG
@ FILE_OPTIONS_ULONGLONG
ulonglong parameter (ulonglong)
Definition: parse_file.h:39
File_parser
Definition: parse_file.h:88
File_option::name
LEX_CSTRING name
Name of the option.
Definition: parse_file.h:49
my_inttypes.h
MEM_ROOT
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
lex_string.h
FILE_OPTIONS_TIMESTAMP
@ FILE_OPTIONS_TIMESTAMP
timestamp (LEX_STRING have to be allocated with length 20 (19+1)
Definition: parse_file.h:40
uint
unsigned int uint
Definition: uca-dump.cc:29
Unknown_key_hook::Unknown_key_hook
Unknown_key_hook()
Definition: parse_file.h:61
uchar
unsigned char uchar
Definition: my_inttypes.h:51
rules_table_service::end
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
file_parser_dummy_hook
File_parser_dummy_hook file_parser_dummy_hook
Definition: parse_file.cc:43
CmdOptionValueReq::required
@ required
File_parser::start
const char * start
Definition: parse_file.h:89
MYSQL_LEX_STRING
Definition: mysql_lex_string.h:34
file_opt_type
file_opt_type
Definition: parse_file.h:36
FILE_OPTIONS_ULLLIST
@ FILE_OPTIONS_ULLLIST
list of ulonglong values (List<ulonglong>)
Definition: parse_file.h:44
FILE_OPTIONS_STRLIST
@ FILE_OPTIONS_STRLIST
list of escaped strings (List<LEX_STRING>)
Definition: parse_file.h:42
File_parser_dummy_hook::process_unknown_string
bool process_unknown_string(const char *&unknown_key, uchar *, MEM_ROOT *, const char *) override
Dummy unknown key hook.
Definition: parse_file.cc:520
File_parser::content_ok
bool content_ok
Definition: parse_file.h:91
File_parser::File_parser
File_parser()
Definition: parse_file.h:94
File_parser::end
const char * end
Definition: parse_file.h:89
MYSQL_LEX_CSTRING::str
const char * str
Definition: mysql_lex_string.h:40
File_parser::parse
bool parse(uchar *base, MEM_ROOT *mem_root, struct File_option *parameters, uint required, Unknown_key_hook *hook) const
parse parameters.
Definition: parse_file.cc:344
FILE_OPTIONS_ESTRING
@ FILE_OPTIONS_ESTRING
Escaped string (LEX_STRING)
Definition: parse_file.h:38
FILE_OPTIONS_STRING
@ FILE_OPTIONS_STRING
String (LEX_STRING)
Definition: parse_file.h:37
File_parser::file_type
LEX_CSTRING file_type
Definition: parse_file.h:90
false
#define false
Definition: config_static.h:43