86
119
chain_arg->first= this;
87
120
chain_arg->last= this;
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)
94
return (type == OPT_SESSION || type == OPT_DEFAULT) &&
95
(binlog_status == SESSION_VARIABLE_IN_BINLOG);
97
virtual bool update(THD *thd, set_var *var)=0;
98
virtual void set_default(THD *thd_arg __attribute__((unused)),
99
enum_var_type type __attribute__((unused)))
124
* Returns the name of the variable.
128
* So that we can exist in a Registry. We really need to formalize that
130
inline const std::string &getName() const
135
* Returns a vector of strings representing aliases
136
* for this variable's name.
138
const std::vector<std::string>& getAliases() const
140
return empty_aliases;
143
* Returns a pointer to the next sys_var, or NULL if none.
145
inline sys_var *getNext() const
150
* Sets the pointer to the next sys_var.
152
* @param Pointer to the next sys_var, or NULL if you set the tail...
154
inline void setNext(sys_var *in_next)
159
* Returns a pointer to the variable's option limits
161
inline struct option *getOptionLimits() const
163
return option_limits;
166
* Sets the pointer to the variable's option limits
168
* @param Pointer to the option limits option variable
170
inline void setOptionLimits(struct option *in_option_limits)
172
option_limits= in_option_limits;
175
* Returns the function pointer for after update trigger, or NULL if none.
177
inline sys_after_update_func getAfterUpdateTrigger() const
181
virtual bool check(Session *session, set_var *var);
182
bool check_enum(Session *session, set_var *var, const TYPELIB *enum_names);
183
virtual bool update(Session *session, set_var *var)=0;
184
virtual void set_default(Session *, sql_var_t)
101
virtual SHOW_TYPE show_type() { return SHOW_UNDEF; }
102
virtual uchar *value_ptr(THD *thd __attribute__((unused)),
103
enum_var_type type __attribute__((unused)),
104
LEX_STRING *base __attribute__((unused)))
106
virtual bool check_type(enum_var_type type)
107
{ return type != OPT_GLOBAL; } /* Error if not GLOBAL */
186
virtual SHOW_TYPE show_type()
190
virtual unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
194
virtual bool check_type(sql_var_t type)
196
return type != OPT_GLOBAL;
197
} /* Error if not GLOBAL */
108
198
virtual bool check_update_type(Item_result type)
109
{ return type != INT_RESULT; } /* Assume INT */
110
virtual bool check_default(enum_var_type type __attribute__((unused)))
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; }
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;
200
return type != INT_RESULT;
202
virtual bool check_default(sql_var_t)
204
return option_limits == 0;
206
Item *item(Session *session, sql_var_t type, const LEX_STRING *base);
207
virtual bool is_readonly() const
211
virtual sys_var_pluginvar *cast_pluginvar()
131
A base class for all variables that require its access to
132
be guarded with a mutex.
218
* A base class for all variables that require its access to
219
* be guarded with a mutex.
135
221
class sys_var_global: public sys_var
138
224
pthread_mutex_t *guard;
140
sys_var_global(const char *name_arg, sys_after_update_func after_update_arg,
226
sys_var_global(const char *name_arg,
227
sys_after_update_func after_update_arg,
141
228
pthread_mutex_t *guard_arg)
142
:sys_var(name_arg, after_update_arg), guard(guard_arg) {}
147
A global-only ulong 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
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),
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; }
166
uchar *value_ptr(THD *thd __attribute__((unused)),
167
enum_var_type type __attribute__((unused)),
168
LEX_STRING *base __attribute__((unused)))
169
{ return (uchar*) value; }
174
A global ulong variable that is protected by LOCK_global_system_variables
177
class sys_var_long_ptr :public sys_var_long_ptr_global
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);
230
sys_var(name_arg, after_update_arg),
235
class sys_var_uint32_t_ptr :public sys_var
239
sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
240
uint32_t *value_ptr_arg)
241
:sys_var(name_arg),value(value_ptr_arg)
242
{ chain_sys_var(chain); }
243
sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
244
uint32_t *value_ptr_arg,
245
sys_after_update_func func)
246
:sys_var(name_arg,func), value(value_ptr_arg)
247
{ chain_sys_var(chain); }
248
bool check(Session *session, set_var *var);
249
bool update(Session *session, set_var *var);
250
void set_default(Session *session, sql_var_t type);
251
SHOW_TYPE show_type() { return SHOW_INT; }
252
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
253
{ return (unsigned char*) value; }
321
401
sys_var_const_str_ptr(sys_var_chain *chain, const char *name_arg, char **value_arg)
322
402
:sys_var(name_arg),value(value_arg)
323
403
{ chain_sys_var(chain); }
324
bool check(THD *thd __attribute__((unused)),
325
set_var *var __attribute__((unused)))
404
bool check(Session *, set_var *)
329
bool update(THD *thd __attribute__((unused)),
330
set_var *var __attribute__((unused)))
408
bool update(Session *, set_var *)
334
412
SHOW_TYPE show_type() { return SHOW_CHAR; }
335
uchar *value_ptr(THD *thd __attribute__((unused)),
336
enum_var_type type __attribute__((unused)),
337
LEX_STRING *base __attribute__((unused)))
413
unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
339
return (uchar*) *value;
415
return (unsigned char*) *value;
341
bool check_update_type(Item_result type __attribute__((unused)))
417
bool check_update_type(Item_result)
345
bool check_default(enum_var_type type __attribute__((unused)))
421
bool check_default(sql_var_t)
347
423
bool is_readonly(void) const { return 1; }
351
class sys_var_enum :public sys_var
356
sys_var_enum(sys_var_chain *chain, const char *name_arg, uint *value_arg,
357
TYPELIB *typelib, sys_after_update_func func)
358
:sys_var(name_arg,func), value(value_arg), enum_names(typelib)
359
{ chain_sys_var(chain); }
360
bool check(THD *thd, set_var *var)
362
return check_enum(thd, var, enum_names);
364
bool update(THD *thd, set_var *var);
365
SHOW_TYPE show_type() { return SHOW_CHAR; }
366
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
367
bool check_update_type(Item_result type __attribute__((unused)))
372
class sys_var_enum_const :public sys_var
377
sys_var_enum_const(sys_var_chain *chain, const char *name_arg, ulong SV::*offset_arg,
378
TYPELIB *typelib, sys_after_update_func func)
379
:sys_var(name_arg,func), offset(offset_arg), enum_names(typelib)
380
{ chain_sys_var(chain); }
381
bool check(THD *thd __attribute__((unused)),
382
set_var *var __attribute__((unused)))
384
bool update(THD *thd __attribute__((unused)),
385
set_var *var __attribute__((unused)))
387
SHOW_TYPE show_type() { return SHOW_CHAR; }
388
bool check_update_type(Item_result type __attribute__((unused)))
390
bool is_readonly() const { return 1; }
391
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
395
class sys_var_thd :public sys_var
398
sys_var_thd(const char *name_arg,
399
sys_after_update_func func= NULL,
400
Binlog_status_enum binlog_status= NOT_IN_BINLOG)
401
:sys_var(name_arg, func, binlog_status)
427
class sys_var_session :public sys_var
430
sys_var_session(const char *name_arg,
431
sys_after_update_func func= NULL)
432
:sys_var(name_arg, func)
403
bool check_type(enum_var_type type __attribute__((unused)))
434
bool check_type(sql_var_t)
405
bool check_default(enum_var_type type)
436
bool check_default(sql_var_t type)
407
438
return type == OPT_GLOBAL && !option_limits;
412
class sys_var_thd_ulong :public sys_var_thd
442
class sys_var_session_uint32_t :public sys_var_session
414
444
sys_check_func check_func;
417
sys_var_thd_ulong(sys_var_chain *chain, const char *name_arg,
418
ulong SV::*offset_arg,
419
sys_check_func c_func= NULL,
420
sys_after_update_func au_func= NULL,
421
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
422
:sys_var_thd(name_arg, au_func, binlog_status_arg), check_func(c_func),
446
uint32_t system_variables::*offset;
447
sys_var_session_uint32_t(sys_var_chain *chain, const char *name_arg,
448
uint32_t system_variables::*offset_arg,
449
sys_check_func c_func= NULL,
450
sys_after_update_func au_func= NULL)
451
:sys_var_session(name_arg, au_func), check_func(c_func),
423
452
offset(offset_arg)
424
453
{ chain_sys_var(chain); }
425
bool check(THD *thd, set_var *var);
426
bool update(THD *thd, set_var *var);
427
void set_default(THD *thd, enum_var_type type);
428
SHOW_TYPE show_type() { return SHOW_LONG; }
429
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
454
bool check(Session *session, set_var *var);
455
bool update(Session *session, set_var *var);
456
void set_default(Session *session, sql_var_t type);
457
SHOW_TYPE show_type() { return SHOW_INT; }
458
unsigned char *value_ptr(Session *session, sql_var_t type,
459
const LEX_STRING *base);
433
class sys_var_thd_ha_rows :public sys_var_thd
463
class sys_var_session_ha_rows :public sys_var_session
437
sys_var_thd_ha_rows(sys_var_chain *chain, const char *name_arg,
438
ha_rows SV::*offset_arg)
439
:sys_var_thd(name_arg), offset(offset_arg)
466
ha_rows system_variables::*offset;
467
sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
468
ha_rows system_variables::*offset_arg)
469
:sys_var_session(name_arg), offset(offset_arg)
440
470
{ chain_sys_var(chain); }
441
sys_var_thd_ha_rows(sys_var_chain *chain, const char *name_arg,
442
ha_rows SV::*offset_arg,
471
sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
472
ha_rows system_variables::*offset_arg,
443
473
sys_after_update_func func)
444
:sys_var_thd(name_arg,func), offset(offset_arg)
474
:sys_var_session(name_arg,func), offset(offset_arg)
445
475
{ chain_sys_var(chain); }
446
bool update(THD *thd, set_var *var);
447
void set_default(THD *thd, enum_var_type type);
476
bool update(Session *session, set_var *var);
477
void set_default(Session *session, sql_var_t type);
448
478
SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
449
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
479
unsigned char *value_ptr(Session *session, sql_var_t type,
480
const LEX_STRING *base);
453
class sys_var_thd_uint64_t :public sys_var_thd
484
class sys_var_session_uint64_t :public sys_var_session
486
sys_check_func check_func;
456
uint64_t SV::*offset;
488
uint64_t system_variables::*offset;
457
489
bool only_global;
458
sys_var_thd_uint64_t(sys_var_chain *chain, const char *name_arg,
459
uint64_t SV::*offset_arg)
460
:sys_var_thd(name_arg), offset(offset_arg)
490
sys_var_session_uint64_t(sys_var_chain *chain,
491
const char *name_arg,
492
uint64_t system_variables::*offset_arg,
493
sys_after_update_func au_func= NULL,
494
sys_check_func c_func= NULL)
495
:sys_var_session(name_arg, au_func),
461
498
{ chain_sys_var(chain); }
462
sys_var_thd_uint64_t(sys_var_chain *chain, const char *name_arg,
463
uint64_t SV::*offset_arg,
464
sys_after_update_func func, bool only_global_arg)
465
:sys_var_thd(name_arg, func), offset(offset_arg),
499
sys_var_session_uint64_t(sys_var_chain *chain,
500
const char *name_arg,
501
uint64_t system_variables::*offset_arg,
502
sys_after_update_func func,
503
bool only_global_arg,
504
sys_check_func cfunc= NULL)
505
:sys_var_session(name_arg, func),
466
508
only_global(only_global_arg)
467
509
{ chain_sys_var(chain); }
468
bool update(THD *thd, set_var *var);
469
void set_default(THD *thd, enum_var_type type);
510
bool update(Session *session, set_var *var);
511
void set_default(Session *session, sql_var_t type);
470
512
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
471
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
472
bool check(THD *thd, set_var *var);
473
bool check_default(enum_var_type type)
475
return type == OPT_GLOBAL && !option_limits;
477
bool check_type(enum_var_type type)
479
return (only_global && type != OPT_GLOBAL);
484
class sys_var_thd_bool :public sys_var_thd
488
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
489
:sys_var_thd(name_arg), offset(offset_arg)
490
{ chain_sys_var(chain); }
491
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
513
unsigned char *value_ptr(Session *session, sql_var_t type,
514
const LEX_STRING *base);
515
bool check(Session *session, set_var *var);
516
bool check_default(sql_var_t type)
518
return type == OPT_GLOBAL && !option_limits;
520
bool check_type(sql_var_t type)
522
return (only_global && type != OPT_GLOBAL);
526
class sys_var_session_size_t :public sys_var_session
528
sys_check_func check_func;
530
size_t system_variables::*offset;
532
sys_var_session_size_t(sys_var_chain *chain, const char *name_arg,
533
size_t system_variables::*offset_arg,
534
sys_after_update_func au_func= NULL,
535
sys_check_func c_func= NULL)
536
:sys_var_session(name_arg, au_func),
539
{ chain_sys_var(chain); }
540
sys_var_session_size_t(sys_var_chain *chain,
541
const char *name_arg,
542
size_t system_variables::*offset_arg,
543
sys_after_update_func func,
544
bool only_global_arg,
545
sys_check_func cfunc= NULL)
546
:sys_var_session(name_arg, func),
549
only_global(only_global_arg)
550
{ chain_sys_var(chain); }
551
bool update(Session *session, set_var *var);
552
void set_default(Session *session, sql_var_t type);
553
SHOW_TYPE show_type() { return SHOW_SIZE; }
554
unsigned char *value_ptr(Session *session, sql_var_t type,
555
const LEX_STRING *base);
556
bool check(Session *session, set_var *var);
557
bool check_default(sql_var_t type)
559
return type == OPT_GLOBAL && !option_limits;
561
bool check_type(sql_var_t type)
563
return (only_global && type != OPT_GLOBAL);
568
class sys_var_session_bool :public sys_var_session
571
bool system_variables::*offset;
572
sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool system_variables::*offset_arg)
573
:sys_var_session(name_arg), offset(offset_arg)
574
{ chain_sys_var(chain); }
575
sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool system_variables::*offset_arg,
492
576
sys_after_update_func func)
493
:sys_var_thd(name_arg,func), offset(offset_arg)
577
:sys_var_session(name_arg,func), offset(offset_arg)
494
578
{ chain_sys_var(chain); }
495
bool update(THD *thd, set_var *var);
496
void set_default(THD *thd, enum_var_type type);
579
bool update(Session *session, set_var *var);
580
void set_default(Session *session, sql_var_t type);
497
581
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
498
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
499
bool check(THD *thd, set_var *var)
582
unsigned char *value_ptr(Session *session, sql_var_t type,
583
const LEX_STRING *base);
584
bool check(Session *session, set_var *var)
501
return check_enum(thd, var, &bool_typelib);
586
return check_enum(session, var, &bool_typelib);
503
bool check_update_type(Item_result type __attribute__((unused)))
588
bool check_update_type(Item_result)
508
class sys_var_thd_enum :public sys_var_thd
593
class sys_var_session_enum :public sys_var_session
596
uint32_t system_variables::*offset;
512
597
TYPELIB *enum_names;
513
598
sys_check_func check_func;
515
sys_var_thd_enum(sys_var_chain *chain, const char *name_arg,
516
ulong SV::*offset_arg, TYPELIB *typelib,
600
sys_var_session_enum(sys_var_chain *chain, const char *name_arg,
601
uint32_t system_variables::*offset_arg, TYPELIB *typelib,
517
602
sys_after_update_func func= NULL,
518
sys_check_func check= NULL)
519
:sys_var_thd(name_arg, func), offset(offset_arg),
520
enum_names(typelib), check_func(check)
603
sys_check_func check_f= NULL)
604
:sys_var_session(name_arg, func), offset(offset_arg),
605
enum_names(typelib), check_func(check_f)
521
606
{ chain_sys_var(chain); }
522
bool check(THD *thd, set_var *var)
607
bool check(Session *session, set_var *var)
526
ret= (*check_func)(thd, var);
527
return ret ? ret : check_enum(thd, var, enum_names);
611
ret= (*check_func)(session, var);
612
return ret ? ret : check_enum(session, var, enum_names);
529
bool update(THD *thd, set_var *var);
530
void set_default(THD *thd, enum_var_type type);
614
bool update(Session *session, set_var *var);
615
void set_default(Session *session, sql_var_t type);
531
616
SHOW_TYPE show_type() { return SHOW_CHAR; }
532
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
533
bool check_update_type(Item_result type __attribute__((unused)))
617
unsigned char *value_ptr(Session *session, sql_var_t type,
618
const LEX_STRING *base);
619
bool check_update_type(Item_result)
539
class sys_var_thd_optimizer_switch :public sys_var_thd_enum
542
sys_var_thd_optimizer_switch(sys_var_chain *chain, const char *name_arg,
543
ulong SV::*offset_arg)
544
:sys_var_thd_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib)
546
bool check(THD *thd, set_var *var)
548
return check_set(thd, var, enum_names);
550
void set_default(THD *thd, enum_var_type type);
551
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
552
static bool symbolic_mode_representation(THD *thd, uint64_t sql_mode,
557
class sys_var_thd_storage_engine :public sys_var_thd
624
class sys_var_session_storage_engine :public sys_var_session
560
plugin_ref SV::*offset;
627
plugin::StorageEngine *system_variables::*offset;
562
sys_var_thd_storage_engine(sys_var_chain *chain, const char *name_arg,
563
plugin_ref SV::*offset_arg)
564
:sys_var_thd(name_arg), offset(offset_arg)
629
sys_var_session_storage_engine(sys_var_chain *chain, const char *name_arg,
630
plugin::StorageEngine *system_variables::*offset_arg)
631
:sys_var_session(name_arg), offset(offset_arg)
565
632
{ chain_sys_var(chain); }
566
bool check(THD *thd, set_var *var);
633
bool check(Session *session, set_var *var);
567
634
SHOW_TYPE show_type() { return SHOW_CHAR; }
568
635
bool check_update_type(Item_result type)
570
637
return type != STRING_RESULT; /* Only accept strings */
572
void set_default(THD *thd, enum_var_type type);
573
bool update(THD *thd, set_var *var);
574
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
639
void set_default(Session *session, sql_var_t type);
640
bool update(Session *session, set_var *var);
641
unsigned char *value_ptr(Session *session, sql_var_t type,
642
const LEX_STRING *base);
577
class sys_var_thd_bit :public sys_var_thd
645
class sys_var_session_bit :public sys_var_session
579
647
sys_check_func check_func;
580
648
sys_update_func update_func;
582
650
uint64_t bit_flag;
584
sys_var_thd_bit(sys_var_chain *chain, const char *name_arg,
652
sys_var_session_bit(sys_var_chain *chain, const char *name_arg,
585
653
sys_check_func c_func, sys_update_func u_func,
586
uint64_t bit, bool reverse_arg=0,
587
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
588
:sys_var_thd(name_arg, NULL, binlog_status_arg), check_func(c_func),
654
uint64_t bit, bool reverse_arg=0)
655
:sys_var_session(name_arg, NULL), check_func(c_func),
589
656
update_func(u_func), bit_flag(bit), reverse(reverse_arg)
590
657
{ chain_sys_var(chain); }
591
bool check(THD *thd, set_var *var);
592
bool update(THD *thd, set_var *var);
593
bool check_update_type(Item_result type __attribute__((unused)))
658
bool check(Session *session, set_var *var);
659
bool update(Session *session, set_var *var);
660
bool check_update_type(Item_result)
595
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
662
bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
596
663
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
597
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
664
unsigned char *value_ptr(Session *session, sql_var_t type,
665
const LEX_STRING *base);
600
668
/* some variables that require special handling */
602
670
class sys_var_timestamp :public sys_var
605
sys_var_timestamp(sys_var_chain *chain, const char *name_arg,
606
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
607
:sys_var(name_arg, NULL, binlog_status_arg)
673
sys_var_timestamp(sys_var_chain *chain, const char *name_arg)
674
:sys_var(name_arg, NULL)
608
675
{ chain_sys_var(chain); }
609
bool update(THD *thd, set_var *var);
610
void set_default(THD *thd, enum_var_type type);
611
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
612
bool check_default(enum_var_type type __attribute__((unused)))
676
bool update(Session *session, set_var *var);
677
void set_default(Session *session, sql_var_t type);
678
bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
679
bool check_default(sql_var_t)
614
681
SHOW_TYPE show_type(void) { return SHOW_LONG; }
615
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
682
unsigned char *value_ptr(Session *session, sql_var_t type,
683
const LEX_STRING *base);
619
687
class sys_var_last_insert_id :public sys_var
622
sys_var_last_insert_id(sys_var_chain *chain, const char *name_arg,
623
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
624
:sys_var(name_arg, NULL, binlog_status_arg)
625
{ chain_sys_var(chain); }
626
bool update(THD *thd, set_var *var);
627
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
628
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
629
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
633
class sys_var_insert_id :public sys_var
636
sys_var_insert_id(sys_var_chain *chain, const char *name_arg)
638
{ chain_sys_var(chain); }
639
bool update(THD *thd, set_var *var);
640
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
641
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
642
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
646
class sys_var_rand_seed1 :public sys_var
649
sys_var_rand_seed1(sys_var_chain *chain, const char *name_arg,
650
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
651
:sys_var(name_arg, NULL, binlog_status_arg)
652
{ chain_sys_var(chain); }
653
bool update(THD *thd, set_var *var);
654
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
657
class sys_var_rand_seed2 :public sys_var
660
sys_var_rand_seed2(sys_var_chain *chain, const char *name_arg,
661
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
662
:sys_var(name_arg, NULL, binlog_status_arg)
663
{ chain_sys_var(chain); }
664
bool update(THD *thd, set_var *var);
665
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
669
class sys_var_collation :public sys_var_thd
672
sys_var_collation(const char *name_arg,
673
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
674
:sys_var_thd(name_arg, NULL, binlog_status_arg)
676
no_support_one_shot= 0;
678
bool check(THD *thd, set_var *var);
679
SHOW_TYPE show_type() { return SHOW_CHAR; }
680
bool check_update_type(Item_result type)
682
return ((type != STRING_RESULT) && (type != INT_RESULT));
684
bool check_default(enum_var_type type __attribute__((unused))) { return 0; }
685
virtual void set_default(THD *thd, enum_var_type type)= 0;
688
class sys_var_character_set :public sys_var_thd
692
sys_var_character_set(const char *name_arg, bool is_nullable= 0,
693
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
694
:sys_var_thd(name_arg, NULL, binlog_status_arg), nullable(is_nullable)
697
In fact only almost all variables derived from sys_var_character_set
698
support ONE_SHOT; character_set_results doesn't. But that's good enough.
700
no_support_one_shot= 0;
702
bool check(THD *thd, set_var *var);
703
SHOW_TYPE show_type() { return SHOW_CHAR; }
704
bool check_update_type(Item_result type)
706
return ((type != STRING_RESULT) && (type != INT_RESULT));
708
bool check_default(enum_var_type type __attribute__((unused)))
710
bool update(THD *thd, set_var *var);
711
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
712
virtual void set_default(THD *thd, enum_var_type type)= 0;
713
virtual const CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
716
class sys_var_character_set_sv :public sys_var_character_set
718
const CHARSET_INFO *SV::*offset;
719
const CHARSET_INFO **global_default;
721
sys_var_character_set_sv(sys_var_chain *chain, const char *name_arg,
722
const CHARSET_INFO *SV::*offset_arg,
723
const CHARSET_INFO **global_default_arg,
725
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
726
: sys_var_character_set(name_arg, is_nullable, binlog_status_arg),
727
offset(offset_arg), global_default(global_default_arg)
728
{ chain_sys_var(chain); }
729
void set_default(THD *thd, enum_var_type type);
730
const CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
734
class sys_var_character_set_client: public sys_var_character_set_sv
737
sys_var_character_set_client(sys_var_chain *chain, const char *name_arg,
738
const CHARSET_INFO *SV::*offset_arg,
739
const CHARSET_INFO **global_default_arg,
740
Binlog_status_enum binlog_status_arg)
741
: sys_var_character_set_sv(chain, name_arg, offset_arg, global_default_arg,
742
0, binlog_status_arg)
690
sys_var_last_insert_id(sys_var_chain *chain, const char *name_arg)
691
:sys_var(name_arg, NULL)
692
{ chain_sys_var(chain); }
693
bool update(Session *session, set_var *var);
694
bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
695
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
696
unsigned char *value_ptr(Session *session, sql_var_t type,
697
const LEX_STRING *base);
701
class sys_var_collation :public sys_var_session
704
sys_var_collation(const char *name_arg)
705
:sys_var_session(name_arg, NULL)
744
bool check(THD *thd, set_var *var);
748
class sys_var_character_set_database :public sys_var_character_set
751
sys_var_character_set_database(sys_var_chain *chain, const char *name_arg,
752
Binlog_status_enum binlog_status_arg=
754
: sys_var_character_set(name_arg, 0, binlog_status_arg)
755
{ chain_sys_var(chain); }
756
void set_default(THD *thd, enum_var_type type);
757
const CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
707
bool check(Session *session, set_var *var);
708
SHOW_TYPE show_type() { return SHOW_CHAR; }
709
bool check_update_type(Item_result type)
711
return ((type != STRING_RESULT) && (type != INT_RESULT));
713
bool check_default(sql_var_t) { return 0; }
714
virtual void set_default(Session *session, sql_var_t type)= 0;
760
717
class sys_var_collation_sv :public sys_var_collation
762
const CHARSET_INFO *SV::*offset;
719
const CHARSET_INFO *system_variables::*offset;
763
720
const CHARSET_INFO **global_default;
765
722
sys_var_collation_sv(sys_var_chain *chain, const char *name_arg,
766
const CHARSET_INFO *SV::*offset_arg,
767
const CHARSET_INFO **global_default_arg,
768
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
769
:sys_var_collation(name_arg, binlog_status_arg),
723
const CHARSET_INFO *system_variables::*offset_arg,
724
const CHARSET_INFO **global_default_arg)
725
:sys_var_collation(name_arg),
770
726
offset(offset_arg), global_default(global_default_arg)
772
728
chain_sys_var(chain);
774
bool update(THD *thd, set_var *var);
775
void set_default(THD *thd, enum_var_type type);
776
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
780
class sys_var_key_cache_param :public sys_var
785
sys_var_key_cache_param(sys_var_chain *chain, const char *name_arg,
787
:sys_var(name_arg), offset(offset_arg)
788
{ chain_sys_var(chain); }
789
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
790
bool check_default(enum_var_type type __attribute__((unused)))
792
bool is_struct() { return 1; }
796
class sys_var_key_buffer_size :public sys_var_key_cache_param
799
sys_var_key_buffer_size(sys_var_chain *chain, const char *name_arg)
800
:sys_var_key_cache_param(chain, name_arg,
801
offsetof(KEY_CACHE, param_buff_size))
803
bool update(THD *thd, set_var *var);
804
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
808
class sys_var_key_cache_long :public sys_var_key_cache_param
811
sys_var_key_cache_long(sys_var_chain *chain, const char *name_arg, size_t offset_arg)
812
:sys_var_key_cache_param(chain, name_arg, offset_arg)
814
bool update(THD *thd, set_var *var);
815
SHOW_TYPE show_type() { return SHOW_LONG; }
819
class sys_var_thd_date_time_format :public sys_var_thd
821
DATE_TIME_FORMAT *SV::*offset;
822
timestamp_type date_time_type;
824
sys_var_thd_date_time_format(sys_var_chain *chain, const char *name_arg,
825
DATE_TIME_FORMAT *SV::*offset_arg,
826
timestamp_type date_time_type_arg)
827
:sys_var_thd(name_arg), offset(offset_arg),
828
date_time_type(date_time_type_arg)
829
{ chain_sys_var(chain); }
830
SHOW_TYPE show_type() { return SHOW_CHAR; }
831
bool check_update_type(Item_result type)
833
return type != STRING_RESULT; /* Only accept strings */
835
bool check_default(enum_var_type type __attribute__((unused)))
837
bool check(THD *thd, set_var *var);
838
bool update(THD *thd, set_var *var);
839
void update2(THD *thd, enum_var_type type, DATE_TIME_FORMAT *new_value);
840
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
841
void set_default(THD *thd, enum_var_type type);
845
class sys_var_log_state :public sys_var_bool_ptr
849
sys_var_log_state(sys_var_chain *chain, const char *name_arg, bool *value_arg,
851
:sys_var_bool_ptr(chain, name_arg, value_arg), log_type(log_type_arg) {}
852
bool update(THD *thd, set_var *var);
853
void set_default(THD *thd, enum_var_type type);
857
class sys_var_set :public sys_var
863
sys_var_set(sys_var_chain *chain, const char *name_arg, ulong *value_arg,
864
TYPELIB *typelib, sys_after_update_func func)
865
:sys_var(name_arg, func), value(value_arg), enum_names(typelib)
866
{ chain_sys_var(chain); }
867
virtual bool check(THD *thd, set_var *var)
869
return check_set(thd, var, enum_names);
871
virtual void set_default(THD *thd __attribute__((unused)),
872
enum_var_type type __attribute__((unused)))
876
bool update(THD *thd, set_var *var);
877
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
878
bool check_update_type(Item_result type __attribute__((unused)))
880
SHOW_TYPE show_type() { return SHOW_CHAR; }
883
class sys_var_set_slave_mode :public sys_var_set
886
sys_var_set_slave_mode(sys_var_chain *chain, const char *name_arg,
888
TYPELIB *typelib, sys_after_update_func func) :
889
sys_var_set(chain, name_arg, value_arg, typelib, func) {}
890
void set_default(THD *thd, enum_var_type type);
891
bool check(THD *thd, set_var *var);
892
bool update(THD *thd, set_var *var);
895
class sys_var_log_output :public sys_var
900
sys_var_log_output(sys_var_chain *chain, const char *name_arg, ulong *value_arg,
901
TYPELIB *typelib, sys_after_update_func func)
902
:sys_var(name_arg,func), value(value_arg), enum_names(typelib)
904
chain_sys_var(chain);
905
set_allow_empty_value(false);
907
virtual bool check(THD *thd, set_var *var)
909
return check_set(thd, var, enum_names);
911
bool update(THD *thd, set_var *var);
912
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
913
bool check_update_type(Item_result type __attribute__((unused)))
915
void set_default(THD *thd, enum_var_type type);
916
SHOW_TYPE show_type() { return SHOW_CHAR; }
730
bool update(Session *session, set_var *var);
731
void set_default(Session *session, sql_var_t type);
732
unsigned char *value_ptr(Session *session, sql_var_t type,
733
const LEX_STRING *base);
920
736
/* Variable that you can only read from */
922
738
class sys_var_readonly: public sys_var
925
enum_var_type var_type;
926
742
SHOW_TYPE show_type_value;
927
743
sys_value_ptr_func value_ptr_func;
928
sys_var_readonly(sys_var_chain *chain, const char *name_arg, enum_var_type type,
744
sys_var_readonly(sys_var_chain *chain, const char *name_arg, sql_var_t type,
929
745
SHOW_TYPE show_type_arg,
930
746
sys_value_ptr_func value_ptr_func_arg)
931
:sys_var(name_arg), var_type(type),
747
:sys_var(name_arg), var_type(type),
932
748
show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
933
749
{ chain_sys_var(chain); }
934
bool update(THD *thd __attribute__((unused)),
935
set_var *var __attribute__((unused)))
937
bool check_default(enum_var_type type __attribute__((unused)))
939
bool check_type(enum_var_type type) { return type != var_type; }
940
bool check_update_type(Item_result type __attribute__((unused)))
942
uchar *value_ptr(THD *thd, enum_var_type type __attribute__((unused)),
943
LEX_STRING *base __attribute__((unused)))
750
bool update(Session *, set_var *)
752
bool check_default(sql_var_t)
754
bool check_type(sql_var_t type) { return type != var_type; }
755
bool check_update_type(Item_result)
757
unsigned char *value_ptr(Session *session, sql_var_t,
945
return (*value_ptr_func)(thd);
760
return (*value_ptr_func)(session);
947
762
SHOW_TYPE show_type(void) { return show_type_value; }
948
763
bool is_readonly(void) const { return 1; }
952
class sys_var_have_option: public sys_var
955
virtual SHOW_COMP_OPTION get_option() = 0;
957
sys_var_have_option(sys_var_chain *chain, const char *variable_name):
958
sys_var(variable_name)
959
{ chain_sys_var(chain); }
960
uchar *value_ptr(THD *thd __attribute__((unused)),
961
enum_var_type type __attribute__((unused)),
962
LEX_STRING *base __attribute__((unused)))
964
return (uchar*) show_comp_option_name[get_option()];
966
bool update(THD *thd __attribute__((unused)),
967
set_var *var __attribute__((unused))) { return 1; }
968
bool check_default(enum_var_type type __attribute__((unused)))
970
bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
971
bool check_update_type(Item_result type __attribute__((unused)))
973
SHOW_TYPE show_type() { return SHOW_CHAR; }
974
bool is_readonly() const { return 1; }
978
class sys_var_have_variable: public sys_var_have_option
980
SHOW_COMP_OPTION *have_variable;
983
sys_var_have_variable(sys_var_chain *chain, const char *variable_name,
984
SHOW_COMP_OPTION *have_variable_arg):
985
sys_var_have_option(chain, variable_name),
986
have_variable(have_variable_arg)
988
SHOW_COMP_OPTION get_option() { return *have_variable; }
992
class sys_var_have_plugin: public sys_var_have_option
994
const char *plugin_name_str;
995
const uint plugin_name_len;
996
const int plugin_type;
999
sys_var_have_plugin(sys_var_chain *chain, const char *variable_name,
1000
const char *plugin_name_str_arg, uint plugin_name_len_arg,
1001
int plugin_type_arg):
1002
sys_var_have_option(chain, variable_name),
1003
plugin_name_str(plugin_name_str_arg), plugin_name_len(plugin_name_len_arg),
1004
plugin_type(plugin_type_arg)
1006
/* the following method is declared in sql_plugin.cc */
1007
SHOW_COMP_OPTION get_option();
1011
class sys_var_thd_time_zone :public sys_var_thd
1014
sys_var_thd_time_zone(sys_var_chain *chain, const char *name_arg,
1015
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
1016
:sys_var_thd(name_arg, NULL, binlog_status_arg)
1018
no_support_one_shot= 0;
767
class sys_var_session_time_zone :public sys_var_session
770
sys_var_session_time_zone(sys_var_chain *chain, const char *name_arg)
771
:sys_var_session(name_arg, NULL)
1019
773
chain_sys_var(chain);
1021
bool check(THD *thd, set_var *var);
775
bool check(Session *session, set_var *var);
1022
776
SHOW_TYPE show_type() { return SHOW_CHAR; }
1023
777
bool check_update_type(Item_result type)
1025
779
return type != STRING_RESULT; /* Only accept strings */
1027
bool check_default(enum_var_type type __attribute__((unused)))
781
bool check_default(sql_var_t)
1029
bool update(THD *thd, set_var *var);
1030
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1031
virtual void set_default(THD *thd, enum_var_type type);
1035
class sys_var_max_user_conn : public sys_var_thd
1038
sys_var_max_user_conn(sys_var_chain *chain, const char *name_arg):
1039
sys_var_thd(name_arg)
1040
{ chain_sys_var(chain); }
1041
bool check(THD *thd, set_var *var);
1042
bool update(THD *thd, set_var *var);
1043
bool check_default(enum_var_type type)
1045
return type != OPT_GLOBAL || !option_limits;
1047
void set_default(THD *thd, enum_var_type type);
1048
SHOW_TYPE show_type() { return SHOW_INT; }
1049
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1053
class sys_var_microseconds :public sys_var_thd
1055
uint64_t SV::*offset;
783
bool update(Session *session, set_var *var);
784
unsigned char *value_ptr(Session *session, sql_var_t type,
785
const LEX_STRING *base);
786
virtual void set_default(Session *session, sql_var_t type);
790
class sys_var_microseconds :public sys_var_session
792
uint64_t system_variables::*offset;
1057
794
sys_var_microseconds(sys_var_chain *chain, const char *name_arg,
1058
uint64_t SV::*offset_arg):
1059
sys_var_thd(name_arg), offset(offset_arg)
795
uint64_t system_variables::*offset_arg):
796
sys_var_session(name_arg), offset(offset_arg)
1060
797
{ chain_sys_var(chain); }
1061
bool check(THD *thd __attribute__((unused)),
1062
set_var *var __attribute__((unused))) {return 0;}
1063
bool update(THD *thd, set_var *var);
1064
void set_default(THD *thd, enum_var_type type);
798
bool check(Session *, set_var *) {return 0;}
799
bool update(Session *session, set_var *var);
800
void set_default(Session *session, sql_var_t type);
1065
801
SHOW_TYPE show_type() { return SHOW_DOUBLE; }
1066
802
bool check_update_type(Item_result type)
1068
804
return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
1070
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1074
Handler for setting the system variable --read-only.
1077
class sys_var_opt_readonly :public sys_var_bool_ptr
1080
sys_var_opt_readonly(sys_var_chain *chain, const char *name_arg,
1082
sys_var_bool_ptr(chain, name_arg, value_arg) {};
1083
~sys_var_opt_readonly() {};
1084
bool update(THD *thd, set_var *var);
1088
class sys_var_thd_lc_time_names :public sys_var_thd
1091
sys_var_thd_lc_time_names(sys_var_chain *chain, const char *name_arg,
1092
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
1093
: sys_var_thd(name_arg, NULL, binlog_status_arg)
808
class sys_var_session_lc_time_names :public sys_var_session
811
sys_var_session_lc_time_names(sys_var_chain *chain, const char *name_arg)
812
: sys_var_session(name_arg, NULL)
1095
#if DRIZZLE_VERSION_ID < 50000
1096
no_support_one_shot= 0;
1098
814
chain_sys_var(chain);
1100
bool check(THD *thd, set_var *var);
816
bool check(Session *session, set_var *var);
1101
817
SHOW_TYPE show_type() { return SHOW_CHAR; }
1102
818
bool check_update_type(Item_result type)
1104
820
return ((type != STRING_RESULT) && (type != INT_RESULT));
1106
bool check_default(enum_var_type type __attribute__((unused)))
822
bool check_default(sql_var_t)
1108
bool update(THD *thd, set_var *var);
1109
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1110
virtual void set_default(THD *thd, enum_var_type type);
1114
extern void fix_binlog_format_after_update(THD *thd, enum_var_type type);
1116
class sys_var_thd_binlog_format :public sys_var_thd_enum
1119
sys_var_thd_binlog_format(sys_var_chain *chain, const char *name_arg,
1120
ulong SV::*offset_arg)
1121
:sys_var_thd_enum(chain, name_arg, offset_arg,
1122
&binlog_format_typelib,
1123
fix_binlog_format_after_update)
1125
bool is_readonly() const;
824
bool update(Session *session, set_var *var);
825
unsigned char *value_ptr(Session *session, sql_var_t type,
826
const LEX_STRING *base);
827
virtual void set_default(Session *session, sql_var_t type);
1128
831
/****************************************************************************
1129
832
Classes for parsing of the SET command
1130
833
****************************************************************************/
1132
class set_var_base :public Sql_alloc
835
class set_var_base :public memory::SqlAlloc
1135
838
set_var_base() {}
1136
839
virtual ~set_var_base() {}
1137
virtual int check(THD *thd)=0; /* To check privileges etc. */
1138
virtual int update(THD *thd)=0; /* To set the value */
840
virtual int check(Session *session)=0; /* To check privileges etc. */
841
virtual int update(Session *session)=0; /* To set the value */
1139
842
/* light check for PS */
1140
virtual bool no_support_one_shot() { return 1; }
1144
845
/* MySQL internal variables */
1146
846
class set_var :public set_var_base
1154
854
const CHARSET_INFO *charset;
855
uint32_t uint32_t_value;
1156
856
uint64_t uint64_t_value;
1158
DATE_TIME_FORMAT *date_time_format;
858
plugin::StorageEngine *storage_engine;
1159
859
Time_zone *time_zone;
1160
860
MY_LOCALE *locale_value;
1162
862
LEX_STRING base; /* for structs */
1164
set_var(enum_var_type type_arg, sys_var *var_arg,
864
set_var(sql_var_t type_arg, sys_var *var_arg,
1165
865
const LEX_STRING *base_name_arg, Item *value_arg)
1166
866
:var(var_arg), type(type_arg), base(*base_name_arg)