1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1
/* Copyright (C) 2002-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
20
16
/* Classes to support the SET command */
41
37
typedef bool (*sys_update_func)(THD *, set_var *);
42
38
typedef void (*sys_after_update_func)(THD *,enum_var_type);
43
39
typedef void (*sys_set_default_func)(THD *, enum_var_type);
44
typedef unsigned char *(*sys_value_ptr_func)(THD *thd);
40
typedef uchar *(*sys_value_ptr_func)(THD *thd);
46
42
struct sys_var_chain
79
75
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
80
76
:name(name_arg), after_update(func), no_support_one_shot(1),
81
77
binlog_status(binlog_status_arg),
82
m_allow_empty_value(true)
78
m_allow_empty_value(TRUE)
84
80
virtual ~sys_var() {}
85
81
void chain_sys_var(sys_var_chain *chain_arg)
99
95
(binlog_status == SESSION_VARIABLE_IN_BINLOG);
101
97
virtual bool update(THD *thd, set_var *var)=0;
102
virtual void set_default(THD *thd_arg __attribute__((unused)),
103
enum_var_type type __attribute__((unused)))
98
virtual void set_default(THD *thd_arg, enum_var_type type) {}
105
99
virtual SHOW_TYPE show_type() { return SHOW_UNDEF; }
106
virtual unsigned char *value_ptr(THD *thd __attribute__((unused)),
107
enum_var_type type __attribute__((unused)),
108
LEX_STRING *base __attribute__((unused)))
100
virtual uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
110
102
virtual bool check_type(enum_var_type type)
111
103
{ return type != OPT_GLOBAL; } /* Error if not GLOBAL */
112
104
virtual bool check_update_type(Item_result type)
113
105
{ return type != INT_RESULT; } /* Assume INT */
114
virtual bool check_default(enum_var_type type __attribute__((unused)))
106
virtual bool check_default(enum_var_type type)
115
107
{ return option_limits == 0; }
116
108
Item *item(THD *thd, enum_var_type type, LEX_STRING *base);
117
109
virtual bool is_struct() { return 0; }
167
159
bool update(THD *thd, set_var *var);
168
160
void set_default(THD *thd, enum_var_type type);
169
161
SHOW_TYPE show_type() { return SHOW_LONG; }
170
unsigned char *value_ptr(THD *thd __attribute__((unused)),
171
enum_var_type type __attribute__((unused)),
172
LEX_STRING *base __attribute__((unused)))
173
{ return (unsigned char*) value; }
162
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
163
{ return (uchar*) value; }
189
class sys_var_uint64_t_ptr :public sys_var
179
class sys_var_ulonglong_ptr :public sys_var
193
sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg)
183
sys_var_ulonglong_ptr(sys_var_chain *chain, const char *name_arg, ulonglong *value_ptr_arg)
194
184
:sys_var(name_arg),value(value_ptr_arg)
195
185
{ chain_sys_var(chain); }
196
sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg,
186
sys_var_ulonglong_ptr(sys_var_chain *chain, const char *name_arg, ulonglong *value_ptr_arg,
197
187
sys_after_update_func func)
198
188
:sys_var(name_arg,func), value(value_ptr_arg)
199
189
{ chain_sys_var(chain); }
200
190
bool update(THD *thd, set_var *var);
201
191
void set_default(THD *thd, enum_var_type type);
202
192
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
203
unsigned char *value_ptr(THD *thd __attribute__((unused)),
204
enum_var_type type __attribute__((unused)),
205
LEX_STRING *base __attribute__((unused)))
206
{ return (unsigned char*) value; }
193
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
194
{ return (uchar*) value; }
210
198
class sys_var_bool_ptr :public sys_var
214
sys_var_bool_ptr(sys_var_chain *chain, const char *name_arg, bool *value_arg)
202
sys_var_bool_ptr(sys_var_chain *chain, const char *name_arg, my_bool *value_arg)
215
203
:sys_var(name_arg),value(value_arg)
216
204
{ chain_sys_var(chain); }
217
205
bool check(THD *thd, set_var *var)
221
209
bool update(THD *thd, set_var *var);
222
210
void set_default(THD *thd, enum_var_type type);
223
211
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
224
unsigned char *value_ptr(THD *thd __attribute__((unused)),
225
enum_var_type type __attribute__((unused)),
226
LEX_STRING *base __attribute__((unused)))
227
{ return (unsigned char*) value; }
228
bool check_update_type(Item_result type __attribute__((unused)))
212
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
213
{ return (uchar*) value; }
214
bool check_update_type(Item_result type) { return 0; }
232
218
class sys_var_bool_ptr_readonly :public sys_var_bool_ptr
235
221
sys_var_bool_ptr_readonly(sys_var_chain *chain, const char *name_arg,
237
223
:sys_var_bool_ptr(chain, name_arg, value_arg)
239
225
bool is_readonly() const { return 1; }
266
252
(*set_default_func)(thd, type);
268
254
SHOW_TYPE show_type() { return SHOW_CHAR; }
269
unsigned char *value_ptr(THD *thd __attribute__((unused)),
270
enum_var_type type __attribute__((unused)),
271
LEX_STRING *base __attribute__((unused)))
272
{ return (unsigned char*) value; }
255
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
256
{ return (uchar*) value; }
273
257
bool check_update_type(Item_result type)
275
259
return type != STRING_RESULT; /* Only accept strings */
277
bool check_default(enum_var_type type __attribute__((unused)))
261
bool check_default(enum_var_type type) { return 0; }
292
275
value= new_value;
294
bool check(THD *thd __attribute__((unused)),
295
set_var *var __attribute__((unused)))
277
bool check(THD *thd, set_var *var)
299
bool update(THD *thd __attribute__((unused)),
300
set_var *var __attribute__((unused)))
281
bool update(THD *thd, set_var *var)
304
285
SHOW_TYPE show_type() { return SHOW_CHAR; }
305
unsigned char *value_ptr(THD *thd __attribute__((unused)),
306
enum_var_type type __attribute__((unused)),
307
LEX_STRING *base __attribute__((unused)))
286
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
309
return (unsigned char*) value;
288
return (uchar*) value;
311
bool check_update_type(Item_result type __attribute__((unused)))
290
bool check_update_type(Item_result type)
315
bool check_default(enum_var_type type __attribute__((unused)))
294
bool check_default(enum_var_type type) { return 1; }
317
295
bool is_readonly() const { return 1; }
325
303
sys_var_const_str_ptr(sys_var_chain *chain, const char *name_arg, char **value_arg)
326
304
:sys_var(name_arg),value(value_arg)
327
305
{ chain_sys_var(chain); }
328
bool check(THD *thd __attribute__((unused)),
329
set_var *var __attribute__((unused)))
306
bool check(THD *thd, set_var *var)
333
bool update(THD *thd __attribute__((unused)),
334
set_var *var __attribute__((unused)))
310
bool update(THD *thd, set_var *var)
338
314
SHOW_TYPE show_type() { return SHOW_CHAR; }
339
unsigned char *value_ptr(THD *thd __attribute__((unused)),
340
enum_var_type type __attribute__((unused)),
341
LEX_STRING *base __attribute__((unused)))
315
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
343
return (unsigned char*) *value;
317
return (uchar*) *value;
345
bool check_update_type(Item_result type __attribute__((unused)))
319
bool check_update_type(Item_result type)
349
bool check_default(enum_var_type type __attribute__((unused)))
351
bool is_readonly(void) const { return 1; }
323
bool check_default(enum_var_type type) { return 1; }
324
bool is_readonly() const { return 1; }
355
328
class sys_var_enum :public sys_var
358
331
TYPELIB *enum_names;
360
sys_var_enum(sys_var_chain *chain, const char *name_arg, uint32_t *value_arg,
333
sys_var_enum(sys_var_chain *chain, const char *name_arg, uint *value_arg,
361
334
TYPELIB *typelib, sys_after_update_func func)
362
335
:sys_var(name_arg,func), value(value_arg), enum_names(typelib)
363
336
{ chain_sys_var(chain); }
368
341
bool update(THD *thd, set_var *var);
369
342
SHOW_TYPE show_type() { return SHOW_CHAR; }
370
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
371
bool check_update_type(Item_result type __attribute__((unused)))
343
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
344
bool check_update_type(Item_result type) { return 0; }
382
354
TYPELIB *typelib, sys_after_update_func func)
383
355
:sys_var(name_arg,func), offset(offset_arg), enum_names(typelib)
384
356
{ chain_sys_var(chain); }
385
bool check(THD *thd __attribute__((unused)),
386
set_var *var __attribute__((unused)))
388
bool update(THD *thd __attribute__((unused)),
389
set_var *var __attribute__((unused)))
357
bool check(THD *thd, set_var *var) { return 1; }
358
bool update(THD *thd, set_var *var) { return 1; }
391
359
SHOW_TYPE show_type() { return SHOW_CHAR; }
392
bool check_update_type(Item_result type __attribute__((unused)))
360
bool check_update_type(Item_result type) { return 1; }
394
361
bool is_readonly() const { return 1; }
395
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
362
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
404
371
Binlog_status_enum binlog_status= NOT_IN_BINLOG)
405
372
:sys_var(name_arg, func, binlog_status)
407
bool check_type(enum_var_type type __attribute__((unused)))
374
bool check_type(enum_var_type type) { return 0; }
409
375
bool check_default(enum_var_type type)
411
377
return type == OPT_GLOBAL && !option_limits;
430
396
bool update(THD *thd, set_var *var);
431
397
void set_default(THD *thd, enum_var_type type);
432
398
SHOW_TYPE show_type() { return SHOW_LONG; }
433
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
399
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
450
416
bool update(THD *thd, set_var *var);
451
417
void set_default(THD *thd, enum_var_type type);
452
418
SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
453
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
419
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
457
class sys_var_thd_uint64_t :public sys_var_thd
423
class sys_var_thd_ulonglong :public sys_var_thd
460
uint64_t SV::*offset;
426
ulonglong SV::*offset;
461
427
bool only_global;
462
sys_var_thd_uint64_t(sys_var_chain *chain, const char *name_arg,
463
uint64_t SV::*offset_arg)
428
sys_var_thd_ulonglong(sys_var_chain *chain, const char *name_arg,
429
ulonglong SV::*offset_arg)
464
430
:sys_var_thd(name_arg), offset(offset_arg)
465
431
{ chain_sys_var(chain); }
466
sys_var_thd_uint64_t(sys_var_chain *chain, const char *name_arg,
467
uint64_t SV::*offset_arg,
432
sys_var_thd_ulonglong(sys_var_chain *chain, const char *name_arg,
433
ulonglong SV::*offset_arg,
468
434
sys_after_update_func func, bool only_global_arg)
469
435
:sys_var_thd(name_arg, func), offset(offset_arg),
470
436
only_global(only_global_arg)
472
438
bool update(THD *thd, set_var *var);
473
439
void set_default(THD *thd, enum_var_type type);
474
440
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
475
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
441
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
476
442
bool check(THD *thd, set_var *var);
477
443
bool check_default(enum_var_type type)
488
454
class sys_var_thd_bool :public sys_var_thd
492
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
458
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg)
493
459
:sys_var_thd(name_arg), offset(offset_arg)
494
460
{ chain_sys_var(chain); }
495
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
461
sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg,
496
462
sys_after_update_func func)
497
463
:sys_var_thd(name_arg,func), offset(offset_arg)
498
464
{ chain_sys_var(chain); }
499
465
bool update(THD *thd, set_var *var);
500
466
void set_default(THD *thd, enum_var_type type);
501
467
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
502
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
468
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
503
469
bool check(THD *thd, set_var *var)
505
471
return check_enum(thd, var, &bool_typelib);
507
bool check_update_type(Item_result type __attribute__((unused)))
473
bool check_update_type(Item_result type) { return 0; }
533
498
bool update(THD *thd, set_var *var);
534
499
void set_default(THD *thd, enum_var_type type);
535
500
SHOW_TYPE show_type() { return SHOW_CHAR; }
536
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
537
bool check_update_type(Item_result type __attribute__((unused)))
501
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
502
bool check_update_type(Item_result type) { return 0; }
552
516
return check_set(thd, var, enum_names);
554
518
void set_default(THD *thd, enum_var_type type);
555
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
556
static bool symbolic_mode_representation(THD *thd, uint64_t sql_mode,
519
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
520
static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode,
557
521
LEX_STRING *rep);
576
540
void set_default(THD *thd, enum_var_type type);
577
541
bool update(THD *thd, set_var *var);
578
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
542
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
581
545
class sys_var_thd_bit :public sys_var_thd
583
547
sys_check_func check_func;
584
548
sys_update_func update_func;
588
552
sys_var_thd_bit(sys_var_chain *chain, const char *name_arg,
589
553
sys_check_func c_func, sys_update_func u_func,
590
uint64_t bit, bool reverse_arg=0,
554
ulonglong bit, bool reverse_arg=0,
591
555
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
592
556
:sys_var_thd(name_arg, NULL, binlog_status_arg), check_func(c_func),
593
557
update_func(u_func), bit_flag(bit), reverse(reverse_arg)
594
558
{ chain_sys_var(chain); }
595
559
bool check(THD *thd, set_var *var);
596
560
bool update(THD *thd, set_var *var);
597
bool check_update_type(Item_result type __attribute__((unused)))
561
bool check_update_type(Item_result type) { return 0; }
599
562
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
600
563
SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
601
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
564
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
567
class sys_var_thd_dbug :public sys_var_thd
570
sys_var_thd_dbug(sys_var_chain *chain, const char *name_arg)
571
:sys_var_thd(name_arg)
572
{ chain_sys_var(chain); }
573
bool check_update_type(Item_result type) { return type != STRING_RESULT; }
574
SHOW_TYPE show_type() { return SHOW_CHAR; }
575
bool update(THD *thd, set_var *var);
576
void set_default(THD *thd, enum_var_type type) { DBUG_POP(); }
577
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b);
604
582
/* some variables that require special handling */
613
591
bool update(THD *thd, set_var *var);
614
592
void set_default(THD *thd, enum_var_type type);
615
593
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
616
bool check_default(enum_var_type type __attribute__((unused)))
618
SHOW_TYPE show_type(void) { return SHOW_LONG; }
619
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
594
bool check_default(enum_var_type type) { return 0; }
595
SHOW_TYPE show_type() { return SHOW_LONG; }
596
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
630
607
bool update(THD *thd, set_var *var);
631
608
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
632
609
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
633
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
610
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
643
620
bool update(THD *thd, set_var *var);
644
621
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
645
622
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
646
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
623
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
710
687
return ((type != STRING_RESULT) && (type != INT_RESULT));
712
bool check_default(enum_var_type type __attribute__((unused)))
689
bool check_default(enum_var_type type) { return 0; }
714
690
bool update(THD *thd, set_var *var);
715
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
691
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
716
692
virtual void set_default(THD *thd, enum_var_type type)= 0;
717
virtual const CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
693
virtual CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
720
696
class sys_var_character_set_sv :public sys_var_character_set
722
const CHARSET_INFO *SV::*offset;
723
const CHARSET_INFO **global_default;
698
CHARSET_INFO *SV::*offset;
699
CHARSET_INFO **global_default;
725
701
sys_var_character_set_sv(sys_var_chain *chain, const char *name_arg,
726
const CHARSET_INFO *SV::*offset_arg,
727
const CHARSET_INFO **global_default_arg,
702
CHARSET_INFO *SV::*offset_arg,
703
CHARSET_INFO **global_default_arg,
728
704
bool is_nullable= 0,
729
705
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
730
706
: sys_var_character_set(name_arg, is_nullable, binlog_status_arg),
731
707
offset(offset_arg), global_default(global_default_arg)
732
708
{ chain_sys_var(chain); }
733
709
void set_default(THD *thd, enum_var_type type);
734
const CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
710
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
741
717
sys_var_character_set_client(sys_var_chain *chain, const char *name_arg,
742
const CHARSET_INFO *SV::*offset_arg,
743
const CHARSET_INFO **global_default_arg,
718
CHARSET_INFO *SV::*offset_arg,
719
CHARSET_INFO **global_default_arg,
744
720
Binlog_status_enum binlog_status_arg)
745
721
: sys_var_character_set_sv(chain, name_arg, offset_arg, global_default_arg,
746
722
0, binlog_status_arg)
758
734
: sys_var_character_set(name_arg, 0, binlog_status_arg)
759
735
{ chain_sys_var(chain); }
760
736
void set_default(THD *thd, enum_var_type type);
761
const CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
737
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
764
740
class sys_var_collation_sv :public sys_var_collation
766
const CHARSET_INFO *SV::*offset;
767
const CHARSET_INFO **global_default;
742
CHARSET_INFO *SV::*offset;
743
CHARSET_INFO **global_default;
769
745
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,
746
CHARSET_INFO *SV::*offset_arg,
747
CHARSET_INFO **global_default_arg,
772
748
Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
773
749
:sys_var_collation(name_arg, binlog_status_arg),
774
750
offset(offset_arg), global_default(global_default_arg)
778
754
bool update(THD *thd, set_var *var);
779
755
void set_default(THD *thd, enum_var_type type);
780
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
756
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
790
766
size_t offset_arg)
791
767
:sys_var(name_arg), offset(offset_arg)
792
768
{ chain_sys_var(chain); }
793
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
794
bool check_default(enum_var_type type __attribute__((unused)))
769
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
770
bool check_default(enum_var_type type) { return 1; }
796
771
bool is_struct() { return 1; }
823
798
class sys_var_thd_date_time_format :public sys_var_thd
825
800
DATE_TIME_FORMAT *SV::*offset;
826
enum enum_drizzle_timestamp_type date_time_type;
801
timestamp_type date_time_type;
828
803
sys_var_thd_date_time_format(sys_var_chain *chain, const char *name_arg,
829
804
DATE_TIME_FORMAT *SV::*offset_arg,
830
enum enum_drizzle_timestamp_type date_time_type_arg)
805
timestamp_type date_time_type_arg)
831
806
:sys_var_thd(name_arg), offset(offset_arg),
832
807
date_time_type(date_time_type_arg)
833
808
{ chain_sys_var(chain); }
837
812
return type != STRING_RESULT; /* Only accept strings */
839
bool check_default(enum_var_type type __attribute__((unused)))
814
bool check_default(enum_var_type type) { return 0; }
841
815
bool check(THD *thd, set_var *var);
842
816
bool update(THD *thd, set_var *var);
843
817
void update2(THD *thd, enum_var_type type, DATE_TIME_FORMAT *new_value);
844
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
818
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
845
819
void set_default(THD *thd, enum_var_type type);
849
823
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)
827
sys_var_log_state(sys_var_chain *chain, const char *name_arg, my_bool *value_arg,
855
829
:sys_var_bool_ptr(chain, name_arg, value_arg), log_type(log_type_arg) {}
856
830
bool update(THD *thd, set_var *var);
857
831
void set_default(THD *thd, enum_var_type type);
873
847
return check_set(thd, var, enum_names);
875
virtual void set_default(THD *thd __attribute__((unused)),
876
enum_var_type type __attribute__((unused)))
849
virtual void set_default(THD *thd, enum_var_type type)
880
853
bool update(THD *thd, set_var *var);
881
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
882
bool check_update_type(Item_result type __attribute__((unused)))
854
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
855
bool check_update_type(Item_result type) { return 0; }
884
856
SHOW_TYPE show_type() { return SHOW_CHAR; }
906
878
:sys_var(name_arg,func), value(value_arg), enum_names(typelib)
908
880
chain_sys_var(chain);
909
set_allow_empty_value(false);
881
set_allow_empty_value(FALSE);
911
883
virtual bool check(THD *thd, set_var *var)
913
885
return check_set(thd, var, enum_names);
915
887
bool update(THD *thd, set_var *var);
916
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
917
bool check_update_type(Item_result type __attribute__((unused)))
888
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
889
bool check_update_type(Item_result type) { return 0; }
919
890
void set_default(THD *thd, enum_var_type type);
920
891
SHOW_TYPE show_type() { return SHOW_CHAR; }
935
906
:sys_var(name_arg), var_type(type),
936
907
show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
937
908
{ chain_sys_var(chain); }
938
bool update(THD *thd __attribute__((unused)),
939
set_var *var __attribute__((unused)))
941
bool check_default(enum_var_type type __attribute__((unused)))
909
bool update(THD *thd, set_var *var) { return 1; }
910
bool check_default(enum_var_type type) { return 1; }
943
911
bool check_type(enum_var_type type) { return type != var_type; }
944
bool check_update_type(Item_result type __attribute__((unused)))
946
unsigned char *value_ptr(THD *thd, enum_var_type type __attribute__((unused)),
947
LEX_STRING *base __attribute__((unused)))
912
bool check_update_type(Item_result type) { return 1; }
913
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
949
915
return (*value_ptr_func)(thd);
951
SHOW_TYPE show_type(void) { return show_type_value; }
952
bool is_readonly(void) const { return 1; }
917
SHOW_TYPE show_type() { return show_type_value; }
918
bool is_readonly() const { return 1; }
961
927
sys_var_have_option(sys_var_chain *chain, const char *variable_name):
962
928
sys_var(variable_name)
963
929
{ chain_sys_var(chain); }
964
unsigned char *value_ptr(THD *thd __attribute__((unused)),
965
enum_var_type type __attribute__((unused)),
966
LEX_STRING *base __attribute__((unused)))
930
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
968
return (unsigned char*) show_comp_option_name[get_option()];
932
return (uchar*) show_comp_option_name[get_option()];
970
bool update(THD *thd __attribute__((unused)),
971
set_var *var __attribute__((unused))) { return 1; }
972
bool check_default(enum_var_type type __attribute__((unused)))
934
bool update(THD *thd, set_var *var) { return 1; }
935
bool check_default(enum_var_type type) { return 1; }
974
936
bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
975
bool check_update_type(Item_result type __attribute__((unused)))
937
bool check_update_type(Item_result type) { return 1; }
977
938
SHOW_TYPE show_type() { return SHOW_CHAR; }
978
939
bool is_readonly() const { return 1; }
996
957
class sys_var_have_plugin: public sys_var_have_option
998
959
const char *plugin_name_str;
999
const uint32_t plugin_name_len;
960
const uint plugin_name_len;
1000
961
const int plugin_type;
1003
964
sys_var_have_plugin(sys_var_chain *chain, const char *variable_name,
1004
const char *plugin_name_str_arg, uint32_t plugin_name_len_arg,
965
const char *plugin_name_str_arg, uint plugin_name_len_arg,
1005
966
int plugin_type_arg):
1006
967
sys_var_have_option(chain, variable_name),
1007
968
plugin_name_str(plugin_name_str_arg), plugin_name_len(plugin_name_len_arg),
1029
990
return type != STRING_RESULT; /* Only accept strings */
1031
bool check_default(enum_var_type type __attribute__((unused)))
992
bool check_default(enum_var_type type) { return 0; }
1033
993
bool update(THD *thd, set_var *var);
1034
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
994
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1035
995
virtual void set_default(THD *thd, enum_var_type type);
1051
1011
void set_default(THD *thd, enum_var_type type);
1052
1012
SHOW_TYPE show_type() { return SHOW_INT; }
1053
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1013
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1057
1017
class sys_var_microseconds :public sys_var_thd
1059
uint64_t SV::*offset;
1019
ulonglong SV::*offset;
1061
1021
sys_var_microseconds(sys_var_chain *chain, const char *name_arg,
1062
uint64_t SV::*offset_arg):
1022
ulonglong SV::*offset_arg):
1063
1023
sys_var_thd(name_arg), offset(offset_arg)
1064
1024
{ chain_sys_var(chain); }
1065
bool check(THD *thd __attribute__((unused)),
1066
set_var *var __attribute__((unused))) {return 0;}
1025
bool check(THD *thd, set_var *var) {return 0;}
1067
1026
bool update(THD *thd, set_var *var);
1068
1027
void set_default(THD *thd, enum_var_type type);
1069
1028
SHOW_TYPE show_type() { return SHOW_DOUBLE; }
1072
1031
return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
1074
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1033
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1037
class sys_var_trust_routine_creators :public sys_var_bool_ptr
1039
/* We need a derived class only to have a warn_deprecated() */
1041
sys_var_trust_routine_creators(sys_var_chain *chain,
1042
const char *name_arg, my_bool *value_arg) :
1043
sys_var_bool_ptr(chain, name_arg, value_arg) {};
1044
void warn_deprecated(THD *thd);
1045
void set_default(THD *thd, enum_var_type type);
1046
bool update(THD *thd, set_var *var);
1084
1056
sys_var_opt_readonly(sys_var_chain *chain, const char *name_arg,
1057
my_bool *value_arg) :
1086
1058
sys_var_bool_ptr(chain, name_arg, value_arg) {};
1087
1059
~sys_var_opt_readonly() {};
1088
1060
bool update(THD *thd, set_var *var);
1108
1080
return ((type != STRING_RESULT) && (type != INT_RESULT));
1110
bool check_default(enum_var_type type __attribute__((unused)))
1082
bool check_default(enum_var_type type) { return 0; }
1112
1083
bool update(THD *thd, set_var *var);
1113
unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1084
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1114
1085
virtual void set_default(THD *thd, enum_var_type type);
1208
1179
class set_var_collation_client: public set_var_base
1210
const CHARSET_INFO *character_set_client;
1211
const CHARSET_INFO *character_set_results;
1212
const CHARSET_INFO *collation_connection;
1181
CHARSET_INFO *character_set_client;
1182
CHARSET_INFO *character_set_results;
1183
CHARSET_INFO *collation_connection;
1214
set_var_collation_client(const CHARSET_INFO * const client_coll_arg,
1215
const CHARSET_INFO * const connection_coll_arg,
1216
const CHARSET_INFO * const result_coll_arg)
1185
set_var_collation_client(CHARSET_INFO *client_coll_arg,
1186
CHARSET_INFO *connection_coll_arg,
1187
CHARSET_INFO *result_coll_arg)
1217
1188
:character_set_client(client_coll_arg),
1218
1189
character_set_results(result_coll_arg),
1219
1190
collation_connection(connection_coll_arg)
1233
1204
class NAMED_LIST :public ilink
1235
1206
const char *name;
1236
uint32_t name_length;
1238
unsigned char* data;
1240
1211
NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg,
1241
uint32_t name_length_arg, unsigned char* data_arg)
1212
uint name_length_arg, uchar* data_arg)
1242
1213
:name_length(name_length_arg), data(data_arg)
1244
1215
name= my_strndup(name_arg, name_length, MYF(MY_WME));
1245
1216
links->push_back(this);
1247
inline bool cmp(const char *name_cmp, uint32_t length)
1218
inline bool cmp(const char *name_cmp, uint length)
1249
1220
return length == name_length && !memcmp(name, name_cmp, length);
1253
free((unsigned char*) name);
1224
my_free((uchar*) name, MYF(0));
1255
1226
friend bool process_key_caches(process_key_cache_t func);
1256
1227
friend void delete_elements(I_List<NAMED_LIST> *list,
1257
void (*free_element)(const char*, unsigned char*));
1228
void (*free_element)(const char*, uchar*));
1260
1231
/* updated in sql_acl.cc */
1262
1233
extern sys_var_thd_bool sys_old_alter_table;
1234
extern sys_var_thd_bool sys_old_passwords;
1263
1235
extern LEX_STRING default_key_cache_base;
1265
1237
/* For sql_yacc */
1276
1248
int set_var_init();
1277
1249
void set_var_free();
1278
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count);
1250
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count);
1279
1251
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted);
1280
1252
int mysql_add_sys_var_chain(sys_var *chain, struct my_option *long_options);
1281
1253
int mysql_del_sys_var_chain(sys_var *chain);
1282
sys_var *find_sys_var(THD *thd, const char *str, uint32_t length=0);
1254
sys_var *find_sys_var(THD *thd, const char *str, uint length=0);
1283
1255
int sql_set_variables(THD *thd, List<set_var_base> *var_list);
1284
1256
bool not_all_support_one_shot(List<set_var_base> *var_list);
1285
1257
void fix_delay_key_write(THD *thd, enum_var_type type);
1286
1258
void fix_slave_exec_mode(enum_var_type type);
1259
ulong fix_sql_mode(ulong sql_mode);
1287
1260
extern sys_var_const_str sys_charset_system;
1288
1261
extern sys_var_str sys_init_connect;
1289
1262
extern sys_var_str sys_init_slave;
1290
1263
extern sys_var_thd_time_zone sys_time_zone;
1291
1264
extern sys_var_thd_bit sys_autocommit;
1292
const CHARSET_INFO *get_old_charset_by_name(const char *old_name);
1293
unsigned char* find_named(I_List<NAMED_LIST> *list, const char *name, uint32_t length,
1265
CHARSET_INFO *get_old_charset_by_name(const char *old_name);
1266
uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
1294
1267
NAMED_LIST **found);
1296
1269
extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
1298
1271
/* key_cache functions */
1299
1272
KEY_CACHE *get_key_cache(LEX_STRING *cache_name);
1300
KEY_CACHE *get_or_create_key_cache(const char *name, uint32_t length);
1273
KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
1301
1274
void free_key_cache(const char *name, KEY_CACHE *key_cache);
1302
1275
bool process_key_caches(process_key_cache_t func);
1303
1276
void delete_elements(I_List<NAMED_LIST> *list,
1304
void (*free_element)(const char*, unsigned char*));
1277
void (*free_element)(const char*, uchar*));