~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/set_var.h

MergingĀ mainline

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
 
183
182
};
184
183
 
185
184
 
186
 
class sys_var_uint64_t_ptr :public sys_var
 
185
class sys_var_ulonglong_ptr :public sys_var
187
186
{
188
 
  uint64_t *value;
 
187
  ulonglong *value;
189
188
public:
190
 
  sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg)
 
189
  sys_var_ulonglong_ptr(sys_var_chain *chain, const char *name_arg, ulonglong *value_ptr_arg)
191
190
    :sys_var(name_arg),value(value_ptr_arg)
192
191
  { chain_sys_var(chain); }
193
 
  sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg,
 
192
  sys_var_ulonglong_ptr(sys_var_chain *chain, const char *name_arg, ulonglong *value_ptr_arg,
194
193
                       sys_after_update_func func)
195
194
    :sys_var(name_arg,func), value(value_ptr_arg)
196
195
  { chain_sys_var(chain); }
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
 
207
206
class sys_var_bool_ptr :public sys_var
208
207
{
209
208
public:
210
 
  bool *value;
211
 
  sys_var_bool_ptr(sys_var_chain *chain, const char *name_arg, bool *value_arg)
 
209
  my_bool *value;
 
210
  sys_var_bool_ptr(sys_var_chain *chain, const char *name_arg, my_bool *value_arg)
212
211
    :sys_var(name_arg),value(value_arg)
213
212
  { chain_sys_var(chain); }
214
213
  bool check(THD *thd, set_var *var)
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
 
 
228
 
229
229
class sys_var_bool_ptr_readonly :public sys_var_bool_ptr
230
230
{
231
231
public:
232
232
  sys_var_bool_ptr_readonly(sys_var_chain *chain, const char *name_arg,
233
 
                            bool *value_arg)
 
233
                            my_bool *value_arg)
234
234
    :sys_var_bool_ptr(chain, name_arg, value_arg)
235
235
  {}
236
236
  bool is_readonly() const { return 1; }
241
241
{
242
242
public:
243
243
  char *value;                                  // Pointer to allocated string
244
 
  uint32_t value_length;
 
244
  uint value_length;
245
245
  sys_check_func check_func;
246
246
  sys_update_func update_func;
247
247
  sys_set_default_func set_default_func;
263
263
    (*set_default_func)(thd, type);
264
264
  }
265
265
  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; }
 
266
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
267
                   enum_var_type type __attribute__((__unused__)),
 
268
                   LEX_STRING *base __attribute__((__unused__)))
 
269
  { return (uchar*) value; }
270
270
  bool check_update_type(Item_result type)
271
271
  {
272
272
    return type != STRING_RESULT;               /* Only accept strings */
273
273
  }
274
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
274
  bool check_default(enum_var_type type __attribute__((__unused__)))
275
275
  { return 0; }
276
276
};
277
277
 
288
288
  {
289
289
    value= new_value;
290
290
  }
291
 
  bool check(THD *thd __attribute__((unused)),
292
 
             set_var *var __attribute__((unused)))
 
291
  bool check(THD *thd __attribute__((__unused__)),
 
292
             set_var *var __attribute__((__unused__)))
293
293
  {
294
294
    return 1;
295
295
  }
296
 
  bool update(THD *thd __attribute__((unused)),
297
 
              set_var *var __attribute__((unused)))
 
296
  bool update(THD *thd __attribute__((__unused__)),
 
297
              set_var *var __attribute__((__unused__)))
298
298
  {
299
299
    return 1;
300
300
  }
301
301
  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)))
 
302
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
303
                   enum_var_type type __attribute__((__unused__)),
 
304
                   LEX_STRING *base __attribute__((__unused__)))
305
305
  {
306
 
    return (unsigned char*) value;
 
306
    return (uchar*) value;
307
307
  }
308
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
308
  bool check_update_type(Item_result type __attribute__((__unused__)))
309
309
  {
310
310
    return 1;
311
311
  }
312
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
312
  bool check_default(enum_var_type type __attribute__((__unused__)))
313
313
  { return 1; }
314
314
  bool is_readonly() const { return 1; }
315
315
};
322
322
  sys_var_const_str_ptr(sys_var_chain *chain, const char *name_arg, char **value_arg)
323
323
    :sys_var(name_arg),value(value_arg)
324
324
  { chain_sys_var(chain); }
325
 
  bool check(THD *thd __attribute__((unused)),
326
 
             set_var *var __attribute__((unused)))
 
325
  bool check(THD *thd __attribute__((__unused__)),
 
326
             set_var *var __attribute__((__unused__)))
327
327
  {
328
328
    return 1;
329
329
  }
330
 
  bool update(THD *thd __attribute__((unused)),
331
 
              set_var *var __attribute__((unused)))
 
330
  bool update(THD *thd __attribute__((__unused__)),
 
331
              set_var *var __attribute__((__unused__)))
332
332
  {
333
333
    return 1;
334
334
  }
335
335
  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)))
 
336
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
337
                   enum_var_type type __attribute__((__unused__)),
 
338
                   LEX_STRING *base __attribute__((__unused__)))
339
339
  {
340
 
    return (unsigned char*) *value;
 
340
    return (uchar*) *value;
341
341
  }
342
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
342
  bool check_update_type(Item_result type __attribute__((__unused__)))
343
343
  {
344
344
    return 1;
345
345
  }
346
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
346
  bool check_default(enum_var_type type __attribute__((__unused__)))
347
347
  { return 1; }
348
348
  bool is_readonly(void) const { return 1; }
349
349
};
351
351
 
352
352
class sys_var_enum :public sys_var
353
353
{
354
 
  uint32_t *value;
 
354
  uint *value;
355
355
  TYPELIB *enum_names;
356
356
public:
357
 
  sys_var_enum(sys_var_chain *chain, const char *name_arg, uint32_t *value_arg,
 
357
  sys_var_enum(sys_var_chain *chain, const char *name_arg, uint *value_arg,
358
358
               TYPELIB *typelib, sys_after_update_func func)
359
359
    :sys_var(name_arg,func), value(value_arg), enum_names(typelib)
360
360
  { chain_sys_var(chain); }
364
364
  }
365
365
  bool update(THD *thd, set_var *var);
366
366
  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)))
 
367
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
368
  bool check_update_type(Item_result type __attribute__((__unused__)))
369
369
  { return 0; }
370
370
};
371
371
 
379
379
      TYPELIB *typelib, sys_after_update_func func)
380
380
    :sys_var(name_arg,func), offset(offset_arg), enum_names(typelib)
381
381
  { chain_sys_var(chain); }
382
 
  bool check(THD *thd __attribute__((unused)),
383
 
             set_var *var __attribute__((unused)))
 
382
  bool check(THD *thd __attribute__((__unused__)),
 
383
             set_var *var __attribute__((__unused__)))
384
384
  { return 1; }
385
 
  bool update(THD *thd __attribute__((unused)),
386
 
              set_var *var __attribute__((unused)))
 
385
  bool update(THD *thd __attribute__((__unused__)),
 
386
              set_var *var __attribute__((__unused__)))
387
387
  { return 1; }
388
388
  SHOW_TYPE show_type() { return SHOW_CHAR; }
389
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
389
  bool check_update_type(Item_result type __attribute__((__unused__)))
390
390
  { return 1; }
391
391
  bool is_readonly() const { return 1; }
392
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
392
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
393
393
};
394
394
 
395
395
 
401
401
              Binlog_status_enum binlog_status= NOT_IN_BINLOG)
402
402
    :sys_var(name_arg, func, binlog_status)
403
403
  {}
404
 
  bool check_type(enum_var_type type __attribute__((unused)))
 
404
  bool check_type(enum_var_type type __attribute__((__unused__)))
405
405
  { return 0; }
406
406
  bool check_default(enum_var_type type)
407
407
  {
427
427
  bool update(THD *thd, set_var *var);
428
428
  void set_default(THD *thd, enum_var_type type);
429
429
  SHOW_TYPE show_type() { return SHOW_LONG; }
430
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
430
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
431
431
};
432
432
 
433
433
 
447
447
  bool update(THD *thd, set_var *var);
448
448
  void set_default(THD *thd, enum_var_type type);
449
449
  SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
450
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
450
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
451
451
};
452
452
 
453
453
 
454
 
class sys_var_thd_uint64_t :public sys_var_thd
 
454
class sys_var_thd_ulonglong :public sys_var_thd
455
455
{
456
456
public:
457
 
  uint64_t SV::*offset;
 
457
  ulonglong SV::*offset;
458
458
  bool only_global;
459
 
  sys_var_thd_uint64_t(sys_var_chain *chain, const char *name_arg, 
460
 
                        uint64_t SV::*offset_arg)
 
459
  sys_var_thd_ulonglong(sys_var_chain *chain, const char *name_arg, 
 
460
                        ulonglong SV::*offset_arg)
461
461
    :sys_var_thd(name_arg), offset(offset_arg)
462
462
  { chain_sys_var(chain); }
463
 
  sys_var_thd_uint64_t(sys_var_chain *chain, const char *name_arg, 
464
 
                        uint64_t SV::*offset_arg,
 
463
  sys_var_thd_ulonglong(sys_var_chain *chain, const char *name_arg, 
 
464
                        ulonglong SV::*offset_arg,
465
465
                        sys_after_update_func func, bool only_global_arg)
466
466
    :sys_var_thd(name_arg, func), offset(offset_arg),
467
467
    only_global(only_global_arg)
469
469
  bool update(THD *thd, set_var *var);
470
470
  void set_default(THD *thd, enum_var_type type);
471
471
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
472
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
472
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
473
473
  bool check(THD *thd, set_var *var);
474
474
  bool check_default(enum_var_type type)
475
475
  {
485
485
class sys_var_thd_bool :public sys_var_thd
486
486
{
487
487
public:
488
 
  bool SV::*offset;
489
 
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
 
488
  my_bool SV::*offset;
 
489
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg)
490
490
    :sys_var_thd(name_arg), offset(offset_arg)
491
491
  { chain_sys_var(chain); }
492
 
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
 
492
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg,
493
493
                   sys_after_update_func func)
494
494
    :sys_var_thd(name_arg,func), offset(offset_arg)
495
495
  { chain_sys_var(chain); }
496
496
  bool update(THD *thd, set_var *var);
497
497
  void set_default(THD *thd, enum_var_type type);
498
498
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
499
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
499
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
500
500
  bool check(THD *thd, set_var *var)
501
501
  {
502
502
    return check_enum(thd, var, &bool_typelib);
503
503
  }
504
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
504
  bool check_update_type(Item_result type __attribute__((__unused__)))
505
505
  { return 0; }
506
506
};
507
507
 
530
530
  bool update(THD *thd, set_var *var);
531
531
  void set_default(THD *thd, enum_var_type type);
532
532
  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)))
 
533
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
534
  bool check_update_type(Item_result type __attribute__((__unused__)))
535
535
  { return 0; }
536
536
};
537
537
 
549
549
    return check_set(thd, var, enum_names);
550
550
  }
551
551
  void set_default(THD *thd, enum_var_type type);
552
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
553
 
  static bool symbolic_mode_representation(THD *thd, uint64_t sql_mode,
 
552
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
553
  static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode,
554
554
                                           LEX_STRING *rep);
555
555
};
556
556
 
572
572
  }
573
573
  void set_default(THD *thd, enum_var_type type);
574
574
  bool update(THD *thd, set_var *var);
575
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
575
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
576
576
};
577
577
 
578
578
class sys_var_thd_bit :public sys_var_thd
580
580
  sys_check_func check_func;
581
581
  sys_update_func update_func;
582
582
public:
583
 
  uint64_t bit_flag;
 
583
  ulonglong bit_flag;
584
584
  bool reverse;
585
585
  sys_var_thd_bit(sys_var_chain *chain, const char *name_arg,
586
586
                  sys_check_func c_func, sys_update_func u_func,
587
 
                  uint64_t bit, bool reverse_arg=0,
 
587
                  ulonglong bit, bool reverse_arg=0,
588
588
                  Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
589
589
    :sys_var_thd(name_arg, NULL, binlog_status_arg), check_func(c_func),
590
590
    update_func(u_func), bit_flag(bit), reverse(reverse_arg)
591
591
  { chain_sys_var(chain); }
592
592
  bool check(THD *thd, set_var *var);
593
593
  bool update(THD *thd, set_var *var);
594
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
594
  bool check_update_type(Item_result type __attribute__((__unused__)))
595
595
  { return 0; }
596
596
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
597
597
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
598
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
598
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
599
599
};
600
600
 
601
601
/* some variables that require special handling */
610
610
  bool update(THD *thd, set_var *var);
611
611
  void set_default(THD *thd, enum_var_type type);
612
612
  bool check_type(enum_var_type type)    { return type == OPT_GLOBAL; }
613
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
613
  bool check_default(enum_var_type type __attribute__((__unused__)))
614
614
  { return 0; }
615
615
  SHOW_TYPE show_type(void) { return SHOW_LONG; }
616
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
616
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
617
617
};
618
618
 
619
619
 
627
627
  bool update(THD *thd, set_var *var);
628
628
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
629
629
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
630
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
630
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
631
631
};
632
632
 
633
633
 
640
640
  bool update(THD *thd, set_var *var);
641
641
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
642
642
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
643
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
643
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
644
644
};
645
645
 
646
646
 
682
682
  {
683
683
    return ((type != STRING_RESULT) && (type != INT_RESULT));
684
684
  }
685
 
  bool check_default(enum_var_type type __attribute__((unused))) { return 0; }
 
685
  bool check_default(enum_var_type type __attribute__((__unused__))) { return 0; }
686
686
  virtual void set_default(THD *thd, enum_var_type type)= 0;
687
687
};
688
688
 
706
706
  {
707
707
    return ((type != STRING_RESULT) && (type != INT_RESULT));
708
708
  }
709
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
709
  bool check_default(enum_var_type type __attribute__((__unused__)))
710
710
  { return 0; }
711
711
  bool update(THD *thd, set_var *var);
712
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
712
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
713
713
  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;
 
714
  virtual CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
 
715
};
 
716
 
 
717
class sys_var_character_set_sv :public sys_var_character_set
 
718
{
 
719
  CHARSET_INFO *SV::*offset;
 
720
  CHARSET_INFO **global_default;
 
721
public:
 
722
  sys_var_character_set_sv(sys_var_chain *chain, const char *name_arg,
 
723
                           CHARSET_INFO *SV::*offset_arg,
 
724
                           CHARSET_INFO **global_default_arg,
 
725
                           bool is_nullable= 0,
 
726
                           Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
 
727
    : sys_var_character_set(name_arg, is_nullable, binlog_status_arg),
 
728
    offset(offset_arg), global_default(global_default_arg)
 
729
  { chain_sys_var(chain); }
 
730
  void set_default(THD *thd, enum_var_type type);
 
731
  CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
 
732
};
 
733
 
 
734
 
 
735
class sys_var_character_set_client: public sys_var_character_set_sv
 
736
{
 
737
public:
 
738
  sys_var_character_set_client(sys_var_chain *chain, const char *name_arg,
 
739
                               CHARSET_INFO *SV::*offset_arg,
 
740
                               CHARSET_INFO **global_default_arg,
 
741
                               Binlog_status_enum binlog_status_arg)
 
742
    : sys_var_character_set_sv(chain, name_arg, offset_arg, global_default_arg,
 
743
                               0, binlog_status_arg)
 
744
  { }
 
745
  bool check(THD *thd, set_var *var);
 
746
};
 
747
 
 
748
 
 
749
class sys_var_character_set_database :public sys_var_character_set
 
750
{
 
751
public:
 
752
  sys_var_character_set_database(sys_var_chain *chain, const char *name_arg,
 
753
                                 Binlog_status_enum binlog_status_arg=
 
754
                                   NOT_IN_BINLOG)
 
755
    : sys_var_character_set(name_arg, 0, binlog_status_arg)
 
756
  { chain_sys_var(chain); }
 
757
  void set_default(THD *thd, enum_var_type type);
 
758
  CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
715
759
};
716
760
 
717
761
class sys_var_collation_sv :public sys_var_collation
718
762
{
719
 
  const CHARSET_INFO *SV::*offset;
720
 
  const CHARSET_INFO **global_default;
 
763
  CHARSET_INFO *SV::*offset;
 
764
  CHARSET_INFO **global_default;
721
765
public:
722
766
  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,
 
767
                       CHARSET_INFO *SV::*offset_arg,
 
768
                       CHARSET_INFO **global_default_arg,
725
769
                       Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
726
770
    :sys_var_collation(name_arg, binlog_status_arg),
727
771
    offset(offset_arg), global_default(global_default_arg)
730
774
  }
731
775
  bool update(THD *thd, set_var *var);
732
776
  void set_default(THD *thd, enum_var_type type);
733
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
777
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
734
778
};
735
779
 
736
780
 
743
787
                          size_t offset_arg)
744
788
    :sys_var(name_arg), offset(offset_arg)
745
789
  { 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)))
 
790
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
791
  bool check_default(enum_var_type type __attribute__((__unused__)))
748
792
  { return 1; }
749
793
  bool is_struct() { return 1; }
750
794
};
776
820
class sys_var_thd_date_time_format :public sys_var_thd
777
821
{
778
822
  DATE_TIME_FORMAT *SV::*offset;
779
 
  enum enum_drizzle_timestamp_type date_time_type;
 
823
  timestamp_type date_time_type;
780
824
public:
781
825
  sys_var_thd_date_time_format(sys_var_chain *chain, const char *name_arg,
782
826
                               DATE_TIME_FORMAT *SV::*offset_arg,
783
 
                               enum enum_drizzle_timestamp_type date_time_type_arg)
 
827
                               timestamp_type date_time_type_arg)
784
828
    :sys_var_thd(name_arg), offset(offset_arg),
785
829
    date_time_type(date_time_type_arg)
786
830
  { chain_sys_var(chain); }
789
833
  {
790
834
    return type != STRING_RESULT;               /* Only accept strings */
791
835
  }
792
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
836
  bool check_default(enum_var_type type __attribute__((__unused__)))
793
837
  { return 0; }
794
838
  bool check(THD *thd, set_var *var);
795
839
  bool update(THD *thd, set_var *var);
796
840
  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);
 
841
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
798
842
  void set_default(THD *thd, enum_var_type type);
799
843
};
800
844
 
801
845
 
802
846
class sys_var_log_state :public sys_var_bool_ptr
803
847
{
804
 
  uint32_t log_type;
 
848
  uint log_type;
805
849
public:
806
 
  sys_var_log_state(sys_var_chain *chain, const char *name_arg, bool *value_arg, 
807
 
                    uint32_t log_type_arg)
 
850
  sys_var_log_state(sys_var_chain *chain, const char *name_arg, my_bool *value_arg, 
 
851
                    uint log_type_arg)
808
852
    :sys_var_bool_ptr(chain, name_arg, value_arg), log_type(log_type_arg) {}
809
853
  bool update(THD *thd, set_var *var);
810
854
  void set_default(THD *thd, enum_var_type type);
825
869
  {
826
870
    return check_set(thd, var, enum_names);
827
871
  }
828
 
  virtual void set_default(THD *thd __attribute__((unused)),
829
 
                           enum_var_type type __attribute__((unused)))
 
872
  virtual void set_default(THD *thd __attribute__((__unused__)),
 
873
                           enum_var_type type __attribute__((__unused__)))
830
874
  {
831
875
    *value= 0;
832
876
  }
833
877
  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)))
 
878
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
879
  bool check_update_type(Item_result type __attribute__((__unused__)))
836
880
  { return 0; }
837
881
  SHOW_TYPE show_type() { return SHOW_CHAR; }
838
882
};
866
910
    return check_set(thd, var, enum_names);
867
911
  }
868
912
  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)))
 
913
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
914
  bool check_update_type(Item_result type __attribute__((__unused__)))
871
915
  { return 0; }
872
916
  void set_default(THD *thd, enum_var_type type);
873
917
  SHOW_TYPE show_type() { return SHOW_CHAR; }
888
932
    :sys_var(name_arg), var_type(type), 
889
933
       show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
890
934
  { chain_sys_var(chain); }
891
 
  bool update(THD *thd __attribute__((unused)),
892
 
              set_var *var __attribute__((unused)))
 
935
  bool update(THD *thd __attribute__((__unused__)),
 
936
              set_var *var __attribute__((__unused__)))
893
937
  { return 1; }
894
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
938
  bool check_default(enum_var_type type __attribute__((__unused__)))
895
939
  { return 1; }
896
940
  bool check_type(enum_var_type type) { return type != var_type; }
897
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
941
  bool check_update_type(Item_result type __attribute__((__unused__)))
898
942
  { return 1; }
899
 
  unsigned char *value_ptr(THD *thd, enum_var_type type __attribute__((unused)),
900
 
                   LEX_STRING *base __attribute__((unused)))
 
943
  uchar *value_ptr(THD *thd, enum_var_type type __attribute__((__unused__)),
 
944
                   LEX_STRING *base __attribute__((__unused__)))
901
945
  {
902
946
    return (*value_ptr_func)(thd);
903
947
  }
914
958
  sys_var_have_option(sys_var_chain *chain, const char *variable_name):
915
959
    sys_var(variable_name)
916
960
  { 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)))
 
961
  uchar *value_ptr(THD *thd __attribute__((__unused__)),
 
962
                   enum_var_type type __attribute__((__unused__)),
 
963
                   LEX_STRING *base __attribute__((__unused__)))
920
964
  {
921
 
    return (unsigned char*) show_comp_option_name[get_option()];
 
965
    return (uchar*) show_comp_option_name[get_option()];
922
966
  }
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)))
 
967
  bool update(THD *thd __attribute__((__unused__)),
 
968
              set_var *var __attribute__((__unused__))) { return 1; }
 
969
  bool check_default(enum_var_type type __attribute__((__unused__)))
926
970
  { return 1; }
927
971
  bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
928
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
972
  bool check_update_type(Item_result type __attribute__((__unused__)))
929
973
  { return 1; }
930
974
  SHOW_TYPE show_type() { return SHOW_CHAR; }
931
975
  bool is_readonly() const { return 1; }
949
993
class sys_var_have_plugin: public sys_var_have_option
950
994
{
951
995
  const char *plugin_name_str;
952
 
  const uint32_t plugin_name_len;
 
996
  const uint plugin_name_len;
953
997
  const int plugin_type;
954
998
 
955
999
public:
956
1000
  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, 
 
1001
                      const char *plugin_name_str_arg, uint plugin_name_len_arg, 
958
1002
                      int plugin_type_arg):
959
1003
    sys_var_have_option(chain, variable_name), 
960
1004
    plugin_name_str(plugin_name_str_arg), plugin_name_len(plugin_name_len_arg),
981
1025
  {
982
1026
    return type != STRING_RESULT;               /* Only accept strings */
983
1027
  }
984
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
1028
  bool check_default(enum_var_type type __attribute__((__unused__)))
985
1029
  { return 0; }
986
1030
  bool update(THD *thd, set_var *var);
987
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1031
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
988
1032
  virtual void set_default(THD *thd, enum_var_type type);
989
1033
};
990
1034
 
1003
1047
  }
1004
1048
  void set_default(THD *thd, enum_var_type type);
1005
1049
  SHOW_TYPE show_type() { return SHOW_INT; }
1006
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1050
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1007
1051
};
1008
1052
 
1009
1053
 
1010
1054
class sys_var_microseconds :public sys_var_thd
1011
1055
{
1012
 
  uint64_t SV::*offset;
 
1056
  ulonglong SV::*offset;
1013
1057
public:
1014
1058
  sys_var_microseconds(sys_var_chain *chain, const char *name_arg,
1015
 
                       uint64_t SV::*offset_arg):
 
1059
                       ulonglong SV::*offset_arg):
1016
1060
    sys_var_thd(name_arg), offset(offset_arg)
1017
1061
  { chain_sys_var(chain); }
1018
 
  bool check(THD *thd __attribute__((unused)),
1019
 
             set_var *var __attribute__((unused))) {return 0;}
 
1062
  bool check(THD *thd __attribute__((__unused__)),
 
1063
             set_var *var __attribute__((__unused__))) {return 0;}
1020
1064
  bool update(THD *thd, set_var *var);
1021
1065
  void set_default(THD *thd, enum_var_type type);
1022
1066
  SHOW_TYPE show_type() { return SHOW_DOUBLE; }
1024
1068
  {
1025
1069
    return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
1026
1070
  }
1027
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1071
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1072
};
 
1073
 
 
1074
 
 
1075
class sys_var_trust_routine_creators :public sys_var_bool_ptr
 
1076
{
 
1077
  /* We need a derived class only to have a warn_deprecated() */
 
1078
public:
 
1079
  sys_var_trust_routine_creators(sys_var_chain *chain,
 
1080
                                 const char *name_arg, my_bool *value_arg) :
 
1081
    sys_var_bool_ptr(chain, name_arg, value_arg) {};
 
1082
  void warn_deprecated(THD *thd);
 
1083
  void set_default(THD *thd, enum_var_type type);
 
1084
  bool update(THD *thd, set_var *var);
1028
1085
};
1029
1086
 
1030
1087
/**
1035
1092
{
1036
1093
public:
1037
1094
  sys_var_opt_readonly(sys_var_chain *chain, const char *name_arg, 
1038
 
                       bool *value_arg) :
 
1095
                       my_bool *value_arg) :
1039
1096
    sys_var_bool_ptr(chain, name_arg, value_arg) {};
1040
1097
  ~sys_var_opt_readonly() {};
1041
1098
  bool update(THD *thd, set_var *var);
1049
1106
                            Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
1050
1107
    : sys_var_thd(name_arg, NULL, binlog_status_arg)
1051
1108
  {
1052
 
#if DRIZZLE_VERSION_ID < 50000
 
1109
#if MYSQL_VERSION_ID < 50000
1053
1110
    no_support_one_shot= 0;
1054
1111
#endif
1055
1112
    chain_sys_var(chain);
1060
1117
  {
1061
1118
    return ((type != STRING_RESULT) && (type != INT_RESULT));
1062
1119
  }
1063
 
  bool check_default(enum_var_type type __attribute__((unused)))
 
1120
  bool check_default(enum_var_type type __attribute__((__unused__)))
1064
1121
  { return 0; }
1065
1122
  bool update(THD *thd, set_var *var);
1066
 
  unsigned char *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1123
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1067
1124
  virtual void set_default(THD *thd, enum_var_type type);
1068
1125
};
1069
1126
 
1098
1155
};
1099
1156
 
1100
1157
 
1101
 
/* MySQL internal variables */
 
1158
/* MySQL internal variables, like query_cache_size */
1102
1159
 
1103
1160
class set_var :public set_var_base
1104
1161
{
1108
1165
  enum_var_type type;
1109
1166
  union
1110
1167
  {
1111
 
    const CHARSET_INFO *charset;
 
1168
    CHARSET_INFO *charset;
1112
1169
    ulong ulong_value;
1113
 
    uint64_t uint64_t_value;
 
1170
    ulonglong ulonglong_value;
1114
1171
    plugin_ref plugin;
1115
1172
    DATE_TIME_FORMAT *date_time_format;
1116
1173
    Time_zone *time_zone;
1160
1217
 
1161
1218
class set_var_collation_client: public set_var_base
1162
1219
{
1163
 
  const CHARSET_INFO *character_set_client;
1164
 
  const CHARSET_INFO *character_set_results;
1165
 
  const CHARSET_INFO *collation_connection;
 
1220
  CHARSET_INFO *character_set_client;
 
1221
  CHARSET_INFO *character_set_results;
 
1222
  CHARSET_INFO *collation_connection;
1166
1223
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)
 
1224
  set_var_collation_client(CHARSET_INFO *client_coll_arg,
 
1225
                           CHARSET_INFO *connection_coll_arg,
 
1226
                           CHARSET_INFO *result_coll_arg)
1170
1227
    :character_set_client(client_coll_arg),
1171
1228
     character_set_results(result_coll_arg),
1172
1229
     collation_connection(connection_coll_arg)
1186
1243
class NAMED_LIST :public ilink
1187
1244
{
1188
1245
  const char *name;
1189
 
  uint32_t name_length;
 
1246
  uint name_length;
1190
1247
public:
1191
 
  unsigned char* data;
 
1248
  uchar* data;
1192
1249
 
1193
1250
  NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg,
1194
 
             uint32_t name_length_arg, unsigned char* data_arg)
 
1251
             uint name_length_arg, uchar* data_arg)
1195
1252
    :name_length(name_length_arg), data(data_arg)
1196
1253
  {
1197
1254
    name= my_strndup(name_arg, name_length, MYF(MY_WME));
1198
1255
    links->push_back(this);
1199
1256
  }
1200
 
  inline bool cmp(const char *name_cmp, uint32_t length)
 
1257
  inline bool cmp(const char *name_cmp, uint length)
1201
1258
  {
1202
1259
    return length == name_length && !memcmp(name, name_cmp, length);
1203
1260
  }
1204
1261
  ~NAMED_LIST()
1205
1262
  {
1206
 
    free((unsigned char*) name);
 
1263
    my_free((uchar*) name, MYF(0));
1207
1264
  }
1208
1265
  friend bool process_key_caches(process_key_cache_t func);
1209
1266
  friend void delete_elements(I_List<NAMED_LIST> *list,
1210
 
                              void (*free_element)(const char*, unsigned char*));
 
1267
                              void (*free_element)(const char*, uchar*));
1211
1268
};
1212
1269
 
1213
1270
/* updated in sql_acl.cc */
1228
1285
 
1229
1286
int set_var_init();
1230
1287
void set_var_free();
1231
 
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count);
 
1288
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count);
1232
1289
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted);
1233
1290
int mysql_add_sys_var_chain(sys_var *chain, struct my_option *long_options);
1234
1291
int mysql_del_sys_var_chain(sys_var *chain);
1235
 
sys_var *find_sys_var(THD *thd, const char *str, uint32_t length=0);
 
1292
sys_var *find_sys_var(THD *thd, const char *str, uint length=0);
1236
1293
int sql_set_variables(THD *thd, List<set_var_base> *var_list);
1237
1294
bool not_all_support_one_shot(List<set_var_base> *var_list);
1238
1295
void fix_delay_key_write(THD *thd, enum_var_type type);
1239
1296
void fix_slave_exec_mode(enum_var_type type);
 
1297
ulong fix_sql_mode(ulong sql_mode);
 
1298
extern sys_var_const_str sys_charset_system;
1240
1299
extern sys_var_str sys_init_connect;
1241
1300
extern sys_var_str sys_init_slave;
1242
1301
extern sys_var_thd_time_zone sys_time_zone;
1243
1302
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,
 
1303
CHARSET_INFO *get_old_charset_by_name(const char *old_name);
 
1304
uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
1246
1305
                NAMED_LIST **found);
1247
1306
 
1248
1307
extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
1249
1308
 
1250
1309
/* key_cache functions */
1251
1310
KEY_CACHE *get_key_cache(LEX_STRING *cache_name);
1252
 
KEY_CACHE *get_or_create_key_cache(const char *name, uint32_t length);
 
1311
KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
1253
1312
void free_key_cache(const char *name, KEY_CACHE *key_cache);
1254
1313
bool process_key_caches(process_key_cache_t func);
1255
1314
void delete_elements(I_List<NAMED_LIST> *list,
1256
 
                     void (*free_element)(const char*, unsigned char*));
 
1315
                     void (*free_element)(const char*, uchar*));