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