~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 17:09:05 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: monty@inaugust.com-20080705170905-itvcfiincapslw9w
Removed redundant declaration.

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
 
 */
19
 
 
20
 
#ifndef DRIZZLED_ITEM_SET_H
21
 
#define DRIZZLED_ITEM_SET_H
22
 
 
23
 
#include <drizzled/function/func.h>
24
 
#include <drizzled/function/set_user_var.h>
25
 
#include <drizzled/item/string.h>
26
 
 
27
 
#include <string>
 
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 */
28
15
 
29
16
/* Classes to support the SET command */
30
17
 
 
18
#ifdef USE_PRAGMA_INTERFACE
 
19
#pragma interface                       /* gcc class implementation */
 
20
#endif
31
21
 
32
22
/****************************************************************************
33
23
  Variables that are changable runtime are declared using the
37
27
class sys_var;
38
28
class set_var;
39
29
class sys_var_pluginvar; /* opaque */
40
 
class Time_zone;
41
30
typedef struct system_variables SV;
42
31
typedef struct my_locale_st MY_LOCALE;
43
32
 
44
33
extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib,
45
 
       optimizer_switch_typelib, slave_exec_mode_typelib;
 
34
  optimizer_switch_typelib, slave_exec_mode_typelib;
46
35
 
47
 
typedef int (*sys_check_func)(Session *,  set_var *);
48
 
typedef bool (*sys_update_func)(Session *, set_var *);
49
 
typedef void (*sys_after_update_func)(Session *,enum_var_type);
50
 
typedef void (*sys_set_default_func)(Session *, enum_var_type);
51
 
typedef unsigned char *(*sys_value_ptr_func)(Session *session);
 
36
typedef int (*sys_check_func)(THD *,  set_var *);
 
37
typedef bool (*sys_update_func)(THD *, set_var *);
 
38
typedef void (*sys_after_update_func)(THD *,enum_var_type);
 
39
typedef void (*sys_set_default_func)(THD *, enum_var_type);
 
40
typedef uchar *(*sys_value_ptr_func)(THD *thd);
52
41
 
53
42
struct sys_var_chain
54
43
{
64
53
    Enumeration type to indicate for a system variable whether it will be written to the binlog or not.
65
54
  */
66
55
  enum Binlog_status_enum
67
 
  {
 
56
  {  
68
57
    /* The variable value is not in the binlog. */
69
58
    NOT_IN_BINLOG,
70
59
    /* The value of the @@session variable is in the binlog. */
77
66
 
78
67
  sys_var *next;
79
68
  struct my_option *option_limits;      /* Updated by by set_var_init() */
80
 
  uint32_t name_length;                 /* Updated by by set_var_init() */
 
69
  uint name_length;                     /* Updated by by set_var_init() */
81
70
  const char *name;
82
71
 
83
72
  sys_after_update_func after_update;
 
73
  bool no_support_one_shot;
84
74
  sys_var(const char *name_arg, sys_after_update_func func= NULL,
85
75
          Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
86
 
    :name(name_arg), after_update(func),
 
76
    :name(name_arg), after_update(func), no_support_one_shot(1),
87
77
    binlog_status(binlog_status_arg),
88
 
    m_allow_empty_value(true)
 
78
    m_allow_empty_value(TRUE)
89
79
  {}
90
80
  virtual ~sys_var() {}
91
81
  void chain_sys_var(sys_var_chain *chain_arg)
96
86
      chain_arg->first= this;
97
87
    chain_arg->last= this;
98
88
  }
99
 
  virtual bool check(Session *session, set_var *var);
100
 
  bool check_enum(Session *session, set_var *var, const TYPELIB *enum_names);
101
 
  bool check_set(Session *session, set_var *var, TYPELIB *enum_names);
102
 
  virtual bool update(Session *session, set_var *var)=0;
103
 
  virtual void set_default(Session *, enum_var_type)
104
 
  {}
 
89
  virtual bool check(THD *thd, set_var *var);
 
90
  bool check_enum(THD *thd, set_var *var, const TYPELIB *enum_names);
 
91
  bool check_set(THD *thd, set_var *var, TYPELIB *enum_names);
 
92
  bool is_written_to_binlog(enum_var_type type)
 
93
  {
 
94
    return (type == OPT_SESSION || type == OPT_DEFAULT) &&
 
95
      (binlog_status == SESSION_VARIABLE_IN_BINLOG);
 
96
  }
 
97
  virtual bool update(THD *thd, set_var *var)=0;
 
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(Session *, enum_var_type, const LEX_STRING *)
 
100
  virtual uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
107
101
  { return 0; }
108
102
  virtual bool check_type(enum_var_type type)
109
103
  { return type != OPT_GLOBAL; }                /* Error if not GLOBAL */
110
104
  virtual bool check_update_type(Item_result type)
111
105
  { return type != INT_RESULT; }                /* Assume INT */
112
 
  virtual bool check_default(enum_var_type)
 
106
  virtual bool check_default(enum_var_type type)
113
107
  { return option_limits == 0; }
114
 
  Item *item(Session *session, enum_var_type type, const LEX_STRING *base);
 
108
  Item *item(THD *thd, enum_var_type type, LEX_STRING *base);
115
109
  virtual bool is_struct() { return 0; }
116
110
  virtual bool is_readonly() const { return 0; }
117
111
  virtual sys_var_pluginvar *cast_pluginvar() { return 0; }
145
139
};
146
140
 
147
141
 
148
 
class sys_var_uint32_t_ptr :public sys_var
149
 
{
150
 
  uint32_t *value;
151
 
public:
152
 
  sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
153
 
                       uint32_t *value_ptr_arg)
154
 
    :sys_var(name_arg),value(value_ptr_arg)
155
 
  { chain_sys_var(chain); }
156
 
  sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
157
 
                       uint32_t *value_ptr_arg,
158
 
                       sys_after_update_func func)
159
 
    :sys_var(name_arg,func), value(value_ptr_arg)
160
 
  { chain_sys_var(chain); }
161
 
  bool check(Session *session, set_var *var);
162
 
  bool update(Session *session, set_var *var);
163
 
  void set_default(Session *session, enum_var_type type);
164
 
  SHOW_TYPE show_type() { return SHOW_INT; }
165
 
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
166
 
  { return (unsigned char*) value; }
167
 
};
168
 
 
169
 
 
170
 
class sys_var_uint64_t_ptr :public sys_var
171
 
{
172
 
  uint64_t *value;
173
 
public:
174
 
  sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg)
175
 
    :sys_var(name_arg),value(value_ptr_arg)
176
 
  { chain_sys_var(chain); }
177
 
  sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg,
 
142
/*
 
143
  A global-only ulong variable that requires its access to be
 
144
  protected with a mutex.
 
145
*/
 
146
 
 
147
class sys_var_long_ptr_global: public sys_var_global
 
148
{
 
149
  ulong *value;
 
150
public:
 
151
  sys_var_long_ptr_global(sys_var_chain *chain, const char *name_arg,
 
152
                          ulong *value_ptr_arg,
 
153
                          pthread_mutex_t *guard_arg,
 
154
                          sys_after_update_func after_update_arg= NULL)
 
155
    :sys_var_global(name_arg, after_update_arg, guard_arg),
 
156
    value(value_ptr_arg)
 
157
  { chain_sys_var(chain); }
 
158
  bool check(THD *thd, set_var *var);
 
159
  bool update(THD *thd, set_var *var);
 
160
  void set_default(THD *thd, enum_var_type type);
 
161
  SHOW_TYPE show_type() { return SHOW_LONG; }
 
162
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
 
163
  { return (uchar*) value; }
 
164
};
 
165
 
 
166
 
 
167
/*
 
168
  A global ulong variable that is protected by LOCK_global_system_variables
 
169
*/
 
170
 
 
171
class sys_var_long_ptr :public sys_var_long_ptr_global
 
172
{
 
173
public:
 
174
  sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, ulong *value_ptr,
 
175
                   sys_after_update_func after_update_arg= NULL);
 
176
};
 
177
 
 
178
 
 
179
class sys_var_ulonglong_ptr :public sys_var
 
180
{
 
181
  ulonglong *value;
 
182
public:
 
183
  sys_var_ulonglong_ptr(sys_var_chain *chain, const char *name_arg, ulonglong *value_ptr_arg)
 
184
    :sys_var(name_arg),value(value_ptr_arg)
 
185
  { chain_sys_var(chain); }
 
186
  sys_var_ulonglong_ptr(sys_var_chain *chain, const char *name_arg, ulonglong *value_ptr_arg,
178
187
                       sys_after_update_func func)
179
188
    :sys_var(name_arg,func), value(value_ptr_arg)
180
189
  { chain_sys_var(chain); }
181
 
  bool update(Session *session, set_var *var);
182
 
  void set_default(Session *session, enum_var_type type);
 
190
  bool update(THD *thd, set_var *var);
 
191
  void set_default(THD *thd, enum_var_type type);
183
192
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
184
 
  unsigned char *value_ptr(Session *, enum_var_type,
185
 
                           const LEX_STRING *)
186
 
  { return (unsigned char*) value; }
 
193
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
 
194
  { return (uchar*) value; }
187
195
};
188
196
 
189
 
class sys_var_size_t_ptr :public sys_var
190
 
{
191
 
  size_t *value;
192
 
public:
193
 
  sys_var_size_t_ptr(sys_var_chain *chain, const char *name_arg, size_t *value_ptr_arg)
194
 
    :sys_var(name_arg),value(value_ptr_arg)
195
 
  { chain_sys_var(chain); }
196
 
  sys_var_size_t_ptr(sys_var_chain *chain, const char *name_arg, size_t *value_ptr_arg,
197
 
                     sys_after_update_func func)
198
 
    :sys_var(name_arg,func), value(value_ptr_arg)
199
 
  { chain_sys_var(chain); }
200
 
  bool update(Session *session, set_var *var);
201
 
  void set_default(Session *session, enum_var_type type);
202
 
  SHOW_TYPE show_type() { return SHOW_SIZE; }
203
 
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
204
 
  { return (unsigned char*) value; }
205
 
};
206
197
 
207
198
class sys_var_bool_ptr :public sys_var
208
199
{
209
200
public:
210
 
  bool *value;
211
 
  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)
212
203
    :sys_var(name_arg),value(value_arg)
213
204
  { chain_sys_var(chain); }
214
 
  bool check(Session *session, set_var *var)
 
205
  bool check(THD *thd, set_var *var)
215
206
  {
216
 
    return check_enum(session, var, &bool_typelib);
 
207
    return check_enum(thd, var, &bool_typelib);
217
208
  }
218
 
  bool update(Session *session, set_var *var);
219
 
  void set_default(Session *session, enum_var_type type);
 
209
  bool update(THD *thd, set_var *var);
 
210
  void set_default(THD *thd, enum_var_type type);
220
211
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
221
 
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
222
 
  { return (unsigned char*) value; }
223
 
  bool check_update_type(Item_result)
224
 
  { 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; }
225
215
};
226
216
 
 
217
 
227
218
class sys_var_bool_ptr_readonly :public sys_var_bool_ptr
228
219
{
229
220
public:
230
221
  sys_var_bool_ptr_readonly(sys_var_chain *chain, const char *name_arg,
231
 
                            bool *value_arg)
 
222
                            my_bool *value_arg)
232
223
    :sys_var_bool_ptr(chain, name_arg, value_arg)
233
224
  {}
234
225
  bool is_readonly() const { return 1; }
239
230
{
240
231
public:
241
232
  char *value;                                  // Pointer to allocated string
242
 
  uint32_t value_length;
 
233
  uint value_length;
243
234
  sys_check_func check_func;
244
235
  sys_update_func update_func;
245
236
  sys_set_default_func set_default_func;
251
242
    :sys_var(name_arg), value(value_arg), check_func(check_func_arg),
252
243
    update_func(update_func_arg),set_default_func(set_default_func_arg)
253
244
  { chain_sys_var(chain); }
254
 
  bool check(Session *session, set_var *var);
255
 
  bool update(Session *session, set_var *var)
 
245
  bool check(THD *thd, set_var *var);
 
246
  bool update(THD *thd, set_var *var)
256
247
  {
257
 
    return (*update_func)(session, var);
 
248
    return (*update_func)(thd, var);
258
249
  }
259
 
  void set_default(Session *session, enum_var_type type)
 
250
  void set_default(THD *thd, enum_var_type type)
260
251
  {
261
 
    (*set_default_func)(session, type);
 
252
    (*set_default_func)(thd, type);
262
253
  }
263
254
  SHOW_TYPE show_type() { return SHOW_CHAR; }
264
 
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
265
 
  { return (unsigned char*) value; }
 
255
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
 
256
  { return (uchar*) value; }
266
257
  bool check_update_type(Item_result type)
267
258
  {
268
259
    return type != STRING_RESULT;               /* Only accept strings */
269
260
  }
270
 
  bool check_default(enum_var_type)
271
 
  { return 0; }
 
261
  bool check_default(enum_var_type type) { return 0; }
272
262
};
273
263
 
274
264
 
284
274
  {
285
275
    value= new_value;
286
276
  }
287
 
  bool check(Session *, set_var *)
 
277
  bool check(THD *thd, set_var *var)
288
278
  {
289
279
    return 1;
290
280
  }
291
 
  bool update(Session *, set_var *)
 
281
  bool update(THD *thd, set_var *var)
292
282
  {
293
283
    return 1;
294
284
  }
295
285
  SHOW_TYPE show_type() { return SHOW_CHAR; }
296
 
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
 
286
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
297
287
  {
298
 
    return (unsigned char*) value;
 
288
    return (uchar*) value;
299
289
  }
300
 
  bool check_update_type(Item_result)
 
290
  bool check_update_type(Item_result type)
301
291
  {
302
292
    return 1;
303
293
  }
304
 
  bool check_default(enum_var_type)
305
 
  { return 1; }
 
294
  bool check_default(enum_var_type type) { return 1; }
306
295
  bool is_readonly() const { return 1; }
307
296
};
308
297
 
314
303
  sys_var_const_str_ptr(sys_var_chain *chain, const char *name_arg, char **value_arg)
315
304
    :sys_var(name_arg),value(value_arg)
316
305
  { chain_sys_var(chain); }
317
 
  bool check(Session *, set_var *)
 
306
  bool check(THD *thd, set_var *var)
318
307
  {
319
308
    return 1;
320
309
  }
321
 
  bool update(Session *, set_var *)
 
310
  bool update(THD *thd, set_var *var)
322
311
  {
323
312
    return 1;
324
313
  }
325
314
  SHOW_TYPE show_type() { return SHOW_CHAR; }
326
 
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
 
315
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
327
316
  {
328
 
    return (unsigned char*) *value;
 
317
    return (uchar*) *value;
329
318
  }
330
 
  bool check_update_type(Item_result)
 
319
  bool check_update_type(Item_result type)
331
320
  {
332
321
    return 1;
333
322
  }
334
 
  bool check_default(enum_var_type)
335
 
  { return 1; }
336
 
  bool is_readonly(void) const { return 1; }
 
323
  bool check_default(enum_var_type type) { return 1; }
 
324
  bool is_readonly() const { return 1; }
337
325
};
338
326
 
339
327
 
340
328
class sys_var_enum :public sys_var
341
329
{
342
 
  uint32_t *value;
 
330
  uint *value;
343
331
  TYPELIB *enum_names;
344
332
public:
345
 
  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,
346
334
               TYPELIB *typelib, sys_after_update_func func)
347
335
    :sys_var(name_arg,func), value(value_arg), enum_names(typelib)
348
336
  { chain_sys_var(chain); }
349
 
  bool check(Session *session, set_var *var)
 
337
  bool check(THD *thd, set_var *var)
350
338
  {
351
 
    return check_enum(session, var, enum_names);
 
339
    return check_enum(thd, var, enum_names);
352
340
  }
353
 
  bool update(Session *session, set_var *var);
 
341
  bool update(THD *thd, set_var *var);
354
342
  SHOW_TYPE show_type() { return SHOW_CHAR; }
355
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
356
 
                           const LEX_STRING *base);
357
 
  bool check_update_type(Item_result)
358
 
  { 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; }
359
345
};
360
346
 
361
347
 
362
348
class sys_var_enum_const :public sys_var
363
349
{
364
 
  uint32_t SV::*offset;
 
350
  ulong SV::*offset;
365
351
  TYPELIB *enum_names;
366
352
public:
367
 
  sys_var_enum_const(sys_var_chain *chain, const char *name_arg, uint32_t SV::*offset_arg,
 
353
  sys_var_enum_const(sys_var_chain *chain, const char *name_arg, ulong SV::*offset_arg,
368
354
      TYPELIB *typelib, sys_after_update_func func)
369
355
    :sys_var(name_arg,func), offset(offset_arg), enum_names(typelib)
370
356
  { chain_sys_var(chain); }
371
 
  bool check(Session *, set_var *)
372
 
  { return 1; }
373
 
  bool update(Session *, set_var *)
374
 
  { return 1; }
 
357
  bool check(THD *thd, set_var *var) { return 1; }
 
358
  bool update(THD *thd, set_var *var) { return 1; }
375
359
  SHOW_TYPE show_type() { return SHOW_CHAR; }
376
 
  bool check_update_type(Item_result)
377
 
  { return 1; }
 
360
  bool check_update_type(Item_result type) { return 1; }
378
361
  bool is_readonly() const { return 1; }
379
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
380
 
                           const LEX_STRING *base);
 
362
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
381
363
};
382
364
 
383
365
 
384
 
class sys_var_session :public sys_var
 
366
class sys_var_thd :public sys_var
385
367
{
386
368
public:
387
 
  sys_var_session(const char *name_arg,
 
369
  sys_var_thd(const char *name_arg, 
388
370
              sys_after_update_func func= NULL,
389
 
              Binlog_status_enum bl_status= NOT_IN_BINLOG)
390
 
    :sys_var(name_arg, func, bl_status)
 
371
              Binlog_status_enum binlog_status= NOT_IN_BINLOG)
 
372
    :sys_var(name_arg, func, binlog_status)
391
373
  {}
392
 
  bool check_type(enum_var_type)
393
 
  { return 0; }
 
374
  bool check_type(enum_var_type type) { return 0; }
394
375
  bool check_default(enum_var_type type)
395
376
  {
396
377
    return type == OPT_GLOBAL && !option_limits;
397
378
  }
398
379
};
399
380
 
400
 
class sys_var_session_uint32_t :public sys_var_session
 
381
 
 
382
class sys_var_thd_ulong :public sys_var_thd
401
383
{
402
384
  sys_check_func check_func;
403
385
public:
404
 
  uint32_t SV::*offset;
405
 
  sys_var_session_uint32_t(sys_var_chain *chain, const char *name_arg,
406
 
                           uint32_t SV::*offset_arg,
407
 
                           sys_check_func c_func= NULL,
408
 
                           sys_after_update_func au_func= NULL,
409
 
                           Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
410
 
    :sys_var_session(name_arg, au_func, binlog_status_arg), check_func(c_func),
 
386
  ulong SV::*offset;
 
387
  sys_var_thd_ulong(sys_var_chain *chain, const char *name_arg,
 
388
                    ulong SV::*offset_arg,
 
389
                    sys_check_func c_func= NULL,
 
390
                    sys_after_update_func au_func= NULL,
 
391
                    Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
 
392
    :sys_var_thd(name_arg, au_func, binlog_status_arg), check_func(c_func),
411
393
    offset(offset_arg)
412
394
  { chain_sys_var(chain); }
413
 
  bool check(Session *session, set_var *var);
414
 
  bool update(Session *session, set_var *var);
415
 
  void set_default(Session *session, enum_var_type type);
416
 
  SHOW_TYPE show_type() { return SHOW_INT; }
417
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
418
 
                           const LEX_STRING *base);
 
395
  bool check(THD *thd, set_var *var);
 
396
  bool update(THD *thd, set_var *var);
 
397
  void set_default(THD *thd, enum_var_type type);
 
398
  SHOW_TYPE show_type() { return SHOW_LONG; }
 
399
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
419
400
};
420
401
 
421
402
 
422
 
class sys_var_session_ha_rows :public sys_var_session
 
403
class sys_var_thd_ha_rows :public sys_var_thd
423
404
{
424
405
public:
425
406
  ha_rows SV::*offset;
426
 
  sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
 
407
  sys_var_thd_ha_rows(sys_var_chain *chain, const char *name_arg, 
427
408
                      ha_rows SV::*offset_arg)
428
 
    :sys_var_session(name_arg), offset(offset_arg)
 
409
    :sys_var_thd(name_arg), offset(offset_arg)
429
410
  { chain_sys_var(chain); }
430
 
  sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
 
411
  sys_var_thd_ha_rows(sys_var_chain *chain, const char *name_arg, 
431
412
                      ha_rows SV::*offset_arg,
432
413
                      sys_after_update_func func)
433
 
    :sys_var_session(name_arg,func), offset(offset_arg)
 
414
    :sys_var_thd(name_arg,func), offset(offset_arg)
434
415
  { chain_sys_var(chain); }
435
 
  bool update(Session *session, set_var *var);
436
 
  void set_default(Session *session, enum_var_type type);
 
416
  bool update(THD *thd, set_var *var);
 
417
  void set_default(THD *thd, enum_var_type type);
437
418
  SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
438
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
439
 
                           const LEX_STRING *base);
 
419
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
440
420
};
441
421
 
442
422
 
443
 
class sys_var_session_uint64_t :public sys_var_session
 
423
class sys_var_thd_ulonglong :public sys_var_thd
444
424
{
445
 
  sys_check_func check_func;
446
425
public:
447
 
  uint64_t SV::*offset;
 
426
  ulonglong SV::*offset;
448
427
  bool only_global;
449
 
  sys_var_session_uint64_t(sys_var_chain *chain, const char *name_arg,
450
 
                           uint64_t SV::*offset_arg,
451
 
                           sys_after_update_func au_func= NULL,
452
 
                           sys_check_func c_func= NULL,
453
 
                           Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
454
 
    :sys_var_session(name_arg, au_func, binlog_status_arg),
455
 
    check_func(c_func),
456
 
    offset(offset_arg)
 
428
  sys_var_thd_ulonglong(sys_var_chain *chain, const char *name_arg, 
 
429
                        ulonglong SV::*offset_arg)
 
430
    :sys_var_thd(name_arg), offset(offset_arg)
457
431
  { chain_sys_var(chain); }
458
 
  sys_var_session_uint64_t(sys_var_chain *chain,
459
 
                           const char *name_arg,
460
 
                           uint64_t SV::*offset_arg,
461
 
                           sys_after_update_func func,
462
 
                           bool only_global_arg,
463
 
                           sys_check_func cfunc= NULL)
464
 
    :sys_var_session(name_arg, func),
465
 
    check_func(cfunc),
466
 
    offset(offset_arg),
 
432
  sys_var_thd_ulonglong(sys_var_chain *chain, const char *name_arg, 
 
433
                        ulonglong SV::*offset_arg,
 
434
                        sys_after_update_func func, bool only_global_arg)
 
435
    :sys_var_thd(name_arg, func), offset(offset_arg),
467
436
    only_global(only_global_arg)
468
437
  { chain_sys_var(chain); }
469
 
  bool update(Session *session, set_var *var);
470
 
  void set_default(Session *session, enum_var_type type);
 
438
  bool update(THD *thd, set_var *var);
 
439
  void set_default(THD *thd, enum_var_type type);
471
440
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
472
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
473
 
                           const LEX_STRING *base);
474
 
  bool check(Session *session, set_var *var);
475
 
  bool check_default(enum_var_type type)
476
 
  {
477
 
    return type == OPT_GLOBAL && !option_limits;
478
 
  }
479
 
  bool check_type(enum_var_type type)
480
 
  {
481
 
    return (only_global && type != OPT_GLOBAL);
482
 
  }
483
 
};
484
 
 
485
 
class sys_var_session_size_t :public sys_var_session
486
 
{
487
 
  sys_check_func check_func;
488
 
public:
489
 
  size_t SV::*offset;
490
 
  bool only_global;
491
 
  sys_var_session_size_t(sys_var_chain *chain, const char *name_arg,
492
 
                         size_t SV::*offset_arg,
493
 
                         sys_after_update_func au_func= NULL,
494
 
                         sys_check_func c_func= NULL,
495
 
                         Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
496
 
    :sys_var_session(name_arg, au_func, binlog_status_arg),
497
 
     check_func(c_func),
498
 
     offset(offset_arg)
499
 
  { chain_sys_var(chain); }
500
 
  sys_var_session_size_t(sys_var_chain *chain,
501
 
                         const char *name_arg,
502
 
                         size_t SV::*offset_arg,
503
 
                         sys_after_update_func func,
504
 
                         bool only_global_arg,
505
 
                         sys_check_func cfunc= NULL)
506
 
    :sys_var_session(name_arg, func),
507
 
     check_func(cfunc),
508
 
     offset(offset_arg),
509
 
     only_global(only_global_arg)
510
 
  { chain_sys_var(chain); }
511
 
  bool update(Session *session, set_var *var);
512
 
  void set_default(Session *session, enum_var_type type);
513
 
  SHOW_TYPE show_type() { return SHOW_SIZE; }
514
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
515
 
                           const LEX_STRING *base);
516
 
  bool check(Session *session, set_var *var);
517
 
  bool check_default(enum_var_type type)
518
 
  {
519
 
    return type == OPT_GLOBAL && !option_limits;
520
 
  }
521
 
  bool check_type(enum_var_type type)
522
 
  {
523
 
    return (only_global && type != OPT_GLOBAL);
524
 
  }
525
 
};
526
 
 
527
 
 
528
 
class sys_var_session_bool :public sys_var_session
529
 
{
530
 
public:
531
 
  bool SV::*offset;
532
 
  sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
533
 
    :sys_var_session(name_arg), offset(offset_arg)
534
 
  { chain_sys_var(chain); }
535
 
  sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
 
441
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
442
  bool check(THD *thd, set_var *var);
 
443
  bool check_default(enum_var_type type)
 
444
  {
 
445
    return type == OPT_GLOBAL && !option_limits;
 
446
  }
 
447
  bool check_type(enum_var_type type)
 
448
  {
 
449
    return (only_global && type != OPT_GLOBAL);
 
450
  }
 
451
};
 
452
 
 
453
 
 
454
class sys_var_thd_bool :public sys_var_thd
 
455
{
 
456
public:
 
457
  my_bool SV::*offset;
 
458
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg)
 
459
    :sys_var_thd(name_arg), offset(offset_arg)
 
460
  { chain_sys_var(chain); }
 
461
  sys_var_thd_bool(sys_var_chain *chain, const char *name_arg, my_bool SV::*offset_arg,
536
462
                   sys_after_update_func func)
537
 
    :sys_var_session(name_arg,func), offset(offset_arg)
 
463
    :sys_var_thd(name_arg,func), offset(offset_arg)
538
464
  { chain_sys_var(chain); }
539
 
  bool update(Session *session, set_var *var);
540
 
  void set_default(Session *session, enum_var_type type);
 
465
  bool update(THD *thd, set_var *var);
 
466
  void set_default(THD *thd, enum_var_type type);
541
467
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
542
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
543
 
                           const LEX_STRING *base);
544
 
  bool check(Session *session, set_var *var)
 
468
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
469
  bool check(THD *thd, set_var *var)
545
470
  {
546
 
    return check_enum(session, var, &bool_typelib);
 
471
    return check_enum(thd, var, &bool_typelib);
547
472
  }
548
 
  bool check_update_type(Item_result)
549
 
  { return 0; }
 
473
  bool check_update_type(Item_result type) { return 0; }
550
474
};
551
475
 
552
476
 
553
 
class sys_var_session_enum :public sys_var_session
 
477
class sys_var_thd_enum :public sys_var_thd
554
478
{
555
479
protected:
556
 
  uint32_t SV::*offset;
 
480
  ulong SV::*offset;
557
481
  TYPELIB *enum_names;
558
482
  sys_check_func check_func;
559
483
public:
560
 
  sys_var_session_enum(sys_var_chain *chain, const char *name_arg,
561
 
                   uint32_t SV::*offset_arg, TYPELIB *typelib,
 
484
  sys_var_thd_enum(sys_var_chain *chain, const char *name_arg,
 
485
                   ulong SV::*offset_arg, TYPELIB *typelib,
562
486
                   sys_after_update_func func= NULL,
563
 
                   sys_check_func check_f= NULL)
564
 
    :sys_var_session(name_arg, func), offset(offset_arg),
565
 
    enum_names(typelib), check_func(check_f)
 
487
                   sys_check_func check= NULL)
 
488
    :sys_var_thd(name_arg, func), offset(offset_arg),
 
489
    enum_names(typelib), check_func(check)
566
490
  { chain_sys_var(chain); }
567
 
  bool check(Session *session, set_var *var)
 
491
  bool check(THD *thd, set_var *var)
568
492
  {
569
493
    int ret= 0;
570
494
    if (check_func)
571
 
      ret= (*check_func)(session, var);
572
 
    return ret ? ret : check_enum(session, var, enum_names);
 
495
      ret= (*check_func)(thd, var);
 
496
    return ret ? ret : check_enum(thd, var, enum_names);
573
497
  }
574
 
  bool update(Session *session, set_var *var);
575
 
  void set_default(Session *session, enum_var_type type);
 
498
  bool update(THD *thd, set_var *var);
 
499
  void set_default(THD *thd, enum_var_type type);
576
500
  SHOW_TYPE show_type() { return SHOW_CHAR; }
577
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
578
 
                           const LEX_STRING *base);
579
 
  bool check_update_type(Item_result)
580
 
  { 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; }
581
503
};
582
504
 
583
505
 
584
506
 
585
 
class sys_var_session_optimizer_switch :public sys_var_session_enum
 
507
class sys_var_thd_optimizer_switch :public sys_var_thd_enum
586
508
{
587
509
public:
588
 
  sys_var_session_optimizer_switch(sys_var_chain *chain, const char *name_arg,
589
 
                                   uint32_t SV::*offset_arg)
590
 
    :sys_var_session_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib)
 
510
  sys_var_thd_optimizer_switch(sys_var_chain *chain, const char *name_arg, 
 
511
                               ulong SV::*offset_arg)
 
512
    :sys_var_thd_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib)
591
513
  {}
592
 
  bool check(Session *session, set_var *var)
 
514
  bool check(THD *thd, set_var *var)
593
515
  {
594
 
    return check_set(session, var, enum_names);
 
516
    return check_set(thd, var, enum_names);
595
517
  }
596
 
  void set_default(Session *session, enum_var_type type);
597
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
598
 
                           const LEX_STRING *base);
599
 
  static bool symbolic_mode_representation(Session *session, uint32_t sql_mode,
 
518
  void set_default(THD *thd, enum_var_type type);
 
519
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
520
  static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode,
600
521
                                           LEX_STRING *rep);
601
522
};
602
523
 
603
524
 
604
 
class sys_var_session_storage_engine :public sys_var_session
 
525
class sys_var_thd_storage_engine :public sys_var_thd
605
526
{
606
527
protected:
607
 
  StorageEngine *SV::*offset;
 
528
  plugin_ref SV::*offset;
608
529
public:
609
 
  sys_var_session_storage_engine(sys_var_chain *chain, const char *name_arg,
610
 
                                 StorageEngine *SV::*offset_arg)
611
 
    :sys_var_session(name_arg), offset(offset_arg)
 
530
  sys_var_thd_storage_engine(sys_var_chain *chain, const char *name_arg, 
 
531
                             plugin_ref SV::*offset_arg)
 
532
    :sys_var_thd(name_arg), offset(offset_arg)
612
533
  { chain_sys_var(chain); }
613
 
  bool check(Session *session, set_var *var);
 
534
  bool check(THD *thd, set_var *var);
614
535
  SHOW_TYPE show_type() { return SHOW_CHAR; }
615
536
  bool check_update_type(Item_result type)
616
537
  {
617
538
    return type != STRING_RESULT;               /* Only accept strings */
618
539
  }
619
 
  void set_default(Session *session, enum_var_type type);
620
 
  bool update(Session *session, set_var *var);
621
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
622
 
                           const LEX_STRING *base);
 
540
  void set_default(THD *thd, enum_var_type type);
 
541
  bool update(THD *thd, set_var *var);
 
542
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
623
543
};
624
544
 
625
 
class sys_var_session_bit :public sys_var_session
 
545
class sys_var_thd_bit :public sys_var_thd
626
546
{
627
547
  sys_check_func check_func;
628
548
  sys_update_func update_func;
629
549
public:
630
 
  uint64_t bit_flag;
 
550
  ulonglong bit_flag;
631
551
  bool reverse;
632
 
  sys_var_session_bit(sys_var_chain *chain, const char *name_arg,
 
552
  sys_var_thd_bit(sys_var_chain *chain, const char *name_arg,
633
553
                  sys_check_func c_func, sys_update_func u_func,
634
 
                  uint64_t bit, bool reverse_arg=0,
 
554
                  ulonglong bit, bool reverse_arg=0,
635
555
                  Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
636
 
    :sys_var_session(name_arg, NULL, binlog_status_arg), check_func(c_func),
 
556
    :sys_var_thd(name_arg, NULL, binlog_status_arg), check_func(c_func),
637
557
    update_func(u_func), bit_flag(bit), reverse(reverse_arg)
638
558
  { chain_sys_var(chain); }
639
 
  bool check(Session *session, set_var *var);
640
 
  bool update(Session *session, set_var *var);
641
 
  bool check_update_type(Item_result)
642
 
  { return 0; }
 
559
  bool check(THD *thd, set_var *var);
 
560
  bool update(THD *thd, set_var *var);
 
561
  bool check_update_type(Item_result type) { return 0; }
643
562
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
644
563
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
645
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
646
 
                           const LEX_STRING *base);
647
 
};
 
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
 
648
581
 
649
582
/* some variables that require special handling */
650
583
 
655
588
                    Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
656
589
    :sys_var(name_arg, NULL, binlog_status_arg)
657
590
  { chain_sys_var(chain); }
658
 
  bool update(Session *session, set_var *var);
659
 
  void set_default(Session *session, enum_var_type type);
 
591
  bool update(THD *thd, set_var *var);
 
592
  void set_default(THD *thd, enum_var_type type);
660
593
  bool check_type(enum_var_type type)    { return type == OPT_GLOBAL; }
661
 
  bool check_default(enum_var_type)
662
 
  { return 0; }
663
 
  SHOW_TYPE show_type(void) { return SHOW_LONG; }
664
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
665
 
                           const 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);
666
597
};
667
598
 
668
599
 
673
604
                         Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
674
605
    :sys_var(name_arg, NULL, binlog_status_arg)
675
606
  { chain_sys_var(chain); }
676
 
  bool update(Session *session, set_var *var);
677
 
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
678
 
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
679
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
680
 
                           const LEX_STRING *base);
681
 
};
682
 
 
683
 
 
684
 
class sys_var_collation :public sys_var_session
 
607
  bool update(THD *thd, set_var *var);
 
608
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
 
609
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
 
610
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
611
};
 
612
 
 
613
 
 
614
class sys_var_insert_id :public sys_var
 
615
{
 
616
public:
 
617
  sys_var_insert_id(sys_var_chain *chain, const char *name_arg)
 
618
    :sys_var(name_arg)
 
619
  { chain_sys_var(chain); }
 
620
  bool update(THD *thd, set_var *var);
 
621
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
 
622
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
 
623
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
624
};
 
625
 
 
626
 
 
627
class sys_var_rand_seed1 :public sys_var
 
628
{
 
629
public:
 
630
  sys_var_rand_seed1(sys_var_chain *chain, const char *name_arg,
 
631
                     Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
 
632
    :sys_var(name_arg, NULL, binlog_status_arg)
 
633
  { chain_sys_var(chain); }
 
634
  bool update(THD *thd, set_var *var);
 
635
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
 
636
};
 
637
 
 
638
class sys_var_rand_seed2 :public sys_var
 
639
{
 
640
public:
 
641
  sys_var_rand_seed2(sys_var_chain *chain, const char *name_arg,
 
642
                     Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
 
643
    :sys_var(name_arg, NULL, binlog_status_arg)
 
644
  { chain_sys_var(chain); }
 
645
  bool update(THD *thd, set_var *var);
 
646
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
 
647
};
 
648
 
 
649
 
 
650
class sys_var_collation :public sys_var_thd
685
651
{
686
652
public:
687
653
  sys_var_collation(const char *name_arg,
688
654
                    Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
689
 
    :sys_var_session(name_arg, NULL, binlog_status_arg)
 
655
    :sys_var_thd(name_arg, NULL, binlog_status_arg)
 
656
  {
 
657
    no_support_one_shot= 0;
 
658
  }
 
659
  bool check(THD *thd, set_var *var);
 
660
  SHOW_TYPE show_type() { return SHOW_CHAR; }
 
661
  bool check_update_type(Item_result type)
 
662
  {
 
663
    return ((type != STRING_RESULT) && (type != INT_RESULT));
 
664
  }
 
665
  bool check_default(enum_var_type type) { return 0; }
 
666
  virtual void set_default(THD *thd, enum_var_type type)= 0;
 
667
};
 
668
 
 
669
class sys_var_character_set :public sys_var_thd
 
670
{
 
671
public:
 
672
  bool nullable;
 
673
  sys_var_character_set(const char *name_arg, bool is_nullable= 0,
 
674
                        Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
 
675
    :sys_var_thd(name_arg, NULL, binlog_status_arg), nullable(is_nullable)
 
676
  {
 
677
    /*
 
678
      In fact only almost all variables derived from sys_var_character_set
 
679
      support ONE_SHOT; character_set_results doesn't. But that's good enough.
 
680
    */
 
681
    no_support_one_shot= 0;
 
682
  }
 
683
  bool check(THD *thd, set_var *var);
 
684
  SHOW_TYPE show_type() { return SHOW_CHAR; }
 
685
  bool check_update_type(Item_result type)
 
686
  {
 
687
    return ((type != STRING_RESULT) && (type != INT_RESULT));
 
688
  }
 
689
  bool check_default(enum_var_type type) { return 0; }
 
690
  bool update(THD *thd, set_var *var);
 
691
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
692
  virtual void set_default(THD *thd, enum_var_type type)= 0;
 
693
  virtual CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
 
694
};
 
695
 
 
696
class sys_var_character_set_sv :public sys_var_character_set
 
697
{
 
698
  CHARSET_INFO *SV::*offset;
 
699
  CHARSET_INFO **global_default;
 
700
public:
 
701
  sys_var_character_set_sv(sys_var_chain *chain, const char *name_arg,
 
702
                           CHARSET_INFO *SV::*offset_arg,
 
703
                           CHARSET_INFO **global_default_arg,
 
704
                           bool is_nullable= 0,
 
705
                           Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
 
706
    : sys_var_character_set(name_arg, is_nullable, binlog_status_arg),
 
707
    offset(offset_arg), global_default(global_default_arg)
 
708
  { chain_sys_var(chain); }
 
709
  void set_default(THD *thd, enum_var_type type);
 
710
  CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
 
711
};
 
712
 
 
713
 
 
714
class sys_var_character_set_client: public sys_var_character_set_sv
 
715
{
 
716
public:
 
717
  sys_var_character_set_client(sys_var_chain *chain, const char *name_arg,
 
718
                               CHARSET_INFO *SV::*offset_arg,
 
719
                               CHARSET_INFO **global_default_arg,
 
720
                               Binlog_status_enum binlog_status_arg)
 
721
    : sys_var_character_set_sv(chain, name_arg, offset_arg, global_default_arg,
 
722
                               0, binlog_status_arg)
690
723
  { }
691
 
  bool check(Session *session, set_var *var);
692
 
  SHOW_TYPE show_type() { return SHOW_CHAR; }
693
 
  bool check_update_type(Item_result type)
694
 
  {
695
 
    return ((type != STRING_RESULT) && (type != INT_RESULT));
696
 
  }
697
 
  bool check_default(enum_var_type) { return 0; }
698
 
  virtual void set_default(Session *session, enum_var_type type)= 0;
 
724
  bool check(THD *thd, set_var *var);
 
725
};
 
726
 
 
727
 
 
728
class sys_var_character_set_database :public sys_var_character_set
 
729
{
 
730
public:
 
731
  sys_var_character_set_database(sys_var_chain *chain, const char *name_arg,
 
732
                                 Binlog_status_enum binlog_status_arg=
 
733
                                   NOT_IN_BINLOG)
 
734
    : sys_var_character_set(name_arg, 0, binlog_status_arg)
 
735
  { chain_sys_var(chain); }
 
736
  void set_default(THD *thd, enum_var_type type);
 
737
  CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
699
738
};
700
739
 
701
740
class sys_var_collation_sv :public sys_var_collation
702
741
{
703
 
  const CHARSET_INFO *SV::*offset;
704
 
  const CHARSET_INFO **global_default;
 
742
  CHARSET_INFO *SV::*offset;
 
743
  CHARSET_INFO **global_default;
705
744
public:
706
745
  sys_var_collation_sv(sys_var_chain *chain, const char *name_arg,
707
 
                       const CHARSET_INFO *SV::*offset_arg,
708
 
                       const CHARSET_INFO **global_default_arg,
 
746
                       CHARSET_INFO *SV::*offset_arg,
 
747
                       CHARSET_INFO **global_default_arg,
709
748
                       Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
710
749
    :sys_var_collation(name_arg, binlog_status_arg),
711
750
    offset(offset_arg), global_default(global_default_arg)
712
751
  {
713
752
    chain_sys_var(chain);
714
753
  }
715
 
  bool update(Session *session, set_var *var);
716
 
  void set_default(Session *session, enum_var_type type);
717
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
718
 
                           const LEX_STRING *base);
 
754
  bool update(THD *thd, set_var *var);
 
755
  void set_default(THD *thd, enum_var_type type);
 
756
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
719
757
};
720
758
 
721
759
 
724
762
protected:
725
763
  size_t offset;
726
764
public:
727
 
  sys_var_key_cache_param(sys_var_chain *chain, const char *name_arg,
 
765
  sys_var_key_cache_param(sys_var_chain *chain, const char *name_arg, 
728
766
                          size_t offset_arg)
729
767
    :sys_var(name_arg), offset(offset_arg)
730
768
  { chain_sys_var(chain); }
731
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
732
 
                           const LEX_STRING *base);
733
 
  bool check_default(enum_var_type)
734
 
  { 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; }
735
771
  bool is_struct() { return 1; }
736
772
};
737
773
 
743
779
    :sys_var_key_cache_param(chain, name_arg,
744
780
                             offsetof(KEY_CACHE, param_buff_size))
745
781
  {}
746
 
  bool update(Session *session, set_var *var);
 
782
  bool update(THD *thd, set_var *var);
747
783
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
748
784
};
749
785
 
750
786
 
751
 
class sys_var_key_cache_uint32_t :public sys_var_key_cache_param
 
787
class sys_var_key_cache_long :public sys_var_key_cache_param
752
788
{
753
789
public:
754
 
  sys_var_key_cache_uint32_t(sys_var_chain *chain, const char *name_arg, size_t offset_arg)
 
790
  sys_var_key_cache_long(sys_var_chain *chain, const char *name_arg, size_t offset_arg)
755
791
    :sys_var_key_cache_param(chain, name_arg, offset_arg)
756
792
  {}
757
 
  bool update(Session *session, set_var *var);
758
 
  SHOW_TYPE show_type() { return SHOW_INT; }
759
 
};
 
793
  bool update(THD *thd, set_var *var);
 
794
  SHOW_TYPE show_type() { return SHOW_LONG; }
 
795
};
 
796
 
 
797
 
 
798
class sys_var_thd_date_time_format :public sys_var_thd
 
799
{
 
800
  DATE_TIME_FORMAT *SV::*offset;
 
801
  timestamp_type date_time_type;
 
802
public:
 
803
  sys_var_thd_date_time_format(sys_var_chain *chain, const char *name_arg,
 
804
                               DATE_TIME_FORMAT *SV::*offset_arg,
 
805
                               timestamp_type date_time_type_arg)
 
806
    :sys_var_thd(name_arg), offset(offset_arg),
 
807
    date_time_type(date_time_type_arg)
 
808
  { chain_sys_var(chain); }
 
809
  SHOW_TYPE show_type() { return SHOW_CHAR; }
 
810
  bool check_update_type(Item_result type)
 
811
  {
 
812
    return type != STRING_RESULT;               /* Only accept strings */
 
813
  }
 
814
  bool check_default(enum_var_type type) { return 0; }
 
815
  bool check(THD *thd, set_var *var);
 
816
  bool update(THD *thd, set_var *var);
 
817
  void update2(THD *thd, enum_var_type type, DATE_TIME_FORMAT *new_value);
 
818
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
819
  void set_default(THD *thd, enum_var_type type);
 
820
};
 
821
 
 
822
 
 
823
class sys_var_log_state :public sys_var_bool_ptr
 
824
{
 
825
  uint log_type;
 
826
public:
 
827
  sys_var_log_state(sys_var_chain *chain, const char *name_arg, my_bool *value_arg, 
 
828
                    uint log_type_arg)
 
829
    :sys_var_bool_ptr(chain, name_arg, value_arg), log_type(log_type_arg) {}
 
830
  bool update(THD *thd, set_var *var);
 
831
  void set_default(THD *thd, enum_var_type type);
 
832
};
 
833
 
 
834
 
 
835
class sys_var_set :public sys_var
 
836
{
 
837
protected:
 
838
  ulong *value;
 
839
  TYPELIB *enum_names;
 
840
public:
 
841
  sys_var_set(sys_var_chain *chain, const char *name_arg, ulong *value_arg,
 
842
              TYPELIB *typelib, sys_after_update_func func)
 
843
    :sys_var(name_arg, func), value(value_arg), enum_names(typelib)
 
844
  { chain_sys_var(chain); }
 
845
  virtual bool check(THD *thd, set_var *var)
 
846
  {
 
847
    return check_set(thd, var, enum_names);
 
848
  }
 
849
  virtual void set_default(THD *thd, enum_var_type type)
 
850
  {  
 
851
    *value= 0;
 
852
  }
 
853
  bool update(THD *thd, set_var *var);
 
854
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
855
  bool check_update_type(Item_result type) { return 0; }
 
856
  SHOW_TYPE show_type() { return SHOW_CHAR; }
 
857
};
 
858
 
 
859
class sys_var_set_slave_mode :public sys_var_set
 
860
{
 
861
public:
 
862
  sys_var_set_slave_mode(sys_var_chain *chain, const char *name_arg,
 
863
                         ulong *value_arg,
 
864
                         TYPELIB *typelib, sys_after_update_func func) :
 
865
    sys_var_set(chain, name_arg, value_arg, typelib, func) {}
 
866
  void set_default(THD *thd, enum_var_type type);
 
867
  bool check(THD *thd, set_var *var);
 
868
  bool update(THD *thd, set_var *var);
 
869
};
 
870
 
 
871
class sys_var_log_output :public sys_var
 
872
{
 
873
  ulong *value;
 
874
  TYPELIB *enum_names;
 
875
public:
 
876
  sys_var_log_output(sys_var_chain *chain, const char *name_arg, ulong *value_arg,
 
877
                     TYPELIB *typelib, sys_after_update_func func)
 
878
    :sys_var(name_arg,func), value(value_arg), enum_names(typelib)
 
879
  {
 
880
    chain_sys_var(chain);
 
881
    set_allow_empty_value(FALSE);
 
882
  }
 
883
  virtual bool check(THD *thd, set_var *var)
 
884
  {
 
885
    return check_set(thd, var, enum_names);
 
886
  }
 
887
  bool update(THD *thd, set_var *var);
 
888
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
889
  bool check_update_type(Item_result type) { return 0; }
 
890
  void set_default(THD *thd, enum_var_type type);
 
891
  SHOW_TYPE show_type() { return SHOW_CHAR; }
 
892
};
 
893
 
760
894
 
761
895
/* Variable that you can only read from */
762
896
 
769
903
  sys_var_readonly(sys_var_chain *chain, const char *name_arg, enum_var_type type,
770
904
                   SHOW_TYPE show_type_arg,
771
905
                   sys_value_ptr_func value_ptr_func_arg)
772
 
    :sys_var(name_arg), var_type(type),
 
906
    :sys_var(name_arg), var_type(type), 
773
907
       show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
774
908
  { chain_sys_var(chain); }
775
 
  bool update(Session *, set_var *)
776
 
  { return 1; }
777
 
  bool check_default(enum_var_type)
778
 
  { return 1; }
 
909
  bool update(THD *thd, set_var *var) { return 1; }
 
910
  bool check_default(enum_var_type type) { return 1; }
779
911
  bool check_type(enum_var_type type) { return type != var_type; }
780
 
  bool check_update_type(Item_result)
781
 
  { return 1; }
782
 
  unsigned char *value_ptr(Session *session, enum_var_type,
783
 
                           const LEX_STRING *)
 
912
  bool check_update_type(Item_result type) { return 1; }
 
913
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
784
914
  {
785
 
    return (*value_ptr_func)(session);
 
915
    return (*value_ptr_func)(thd);
786
916
  }
787
 
  SHOW_TYPE show_type(void) { return show_type_value; }
788
 
  bool is_readonly(void) const { return 1; }
 
917
  SHOW_TYPE show_type() { return show_type_value; }
 
918
  bool is_readonly() const { return 1; }
789
919
};
790
920
 
791
921
 
797
927
  sys_var_have_option(sys_var_chain *chain, const char *variable_name):
798
928
    sys_var(variable_name)
799
929
  { chain_sys_var(chain); }
800
 
  unsigned char *value_ptr(Session *, enum_var_type,
801
 
                           const LEX_STRING *)
 
930
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
802
931
  {
803
 
    return (unsigned char*) show_comp_option_name[get_option()];
 
932
    return (uchar*) show_comp_option_name[get_option()];
804
933
  }
805
 
  bool update(Session *, set_var *) { return 1; }
806
 
  bool check_default(enum_var_type)
807
 
  { return 1; }
 
934
  bool update(THD *thd, set_var *var) { return 1; }
 
935
  bool check_default(enum_var_type type) { return 1; }
808
936
  bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
809
 
  bool check_update_type(Item_result)
810
 
  { return 1; }
 
937
  bool check_update_type(Item_result type) { return 1; }
811
938
  SHOW_TYPE show_type() { return SHOW_CHAR; }
812
939
  bool is_readonly() const { return 1; }
813
940
};
830
957
class sys_var_have_plugin: public sys_var_have_option
831
958
{
832
959
  const char *plugin_name_str;
833
 
  const uint32_t plugin_name_len;
 
960
  const uint plugin_name_len;
834
961
  const int plugin_type;
835
962
 
836
963
public:
837
964
  sys_var_have_plugin(sys_var_chain *chain, const char *variable_name,
838
 
                      const char *plugin_name_str_arg, uint32_t plugin_name_len_arg,
 
965
                      const char *plugin_name_str_arg, uint plugin_name_len_arg, 
839
966
                      int plugin_type_arg):
840
 
    sys_var_have_option(chain, variable_name),
 
967
    sys_var_have_option(chain, variable_name), 
841
968
    plugin_name_str(plugin_name_str_arg), plugin_name_len(plugin_name_len_arg),
842
969
    plugin_type(plugin_type_arg)
843
970
  { }
846
973
};
847
974
 
848
975
 
849
 
class sys_var_session_time_zone :public sys_var_session
 
976
class sys_var_thd_time_zone :public sys_var_thd
850
977
{
851
978
public:
852
 
  sys_var_session_time_zone(sys_var_chain *chain, const char *name_arg,
 
979
  sys_var_thd_time_zone(sys_var_chain *chain, const char *name_arg,
853
980
                        Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
854
 
    :sys_var_session(name_arg, NULL, binlog_status_arg)
 
981
    :sys_var_thd(name_arg, NULL, binlog_status_arg)
855
982
  {
 
983
    no_support_one_shot= 0;
856
984
    chain_sys_var(chain);
857
985
  }
858
 
  bool check(Session *session, set_var *var);
 
986
  bool check(THD *thd, set_var *var);
859
987
  SHOW_TYPE show_type() { return SHOW_CHAR; }
860
988
  bool check_update_type(Item_result type)
861
989
  {
862
990
    return type != STRING_RESULT;               /* Only accept strings */
863
991
  }
864
 
  bool check_default(enum_var_type)
865
 
  { return 0; }
866
 
  bool update(Session *session, set_var *var);
867
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
868
 
                           const LEX_STRING *base);
869
 
  virtual void set_default(Session *session, enum_var_type type);
870
 
};
871
 
 
872
 
 
873
 
class sys_var_microseconds :public sys_var_session
874
 
{
875
 
  uint64_t SV::*offset;
 
992
  bool check_default(enum_var_type type) { return 0; }
 
993
  bool update(THD *thd, set_var *var);
 
994
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
995
  virtual void set_default(THD *thd, enum_var_type type);
 
996
};
 
997
 
 
998
 
 
999
class sys_var_max_user_conn : public sys_var_thd
 
1000
{
 
1001
public:
 
1002
  sys_var_max_user_conn(sys_var_chain *chain, const char *name_arg):
 
1003
    sys_var_thd(name_arg)
 
1004
  { chain_sys_var(chain); }
 
1005
  bool check(THD *thd, set_var *var);
 
1006
  bool update(THD *thd, set_var *var);
 
1007
  bool check_default(enum_var_type type)
 
1008
  {
 
1009
    return type != OPT_GLOBAL || !option_limits;
 
1010
  }
 
1011
  void set_default(THD *thd, enum_var_type type);
 
1012
  SHOW_TYPE show_type() { return SHOW_INT; }
 
1013
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1014
};
 
1015
 
 
1016
 
 
1017
class sys_var_microseconds :public sys_var_thd
 
1018
{
 
1019
  ulonglong SV::*offset;
876
1020
public:
877
1021
  sys_var_microseconds(sys_var_chain *chain, const char *name_arg,
878
 
                       uint64_t SV::*offset_arg):
879
 
    sys_var_session(name_arg), offset(offset_arg)
 
1022
                       ulonglong SV::*offset_arg):
 
1023
    sys_var_thd(name_arg), offset(offset_arg)
880
1024
  { chain_sys_var(chain); }
881
 
  bool check(Session *, set_var *) {return 0;}
882
 
  bool update(Session *session, set_var *var);
883
 
  void set_default(Session *session, enum_var_type type);
 
1025
  bool check(THD *thd, set_var *var) {return 0;}
 
1026
  bool update(THD *thd, set_var *var);
 
1027
  void set_default(THD *thd, enum_var_type type);
884
1028
  SHOW_TYPE show_type() { return SHOW_DOUBLE; }
885
1029
  bool check_update_type(Item_result type)
886
1030
  {
887
1031
    return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
888
1032
  }
889
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
890
 
                           const LEX_STRING *base);
891
 
};
892
 
 
893
 
class sys_var_session_lc_time_names :public sys_var_session
894
 
{
895
 
public:
896
 
  sys_var_session_lc_time_names(sys_var_chain *chain, const char *name_arg,
 
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);
 
1047
};
 
1048
 
 
1049
/**
 
1050
  Handler for setting the system variable --read-only.
 
1051
*/
 
1052
 
 
1053
class sys_var_opt_readonly :public sys_var_bool_ptr
 
1054
{
 
1055
public:
 
1056
  sys_var_opt_readonly(sys_var_chain *chain, const char *name_arg, 
 
1057
                       my_bool *value_arg) :
 
1058
    sys_var_bool_ptr(chain, name_arg, value_arg) {};
 
1059
  ~sys_var_opt_readonly() {};
 
1060
  bool update(THD *thd, set_var *var);
 
1061
};
 
1062
 
 
1063
 
 
1064
class sys_var_thd_lc_time_names :public sys_var_thd
 
1065
{
 
1066
public:
 
1067
  sys_var_thd_lc_time_names(sys_var_chain *chain, const char *name_arg,
897
1068
                            Binlog_status_enum binlog_status_arg= NOT_IN_BINLOG)
898
 
    : sys_var_session(name_arg, NULL, binlog_status_arg)
 
1069
    : sys_var_thd(name_arg, NULL, binlog_status_arg)
899
1070
  {
 
1071
#if MYSQL_VERSION_ID < 50000
 
1072
    no_support_one_shot= 0;
 
1073
#endif
900
1074
    chain_sys_var(chain);
901
1075
  }
902
 
  bool check(Session *session, set_var *var);
 
1076
  bool check(THD *thd, set_var *var);
903
1077
  SHOW_TYPE show_type() { return SHOW_CHAR; }
904
1078
  bool check_update_type(Item_result type)
905
1079
  {
906
1080
    return ((type != STRING_RESULT) && (type != INT_RESULT));
907
1081
  }
908
 
  bool check_default(enum_var_type)
909
 
  { return 0; }
910
 
  bool update(Session *session, set_var *var);
911
 
  unsigned char *value_ptr(Session *session, enum_var_type type,
912
 
                           const LEX_STRING *base);
913
 
  virtual void set_default(Session *session, enum_var_type type);
914
 
};
915
 
 
 
1082
  bool check_default(enum_var_type type) { return 0; }
 
1083
  bool update(THD *thd, set_var *var);
 
1084
  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1085
  virtual void set_default(THD *thd, enum_var_type type);
 
1086
};
 
1087
 
 
1088
 
 
1089
extern void fix_binlog_format_after_update(THD *thd, enum_var_type type);
 
1090
 
 
1091
class sys_var_thd_binlog_format :public sys_var_thd_enum
 
1092
{
 
1093
public:
 
1094
  sys_var_thd_binlog_format(sys_var_chain *chain, const char *name_arg, 
 
1095
                            ulong SV::*offset_arg)
 
1096
    :sys_var_thd_enum(chain, name_arg, offset_arg,
 
1097
                      &binlog_format_typelib,
 
1098
                      fix_binlog_format_after_update)
 
1099
  {};
 
1100
  bool is_readonly() const;
 
1101
};
916
1102
 
917
1103
/****************************************************************************
918
1104
  Classes for parsing of the SET command
923
1109
public:
924
1110
  set_var_base() {}
925
1111
  virtual ~set_var_base() {}
926
 
  virtual int check(Session *session)=0;        /* To check privileges etc. */
927
 
  virtual int update(Session *session)=0;       /* To set the value */
 
1112
  virtual int check(THD *thd)=0;        /* To check privileges etc. */
 
1113
  virtual int update(THD *thd)=0;       /* To set the value */
928
1114
  /* light check for PS */
 
1115
  virtual bool no_support_one_shot() { return 1; }
929
1116
};
930
1117
 
931
1118
 
932
 
/* MySQL internal variables */
 
1119
/* MySQL internal variables, like query_cache_size */
933
1120
 
934
1121
class set_var :public set_var_base
935
1122
{
939
1126
  enum_var_type type;
940
1127
  union
941
1128
  {
942
 
    const CHARSET_INFO *charset;
943
 
    uint32_t uint32_t_value;
944
 
    uint64_t uint64_t_value;
945
 
    size_t size_t_value;
946
 
    StorageEngine *storage_engine;
 
1129
    CHARSET_INFO *charset;
 
1130
    ulong ulong_value;
 
1131
    ulonglong ulonglong_value;
 
1132
    plugin_ref plugin;
 
1133
    DATE_TIME_FORMAT *date_time_format;
947
1134
    Time_zone *time_zone;
948
1135
    MY_LOCALE *locale_value;
949
1136
  } save_result;
960
1147
    if (value_arg && value_arg->type() == Item::FIELD_ITEM)
961
1148
    {
962
1149
      Item_field *item= (Item_field*) value_arg;
963
 
      if (!(value=new Item_string(item->field_name,
964
 
                  (uint32_t) strlen(item->field_name),
 
1150
      if (!(value=new Item_string(item->field_name, 
 
1151
                  (uint) strlen(item->field_name),
965
1152
                                  item->collation.collation)))
966
1153
        value=value_arg;                        /* Give error message later */
967
1154
    }
968
1155
    else
969
1156
      value=value_arg;
970
1157
  }
971
 
  int check(Session *session);
972
 
  int update(Session *session);
 
1158
  int check(THD *thd);
 
1159
  int update(THD *thd);
 
1160
  bool no_support_one_shot() { return var->no_support_one_shot; }
973
1161
};
974
1162
 
975
1163
 
982
1170
  set_var_user(Item_func_set_user_var *item)
983
1171
    :user_var_item(item)
984
1172
  {}
985
 
  int check(Session *session);
986
 
  int update(Session *session);
 
1173
  int check(THD *thd);
 
1174
  int update(THD *thd);
 
1175
};
 
1176
 
 
1177
/* For SET NAMES and SET CHARACTER SET */
 
1178
 
 
1179
class set_var_collation_client: public set_var_base
 
1180
{
 
1181
  CHARSET_INFO *character_set_client;
 
1182
  CHARSET_INFO *character_set_results;
 
1183
  CHARSET_INFO *collation_connection;
 
1184
public:
 
1185
  set_var_collation_client(CHARSET_INFO *client_coll_arg,
 
1186
                           CHARSET_INFO *connection_coll_arg,
 
1187
                           CHARSET_INFO *result_coll_arg)
 
1188
    :character_set_client(client_coll_arg),
 
1189
     character_set_results(result_coll_arg),
 
1190
     collation_connection(connection_coll_arg)
 
1191
  {}
 
1192
  int check(THD *thd);
 
1193
  int update(THD *thd);
987
1194
};
988
1195
 
989
1196
 
996
1203
 
997
1204
class NAMED_LIST :public ilink
998
1205
{
999
 
  std::string name;
 
1206
  const char *name;
 
1207
  uint name_length;
1000
1208
public:
1001
 
  unsigned char* data;
 
1209
  uchar* data;
1002
1210
 
1003
1211
  NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg,
1004
 
                   uint32_t name_length_arg, unsigned char* data_arg);
1005
 
  bool cmp(const char *name_cmp, uint32_t length);
 
1212
             uint name_length_arg, uchar* data_arg)
 
1213
    :name_length(name_length_arg), data(data_arg)
 
1214
  {
 
1215
    name= my_strndup(name_arg, name_length, MYF(MY_WME));
 
1216
    links->push_back(this);
 
1217
  }
 
1218
  inline bool cmp(const char *name_cmp, uint length)
 
1219
  {
 
1220
    return length == name_length && !memcmp(name, name_cmp, length);
 
1221
  }
 
1222
  ~NAMED_LIST()
 
1223
  {
 
1224
    my_free((uchar*) name, MYF(0));
 
1225
  }
1006
1226
  friend bool process_key_caches(process_key_cache_t func);
1007
1227
  friend void delete_elements(I_List<NAMED_LIST> *list,
1008
 
                              void (*free_element)(const char*,
1009
 
                                                   unsigned char*));
 
1228
                              void (*free_element)(const char*, uchar*));
1010
1229
};
1011
1230
 
1012
1231
/* updated in sql_acl.cc */
1013
1232
 
1014
 
extern sys_var_session_bool sys_old_alter_table;
 
1233
extern sys_var_thd_bool sys_old_alter_table;
 
1234
extern sys_var_thd_bool sys_old_passwords;
1015
1235
extern LEX_STRING default_key_cache_base;
1016
1236
 
1017
1237
/* For sql_yacc */
1027
1247
 
1028
1248
int set_var_init();
1029
1249
void set_var_free();
1030
 
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count);
1031
 
SHOW_VAR* enumerate_sys_vars(Session *session, bool sorted);
 
1250
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count);
 
1251
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted);
1032
1252
int mysql_add_sys_var_chain(sys_var *chain, struct my_option *long_options);
1033
1253
int mysql_del_sys_var_chain(sys_var *chain);
1034
 
sys_var *find_sys_var(Session *session, const char *str, uint32_t length=0);
1035
 
int sql_set_variables(Session *session, List<set_var_base> *var_list);
 
1254
sys_var *find_sys_var(THD *thd, const char *str, uint length=0);
 
1255
int sql_set_variables(THD *thd, List<set_var_base> *var_list);
1036
1256
bool not_all_support_one_shot(List<set_var_base> *var_list);
1037
 
void fix_delay_key_write(Session *session, enum_var_type type);
 
1257
void fix_delay_key_write(THD *thd, enum_var_type type);
1038
1258
void fix_slave_exec_mode(enum_var_type type);
1039
 
extern sys_var_session_time_zone sys_time_zone;
1040
 
extern sys_var_session_bit sys_autocommit;
1041
 
const CHARSET_INFO *get_old_charset_by_name(const char *old_name);
1042
 
unsigned char* find_named(I_List<NAMED_LIST> *list, const char *name, uint32_t length,
 
1259
ulong fix_sql_mode(ulong sql_mode);
 
1260
extern sys_var_const_str sys_charset_system;
 
1261
extern sys_var_str sys_init_connect;
 
1262
extern sys_var_str sys_init_slave;
 
1263
extern sys_var_thd_time_zone sys_time_zone;
 
1264
extern sys_var_thd_bit sys_autocommit;
 
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,
1043
1267
                NAMED_LIST **found);
1044
1268
 
1045
1269
extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
1046
1270
 
1047
1271
/* key_cache functions */
1048
 
KEY_CACHE *get_key_cache(const LEX_STRING *cache_name);
1049
 
KEY_CACHE *get_or_create_key_cache(const char *name, uint32_t length);
 
1272
KEY_CACHE *get_key_cache(LEX_STRING *cache_name);
 
1273
KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
1050
1274
void free_key_cache(const char *name, KEY_CACHE *key_cache);
1051
1275
bool process_key_caches(process_key_cache_t func);
1052
1276
void delete_elements(I_List<NAMED_LIST> *list,
1053
 
                     void (*free_element)(const char*, unsigned char*));
1054
 
 
1055
 
#endif /* DRIZZLED_ITEM_SET_H */
 
1277
                     void (*free_element)(const char*, uchar*));