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