1
by brian
clean slate |
1 |
/* Copyright (C) 2002-2006 MySQL 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
/* Classes to support the SET command */
|
|
17 |
||
18 |
#ifdef USE_PRAGMA_INTERFACE
|
|
19 |
#pragma interface /* gcc class implementation */ |
|
20 |
#endif
|
|
21 |
||
22 |
/****************************************************************************
|
|
23 |
Variables that are changable runtime are declared using the
|
|
24 |
following classes
|
|
25 |
****************************************************************************/
|
|
26 |
||
27 |
class sys_var; |
|
28 |
class set_var; |
|
29 |
class sys_var_pluginvar; /* opaque */ |
|
30 |
typedef struct system_variables SV; |
|
31 |
typedef struct my_locale_st MY_LOCALE; |
|
32 |
||
33 |
extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib, |
|
34 |
optimizer_switch_typelib, slave_exec_mode_typelib; |
|
35 |
||
36 |
typedef int (*sys_check_func)(THD *, set_var *); |
|
37 |
typedef bool (*sys_update_func)(THD *, set_var *); |
|
38 |
typedef void (*sys_after_update_func)(THD *,enum_var_type); |
|
39 |
typedef void (*sys_set_default_func)(THD *, enum_var_type); |
|
40 |
typedef uchar *(*sys_value_ptr_func)(THD *thd); |
|
41 |
||
42 |
struct sys_var_chain |
|
43 |
{
|
|
44 |
sys_var *first; |
|
45 |
sys_var *last; |
|
46 |
};
|
|
47 |
||
48 |
class sys_var |
|
49 |
{
|
|
50 |
public: |
|
51 |
||
52 |
/**
|
|
53 |
Enumeration type to indicate for a system variable whether it will be written to the binlog or not.
|
|
54 |
*/
|
|
55 |
enum Binlog_status_enum |
|
56 |
{
|
|
57 |
/* The variable value is not in the binlog. */
|
|
58 |
NOT_IN_BINLOG, |
|
59 |
/* The value of the @@session variable is in the binlog. */
|
|
60 |
SESSION_VARIABLE_IN_BINLOG
|
|
61 |
/*
|
|
62 |
Currently, no @@global variable is ever in the binlog, so we
|
|
63 |
don't need an enumeration value for that.
|
|
64 |
*/
|
|
65 |
};
|
|
66 |
||
67 |
sys_var *next; |
|
68 |
struct my_option *option_limits; /* Updated by by set_var_init() */ |
|
69 |
uint name_length; /* Updated by by set_var_init() */ |
|
70 |
const char *name; |
|
71 |
||
72 |
sys_after_update_func after_update; |
|
73 |
bool no_support_one_shot; |
|
74 |
sys_var(const char *name_arg, sys_after_update_func func= NULL, |
|
75 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
76 |
:name(name_arg), after_update(func), no_support_one_shot(1), |
|
77 |
binlog_status(binlog_status_arg), |
|
78 |
m_allow_empty_value(TRUE) |
|
79 |
{}
|
|
80 |
virtual ~sys_var() {} |
|
81 |
void chain_sys_var(sys_var_chain *chain_arg) |
|
82 |
{
|
|
83 |
if (chain_arg->last) |
|
84 |
chain_arg->last->next= this; |
|
85 |
else
|
|
86 |
chain_arg->first= this; |
|
87 |
chain_arg->last= this; |
|
88 |
}
|
|
89 |
virtual bool check(THD *thd, set_var *var); |
|
90 |
bool check_enum(THD *thd, set_var *var, const TYPELIB *enum_names); |
|
91 |
bool check_set(THD *thd, set_var *var, TYPELIB *enum_names); |
|
92 |
bool is_written_to_binlog(enum_var_type type) |
|
93 |
{
|
|
94 |
return (type == OPT_SESSION || type == OPT_DEFAULT) && |
|
95 |
(binlog_status == SESSION_VARIABLE_IN_BINLOG); |
|
96 |
}
|
|
97 |
virtual bool update(THD *thd, set_var *var)=0; |
|
77.1.7
by Monty Taylor
Heap builds clean. |
98 |
virtual void set_default(THD *thd_arg __attribute__((__unused__)), |
99 |
enum_var_type type __attribute__((__unused__))) |
|
100 |
{}
|
|
1
by brian
clean slate |
101 |
virtual SHOW_TYPE show_type() { return SHOW_UNDEF; } |
77.1.7
by Monty Taylor
Heap builds clean. |
102 |
virtual uchar *value_ptr(THD *thd __attribute__((__unused__)), |
103 |
enum_var_type type __attribute__((__unused__)), |
|
104 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
105 |
{ return 0; } |
106 |
virtual bool check_type(enum_var_type type) |
|
107 |
{ return type != OPT_GLOBAL; } /* Error if not GLOBAL */ |
|
108 |
virtual bool check_update_type(Item_result type) |
|
109 |
{ return type != INT_RESULT; } /* Assume INT */ |
|
77.1.7
by Monty Taylor
Heap builds clean. |
110 |
virtual bool check_default(enum_var_type type __attribute__((__unused__))) |
1
by brian
clean slate |
111 |
{ return option_limits == 0; } |
112 |
Item *item(THD *thd, enum_var_type type, LEX_STRING *base); |
|
113 |
virtual bool is_struct() { return 0; } |
|
114 |
virtual bool is_readonly() const { return 0; } |
|
115 |
virtual sys_var_pluginvar *cast_pluginvar() { return 0; } |
|
116 |
||
117 |
protected: |
|
118 |
void set_allow_empty_value(bool allow_empty_value) |
|
119 |
{
|
|
120 |
m_allow_empty_value= allow_empty_value; |
|
121 |
}
|
|
122 |
||
123 |
private: |
|
124 |
const Binlog_status_enum binlog_status; |
|
125 |
||
126 |
bool m_allow_empty_value; |
|
127 |
};
|
|
128 |
||
129 |
||
130 |
/*
|
|
131 |
A base class for all variables that require its access to
|
|
132 |
be guarded with a mutex.
|
|
133 |
*/
|
|
134 |
||
135 |
class sys_var_global: public sys_var |
|
136 |
{
|
|
137 |
protected: |
|
138 |
pthread_mutex_t *guard; |
|
139 |
public: |
|
140 |
sys_var_global(const char *name_arg, sys_after_update_func after_update_arg, |
|
141 |
pthread_mutex_t *guard_arg) |
|
142 |
:sys_var(name_arg, after_update_arg), guard(guard_arg) {} |
|
143 |
};
|
|
144 |
||
145 |
||
146 |
/*
|
|
147 |
A global-only ulong variable that requires its access to be
|
|
148 |
protected with a mutex.
|
|
149 |
*/
|
|
150 |
||
151 |
class sys_var_long_ptr_global: public sys_var_global |
|
152 |
{
|
|
10
by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs |
153 |
ulong *value; |
1
by brian
clean slate |
154 |
public: |
155 |
sys_var_long_ptr_global(sys_var_chain *chain, const char *name_arg, |
|
156 |
ulong *value_ptr_arg, |
|
157 |
pthread_mutex_t *guard_arg, |
|
158 |
sys_after_update_func after_update_arg= NULL) |
|
159 |
:sys_var_global(name_arg, after_update_arg, guard_arg), |
|
160 |
value(value_ptr_arg) |
|
161 |
{ chain_sys_var(chain); } |
|
162 |
bool check(THD *thd, set_var *var); |
|
163 |
bool update(THD *thd, set_var *var); |
|
164 |
void set_default(THD *thd, enum_var_type type); |
|
165 |
SHOW_TYPE show_type() { return SHOW_LONG; } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
166 |
uchar *value_ptr(THD *thd __attribute__((__unused__)), |
167 |
enum_var_type type __attribute__((__unused__)), |
|
168 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
169 |
{ return (uchar*) value; } |
170 |
};
|
|
171 |
||
172 |
||
173 |
/*
|
|
174 |
A global ulong variable that is protected by LOCK_global_system_variables
|
|
175 |
*/
|
|
176 |
||
177 |
class sys_var_long_ptr :public sys_var_long_ptr_global |
|
178 |
{
|
|
179 |
public: |
|
180 |
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, ulong *value_ptr, |
|
181 |
sys_after_update_func after_update_arg= NULL); |
|
182 |
};
|
|
183 |
||
184 |
||
185 |
class sys_var_ulonglong_ptr :public sys_var |
|
186 |
{
|
|
187 |
ulonglong *value; |
|
10
by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs |
188 |
public: |
1
by brian
clean slate |
189 |
sys_var_ulonglong_ptr(sys_var_chain *chain, const char *name_arg, ulonglong *value_ptr_arg) |
190 |
:sys_var(name_arg),value(value_ptr_arg) |
|
191 |
{ chain_sys_var(chain); } |
|
192 |
sys_var_ulonglong_ptr(sys_var_chain *chain, const char *name_arg, ulonglong *value_ptr_arg, |
|
193 |
sys_after_update_func func) |
|
194 |
:sys_var(name_arg,func), value(value_ptr_arg) |
|
195 |
{ chain_sys_var(chain); } |
|
196 |
bool update(THD *thd, set_var *var); |
|
197 |
void set_default(THD *thd, enum_var_type type); |
|
198 |
SHOW_TYPE show_type() { return SHOW_LONGLONG; } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
199 |
uchar *value_ptr(THD *thd __attribute__((__unused__)), |
200 |
enum_var_type type __attribute__((__unused__)), |
|
201 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
202 |
{ return (uchar*) value; } |
203 |
};
|
|
204 |
||
205 |
||
206 |
class sys_var_bool_ptr :public sys_var |
|
207 |
{
|
|
208 |
public: |
|
209 |
my_bool *value; |
|
210 |
sys_var_bool_ptr(sys_var_chain *chain, const char *name_arg, my_bool *value_arg) |
|
211 |
:sys_var(name_arg),value(value_arg) |
|
212 |
{ chain_sys_var(chain); } |
|
213 |
bool check(THD *thd, set_var *var) |
|
214 |
{
|
|
215 |
return check_enum(thd, var, &bool_typelib); |
|
216 |
}
|
|
217 |
bool update(THD *thd, set_var *var); |
|
218 |
void set_default(THD *thd, enum_var_type type); |
|
219 |
SHOW_TYPE show_type() { return SHOW_MY_BOOL; } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
220 |
uchar *value_ptr(THD *thd __attribute__((__unused__)), |
221 |
enum_var_type type __attribute__((__unused__)), |
|
222 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
223 |
{ return (uchar*) value; } |
77.1.7
by Monty Taylor
Heap builds clean. |
224 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
225 |
{ return 0; } |
|
1
by brian
clean slate |
226 |
};
|
227 |
||
228 |
||
229 |
class sys_var_bool_ptr_readonly :public sys_var_bool_ptr |
|
230 |
{
|
|
231 |
public: |
|
232 |
sys_var_bool_ptr_readonly(sys_var_chain *chain, const char *name_arg, |
|
233 |
my_bool *value_arg) |
|
234 |
:sys_var_bool_ptr(chain, name_arg, value_arg) |
|
235 |
{}
|
|
236 |
bool is_readonly() const { return 1; } |
|
237 |
};
|
|
238 |
||
239 |
||
240 |
class sys_var_str :public sys_var |
|
241 |
{
|
|
242 |
public: |
|
243 |
char *value; // Pointer to allocated string |
|
244 |
uint value_length; |
|
245 |
sys_check_func check_func; |
|
246 |
sys_update_func update_func; |
|
247 |
sys_set_default_func set_default_func; |
|
248 |
sys_var_str(sys_var_chain *chain, const char *name_arg, |
|
249 |
sys_check_func check_func_arg, |
|
250 |
sys_update_func update_func_arg, |
|
251 |
sys_set_default_func set_default_func_arg, |
|
252 |
char *value_arg) |
|
253 |
:sys_var(name_arg), value(value_arg), check_func(check_func_arg), |
|
254 |
update_func(update_func_arg),set_default_func(set_default_func_arg) |
|
255 |
{ chain_sys_var(chain); } |
|
256 |
bool check(THD *thd, set_var *var); |
|
257 |
bool update(THD *thd, set_var *var) |
|
258 |
{
|
|
259 |
return (*update_func)(thd, var); |
|
260 |
}
|
|
261 |
void set_default(THD *thd, enum_var_type type) |
|
262 |
{
|
|
263 |
(*set_default_func)(thd, type); |
|
264 |
}
|
|
265 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
266 |
uchar *value_ptr(THD *thd __attribute__((__unused__)), |
267 |
enum_var_type type __attribute__((__unused__)), |
|
268 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
269 |
{ return (uchar*) value; } |
270 |
bool check_update_type(Item_result type) |
|
271 |
{
|
|
272 |
return type != STRING_RESULT; /* Only accept strings */ |
|
273 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
274 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
275 |
{ return 0; } |
|
1
by brian
clean slate |
276 |
};
|
277 |
||
278 |
||
279 |
class sys_var_const_str :public sys_var |
|
280 |
{
|
|
281 |
char *value; // Pointer to const value |
|
10
by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs |
282 |
public: |
1
by brian
clean slate |
283 |
sys_var_const_str(sys_var_chain *chain, const char *name_arg, |
284 |
const char *value_arg) |
|
285 |
:sys_var(name_arg), value((char*) value_arg) |
|
286 |
{ chain_sys_var(chain); } |
|
10
by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs |
287 |
inline void set (char *new_value) |
288 |
{
|
|
289 |
value= new_value; |
|
290 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
291 |
bool check(THD *thd __attribute__((__unused__)), |
292 |
set_var *var __attribute__((__unused__))) |
|
1
by brian
clean slate |
293 |
{
|
294 |
return 1; |
|
295 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
296 |
bool update(THD *thd __attribute__((__unused__)), |
297 |
set_var *var __attribute__((__unused__))) |
|
1
by brian
clean slate |
298 |
{
|
299 |
return 1; |
|
300 |
}
|
|
301 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
302 |
uchar *value_ptr(THD *thd __attribute__((__unused__)), |
303 |
enum_var_type type __attribute__((__unused__)), |
|
304 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
305 |
{
|
306 |
return (uchar*) value; |
|
307 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
308 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
1
by brian
clean slate |
309 |
{
|
310 |
return 1; |
|
311 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
312 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
313 |
{ return 1; } |
|
1
by brian
clean slate |
314 |
bool is_readonly() const { return 1; } |
315 |
};
|
|
316 |
||
317 |
||
318 |
class sys_var_const_str_ptr :public sys_var |
|
319 |
{
|
|
320 |
char **value; // Pointer to const value |
|
10
by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs |
321 |
public: |
1
by brian
clean slate |
322 |
sys_var_const_str_ptr(sys_var_chain *chain, const char *name_arg, char **value_arg) |
323 |
:sys_var(name_arg),value(value_arg) |
|
324 |
{ chain_sys_var(chain); } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
325 |
bool check(THD *thd __attribute__((__unused__)), |
326 |
set_var *var __attribute__((__unused__))) |
|
1
by brian
clean slate |
327 |
{
|
328 |
return 1; |
|
329 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
330 |
bool update(THD *thd __attribute__((__unused__)), |
331 |
set_var *var __attribute__((__unused__))) |
|
1
by brian
clean slate |
332 |
{
|
333 |
return 1; |
|
334 |
}
|
|
335 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
336 |
uchar *value_ptr(THD *thd __attribute__((__unused__)), |
337 |
enum_var_type type __attribute__((__unused__)), |
|
338 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
339 |
{
|
340 |
return (uchar*) *value; |
|
341 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
342 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
1
by brian
clean slate |
343 |
{
|
344 |
return 1; |
|
345 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
346 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
347 |
{ return 1; } |
|
348 |
bool is_readonly(void) const { return 1; } |
|
1
by brian
clean slate |
349 |
};
|
350 |
||
351 |
||
352 |
class sys_var_enum :public sys_var |
|
353 |
{
|
|
354 |
uint *value; |
|
355 |
TYPELIB *enum_names; |
|
356 |
public: |
|
357 |
sys_var_enum(sys_var_chain *chain, const char *name_arg, uint *value_arg, |
|
358 |
TYPELIB *typelib, sys_after_update_func func) |
|
359 |
:sys_var(name_arg,func), value(value_arg), enum_names(typelib) |
|
360 |
{ chain_sys_var(chain); } |
|
361 |
bool check(THD *thd, set_var *var) |
|
362 |
{
|
|
363 |
return check_enum(thd, var, enum_names); |
|
364 |
}
|
|
365 |
bool update(THD *thd, set_var *var); |
|
366 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
367 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
77.1.7
by Monty Taylor
Heap builds clean. |
368 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
369 |
{ return 0; } |
|
1
by brian
clean slate |
370 |
};
|
371 |
||
372 |
||
373 |
class sys_var_enum_const :public sys_var |
|
374 |
{
|
|
375 |
ulong SV::*offset; |
|
376 |
TYPELIB *enum_names; |
|
377 |
public: |
|
378 |
sys_var_enum_const(sys_var_chain *chain, const char *name_arg, ulong SV::*offset_arg, |
|
379 |
TYPELIB *typelib, sys_after_update_func func) |
|
380 |
:sys_var(name_arg,func), offset(offset_arg), enum_names(typelib) |
|
381 |
{ chain_sys_var(chain); } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
382 |
bool check(THD *thd __attribute__((__unused__)), |
383 |
set_var *var __attribute__((__unused__))) |
|
384 |
{ return 1; } |
|
385 |
bool update(THD *thd __attribute__((__unused__)), |
|
386 |
set_var *var __attribute__((__unused__))) |
|
387 |
{ return 1; } |
|
1
by brian
clean slate |
388 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
77.1.7
by Monty Taylor
Heap builds clean. |
389 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
390 |
{ return 1; } |
|
1
by brian
clean slate |
391 |
bool is_readonly() const { return 1; } |
392 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
393 |
};
|
|
394 |
||
395 |
||
396 |
class sys_var_thd :public sys_var |
|
397 |
{
|
|
398 |
public: |
|
399 |
sys_var_thd(const char *name_arg, |
|
400 |
sys_after_update_func func= NULL, |
|
401 |
Binlog_status_enum binlog_status= NOT_IN_BINLOG) |
|
402 |
:sys_var(name_arg, func, binlog_status) |
|
403 |
{}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
404 |
bool check_type(enum_var_type type __attribute__((__unused__))) |
405 |
{ return 0; } |
|
1
by brian
clean slate |
406 |
bool check_default(enum_var_type type) |
407 |
{
|
|
408 |
return type == OPT_GLOBAL && !option_limits; |
|
409 |
}
|
|
410 |
};
|
|
411 |
||
412 |
||
413 |
class sys_var_thd_ulong :public sys_var_thd |
|
414 |
{
|
|
415 |
sys_check_func check_func; |
|
416 |
public: |
|
417 |
ulong SV::*offset; |
|
418 |
sys_var_thd_ulong(sys_var_chain *chain, const char *name_arg, |
|
419 |
ulong SV::*offset_arg, |
|
420 |
sys_check_func c_func= NULL, |
|
421 |
sys_after_update_func au_func= NULL, |
|
422 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
423 |
:sys_var_thd(name_arg, au_func, binlog_status_arg), check_func(c_func), |
|
424 |
offset(offset_arg) |
|
425 |
{ chain_sys_var(chain); } |
|
426 |
bool check(THD *thd, set_var *var); |
|
427 |
bool update(THD *thd, set_var *var); |
|
428 |
void set_default(THD *thd, enum_var_type type); |
|
429 |
SHOW_TYPE show_type() { return SHOW_LONG; } |
|
430 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
431 |
};
|
|
432 |
||
433 |
||
434 |
class sys_var_thd_ha_rows :public sys_var_thd |
|
435 |
{
|
|
436 |
public: |
|
437 |
ha_rows SV::*offset; |
|
438 |
sys_var_thd_ha_rows(sys_var_chain *chain, const char *name_arg, |
|
439 |
ha_rows SV::*offset_arg) |
|
440 |
:sys_var_thd(name_arg), offset(offset_arg) |
|
441 |
{ chain_sys_var(chain); } |
|
442 |
sys_var_thd_ha_rows(sys_var_chain *chain, const char *name_arg, |
|
443 |
ha_rows SV::*offset_arg, |
|
444 |
sys_after_update_func func) |
|
445 |
:sys_var_thd(name_arg,func), offset(offset_arg) |
|
446 |
{ chain_sys_var(chain); } |
|
447 |
bool update(THD *thd, set_var *var); |
|
448 |
void set_default(THD *thd, enum_var_type type); |
|
449 |
SHOW_TYPE show_type() { return SHOW_HA_ROWS; } |
|
450 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
451 |
};
|
|
452 |
||
453 |
||
454 |
class sys_var_thd_ulonglong :public sys_var_thd |
|
455 |
{
|
|
456 |
public: |
|
457 |
ulonglong SV::*offset; |
|
458 |
bool only_global; |
|
459 |
sys_var_thd_ulonglong(sys_var_chain *chain, const char *name_arg, |
|
460 |
ulonglong SV::*offset_arg) |
|
461 |
:sys_var_thd(name_arg), offset(offset_arg) |
|
462 |
{ chain_sys_var(chain); } |
|
463 |
sys_var_thd_ulonglong(sys_var_chain *chain, const char *name_arg, |
|
464 |
ulonglong SV::*offset_arg, |
|
465 |
sys_after_update_func func, bool only_global_arg) |
|
466 |
:sys_var_thd(name_arg, func), offset(offset_arg), |
|
467 |
only_global(only_global_arg) |
|
468 |
{ chain_sys_var(chain); } |
|
469 |
bool update(THD *thd, set_var *var); |
|
470 |
void set_default(THD *thd, enum_var_type type); |
|
471 |
SHOW_TYPE show_type() { return SHOW_LONGLONG; } |
|
472 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
473 |
bool check(THD *thd, set_var *var); |
|
474 |
bool check_default(enum_var_type type) |
|
475 |
{
|
|
476 |
return type == OPT_GLOBAL && !option_limits; |
|
477 |
}
|
|
478 |
bool check_type(enum_var_type type) |
|
479 |
{
|
|
480 |
return (only_global && type != OPT_GLOBAL); |
|
481 |
}
|
|
482 |
};
|
|
483 |
||
484 |
||
485 |
class sys_var_thd_bool :public sys_var_thd |
|
486 |
{
|
|
487 |
public: |
|
488 |
my_bool SV::*offset; |
|
489 |
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg) |
|
490 |
:sys_var_thd(name_arg), offset(offset_arg) |
|
491 |
{ chain_sys_var(chain); } |
|
492 |
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg, |
|
493 |
sys_after_update_func func) |
|
494 |
:sys_var_thd(name_arg,func), offset(offset_arg) |
|
495 |
{ chain_sys_var(chain); } |
|
496 |
bool update(THD *thd, set_var *var); |
|
497 |
void set_default(THD *thd, enum_var_type type); |
|
498 |
SHOW_TYPE show_type() { return SHOW_MY_BOOL; } |
|
499 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
500 |
bool check(THD *thd, set_var *var) |
|
501 |
{
|
|
502 |
return check_enum(thd, var, &bool_typelib); |
|
503 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
504 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
505 |
{ return 0; } |
|
1
by brian
clean slate |
506 |
};
|
507 |
||
508 |
||
509 |
class sys_var_thd_enum :public sys_var_thd |
|
510 |
{
|
|
511 |
protected: |
|
512 |
ulong SV::*offset; |
|
513 |
TYPELIB *enum_names; |
|
514 |
sys_check_func check_func; |
|
515 |
public: |
|
516 |
sys_var_thd_enum(sys_var_chain *chain, const char *name_arg, |
|
517 |
ulong SV::*offset_arg, TYPELIB *typelib, |
|
518 |
sys_after_update_func func= NULL, |
|
519 |
sys_check_func check= NULL) |
|
520 |
:sys_var_thd(name_arg, func), offset(offset_arg), |
|
521 |
enum_names(typelib), check_func(check) |
|
522 |
{ chain_sys_var(chain); } |
|
523 |
bool check(THD *thd, set_var *var) |
|
524 |
{
|
|
525 |
int ret= 0; |
|
526 |
if (check_func) |
|
527 |
ret= (*check_func)(thd, var); |
|
528 |
return ret ? ret : check_enum(thd, var, enum_names); |
|
529 |
}
|
|
530 |
bool update(THD *thd, set_var *var); |
|
531 |
void set_default(THD *thd, enum_var_type type); |
|
532 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
533 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
77.1.7
by Monty Taylor
Heap builds clean. |
534 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
535 |
{ return 0; } |
|
1
by brian
clean slate |
536 |
};
|
537 |
||
538 |
||
539 |
||
540 |
class sys_var_thd_optimizer_switch :public sys_var_thd_enum |
|
541 |
{
|
|
542 |
public: |
|
543 |
sys_var_thd_optimizer_switch(sys_var_chain *chain, const char *name_arg, |
|
544 |
ulong SV::*offset_arg) |
|
545 |
:sys_var_thd_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib) |
|
546 |
{}
|
|
547 |
bool check(THD *thd, set_var *var) |
|
548 |
{
|
|
549 |
return check_set(thd, var, enum_names); |
|
550 |
}
|
|
551 |
void set_default(THD *thd, enum_var_type type); |
|
552 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
553 |
static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode, |
|
554 |
LEX_STRING *rep); |
|
555 |
};
|
|
556 |
||
557 |
||
558 |
class sys_var_thd_storage_engine :public sys_var_thd |
|
559 |
{
|
|
560 |
protected: |
|
561 |
plugin_ref SV::*offset; |
|
562 |
public: |
|
563 |
sys_var_thd_storage_engine(sys_var_chain *chain, const char *name_arg, |
|
564 |
plugin_ref SV::*offset_arg) |
|
565 |
:sys_var_thd(name_arg), offset(offset_arg) |
|
566 |
{ chain_sys_var(chain); } |
|
567 |
bool check(THD *thd, set_var *var); |
|
568 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
569 |
bool check_update_type(Item_result type) |
|
570 |
{
|
|
571 |
return type != STRING_RESULT; /* Only accept strings */ |
|
572 |
}
|
|
573 |
void set_default(THD *thd, enum_var_type type); |
|
574 |
bool update(THD *thd, set_var *var); |
|
575 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
576 |
};
|
|
577 |
||
578 |
class sys_var_thd_bit :public sys_var_thd |
|
579 |
{
|
|
580 |
sys_check_func check_func; |
|
581 |
sys_update_func update_func; |
|
582 |
public: |
|
583 |
ulonglong bit_flag; |
|
584 |
bool reverse; |
|
585 |
sys_var_thd_bit(sys_var_chain *chain, const char *name_arg, |
|
586 |
sys_check_func c_func, sys_update_func u_func, |
|
587 |
ulonglong bit, bool reverse_arg=0, |
|
588 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
589 |
:sys_var_thd(name_arg, NULL, binlog_status_arg), check_func(c_func), |
|
590 |
update_func(u_func), bit_flag(bit), reverse(reverse_arg) |
|
591 |
{ chain_sys_var(chain); } |
|
592 |
bool check(THD *thd, set_var *var); |
|
593 |
bool update(THD *thd, set_var *var); |
|
77.1.7
by Monty Taylor
Heap builds clean. |
594 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
595 |
{ return 0; } |
|
1
by brian
clean slate |
596 |
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } |
597 |
SHOW_TYPE show_type() { return SHOW_MY_BOOL; } |
|
598 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
599 |
};
|
|
600 |
||
601 |
class sys_var_thd_dbug :public sys_var_thd |
|
602 |
{
|
|
603 |
public: |
|
604 |
sys_var_thd_dbug(sys_var_chain *chain, const char *name_arg) |
|
605 |
:sys_var_thd(name_arg) |
|
606 |
{ chain_sys_var(chain); } |
|
607 |
bool check_update_type(Item_result type) { return type != STRING_RESULT; } |
|
608 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
609 |
bool update(THD *thd, set_var *var); |
|
77.1.7
by Monty Taylor
Heap builds clean. |
610 |
void set_default(THD *thd __attribute__((__unused__)), |
611 |
enum_var_type type __attribute__((__unused__))) |
|
612 |
{ DBUG_POP(); } |
|
1
by brian
clean slate |
613 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b); |
614 |
};
|
|
615 |
||
616 |
||
617 |
||
618 |
/* some variables that require special handling */
|
|
619 |
||
620 |
class sys_var_timestamp :public sys_var |
|
621 |
{
|
|
622 |
public: |
|
623 |
sys_var_timestamp(sys_var_chain *chain, const char *name_arg, |
|
624 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
625 |
:sys_var(name_arg, NULL, binlog_status_arg) |
|
626 |
{ chain_sys_var(chain); } |
|
627 |
bool update(THD *thd, set_var *var); |
|
628 |
void set_default(THD *thd, enum_var_type type); |
|
629 |
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
630 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
631 |
{ return 0; } |
|
632 |
SHOW_TYPE show_type(void) { return SHOW_LONG; } |
|
1
by brian
clean slate |
633 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
634 |
};
|
|
635 |
||
636 |
||
637 |
class sys_var_last_insert_id :public sys_var |
|
638 |
{
|
|
639 |
public: |
|
640 |
sys_var_last_insert_id(sys_var_chain *chain, const char *name_arg, |
|
641 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
642 |
:sys_var(name_arg, NULL, binlog_status_arg) |
|
643 |
{ chain_sys_var(chain); } |
|
644 |
bool update(THD *thd, set_var *var); |
|
645 |
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } |
|
646 |
SHOW_TYPE show_type() { return SHOW_LONGLONG; } |
|
647 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
648 |
};
|
|
649 |
||
650 |
||
651 |
class sys_var_insert_id :public sys_var |
|
652 |
{
|
|
653 |
public: |
|
654 |
sys_var_insert_id(sys_var_chain *chain, const char *name_arg) |
|
655 |
:sys_var(name_arg) |
|
656 |
{ chain_sys_var(chain); } |
|
657 |
bool update(THD *thd, set_var *var); |
|
658 |
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } |
|
659 |
SHOW_TYPE show_type() { return SHOW_LONGLONG; } |
|
660 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
661 |
};
|
|
662 |
||
663 |
||
664 |
class sys_var_rand_seed1 :public sys_var |
|
665 |
{
|
|
666 |
public: |
|
667 |
sys_var_rand_seed1(sys_var_chain *chain, const char *name_arg, |
|
668 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
669 |
:sys_var(name_arg, NULL, binlog_status_arg) |
|
670 |
{ chain_sys_var(chain); } |
|
671 |
bool update(THD *thd, set_var *var); |
|
672 |
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } |
|
673 |
};
|
|
674 |
||
675 |
class sys_var_rand_seed2 :public sys_var |
|
676 |
{
|
|
677 |
public: |
|
678 |
sys_var_rand_seed2(sys_var_chain *chain, const char *name_arg, |
|
679 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
680 |
:sys_var(name_arg, NULL, binlog_status_arg) |
|
681 |
{ chain_sys_var(chain); } |
|
682 |
bool update(THD *thd, set_var *var); |
|
683 |
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } |
|
684 |
};
|
|
685 |
||
686 |
||
687 |
class sys_var_collation :public sys_var_thd |
|
688 |
{
|
|
689 |
public: |
|
690 |
sys_var_collation(const char *name_arg, |
|
691 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
692 |
:sys_var_thd(name_arg, NULL, binlog_status_arg) |
|
693 |
{
|
|
694 |
no_support_one_shot= 0; |
|
695 |
}
|
|
696 |
bool check(THD *thd, set_var *var); |
|
697 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
698 |
bool check_update_type(Item_result type) |
|
699 |
{
|
|
700 |
return ((type != STRING_RESULT) && (type != INT_RESULT)); |
|
701 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
702 |
bool check_default(enum_var_type type __attribute__((__unused__))) { return 0; } |
1
by brian
clean slate |
703 |
virtual void set_default(THD *thd, enum_var_type type)= 0; |
704 |
};
|
|
705 |
||
706 |
class sys_var_character_set :public sys_var_thd |
|
707 |
{
|
|
708 |
public: |
|
709 |
bool nullable; |
|
710 |
sys_var_character_set(const char *name_arg, bool is_nullable= 0, |
|
711 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
712 |
:sys_var_thd(name_arg, NULL, binlog_status_arg), nullable(is_nullable) |
|
713 |
{
|
|
714 |
/*
|
|
715 |
In fact only almost all variables derived from sys_var_character_set
|
|
716 |
support ONE_SHOT; character_set_results doesn't. But that's good enough.
|
|
717 |
*/
|
|
718 |
no_support_one_shot= 0; |
|
719 |
}
|
|
720 |
bool check(THD *thd, set_var *var); |
|
721 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
722 |
bool check_update_type(Item_result type) |
|
723 |
{
|
|
724 |
return ((type != STRING_RESULT) && (type != INT_RESULT)); |
|
725 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
726 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
727 |
{ return 0; } |
|
1
by brian
clean slate |
728 |
bool update(THD *thd, set_var *var); |
729 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
730 |
virtual void set_default(THD *thd, enum_var_type type)= 0; |
|
731 |
virtual CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0; |
|
732 |
};
|
|
733 |
||
734 |
class sys_var_character_set_sv :public sys_var_character_set |
|
735 |
{
|
|
736 |
CHARSET_INFO *SV::*offset; |
|
737 |
CHARSET_INFO **global_default; |
|
738 |
public: |
|
739 |
sys_var_character_set_sv(sys_var_chain *chain, const char *name_arg, |
|
740 |
CHARSET_INFO *SV::*offset_arg, |
|
741 |
CHARSET_INFO **global_default_arg, |
|
742 |
bool is_nullable= 0, |
|
743 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
744 |
: sys_var_character_set(name_arg, is_nullable, binlog_status_arg), |
|
745 |
offset(offset_arg), global_default(global_default_arg) |
|
746 |
{ chain_sys_var(chain); } |
|
747 |
void set_default(THD *thd, enum_var_type type); |
|
748 |
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type); |
|
749 |
};
|
|
750 |
||
751 |
||
752 |
class sys_var_character_set_client: public sys_var_character_set_sv |
|
753 |
{
|
|
754 |
public: |
|
755 |
sys_var_character_set_client(sys_var_chain *chain, const char *name_arg, |
|
756 |
CHARSET_INFO *SV::*offset_arg, |
|
757 |
CHARSET_INFO **global_default_arg, |
|
758 |
Binlog_status_enum binlog_status_arg) |
|
759 |
: sys_var_character_set_sv(chain, name_arg, offset_arg, global_default_arg, |
|
760 |
0, binlog_status_arg) |
|
761 |
{ } |
|
762 |
bool check(THD *thd, set_var *var); |
|
763 |
};
|
|
764 |
||
765 |
||
766 |
class sys_var_character_set_database :public sys_var_character_set |
|
767 |
{
|
|
768 |
public: |
|
769 |
sys_var_character_set_database(sys_var_chain *chain, const char *name_arg, |
|
770 |
Binlog_status_enum binlog_status_arg= |
|
771 |
NOT_IN_BINLOG) |
|
772 |
: sys_var_character_set(name_arg, 0, binlog_status_arg) |
|
773 |
{ chain_sys_var(chain); } |
|
774 |
void set_default(THD *thd, enum_var_type type); |
|
775 |
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type); |
|
776 |
};
|
|
777 |
||
778 |
class sys_var_collation_sv :public sys_var_collation |
|
779 |
{
|
|
780 |
CHARSET_INFO *SV::*offset; |
|
781 |
CHARSET_INFO **global_default; |
|
782 |
public: |
|
783 |
sys_var_collation_sv(sys_var_chain *chain, const char *name_arg, |
|
784 |
CHARSET_INFO *SV::*offset_arg, |
|
785 |
CHARSET_INFO **global_default_arg, |
|
786 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
787 |
:sys_var_collation(name_arg, binlog_status_arg), |
|
788 |
offset(offset_arg), global_default(global_default_arg) |
|
789 |
{
|
|
790 |
chain_sys_var(chain); |
|
791 |
}
|
|
792 |
bool update(THD *thd, set_var *var); |
|
793 |
void set_default(THD *thd, enum_var_type type); |
|
794 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
795 |
};
|
|
796 |
||
797 |
||
798 |
class sys_var_key_cache_param :public sys_var |
|
799 |
{
|
|
800 |
protected: |
|
801 |
size_t offset; |
|
802 |
public: |
|
803 |
sys_var_key_cache_param(sys_var_chain *chain, const char *name_arg, |
|
804 |
size_t offset_arg) |
|
805 |
:sys_var(name_arg), offset(offset_arg) |
|
806 |
{ chain_sys_var(chain); } |
|
807 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
77.1.7
by Monty Taylor
Heap builds clean. |
808 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
809 |
{ return 1; } |
|
1
by brian
clean slate |
810 |
bool is_struct() { return 1; } |
811 |
};
|
|
812 |
||
813 |
||
814 |
class sys_var_key_buffer_size :public sys_var_key_cache_param |
|
815 |
{
|
|
816 |
public: |
|
817 |
sys_var_key_buffer_size(sys_var_chain *chain, const char *name_arg) |
|
818 |
:sys_var_key_cache_param(chain, name_arg, |
|
819 |
offsetof(KEY_CACHE, param_buff_size)) |
|
820 |
{}
|
|
821 |
bool update(THD *thd, set_var *var); |
|
822 |
SHOW_TYPE show_type() { return SHOW_LONGLONG; } |
|
823 |
};
|
|
824 |
||
825 |
||
826 |
class sys_var_key_cache_long :public sys_var_key_cache_param |
|
827 |
{
|
|
828 |
public: |
|
829 |
sys_var_key_cache_long(sys_var_chain *chain, const char *name_arg, size_t offset_arg) |
|
830 |
:sys_var_key_cache_param(chain, name_arg, offset_arg) |
|
831 |
{}
|
|
832 |
bool update(THD *thd, set_var *var); |
|
833 |
SHOW_TYPE show_type() { return SHOW_LONG; } |
|
834 |
};
|
|
835 |
||
836 |
||
837 |
class sys_var_thd_date_time_format :public sys_var_thd |
|
838 |
{
|
|
839 |
DATE_TIME_FORMAT *SV::*offset; |
|
840 |
timestamp_type date_time_type; |
|
841 |
public: |
|
842 |
sys_var_thd_date_time_format(sys_var_chain *chain, const char *name_arg, |
|
843 |
DATE_TIME_FORMAT *SV::*offset_arg, |
|
844 |
timestamp_type date_time_type_arg) |
|
845 |
:sys_var_thd(name_arg), offset(offset_arg), |
|
846 |
date_time_type(date_time_type_arg) |
|
847 |
{ chain_sys_var(chain); } |
|
848 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
849 |
bool check_update_type(Item_result type) |
|
850 |
{
|
|
851 |
return type != STRING_RESULT; /* Only accept strings */ |
|
852 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
853 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
854 |
{ return 0; } |
|
1
by brian
clean slate |
855 |
bool check(THD *thd, set_var *var); |
856 |
bool update(THD *thd, set_var *var); |
|
857 |
void update2(THD *thd, enum_var_type type, DATE_TIME_FORMAT *new_value); |
|
858 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
859 |
void set_default(THD *thd, enum_var_type type); |
|
860 |
};
|
|
861 |
||
862 |
||
863 |
class sys_var_log_state :public sys_var_bool_ptr |
|
864 |
{
|
|
865 |
uint log_type; |
|
866 |
public: |
|
867 |
sys_var_log_state(sys_var_chain *chain, const char *name_arg, my_bool *value_arg, |
|
868 |
uint log_type_arg) |
|
869 |
:sys_var_bool_ptr(chain, name_arg, value_arg), log_type(log_type_arg) {} |
|
870 |
bool update(THD *thd, set_var *var); |
|
871 |
void set_default(THD *thd, enum_var_type type); |
|
872 |
};
|
|
873 |
||
874 |
||
875 |
class sys_var_set :public sys_var |
|
876 |
{
|
|
877 |
protected: |
|
878 |
ulong *value; |
|
879 |
TYPELIB *enum_names; |
|
880 |
public: |
|
881 |
sys_var_set(sys_var_chain *chain, const char *name_arg, ulong *value_arg, |
|
882 |
TYPELIB *typelib, sys_after_update_func func) |
|
883 |
:sys_var(name_arg, func), value(value_arg), enum_names(typelib) |
|
884 |
{ chain_sys_var(chain); } |
|
885 |
virtual bool check(THD *thd, set_var *var) |
|
886 |
{
|
|
887 |
return check_set(thd, var, enum_names); |
|
888 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
889 |
virtual void set_default(THD *thd __attribute__((__unused__)), |
890 |
enum_var_type type __attribute__((__unused__))) |
|
891 |
{
|
|
1
by brian
clean slate |
892 |
*value= 0; |
893 |
}
|
|
894 |
bool update(THD *thd, set_var *var); |
|
895 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
77.1.7
by Monty Taylor
Heap builds clean. |
896 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
897 |
{ return 0; } |
|
1
by brian
clean slate |
898 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
899 |
};
|
|
900 |
||
901 |
class sys_var_set_slave_mode :public sys_var_set |
|
902 |
{
|
|
903 |
public: |
|
904 |
sys_var_set_slave_mode(sys_var_chain *chain, const char *name_arg, |
|
905 |
ulong *value_arg, |
|
906 |
TYPELIB *typelib, sys_after_update_func func) : |
|
907 |
sys_var_set(chain, name_arg, value_arg, typelib, func) {} |
|
908 |
void set_default(THD *thd, enum_var_type type); |
|
909 |
bool check(THD *thd, set_var *var); |
|
910 |
bool update(THD *thd, set_var *var); |
|
911 |
};
|
|
912 |
||
913 |
class sys_var_log_output :public sys_var |
|
914 |
{
|
|
915 |
ulong *value; |
|
916 |
TYPELIB *enum_names; |
|
917 |
public: |
|
918 |
sys_var_log_output(sys_var_chain *chain, const char *name_arg, ulong *value_arg, |
|
919 |
TYPELIB *typelib, sys_after_update_func func) |
|
920 |
:sys_var(name_arg,func), value(value_arg), enum_names(typelib) |
|
921 |
{
|
|
922 |
chain_sys_var(chain); |
|
923 |
set_allow_empty_value(FALSE); |
|
924 |
}
|
|
925 |
virtual bool check(THD *thd, set_var *var) |
|
926 |
{
|
|
927 |
return check_set(thd, var, enum_names); |
|
928 |
}
|
|
929 |
bool update(THD *thd, set_var *var); |
|
930 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
77.1.7
by Monty Taylor
Heap builds clean. |
931 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
932 |
{ return 0; } |
|
1
by brian
clean slate |
933 |
void set_default(THD *thd, enum_var_type type); |
934 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
935 |
};
|
|
936 |
||
937 |
||
938 |
/* Variable that you can only read from */
|
|
939 |
||
940 |
class sys_var_readonly: public sys_var |
|
941 |
{
|
|
942 |
public: |
|
943 |
enum_var_type var_type; |
|
944 |
SHOW_TYPE show_type_value; |
|
945 |
sys_value_ptr_func value_ptr_func; |
|
946 |
sys_var_readonly(sys_var_chain *chain, const char *name_arg, enum_var_type type, |
|
947 |
SHOW_TYPE show_type_arg, |
|
948 |
sys_value_ptr_func value_ptr_func_arg) |
|
949 |
:sys_var(name_arg), var_type(type), |
|
950 |
show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg) |
|
951 |
{ chain_sys_var(chain); } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
952 |
bool update(THD *thd __attribute__((__unused__)), |
953 |
set_var *var __attribute__((__unused__))) |
|
954 |
{ return 1; } |
|
955 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
|
956 |
{ return 1; } |
|
1
by brian
clean slate |
957 |
bool check_type(enum_var_type type) { return type != var_type; } |
77.1.7
by Monty Taylor
Heap builds clean. |
958 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
959 |
{ return 1; } |
|
960 |
uchar *value_ptr(THD *thd, enum_var_type type __attribute__((__unused__)), |
|
961 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
962 |
{
|
963 |
return (*value_ptr_func)(thd); |
|
964 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
965 |
SHOW_TYPE show_type(void) { return show_type_value; } |
966 |
bool is_readonly(void) const { return 1; } |
|
1
by brian
clean slate |
967 |
};
|
968 |
||
969 |
||
970 |
class sys_var_have_option: public sys_var |
|
971 |
{
|
|
972 |
protected: |
|
973 |
virtual SHOW_COMP_OPTION get_option() = 0; |
|
974 |
public: |
|
975 |
sys_var_have_option(sys_var_chain *chain, const char *variable_name): |
|
976 |
sys_var(variable_name) |
|
977 |
{ chain_sys_var(chain); } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
978 |
uchar *value_ptr(THD *thd __attribute__((__unused__)), |
979 |
enum_var_type type __attribute__((__unused__)), |
|
980 |
LEX_STRING *base __attribute__((__unused__))) |
|
1
by brian
clean slate |
981 |
{
|
982 |
return (uchar*) show_comp_option_name[get_option()]; |
|
983 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
984 |
bool update(THD *thd __attribute__((__unused__)), |
985 |
set_var *var __attribute__((__unused__))) { return 1; } |
|
986 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
|
987 |
{ return 1; } |
|
1
by brian
clean slate |
988 |
bool check_type(enum_var_type type) { return type != OPT_GLOBAL; } |
77.1.7
by Monty Taylor
Heap builds clean. |
989 |
bool check_update_type(Item_result type __attribute__((__unused__))) |
990 |
{ return 1; } |
|
1
by brian
clean slate |
991 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
992 |
bool is_readonly() const { return 1; } |
|
993 |
};
|
|
994 |
||
995 |
||
996 |
class sys_var_have_variable: public sys_var_have_option |
|
997 |
{
|
|
998 |
SHOW_COMP_OPTION *have_variable; |
|
999 |
||
1000 |
public: |
|
1001 |
sys_var_have_variable(sys_var_chain *chain, const char *variable_name, |
|
1002 |
SHOW_COMP_OPTION *have_variable_arg): |
|
1003 |
sys_var_have_option(chain, variable_name), |
|
1004 |
have_variable(have_variable_arg) |
|
1005 |
{ } |
|
1006 |
SHOW_COMP_OPTION get_option() { return *have_variable; } |
|
1007 |
};
|
|
1008 |
||
1009 |
||
1010 |
class sys_var_have_plugin: public sys_var_have_option |
|
1011 |
{
|
|
1012 |
const char *plugin_name_str; |
|
1013 |
const uint plugin_name_len; |
|
1014 |
const int plugin_type; |
|
1015 |
||
1016 |
public: |
|
1017 |
sys_var_have_plugin(sys_var_chain *chain, const char *variable_name, |
|
1018 |
const char *plugin_name_str_arg, uint plugin_name_len_arg, |
|
1019 |
int plugin_type_arg): |
|
1020 |
sys_var_have_option(chain, variable_name), |
|
1021 |
plugin_name_str(plugin_name_str_arg), plugin_name_len(plugin_name_len_arg), |
|
1022 |
plugin_type(plugin_type_arg) |
|
1023 |
{ } |
|
1024 |
/* the following method is declared in sql_plugin.cc */
|
|
1025 |
SHOW_COMP_OPTION get_option(); |
|
1026 |
};
|
|
1027 |
||
1028 |
||
1029 |
class sys_var_thd_time_zone :public sys_var_thd |
|
1030 |
{
|
|
1031 |
public: |
|
1032 |
sys_var_thd_time_zone(sys_var_chain *chain, const char *name_arg, |
|
1033 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
1034 |
:sys_var_thd(name_arg, NULL, binlog_status_arg) |
|
1035 |
{
|
|
1036 |
no_support_one_shot= 0; |
|
1037 |
chain_sys_var(chain); |
|
1038 |
}
|
|
1039 |
bool check(THD *thd, set_var *var); |
|
1040 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
1041 |
bool check_update_type(Item_result type) |
|
1042 |
{
|
|
1043 |
return type != STRING_RESULT; /* Only accept strings */ |
|
1044 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
1045 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
1046 |
{ return 0; } |
|
1
by brian
clean slate |
1047 |
bool update(THD *thd, set_var *var); |
1048 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
1049 |
virtual void set_default(THD *thd, enum_var_type type); |
|
1050 |
};
|
|
1051 |
||
1052 |
||
1053 |
class sys_var_max_user_conn : public sys_var_thd |
|
1054 |
{
|
|
1055 |
public: |
|
1056 |
sys_var_max_user_conn(sys_var_chain *chain, const char *name_arg): |
|
1057 |
sys_var_thd(name_arg) |
|
1058 |
{ chain_sys_var(chain); } |
|
1059 |
bool check(THD *thd, set_var *var); |
|
1060 |
bool update(THD *thd, set_var *var); |
|
1061 |
bool check_default(enum_var_type type) |
|
1062 |
{
|
|
1063 |
return type != OPT_GLOBAL || !option_limits; |
|
1064 |
}
|
|
1065 |
void set_default(THD *thd, enum_var_type type); |
|
1066 |
SHOW_TYPE show_type() { return SHOW_INT; } |
|
1067 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
1068 |
};
|
|
1069 |
||
1070 |
||
1071 |
class sys_var_microseconds :public sys_var_thd |
|
1072 |
{
|
|
1073 |
ulonglong SV::*offset; |
|
1074 |
public: |
|
1075 |
sys_var_microseconds(sys_var_chain *chain, const char *name_arg, |
|
1076 |
ulonglong SV::*offset_arg): |
|
1077 |
sys_var_thd(name_arg), offset(offset_arg) |
|
1078 |
{ chain_sys_var(chain); } |
|
77.1.7
by Monty Taylor
Heap builds clean. |
1079 |
bool check(THD *thd __attribute__((__unused__)), |
1080 |
set_var *var __attribute__((__unused__))) {return 0;} |
|
1
by brian
clean slate |
1081 |
bool update(THD *thd, set_var *var); |
1082 |
void set_default(THD *thd, enum_var_type type); |
|
1083 |
SHOW_TYPE show_type() { return SHOW_DOUBLE; } |
|
1084 |
bool check_update_type(Item_result type) |
|
1085 |
{
|
|
1086 |
return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT); |
|
1087 |
}
|
|
1088 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
1089 |
};
|
|
1090 |
||
1091 |
||
1092 |
class sys_var_trust_routine_creators :public sys_var_bool_ptr |
|
1093 |
{
|
|
1094 |
/* We need a derived class only to have a warn_deprecated() */
|
|
1095 |
public: |
|
1096 |
sys_var_trust_routine_creators(sys_var_chain *chain, |
|
1097 |
const char *name_arg, my_bool *value_arg) : |
|
1098 |
sys_var_bool_ptr(chain, name_arg, value_arg) {}; |
|
1099 |
void warn_deprecated(THD *thd); |
|
1100 |
void set_default(THD *thd, enum_var_type type); |
|
1101 |
bool update(THD *thd, set_var *var); |
|
1102 |
};
|
|
1103 |
||
1104 |
/**
|
|
1105 |
Handler for setting the system variable --read-only.
|
|
1106 |
*/
|
|
1107 |
||
1108 |
class sys_var_opt_readonly :public sys_var_bool_ptr |
|
1109 |
{
|
|
1110 |
public: |
|
1111 |
sys_var_opt_readonly(sys_var_chain *chain, const char *name_arg, |
|
1112 |
my_bool *value_arg) : |
|
1113 |
sys_var_bool_ptr(chain, name_arg, value_arg) {}; |
|
1114 |
~sys_var_opt_readonly() {}; |
|
1115 |
bool update(THD *thd, set_var *var); |
|
1116 |
};
|
|
1117 |
||
1118 |
||
1119 |
class sys_var_thd_lc_time_names :public sys_var_thd |
|
1120 |
{
|
|
1121 |
public: |
|
1122 |
sys_var_thd_lc_time_names(sys_var_chain *chain, const char *name_arg, |
|
1123 |
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG) |
|
1124 |
: sys_var_thd(name_arg, NULL, binlog_status_arg) |
|
1125 |
{
|
|
1126 |
#if MYSQL_VERSION_ID < 50000
|
|
1127 |
no_support_one_shot= 0; |
|
1128 |
#endif
|
|
1129 |
chain_sys_var(chain); |
|
1130 |
}
|
|
1131 |
bool check(THD *thd, set_var *var); |
|
1132 |
SHOW_TYPE show_type() { return SHOW_CHAR; } |
|
1133 |
bool check_update_type(Item_result type) |
|
1134 |
{
|
|
1135 |
return ((type != STRING_RESULT) && (type != INT_RESULT)); |
|
1136 |
}
|
|
77.1.7
by Monty Taylor
Heap builds clean. |
1137 |
bool check_default(enum_var_type type __attribute__((__unused__))) |
1138 |
{ return 0; } |
|
1
by brian
clean slate |
1139 |
bool update(THD *thd, set_var *var); |
1140 |
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); |
|
1141 |
virtual void set_default(THD *thd, enum_var_type type); |
|
1142 |
};
|
|
1143 |
||
1144 |
||
1145 |
extern void fix_binlog_format_after_update(THD *thd, enum_var_type type); |
|
1146 |
||
1147 |
class sys_var_thd_binlog_format :public sys_var_thd_enum |
|
1148 |
{
|
|
1149 |
public: |
|
1150 |
sys_var_thd_binlog_format(sys_var_chain *chain, const char *name_arg, |
|
1151 |
ulong SV::*offset_arg) |
|
1152 |
:sys_var_thd_enum(chain, name_arg, offset_arg, |
|
1153 |
&binlog_format_typelib, |
|
1154 |
fix_binlog_format_after_update) |
|
1155 |
{};
|
|
1156 |
bool is_readonly() const; |
|
1157 |
};
|
|
1158 |
||
1159 |
/****************************************************************************
|
|
1160 |
Classes for parsing of the SET command
|
|
1161 |
****************************************************************************/
|
|
1162 |
||
1163 |
class set_var_base :public Sql_alloc |
|
1164 |
{
|
|
1165 |
public: |
|
1166 |
set_var_base() {} |
|
1167 |
virtual ~set_var_base() {} |
|
1168 |
virtual int check(THD *thd)=0; /* To check privileges etc. */ |
|
1169 |
virtual int update(THD *thd)=0; /* To set the value */ |
|
1170 |
/* light check for PS */
|
|
1171 |
virtual bool no_support_one_shot() { return 1; } |
|
1172 |
};
|
|
1173 |
||
1174 |
||
1175 |
/* MySQL internal variables, like query_cache_size */
|
|
1176 |
||
1177 |
class set_var :public set_var_base |
|
1178 |
{
|
|
1179 |
public: |
|
1180 |
sys_var *var; |
|
1181 |
Item *value; |
|
1182 |
enum_var_type type; |
|
1183 |
union
|
|
1184 |
{
|
|
1185 |
CHARSET_INFO *charset; |
|
1186 |
ulong ulong_value; |
|
1187 |
ulonglong ulonglong_value; |
|
1188 |
plugin_ref plugin; |
|
1189 |
DATE_TIME_FORMAT *date_time_format; |
|
1190 |
Time_zone *time_zone; |
|
1191 |
MY_LOCALE *locale_value; |
|
1192 |
} save_result; |
|
1193 |
LEX_STRING base; /* for structs */ |
|
1194 |
||
1195 |
set_var(enum_var_type type_arg, sys_var *var_arg, |
|
1196 |
const LEX_STRING *base_name_arg, Item *value_arg) |
|
1197 |
:var(var_arg), type(type_arg), base(*base_name_arg) |
|
1198 |
{
|
|
1199 |
/*
|
|
1200 |
If the set value is a field, change it to a string to allow things like
|
|
1201 |
SET table_type=MYISAM;
|
|
1202 |
*/
|
|
1203 |
if (value_arg && value_arg->type() == Item::FIELD_ITEM) |
|
1204 |
{
|
|
1205 |
Item_field *item= (Item_field*) value_arg; |
|
1206 |
if (!(value=new Item_string(item->field_name, |
|
1207 |
(uint) strlen(item->field_name), |
|
1208 |
item->collation.collation))) |
|
1209 |
value=value_arg; /* Give error message later */ |
|
1210 |
}
|
|
1211 |
else
|
|
1212 |
value=value_arg; |
|
1213 |
}
|
|
1214 |
int check(THD *thd); |
|
1215 |
int update(THD *thd); |
|
1216 |
bool no_support_one_shot() { return var->no_support_one_shot; } |
|
1217 |
};
|
|
1218 |
||
1219 |
||
1220 |
/* User variables like @my_own_variable */
|
|
1221 |
||
1222 |
class set_var_user: public set_var_base |
|
1223 |
{
|
|
1224 |
Item_func_set_user_var *user_var_item; |
|
1225 |
public: |
|
1226 |
set_var_user(Item_func_set_user_var *item) |
|
1227 |
:user_var_item(item) |
|
1228 |
{}
|
|
1229 |
int check(THD *thd); |
|
1230 |
int update(THD *thd); |
|
1231 |
};
|
|
1232 |
||
1233 |
/* For SET NAMES and SET CHARACTER SET */
|
|
1234 |
||
1235 |
class set_var_collation_client: public set_var_base |
|
1236 |
{
|
|
1237 |
CHARSET_INFO *character_set_client; |
|
1238 |
CHARSET_INFO *character_set_results; |
|
1239 |
CHARSET_INFO *collation_connection; |
|
1240 |
public: |
|
1241 |
set_var_collation_client(CHARSET_INFO *client_coll_arg, |
|
1242 |
CHARSET_INFO *connection_coll_arg, |
|
1243 |
CHARSET_INFO *result_coll_arg) |
|
1244 |
:character_set_client(client_coll_arg), |
|
1245 |
character_set_results(result_coll_arg), |
|
1246 |
collation_connection(connection_coll_arg) |
|
1247 |
{}
|
|
1248 |
int check(THD *thd); |
|
1249 |
int update(THD *thd); |
|
1250 |
};
|
|
1251 |
||
1252 |
||
1253 |
extern "C" |
|
1254 |
{
|
|
1255 |
typedef int (*process_key_cache_t) (const char *, KEY_CACHE *); |
|
1256 |
}
|
|
1257 |
||
1258 |
/* Named lists (used for keycaches) */
|
|
1259 |
||
1260 |
class NAMED_LIST :public ilink |
|
1261 |
{
|
|
1262 |
const char *name; |
|
1263 |
uint name_length; |
|
1264 |
public: |
|
1265 |
uchar* data; |
|
1266 |
||
1267 |
NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg, |
|
1268 |
uint name_length_arg, uchar* data_arg) |
|
1269 |
:name_length(name_length_arg), data(data_arg) |
|
1270 |
{
|
|
1271 |
name= my_strndup(name_arg, name_length, MYF(MY_WME)); |
|
1272 |
links->push_back(this); |
|
1273 |
}
|
|
1274 |
inline bool cmp(const char *name_cmp, uint length) |
|
1275 |
{
|
|
1276 |
return length == name_length && !memcmp(name, name_cmp, length); |
|
1277 |
}
|
|
1278 |
~NAMED_LIST() |
|
1279 |
{
|
|
1280 |
my_free((uchar*) name, MYF(0)); |
|
1281 |
}
|
|
1282 |
friend bool process_key_caches(process_key_cache_t func); |
|
1283 |
friend void delete_elements(I_List<NAMED_LIST> *list, |
|
1284 |
void (*free_element)(const char*, uchar*)); |
|
1285 |
};
|
|
1286 |
||
1287 |
/* updated in sql_acl.cc */
|
|
1288 |
||
1289 |
extern sys_var_thd_bool sys_old_alter_table; |
|
1290 |
extern sys_var_thd_bool sys_old_passwords; |
|
1291 |
extern LEX_STRING default_key_cache_base; |
|
1292 |
||
1293 |
/* For sql_yacc */
|
|
1294 |
struct sys_var_with_base |
|
1295 |
{
|
|
1296 |
sys_var *var; |
|
1297 |
LEX_STRING base_name; |
|
1298 |
};
|
|
1299 |
||
1300 |
/*
|
|
1301 |
Prototypes for helper functions
|
|
1302 |
*/
|
|
1303 |
||
1304 |
int set_var_init(); |
|
1305 |
void set_var_free(); |
|
1306 |
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count); |
|
1307 |
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted); |
|
1308 |
int mysql_add_sys_var_chain(sys_var *chain, struct my_option *long_options); |
|
1309 |
int mysql_del_sys_var_chain(sys_var *chain); |
|
1310 |
sys_var *find_sys_var(THD *thd, const char *str, uint length=0); |
|
1311 |
int sql_set_variables(THD *thd, List<set_var_base> *var_list); |
|
1312 |
bool not_all_support_one_shot(List<set_var_base> *var_list); |
|
1313 |
void fix_delay_key_write(THD *thd, enum_var_type type); |
|
1314 |
void fix_slave_exec_mode(enum_var_type type); |
|
1315 |
ulong fix_sql_mode(ulong sql_mode); |
|
1316 |
extern sys_var_const_str sys_charset_system; |
|
1317 |
extern sys_var_str sys_init_connect; |
|
1318 |
extern sys_var_str sys_init_slave; |
|
1319 |
extern sys_var_thd_time_zone sys_time_zone; |
|
1320 |
extern sys_var_thd_bit sys_autocommit; |
|
1321 |
CHARSET_INFO *get_old_charset_by_name(const char *old_name); |
|
1322 |
uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length, |
|
1323 |
NAMED_LIST **found); |
|
1324 |
||
1325 |
extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path; |
|
1326 |
||
1327 |
/* key_cache functions */
|
|
1328 |
KEY_CACHE *get_key_cache(LEX_STRING *cache_name); |
|
1329 |
KEY_CACHE *get_or_create_key_cache(const char *name, uint length); |
|
1330 |
void free_key_cache(const char *name, KEY_CACHE *key_cache); |
|
1331 |
bool process_key_caches(process_key_cache_t func); |
|
1332 |
void delete_elements(I_List<NAMED_LIST> *list, |
|
1333 |
void (*free_element)(const char*, uchar*)); |