17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_ITEM_SET_H
21
#define DRIZZLED_ITEM_SET_H
23
#include <drizzled/functions/func.h>
24
#include <drizzled/functions/set_user_var.h>
26
/* Classes to support the SET command */
29
/****************************************************************************
30
Variables that are changable runtime are declared using the
32
****************************************************************************/
20
#ifndef DRIZZLED_SYS_VAR_H
21
#define DRIZZLED_SYS_VAR_H
24
#include <boost/filesystem.hpp>
26
#include <drizzled/constrained_value.h>
27
#include <drizzled/set_var.h>
28
#include <drizzled/show_type.h>
29
#include <drizzled/item_result.h>
30
#include <drizzled/base.h>
31
#include <drizzled/global_charset_info.h>
32
#include <drizzled/lex_string.h>
34
#include <drizzled/visibility.h>
36
class sys_var_pluginvar; /* opaque */
38
typedef struct system_variables SV;
39
41
typedef struct my_locale_st MY_LOCALE;
41
extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib,
42
optimizer_switch_typelib, slave_exec_mode_typelib;
42
typedef struct st_typelib TYPELIB;
44
44
typedef int (*sys_check_func)(Session *, set_var *);
45
45
typedef bool (*sys_update_func)(Session *, set_var *);
46
typedef void (*sys_after_update_func)(Session *,enum_var_type);
47
typedef void (*sys_set_default_func)(Session *, enum_var_type);
46
typedef void (*sys_after_update_func)(Session *, sql_var_t);
47
typedef void (*sys_set_default_func)(Session *, sql_var_t);
48
48
typedef unsigned char *(*sys_value_ptr_func)(Session *session);
50
static const std::vector<std::string> empty_aliases;
51
extern struct drizzle_system_variables max_system_variables;
52
extern size_t table_def_size;
54
extern std::string drizzle_tmpdir;
55
extern const char *first_keyword;
56
extern const char *in_left_expr_name;
57
extern const char *in_additional_cond;
58
extern const char *in_having_cond;
59
extern boost::filesystem::path basedir;
60
extern boost::filesystem::path pid_file;
61
extern boost::filesystem::path secure_file_priv;
62
extern char *opt_tc_log_file;
63
extern uint64_t session_startup_options;
64
extern uint32_t global_thread_id;
65
extern uint64_t table_cache_size;
66
extern back_log_constraints back_log;
67
extern uint32_t ha_open_options;
68
extern char *drizzled_bind_host;
69
extern uint32_t dropping_tables;
70
extern bool opt_endinfo;
71
extern uint32_t volatile thread_running;
72
extern uint32_t volatile global_read_lock;
73
extern bool opt_readonly;
74
extern const char *opt_scheduler;
75
extern size_t transaction_message_threshold;
77
uint64_t fix_unsigned(Session *, uint64_t, const struct option *);
79
const std::string &getServerHostname();
83
* A class which represents a variable, either global or
86
class DRIZZLED_API sys_var
89
std::string name; /**< The name of the variable */
90
sys_check_func check_func;
91
sys_after_update_func after_update; /**< Function pointer triggered after the variable's value is updated */
92
struct option *option_limits; /**< Updated by by sys_var_init() */
93
bool m_allow_empty_value; /**< Does variable allow an empty value? */
61
Enumeration type to indicate for a system variable whether it will be written to the binlog or not.
63
enum Binlog_status_enum
65
/* The variable value is not in the binlog. */
67
/* The value of the @@session variable is in the binlog. */
68
SESSION_VARIABLE_IN_BINLOG
70
Currently, no @@global variable is ever in the binlog, so we
71
don't need an enumeration value for that.
76
struct my_option *option_limits; /* Updated by by set_var_init() */
77
uint32_t name_length; /* Updated by by set_var_init() */
80
sys_after_update_func after_update;
81
bool no_support_one_shot;
82
sys_var(const char *name_arg, sys_after_update_func func= NULL,
83
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
84
:name(name_arg), after_update(func), no_support_one_shot(1),
85
binlog_status(binlog_status_arg),
95
sys_var(const std::string &name_arg,
96
sys_after_update_func func= NULL,
97
sys_check_func check_func_arg= NULL)
100
check_func(check_func_arg),
86
103
m_allow_empty_value(true)
88
105
virtual ~sys_var() {}
89
void chain_sys_var(sys_var_chain *chain_arg)
92
chain_arg->last->next= this;
94
chain_arg->first= this;
95
chain_arg->last= this;
107
void setName(const std::string &name_in)
113
* Returns the name of the variable.
117
* So that we can exist in a Registry. We really need to formalize that
119
inline const std::string &getName() const
124
* Returns a vector of strings representing aliases
125
* for this variable's name.
127
const std::vector<std::string>& getAliases() const
129
return empty_aliases;
132
* Returns a pointer to the variable's option limits
134
inline struct option *getOptionLimits() const
136
return option_limits;
139
* Sets the pointer to the variable's option limits
141
* @param Pointer to the option limits option variable
143
inline void setOptionLimits(struct option *in_option_limits)
145
option_limits= in_option_limits;
148
* Returns the function pointer for after update trigger, or NULL if none.
150
inline sys_after_update_func getAfterUpdateTrigger() const
97
154
virtual bool check(Session *session, set_var *var);
98
155
bool check_enum(Session *session, set_var *var, const TYPELIB *enum_names);
99
bool check_set(Session *session, set_var *var, TYPELIB *enum_names);
100
156
virtual bool update(Session *session, set_var *var)=0;
101
virtual void set_default(Session *, enum_var_type)
157
virtual void set_default(Session *, sql_var_t)
103
virtual SHOW_TYPE show_type() { return SHOW_UNDEF; }
104
virtual unsigned char *value_ptr(Session *, enum_var_type, LEX_STRING *)
106
virtual bool check_type(enum_var_type type)
107
{ return type != OPT_GLOBAL; } /* Error if not GLOBAL */
159
virtual SHOW_TYPE show_type()
163
virtual unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
167
virtual bool check_type(sql_var_t type)
169
return type != OPT_GLOBAL;
170
} /* Error if not GLOBAL */
108
171
virtual bool check_update_type(Item_result type)
109
{ return type != INT_RESULT; } /* Assume INT */
110
virtual bool check_default(enum_var_type)
111
{ return option_limits == 0; }
112
Item *item(Session *session, 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; }
118
void set_allow_empty_value(bool allow_empty_value)
120
m_allow_empty_value= allow_empty_value;
124
const Binlog_status_enum binlog_status;
126
bool m_allow_empty_value;
173
return type != INT_RESULT;
175
virtual bool check_default(sql_var_t)
177
return option_limits == 0;
179
Item *item(Session *session, sql_var_t type, const LEX_STRING *base);
180
virtual bool is_readonly() const
131
A base class for all variables that require its access to
132
be guarded with a mutex.
135
class sys_var_global: public sys_var
187
* A base class for all variables that require its access to
188
* be guarded with a mutex.
190
class DRIZZLED_API sys_var_global: public sys_var
138
193
pthread_mutex_t *guard;
140
sys_var_global(const char *name_arg, sys_after_update_func after_update_arg,
195
sys_var_global(const char *name_arg,
196
sys_after_update_func after_update_arg,
141
197
pthread_mutex_t *guard_arg)
142
:sys_var(name_arg, after_update_arg), guard(guard_arg) {}
147
A global-only uint64_t variable that requires its access to be
148
protected with a mutex.
151
class sys_var_long_ptr_global: public sys_var_global
155
sys_var_long_ptr_global(sys_var_chain *chain, const char *name_arg,
156
uint64_t *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),
161
{ chain_sys_var(chain); }
162
bool check(Session *session, set_var *var);
163
bool update(Session *session, set_var *var);
164
void set_default(Session *session, enum_var_type type);
165
SHOW_TYPE show_type() { return SHOW_LONG; }
166
unsigned char *value_ptr(Session *, enum_var_type, LEX_STRING *)
167
{ return (unsigned char*) value; }
172
A global uint64_t variable that is protected by LOCK_global_system_variables
175
class sys_var_long_ptr :public sys_var_long_ptr_global
178
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr,
179
sys_after_update_func after_update_arg= NULL);
183
class sys_var_uint32_t_ptr :public sys_var
199
sys_var(name_arg, after_update_arg),
204
class DRIZZLED_API sys_var_uint32_t_ptr :public sys_var
187
sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
208
sys_var_uint32_t_ptr(const char *name_arg,
188
209
uint32_t *value_ptr_arg)
189
210
:sys_var(name_arg),value(value_ptr_arg)
190
{ chain_sys_var(chain); }
191
sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
212
sys_var_uint32_t_ptr(const char *name_arg,
192
213
uint32_t *value_ptr_arg,
193
214
sys_after_update_func func)
194
215
:sys_var(name_arg,func), value(value_ptr_arg)
195
{ chain_sys_var(chain); }
217
bool check(Session *session, set_var *var);
196
218
bool update(Session *session, set_var *var);
197
void set_default(Session *session, enum_var_type type);
198
SHOW_TYPE show_type() { return SHOW_LONG; }
199
unsigned char *value_ptr(Session *, enum_var_type, LEX_STRING *)
219
void set_default(Session *session, sql_var_t type);
220
SHOW_TYPE show_type() { return SHOW_INT; }
221
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
200
222
{ return (unsigned char*) value; }
204
class sys_var_uint64_t_ptr :public sys_var
225
class DRIZZLED_API sys_var_uint32_t_ptr_readonly :
226
public sys_var_uint32_t_ptr
229
sys_var_uint32_t_ptr_readonly(const char *name_arg,
230
uint32_t *value_ptr_arg) :
231
sys_var_uint32_t_ptr(name_arg, value_ptr_arg)
234
sys_var_uint32_t_ptr_readonly(const char *name_arg,
235
uint32_t *value_ptr_arg,
236
sys_after_update_func func) :
237
sys_var_uint32_t_ptr(name_arg, value_ptr_arg, func)
240
bool is_readonly() const
247
class DRIZZLED_API sys_var_uint64_t_ptr :public sys_var
250
const uint64_t default_value;
251
bool have_default_value;
208
sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg)
209
:sys_var(name_arg),value(value_ptr_arg)
210
{ chain_sys_var(chain); }
211
sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg,
212
sys_after_update_func func)
213
:sys_var(name_arg,func), value(value_ptr_arg)
214
{ chain_sys_var(chain); }
253
sys_var_uint64_t_ptr(const char *name_arg, uint64_t *value_ptr_arg) :
255
value(value_ptr_arg),
257
have_default_value(false)
260
sys_var_uint64_t_ptr(const char *name_arg,
261
uint64_t *value_ptr_arg,
262
const uint64_t default_value_in) :
264
value(value_ptr_arg),
265
default_value(default_value_in),
266
have_default_value(true)
269
sys_var_uint64_t_ptr(const char *name_arg,
270
uint64_t *value_ptr_arg,
271
sys_after_update_func func) :
272
sys_var(name_arg,func),
273
value(value_ptr_arg),
275
have_default_value(false)
278
sys_var_uint64_t_ptr(const char *name_arg,
279
uint64_t *value_ptr_arg,
280
sys_after_update_func func,
281
const uint64_t default_value_in) :
282
sys_var(name_arg,func),
283
value(value_ptr_arg),
284
default_value(default_value_in),
285
have_default_value(true)
215
288
bool update(Session *session, set_var *var);
216
void set_default(Session *session, enum_var_type type);
289
void set_default(Session *session, sql_var_t type);
290
virtual bool check_default(sql_var_t)
292
return (not have_default_value) && option_limits == 0;
217
294
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
218
unsigned char *value_ptr(Session *, enum_var_type, LEX_STRING *)
295
unsigned char *value_ptr(Session *, sql_var_t,
219
297
{ return (unsigned char*) value; }
222
class sys_var_size_t_ptr :public sys_var
300
class DRIZZLED_API sys_var_size_t_ptr :public sys_var
226
sys_var_size_t_ptr(sys_var_chain *chain, const char *name_arg, size_t *value_ptr_arg)
304
sys_var_size_t_ptr(const char *name_arg, size_t *value_ptr_arg)
227
305
:sys_var(name_arg),value(value_ptr_arg)
228
{ chain_sys_var(chain); }
229
sys_var_size_t_ptr(sys_var_chain *chain, const char *name_arg, size_t *value_ptr_arg,
307
sys_var_size_t_ptr(const char *name_arg, size_t *value_ptr_arg,
230
308
sys_after_update_func func)
231
309
:sys_var(name_arg,func), value(value_ptr_arg)
232
{ chain_sys_var(chain); }
233
311
bool update(Session *session, set_var *var);
234
void set_default(Session *session, enum_var_type type);
312
void set_default(Session *session, sql_var_t type);
235
313
SHOW_TYPE show_type() { return SHOW_SIZE; }
236
unsigned char *value_ptr(Session *, enum_var_type, LEX_STRING *)
314
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
237
315
{ return (unsigned char*) value; }
240
class sys_var_bool_ptr :public sys_var
318
class DRIZZLED_API sys_var_size_t_ptr_readonly :public sys_var_size_t_ptr
321
sys_var_size_t_ptr_readonly(const char *name_arg,
323
:sys_var_size_t_ptr(name_arg, value_arg)
325
bool is_readonly() const { return 1; }
328
class DRIZZLED_API sys_var_bool_ptr :public sys_var
244
sys_var_bool_ptr(sys_var_chain *chain, const char *name_arg, bool *value_arg)
245
:sys_var(name_arg),value(value_arg)
246
{ chain_sys_var(chain); }
247
bool check(Session *session, set_var *var)
333
sys_var_bool_ptr(const std::string &name_arg, bool *value_arg,
334
sys_after_update_func func= NULL) :
335
sys_var(name_arg, func), default_value(*value_arg), value(value_arg)
337
bool check(Session *session, set_var *var);
338
virtual bool check_default(sql_var_t)
249
return check_enum(session, var, &bool_typelib);
251
342
bool update(Session *session, set_var *var);
252
void set_default(Session *session, enum_var_type type);
343
void set_default(Session *session, sql_var_t type);
253
344
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
254
unsigned char *value_ptr(Session *, enum_var_type, LEX_STRING *)
345
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
255
346
{ return (unsigned char*) value; }
256
347
bool check_update_type(Item_result)
260
class sys_var_bool_ptr_readonly :public sys_var_bool_ptr
351
class DRIZZLED_API sys_var_bool_ptr_readonly :public sys_var_bool_ptr
263
sys_var_bool_ptr_readonly(sys_var_chain *chain, const char *name_arg,
354
sys_var_bool_ptr_readonly(const char *name_arg,
265
:sys_var_bool_ptr(chain, name_arg, value_arg)
356
:sys_var_bool_ptr(name_arg, value_arg)
267
358
bool is_readonly() const { return 1; }
271
class sys_var_str :public sys_var
362
class DRIZZLED_API sys_var_str :public sys_var
274
365
char *value; // Pointer to allocated string
275
366
uint32_t value_length;
276
sys_check_func check_func;
277
367
sys_update_func update_func;
278
368
sys_set_default_func set_default_func;
279
sys_var_str(sys_var_chain *chain, const char *name_arg,
280
sys_check_func check_func_arg,
281
sys_update_func update_func_arg,
282
sys_set_default_func set_default_func_arg,
284
:sys_var(name_arg), value(value_arg), check_func(check_func_arg),
285
update_func(update_func_arg),set_default_func(set_default_func_arg)
286
{ chain_sys_var(chain); }
369
sys_var_str(const char *name_arg,
370
sys_check_func check_func_arg,
371
sys_update_func update_func_arg,
372
sys_set_default_func set_default_func_arg,
374
sys_var(name_arg, NULL, check_func_arg),
376
update_func(update_func_arg),
377
set_default_func(set_default_func_arg)
287
379
bool check(Session *session, set_var *var);
288
380
bool update(Session *session, set_var *var)
290
382
return (*update_func)(session, var);
292
void set_default(Session *session, enum_var_type type)
384
void set_default(Session *session, sql_var_t type)
294
386
(*set_default_func)(session, type);
296
388
SHOW_TYPE show_type() { return SHOW_CHAR; }
297
unsigned char *value_ptr(Session *, enum_var_type, LEX_STRING *)
389
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
298
390
{ return (unsigned char*) value; }
299
391
bool check_update_type(Item_result type)
301
393
return type != STRING_RESULT; /* Only accept strings */
303
bool check_default(enum_var_type)
395
bool check_default(sql_var_t)
308
class sys_var_const_str :public sys_var
400
class DRIZZLED_API sys_var_fs_path :
403
const boost::filesystem::path &value;
405
sys_var_fs_path(const char *name_arg,
406
const boost::filesystem::path& value_arg) :
411
inline void set(char *)
414
bool check(Session *, set_var *)
418
bool update(Session *, set_var *)
422
SHOW_TYPE show_type() { return SHOW_CHAR; }
423
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
425
return (unsigned char*)(value.file_string().c_str());
427
bool check_update_type(Item_result)
431
bool check_default(sql_var_t) { return true; }
432
bool is_readonly() const { return true; }
436
class sys_var_constrained_value :
439
constrained_value<T> &value;
443
sys_var_constrained_value(const char *name_arg,
444
constrained_value<T> &value_arg) :
447
default_value(value_arg.get())
450
sys_var_constrained_value(const char *name_arg,
451
constrained_value<T> &value_arg,
452
sys_after_update_func after_update_func_arg) :
453
sys_var(name_arg, after_update_func_arg),
455
default_value(value_arg.get())
458
sys_var_constrained_value(const char *name_arg,
459
constrained_value<T> &value_arg,
460
sys_check_func check_func_arg) :
461
sys_var(name_arg, NULL, check_func_arg),
463
default_value(value_arg.get())
467
bool is_readonly() const
472
SHOW_TYPE show_type() { return SHOW_INT; }
474
bool update(Session *, set_var *var)
476
value= uint32_t(var->getInteger());
480
bool check_default(sql_var_t)
485
void set_default(Session *, sql_var_t)
487
value= default_value;
490
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
492
basic_value= value.get();
493
return (unsigned char*)&basic_value;
498
inline SHOW_TYPE sys_var_constrained_value<uint64_t>::show_type()
500
return SHOW_LONGLONG;
504
inline SHOW_TYPE sys_var_constrained_value<int64_t>::show_type()
506
return SHOW_LONGLONG;
510
inline SHOW_TYPE sys_var_constrained_value<uint32_t>::show_type()
516
inline SHOW_TYPE sys_var_constrained_value<int32_t>::show_type()
522
inline bool sys_var_constrained_value<uint64_t>::update(Session *, set_var *var)
524
value= var->getInteger();
529
inline bool sys_var_constrained_value<uint32_t>::update(Session *, set_var *var)
531
value= uint32_t(var->getInteger());
536
class sys_var_constrained_value_readonly :
537
public sys_var_constrained_value<T>
540
sys_var_constrained_value_readonly(const char *name_arg,
541
constrained_value<T> &value_arg) :
542
sys_var_constrained_value<T>(name_arg, value_arg)
545
sys_var_constrained_value_readonly(const char *name_arg,
546
constrained_value<T> &value_arg,
547
T default_value_arg) :
548
sys_var_constrained_value<T>(name_arg, value_arg, default_value_arg)
552
bool is_readonly() const
558
class DRIZZLED_API sys_var_std_string :
562
sys_check_func check_func;
563
sys_update_func update_func;
564
sys_set_default_func set_default_func;
566
sys_var_std_string(const std::string &name_arg,
567
std::string &value_arg,
568
sys_check_func check_func_arg= NULL,
569
sys_update_func update_func_arg= NULL) :
572
check_func(check_func_arg),
573
update_func(update_func_arg)
576
inline void set(char *val_in)
581
void set_check_func(sys_check_func check_func_arg= NULL)
583
check_func= check_func_arg;
586
void set_update_func(sys_update_func update_func_arg= NULL)
588
update_func= update_func_arg;
591
bool check(Session *session, set_var *var);
593
bool update(Session *session, set_var *var)
595
if (update_func != NULL)
597
return (*update_func)(session, var);
601
SHOW_TYPE show_type() { return SHOW_CHAR; }
602
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
604
return (unsigned char*)(value.c_str());
606
bool check_update_type(Item_result type)
608
return type != STRING_RESULT; /* Only accept strings */
610
bool check_default(sql_var_t)
612
bool is_readonly() const { return false; }
615
class DRIZZLED_API sys_var_const_string :
618
const std::string &value;
620
sys_var_const_string(const char *name_arg,
621
const std::string& value_arg) :
626
inline void set(char *)
629
bool check(Session *, set_var *)
633
bool update(Session *, set_var *)
637
SHOW_TYPE show_type() { return SHOW_CHAR; }
638
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
640
return (unsigned char*)(value.c_str());
642
bool check_update_type(Item_result)
646
bool check_default(sql_var_t) { return true; }
647
bool is_readonly() const { return true; }
650
class DRIZZLED_API sys_var_const_string_val :
653
const std::string value;
655
sys_var_const_string_val(const char *name_arg,
656
const std::string& value_arg) :
661
inline void set(char *)
664
bool check(Session *, set_var *)
668
bool update(Session *, set_var *)
672
SHOW_TYPE show_type() { return SHOW_CHAR; }
673
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
675
return (unsigned char*)(value.c_str());
677
bool check_update_type(Item_result)
681
bool check_default(sql_var_t) { return true; }
682
bool is_readonly() const { return true; }
685
class DRIZZLED_API sys_var_const_str :public sys_var
310
687
char *value; // Pointer to const value
312
sys_var_const_str(sys_var_chain *chain, const char *name_arg,
689
sys_var_const_str(const char *name_arg,
313
690
const char *value_arg)
314
691
:sys_var(name_arg), value((char*) value_arg)
315
{ chain_sys_var(chain); }
316
693
inline void set (char *new_value)
318
695
value= new_value;
367
bool check_default(enum_var_type)
744
bool check_default(sql_var_t)
369
746
bool is_readonly(void) const { return 1; }
373
class sys_var_enum :public sys_var
378
sys_var_enum(sys_var_chain *chain, const char *name_arg, uint32_t *value_arg,
379
TYPELIB *typelib, sys_after_update_func func)
380
:sys_var(name_arg,func), value(value_arg), enum_names(typelib)
381
{ chain_sys_var(chain); }
382
bool check(Session *session, set_var *var)
384
return check_enum(session, var, enum_names);
386
bool update(Session *session, set_var *var);
387
SHOW_TYPE show_type() { return SHOW_CHAR; }
388
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
389
bool check_update_type(Item_result)
394
class sys_var_enum_const :public sys_var
396
uint32_t SV::*offset;
399
sys_var_enum_const(sys_var_chain *chain, const char *name_arg, uint32_t SV::*offset_arg,
400
TYPELIB *typelib, sys_after_update_func func)
401
:sys_var(name_arg,func), offset(offset_arg), enum_names(typelib)
402
{ chain_sys_var(chain); }
403
bool check(Session *, set_var *)
405
bool update(Session *, set_var *)
407
SHOW_TYPE show_type() { return SHOW_CHAR; }
408
bool check_update_type(Item_result)
410
bool is_readonly() const { return 1; }
411
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
415
class sys_var_session :public sys_var
418
sys_var_session(const char *name_arg,
419
sys_after_update_func func= NULL,
420
Binlog_status_enum binlog_status= NOT_IN_BINLOG)
421
:sys_var(name_arg, func, binlog_status)
750
class DRIZZLED_API sys_var_session :public sys_var
753
sys_var_session(const char *name_arg,
754
sys_after_update_func func= NULL)
755
:sys_var(name_arg, func)
423
bool check_type(enum_var_type)
757
bool check_type(sql_var_t)
425
bool check_default(enum_var_type type)
759
bool check_default(sql_var_t type)
427
761
return type == OPT_GLOBAL && !option_limits;
431
class sys_var_session_uint32_t :public sys_var_session
765
class DRIZZLED_API sys_var_session_uint32_t :public sys_var_session
433
767
sys_check_func check_func;
435
uint32_t SV::*offset;
436
sys_var_session_uint32_t(sys_var_chain *chain, const char *name_arg,
437
uint32_t SV::*offset_arg,
769
uint32_t drizzle_system_variables::*offset;
770
sys_var_session_uint32_t(const char *name_arg,
771
uint32_t drizzle_system_variables::*offset_arg,
438
772
sys_check_func c_func= NULL,
439
sys_after_update_func au_func= NULL,
440
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
441
:sys_var_session(name_arg, au_func, binlog_status_arg), check_func(c_func),
773
sys_after_update_func au_func= NULL)
774
:sys_var_session(name_arg, au_func), check_func(c_func),
442
775
offset(offset_arg)
443
{ chain_sys_var(chain); }
444
777
bool check(Session *session, set_var *var);
445
778
bool update(Session *session, set_var *var);
446
void set_default(Session *session, enum_var_type type);
447
SHOW_TYPE show_type() { return SHOW_LONG; }
448
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
779
void set_default(Session *session, sql_var_t type);
780
SHOW_TYPE show_type() { return SHOW_INT; }
781
unsigned char *value_ptr(Session *session, sql_var_t type,
782
const LEX_STRING *base);
452
class sys_var_session_ha_rows :public sys_var_session
786
class DRIZZLED_API sys_var_session_ha_rows :public sys_var_session
456
sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
457
ha_rows SV::*offset_arg)
789
ha_rows drizzle_system_variables::*offset;
790
sys_var_session_ha_rows(const char *name_arg,
791
ha_rows drizzle_system_variables::*offset_arg)
458
792
:sys_var_session(name_arg), offset(offset_arg)
459
{ chain_sys_var(chain); }
460
sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
461
ha_rows SV::*offset_arg,
794
sys_var_session_ha_rows(const char *name_arg,
795
ha_rows drizzle_system_variables::*offset_arg,
462
796
sys_after_update_func func)
463
797
:sys_var_session(name_arg,func), offset(offset_arg)
464
{ chain_sys_var(chain); }
465
799
bool update(Session *session, set_var *var);
466
void set_default(Session *session, enum_var_type type);
800
void set_default(Session *session, sql_var_t type);
467
801
SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
468
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
802
unsigned char *value_ptr(Session *session, sql_var_t type,
803
const LEX_STRING *base);
472
class sys_var_session_uint64_t :public sys_var_session
807
class DRIZZLED_API sys_var_session_uint64_t :public sys_var_session
474
809
sys_check_func check_func;
476
uint64_t SV::*offset;
811
uint64_t drizzle_system_variables::*offset;
477
812
bool only_global;
478
sys_var_session_uint64_t(sys_var_chain *chain, const char *name_arg,
479
uint64_t SV::*offset_arg,
813
sys_var_session_uint64_t(
814
const char *name_arg,
815
uint64_t drizzle_system_variables::*offset_arg,
480
816
sys_after_update_func au_func= NULL,
481
sys_check_func c_func= NULL,
482
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
483
:sys_var_session(name_arg, au_func, binlog_status_arg),
817
sys_check_func c_func= NULL)
818
:sys_var_session(name_arg, au_func),
484
819
check_func(c_func),
485
820
offset(offset_arg)
486
{ chain_sys_var(chain); }
487
sys_var_session_uint64_t(sys_var_chain *chain,
488
const char *name_arg,
489
uint64_t SV::*offset_arg,
490
sys_after_update_func func,
822
sys_var_session_uint64_t(const char *name_arg,
823
uint64_t drizzle_system_variables::*offset_arg,
824
sys_after_update_func func,
491
825
bool only_global_arg,
492
826
sys_check_func cfunc= NULL)
493
827
:sys_var_session(name_arg, func),
494
828
check_func(cfunc),
495
829
offset(offset_arg),
496
830
only_global(only_global_arg)
497
{ chain_sys_var(chain); }
498
832
bool update(Session *session, set_var *var);
499
void set_default(Session *session, enum_var_type type);
833
void set_default(Session *session, sql_var_t type);
500
834
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
501
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
835
unsigned char *value_ptr(Session *session, sql_var_t type,
836
const LEX_STRING *base);
502
837
bool check(Session *session, set_var *var);
503
bool check_default(enum_var_type type)
838
bool check_default(sql_var_t type)
505
840
return type == OPT_GLOBAL && !option_limits;
507
bool check_type(enum_var_type type)
842
bool check_type(sql_var_t type)
509
844
return (only_global && type != OPT_GLOBAL);
513
class sys_var_session_size_t :public sys_var_session
848
class DRIZZLED_API sys_var_session_size_t :public sys_var_session
515
850
sys_check_func check_func;
852
size_t drizzle_system_variables::*offset;
518
853
bool only_global;
519
sys_var_session_size_t(sys_var_chain *chain, const char *name_arg,
520
size_t SV::*offset_arg,
854
sys_var_session_size_t(const char *name_arg,
855
size_t drizzle_system_variables::*offset_arg,
521
856
sys_after_update_func au_func= NULL,
522
sys_check_func c_func= NULL,
523
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
524
:sys_var_session(name_arg, au_func, binlog_status_arg),
857
sys_check_func c_func= NULL)
858
:sys_var_session(name_arg, au_func),
525
859
check_func(c_func),
526
860
offset(offset_arg)
527
{ chain_sys_var(chain); }
528
sys_var_session_size_t(sys_var_chain *chain,
529
const char *name_arg,
530
size_t SV::*offset_arg,
531
sys_after_update_func func,
862
sys_var_session_size_t(const char *name_arg,
863
size_t drizzle_system_variables::*offset_arg,
864
sys_after_update_func func,
532
865
bool only_global_arg,
533
866
sys_check_func cfunc= NULL)
534
867
:sys_var_session(name_arg, func),
535
868
check_func(cfunc),
536
869
offset(offset_arg),
537
870
only_global(only_global_arg)
538
{ chain_sys_var(chain); }
539
872
bool update(Session *session, set_var *var);
540
void set_default(Session *session, enum_var_type type);
873
void set_default(Session *session, sql_var_t type);
541
874
SHOW_TYPE show_type() { return SHOW_SIZE; }
542
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
875
unsigned char *value_ptr(Session *session, sql_var_t type,
876
const LEX_STRING *base);
543
877
bool check(Session *session, set_var *var);
544
bool check_default(enum_var_type type)
878
bool check_default(sql_var_t type)
546
880
return type == OPT_GLOBAL && !option_limits;
548
bool check_type(enum_var_type type)
882
bool check_type(sql_var_t type)
550
884
return (only_global && type != OPT_GLOBAL);
555
class sys_var_session_bool :public sys_var_session
889
class DRIZZLED_API sys_var_session_bool :public sys_var_session
559
sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
892
bool drizzle_system_variables::*offset;
893
sys_var_session_bool(const char *name_arg, bool drizzle_system_variables::*offset_arg)
560
894
:sys_var_session(name_arg), offset(offset_arg)
561
{ chain_sys_var(chain); }
562
sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
896
sys_var_session_bool(const char *name_arg, bool drizzle_system_variables::*offset_arg,
563
897
sys_after_update_func func)
564
898
:sys_var_session(name_arg,func), offset(offset_arg)
565
{ chain_sys_var(chain); }
566
900
bool update(Session *session, set_var *var);
567
void set_default(Session *session, enum_var_type type);
901
void set_default(Session *session, sql_var_t type);
568
902
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
569
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
570
bool check(Session *session, set_var *var)
572
return check_enum(session, var, &bool_typelib);
903
unsigned char *value_ptr(Session *session, sql_var_t type,
904
const LEX_STRING *base);
905
bool check(Session *session, set_var *var);
574
906
bool check_update_type(Item_result)
579
class sys_var_session_enum :public sys_var_session
911
class DRIZZLED_API sys_var_session_enum :public sys_var_session
582
uint32_t SV::*offset;
914
uint32_t drizzle_system_variables::*offset;
583
915
TYPELIB *enum_names;
584
916
sys_check_func check_func;
586
sys_var_session_enum(sys_var_chain *chain, const char *name_arg,
587
uint32_t SV::*offset_arg, TYPELIB *typelib,
918
sys_var_session_enum(const char *name_arg,
919
uint32_t drizzle_system_variables::*offset_arg, TYPELIB *typelib,
588
920
sys_after_update_func func= NULL,
589
sys_check_func check= NULL)
921
sys_check_func check_f= NULL)
590
922
:sys_var_session(name_arg, func), offset(offset_arg),
591
enum_names(typelib), check_func(check)
592
{ chain_sys_var(chain); }
923
enum_names(typelib), check_func(check_f)
593
925
bool check(Session *session, set_var *var)
598
930
return ret ? ret : check_enum(session, var, enum_names);
600
932
bool update(Session *session, set_var *var);
601
void set_default(Session *session, enum_var_type type);
933
void set_default(Session *session, sql_var_t type);
602
934
SHOW_TYPE show_type() { return SHOW_CHAR; }
603
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
935
unsigned char *value_ptr(Session *session, sql_var_t type,
936
const LEX_STRING *base);
604
937
bool check_update_type(Item_result)
610
class sys_var_session_optimizer_switch :public sys_var_session_enum
613
sys_var_session_optimizer_switch(sys_var_chain *chain, const char *name_arg,
614
uint32_t SV::*offset_arg)
615
:sys_var_session_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib)
617
bool check(Session *session, set_var *var)
619
return check_set(session, var, enum_names);
621
void set_default(Session *session, enum_var_type type);
622
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
623
static bool symbolic_mode_representation(Session *session, uint32_t sql_mode,
628
class sys_var_session_storage_engine :public sys_var_session
942
class DRIZZLED_API sys_var_session_storage_engine :public sys_var_session
631
plugin_ref SV::*offset;
945
plugin::StorageEngine *drizzle_system_variables::*offset;
633
sys_var_session_storage_engine(sys_var_chain *chain, const char *name_arg,
634
plugin_ref SV::*offset_arg)
947
sys_var_session_storage_engine(const char *name_arg,
948
plugin::StorageEngine *drizzle_system_variables::*offset_arg)
635
949
:sys_var_session(name_arg), offset(offset_arg)
636
{ chain_sys_var(chain); }
637
bool check(Session *session, set_var *var);
638
951
SHOW_TYPE show_type() { return SHOW_CHAR; }
639
952
bool check_update_type(Item_result type)
641
954
return type != STRING_RESULT; /* Only accept strings */
643
void set_default(Session *session, enum_var_type type);
956
void set_default(Session *session, sql_var_t type);
644
957
bool update(Session *session, set_var *var);
645
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
958
unsigned char *value_ptr(Session *session, sql_var_t type,
959
const LEX_STRING *base);
648
class sys_var_session_bit :public sys_var_session
962
class DRIZZLED_API sys_var_session_bit :public sys_var_session
650
964
sys_check_func check_func;
651
965
sys_update_func update_func;
653
967
uint64_t bit_flag;
655
sys_var_session_bit(sys_var_chain *chain, const char *name_arg,
969
sys_var_session_bit(const char *name_arg,
656
970
sys_check_func c_func, sys_update_func u_func,
657
uint64_t bit, bool reverse_arg=0,
658
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
659
:sys_var_session(name_arg, NULL, binlog_status_arg), check_func(c_func),
971
uint64_t bit, bool reverse_arg=0)
972
:sys_var_session(name_arg, NULL), check_func(c_func),
660
973
update_func(u_func), bit_flag(bit), reverse(reverse_arg)
661
{ chain_sys_var(chain); }
662
975
bool check(Session *session, set_var *var);
663
976
bool update(Session *session, set_var *var);
664
977
bool check_update_type(Item_result)
666
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
979
bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
667
980
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
668
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
981
unsigned char *value_ptr(Session *session, sql_var_t type,
982
const LEX_STRING *base);
671
985
/* some variables that require special handling */
673
class sys_var_timestamp :public sys_var
987
class DRIZZLED_API sys_var_timestamp :public sys_var
676
sys_var_timestamp(sys_var_chain *chain, const char *name_arg,
677
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
678
:sys_var(name_arg, NULL, binlog_status_arg)
679
{ chain_sys_var(chain); }
990
sys_var_timestamp(const char *name_arg)
991
:sys_var(name_arg, NULL)
680
993
bool update(Session *session, set_var *var);
681
void set_default(Session *session, enum_var_type type);
682
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
683
bool check_default(enum_var_type)
994
void set_default(Session *session, sql_var_t type);
995
bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
996
bool check_default(sql_var_t)
685
998
SHOW_TYPE show_type(void) { return SHOW_LONG; }
686
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
690
class sys_var_last_insert_id :public sys_var
693
sys_var_last_insert_id(sys_var_chain *chain, const char *name_arg,
694
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
695
:sys_var(name_arg, NULL, binlog_status_arg)
696
{ chain_sys_var(chain); }
697
bool update(Session *session, set_var *var);
698
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
699
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
700
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
704
class sys_var_insert_id :public sys_var
707
sys_var_insert_id(sys_var_chain *chain, const char *name_arg)
709
{ chain_sys_var(chain); }
710
bool update(Session *session, set_var *var);
711
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
712
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
713
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
717
class sys_var_collation :public sys_var_session
720
sys_var_collation(const char *name_arg,
721
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
722
:sys_var_session(name_arg, NULL, binlog_status_arg)
724
no_support_one_shot= 0;
726
bool check(Session *session, set_var *var);
727
SHOW_TYPE show_type() { return SHOW_CHAR; }
728
bool check_update_type(Item_result type)
730
return ((type != STRING_RESULT) && (type != INT_RESULT));
732
bool check_default(enum_var_type) { return 0; }
733
virtual void set_default(Session *session, enum_var_type type)= 0;
736
class sys_var_character_set :public sys_var_session
740
sys_var_character_set(const char *name_arg, bool is_nullable= 0,
741
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
742
:sys_var_session(name_arg, NULL, binlog_status_arg), nullable(is_nullable)
745
In fact only almost all variables derived from sys_var_character_set
746
support ONE_SHOT; character_set_results doesn't. But that's good enough.
748
no_support_one_shot= 0;
750
bool check(Session *session, set_var *var);
751
SHOW_TYPE show_type() { return SHOW_CHAR; }
752
bool check_update_type(Item_result type)
754
return ((type != STRING_RESULT) && (type != INT_RESULT));
756
bool check_default(enum_var_type)
758
bool update(Session *session, set_var *var);
759
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
760
virtual void set_default(Session *session, enum_var_type type)= 0;
761
virtual const CHARSET_INFO **ci_ptr(Session *session, enum_var_type type)= 0;
764
class sys_var_collation_sv :public sys_var_collation
766
const CHARSET_INFO *SV::*offset;
999
unsigned char *value_ptr(Session *session, sql_var_t type,
1000
const LEX_STRING *base);
1004
class DRIZZLED_API sys_var_last_insert_id :public sys_var
1007
sys_var_last_insert_id(const char *name_arg)
1008
:sys_var(name_arg, NULL)
1010
bool update(Session *session, set_var *var);
1011
bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
1012
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
1013
unsigned char *value_ptr(Session *session, sql_var_t type,
1014
const LEX_STRING *base);
1018
class DRIZZLED_API sys_var_collation :public sys_var_session
1021
sys_var_collation(const char *name_arg)
1022
:sys_var_session(name_arg, NULL)
1024
SHOW_TYPE show_type() { return SHOW_CHAR; }
1025
bool check_update_type(Item_result type)
1027
return ((type != STRING_RESULT) && (type != INT_RESULT));
1029
bool check_default(sql_var_t) { return 0; }
1030
virtual void set_default(Session *session, sql_var_t type)= 0;
1033
class DRIZZLED_API sys_var_collation_sv :public sys_var_collation
1035
const CHARSET_INFO *drizzle_system_variables::*offset;
767
1036
const CHARSET_INFO **global_default;
769
sys_var_collation_sv(sys_var_chain *chain, const char *name_arg,
770
const CHARSET_INFO *SV::*offset_arg,
771
const CHARSET_INFO **global_default_arg,
772
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
773
:sys_var_collation(name_arg, binlog_status_arg),
1038
sys_var_collation_sv(const char *name_arg,
1039
const CHARSET_INFO *drizzle_system_variables::*offset_arg,
1040
const CHARSET_INFO **global_default_arg)
1041
:sys_var_collation(name_arg),
774
1042
offset(offset_arg), global_default(global_default_arg)
776
chain_sys_var(chain);
778
bool update(Session *session, set_var *var);
779
void set_default(Session *session, enum_var_type type);
780
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
784
class sys_var_key_cache_param :public sys_var
789
sys_var_key_cache_param(sys_var_chain *chain, const char *name_arg,
791
:sys_var(name_arg), offset(offset_arg)
792
{ chain_sys_var(chain); }
793
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
794
bool check_default(enum_var_type)
796
bool is_struct() { return 1; }
800
class sys_var_key_buffer_size :public sys_var_key_cache_param
803
sys_var_key_buffer_size(sys_var_chain *chain, const char *name_arg)
804
:sys_var_key_cache_param(chain, name_arg,
805
offsetof(KEY_CACHE, param_buff_size))
807
bool update(Session *session, set_var *var);
808
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
812
class sys_var_key_cache_long :public sys_var_key_cache_param
815
sys_var_key_cache_long(sys_var_chain *chain, const char *name_arg, size_t offset_arg)
816
:sys_var_key_cache_param(chain, name_arg, offset_arg)
818
bool update(Session *session, set_var *var);
819
SHOW_TYPE show_type() { return SHOW_LONG; }
823
class sys_var_session_date_time_format :public sys_var_session
825
DATE_TIME_FORMAT *SV::*offset;
826
enum enum_drizzle_timestamp_type date_time_type;
828
sys_var_session_date_time_format(sys_var_chain *chain, const char *name_arg,
829
DATE_TIME_FORMAT *SV::*offset_arg,
830
enum enum_drizzle_timestamp_type date_time_type_arg)
831
:sys_var_session(name_arg), offset(offset_arg),
832
date_time_type(date_time_type_arg)
833
{ chain_sys_var(chain); }
834
SHOW_TYPE show_type() { return SHOW_CHAR; }
835
bool check_update_type(Item_result type)
837
return type != STRING_RESULT; /* Only accept strings */
839
bool check_default(enum_var_type)
841
bool check(Session *session, set_var *var);
842
bool update(Session *session, set_var *var);
843
void update2(Session *session, enum_var_type type, DATE_TIME_FORMAT *new_value);
844
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
845
void set_default(Session *session, enum_var_type type);
849
class sys_var_log_state :public sys_var_bool_ptr
853
sys_var_log_state(sys_var_chain *chain, const char *name_arg, bool *value_arg,
854
uint32_t log_type_arg)
855
:sys_var_bool_ptr(chain, name_arg, value_arg), log_type(log_type_arg) {}
856
bool update(Session *session, set_var *var);
857
void set_default(Session *session, enum_var_type type);
1046
bool update(Session *session, set_var *var);
1047
void set_default(Session *session, sql_var_t type);
1048
unsigned char *value_ptr(Session *session, sql_var_t type,
1049
const LEX_STRING *base);
860
1052
/* Variable that you can only read from */
862
class sys_var_readonly: public sys_var
1054
class DRIZZLED_API sys_var_readonly: public sys_var
865
enum_var_type var_type;
866
1058
SHOW_TYPE show_type_value;
867
1059
sys_value_ptr_func value_ptr_func;
868
sys_var_readonly(sys_var_chain *chain, const char *name_arg, enum_var_type type,
1060
sys_var_readonly(const char *name_arg, sql_var_t type,
869
1061
SHOW_TYPE show_type_arg,
870
1062
sys_value_ptr_func value_ptr_func_arg)
871
:sys_var(name_arg), var_type(type),
1063
:sys_var(name_arg), var_type(type),
872
1064
show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
873
{ chain_sys_var(chain); }
874
1066
bool update(Session *, set_var *)
876
bool check_default(enum_var_type)
1068
bool check_default(sql_var_t)
878
bool check_type(enum_var_type type) { return type != var_type; }
1070
bool check_type(sql_var_t type) { return type != var_type; }
879
1071
bool check_update_type(Item_result)
881
unsigned char *value_ptr(Session *session, enum_var_type, LEX_STRING *)
1073
unsigned char *value_ptr(Session *session, sql_var_t,
883
1076
return (*value_ptr_func)(session);
886
1079
bool is_readonly(void) const { return 1; }
890
class sys_var_have_option: public sys_var
893
virtual SHOW_COMP_OPTION get_option() = 0;
895
sys_var_have_option(sys_var_chain *chain, const char *variable_name):
896
sys_var(variable_name)
897
{ chain_sys_var(chain); }
898
unsigned char *value_ptr(Session *, enum_var_type, LEX_STRING *)
900
return (unsigned char*) show_comp_option_name[get_option()];
902
bool update(Session *, set_var *) { return 1; }
903
bool check_default(enum_var_type)
905
bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
906
bool check_update_type(Item_result)
908
SHOW_TYPE show_type() { return SHOW_CHAR; }
909
bool is_readonly() const { return 1; }
913
class sys_var_have_variable: public sys_var_have_option
915
SHOW_COMP_OPTION *have_variable;
918
sys_var_have_variable(sys_var_chain *chain, const char *variable_name,
919
SHOW_COMP_OPTION *have_variable_arg):
920
sys_var_have_option(chain, variable_name),
921
have_variable(have_variable_arg)
923
SHOW_COMP_OPTION get_option() { return *have_variable; }
927
class sys_var_have_plugin: public sys_var_have_option
929
const char *plugin_name_str;
930
const uint32_t plugin_name_len;
931
const int plugin_type;
934
sys_var_have_plugin(sys_var_chain *chain, const char *variable_name,
935
const char *plugin_name_str_arg, uint32_t plugin_name_len_arg,
936
int plugin_type_arg):
937
sys_var_have_option(chain, variable_name),
938
plugin_name_str(plugin_name_str_arg), plugin_name_len(plugin_name_len_arg),
939
plugin_type(plugin_type_arg)
941
/* the following method is declared in sql_plugin.cc */
942
SHOW_COMP_OPTION get_option();
946
class sys_var_session_time_zone :public sys_var_session
949
sys_var_session_time_zone(sys_var_chain *chain, const char *name_arg,
950
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
951
:sys_var_session(name_arg, NULL, binlog_status_arg)
953
no_support_one_shot= 0;
954
chain_sys_var(chain);
956
bool check(Session *session, set_var *var);
957
SHOW_TYPE show_type() { return SHOW_CHAR; }
958
bool check_update_type(Item_result type)
960
return type != STRING_RESULT; /* Only accept strings */
962
bool check_default(enum_var_type)
964
bool update(Session *session, set_var *var);
965
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
966
virtual void set_default(Session *session, enum_var_type type);
970
class sys_var_microseconds :public sys_var_session
972
uint64_t SV::*offset;
974
sys_var_microseconds(sys_var_chain *chain, const char *name_arg,
975
uint64_t SV::*offset_arg):
1082
class DRIZZLED_API sys_var_microseconds :public sys_var_session
1084
uint64_t drizzle_system_variables::*offset;
1086
sys_var_microseconds(const char *name_arg,
1087
uint64_t drizzle_system_variables::*offset_arg):
976
1088
sys_var_session(name_arg), offset(offset_arg)
977
{ chain_sys_var(chain); }
978
1090
bool check(Session *, set_var *) {return 0;}
979
1091
bool update(Session *session, set_var *var);
980
void set_default(Session *session, enum_var_type type);
1092
void set_default(Session *session, sql_var_t type);
981
1093
SHOW_TYPE show_type() { return SHOW_DOUBLE; }
982
1094
bool check_update_type(Item_result type)
984
1096
return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
986
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
990
Handler for setting the system variable --read-only.
993
class sys_var_opt_readonly :public sys_var_bool_ptr
996
sys_var_opt_readonly(sys_var_chain *chain, const char *name_arg,
998
sys_var_bool_ptr(chain, name_arg, value_arg) {};
999
~sys_var_opt_readonly() {};
1000
bool update(Session *session, set_var *var);
1004
class sys_var_session_lc_time_names :public sys_var_session
1007
sys_var_session_lc_time_names(sys_var_chain *chain, const char *name_arg,
1008
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
1009
: sys_var_session(name_arg, NULL, binlog_status_arg)
1100
class DRIZZLED_API sys_var_session_lc_time_names :public sys_var_session
1103
sys_var_session_lc_time_names(const char *name_arg)
1104
: sys_var_session(name_arg, NULL)
1011
chain_sys_var(chain);
1013
bool check(Session *session, set_var *var);
1014
1108
SHOW_TYPE show_type() { return SHOW_CHAR; }
1015
1109
bool check_update_type(Item_result type)
1017
1111
return ((type != STRING_RESULT) && (type != INT_RESULT));
1019
bool check_default(enum_var_type)
1113
bool check_default(sql_var_t)
1021
1115
bool update(Session *session, set_var *var);
1022
unsigned char *value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
1023
virtual void set_default(Session *session, enum_var_type type);
1027
/****************************************************************************
1028
Classes for parsing of the SET command
1029
****************************************************************************/
1031
class set_var_base :public Sql_alloc
1035
virtual ~set_var_base() {}
1036
virtual int check(Session *session)=0; /* To check privileges etc. */
1037
virtual int update(Session *session)=0; /* To set the value */
1038
/* light check for PS */
1039
virtual bool no_support_one_shot() { return 1; }
1043
/* MySQL internal variables */
1045
class set_var :public set_var_base
1053
const CHARSET_INFO *charset;
1054
uint32_t uint32_t_value;
1055
uint64_t uint64_t_value;
1056
size_t size_t_value;
1058
DATE_TIME_FORMAT *date_time_format;
1059
Time_zone *time_zone;
1060
MY_LOCALE *locale_value;
1062
LEX_STRING base; /* for structs */
1064
set_var(enum_var_type type_arg, sys_var *var_arg,
1065
const LEX_STRING *base_name_arg, Item *value_arg)
1066
:var(var_arg), type(type_arg), base(*base_name_arg)
1069
If the set value is a field, change it to a string to allow things like
1070
SET table_type=MYISAM;
1072
if (value_arg && value_arg->type() == Item::FIELD_ITEM)
1074
Item_field *item= (Item_field*) value_arg;
1075
if (!(value=new Item_string(item->field_name,
1076
(uint) strlen(item->field_name),
1077
item->collation.collation)))
1078
value=value_arg; /* Give error message later */
1083
int check(Session *session);
1084
int update(Session *session);
1085
bool no_support_one_shot() { return var->no_support_one_shot; }
1089
/* User variables like @my_own_variable */
1091
class set_var_user: public set_var_base
1093
Item_func_set_user_var *user_var_item;
1095
set_var_user(Item_func_set_user_var *item)
1096
:user_var_item(item)
1098
int check(Session *session);
1099
int update(Session *session);
1102
/* For SET NAMES and SET CHARACTER SET */
1104
class set_var_collation_client: public set_var_base
1106
const CHARSET_INFO *character_set_client;
1107
const CHARSET_INFO *character_set_results;
1108
const CHARSET_INFO *collation_connection;
1110
set_var_collation_client(const CHARSET_INFO * const client_coll_arg,
1111
const CHARSET_INFO * const connection_coll_arg,
1112
const CHARSET_INFO * const result_coll_arg)
1113
:character_set_client(client_coll_arg),
1114
character_set_results(result_coll_arg),
1115
collation_connection(connection_coll_arg)
1117
int check(Session *session);
1118
int update(Session *session);
1124
typedef int (*process_key_cache_t) (const char *, KEY_CACHE *);
1127
/* Named lists (used for keycaches) */
1129
class NAMED_LIST :public ilink
1132
uint32_t name_length;
1134
unsigned char* data;
1136
NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg,
1137
uint32_t name_length_arg, unsigned char* data_arg)
1138
:name_length(name_length_arg), data(data_arg)
1140
name= my_strndup(name_arg, name_length, MYF(MY_WME));
1141
links->push_back(this);
1143
inline bool cmp(const char *name_cmp, uint32_t length)
1145
return length == name_length && !memcmp(name, name_cmp, length);
1149
free((unsigned char*) name);
1151
friend bool process_key_caches(process_key_cache_t func);
1152
friend void delete_elements(I_List<NAMED_LIST> *list,
1153
void (*free_element)(const char*, unsigned char*));
1156
/* updated in sql_acl.cc */
1158
extern sys_var_session_bool sys_old_alter_table;
1159
extern LEX_STRING default_key_cache_base;
1116
unsigned char *value_ptr(Session *session, sql_var_t type,
1117
const LEX_STRING *base);
1118
virtual void set_default(Session *session, sql_var_t type);
1161
1123
/* For sql_yacc */
1162
1124
struct sys_var_with_base