86
121
chain_arg->first= this;
87
122
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)))
126
* Returns the name of the variable.
130
* So that we can exist in a Registry. We really need to formalize that
132
inline const std::string &getName() const
137
* Returns a vector of strings representing aliases
138
* for this variable's name.
140
const std::vector<std::string>& getAliases() const
142
return empty_aliases;
145
* Returns a pointer to the next sys_var, or NULL if none.
147
inline sys_var *getNext() const
152
* Sets the pointer to the next sys_var.
154
* @param Pointer to the next sys_var, or NULL if you set the tail...
156
inline void setNext(sys_var *in_next)
161
* Returns a pointer to the variable's option limits
163
inline struct my_option *getOptionLimits() const
165
return option_limits;
168
* Sets the pointer to the variable's option limits
170
* @param Pointer to the option limits my_option variable
172
inline void setOptionLimits(struct my_option *in_option_limits)
174
option_limits= in_option_limits;
177
* Returns the function pointer for after update trigger, or NULL if none.
179
inline sys_after_update_func getAfterUpdateTrigger() const
183
virtual bool check(Session *session, set_var *var);
184
bool check_enum(Session *session, set_var *var, const TYPELIB *enum_names);
185
virtual bool update(Session *session, set_var *var)=0;
186
virtual void set_default(Session *, enum_var_type)
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)))
188
virtual SHOW_TYPE show_type()
192
virtual unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
106
196
virtual bool check_type(enum_var_type type)
107
{ return type != OPT_GLOBAL; } /* Error if not GLOBAL */
198
return type != OPT_GLOBAL;
199
} /* Error if not GLOBAL */
108
200
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;
202
return type != INT_RESULT;
204
virtual bool check_default(enum_var_type)
206
return option_limits == 0;
208
Item *item(Session *session, enum_var_type type, const LEX_STRING *base);
209
virtual bool is_readonly() const
213
virtual sys_var_pluginvar *cast_pluginvar()
131
A base class for all variables that require its access to
132
be guarded with a mutex.
220
* A base class for all variables that require its access to
221
* be guarded with a mutex.
135
223
class sys_var_global: public sys_var
138
226
pthread_mutex_t *guard;
140
sys_var_global(const char *name_arg, sys_after_update_func after_update_arg,
228
sys_var_global(const char *name_arg,
229
sys_after_update_func after_update_arg,
141
230
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);
232
sys_var(name_arg, after_update_arg),
237
class sys_var_uint32_t_ptr :public sys_var
241
sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
242
uint32_t *value_ptr_arg)
243
:sys_var(name_arg),value(value_ptr_arg)
244
{ chain_sys_var(chain); }
245
sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
246
uint32_t *value_ptr_arg,
247
sys_after_update_func func)
248
:sys_var(name_arg,func), value(value_ptr_arg)
249
{ chain_sys_var(chain); }
250
bool check(Session *session, set_var *var);
251
bool update(Session *session, set_var *var);
252
void set_default(Session *session, enum_var_type type);
253
SHOW_TYPE show_type() { return SHOW_INT; }
254
unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
255
{ return (unsigned char*) value; }
321
403
sys_var_const_str_ptr(sys_var_chain *chain, const char *name_arg, char **value_arg)
322
404
:sys_var(name_arg),value(value_arg)
323
405
{ chain_sys_var(chain); }
324
bool check(THD *thd __attribute__((unused)),
325
set_var *var __attribute__((unused)))
406
bool check(Session *, set_var *)
329
bool update(THD *thd __attribute__((unused)),
330
set_var *var __attribute__((unused)))
410
bool update(Session *, set_var *)
334
414
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)))
415
unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
339
return (uchar*) *value;
417
return (unsigned char*) *value;
341
bool check_update_type(Item_result type __attribute__((unused)))
419
bool check_update_type(Item_result)
345
bool check_default(enum_var_type type __attribute__((unused)))
423
bool check_default(enum_var_type)
347
425
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)
429
class sys_var_session :public sys_var
432
sys_var_session(const char *name_arg,
433
sys_after_update_func func= NULL)
434
:sys_var(name_arg, func)
403
bool check_type(enum_var_type type __attribute__((unused)))
436
bool check_type(enum_var_type)
405
438
bool check_default(enum_var_type type)
412
class sys_var_thd_ulong :public sys_var_thd
444
class sys_var_session_uint32_t :public sys_var_session
414
446
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),
448
uint32_t SV::*offset;
449
sys_var_session_uint32_t(sys_var_chain *chain, const char *name_arg,
450
uint32_t SV::*offset_arg,
451
sys_check_func c_func= NULL,
452
sys_after_update_func au_func= NULL)
453
:sys_var_session(name_arg, au_func), check_func(c_func),
423
454
offset(offset_arg)
424
455
{ 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);
456
bool check(Session *session, set_var *var);
457
bool update(Session *session, set_var *var);
458
void set_default(Session *session, enum_var_type type);
459
SHOW_TYPE show_type() { return SHOW_INT; }
460
unsigned char *value_ptr(Session *session, enum_var_type type,
461
const LEX_STRING *base);
433
class sys_var_thd_ha_rows :public sys_var_thd
465
class sys_var_session_ha_rows :public sys_var_session
436
468
ha_rows SV::*offset;
437
sys_var_thd_ha_rows(sys_var_chain *chain, const char *name_arg,
469
sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
438
470
ha_rows SV::*offset_arg)
439
:sys_var_thd(name_arg), offset(offset_arg)
471
:sys_var_session(name_arg), offset(offset_arg)
440
472
{ chain_sys_var(chain); }
441
sys_var_thd_ha_rows(sys_var_chain *chain, const char *name_arg,
473
sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
442
474
ha_rows SV::*offset_arg,
443
475
sys_after_update_func func)
444
:sys_var_thd(name_arg,func), offset(offset_arg)
476
:sys_var_session(name_arg,func), offset(offset_arg)
445
477
{ chain_sys_var(chain); }
446
bool update(THD *thd, set_var *var);
447
void set_default(THD *thd, enum_var_type type);
478
bool update(Session *session, set_var *var);
479
void set_default(Session *session, enum_var_type type);
448
480
SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
449
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
481
unsigned char *value_ptr(Session *session, enum_var_type type,
482
const LEX_STRING *base);
453
class sys_var_thd_uint64_t :public sys_var_thd
486
class sys_var_session_uint64_t :public sys_var_session
488
sys_check_func check_func;
456
490
uint64_t SV::*offset;
457
491
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)
492
sys_var_session_uint64_t(sys_var_chain *chain,
493
const char *name_arg,
494
uint64_t SV::*offset_arg,
495
sys_after_update_func au_func= NULL,
496
sys_check_func c_func= NULL)
497
:sys_var_session(name_arg, au_func),
461
500
{ 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),
501
sys_var_session_uint64_t(sys_var_chain *chain,
502
const char *name_arg,
503
uint64_t SV::*offset_arg,
504
sys_after_update_func func,
505
bool only_global_arg,
506
sys_check_func cfunc= NULL)
507
:sys_var_session(name_arg, func),
466
510
only_global(only_global_arg)
467
511
{ chain_sys_var(chain); }
468
bool update(THD *thd, set_var *var);
469
void set_default(THD *thd, enum_var_type type);
512
bool update(Session *session, set_var *var);
513
void set_default(Session *session, enum_var_type type);
470
514
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
515
unsigned char *value_ptr(Session *session, enum_var_type type,
516
const LEX_STRING *base);
517
bool check(Session *session, set_var *var);
518
bool check_default(enum_var_type type)
520
return type == OPT_GLOBAL && !option_limits;
522
bool check_type(enum_var_type type)
524
return (only_global && type != OPT_GLOBAL);
528
class sys_var_session_size_t :public sys_var_session
530
sys_check_func check_func;
534
sys_var_session_size_t(sys_var_chain *chain, const char *name_arg,
535
size_t SV::*offset_arg,
536
sys_after_update_func au_func= NULL,
537
sys_check_func c_func= NULL)
538
:sys_var_session(name_arg, au_func),
541
{ chain_sys_var(chain); }
542
sys_var_session_size_t(sys_var_chain *chain,
543
const char *name_arg,
544
size_t SV::*offset_arg,
545
sys_after_update_func func,
546
bool only_global_arg,
547
sys_check_func cfunc= NULL)
548
:sys_var_session(name_arg, func),
551
only_global(only_global_arg)
552
{ chain_sys_var(chain); }
553
bool update(Session *session, set_var *var);
554
void set_default(Session *session, enum_var_type type);
555
SHOW_TYPE show_type() { return SHOW_SIZE; }
556
unsigned char *value_ptr(Session *session, enum_var_type type,
557
const LEX_STRING *base);
558
bool check(Session *session, set_var *var);
559
bool check_default(enum_var_type type)
561
return type == OPT_GLOBAL && !option_limits;
563
bool check_type(enum_var_type type)
565
return (only_global && type != OPT_GLOBAL);
570
class sys_var_session_bool :public sys_var_session
487
573
bool SV::*offset;
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)
574
sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
575
:sys_var_session(name_arg), offset(offset_arg)
490
576
{ chain_sys_var(chain); }
491
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
577
sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
492
578
sys_after_update_func func)
493
:sys_var_thd(name_arg,func), offset(offset_arg)
579
:sys_var_session(name_arg,func), offset(offset_arg)
494
580
{ chain_sys_var(chain); }
495
bool update(THD *thd, set_var *var);
496
void set_default(THD *thd, enum_var_type type);
581
bool update(Session *session, set_var *var);
582
void set_default(Session *session, enum_var_type type);
497
583
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)
584
unsigned char *value_ptr(Session *session, enum_var_type type,
585
const LEX_STRING *base);
586
bool check(Session *session, set_var *var)
501
return check_enum(thd, var, &bool_typelib);
588
return check_enum(session, var, &bool_typelib);
503
bool check_update_type(Item_result type __attribute__((unused)))
590
bool check_update_type(Item_result)
508
class sys_var_thd_enum :public sys_var_thd
595
class sys_var_session_enum :public sys_var_session
598
uint32_t SV::*offset;
512
599
TYPELIB *enum_names;
513
600
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,
602
sys_var_session_enum(sys_var_chain *chain, const char *name_arg,
603
uint32_t SV::*offset_arg, TYPELIB *typelib,
517
604
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)
605
sys_check_func check_f= NULL)
606
:sys_var_session(name_arg, func), offset(offset_arg),
607
enum_names(typelib), check_func(check_f)
521
608
{ chain_sys_var(chain); }
522
bool check(THD *thd, set_var *var)
609
bool check(Session *session, set_var *var)
526
ret= (*check_func)(thd, var);
527
return ret ? ret : check_enum(thd, var, enum_names);
613
ret= (*check_func)(session, var);
614
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);
616
bool update(Session *session, set_var *var);
617
void set_default(Session *session, enum_var_type type);
531
618
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)))
619
unsigned char *value_ptr(Session *session, enum_var_type type,
620
const LEX_STRING *base);
621
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
626
class sys_var_session_storage_engine :public sys_var_session
560
plugin_ref SV::*offset;
629
plugin::StorageEngine *SV::*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)
631
sys_var_session_storage_engine(sys_var_chain *chain, const char *name_arg,
632
plugin::StorageEngine *SV::*offset_arg)
633
:sys_var_session(name_arg), offset(offset_arg)
565
634
{ chain_sys_var(chain); }
566
bool check(THD *thd, set_var *var);
635
bool check(Session *session, set_var *var);
567
636
SHOW_TYPE show_type() { return SHOW_CHAR; }
568
637
bool check_update_type(Item_result type)
570
639
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);
641
void set_default(Session *session, enum_var_type type);
642
bool update(Session *session, set_var *var);
643
unsigned char *value_ptr(Session *session, enum_var_type type,
644
const LEX_STRING *base);
577
class sys_var_thd_bit :public sys_var_thd
647
class sys_var_session_bit :public sys_var_session
579
649
sys_check_func check_func;
580
650
sys_update_func update_func;
582
652
uint64_t bit_flag;
584
sys_var_thd_bit(sys_var_chain *chain, const char *name_arg,
654
sys_var_session_bit(sys_var_chain *chain, const char *name_arg,
585
655
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),
656
uint64_t bit, bool reverse_arg=0)
657
:sys_var_session(name_arg, NULL), check_func(c_func),
589
658
update_func(u_func), bit_flag(bit), reverse(reverse_arg)
590
659
{ 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)))
660
bool check(Session *session, set_var *var);
661
bool update(Session *session, set_var *var);
662
bool check_update_type(Item_result)
595
664
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
596
665
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
597
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
666
unsigned char *value_ptr(Session *session, enum_var_type type,
667
const LEX_STRING *base);
600
670
/* some variables that require special handling */
602
672
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)
675
sys_var_timestamp(sys_var_chain *chain, const char *name_arg)
676
:sys_var(name_arg, NULL)
608
677
{ chain_sys_var(chain); }
609
bool update(THD *thd, set_var *var);
610
void set_default(THD *thd, enum_var_type type);
678
bool update(Session *session, set_var *var);
679
void set_default(Session *session, enum_var_type type);
611
680
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
612
bool check_default(enum_var_type type __attribute__((unused)))
681
bool check_default(enum_var_type)
614
683
SHOW_TYPE show_type(void) { return SHOW_LONG; }
615
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
684
unsigned char *value_ptr(Session *session, enum_var_type type,
685
const LEX_STRING *base);
619
689
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)
692
sys_var_last_insert_id(sys_var_chain *chain, const char *name_arg)
693
:sys_var(name_arg, NULL)
694
{ chain_sys_var(chain); }
695
bool update(Session *session, set_var *var);
696
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
697
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
698
unsigned char *value_ptr(Session *session, enum_var_type type,
699
const LEX_STRING *base);
703
class sys_var_collation :public sys_var_session
706
sys_var_collation(const char *name_arg)
707
: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);
709
bool check(Session *session, set_var *var);
710
SHOW_TYPE show_type() { return SHOW_CHAR; }
711
bool check_update_type(Item_result type)
713
return ((type != STRING_RESULT) && (type != INT_RESULT));
715
bool check_default(enum_var_type) { return 0; }
716
virtual void set_default(Session *session, enum_var_type type)= 0;
760
719
class sys_var_collation_sv :public sys_var_collation
763
722
const CHARSET_INFO **global_default;
765
724
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),
725
const CHARSET_INFO *SV::*offset_arg,
726
const CHARSET_INFO **global_default_arg)
727
:sys_var_collation(name_arg),
770
728
offset(offset_arg), global_default(global_default_arg)
772
730
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; }
732
bool update(Session *session, set_var *var);
733
void set_default(Session *session, enum_var_type type);
734
unsigned char *value_ptr(Session *session, enum_var_type type,
735
const LEX_STRING *base);
920
738
/* Variable that you can only read from */
928
746
sys_var_readonly(sys_var_chain *chain, const char *name_arg, enum_var_type type,
929
747
SHOW_TYPE show_type_arg,
930
748
sys_value_ptr_func value_ptr_func_arg)
931
:sys_var(name_arg), var_type(type),
749
:sys_var(name_arg), var_type(type),
932
750
show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
933
751
{ chain_sys_var(chain); }
934
bool update(THD *thd __attribute__((unused)),
935
set_var *var __attribute__((unused)))
752
bool update(Session *, set_var *)
937
bool check_default(enum_var_type type __attribute__((unused)))
754
bool check_default(enum_var_type)
939
756
bool check_type(enum_var_type type) { return type != var_type; }
940
bool check_update_type(Item_result type __attribute__((unused)))
757
bool check_update_type(Item_result)
942
uchar *value_ptr(THD *thd, enum_var_type type __attribute__((unused)),
943
LEX_STRING *base __attribute__((unused)))
759
unsigned char *value_ptr(Session *session, enum_var_type,
945
return (*value_ptr_func)(thd);
762
return (*value_ptr_func)(session);
947
764
SHOW_TYPE show_type(void) { return show_type_value; }
948
765
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;
769
class sys_var_session_time_zone :public sys_var_session
772
sys_var_session_time_zone(sys_var_chain *chain, const char *name_arg)
773
:sys_var_session(name_arg, NULL)
1019
775
chain_sys_var(chain);
1021
bool check(THD *thd, set_var *var);
777
bool check(Session *session, set_var *var);
1022
778
SHOW_TYPE show_type() { return SHOW_CHAR; }
1023
779
bool check_update_type(Item_result type)
1025
781
return type != STRING_RESULT; /* Only accept strings */
1027
bool check_default(enum_var_type type __attribute__((unused)))
783
bool check_default(enum_var_type)
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
785
bool update(Session *session, set_var *var);
786
unsigned char *value_ptr(Session *session, enum_var_type type,
787
const LEX_STRING *base);
788
virtual void set_default(Session *session, enum_var_type type);
792
class sys_var_microseconds :public sys_var_session
1055
794
uint64_t SV::*offset;
1057
796
sys_var_microseconds(sys_var_chain *chain, const char *name_arg,
1058
797
uint64_t SV::*offset_arg):
1059
sys_var_thd(name_arg), offset(offset_arg)
798
sys_var_session(name_arg), offset(offset_arg)
1060
799
{ 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);
800
bool check(Session *, set_var *) {return 0;}
801
bool update(Session *session, set_var *var);
802
void set_default(Session *session, enum_var_type type);
1065
803
SHOW_TYPE show_type() { return SHOW_DOUBLE; }
1066
804
bool check_update_type(Item_result type)
1068
806
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)
810
class sys_var_session_lc_time_names :public sys_var_session
813
sys_var_session_lc_time_names(sys_var_chain *chain, const char *name_arg)
814
: sys_var_session(name_arg, NULL)
1095
#if DRIZZLE_VERSION_ID < 50000
1096
no_support_one_shot= 0;
1098
816
chain_sys_var(chain);
1100
bool check(THD *thd, set_var *var);
818
bool check(Session *session, set_var *var);
1101
819
SHOW_TYPE show_type() { return SHOW_CHAR; }
1102
820
bool check_update_type(Item_result type)
1104
822
return ((type != STRING_RESULT) && (type != INT_RESULT));
1106
bool check_default(enum_var_type type __attribute__((unused)))
824
bool check_default(enum_var_type)
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;
826
bool update(Session *session, set_var *var);
827
unsigned char *value_ptr(Session *session, enum_var_type type,
828
const LEX_STRING *base);
829
virtual void set_default(Session *session, enum_var_type type);
1128
833
/****************************************************************************
1129
834
Classes for parsing of the SET command
1130
835
****************************************************************************/
1132
class set_var_base :public Sql_alloc
837
class set_var_base :public memory::SqlAlloc
1135
840
set_var_base() {}
1136
841
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 */
842
virtual int check(Session *session)=0; /* To check privileges etc. */
843
virtual int update(Session *session)=0; /* To set the value */
1139
844
/* light check for PS */
1140
virtual bool no_support_one_shot() { return 1; }
1144
847
/* MySQL internal variables */
1146
848
class set_var :public set_var_base