~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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 by brian
clean slate
19
1122.2.10 by Monty Taylor
Fixed all of the include guards.
20
#ifndef DRIZZLED_SET_VAR_H
21
#define DRIZZLED_SET_VAR_H
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
22
656.1.34 by Monty Taylor
Got closer...
23
#include <string>
24
1122.2.13 by Monty Taylor
Header cleanup.
25
#include "drizzled/function/func.h"
26
#include "drizzled/function/set_user_var.h"
27
#include "drizzled/item/string.h"
28
#include "drizzled/item/field.h"
29
30
1 by brian
clean slate
31
/* Classes to support the SET command */
32
33
34
/****************************************************************************
35
  Variables that are changable runtime are declared using the
36
  following classes
37
****************************************************************************/
38
39
class sys_var;
40
class set_var;
41
class sys_var_pluginvar; /* opaque */
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
42
class Time_zone;
1 by brian
clean slate
43
typedef struct system_variables SV;
44
typedef struct my_locale_st MY_LOCALE;
45
1055.2.18 by Jay Pipes
Removes dead variables in set_var.h
46
extern TYPELIB bool_typelib;
47
extern TYPELIB optimizer_switch_typelib;
1 by brian
clean slate
48
520.1.21 by Brian Aker
THD -> Session rename
49
typedef int (*sys_check_func)(Session *,  set_var *);
50
typedef bool (*sys_update_func)(Session *, set_var *);
51
typedef void (*sys_after_update_func)(Session *,enum_var_type);
52
typedef void (*sys_set_default_func)(Session *, enum_var_type);
520.1.22 by Brian Aker
Second pass of thd cleanup
53
typedef unsigned char *(*sys_value_ptr_func)(Session *session);
1 by brian
clean slate
54
1022.2.37 by Monty Taylor
Moved more tolower calls to setup rather than during runtime.
55
static const std::vector<std::string> empty_aliases;
56
1 by brian
clean slate
57
struct sys_var_chain
58
{
59
  sys_var *first;
60
  sys_var *last;
61
};
62
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
63
/**
64
 * A class which represents a variable, either global or 
65
 * session-local.
66
 */
1 by brian
clean slate
67
class sys_var
68
{
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
69
protected:
70
  const std::string name; /**< The name of the variable */
71
  sys_after_update_func after_update; /**< Function pointer triggered after the variable's value is updated */
72
  struct my_option *option_limits; /**< Updated by by set_var_init() */
73
  bool m_allow_empty_value; /**< Does variable allow an empty value? */
1 by brian
clean slate
74
  sys_var *next;
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
75
public:
1101.1.27 by Monty Taylor
Fixed the plugin string valgrind leak.
76
  sys_var(const std::string name_arg, sys_after_update_func func= NULL)
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
77
    :
78
    name(name_arg),
79
    after_update(func),
51.1.46 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
80
    m_allow_empty_value(true)
1 by brian
clean slate
81
  {}
82
  virtual ~sys_var() {}
83
  void chain_sys_var(sys_var_chain *chain_arg)
84
  {
85
    if (chain_arg->last)
86
      chain_arg->last->next= this;
87
    else
88
      chain_arg->first= this;
89
    chain_arg->last= this;
90
  }
1022.2.37 by Monty Taylor
Moved more tolower calls to setup rather than during runtime.
91
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
92
  /** 
93
   * Returns the name of the variable.
94
   *
95
   * @note 
96
   *
97
   * So that we can exist in a Registry. We really need to formalize that 
98
   */
99
  inline const std::string &getName() const
100
  {
101
    return name;
102
  }
103
  /**
104
   * Returns a vector of strings representing aliases
105
   * for this variable's name.
106
   */
107
  const std::vector<std::string>& getAliases() const
108
  {
109
    return empty_aliases;
110
  }
111
  /**
112
   * Returns a pointer to the next sys_var, or NULL if none.
113
   */
114
  inline sys_var *getNext() const
115
  {
116
    return next;
117
  }
118
  /**
119
   * Sets the pointer to the next sys_var.
120
   *
121
   * @param Pointer to the next sys_var, or NULL if you set the tail...
122
   */
123
  inline void setNext(sys_var *in_next)
124
  {
125
    next= in_next;
126
  }
127
  /**
128
   * Returns a pointer to the variable's option limits
129
   */
130
  inline struct my_option *getOptionLimits() const
131
  {
132
    return option_limits;
133
  }
134
  /**
135
   * Sets the pointer to the variable's option limits
136
   *
137
   * @param Pointer to the option limits my_option variable
138
   */
139
  inline void setOptionLimits(struct my_option *in_option_limits)
140
  {
141
    option_limits= in_option_limits;
142
  }
143
  /** 
144
   * Returns the function pointer for after update trigger, or NULL if none.
145
   */
146
  inline sys_after_update_func getAfterUpdateTrigger() const
147
  {
148
    return after_update;
149
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
150
  virtual bool check(Session *session, set_var *var);
151
  bool check_enum(Session *session, set_var *var, const TYPELIB *enum_names);
152
  bool check_set(Session *session, set_var *var, TYPELIB *enum_names);
153
  virtual bool update(Session *session, set_var *var)=0;
644 by Brian Aker
Clean up warnings for Solaris.
154
  virtual void set_default(Session *, enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
155
  {}
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
156
  virtual SHOW_TYPE show_type()
157
  {
158
    return SHOW_UNDEF;
159
  }
779.3.10 by Monty Taylor
Turned on -Wshadow.
160
  virtual unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
161
  {
162
    return 0;
163
  }
1 by brian
clean slate
164
  virtual bool check_type(enum_var_type type)
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
165
  {
166
    return type != OPT_GLOBAL;
167
  }		/* Error if not GLOBAL */
1 by brian
clean slate
168
  virtual bool check_update_type(Item_result type)
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
169
  {
170
    return type != INT_RESULT;
171
  }		/* Assume INT */
644 by Brian Aker
Clean up warnings for Solaris.
172
  virtual bool check_default(enum_var_type)
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
173
  {
174
    return option_limits == 0;
175
  }
779.3.10 by Monty Taylor
Turned on -Wshadow.
176
  Item *item(Session *session, enum_var_type type, const LEX_STRING *base);
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
177
  virtual bool is_readonly() const
178
  {
179
    return 0;
180
  }
181
  virtual sys_var_pluginvar *cast_pluginvar()
182
  {
183
    return 0;
184
  }
1 by brian
clean slate
185
};
186
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
187
/**
188
 * A base class for all variables that require its access to
189
 * be guarded with a mutex.
190
 */
1 by brian
clean slate
191
class sys_var_global: public sys_var
192
{
193
protected:
194
  pthread_mutex_t *guard;
195
public:
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
196
  sys_var_global(const char *name_arg,
197
                 sys_after_update_func after_update_arg,
1 by brian
clean slate
198
                 pthread_mutex_t *guard_arg)
1055.2.20 by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters.
199
    :
200
      sys_var(name_arg, after_update_arg), 
201
      guard(guard_arg) 
202
  {}
1 by brian
clean slate
203
};
204
520.4.14 by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf.
205
class sys_var_uint32_t_ptr :public sys_var
206
{
207
  uint32_t *value;
208
public:
209
  sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
210
                       uint32_t *value_ptr_arg)
211
    :sys_var(name_arg),value(value_ptr_arg)
212
  { chain_sys_var(chain); }
213
  sys_var_uint32_t_ptr(sys_var_chain *chain, const char *name_arg,
214
                       uint32_t *value_ptr_arg,
215
                       sys_after_update_func func)
216
    :sys_var(name_arg,func), value(value_ptr_arg)
217
  { chain_sys_var(chain); }
910.4.10 by Stewart Smith
fix system variables for correct endian architectures.
218
  bool check(Session *session, set_var *var);
520.4.14 by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf.
219
  bool update(Session *session, set_var *var);
220
  void set_default(Session *session, enum_var_type type);
910.4.18 by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64
221
  SHOW_TYPE show_type() { return SHOW_INT; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
222
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
520.4.14 by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf.
223
  { return (unsigned char*) value; }
224
};
225
226
151 by Brian Aker
Ulonglong to uint64_t
227
class sys_var_uint64_t_ptr :public sys_var
1 by brian
clean slate
228
{
151 by Brian Aker
Ulonglong to uint64_t
229
  uint64_t *value;
10 by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs
230
public:
151 by Brian Aker
Ulonglong to uint64_t
231
  sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg)
1 by brian
clean slate
232
    :sys_var(name_arg),value(value_ptr_arg)
233
  { chain_sys_var(chain); }
151 by Brian Aker
Ulonglong to uint64_t
234
  sys_var_uint64_t_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg,
1 by brian
clean slate
235
		       sys_after_update_func func)
236
    :sys_var(name_arg,func), value(value_ptr_arg)
237
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
238
  bool update(Session *session, set_var *var);
239
  void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
240
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
241
  unsigned char *value_ptr(Session *, enum_var_type,
242
                           const LEX_STRING *)
481 by Brian Aker
Remove all of uchar.
243
  { return (unsigned char*) value; }
1 by brian
clean slate
244
};
245
629.4.1 by Monty Taylor
First step in support size_t sys_var stuff.
246
class sys_var_size_t_ptr :public sys_var
247
{
248
  size_t *value;
249
public:
250
  sys_var_size_t_ptr(sys_var_chain *chain, const char *name_arg, size_t *value_ptr_arg)
251
    :sys_var(name_arg),value(value_ptr_arg)
252
  { chain_sys_var(chain); }
253
  sys_var_size_t_ptr(sys_var_chain *chain, const char *name_arg, size_t *value_ptr_arg,
254
                     sys_after_update_func func)
255
    :sys_var(name_arg,func), value(value_ptr_arg)
256
  { chain_sys_var(chain); }
257
  bool update(Session *session, set_var *var);
258
  void set_default(Session *session, enum_var_type type);
259
  SHOW_TYPE show_type() { return SHOW_SIZE; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
260
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
629.4.1 by Monty Taylor
First step in support size_t sys_var stuff.
261
  { return (unsigned char*) value; }
262
};
1 by brian
clean slate
263
264
class sys_var_bool_ptr :public sys_var
265
{
266
public:
146 by Brian Aker
my_bool cleanup.
267
  bool *value;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
268
  sys_var_bool_ptr(sys_var_chain *chain, const char *name_arg, bool *value_arg)
146 by Brian Aker
my_bool cleanup.
269
    :sys_var(name_arg),value(value_arg)
270
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
271
  bool check(Session *session, set_var *var)
146 by Brian Aker
my_bool cleanup.
272
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
273
    return check_enum(session, var, &bool_typelib);
146 by Brian Aker
my_bool cleanup.
274
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
275
  bool update(Session *session, set_var *var);
276
  void set_default(Session *session, enum_var_type type);
146 by Brian Aker
my_bool cleanup.
277
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
278
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
481 by Brian Aker
Remove all of uchar.
279
  { return (unsigned char*) value; }
644 by Brian Aker
Clean up warnings for Solaris.
280
  bool check_update_type(Item_result)
146 by Brian Aker
my_bool cleanup.
281
  { return 0; }
282
};
283
1 by brian
clean slate
284
class sys_var_bool_ptr_readonly :public sys_var_bool_ptr
285
{
286
public:
287
  sys_var_bool_ptr_readonly(sys_var_chain *chain, const char *name_arg,
147 by Brian Aker
More my_bool conversion. This time the set_var class.
288
                            bool *value_arg)
1 by brian
clean slate
289
    :sys_var_bool_ptr(chain, name_arg, value_arg)
290
  {}
291
  bool is_readonly() const { return 1; }
292
};
293
294
295
class sys_var_str :public sys_var
296
{
297
public:
298
  char *value;					// Pointer to allocated string
482 by Brian Aker
Remove uint.
299
  uint32_t value_length;
1 by brian
clean slate
300
  sys_check_func check_func;
301
  sys_update_func update_func;
302
  sys_set_default_func set_default_func;
303
  sys_var_str(sys_var_chain *chain, const char *name_arg,
304
	      sys_check_func check_func_arg,
305
	      sys_update_func update_func_arg,
306
	      sys_set_default_func set_default_func_arg,
307
              char *value_arg)
308
    :sys_var(name_arg), value(value_arg), check_func(check_func_arg),
309
    update_func(update_func_arg),set_default_func(set_default_func_arg)
310
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
311
  bool check(Session *session, set_var *var);
312
  bool update(Session *session, set_var *var)
1 by brian
clean slate
313
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
314
    return (*update_func)(session, var);
1 by brian
clean slate
315
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
316
  void set_default(Session *session, enum_var_type type)
1 by brian
clean slate
317
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
318
    (*set_default_func)(session, type);
1 by brian
clean slate
319
  }
320
  SHOW_TYPE show_type() { return SHOW_CHAR; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
321
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
481 by Brian Aker
Remove all of uchar.
322
  { return (unsigned char*) value; }
1 by brian
clean slate
323
  bool check_update_type(Item_result type)
324
  {
325
    return type != STRING_RESULT;		/* Only accept strings */
326
  }
644 by Brian Aker
Clean up warnings for Solaris.
327
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
328
  { return 0; }
1 by brian
clean slate
329
};
330
331
332
class sys_var_const_str :public sys_var
333
{
334
  char *value;					// Pointer to const value
10 by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs
335
public:
1 by brian
clean slate
336
  sys_var_const_str(sys_var_chain *chain, const char *name_arg,
337
                    const char *value_arg)
338
    :sys_var(name_arg), value((char*) value_arg)
339
  { chain_sys_var(chain); }
10 by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs
340
  inline void set (char *new_value)
341
  {
342
    value= new_value;
343
  }
644 by Brian Aker
Clean up warnings for Solaris.
344
  bool check(Session *, set_var *)
1 by brian
clean slate
345
  {
346
    return 1;
347
  }
644 by Brian Aker
Clean up warnings for Solaris.
348
  bool update(Session *, set_var *)
1 by brian
clean slate
349
  {
350
    return 1;
351
  }
352
  SHOW_TYPE show_type() { return SHOW_CHAR; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
353
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
1 by brian
clean slate
354
  {
481 by Brian Aker
Remove all of uchar.
355
    return (unsigned char*) value;
1 by brian
clean slate
356
  }
644 by Brian Aker
Clean up warnings for Solaris.
357
  bool check_update_type(Item_result)
1 by brian
clean slate
358
  {
359
    return 1;
360
  }
644 by Brian Aker
Clean up warnings for Solaris.
361
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
362
  { return 1; }
1 by brian
clean slate
363
  bool is_readonly() const { return 1; }
364
};
365
366
367
class sys_var_const_str_ptr :public sys_var
368
{
369
  char **value;					// Pointer to const value
10 by Brian Aker
Start of var cleanup (really.... looking at this code the entire thing needs
370
public:
1 by brian
clean slate
371
  sys_var_const_str_ptr(sys_var_chain *chain, const char *name_arg, char **value_arg)
372
    :sys_var(name_arg),value(value_arg)
373
  { chain_sys_var(chain); }
644 by Brian Aker
Clean up warnings for Solaris.
374
  bool check(Session *, set_var *)
1 by brian
clean slate
375
  {
376
    return 1;
377
  }
644 by Brian Aker
Clean up warnings for Solaris.
378
  bool update(Session *, set_var *)
1 by brian
clean slate
379
  {
380
    return 1;
381
  }
382
  SHOW_TYPE show_type() { return SHOW_CHAR; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
383
  unsigned char *value_ptr(Session *, enum_var_type, const LEX_STRING *)
1 by brian
clean slate
384
  {
481 by Brian Aker
Remove all of uchar.
385
    return (unsigned char*) *value;
1 by brian
clean slate
386
  }
644 by Brian Aker
Clean up warnings for Solaris.
387
  bool check_update_type(Item_result)
1 by brian
clean slate
388
  {
389
    return 1;
390
  }
644 by Brian Aker
Clean up warnings for Solaris.
391
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
392
  { return 1; }
393
  bool is_readonly(void) const { return 1; }
1 by brian
clean slate
394
};
395
396
397
class sys_var_enum :public sys_var
398
{
482 by Brian Aker
Remove uint.
399
  uint32_t *value;
1 by brian
clean slate
400
  TYPELIB *enum_names;
401
public:
482 by Brian Aker
Remove uint.
402
  sys_var_enum(sys_var_chain *chain, const char *name_arg, uint32_t *value_arg,
1 by brian
clean slate
403
	       TYPELIB *typelib, sys_after_update_func func)
404
    :sys_var(name_arg,func), value(value_arg), enum_names(typelib)
405
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
406
  bool check(Session *session, set_var *var)
1 by brian
clean slate
407
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
408
    return check_enum(session, var, enum_names);
1 by brian
clean slate
409
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
410
  bool update(Session *session, set_var *var);
1 by brian
clean slate
411
  SHOW_TYPE show_type() { return SHOW_CHAR; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
412
  unsigned char *value_ptr(Session *session, enum_var_type type,
413
                           const LEX_STRING *base);
644 by Brian Aker
Clean up warnings for Solaris.
414
  bool check_update_type(Item_result)
77.1.7 by Monty Taylor
Heap builds clean.
415
  { return 0; }
1 by brian
clean slate
416
};
417
418
419
class sys_var_enum_const :public sys_var
420
{
621 by Brian Aker
ulong fixes
421
  uint32_t SV::*offset;
1 by brian
clean slate
422
  TYPELIB *enum_names;
423
public:
621 by Brian Aker
ulong fixes
424
  sys_var_enum_const(sys_var_chain *chain, const char *name_arg, uint32_t SV::*offset_arg,
1 by brian
clean slate
425
      TYPELIB *typelib, sys_after_update_func func)
426
    :sys_var(name_arg,func), offset(offset_arg), enum_names(typelib)
427
  { chain_sys_var(chain); }
644 by Brian Aker
Clean up warnings for Solaris.
428
  bool check(Session *, set_var *)
77.1.7 by Monty Taylor
Heap builds clean.
429
  { return 1; }
644 by Brian Aker
Clean up warnings for Solaris.
430
  bool update(Session *, set_var *)
77.1.7 by Monty Taylor
Heap builds clean.
431
  { return 1; }
1 by brian
clean slate
432
  SHOW_TYPE show_type() { return SHOW_CHAR; }
644 by Brian Aker
Clean up warnings for Solaris.
433
  bool check_update_type(Item_result)
77.1.7 by Monty Taylor
Heap builds clean.
434
  { return 1; }
1 by brian
clean slate
435
  bool is_readonly() const { return 1; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
436
  unsigned char *value_ptr(Session *session, enum_var_type type,
437
                           const LEX_STRING *base);
1 by brian
clean slate
438
};
439
440
520.1.22 by Brian Aker
Second pass of thd cleanup
441
class sys_var_session :public sys_var
1 by brian
clean slate
442
{
443
public:
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
444
  sys_var_session(const char *name_arg,
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
445
              sys_after_update_func func= NULL)
446
    :sys_var(name_arg, func)
1 by brian
clean slate
447
  {}
644 by Brian Aker
Clean up warnings for Solaris.
448
  bool check_type(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
449
  { return 0; }
1 by brian
clean slate
450
  bool check_default(enum_var_type type)
451
  {
452
    return type == OPT_GLOBAL && !option_limits;
453
  }
454
};
455
615 by Brian Aker
Added 32bit system variable support
456
class sys_var_session_uint32_t :public sys_var_session
457
{
458
  sys_check_func check_func;
459
public:
460
  uint32_t SV::*offset;
461
  sys_var_session_uint32_t(sys_var_chain *chain, const char *name_arg,
462
                           uint32_t SV::*offset_arg,
463
                           sys_check_func c_func= NULL,
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
464
                           sys_after_update_func au_func= NULL)
465
    :sys_var_session(name_arg, au_func), check_func(c_func),
615 by Brian Aker
Added 32bit system variable support
466
    offset(offset_arg)
467
  { chain_sys_var(chain); }
468
  bool check(Session *session, set_var *var);
469
  bool update(Session *session, set_var *var);
470
  void set_default(Session *session, enum_var_type type);
910.4.18 by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64
471
  SHOW_TYPE show_type() { return SHOW_INT; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
472
  unsigned char *value_ptr(Session *session, enum_var_type type,
473
                           const LEX_STRING *base);
615 by Brian Aker
Added 32bit system variable support
474
};
475
1 by brian
clean slate
476
520.1.22 by Brian Aker
Second pass of thd cleanup
477
class sys_var_session_ha_rows :public sys_var_session
1 by brian
clean slate
478
{
479
public:
480
  ha_rows SV::*offset;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
481
  sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
1 by brian
clean slate
482
                      ha_rows SV::*offset_arg)
520.1.22 by Brian Aker
Second pass of thd cleanup
483
    :sys_var_session(name_arg), offset(offset_arg)
1 by brian
clean slate
484
  { chain_sys_var(chain); }
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
485
  sys_var_session_ha_rows(sys_var_chain *chain, const char *name_arg,
1 by brian
clean slate
486
                      ha_rows SV::*offset_arg,
487
		      sys_after_update_func func)
520.1.22 by Brian Aker
Second pass of thd cleanup
488
    :sys_var_session(name_arg,func), offset(offset_arg)
1 by brian
clean slate
489
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
490
  bool update(Session *session, set_var *var);
491
  void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
492
  SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
493
  unsigned char *value_ptr(Session *session, enum_var_type type,
494
                           const LEX_STRING *base);
1 by brian
clean slate
495
};
496
497
520.1.22 by Brian Aker
Second pass of thd cleanup
498
class sys_var_session_uint64_t :public sys_var_session
1 by brian
clean slate
499
{
555 by Monty
Fixed 32-bit issues.
500
  sys_check_func check_func;
1 by brian
clean slate
501
public:
151 by Brian Aker
Ulonglong to uint64_t
502
  uint64_t SV::*offset;
1 by brian
clean slate
503
  bool only_global;
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
504
  sys_var_session_uint64_t(sys_var_chain *chain, 
505
                           const char *name_arg,
555 by Monty
Fixed 32-bit issues.
506
                           uint64_t SV::*offset_arg,
507
                           sys_after_update_func au_func= NULL,
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
508
                           sys_check_func c_func= NULL)
509
    :sys_var_session(name_arg, au_func),
617 by Brian Aker
ulong fixes
510
    check_func(c_func),
511
    offset(offset_arg)
512
  { chain_sys_var(chain); }
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
513
  sys_var_session_uint64_t(sys_var_chain *chain,
514
                           const char *name_arg,
515
                           uint64_t SV::*offset_arg,
516
                           sys_after_update_func func,
617 by Brian Aker
ulong fixes
517
                           bool only_global_arg,
518
                           sys_check_func cfunc= NULL)
555 by Monty
Fixed 32-bit issues.
519
    :sys_var_session(name_arg, func),
520
    check_func(cfunc),
521
    offset(offset_arg),
1 by brian
clean slate
522
    only_global(only_global_arg)
523
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
524
  bool update(Session *session, set_var *var);
525
  void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
526
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
527
  unsigned char *value_ptr(Session *session, enum_var_type type,
528
                           const LEX_STRING *base);
520.1.22 by Brian Aker
Second pass of thd cleanup
529
  bool check(Session *session, set_var *var);
1 by brian
clean slate
530
  bool check_default(enum_var_type type)
531
  {
532
    return type == OPT_GLOBAL && !option_limits;
533
  }
534
  bool check_type(enum_var_type type)
535
  {
536
    return (only_global && type != OPT_GLOBAL);
537
  }
538
};
539
629.4.1 by Monty Taylor
First step in support size_t sys_var stuff.
540
class sys_var_session_size_t :public sys_var_session
541
{
542
  sys_check_func check_func;
543
public:
544
  size_t SV::*offset;
545
  bool only_global;
546
  sys_var_session_size_t(sys_var_chain *chain, const char *name_arg,
547
                         size_t SV::*offset_arg,
548
                         sys_after_update_func au_func= NULL,
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
549
                         sys_check_func c_func= NULL)
550
    :sys_var_session(name_arg, au_func),
629.4.1 by Monty Taylor
First step in support size_t sys_var stuff.
551
     check_func(c_func),
552
     offset(offset_arg)
553
  { chain_sys_var(chain); }
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
554
  sys_var_session_size_t(sys_var_chain *chain,
555
                         const char *name_arg,
556
                         size_t SV::*offset_arg,
557
                         sys_after_update_func func,
629.4.1 by Monty Taylor
First step in support size_t sys_var stuff.
558
                         bool only_global_arg,
559
                         sys_check_func cfunc= NULL)
560
    :sys_var_session(name_arg, func),
561
     check_func(cfunc),
562
     offset(offset_arg),
563
     only_global(only_global_arg)
564
  { chain_sys_var(chain); }
565
  bool update(Session *session, set_var *var);
566
  void set_default(Session *session, enum_var_type type);
567
  SHOW_TYPE show_type() { return SHOW_SIZE; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
568
  unsigned char *value_ptr(Session *session, enum_var_type type,
569
                           const LEX_STRING *base);
629.4.1 by Monty Taylor
First step in support size_t sys_var stuff.
570
  bool check(Session *session, set_var *var);
571
  bool check_default(enum_var_type type)
572
  {
573
    return type == OPT_GLOBAL && !option_limits;
574
  }
575
  bool check_type(enum_var_type type)
576
  {
577
    return (only_global && type != OPT_GLOBAL);
578
  }
579
};
580
1 by brian
clean slate
581
520.1.22 by Brian Aker
Second pass of thd cleanup
582
class sys_var_session_bool :public sys_var_session
1 by brian
clean slate
583
{
584
public:
200 by Brian Aker
my_bool from handler and set_var
585
  bool SV::*offset;
520.1.22 by Brian Aker
Second pass of thd cleanup
586
  sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg)
587
    :sys_var_session(name_arg), offset(offset_arg)
1 by brian
clean slate
588
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
589
  sys_var_session_bool(sys_var_chain *chain, const char *name_arg, bool SV::*offset_arg,
1 by brian
clean slate
590
		   sys_after_update_func func)
520.1.22 by Brian Aker
Second pass of thd cleanup
591
    :sys_var_session(name_arg,func), offset(offset_arg)
1 by brian
clean slate
592
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
593
  bool update(Session *session, set_var *var);
594
  void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
595
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
596
  unsigned char *value_ptr(Session *session, enum_var_type type,
597
                           const LEX_STRING *base);
520.1.22 by Brian Aker
Second pass of thd cleanup
598
  bool check(Session *session, set_var *var)
1 by brian
clean slate
599
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
600
    return check_enum(session, var, &bool_typelib);
1 by brian
clean slate
601
  }
644 by Brian Aker
Clean up warnings for Solaris.
602
  bool check_update_type(Item_result)
77.1.7 by Monty Taylor
Heap builds clean.
603
  { return 0; }
1 by brian
clean slate
604
};
605
606
520.1.22 by Brian Aker
Second pass of thd cleanup
607
class sys_var_session_enum :public sys_var_session
1 by brian
clean slate
608
{
609
protected:
617 by Brian Aker
ulong fixes
610
  uint32_t SV::*offset;
1 by brian
clean slate
611
  TYPELIB *enum_names;
612
  sys_check_func check_func;
613
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
614
  sys_var_session_enum(sys_var_chain *chain, const char *name_arg,
617 by Brian Aker
ulong fixes
615
                   uint32_t SV::*offset_arg, TYPELIB *typelib,
1 by brian
clean slate
616
                   sys_after_update_func func= NULL,
801.1.1 by Brian Aker
Solaris build error fix.
617
                   sys_check_func check_f= NULL)
520.1.22 by Brian Aker
Second pass of thd cleanup
618
    :sys_var_session(name_arg, func), offset(offset_arg),
801.1.1 by Brian Aker
Solaris build error fix.
619
    enum_names(typelib), check_func(check_f)
1 by brian
clean slate
620
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
621
  bool check(Session *session, set_var *var)
1 by brian
clean slate
622
  {
623
    int ret= 0;
624
    if (check_func)
520.1.22 by Brian Aker
Second pass of thd cleanup
625
      ret= (*check_func)(session, var);
626
    return ret ? ret : check_enum(session, var, enum_names);
1 by brian
clean slate
627
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
628
  bool update(Session *session, set_var *var);
629
  void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
630
  SHOW_TYPE show_type() { return SHOW_CHAR; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
631
  unsigned char *value_ptr(Session *session, enum_var_type type,
632
                           const LEX_STRING *base);
644 by Brian Aker
Clean up warnings for Solaris.
633
  bool check_update_type(Item_result)
77.1.7 by Monty Taylor
Heap builds clean.
634
  { return 0; }
1 by brian
clean slate
635
};
636
637
638
520.1.22 by Brian Aker
Second pass of thd cleanup
639
class sys_var_session_optimizer_switch :public sys_var_session_enum
1 by brian
clean slate
640
{
641
public:
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
642
  sys_var_session_optimizer_switch(sys_var_chain *chain, const char *name_arg,
617 by Brian Aker
ulong fixes
643
                                   uint32_t SV::*offset_arg)
520.1.22 by Brian Aker
Second pass of thd cleanup
644
    :sys_var_session_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib)
1 by brian
clean slate
645
  {}
520.1.22 by Brian Aker
Second pass of thd cleanup
646
  bool check(Session *session, set_var *var)
1 by brian
clean slate
647
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
648
    return check_set(session, var, enum_names);
1 by brian
clean slate
649
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
650
  void set_default(Session *session, enum_var_type type);
779.3.10 by Monty Taylor
Turned on -Wshadow.
651
  unsigned char *value_ptr(Session *session, enum_var_type type,
652
                           const LEX_STRING *base);
617 by Brian Aker
ulong fixes
653
  static bool symbolic_mode_representation(Session *session, uint32_t sql_mode,
1 by brian
clean slate
654
                                           LEX_STRING *rep);
655
};
656
657
520.1.22 by Brian Aker
Second pass of thd cleanup
658
class sys_var_session_storage_engine :public sys_var_session
1 by brian
clean slate
659
{
660
protected:
1130.1.4 by Monty Taylor
Moved StorageEngine into plugin namespace.
661
  drizzled::plugin::StorageEngine *SV::*offset;
1 by brian
clean slate
662
public:
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
663
  sys_var_session_storage_engine(sys_var_chain *chain, const char *name_arg,
1130.1.4 by Monty Taylor
Moved StorageEngine into plugin namespace.
664
                                 drizzled::plugin::StorageEngine *SV::*offset_arg)
520.1.22 by Brian Aker
Second pass of thd cleanup
665
    :sys_var_session(name_arg), offset(offset_arg)
1 by brian
clean slate
666
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
667
  bool check(Session *session, set_var *var);
1 by brian
clean slate
668
  SHOW_TYPE show_type() { return SHOW_CHAR; }
669
  bool check_update_type(Item_result type)
670
  {
671
    return type != STRING_RESULT;		/* Only accept strings */
672
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
673
  void set_default(Session *session, enum_var_type type);
674
  bool update(Session *session, set_var *var);
779.3.10 by Monty Taylor
Turned on -Wshadow.
675
  unsigned char *value_ptr(Session *session, enum_var_type type,
676
                           const LEX_STRING *base);
1 by brian
clean slate
677
};
678
520.1.22 by Brian Aker
Second pass of thd cleanup
679
class sys_var_session_bit :public sys_var_session
1 by brian
clean slate
680
{
681
  sys_check_func check_func;
682
  sys_update_func update_func;
683
public:
151 by Brian Aker
Ulonglong to uint64_t
684
  uint64_t bit_flag;
1 by brian
clean slate
685
  bool reverse;
520.1.22 by Brian Aker
Second pass of thd cleanup
686
  sys_var_session_bit(sys_var_chain *chain, const char *name_arg,
1 by brian
clean slate
687
                  sys_check_func c_func, sys_update_func u_func,
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
688
                  uint64_t bit, bool reverse_arg=0)
689
    :sys_var_session(name_arg, NULL), check_func(c_func),
1 by brian
clean slate
690
    update_func(u_func), bit_flag(bit), reverse(reverse_arg)
691
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
692
  bool check(Session *session, set_var *var);
693
  bool update(Session *session, set_var *var);
644 by Brian Aker
Clean up warnings for Solaris.
694
  bool check_update_type(Item_result)
77.1.7 by Monty Taylor
Heap builds clean.
695
  { return 0; }
1 by brian
clean slate
696
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
697
  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
698
  unsigned char *value_ptr(Session *session, enum_var_type type,
699
                           const LEX_STRING *base);
1 by brian
clean slate
700
};
701
702
/* some variables that require special handling */
703
704
class sys_var_timestamp :public sys_var
705
{
706
public:
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
707
  sys_var_timestamp(sys_var_chain *chain, const char *name_arg)
708
    :sys_var(name_arg, NULL)
1 by brian
clean slate
709
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
710
  bool update(Session *session, set_var *var);
711
  void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
712
  bool check_type(enum_var_type type)    { return type == OPT_GLOBAL; }
644 by Brian Aker
Clean up warnings for Solaris.
713
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
714
  { return 0; }
715
  SHOW_TYPE show_type(void) { return SHOW_LONG; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
716
  unsigned char *value_ptr(Session *session, enum_var_type type,
717
                           const LEX_STRING *base);
1 by brian
clean slate
718
};
719
720
721
class sys_var_last_insert_id :public sys_var
722
{
723
public:
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
724
  sys_var_last_insert_id(sys_var_chain *chain, const char *name_arg)
725
    :sys_var(name_arg, NULL)
1 by brian
clean slate
726
  { chain_sys_var(chain); }
520.1.22 by Brian Aker
Second pass of thd cleanup
727
  bool update(Session *session, set_var *var);
1 by brian
clean slate
728
  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
729
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
730
  unsigned char *value_ptr(Session *session, enum_var_type type,
731
                           const LEX_STRING *base);
1 by brian
clean slate
732
};
733
734
520.1.22 by Brian Aker
Second pass of thd cleanup
735
class sys_var_collation :public sys_var_session
1 by brian
clean slate
736
{
737
public:
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
738
  sys_var_collation(const char *name_arg)
739
    :sys_var_session(name_arg, NULL)
744 by Brian Aker
Removing dead code around one shot.
740
  { }
520.1.22 by Brian Aker
Second pass of thd cleanup
741
  bool check(Session *session, set_var *var);
1 by brian
clean slate
742
  SHOW_TYPE show_type() { return SHOW_CHAR; }
743
  bool check_update_type(Item_result type)
744
  {
745
    return ((type != STRING_RESULT) && (type != INT_RESULT));
746
  }
644 by Brian Aker
Clean up warnings for Solaris.
747
  bool check_default(enum_var_type) { return 0; }
520.1.22 by Brian Aker
Second pass of thd cleanup
748
  virtual void set_default(Session *session, enum_var_type type)= 0;
1 by brian
clean slate
749
};
750
751
class sys_var_collation_sv :public sys_var_collation
752
{
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
753
  const CHARSET_INFO *SV::*offset;
754
  const CHARSET_INFO **global_default;
1 by brian
clean slate
755
public:
756
  sys_var_collation_sv(sys_var_chain *chain, const char *name_arg,
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
757
                       const CHARSET_INFO *SV::*offset_arg,
758
                       const CHARSET_INFO **global_default_arg)
759
    :sys_var_collation(name_arg),
1 by brian
clean slate
760
    offset(offset_arg), global_default(global_default_arg)
761
  {
762
    chain_sys_var(chain);
763
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
764
  bool update(Session *session, set_var *var);
765
  void set_default(Session *session, enum_var_type type);
779.3.10 by Monty Taylor
Turned on -Wshadow.
766
  unsigned char *value_ptr(Session *session, enum_var_type type,
767
                           const LEX_STRING *base);
1 by brian
clean slate
768
};
769
770
771
class sys_var_key_cache_param :public sys_var
772
{
773
protected:
774
  size_t offset;
775
public:
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
776
  sys_var_key_cache_param(sys_var_chain *chain, const char *name_arg,
1 by brian
clean slate
777
                          size_t offset_arg)
778
    :sys_var(name_arg), offset(offset_arg)
779
  { chain_sys_var(chain); }
779.3.10 by Monty Taylor
Turned on -Wshadow.
780
  unsigned char *value_ptr(Session *session, enum_var_type type,
781
                           const LEX_STRING *base);
644 by Brian Aker
Clean up warnings for Solaris.
782
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
783
  { return 1; }
1 by brian
clean slate
784
};
785
786
787
class sys_var_key_buffer_size :public sys_var_key_cache_param
788
{
789
public:
790
  sys_var_key_buffer_size(sys_var_chain *chain, const char *name_arg)
791
    :sys_var_key_cache_param(chain, name_arg,
792
                             offsetof(KEY_CACHE, param_buff_size))
793
  {}
520.1.22 by Brian Aker
Second pass of thd cleanup
794
  bool update(Session *session, set_var *var);
1 by brian
clean slate
795
  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
796
};
797
798
910.4.18 by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64
799
class sys_var_key_cache_uint32_t :public sys_var_key_cache_param
1 by brian
clean slate
800
{
801
public:
910.4.18 by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64
802
  sys_var_key_cache_uint32_t(sys_var_chain *chain, const char *name_arg, size_t offset_arg)
1 by brian
clean slate
803
    :sys_var_key_cache_param(chain, name_arg, offset_arg)
804
  {}
520.1.22 by Brian Aker
Second pass of thd cleanup
805
  bool update(Session *session, set_var *var);
910.4.18 by Stewart Smith
fix alignment of variables (incl key cache). fixes SIGBUS on SPARC64
806
  SHOW_TYPE show_type() { return SHOW_INT; }
1 by brian
clean slate
807
};
808
809
/* Variable that you can only read from */
810
811
class sys_var_readonly: public sys_var
812
{
813
public:
814
  enum_var_type var_type;
815
  SHOW_TYPE show_type_value;
816
  sys_value_ptr_func value_ptr_func;
817
  sys_var_readonly(sys_var_chain *chain, const char *name_arg, enum_var_type type,
818
		   SHOW_TYPE show_type_arg,
819
		   sys_value_ptr_func value_ptr_func_arg)
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
820
    :sys_var(name_arg), var_type(type),
1 by brian
clean slate
821
       show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
822
  { chain_sys_var(chain); }
644 by Brian Aker
Clean up warnings for Solaris.
823
  bool update(Session *, set_var *)
77.1.7 by Monty Taylor
Heap builds clean.
824
  { return 1; }
644 by Brian Aker
Clean up warnings for Solaris.
825
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
826
  { return 1; }
1 by brian
clean slate
827
  bool check_type(enum_var_type type) { return type != var_type; }
644 by Brian Aker
Clean up warnings for Solaris.
828
  bool check_update_type(Item_result)
77.1.7 by Monty Taylor
Heap builds clean.
829
  { return 1; }
779.3.10 by Monty Taylor
Turned on -Wshadow.
830
  unsigned char *value_ptr(Session *session, enum_var_type,
831
                           const LEX_STRING *)
1 by brian
clean slate
832
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
833
    return (*value_ptr_func)(session);
1 by brian
clean slate
834
  }
77.1.7 by Monty Taylor
Heap builds clean.
835
  SHOW_TYPE show_type(void) { return show_type_value; }
836
  bool is_readonly(void) const { return 1; }
1 by brian
clean slate
837
};
838
839
840
class sys_var_have_option: public sys_var
841
{
842
protected:
843
  virtual SHOW_COMP_OPTION get_option() = 0;
844
public:
845
  sys_var_have_option(sys_var_chain *chain, const char *variable_name):
846
    sys_var(variable_name)
847
  { chain_sys_var(chain); }
779.3.10 by Monty Taylor
Turned on -Wshadow.
848
  unsigned char *value_ptr(Session *, enum_var_type,
849
                           const LEX_STRING *)
1 by brian
clean slate
850
  {
481 by Brian Aker
Remove all of uchar.
851
    return (unsigned char*) show_comp_option_name[get_option()];
1 by brian
clean slate
852
  }
644 by Brian Aker
Clean up warnings for Solaris.
853
  bool update(Session *, set_var *) { return 1; }
854
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
855
  { return 1; }
1 by brian
clean slate
856
  bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
644 by Brian Aker
Clean up warnings for Solaris.
857
  bool check_update_type(Item_result)
77.1.7 by Monty Taylor
Heap builds clean.
858
  { return 1; }
1 by brian
clean slate
859
  SHOW_TYPE show_type() { return SHOW_CHAR; }
860
  bool is_readonly() const { return 1; }
861
};
862
863
864
class sys_var_have_variable: public sys_var_have_option
865
{
866
  SHOW_COMP_OPTION *have_variable;
867
868
public:
869
  sys_var_have_variable(sys_var_chain *chain, const char *variable_name,
870
                        SHOW_COMP_OPTION *have_variable_arg):
871
    sys_var_have_option(chain, variable_name),
872
    have_variable(have_variable_arg)
873
  { }
874
  SHOW_COMP_OPTION get_option() { return *have_variable; }
875
};
876
877
878
class sys_var_have_plugin: public sys_var_have_option
879
{
880
  const char *plugin_name_str;
482 by Brian Aker
Remove uint.
881
  const uint32_t plugin_name_len;
1 by brian
clean slate
882
  const int plugin_type;
883
884
public:
885
  sys_var_have_plugin(sys_var_chain *chain, const char *variable_name,
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
886
                      const char *plugin_name_str_arg, uint32_t plugin_name_len_arg,
1 by brian
clean slate
887
                      int plugin_type_arg):
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
888
    sys_var_have_option(chain, variable_name),
1 by brian
clean slate
889
    plugin_name_str(plugin_name_str_arg), plugin_name_len(plugin_name_len_arg),
890
    plugin_type(plugin_type_arg)
891
  { }
892
  /* the following method is declared in sql_plugin.cc */
893
  SHOW_COMP_OPTION get_option();
894
};
895
896
520.1.22 by Brian Aker
Second pass of thd cleanup
897
class sys_var_session_time_zone :public sys_var_session
1 by brian
clean slate
898
{
899
public:
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
900
  sys_var_session_time_zone(sys_var_chain *chain, const char *name_arg)
901
    :sys_var_session(name_arg, NULL)
1 by brian
clean slate
902
  {
903
    chain_sys_var(chain);
904
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
905
  bool check(Session *session, set_var *var);
1 by brian
clean slate
906
  SHOW_TYPE show_type() { return SHOW_CHAR; }
907
  bool check_update_type(Item_result type)
908
  {
909
    return type != STRING_RESULT;		/* Only accept strings */
910
  }
644 by Brian Aker
Clean up warnings for Solaris.
911
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
912
  { return 0; }
520.1.22 by Brian Aker
Second pass of thd cleanup
913
  bool update(Session *session, set_var *var);
779.3.10 by Monty Taylor
Turned on -Wshadow.
914
  unsigned char *value_ptr(Session *session, enum_var_type type,
915
                           const LEX_STRING *base);
520.1.22 by Brian Aker
Second pass of thd cleanup
916
  virtual void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
917
};
918
919
520.1.22 by Brian Aker
Second pass of thd cleanup
920
class sys_var_microseconds :public sys_var_session
1 by brian
clean slate
921
{
151 by Brian Aker
Ulonglong to uint64_t
922
  uint64_t SV::*offset;
1 by brian
clean slate
923
public:
924
  sys_var_microseconds(sys_var_chain *chain, const char *name_arg,
151 by Brian Aker
Ulonglong to uint64_t
925
                       uint64_t SV::*offset_arg):
520.1.22 by Brian Aker
Second pass of thd cleanup
926
    sys_var_session(name_arg), offset(offset_arg)
1 by brian
clean slate
927
  { chain_sys_var(chain); }
644 by Brian Aker
Clean up warnings for Solaris.
928
  bool check(Session *, set_var *) {return 0;}
520.1.22 by Brian Aker
Second pass of thd cleanup
929
  bool update(Session *session, set_var *var);
930
  void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
931
  SHOW_TYPE show_type() { return SHOW_DOUBLE; }
932
  bool check_update_type(Item_result type)
933
  {
934
    return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
935
  }
936
};
937
520.1.22 by Brian Aker
Second pass of thd cleanup
938
class sys_var_session_lc_time_names :public sys_var_session
1 by brian
clean slate
939
{
940
public:
1018 by Brian Aker
Remove "BINLOG" from variables (we don't need this for our replication).
941
  sys_var_session_lc_time_names(sys_var_chain *chain, const char *name_arg)
942
    : sys_var_session(name_arg, NULL)
1 by brian
clean slate
943
  {
944
    chain_sys_var(chain);
945
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
946
  bool check(Session *session, set_var *var);
1 by brian
clean slate
947
  SHOW_TYPE show_type() { return SHOW_CHAR; }
948
  bool check_update_type(Item_result type)
949
  {
950
    return ((type != STRING_RESULT) && (type != INT_RESULT));
951
  }
644 by Brian Aker
Clean up warnings for Solaris.
952
  bool check_default(enum_var_type)
77.1.7 by Monty Taylor
Heap builds clean.
953
  { return 0; }
520.1.22 by Brian Aker
Second pass of thd cleanup
954
  bool update(Session *session, set_var *var);
779.3.10 by Monty Taylor
Turned on -Wshadow.
955
  unsigned char *value_ptr(Session *session, enum_var_type type,
956
                           const LEX_STRING *base);
520.1.22 by Brian Aker
Second pass of thd cleanup
957
  virtual void set_default(Session *session, enum_var_type type);
1 by brian
clean slate
958
};
959
960
961
/****************************************************************************
962
  Classes for parsing of the SET command
963
****************************************************************************/
964
965
class set_var_base :public Sql_alloc
966
{
967
public:
968
  set_var_base() {}
969
  virtual ~set_var_base() {}
520.1.22 by Brian Aker
Second pass of thd cleanup
970
  virtual int check(Session *session)=0;	/* To check privileges etc. */
971
  virtual int update(Session *session)=0;	/* To set the value */
1 by brian
clean slate
972
  /* light check for PS */
973
};
974
141 by Brian Aker
Code cleanup. Mainly dead stuff :)
975
/* MySQL internal variables */
1 by brian
clean slate
976
class set_var :public set_var_base
977
{
978
public:
979
  sys_var *var;
980
  Item *value;
981
  enum_var_type type;
982
  union
983
  {
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
984
    const CHARSET_INFO *charset;
520.4.14 by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf.
985
    uint32_t uint32_t_value;
151 by Brian Aker
Ulonglong to uint64_t
986
    uint64_t uint64_t_value;
629.4.1 by Monty Taylor
First step in support size_t sys_var stuff.
987
    size_t size_t_value;
1130.1.4 by Monty Taylor
Moved StorageEngine into plugin namespace.
988
    drizzled::plugin::StorageEngine *storage_engine;
1 by brian
clean slate
989
    Time_zone *time_zone;
990
    MY_LOCALE *locale_value;
991
  } save_result;
992
  LEX_STRING base;			/* for structs */
993
994
  set_var(enum_var_type type_arg, sys_var *var_arg,
995
          const LEX_STRING *base_name_arg, Item *value_arg)
996
    :var(var_arg), type(type_arg), base(*base_name_arg)
997
  {
998
    /*
999
      If the set value is a field, change it to a string to allow things like
1000
      SET table_type=MYISAM;
1001
    */
1002
    if (value_arg && value_arg->type() == Item::FIELD_ITEM)
1003
    {
1004
      Item_field *item= (Item_field*) value_arg;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
1005
      if (!(value=new Item_string(item->field_name,
895 by Brian Aker
Completion (?) of uint conversion.
1006
                  (uint32_t) strlen(item->field_name),
1 by brian
clean slate
1007
				  item->collation.collation)))
1008
	value=value_arg;			/* Give error message later */
1009
    }
1010
    else
1011
      value=value_arg;
1012
  }
520.1.22 by Brian Aker
Second pass of thd cleanup
1013
  int check(Session *session);
1014
  int update(Session *session);
1 by brian
clean slate
1015
};
1016
1017
1018
/* User variables like @my_own_variable */
1019
1020
class set_var_user: public set_var_base
1021
{
1022
  Item_func_set_user_var *user_var_item;
1023
public:
1024
  set_var_user(Item_func_set_user_var *item)
1025
    :user_var_item(item)
1026
  {}
520.1.22 by Brian Aker
Second pass of thd cleanup
1027
  int check(Session *session);
1028
  int update(Session *session);
1 by brian
clean slate
1029
};
1030
1031
1032
/* For sql_yacc */
1033
struct sys_var_with_base
1034
{
1035
  sys_var *var;
1036
  LEX_STRING base_name;
1037
};
1038
1039
/*
1040
  Prototypes for helper functions
1041
*/
1042
1043
int set_var_init();
1044
void set_var_free();
482 by Brian Aker
Remove uint.
1045
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count);
520.1.22 by Brian Aker
Second pass of thd cleanup
1046
SHOW_VAR* enumerate_sys_vars(Session *session, bool sorted);
1101.1.27 by Monty Taylor
Fixed the plugin string valgrind leak.
1047
void drizzle_add_plugin_sysvar(sys_var_pluginvar *var);
1048
void drizzle_del_plugin_sysvar();
1 by brian
clean slate
1049
int mysql_add_sys_var_chain(sys_var *chain, struct my_option *long_options);
1050
int mysql_del_sys_var_chain(sys_var *chain);
520.1.22 by Brian Aker
Second pass of thd cleanup
1051
sys_var *find_sys_var(Session *session, const char *str, uint32_t length=0);
1052
int sql_set_variables(Session *session, List<set_var_base> *var_list);
1 by brian
clean slate
1053
bool not_all_support_one_shot(List<set_var_base> *var_list);
520.1.22 by Brian Aker
Second pass of thd cleanup
1054
extern sys_var_session_time_zone sys_time_zone;
1055
extern sys_var_session_bit sys_autocommit;
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
1056
const CHARSET_INFO *get_old_charset_by_name(const char *old_name);
1 by brian
clean slate
1057
1058
extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
1059
1122.2.10 by Monty Taylor
Fixed all of the include guards.
1060
#endif /* DRIZZLED_SET_VAR_H */