MySQL 8.0.30
Source Code Documentation
parse_file.h
Go to the documentation of this file.
1/* Copyright (c) 2004, 2022, 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 _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
32struct 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
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 virtual ~Unknown_key_hook() = default;
62 virtual bool process_unknown_string(const char *&unknown_key, uchar *base,
63 MEM_ROOT *mem_root, const char *end) = 0;
64};
65
66/**
67 Dummy hook for parsers which do not need hook for unknown keys.
68*/
70 public:
71 bool process_unknown_string(const char *&unknown_key, uchar *, MEM_ROOT *,
72 const char *) override;
73};
74
76
77bool get_file_options_ulllist(const char *&ptr, const char *end,
78 const char *line, uchar *base,
79 File_option *parameter, MEM_ROOT *mem_root);
80
81class File_parser;
82
84 bool bad_format_errors);
85
87 const char *start, *end;
90
91 public:
93 file_type.str = nullptr;
94 file_type.length = 0;
95 }
96
97 bool ok() { return content_ok; }
98 const LEX_CSTRING &type() const { return file_type; }
99 bool parse(uchar *base, MEM_ROOT *mem_root, struct File_option *parameters,
100 uint required, Unknown_key_hook *hook) const;
101
104 bool bad_format_errors);
105};
106#endif /* _PARSE_FILE_H_ */
Dummy hook for parsers which do not need hook for unknown keys.
Definition: parse_file.h:69
bool process_unknown_string(const char *&unknown_key, uchar *, MEM_ROOT *, const char *) override
Dummy unknown key hook.
Definition: parse_file.cc:520
Definition: parse_file.h:86
bool content_ok
Definition: parse_file.h:89
LEX_CSTRING file_type
Definition: parse_file.h:88
bool ok()
Definition: parse_file.h:97
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
const LEX_CSTRING & type() const
Definition: parse_file.h:98
File_parser()
Definition: parse_file.h:92
const char * end
Definition: parse_file.h:87
const char * start
Definition: parse_file.h:87
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
This hook used to catch no longer supported keys and process them for backward compatibility.
Definition: parse_file.h:59
virtual bool process_unknown_string(const char *&unknown_key, uchar *base, MEM_ROOT *mem_root, const char *end)=0
virtual ~Unknown_key_hook()=default
static MEM_ROOT mem_root
Definition: client_plugin.cc:109
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
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:93
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
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_opt_type
Definition: parse_file.h:36
@ FILE_OPTIONS_STRING
String (LEX_STRING)
Definition: parse_file.h:37
@ FILE_OPTIONS_ULONGLONG
ulonglong parameter (ulonglong)
Definition: parse_file.h:39
@ FILE_OPTIONS_ESTRING
Escaped string (LEX_STRING)
Definition: parse_file.h:38
@ FILE_OPTIONS_ULLLIST
list of ulonglong values (List<ulonglong>)
Definition: parse_file.h:44
@ FILE_OPTIONS_TIMESTAMP
timestamp (LEX_STRING have to be allocated with length 20 (19+1)
Definition: parse_file.h:40
@ FILE_OPTIONS_STRLIST
list of escaped strings (List<LEX_STRING>)
Definition: parse_file.h:42
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
File_parser_dummy_hook file_parser_dummy_hook
Definition: parse_file.cc:43
Definition: parse_file.h:48
file_opt_type type
Option type.
Definition: parse_file.h:51
size_t offset
offset to base address of value
Definition: parse_file.h:50
LEX_CSTRING name
Name of the option.
Definition: parse_file.h:49
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
Definition: mysql_lex_string.h:39
const char * str
Definition: mysql_lex_string.h:40
size_t length
Definition: mysql_lex_string.h:41
Definition: mysql_lex_string.h:34
unsigned int uint
Definition: uca-dump.cc:29