1 | /* Copyright (C) 2010 Monty Program Ab |
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 as published by |
5 | the Free Software Foundation; version 2 of the License. |
6 | |
7 | This program is distributed in the hope that it will be useful, |
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | GNU General Public License for more details. |
11 | |
12 | You should have received a copy of the GNU General Public License |
13 | along with this program; if not, write to the Free Software |
14 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ |
15 | |
16 | /** |
17 | @file |
18 | |
19 | Engine defined options of tables/fields/keys in CREATE/ALTER TABLE. |
20 | */ |
21 | |
22 | #ifndef SQL_CREATE_OPTIONS_INCLUDED |
23 | #define SQL_CREATE_OPTIONS_INCLUDED |
24 | |
25 | #include "sql_class.h" |
26 | |
27 | enum { ENGINE_OPTION_MAX_LENGTH=32767 }; |
28 | |
29 | class engine_option_value: public Sql_alloc |
30 | { |
31 | public: |
32 | LEX_CSTRING name; |
33 | LEX_CSTRING value; |
34 | engine_option_value *next; ///< parser puts them in a FIFO linked list |
35 | bool parsed; ///< to detect unrecognized options |
36 | bool quoted_value; ///< option=VAL vs. option='VAL' |
37 | |
38 | engine_option_value(engine_option_value *src, |
39 | engine_option_value **start, engine_option_value **end) : |
40 | name(src->name), value(src->value), |
41 | next(NULL), parsed(src->parsed), quoted_value(src->quoted_value) |
42 | { |
43 | link(start, end); |
44 | } |
45 | engine_option_value(LEX_CSTRING &name_arg, LEX_CSTRING &value_arg, |
46 | bool quoted, |
47 | engine_option_value **start, engine_option_value **end) : |
48 | name(name_arg), value(value_arg), |
49 | next(NULL), parsed(false), quoted_value(quoted) |
50 | { |
51 | link(start, end); |
52 | } |
53 | engine_option_value(LEX_CSTRING &name_arg, |
54 | engine_option_value **start, engine_option_value **end) : |
55 | name(name_arg), value(null_clex_str), |
56 | next(NULL), parsed(false), quoted_value(false) |
57 | { |
58 | link(start, end); |
59 | } |
60 | engine_option_value(LEX_CSTRING &name_arg, ulonglong value_arg, |
61 | engine_option_value **start, engine_option_value **end, |
62 | MEM_ROOT *root) : |
63 | name(name_arg), next(NULL), parsed(false), quoted_value(false) |
64 | { |
65 | char *str; |
66 | if (likely((value.str= str= (char *)alloc_root(root, 22)))) |
67 | { |
68 | value.length= longlong10_to_str(value_arg, str, 10) - str; |
69 | link(start, end); |
70 | } |
71 | } |
72 | static uchar *frm_read(const uchar *buff, const uchar *buff_end, |
73 | engine_option_value **start, |
74 | engine_option_value **end, MEM_ROOT *root); |
75 | void link(engine_option_value **start, engine_option_value **end); |
76 | uint frm_length(); |
77 | uchar *frm_image(uchar *buff); |
78 | }; |
79 | |
80 | typedef struct st_key KEY; |
81 | class Create_field; |
82 | |
83 | bool resolve_sysvar_table_options(handlerton *hton); |
84 | void free_sysvar_table_options(handlerton *hton); |
85 | bool parse_engine_table_options(THD *thd, handlerton *ht, TABLE_SHARE *share); |
86 | bool parse_option_list(THD* thd, handlerton *hton, void *option_struct, |
87 | engine_option_value **option_list, |
88 | ha_create_table_option *rules, |
89 | bool suppress_warning, MEM_ROOT *root); |
90 | bool engine_table_options_frm_read(const uchar *buff, size_t length, |
91 | TABLE_SHARE *share); |
92 | engine_option_value *merge_engine_table_options(engine_option_value *source, |
93 | engine_option_value *changes, |
94 | MEM_ROOT *root); |
95 | |
96 | uint engine_table_options_frm_length(engine_option_value *table_option_list, |
97 | List<Create_field> &create_fields, |
98 | uint keys, KEY *key_info); |
99 | uchar *engine_table_options_frm_image(uchar *buff, |
100 | engine_option_value *table_option_list, |
101 | List<Create_field> &create_fields, |
102 | uint keys, KEY *key_info); |
103 | |
104 | bool engine_options_differ(void *old_struct, void *new_struct, |
105 | ha_create_table_option *rules); |
106 | bool is_engine_option_known(engine_option_value *opt, |
107 | ha_create_table_option *rules); |
108 | #endif |
109 | |