~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/set_var.h

  • Committer: Brian Aker
  • Date: 2008-07-14 03:04:13 UTC
  • mfrom: (77.1.90 codestyle)
  • Revision ID: brian@tangent.org-20080714030413-dpv6opb0eoy1rd3f
Merging Monty's code, I did remove error on compile though (since it does
not currently work because of sql_plugin.cc)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
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.
9
 
 *
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.
14
 
 *
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
18
 
 */
 
1
/* Copyright (C) 2002-2006 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
19
15
 
20
16
/* Classes to support the SET command */
21
17
 
 
18
#ifdef USE_PRAGMA_INTERFACE
 
19
#pragma interface                       /* gcc class implementation */
 
20
#endif
22
21
 
23
22
/****************************************************************************
24
23
  Variables that are changable runtime are declared using the
38
37
typedef bool (*sys_update_func)(THD *, set_var *);
39
38
typedef void (*sys_after_update_func)(THD *,enum_var_type);
40
39
typedef void (*sys_set_default_func)(THD *, enum_var_type);
41
 
typedef unsigned char *(*sys_value_ptr_func)(THD *thd);
 
40
typedef uchar *(*sys_value_ptr_func)(THD *thd);
42
41
 
43
42
struct sys_var_chain
44
43
{
67
66
 
68
67
  sys_var *next;
69
68
  struct my_option *option_limits;      /* Updated by by set_var_init() */
70
 
  uint32_t name_length;                 /* Updated by by set_var_init() */
 
69
  uint name_length;                     /* Updated by by set_var_init() */
71
70
  const char *name;
72
71
 
73
72
  sys_after_update_func after_update;
96
95
      (binlog_status == SESSION_VARIABLE_IN_BINLOG);
97
96
  }
98
97
  virtual bool update(THD *thd, set_var *var)=0;
99
 
  virtual void set_default(THD *thd_arg __attribute__((unused)),
100
 
                           enum_var_type type __attribute__((unused)))
 
98
  virtual void set_default(THD *thd_arg __attribute__((__unused__)),
 
99
                           enum_var_type type __attribute__((__unused__)))
101
100
  {}
102
101
  virtual SHOW_TYPE show_type() { return SHOW_UNDEF; }
103
 
  virtual unsigned char *value_ptr(THD *thd __attribute__((unused)),
104
 
                           enum_var_type type __attribute__((unused)),
105
 
                           LEX_STRING *base __attribute__((unused)))
 
102
  virtual uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
103
                           enum_var_type type __attribute__((__unused__)),
 
104
                           LEX_STRING *base __attribute__((__unused__)))
106
105
  { return 0; }
107
106
  virtual bool check_type(enum_var_type type)
108
107
  { return type != OPT_GLOBAL; }                /* Error if not GLOBAL */
109
108
  virtual bool check_update_type(Item_result type)
110
109
  { return type != INT_RESULT; }                /* Assume INT */
111
 
  virtual bool check_default(enum_var_type type __attribute__((unused)))
 
110
  virtual bool check_default(enum_var_type type __attribute__((__unused__)))
112
111
  { return option_limits == 0; }
113
112
  Item *item(THD *thd, enum_var_type type, LEX_STRING *base);
114
113
  virtual bool is_struct() { return 0; }
164
163
  bool update(THD *thd, set_var *var);
165
164
  void set_default(THD *thd, enum_var_type type);
166
165
  SHOW_TYPE show_type() { return SHOW_LONG; }
167
 
  unsigned char *value_ptr(THD *thd __attribute__((unused)),
168
 
                   enum_var_type type __attribute__((unused)),
169
 
                   LEX_STRING *base __attribute__((unused)))
170
 
  { return (unsigned char*) value; }
 
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; }
171
170
};
172
171
 
173
172
 
197
196
  bool update(THD *thd, set_var *var);
198
197
  void set_default(THD *thd, enum_var_type type);
199
198
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
200
 
  unsigned char *value_ptr(THD *thd __attribute__((unused)),
201
 
                   enum_var_type type __attribute__((unused)),
202
 
                   LEX_STRING *base __attribute__((unused)))
203
 
  { return (unsigned char*) value; }
 
199
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
200
                   enum_var_type type __attribute__((__unused__)),
 
201
                   LEX_STRING *base __attribute__((__unused__)))
 
202
  { return (uchar*) value; }
204
203
};
205
204
 
206
205
 
218
217
  bool update(THD *thd, set_var *var);
219
218
  void set_default(THD *thd, enum_var_type type);
220
219
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
221
 
  unsigned char *value_ptr(THD *thd __attribute__((unused)),
222
 
                   enum_var_type type __attribute__((unused)),
223
 
                   LEX_STRING *base __attribute__((unused)))
224
 
  { return (unsigned char*) value; }
225
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
220
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
221
                   enum_var_type type __attribute__((__unused__)),
 
222
                   LEX_STRING *base __attribute__((__unused__)))
 
223
  { return (uchar*) value; }
 
224
  bool check_update_type(Item_result type __attribute__((__unused__)))
226
225
  { return 0; }
227
226
};
228
227
 
241
240
{
242
241
public:
243
242
  char *value;                                  // Pointer to allocated string
244
 
  uint32_t value_length;
 
243
  uint value_length;
245
244
  sys_check_func check_func;
246
245
  sys_update_func update_func;
247
246
  sys_set_default_func set_default_func;
263
262
    (*set_default_func)(thd, type);
264
263
  }
265
264
  SHOW_TYPE show_type() { return SHOW_CHAR; }
266
 
  unsigned char *value_ptr(THD *thd __attribute__((unused)),
267
 
                   enum_var_type type __attribute__((unused)),
268
 
                   LEX_STRING *base __attribute__((unused)))
269
 
  { return (unsigned char*) value; }
 
265
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
266
                   enum_var_type type __attribute__((__unused__)),
 
267
                   LEX_STRING *base __attribute__((__unused__)))
 
268
  { return (uchar*) value; }
270
269
  bool check_update_type(Item_result type)
271
270
  {
272
271
    return type != STRING_RESULT;               /* Only accept strings */
273
272
  }
274
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
273
  bool check_default(enum_var_type type __attribute__((__unused__)))
275
274
  { return 0; }
276
275
};
277
276
 
288
287
  {
289
288
    value= new_value;
290
289
  }
291
 
  bool check(THD *thd __attribute__((unused)),
292
 
             set_var *var __attribute__((unused)))
 
290
  bool check(THD *thd __attribute__((__unused__)),
 
291
             set_var *var __attribute__((__unused__)))
293
292
  {
294
293
    return 1;
295
294
  }
296
 
  bool update(THD *thd __attribute__((unused)),
297
 
              set_var *var __attribute__((unused)))
 
295
  bool update(THD *thd __attribute__((__unused__)),
 
296
              set_var *var __attribute__((__unused__)))
298
297
  {
299
298
    return 1;
300
299
  }
301
300
  SHOW_TYPE show_type() { return SHOW_CHAR; }
302
 
  unsigned char *value_ptr(THD *thd __attribute__((unused)),
303
 
                   enum_var_type type __attribute__((unused)),
304
 
                   LEX_STRING *base __attribute__((unused)))
 
301
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
302
                   enum_var_type type __attribute__((__unused__)),
 
303
                   LEX_STRING *base __attribute__((__unused__)))
305
304
  {
306
 
    return (unsigned char*) value;
 
305
    return (uchar*) value;
307
306
  }
308
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
307
  bool check_update_type(Item_result type __attribute__((__unused__)))
309
308
  {
310
309
    return 1;
311
310
  }
312
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
311
  bool check_default(enum_var_type type __attribute__((__unused__)))
313
312
  { return 1; }
314
313
  bool is_readonly() const { return 1; }
315
314
};
322
321
  sys_var_const_str_ptr(sys_var_chain *chain, const char *name_arg, char **value_arg)
323
322
    :sys_var(name_arg),value(value_arg)
324
323
  { chain_sys_var(chain); }
325
 
  bool check(THD *thd __attribute__((unused)),
326
 
             set_var *var __attribute__((unused)))
 
324
  bool check(THD *thd __attribute__((__unused__)),
 
325
             set_var *var __attribute__((__unused__)))
327
326
  {
328
327
    return 1;
329
328
  }
330
 
  bool update(THD *thd __attribute__((unused)),
331
 
              set_var *var __attribute__((unused)))
 
329
  bool update(THD *thd __attribute__((__unused__)),
 
330
              set_var *var __attribute__((__unused__)))
332
331
  {
333
332
    return 1;
334
333
  }
335
334
  SHOW_TYPE show_type() { return SHOW_CHAR; }
336
 
  unsigned char *value_ptr(THD *thd __attribute__((unused)),
337
 
                   enum_var_type type __attribute__((unused)),
338
 
                   LEX_STRING *base __attribute__((unused)))
 
335
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
336
                   enum_var_type type __attribute__((__unused__)),
 
337
                   LEX_STRING *base __attribute__((__unused__)))
339
338
  {
340
 
    return (unsigned char*) *value;
 
339
    return (uchar*) *value;
341
340
  }
342
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
341
  bool check_update_type(Item_result type __attribute__((__unused__)))
343
342
  {
344
343
    return 1;
345
344
  }
346
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
345
  bool check_default(enum_var_type type __attribute__((__unused__)))
347
346
  { return 1; }
348
347
  bool is_readonly(void) const { return 1; }
349
348
};
351
350
 
352
351
class sys_var_enum :public sys_var
353
352
{
354
 
  uint32_t *value;
 
353
  uint *value;
355
354
  TYPELIB *enum_names;
356
355
public:
357
 
  sys_var_enum(sys_var_chain *chain, const char *name_arg, uint32_t *value_arg,
 
356
  sys_var_enum(sys_var_chain *chain, const char *name_arg, uint *value_arg,
358
357
               TYPELIB *typelib, sys_after_update_func func)
359
358
    :sys_var(name_arg,func), value(value_arg), enum_names(typelib)
360
359
  { chain_sys_var(chain); }
364
363
  }
365
364
  bool update(THD *thd, set_var *var);
366
365
  SHOW_TYPE show_type() { return SHOW_CHAR; }
367
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
368
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
366
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
367
  bool check_update_type(Item_result type __attribute__((__unused__)))
369
368
  { return 0; }
370
369
};
371
370
 
379
378
      TYPELIB *typelib, sys_after_update_func func)
380
379
    :sys_var(name_arg,func), offset(offset_arg), enum_names(typelib)
381
380
  { chain_sys_var(chain); }
382
 
  bool check(THD *thd __attribute__((unused)),
383
 
             set_var *var __attribute__((unused)))
 
381
  bool check(THD *thd __attribute__((__unused__)),
 
382
             set_var *var __attribute__((__unused__)))
384
383
  { return 1; }
385
 
  bool update(THD *thd __attribute__((unused)),
386
 
              set_var *var __attribute__((unused)))
 
384
  bool update(THD *thd __attribute__((__unused__)),
 
385
              set_var *var __attribute__((__unused__)))
387
386
  { return 1; }
388
387
  SHOW_TYPE show_type() { return SHOW_CHAR; }
389
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
388
  bool check_update_type(Item_result type __attribute__((__unused__)))
390
389
  { return 1; }
391
390
  bool is_readonly() const { return 1; }
392
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
391
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
393
392
};
394
393
 
395
394
 
401
400
              Binlog_status_enum binlog_status= NOT_IN_BINLOG)
402
401
    :sys_var(name_arg, func, binlog_status)
403
402
  {}
404
 
  bool check_type(enum_var_type type __attribute__((unused)))
 
403
  bool check_type(enum_var_type type __attribute__((__unused__)))
405
404
  { return 0; }
406
405
  bool check_default(enum_var_type type)
407
406
  {
427
426
  bool update(THD *thd, set_var *var);
428
427
  void set_default(THD *thd, enum_var_type type);
429
428
  SHOW_TYPE show_type() { return SHOW_LONG; }
430
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
429
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
431
430
};
432
431
 
433
432
 
447
446
  bool update(THD *thd, set_var *var);
448
447
  void set_default(THD *thd, enum_var_type type);
449
448
  SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
450
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
449
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
451
450
};
452
451
 
453
452
 
469
468
  bool update(THD *thd, set_var *var);
470
469
  void set_default(THD *thd, enum_var_type type);
471
470
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
472
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
471
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
473
472
  bool check(THD *thd, set_var *var);
474
473
  bool check_default(enum_var_type type)
475
474
  {
485
484
class sys_var_thd_bool :public sys_var_thd
486
485
{
487
486
public:
488
 
  bool SV::*offset;
489
 
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
 
487
  my_bool SV::*offset;
 
488
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg)
490
489
    :sys_var_thd(name_arg), offset(offset_arg)
491
490
  { chain_sys_var(chain); }
492
 
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
 
491
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg,
493
492
                   sys_after_update_func func)
494
493
    :sys_var_thd(name_arg,func), offset(offset_arg)
495
494
  { chain_sys_var(chain); }
496
495
  bool update(THD *thd, set_var *var);
497
496
  void set_default(THD *thd, enum_var_type type);
498
497
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
499
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
498
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
500
499
  bool check(THD *thd, set_var *var)
501
500
  {
502
501
    return check_enum(thd, var, &bool_typelib);
503
502
  }
504
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
503
  bool check_update_type(Item_result type __attribute__((__unused__)))
505
504
  { return 0; }
506
505
};
507
506
 
530
529
  bool update(THD *thd, set_var *var);
531
530
  void set_default(THD *thd, enum_var_type type);
532
531
  SHOW_TYPE show_type() { return SHOW_CHAR; }
533
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
534
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
532
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
533
  bool check_update_type(Item_result type __attribute__((__unused__)))
535
534
  { return 0; }
536
535
};
537
536
 
549
548
    return check_set(thd, var, enum_names);
550
549
  }
551
550
  void set_default(THD *thd, enum_var_type type);
552
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
551
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
553
552
  static bool symbolic_mode_representation(THD *thd, uint64_t sql_mode,
554
553
                                           LEX_STRING *rep);
555
554
};
572
571
  }
573
572
  void set_default(THD *thd, enum_var_type type);
574
573
  bool update(THD *thd, set_var *var);
575
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
574
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
576
575
};
577
576
 
578
577
class sys_var_thd_bit :public sys_var_thd
591
590
  { chain_sys_var(chain); }
592
591
  bool check(THD *thd, set_var *var);
593
592
  bool update(THD *thd, set_var *var);
594
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
593
  bool check_update_type(Item_result type __attribute__((__unused__)))
595
594
  { return 0; }
596
595
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
597
596
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
598
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
597
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
599
598
};
600
599
 
601
600
/* some variables that require special handling */
610
609
  bool update(THD *thd, set_var *var);
611
610
  void set_default(THD *thd, enum_var_type type);
612
611
  bool check_type(enum_var_type type)    { return type == OPT_GLOBAL; }
613
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
612
  bool check_default(enum_var_type type __attribute__((__unused__)))
614
613
  { return 0; }
615
614
  SHOW_TYPE show_type(void) { return SHOW_LONG; }
616
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
615
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
617
616
};
618
617
 
619
618
 
627
626
  bool update(THD *thd, set_var *var);
628
627
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
629
628
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
630
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
629
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
631
630
};
632
631
 
633
632
 
640
639
  bool update(THD *thd, set_var *var);
641
640
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
642
641
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
643
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
642
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
644
643
};
645
644
 
646
645
 
682
681
  {
683
682
    return ((type != STRING_RESULT) && (type != INT_RESULT));
684
683
  }
685
 
  bool check_default(enum_var_type type __attribute__((unused))) { return 0; }
 
684
  bool check_default(enum_var_type type __attribute__((__unused__))) { return 0; }
686
685
  virtual void set_default(THD *thd, enum_var_type type)= 0;
687
686
};
688
687
 
706
705
  {
707
706
    return ((type != STRING_RESULT) && (type != INT_RESULT));
708
707
  }
709
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
708
  bool check_default(enum_var_type type __attribute__((__unused__)))
710
709
  { return 0; }
711
710
  bool update(THD *thd, set_var *var);
712
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
711
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
713
712
  virtual void set_default(THD *thd, enum_var_type type)= 0;
714
 
  virtual const CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
 
713
  virtual CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
 
714
};
 
715
 
 
716
class sys_var_character_set_sv :public sys_var_character_set
 
717
{
 
718
  CHARSET_INFO *SV::*offset;
 
719
  CHARSET_INFO **global_default;
 
720
public:
 
721
  sys_var_character_set_sv(sys_var_chain *chain, const char *name_arg,
 
722
                           CHARSET_INFO *SV::*offset_arg,
 
723
                           CHARSET_INFO **global_default_arg,
 
724
                           bool is_nullable= 0,
 
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
  CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
 
731
};
 
732
 
 
733
 
 
734
class sys_var_character_set_client: public sys_var_character_set_sv
 
735
{
 
736
public:
 
737
  sys_var_character_set_client(sys_var_chain *chain, const char *name_arg,
 
738
                               CHARSET_INFO *SV::*offset_arg,
 
739
                               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)
 
743
  { }
 
744
  bool check(THD *thd, set_var *var);
 
745
};
 
746
 
 
747
 
 
748
class sys_var_character_set_database :public sys_var_character_set
 
749
{
 
750
public:
 
751
  sys_var_character_set_database(sys_var_chain *chain, const char *name_arg,
 
752
                                 Binlog_status_enum binlog_status_arg=
 
753
                                   NOT_IN_BINLOG)
 
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
  CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
715
758
};
716
759
 
717
760
class sys_var_collation_sv :public sys_var_collation
718
761
{
719
 
  const CHARSET_INFO *SV::*offset;
720
 
  const CHARSET_INFO **global_default;
 
762
  CHARSET_INFO *SV::*offset;
 
763
  CHARSET_INFO **global_default;
721
764
public:
722
765
  sys_var_collation_sv(sys_var_chain *chain, const char *name_arg,
723
 
                       const CHARSET_INFO *SV::*offset_arg,
724
 
                       const CHARSET_INFO **global_default_arg,
 
766
                       CHARSET_INFO *SV::*offset_arg,
 
767
                       CHARSET_INFO **global_default_arg,
725
768
                       Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
726
769
    :sys_var_collation(name_arg, binlog_status_arg),
727
770
    offset(offset_arg), global_default(global_default_arg)
730
773
  }
731
774
  bool update(THD *thd, set_var *var);
732
775
  void set_default(THD *thd, enum_var_type type);
733
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
776
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
734
777
};
735
778
 
736
779
 
743
786
                          size_t offset_arg)
744
787
    :sys_var(name_arg), offset(offset_arg)
745
788
  { chain_sys_var(chain); }
746
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
747
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
789
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
790
  bool check_default(enum_var_type type __attribute__((__unused__)))
748
791
  { return 1; }
749
792
  bool is_struct() { return 1; }
750
793
};
776
819
class sys_var_thd_date_time_format :public sys_var_thd
777
820
{
778
821
  DATE_TIME_FORMAT *SV::*offset;
779
 
  enum enum_drizzle_timestamp_type date_time_type;
 
822
  timestamp_type date_time_type;
780
823
public:
781
824
  sys_var_thd_date_time_format(sys_var_chain *chain, const char *name_arg,
782
825
                               DATE_TIME_FORMAT *SV::*offset_arg,
783
 
                               enum enum_drizzle_timestamp_type date_time_type_arg)
 
826
                               timestamp_type date_time_type_arg)
784
827
    :sys_var_thd(name_arg), offset(offset_arg),
785
828
    date_time_type(date_time_type_arg)
786
829
  { chain_sys_var(chain); }
789
832
  {
790
833
    return type != STRING_RESULT;               /* Only accept strings */
791
834
  }
792
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
835
  bool check_default(enum_var_type type __attribute__((__unused__)))
793
836
  { return 0; }
794
837
  bool check(THD *thd, set_var *var);
795
838
  bool update(THD *thd, set_var *var);
796
839
  void update2(THD *thd, enum_var_type type, DATE_TIME_FORMAT *new_value);
797
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
840
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
798
841
  void set_default(THD *thd, enum_var_type type);
799
842
};
800
843
 
801
844
 
802
845
class sys_var_log_state :public sys_var_bool_ptr
803
846
{
804
 
  uint32_t log_type;
 
847
  uint log_type;
805
848
public:
806
849
  sys_var_log_state(sys_var_chain *chain, const char *name_arg, bool *value_arg, 
807
 
                    uint32_t log_type_arg)
 
850
                    uint log_type_arg)
808
851
    :sys_var_bool_ptr(chain, name_arg, value_arg), log_type(log_type_arg) {}
809
852
  bool update(THD *thd, set_var *var);
810
853
  void set_default(THD *thd, enum_var_type type);
825
868
  {
826
869
    return check_set(thd, var, enum_names);
827
870
  }
828
 
  virtual void set_default(THD *thd __attribute__((unused)),
829
 
                           enum_var_type type __attribute__((unused)))
 
871
  virtual void set_default(THD *thd __attribute__((__unused__)),
 
872
                           enum_var_type type __attribute__((__unused__)))
830
873
  {
831
874
    *value= 0;
832
875
  }
833
876
  bool update(THD *thd, set_var *var);
834
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
835
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
877
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
878
  bool check_update_type(Item_result type __attribute__((__unused__)))
836
879
  { return 0; }
837
880
  SHOW_TYPE show_type() { return SHOW_CHAR; }
838
881
};
866
909
    return check_set(thd, var, enum_names);
867
910
  }
868
911
  bool update(THD *thd, set_var *var);
869
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
870
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
912
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
913
  bool check_update_type(Item_result type __attribute__((__unused__)))
871
914
  { return 0; }
872
915
  void set_default(THD *thd, enum_var_type type);
873
916
  SHOW_TYPE show_type() { return SHOW_CHAR; }
888
931
    :sys_var(name_arg), var_type(type), 
889
932
       show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
890
933
  { chain_sys_var(chain); }
891
 
  bool update(THD *thd __attribute__((unused)),
892
 
              set_var *var __attribute__((unused)))
 
934
  bool update(THD *thd __attribute__((__unused__)),
 
935
              set_var *var __attribute__((__unused__)))
893
936
  { return 1; }
894
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
937
  bool check_default(enum_var_type type __attribute__((__unused__)))
895
938
  { return 1; }
896
939
  bool check_type(enum_var_type type) { return type != var_type; }
897
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
940
  bool check_update_type(Item_result type __attribute__((__unused__)))
898
941
  { return 1; }
899
 
  unsigned char *value_ptr(THD *thd, enum_var_type type __attribute__((unused)),
900
 
                   LEX_STRING *base __attribute__((unused)))
 
942
  uchar *value_ptr(THD *thd, enum_var_type type __attribute__((__unused__)),
 
943
                   LEX_STRING *base __attribute__((__unused__)))
901
944
  {
902
945
    return (*value_ptr_func)(thd);
903
946
  }
914
957
  sys_var_have_option(sys_var_chain *chain, const char *variable_name):
915
958
    sys_var(variable_name)
916
959
  { chain_sys_var(chain); }
917
 
  unsigned char *value_ptr(THD *thd __attribute__((unused)),
918
 
                   enum_var_type type __attribute__((unused)),
919
 
                   LEX_STRING *base __attribute__((unused)))
 
960
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
961
                   enum_var_type type __attribute__((__unused__)),
 
962
                   LEX_STRING *base __attribute__((__unused__)))
920
963
  {
921
 
    return (unsigned char*) show_comp_option_name[get_option()];
 
964
    return (uchar*) show_comp_option_name[get_option()];
922
965
  }
923
 
  bool update(THD *thd __attribute__((unused)),
924
 
              set_var *var __attribute__((unused))) { return 1; }
925
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
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__)))
926
969
  { return 1; }
927
970
  bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
928
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
971
  bool check_update_type(Item_result type __attribute__((__unused__)))
929
972
  { return 1; }
930
973
  SHOW_TYPE show_type() { return SHOW_CHAR; }
931
974
  bool is_readonly() const { return 1; }
949
992
class sys_var_have_plugin: public sys_var_have_option
950
993
{
951
994
  const char *plugin_name_str;
952
 
  const uint32_t plugin_name_len;
 
995
  const uint plugin_name_len;
953
996
  const int plugin_type;
954
997
 
955
998
public:
956
999
  sys_var_have_plugin(sys_var_chain *chain, const char *variable_name,
957
 
                      const char *plugin_name_str_arg, uint32_t plugin_name_len_arg, 
 
1000
                      const char *plugin_name_str_arg, uint plugin_name_len_arg, 
958
1001
                      int plugin_type_arg):
959
1002
    sys_var_have_option(chain, variable_name), 
960
1003
    plugin_name_str(plugin_name_str_arg), plugin_name_len(plugin_name_len_arg),
981
1024
  {
982
1025
    return type != STRING_RESULT;               /* Only accept strings */
983
1026
  }
984
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
1027
  bool check_default(enum_var_type type __attribute__((__unused__)))
985
1028
  { return 0; }
986
1029
  bool update(THD *thd, set_var *var);
987
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1030
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
988
1031
  virtual void set_default(THD *thd, enum_var_type type);
989
1032
};
990
1033
 
1003
1046
  }
1004
1047
  void set_default(THD *thd, enum_var_type type);
1005
1048
  SHOW_TYPE show_type() { return SHOW_INT; }
1006
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1049
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1007
1050
};
1008
1051
 
1009
1052
 
1015
1058
                       uint64_t SV::*offset_arg):
1016
1059
    sys_var_thd(name_arg), offset(offset_arg)
1017
1060
  { chain_sys_var(chain); }
1018
 
  bool check(THD *thd __attribute__((unused)),
1019
 
             set_var *var __attribute__((unused))) {return 0;}
 
1061
  bool check(THD *thd __attribute__((__unused__)),
 
1062
             set_var *var __attribute__((__unused__))) {return 0;}
1020
1063
  bool update(THD *thd, set_var *var);
1021
1064
  void set_default(THD *thd, enum_var_type type);
1022
1065
  SHOW_TYPE show_type() { return SHOW_DOUBLE; }
1024
1067
  {
1025
1068
    return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
1026
1069
  }
1027
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1070
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1028
1071
};
1029
1072
 
1030
1073
/**
1049
1092
                            Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
1050
1093
    : sys_var_thd(name_arg, NULL, binlog_status_arg)
1051
1094
  {
1052
 
#if DRIZZLE_VERSION_ID < 50000
 
1095
#if MYSQL_VERSION_ID < 50000
1053
1096
    no_support_one_shot= 0;
1054
1097
#endif
1055
1098
    chain_sys_var(chain);
1060
1103
  {
1061
1104
    return ((type != STRING_RESULT) && (type != INT_RESULT));
1062
1105
  }
1063
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
1106
  bool check_default(enum_var_type type __attribute__((__unused__)))
1064
1107
  { return 0; }
1065
1108
  bool update(THD *thd, set_var *var);
1066
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1109
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1067
1110
  virtual void set_default(THD *thd, enum_var_type type);
1068
1111
};
1069
1112
 
1108
1151
  enum_var_type type;
1109
1152
  union
1110
1153
  {
1111
 
    const CHARSET_INFO *charset;
 
1154
    CHARSET_INFO *charset;
1112
1155
    ulong ulong_value;
1113
1156
    uint64_t uint64_t_value;
1114
1157
    plugin_ref plugin;
1160
1203
 
1161
1204
class set_var_collation_client: public set_var_base
1162
1205
{
1163
 
  const CHARSET_INFO *character_set_client;
1164
 
  const CHARSET_INFO *character_set_results;
1165
 
  const CHARSET_INFO *collation_connection;
 
1206
  CHARSET_INFO *character_set_client;
 
1207
  CHARSET_INFO *character_set_results;
 
1208
  CHARSET_INFO *collation_connection;
1166
1209
public:
1167
 
  set_var_collation_client(const CHARSET_INFO * const client_coll_arg,
1168
 
                           const CHARSET_INFO * const connection_coll_arg,
1169
 
                           const CHARSET_INFO * const result_coll_arg)
 
1210
  set_var_collation_client(CHARSET_INFO *client_coll_arg,
 
1211
                           CHARSET_INFO *connection_coll_arg,
 
1212
                           CHARSET_INFO *result_coll_arg)
1170
1213
    :character_set_client(client_coll_arg),
1171
1214
     character_set_results(result_coll_arg),
1172
1215
     collation_connection(connection_coll_arg)
1186
1229
class NAMED_LIST :public ilink
1187
1230
{
1188
1231
  const char *name;
1189
 
  uint32_t name_length;
 
1232
  uint name_length;
1190
1233
public:
1191
 
  unsigned char* data;
 
1234
  uchar* data;
1192
1235
 
1193
1236
  NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg,
1194
 
             uint32_t name_length_arg, unsigned char* data_arg)
 
1237
             uint name_length_arg, uchar* data_arg)
1195
1238
    :name_length(name_length_arg), data(data_arg)
1196
1239
  {
1197
1240
    name= my_strndup(name_arg, name_length, MYF(MY_WME));
1198
1241
    links->push_back(this);
1199
1242
  }
1200
 
  inline bool cmp(const char *name_cmp, uint32_t length)
 
1243
  inline bool cmp(const char *name_cmp, uint length)
1201
1244
  {
1202
1245
    return length == name_length && !memcmp(name, name_cmp, length);
1203
1246
  }
1204
1247
  ~NAMED_LIST()
1205
1248
  {
1206
 
    free((unsigned char*) name);
 
1249
    my_free((uchar*) name, MYF(0));
1207
1250
  }
1208
1251
  friend bool process_key_caches(process_key_cache_t func);
1209
1252
  friend void delete_elements(I_List<NAMED_LIST> *list,
1210
 
                              void (*free_element)(const char*, unsigned char*));
 
1253
                              void (*free_element)(const char*, uchar*));
1211
1254
};
1212
1255
 
1213
1256
/* updated in sql_acl.cc */
1228
1271
 
1229
1272
int set_var_init();
1230
1273
void set_var_free();
1231
 
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count);
 
1274
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count);
1232
1275
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted);
1233
1276
int mysql_add_sys_var_chain(sys_var *chain, struct my_option *long_options);
1234
1277
int mysql_del_sys_var_chain(sys_var *chain);
1235
 
sys_var *find_sys_var(THD *thd, const char *str, uint32_t length=0);
 
1278
sys_var *find_sys_var(THD *thd, const char *str, uint length=0);
1236
1279
int sql_set_variables(THD *thd, List<set_var_base> *var_list);
1237
1280
bool not_all_support_one_shot(List<set_var_base> *var_list);
1238
1281
void fix_delay_key_write(THD *thd, enum_var_type type);
1239
1282
void fix_slave_exec_mode(enum_var_type type);
 
1283
ulong fix_sql_mode(ulong sql_mode);
 
1284
extern sys_var_const_str sys_charset_system;
1240
1285
extern sys_var_str sys_init_connect;
1241
1286
extern sys_var_str sys_init_slave;
1242
1287
extern sys_var_thd_time_zone sys_time_zone;
1243
1288
extern sys_var_thd_bit sys_autocommit;
1244
 
const CHARSET_INFO *get_old_charset_by_name(const char *old_name);
1245
 
unsigned char* find_named(I_List<NAMED_LIST> *list, const char *name, uint32_t length,
 
1289
CHARSET_INFO *get_old_charset_by_name(const char *old_name);
 
1290
uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
1246
1291
                NAMED_LIST **found);
1247
1292
 
1248
1293
extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
1249
1294
 
1250
1295
/* key_cache functions */
1251
1296
KEY_CACHE *get_key_cache(LEX_STRING *cache_name);
1252
 
KEY_CACHE *get_or_create_key_cache(const char *name, uint32_t length);
 
1297
KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
1253
1298
void free_key_cache(const char *name, KEY_CACHE *key_cache);
1254
1299
bool process_key_caches(process_key_cache_t func);
1255
1300
void delete_elements(I_List<NAMED_LIST> *list,
1256
 
                     void (*free_element)(const char*, unsigned char*));
 
1301
                     void (*free_element)(const char*, uchar*));