~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/set_var.h

  • Committer: Monty Taylor
  • Date: 2008-07-05 11:20:18 UTC
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: monty@inaugust.com-20080705112018-fr12kkmgphtu7m29
Changes so that removal of duplicate curr_dir from my_sys.h work.

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
 
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);
45
41
 
46
42
struct sys_var_chain
47
43
{
70
66
 
71
67
  sys_var *next;
72
68
  struct my_option *option_limits;      /* Updated by by set_var_init() */
73
 
  uint32_t name_length;                 /* Updated by by set_var_init() */
 
69
  uint name_length;                     /* Updated by by set_var_init() */
74
70
  const char *name;
75
71
 
76
72
  sys_after_update_func after_update;
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)
83
79
  {}
84
80
  virtual ~sys_var() {}
85
81
  void chain_sys_var(sys_var_chain *chain_arg)
99
95
      (binlog_status == SESSION_VARIABLE_IN_BINLOG);
100
96
  }
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)))
104
 
  {}
 
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)
109
101
  { return 0; }
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; }
174
164
};
175
165
 
176
166
 
186
176
};
187
177
 
188
178
 
189
 
class sys_var_uint64_t_ptr :public sys_var
 
179
class sys_var_ulonglong_ptr :public sys_var
190
180
{
191
 
  uint64_t *value;
 
181
  ulonglong *value;
192
182
public:
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; }
207
195
};
208
196
 
209
197
 
210
198
class sys_var_bool_ptr :public sys_var
211
199
{
212
200
public:
213
 
  bool *value;
214
 
  sys_var_bool_ptr(sys_var_chain *chain, const char *name_arg, bool *value_arg)
 
201
  my_bool *value;
 
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)))
229
 
  { return 0; }
 
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; }
230
215
};
231
216
 
 
217
 
232
218
class sys_var_bool_ptr_readonly :public sys_var_bool_ptr
233
219
{
234
220
public:
235
221
  sys_var_bool_ptr_readonly(sys_var_chain *chain, const char *name_arg,
236
 
                            bool *value_arg)
 
222
                            my_bool *value_arg)
237
223
    :sys_var_bool_ptr(chain, name_arg, value_arg)
238
224
  {}
239
225
  bool is_readonly() const { return 1; }
244
230
{
245
231
public:
246
232
  char *value;                                  // Pointer to allocated string
247
 
  uint32_t value_length;
 
233
  uint value_length;
248
234
  sys_check_func check_func;
249
235
  sys_update_func update_func;
250
236
  sys_set_default_func set_default_func;
266
252
    (*set_default_func)(thd, type);
267
253
  }
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)
274
258
  {
275
259
    return type != STRING_RESULT;               /* Only accept strings */
276
260
  }
277
 
  bool check_default(enum_var_type type __attribute__((unused)))
278
 
  { return 0; }
 
261
  bool check_default(enum_var_type type) { return 0; }
279
262
};
280
263
 
281
264
 
291
274
  {
292
275
    value= new_value;
293
276
  }
294
 
  bool check(THD *thd __attribute__((unused)),
295
 
             set_var *var __attribute__((unused)))
 
277
  bool check(THD *thd, set_var *var)
296
278
  {
297
279
    return 1;
298
280
  }
299
 
  bool update(THD *thd __attribute__((unused)),
300
 
              set_var *var __attribute__((unused)))
 
281
  bool update(THD *thd, set_var *var)
301
282
  {
302
283
    return 1;
303
284
  }
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)
308
287
  {
309
 
    return (unsigned char*) value;
 
288
    return (uchar*) value;
310
289
  }
311
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
290
  bool check_update_type(Item_result type)
312
291
  {
313
292
    return 1;
314
293
  }
315
 
  bool check_default(enum_var_type type __attribute__((unused)))
316
 
  { return 1; }
 
294
  bool check_default(enum_var_type type) { return 1; }
317
295
  bool is_readonly() const { return 1; }
318
296
};
319
297
 
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)
330
307
  {
331
308
    return 1;
332
309
  }
333
 
  bool update(THD *thd __attribute__((unused)),
334
 
              set_var *var __attribute__((unused)))
 
310
  bool update(THD *thd, set_var *var)
335
311
  {
336
312
    return 1;
337
313
  }
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)
342
316
  {
343
 
    return (unsigned char*) *value;
 
317
    return (uchar*) *value;
344
318
  }
345
 
  bool check_update_type(Item_result type __attribute__((unused)))
 
319
  bool check_update_type(Item_result type)
346
320
  {
347
321
    return 1;
348
322
  }
349
 
  bool check_default(enum_var_type type __attribute__((unused)))
350
 
  { return 1; }
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; }
352
325
};
353
326
 
354
327
 
355
328
class sys_var_enum :public sys_var
356
329
{
357
 
  uint32_t *value;
 
330
  uint *value;
358
331
  TYPELIB *enum_names;
359
332
public:
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); }
367
340
  }
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)))
372
 
  { return 0; }
 
343
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
344
  bool check_update_type(Item_result type) { return 0; }
373
345
};
374
346
 
375
347
 
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)))
387
 
  { return 1; }
388
 
  bool update(THD *thd __attribute__((unused)),
389
 
              set_var *var __attribute__((unused)))
390
 
  { return 1; }
 
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)))
393
 
  { return 1; }
 
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);
396
363
};
397
364
 
398
365
 
404
371
              Binlog_status_enum binlog_status= NOT_IN_BINLOG)
405
372
    :sys_var(name_arg, func, binlog_status)
406
373
  {}
407
 
  bool check_type(enum_var_type type __attribute__((unused)))
408
 
  { return 0; }
 
374
  bool check_type(enum_var_type type) { return 0; }
409
375
  bool check_default(enum_var_type type)
410
376
  {
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);
434
400
};
435
401
 
436
402
 
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);
454
420
};
455
421
 
456
422
 
457
 
class sys_var_thd_uint64_t :public sys_var_thd
 
423
class sys_var_thd_ulonglong :public sys_var_thd
458
424
{
459
425
public:
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)
478
444
  {
488
454
class sys_var_thd_bool :public sys_var_thd
489
455
{
490
456
public:
491
 
  bool SV::*offset;
492
 
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
 
457
  my_bool SV::*offset;
 
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)
504
470
  {
505
471
    return check_enum(thd, var, &bool_typelib);
506
472
  }
507
 
  bool check_update_type(Item_result type __attribute__((unused)))
508
 
  { return 0; }
 
473
  bool check_update_type(Item_result type) { return 0; }
509
474
};
510
475
 
511
476
 
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)))
538
 
  { return 0; }
 
501
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
502
  bool check_update_type(Item_result type) { return 0; }
539
503
};
540
504
 
541
505
 
552
516
    return check_set(thd, var, enum_names);
553
517
  }
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);
558
522
};
559
523
 
575
539
  }
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);
579
543
};
580
544
 
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;
585
549
public:
586
 
  uint64_t bit_flag;
 
550
  ulonglong bit_flag;
587
551
  bool reverse;
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)))
598
 
  { return 0; }
 
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);
602
 
};
 
564
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
565
};
 
566
 
 
567
class sys_var_thd_dbug :public sys_var_thd
 
568
{
 
569
public:
 
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);
 
578
};
 
579
 
 
580
 
603
581
 
604
582
/* some variables that require special handling */
605
583
 
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)))
617
 
  { return 0; }
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);
620
597
};
621
598
 
622
599
 
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);
634
611
};
635
612
 
636
613
 
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);
647
624
};
648
625
 
649
626
 
685
662
  {
686
663
    return ((type != STRING_RESULT) && (type != INT_RESULT));
687
664
  }
688
 
  bool check_default(enum_var_type type __attribute__((unused))) { return 0; }
 
665
  bool check_default(enum_var_type type) { return 0; }
689
666
  virtual void set_default(THD *thd, enum_var_type type)= 0;
690
667
};
691
668
 
709
686
  {
710
687
    return ((type != STRING_RESULT) && (type != INT_RESULT));
711
688
  }
712
 
  bool check_default(enum_var_type type __attribute__((unused)))
713
 
  { return 0; }
 
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;
718
694
};
719
695
 
720
696
class sys_var_character_set_sv :public sys_var_character_set
721
697
{
722
 
  const CHARSET_INFO *SV::*offset;
723
 
  const CHARSET_INFO **global_default;
 
698
  CHARSET_INFO *SV::*offset;
 
699
  CHARSET_INFO **global_default;
724
700
public:
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);
735
711
};
736
712
 
737
713
 
739
715
{
740
716
public:
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);
762
738
};
763
739
 
764
740
class sys_var_collation_sv :public sys_var_collation
765
741
{
766
 
  const CHARSET_INFO *SV::*offset;
767
 
  const CHARSET_INFO **global_default;
 
742
  CHARSET_INFO *SV::*offset;
 
743
  CHARSET_INFO **global_default;
768
744
public:
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)
777
753
  }
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);
781
757
};
782
758
 
783
759
 
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)))
795
 
  { return 1; }
 
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; }
797
772
};
798
773
 
823
798
class sys_var_thd_date_time_format :public sys_var_thd
824
799
{
825
800
  DATE_TIME_FORMAT *SV::*offset;
826
 
  enum enum_drizzle_timestamp_type date_time_type;
 
801
  timestamp_type date_time_type;
827
802
public:
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); }
836
811
  {
837
812
    return type != STRING_RESULT;               /* Only accept strings */
838
813
  }
839
 
  bool check_default(enum_var_type type __attribute__((unused)))
840
 
  { return 0; }
 
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);
846
820
};
847
821
 
848
822
 
849
823
class sys_var_log_state :public sys_var_bool_ptr
850
824
{
851
 
  uint32_t log_type;
 
825
  uint log_type;
852
826
public:
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, 
 
828
                    uint log_type_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);
872
846
  {
873
847
    return check_set(thd, var, enum_names);
874
848
  }
875
 
  virtual void set_default(THD *thd __attribute__((unused)),
876
 
                           enum_var_type type __attribute__((unused)))
877
 
  {
 
849
  virtual void set_default(THD *thd, enum_var_type type)
 
850
  {  
878
851
    *value= 0;
879
852
  }
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)))
883
 
  { return 0; }
 
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; }
885
857
};
886
858
 
906
878
    :sys_var(name_arg,func), value(value_arg), enum_names(typelib)
907
879
  {
908
880
    chain_sys_var(chain);
909
 
    set_allow_empty_value(false);
 
881
    set_allow_empty_value(FALSE);
910
882
  }
911
883
  virtual bool check(THD *thd, set_var *var)
912
884
  {
913
885
    return check_set(thd, var, enum_names);
914
886
  }
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)))
918
 
  { return 0; }
 
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; }
921
892
};
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)))
940
 
  { return 1; }
941
 
  bool check_default(enum_var_type type __attribute__((unused)))
942
 
  { return 1; }
 
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)))
945
 
  { return 1; }
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)
948
914
  {
949
915
    return (*value_ptr_func)(thd);
950
916
  }
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; }
953
919
};
954
920
 
955
921
 
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)
967
931
  {
968
 
    return (unsigned char*) show_comp_option_name[get_option()];
 
932
    return (uchar*) show_comp_option_name[get_option()];
969
933
  }
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)))
973
 
  { return 1; }
 
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)))
976
 
  { return 1; }
 
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; }
979
940
};
996
957
class sys_var_have_plugin: public sys_var_have_option
997
958
{
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;
1001
962
 
1002
963
public:
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),
1028
989
  {
1029
990
    return type != STRING_RESULT;               /* Only accept strings */
1030
991
  }
1031
 
  bool check_default(enum_var_type type __attribute__((unused)))
1032
 
  { return 0; }
 
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);
1036
996
};
1037
997
 
1050
1010
  }
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);
1054
1014
};
1055
1015
 
1056
1016
 
1057
1017
class sys_var_microseconds :public sys_var_thd
1058
1018
{
1059
 
  uint64_t SV::*offset;
 
1019
  ulonglong SV::*offset;
1060
1020
public:
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; }
1071
1030
  {
1072
1031
    return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
1073
1032
  }
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);
 
1034
};
 
1035
 
 
1036
 
 
1037
class sys_var_trust_routine_creators :public sys_var_bool_ptr
 
1038
{
 
1039
  /* We need a derived class only to have a warn_deprecated() */
 
1040
public:
 
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);
1075
1047
};
1076
1048
 
1077
1049
/**
1082
1054
{
1083
1055
public:
1084
1056
  sys_var_opt_readonly(sys_var_chain *chain, const char *name_arg, 
1085
 
                       bool *value_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);
1096
1068
                            Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
1097
1069
    : sys_var_thd(name_arg, NULL, binlog_status_arg)
1098
1070
  {
1099
 
#if DRIZZLE_VERSION_ID < 50000
 
1071
#if MYSQL_VERSION_ID < 50000
1100
1072
    no_support_one_shot= 0;
1101
1073
#endif
1102
1074
    chain_sys_var(chain);
1107
1079
  {
1108
1080
    return ((type != STRING_RESULT) && (type != INT_RESULT));
1109
1081
  }
1110
 
  bool check_default(enum_var_type type __attribute__((unused)))
1111
 
  { return 0; }
 
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);
1115
1086
};
1116
1087
 
1145
1116
};
1146
1117
 
1147
1118
 
1148
 
/* MySQL internal variables */
 
1119
/* MySQL internal variables, like query_cache_size */
1149
1120
 
1150
1121
class set_var :public set_var_base
1151
1122
{
1155
1126
  enum_var_type type;
1156
1127
  union
1157
1128
  {
1158
 
    const CHARSET_INFO *charset;
 
1129
    CHARSET_INFO *charset;
1159
1130
    ulong ulong_value;
1160
 
    uint64_t uint64_t_value;
 
1131
    ulonglong ulonglong_value;
1161
1132
    plugin_ref plugin;
1162
1133
    DATE_TIME_FORMAT *date_time_format;
1163
1134
    Time_zone *time_zone;
1207
1178
 
1208
1179
class set_var_collation_client: public set_var_base
1209
1180
{
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;
1213
1184
public:
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
1234
1205
{
1235
1206
  const char *name;
1236
 
  uint32_t name_length;
 
1207
  uint name_length;
1237
1208
public:
1238
 
  unsigned char* data;
 
1209
  uchar* data;
1239
1210
 
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)
1243
1214
  {
1244
1215
    name= my_strndup(name_arg, name_length, MYF(MY_WME));
1245
1216
    links->push_back(this);
1246
1217
  }
1247
 
  inline bool cmp(const char *name_cmp, uint32_t length)
 
1218
  inline bool cmp(const char *name_cmp, uint length)
1248
1219
  {
1249
1220
    return length == name_length && !memcmp(name, name_cmp, length);
1250
1221
  }
1251
1222
  ~NAMED_LIST()
1252
1223
  {
1253
 
    free((unsigned char*) name);
 
1224
    my_free((uchar*) name, MYF(0));
1254
1225
  }
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*));
1258
1229
};
1259
1230
 
1260
1231
/* updated in sql_acl.cc */
1261
1232
 
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;
1264
1236
 
1265
1237
/* For sql_yacc */
1275
1247
 
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);
1295
1268
 
1296
1269
extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
1297
1270
 
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*));