MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
parse_file.h
1 /* -*- C++ -*- */
2 /* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software Foundation,
15  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
16 
17 #ifndef _PARSE_FILE_H_
18 #define _PARSE_FILE_H_
19 
20 #include "my_global.h" // uchar
21 #include "sql_string.h" // LEX_STRING
22 #include "sql_alloc.h"
23 
24 class THD;
25 
26 typedef struct st_mem_root MEM_ROOT;
27 
28 #define PARSE_FILE_TIMESTAMPLENGTH 19
29 
30 enum file_opt_type {
31  FILE_OPTIONS_STRING,
32  FILE_OPTIONS_ESTRING,
33  FILE_OPTIONS_ULONGLONG,
34  FILE_OPTIONS_TIMESTAMP,
36  FILE_OPTIONS_STRLIST,
38  FILE_OPTIONS_ULLLIST
40 };
41 
43 {
45  int offset;
46  file_opt_type type;
47 };
48 
49 
56 {
57 public:
58  Unknown_key_hook() {} /* Remove gcc warning */
59  virtual ~Unknown_key_hook() {} /* Remove gcc warning */
60  virtual bool process_unknown_string(const char *&unknown_key, uchar* base,
61  MEM_ROOT *mem_root, const char *end)= 0;
62 };
63 
64 
68 {
69 public:
70  File_parser_dummy_hook() {} /* Remove gcc warning */
71  virtual bool process_unknown_string(const char *&unknown_key, uchar* base,
72  MEM_ROOT *mem_root, const char *end);
73 };
74 
75 extern File_parser_dummy_hook file_parser_dummy_hook;
76 
77 bool get_file_options_ulllist(const char *&ptr, const char *end,
78  const char *line, uchar* base,
79  File_option *parameter,
80  MEM_ROOT *mem_root);
81 
82 const char *
83 parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root,
84  LEX_STRING *str);
85 
86 class File_parser;
87 File_parser *sql_parse_prepare(const LEX_STRING *file_name,
88  MEM_ROOT *mem_root, bool bad_format_errors);
89 
90 my_bool
91 sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
92  const LEX_STRING *type,
93  uchar* base, File_option *parameters);
94 my_bool rename_in_schema_file(THD *thd,
95  const char *schema, const char *old_name,
96  const char *new_db, const char *new_name);
97 
98 class File_parser: public Sql_alloc
99 {
100  const char *start, *end;
101  LEX_STRING file_type;
102  my_bool content_ok;
103 public:
104  File_parser() :start(0), end(0), content_ok(0)
105  { file_type.str= 0; file_type.length= 0; }
106 
107  my_bool ok() { return content_ok; }
108  const LEX_STRING *type() const { return &file_type; }
109  my_bool parse(uchar* base, MEM_ROOT *mem_root,
110  struct File_option *parameters, uint required,
111  Unknown_key_hook *hook) const;
112 
113  friend File_parser *sql_parse_prepare(const LEX_STRING *file_name,
114  MEM_ROOT *mem_root,
115  bool bad_format_errors);
116 };
117 #endif /* _PARSE_FILE_H_ */