Drizzled Public API Documentation

sys_var.h
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, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #pragma once
21 
22 #include <string>
23 #include <boost/filesystem.hpp>
24 
25 #include <drizzled/common_fwd.h>
26 #include <drizzled/constrained_value.h>
27 #include <drizzled/set_var.h>
28 #include <drizzled/show_type.h>
29 #include <drizzled/item_result.h>
30 #include <drizzled/base.h>
31 #include <drizzled/charset.h>
32 #include <drizzled/lex_string.h>
33 #include <drizzled/visibility.h>
34 
35 namespace drizzled {
36 
37 typedef int (*sys_check_func)(Session *, set_var *);
38 typedef bool (*sys_update_func)(Session *, set_var *);
39 typedef void (*sys_after_update_func)(Session *, sql_var_t);
40 typedef void (*sys_set_default_func)(Session *, sql_var_t);
41 typedef unsigned char *(*sys_value_ptr_func)(Session *session);
42 
43 static const std::vector<std::string> empty_aliases;
44 extern struct drizzle_system_variables max_system_variables;
45 extern size_t table_def_size;
46 
47 extern std::string drizzle_tmpdir;
48 extern const char *first_keyword;
49 extern const char *in_left_expr_name;
50 extern const char *in_additional_cond;
51 extern const char *in_having_cond;
52 extern boost::filesystem::path basedir;
53 extern boost::filesystem::path pid_file;
54 extern boost::filesystem::path secure_file_priv;
55 extern uint64_t session_startup_options;
56 extern uint32_t global_thread_id;
57 extern uint64_t table_cache_size;
58 extern back_log_constraints back_log;
59 extern uint32_t ha_open_options;
60 extern const char *drizzled_bind_host;
61 extern uint32_t dropping_tables;
62 extern bool opt_endinfo;
63 extern uint32_t volatile thread_running;
64 extern uint32_t volatile global_read_lock;
65 extern bool opt_readonly;
66 extern const char *opt_scheduler;
67 extern size_t transaction_message_threshold;
68 
69 uint64_t fix_unsigned(Session*, uint64_t, const option&);
70 
71 DRIZZLED_API const std::string &getServerHostname();
72 int sys_var_init();
73 
79 {
80 protected:
81  std::string name;
82  sys_check_func check_func;
83  sys_after_update_func after_update;
86 public:
87  sys_var(const std::string &name_arg,
88  sys_after_update_func func= NULL,
89  sys_check_func check_func_arg= NULL)
90  :
91  name(name_arg),
92  check_func(check_func_arg),
93  after_update(func),
94  option_limits(NULL),
95  m_allow_empty_value(true)
96  {}
97  virtual ~sys_var() {}
98 
99  void setName(const std::string &name_in)
100  {
101  name= name_in;
102  }
103 
111  inline const std::string &getName() const
112  {
113  return name;
114  }
119  const std::vector<std::string>& getAliases() const
120  {
121  return empty_aliases;
122  }
126  inline struct option *getOptionLimits() const
127  {
128  return option_limits;
129  }
135  inline void setOptionLimits(struct option *in_option_limits)
136  {
137  option_limits= in_option_limits;
138  }
142  inline sys_after_update_func getAfterUpdateTrigger() const
143  {
144  return after_update;
145  }
146  virtual bool check(Session *session, set_var *var);
147  bool check_enum(Session *session, set_var *var, const TYPELIB *enum_names);
148  virtual bool update(Session *session, set_var *var)=0;
149  virtual void set_default(Session *, sql_var_t)
150  {}
151  virtual SHOW_TYPE show_type()
152  {
153  return SHOW_UNDEF;
154  }
155  virtual unsigned char *value_ptr(Session*, sql_var_t) = 0;
156  virtual bool check_type(sql_var_t type)
157  {
158  return type != OPT_GLOBAL;
159  } /* Error if not GLOBAL */
160  virtual bool check_update_type(Item_result type)
161  {
162  return type != INT_RESULT;
163  } /* Assume INT */
164  virtual bool check_default(sql_var_t)
165  {
166  return option_limits == 0;
167  }
168  Item *item(Session*, sql_var_t);
169  virtual bool is_readonly() const
170  {
171  return 0;
172  }
173 };
174 
180 {
181 protected:
182  pthread_mutex_t *guard;
183 public:
184  sys_var_global(const char *name_arg, sys_after_update_func after_update_arg, pthread_mutex_t *guard_arg) :
185  sys_var(name_arg, after_update_arg),
186  guard(guard_arg)
187  {}
188 };
189 
191 {
192  uint32_t *value;
193 public:
194  sys_var_uint32_t_ptr(const char *name_arg, uint32_t *value_ptr_arg) :
195  sys_var(name_arg), value(value_ptr_arg)
196  { }
197  sys_var_uint32_t_ptr(const char *name_arg, uint32_t *value_ptr_arg, sys_after_update_func func) :
198  sys_var(name_arg,func), value(value_ptr_arg)
199  { }
200  bool check(Session *session, set_var *var);
201  bool update(Session *session, set_var *var);
202  void set_default(Session *session, sql_var_t type);
203  SHOW_TYPE show_type() { return SHOW_INT; }
204  unsigned char *value_ptr(Session *, sql_var_t)
205  { return (unsigned char*) value; }
206 };
207 
209 {
210 public:
211  sys_var_uint32_t_ptr_readonly(const char *name_arg, uint32_t *value_ptr_arg) :
212  sys_var_uint32_t_ptr(name_arg, value_ptr_arg)
213  {}
214 
215  sys_var_uint32_t_ptr_readonly(const char *name_arg,
216  uint32_t *value_ptr_arg,
217  sys_after_update_func func) :
218  sys_var_uint32_t_ptr(name_arg, value_ptr_arg, func)
219  {}
220 
221  bool is_readonly() const
222  {
223  return true;
224  }
225 };
226 
227 
229 {
230  uint64_t *value;
231  const uint64_t default_value;
232  bool have_default_value;
233 public:
234  sys_var_uint64_t_ptr(const char *name_arg, uint64_t *value_ptr_arg) :
235  sys_var(name_arg),
236  value(value_ptr_arg),
237  default_value(0),
238  have_default_value(false)
239  { }
240 
241  sys_var_uint64_t_ptr(const char *name_arg,
242  uint64_t *value_ptr_arg,
243  const uint64_t default_value_in) :
244  sys_var(name_arg),
245  value(value_ptr_arg),
246  default_value(default_value_in),
247  have_default_value(true)
248  { }
249 
250  sys_var_uint64_t_ptr(const char *name_arg,
251  uint64_t *value_ptr_arg,
252  sys_after_update_func func) :
253  sys_var(name_arg,func),
254  value(value_ptr_arg),
255  default_value(0),
256  have_default_value(false)
257  { }
258 
259  sys_var_uint64_t_ptr(const char *name_arg,
260  uint64_t *value_ptr_arg,
261  sys_after_update_func func,
262  const uint64_t default_value_in) :
263  sys_var(name_arg,func),
264  value(value_ptr_arg),
265  default_value(default_value_in),
266  have_default_value(true)
267  { }
268 
269  bool update(Session *session, set_var *var);
270  void set_default(Session *session, sql_var_t type);
271  virtual bool check_default(sql_var_t)
272  {
273  return (not have_default_value) && option_limits == 0;
274  }
275  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
276  unsigned char *value_ptr(Session *, sql_var_t)
277  { return (unsigned char*) value; }
278 };
279 
281 {
282  size_t *value;
283 public:
284  sys_var_size_t_ptr(const char *name_arg, size_t *value_ptr_arg)
285  :sys_var(name_arg),value(value_ptr_arg)
286  { }
287  sys_var_size_t_ptr(const char *name_arg, size_t *value_ptr_arg,
288  sys_after_update_func func)
289  :sys_var(name_arg,func), value(value_ptr_arg)
290  { }
291  bool update(Session *session, set_var *var);
292  void set_default(Session *session, sql_var_t type);
293  SHOW_TYPE show_type() { return SHOW_SIZE; }
294  unsigned char *value_ptr(Session *, sql_var_t)
295  { return (unsigned char*) value; }
296 };
297 
299 {
300 public:
301  sys_var_size_t_ptr_readonly(const char *name_arg,
302  size_t *value_arg)
303  :sys_var_size_t_ptr(name_arg, value_arg)
304  {}
305  bool is_readonly() const { return 1; }
306 };
307 
309 {
310  bool default_value;
311 public:
312  bool *value;
313  sys_var_bool_ptr(const std::string &name_arg, bool *value_arg,
314  sys_after_update_func func= NULL) :
315  sys_var(name_arg, func), default_value(*value_arg), value(value_arg)
316  { }
317  bool check(Session *session, set_var *var);
318  virtual bool check_default(sql_var_t)
319  {
320  return false;
321  }
322  bool update(Session *session, set_var *var);
323  void set_default(Session *session, sql_var_t type);
324  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
325  unsigned char *value_ptr(Session *, sql_var_t)
326  { return (unsigned char*) value; }
327  bool check_update_type(Item_result)
328  { return 0; }
329 };
330 
332 {
333 public:
334  sys_var_bool_ptr_readonly(const char *name_arg,
335  bool *value_arg)
336  :sys_var_bool_ptr(name_arg, value_arg)
337  {}
338  bool is_readonly() const { return 1; }
339 };
340 
341 
343 {
344 public:
345  char *value; // Pointer to allocated string
346  uint32_t value_length;
347  sys_update_func update_func;
348  sys_set_default_func set_default_func;
349  sys_var_str(const char *name_arg,
350  sys_check_func check_func_arg,
351  sys_update_func update_func_arg,
352  sys_set_default_func set_default_func_arg,
353  char *value_arg) :
354  sys_var(name_arg, NULL, check_func_arg),
355  value(value_arg),
356  update_func(update_func_arg),
357  set_default_func(set_default_func_arg)
358  { }
359  bool check(Session *session, set_var *var);
360  bool update(Session *session, set_var *var)
361  {
362  return (*update_func)(session, var);
363  }
364  void set_default(Session *session, sql_var_t type)
365  {
366  (*set_default_func)(session, type);
367  }
368  SHOW_TYPE show_type() { return SHOW_CHAR; }
369  unsigned char *value_ptr(Session *, sql_var_t)
370  { return (unsigned char*) value; }
371  bool check_update_type(Item_result type)
372  {
373  return type != STRING_RESULT; /* Only accept strings */
374  }
375  bool check_default(sql_var_t)
376  { return 0; }
377 };
378 
379 
381  public sys_var
382 {
383  const boost::filesystem::path &value;
384 public:
385  sys_var_fs_path(const char *name_arg,
386  const boost::filesystem::path& value_arg) :
387  sys_var(name_arg),
388  value(value_arg)
389  { }
390 
391  inline void set(char *)
392  { }
393 
394  bool check(Session *, set_var *)
395  {
396  return true;
397  }
398  bool update(Session *, set_var *)
399  {
400  return true;
401  }
402  SHOW_TYPE show_type() { return SHOW_CHAR; }
403  unsigned char *value_ptr(Session *, sql_var_t)
404  {
405  return (unsigned char*)(value.file_string().c_str());
406  }
407  bool check_update_type(Item_result)
408  {
409  return true;
410  }
411  bool check_default(sql_var_t) { return true; }
412  bool is_readonly() const { return true; }
413 };
414 
415 template<class T>
417  public sys_var
418 {
419  constrained_value<T> &value;
420  T basic_value;
421  T default_value;
422 public:
423  sys_var_constrained_value(const char *name_arg,
424  constrained_value<T> &value_arg) :
425  sys_var(name_arg),
426  value(value_arg),
427  default_value(value_arg.get())
428  { }
429 
430  sys_var_constrained_value(const char *name_arg,
431  constrained_value<T> &value_arg,
432  sys_after_update_func after_update_func_arg) :
433  sys_var(name_arg, after_update_func_arg),
434  value(value_arg),
435  default_value(value_arg.get())
436  { }
437 
438  sys_var_constrained_value(const char *name_arg,
439  constrained_value<T> &value_arg,
440  sys_check_func check_func_arg) :
441  sys_var(name_arg, NULL, check_func_arg),
442  value(value_arg),
443  default_value(value_arg.get())
444  { }
445 
446 public:
447  bool is_readonly() const
448  {
449  return false;
450  }
451 
452  SHOW_TYPE show_type() { return SHOW_INT; }
453 
454  bool update(Session *, set_var *var)
455  {
456  value= uint32_t(var->getInteger());
457  return false;
458  }
459 
460  bool check_default(sql_var_t)
461  {
462  return false;
463  }
464 
465  void set_default(Session *, sql_var_t)
466  {
467  value= default_value;
468  }
469 
470  unsigned char *value_ptr(Session *, sql_var_t)
471  {
472  basic_value= value.get();
473  return (unsigned char*)&basic_value;
474  }
475 };
476 
477 template<>
479 {
480  return SHOW_LONGLONG;
481 }
482 
483 template<>
484 inline SHOW_TYPE sys_var_constrained_value<int64_t>::show_type()
485 {
486  return SHOW_LONGLONG;
487 }
488 
489 template<>
490 inline SHOW_TYPE sys_var_constrained_value<uint32_t>::show_type()
491 {
492  return SHOW_INT;
493 }
494 
495 template<>
496 inline SHOW_TYPE sys_var_constrained_value<int32_t>::show_type()
497 {
498  return SHOW_LONG;
499 }
500 
501 template<>
502 inline bool sys_var_constrained_value<uint64_t>::update(Session *, set_var *var)
503 {
504  value= var->getInteger();
505  return false;
506 }
507 
508 template<>
509 inline bool sys_var_constrained_value<uint32_t>::update(Session *, set_var *var)
510 {
511  value= uint32_t(var->getInteger());
512  return false;
513 }
514 
515 template<class T>
517  public sys_var_constrained_value<T>
518 {
519 public:
520  sys_var_constrained_value_readonly(const char *name_arg,
521  constrained_value<T> &value_arg) :
522  sys_var_constrained_value<T>(name_arg, value_arg)
523  { }
524 
525  sys_var_constrained_value_readonly(const char *name_arg,
526  constrained_value<T> &value_arg,
527  T default_value_arg) :
528  sys_var_constrained_value<T>(name_arg, value_arg, default_value_arg)
529  { }
530 
531 public:
532  bool is_readonly() const
533  {
534  return true;
535  }
536 };
537 
539  public sys_var
540 {
541  std::string &value;
542  sys_check_func check_func;
543  sys_update_func update_func;
544  sys_set_default_func set_default_func;
545 public:
546  sys_var_std_string(const std::string &name_arg,
547  std::string &value_arg,
548  sys_check_func check_func_arg= NULL,
549  sys_update_func update_func_arg= NULL) :
550  sys_var(name_arg),
551  value(value_arg),
552  check_func(check_func_arg),
553  update_func(update_func_arg)
554  { }
555 
556  inline void set(char *val_in)
557  {
558  value= val_in;
559  }
560 
561  void set_check_func(sys_check_func check_func_arg= NULL)
562  {
563  check_func= check_func_arg;
564  }
565 
566  void set_update_func(sys_update_func update_func_arg= NULL)
567  {
568  update_func= update_func_arg;
569  }
570 
571  bool check(Session *session, set_var *var);
572 
573  bool update(Session *session, set_var *var)
574  {
575  if (update_func != NULL)
576  {
577  return (*update_func)(session, var);
578  }
579  return false;
580  }
581  SHOW_TYPE show_type() { return SHOW_CHAR; }
582  unsigned char *value_ptr(Session *, sql_var_t)
583  {
584  return (unsigned char*)(value.c_str());
585  }
586  bool check_update_type(Item_result type)
587  {
588  return type != STRING_RESULT; /* Only accept strings */
589  }
590  bool check_default(sql_var_t)
591  { return true; }
592  bool is_readonly() const { return false; }
593 };
594 
596  public sys_var
597 {
598  const std::string &value;
599 public:
600  sys_var_const_string(const char *name_arg,
601  const std::string& value_arg) :
602  sys_var(name_arg),
603  value(value_arg)
604  { }
605 
606  inline void set(char *)
607  { }
608 
609  bool check(Session *, set_var *)
610  {
611  return true;
612  }
613  bool update(Session *, set_var *)
614  {
615  return true;
616  }
617  SHOW_TYPE show_type() { return SHOW_CHAR; }
618  unsigned char *value_ptr(Session *, sql_var_t)
619  {
620  return (unsigned char*)(value.c_str());
621  }
622  bool check_update_type(Item_result)
623  {
624  return true;
625  }
626  bool check_default(sql_var_t) { return true; }
627  bool is_readonly() const { return true; }
628 };
629 
631  public sys_var
632 {
633  const std::string value;
634 public:
635  sys_var_const_string_val(const char *name_arg,
636  const std::string& value_arg) :
637  sys_var(name_arg),
638  value(value_arg)
639  { }
640 
641  inline void set(char *)
642  { }
643 
644  bool check(Session *, set_var *)
645  {
646  return true;
647  }
648  bool update(Session *, set_var *)
649  {
650  return true;
651  }
652  SHOW_TYPE show_type() { return SHOW_CHAR; }
653  unsigned char *value_ptr(Session *, sql_var_t)
654  {
655  return (unsigned char*)(value.c_str());
656  }
657  bool check_update_type(Item_result)
658  {
659  return true;
660  }
661  bool check_default(sql_var_t) { return true; }
662  bool is_readonly() const { return true; }
663 };
664 
666 {
667  char *value; // Pointer to const value
668 public:
669  sys_var_const_str(const char *name_arg,
670  const char *value_arg)
671  :sys_var(name_arg), value((char*) value_arg)
672  { }
673  inline void set (char *new_value)
674  {
675  value= new_value;
676  }
677  bool check(Session *, set_var *)
678  {
679  return 1;
680  }
681  bool update(Session *, set_var *)
682  {
683  return 1;
684  }
685  SHOW_TYPE show_type() { return SHOW_CHAR; }
686  unsigned char *value_ptr(Session *, sql_var_t)
687  {
688  return (unsigned char*) value;
689  }
690  bool check_update_type(Item_result)
691  {
692  return 1;
693  }
694  bool check_default(sql_var_t)
695  { return 1; }
696  bool is_readonly() const { return 1; }
697 };
698 
699 
701 {
702  char **value; // Pointer to const value
703 public:
704  sys_var_const_str_ptr(const char *name_arg, char **value_arg)
705  :sys_var(name_arg),value(value_arg)
706  { }
707  bool check(Session *, set_var *)
708  {
709  return 1;
710  }
711  bool update(Session *, set_var *)
712  {
713  return 1;
714  }
715  SHOW_TYPE show_type() { return SHOW_CHAR; }
716  unsigned char *value_ptr(Session *, sql_var_t)
717  {
718  return (unsigned char*) *value;
719  }
720  bool check_update_type(Item_result)
721  {
722  return 1;
723  }
724  bool check_default(sql_var_t)
725  { return 1; }
726  bool is_readonly(void) const { return 1; }
727 };
728 
729 
731 {
732 public:
733  sys_var_session(const char *name_arg,
734  sys_after_update_func func= NULL)
735  :sys_var(name_arg, func)
736  {}
737  bool check_type(sql_var_t)
738  { return 0; }
739  bool check_default(sql_var_t type)
740  {
741  return type == OPT_GLOBAL && !option_limits;
742  }
743 };
744 
746 {
747  sys_check_func check_func;
748 public:
749  uint32_t drizzle_system_variables::*offset;
750  sys_var_session_uint32_t(const char *name_arg,
751  uint32_t drizzle_system_variables::*offset_arg,
752  sys_check_func c_func= NULL,
753  sys_after_update_func au_func= NULL)
754  :sys_var_session(name_arg, au_func), check_func(c_func),
755  offset(offset_arg)
756  { }
757  bool check(Session *session, set_var *var);
758  bool update(Session *session, set_var *var);
759  void set_default(Session *session, sql_var_t type);
760  SHOW_TYPE show_type() { return SHOW_INT; }
761  unsigned char *value_ptr(Session *session, sql_var_t type);
762 };
763 
764 
766 {
767 public:
768  ha_rows drizzle_system_variables::*offset;
769  sys_var_session_ha_rows(const char *name_arg,
770  ha_rows drizzle_system_variables::*offset_arg)
771  :sys_var_session(name_arg), offset(offset_arg)
772  { }
773  sys_var_session_ha_rows(const char *name_arg,
774  ha_rows drizzle_system_variables::*offset_arg,
775  sys_after_update_func func)
776  :sys_var_session(name_arg,func), offset(offset_arg)
777  { }
778  bool update(Session *session, set_var *var);
779  void set_default(Session *session, sql_var_t type);
780  SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
781  unsigned char *value_ptr(Session *session, sql_var_t type);
782 };
783 
784 
786 {
787  sys_check_func check_func;
788 public:
789  uint64_t drizzle_system_variables::*offset;
790  bool only_global;
792  const char *name_arg,
793  uint64_t drizzle_system_variables::*offset_arg,
794  sys_after_update_func au_func= NULL,
795  sys_check_func c_func= NULL)
796  :sys_var_session(name_arg, au_func),
797  check_func(c_func),
798  offset(offset_arg)
799  { }
800  sys_var_session_uint64_t(const char *name_arg,
801  uint64_t drizzle_system_variables::*offset_arg,
802  sys_after_update_func func,
803  bool only_global_arg,
804  sys_check_func cfunc= NULL)
805  :sys_var_session(name_arg, func),
806  check_func(cfunc),
807  offset(offset_arg),
808  only_global(only_global_arg)
809  { }
810  bool update(Session *session, set_var *var);
811  void set_default(Session *session, sql_var_t type);
812  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
813  unsigned char *value_ptr(Session *session, sql_var_t type);
814  bool check(Session *session, set_var *var);
815  bool check_default(sql_var_t type)
816  {
817  return type == OPT_GLOBAL && !option_limits;
818  }
819  bool check_type(sql_var_t type)
820  {
821  return (only_global && type != OPT_GLOBAL);
822  }
823 };
824 
826 {
827  sys_check_func check_func;
828 public:
829  size_t drizzle_system_variables::*offset;
830  bool only_global;
831  sys_var_session_size_t(const char *name_arg,
832  size_t drizzle_system_variables::*offset_arg,
833  sys_after_update_func au_func= NULL,
834  sys_check_func c_func= NULL)
835  :sys_var_session(name_arg, au_func),
836  check_func(c_func),
837  offset(offset_arg)
838  { }
839  sys_var_session_size_t(const char *name_arg,
840  size_t drizzle_system_variables::*offset_arg,
841  sys_after_update_func func,
842  bool only_global_arg,
843  sys_check_func cfunc= NULL)
844  :sys_var_session(name_arg, func),
845  check_func(cfunc),
846  offset(offset_arg),
847  only_global(only_global_arg)
848  { }
849  bool update(Session *session, set_var *var);
850  void set_default(Session *session, sql_var_t type);
851  SHOW_TYPE show_type() { return SHOW_SIZE; }
852  unsigned char *value_ptr(Session *session, sql_var_t type);
853  bool check(Session *session, set_var *var);
854  bool check_default(sql_var_t type)
855  {
856  return type == OPT_GLOBAL && !option_limits;
857  }
858  bool check_type(sql_var_t type)
859  {
860  return (only_global && type != OPT_GLOBAL);
861  }
862 };
863 
864 
866 {
867 public:
868  bool drizzle_system_variables::*offset;
869  sys_var_session_bool(const char *name_arg, bool drizzle_system_variables::*offset_arg)
870  :sys_var_session(name_arg), offset(offset_arg)
871  { }
872  sys_var_session_bool(const char *name_arg, bool drizzle_system_variables::*offset_arg,
873  sys_after_update_func func)
874  :sys_var_session(name_arg,func), offset(offset_arg)
875  { }
876  bool update(Session *session, set_var *var);
877  void set_default(Session *session, sql_var_t type);
878  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
879  unsigned char *value_ptr(Session *session, sql_var_t type);
880  bool check(Session *session, set_var *var);
881  bool check_update_type(Item_result)
882  { return 0; }
883 };
884 
885 
887 {
888 protected:
889  uint32_t drizzle_system_variables::*offset;
890  TYPELIB *enum_names;
891  sys_check_func check_func;
892 public:
893  sys_var_session_enum(const char *name_arg,
894  uint32_t drizzle_system_variables::*offset_arg, TYPELIB *typelib,
895  sys_after_update_func func= NULL,
896  sys_check_func check_f= NULL)
897  :sys_var_session(name_arg, func), offset(offset_arg),
898  enum_names(typelib), check_func(check_f)
899  { }
900  bool check(Session *session, set_var *var)
901  {
902  int ret= 0;
903  if (check_func)
904  ret= (*check_func)(session, var);
905  return ret ? ret : check_enum(session, var, enum_names);
906  }
907  bool update(Session *session, set_var *var);
908  void set_default(Session *session, sql_var_t type);
909  SHOW_TYPE show_type() { return SHOW_CHAR; }
910  unsigned char *value_ptr(Session *session, sql_var_t type);
911  bool check_update_type(Item_result)
912  { return 0; }
913 };
914 
915 
917 {
918 protected:
920 public:
921  sys_var_session_storage_engine(const char *name_arg,
923  :sys_var_session(name_arg), offset(offset_arg)
924  { }
925  SHOW_TYPE show_type() { return SHOW_CHAR; }
926  bool check_update_type(Item_result type)
927  {
928  return type != STRING_RESULT; /* Only accept strings */
929  }
930  void set_default(Session *session, sql_var_t type);
931  bool update(Session *session, set_var *var);
932  unsigned char *value_ptr(Session *session, sql_var_t type);
933 };
934 
936 {
937  sys_check_func check_func;
938  sys_update_func update_func;
939 public:
940  uint64_t bit_flag;
941  bool reverse;
942  sys_var_session_bit(const char *name_arg,
943  sys_check_func c_func, sys_update_func u_func,
944  uint64_t bit, bool reverse_arg=0)
945  :sys_var_session(name_arg, NULL), check_func(c_func),
946  update_func(u_func), bit_flag(bit), reverse(reverse_arg)
947  { }
948  bool check(Session *session, set_var *var);
949  bool update(Session *session, set_var *var);
950  bool check_update_type(Item_result)
951  { return 0; }
952  bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
953  SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
954  unsigned char *value_ptr(Session *session, sql_var_t type);
955 };
956 
957 /* some variables that require special handling */
958 
960 {
961 public:
962  sys_var_timestamp(const char *name_arg)
963  :sys_var(name_arg, NULL)
964  { }
965  bool update(Session *session, set_var *var);
966  void set_default(Session *session, sql_var_t type);
967  bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
968  bool check_default(sql_var_t)
969  { return 0; }
970  SHOW_TYPE show_type(void) { return SHOW_LONG; }
971  unsigned char *value_ptr(Session *session, sql_var_t type);
972 };
973 
974 
976 {
977 public:
978  sys_var_last_insert_id(const char *name_arg)
979  :sys_var(name_arg, NULL)
980  { }
981  bool update(Session *session, set_var *var);
982  bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
983  SHOW_TYPE show_type() { return SHOW_LONGLONG; }
984  unsigned char *value_ptr(Session *session, sql_var_t type);
985 };
986 
987 
989 {
990 public:
991  sys_var_collation(const char *name_arg)
992  :sys_var_session(name_arg, NULL)
993  { }
994  SHOW_TYPE show_type() { return SHOW_CHAR; }
995  bool check_update_type(Item_result type)
996  {
997  return ((type != STRING_RESULT) && (type != INT_RESULT));
998  }
999  bool check_default(sql_var_t) { return 0; }
1000  virtual void set_default(Session *session, sql_var_t type)= 0;
1001 };
1002 
1004 {
1005  const charset_info_st *drizzle_system_variables::*offset;
1006  const charset_info_st **global_default;
1007 public:
1008  sys_var_collation_sv(const char *name_arg,
1009  const charset_info_st *drizzle_system_variables::*offset_arg,
1010  const charset_info_st **global_default_arg)
1011  :sys_var_collation(name_arg),
1012  offset(offset_arg), global_default(global_default_arg)
1013  {
1014 
1015  }
1016  bool update(Session *session, set_var *var);
1017  void set_default(Session *session, sql_var_t type);
1018  unsigned char *value_ptr(Session *session, sql_var_t type);
1019 };
1020 
1021 /* Variable that you can only read from */
1022 
1024 {
1025 public:
1026  sql_var_t var_type;
1027  SHOW_TYPE show_type_value;
1028  sys_value_ptr_func value_ptr_func;
1029  sys_var_readonly(const char *name_arg, sql_var_t type,
1030  SHOW_TYPE show_type_arg,
1031  sys_value_ptr_func value_ptr_func_arg)
1032  :sys_var(name_arg), var_type(type),
1033  show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
1034  { }
1035  bool update(Session *, set_var *)
1036  { return 1; }
1037  bool check_default(sql_var_t)
1038  { return 1; }
1039  bool check_type(sql_var_t type) { return type != var_type; }
1040  bool check_update_type(Item_result)
1041  { return 1; }
1042  unsigned char *value_ptr(Session *session, sql_var_t)
1043  {
1044  return (*value_ptr_func)(session);
1045  }
1046  SHOW_TYPE show_type(void) { return show_type_value; }
1047  bool is_readonly(void) const { return 1; }
1048 };
1049 
1051 {
1052  uint64_t drizzle_system_variables::*offset;
1053 public:
1054  sys_var_microseconds(const char *name_arg,
1055  uint64_t drizzle_system_variables::*offset_arg):
1056  sys_var_session(name_arg), offset(offset_arg)
1057  { }
1058  bool check(Session *, set_var *) {return 0;}
1059  bool update(Session *session, set_var *var);
1060  void set_default(Session *session, sql_var_t type);
1061  SHOW_TYPE show_type() { return SHOW_DOUBLE; }
1062  bool check_update_type(Item_result type)
1063  {
1064  return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
1065  }
1066 };
1067 
1069 {
1070 public:
1071  sys_var_session_lc_time_names(const char *name_arg)
1072  : sys_var_session(name_arg, NULL)
1073  {
1074 
1075  }
1076  SHOW_TYPE show_type() { return SHOW_CHAR; }
1077  bool check_update_type(Item_result type)
1078  {
1079  return ((type != STRING_RESULT) && (type != INT_RESULT));
1080  }
1081  bool check_default(sql_var_t)
1082  { return 0; }
1083  bool update(Session *session, set_var *var);
1084  unsigned char *value_ptr(Session *session, sql_var_t type);
1085  virtual void set_default(Session *session, sql_var_t type);
1086 };
1087 
1088 /* For sql_yacc */
1090 {
1091  sys_var* var;
1092  lex_string_t base_name;
1093 };
1094 
1095 /*
1096  Prototypes for helper functions
1097 */
1098 
1099 drizzle_show_var* enumerate_sys_vars(Session*);
1100 void add_sys_var_to_list(sys_var*, option*);
1101 void add_sys_var_to_list(sys_var*);
1102 sys_var* find_sys_var(const std::string&);
1103 
1104 extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
1105 
1106 } /* namespace drizzled */
struct option * getOptionLimits() const
Definition: sys_var.h:126
bool m_allow_empty_value
Definition: sys_var.h:85
const char * in_additional_cond
Definition: drizzled.cc:312
TODO: Rename this file - func.h is stupid.
sys_after_update_func getAfterUpdateTrigger() const
Definition: sys_var.h:142
const std::string & getName() const
Definition: sys_var.h:111
struct option * option_limits
Definition: sys_var.h:84
sys_after_update_func after_update
Definition: sys_var.h:83
#define DRIZZLED_API
Definition: visibility.h:62
const std::vector< std::string > & getAliases() const
Definition: sys_var.h:119
Visibility Control Macros.
void setOptionLimits(struct option *in_option_limits)
Definition: sys_var.h:135
sys_var * find_sys_var(const std::string &name)
Definition: sys_var.cc:1411
const char * in_left_expr_name
Definition: drizzled.cc:310
std::string name
Definition: sys_var.h:81