00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <string>
00023 #include <boost/filesystem.hpp>
00024
00025 #include <drizzled/constrained_value.h>
00026 #include <drizzled/set_var.h>
00027 #include <drizzled/show_type.h>
00028 #include <drizzled/item_result.h>
00029 #include <drizzled/base.h>
00030 #include <drizzled/global_charset_info.h>
00031 #include <drizzled/lex_string.h>
00032 #include <drizzled/visibility.h>
00033
00034 namespace drizzled {
00035
00036 class Session;
00037 class sys_var;
00038 class Time_zone;
00039 typedef struct my_locale_st MY_LOCALE;
00040 typedef struct st_typelib TYPELIB;
00041
00042 typedef int (*sys_check_func)(Session *, set_var *);
00043 typedef bool (*sys_update_func)(Session *, set_var *);
00044 typedef void (*sys_after_update_func)(Session *, sql_var_t);
00045 typedef void (*sys_set_default_func)(Session *, sql_var_t);
00046 typedef unsigned char *(*sys_value_ptr_func)(Session *session);
00047
00048 static const std::vector<std::string> empty_aliases;
00049 extern struct drizzle_system_variables max_system_variables;
00050 extern size_t table_def_size;
00051
00052 extern std::string drizzle_tmpdir;
00053 extern const char *first_keyword;
00054 extern const char *in_left_expr_name;
00055 extern const char *in_additional_cond;
00056 extern const char *in_having_cond;
00057 extern boost::filesystem::path basedir;
00058 extern boost::filesystem::path pid_file;
00059 extern boost::filesystem::path secure_file_priv;
00060 extern char *opt_tc_log_file;
00061 extern uint64_t session_startup_options;
00062 extern uint32_t global_thread_id;
00063 extern uint64_t table_cache_size;
00064 extern back_log_constraints back_log;
00065 extern uint32_t ha_open_options;
00066 extern char *drizzled_bind_host;
00067 extern uint32_t dropping_tables;
00068 extern bool opt_endinfo;
00069 extern uint32_t volatile thread_running;
00070 extern uint32_t volatile global_read_lock;
00071 extern bool opt_readonly;
00072 extern const char *opt_scheduler;
00073 extern size_t transaction_message_threshold;
00074
00075 uint64_t fix_unsigned(Session *, uint64_t, const struct option *);
00076
00077 DRIZZLED_API const std::string &getServerHostname();
00078 int sys_var_init();
00079
00084 class DRIZZLED_API sys_var
00085 {
00086 protected:
00087 std::string name;
00088 sys_check_func check_func;
00089 sys_after_update_func after_update;
00090 struct option *option_limits;
00091 bool m_allow_empty_value;
00092 public:
00093 sys_var(const std::string &name_arg,
00094 sys_after_update_func func= NULL,
00095 sys_check_func check_func_arg= NULL)
00096 :
00097 name(name_arg),
00098 check_func(check_func_arg),
00099 after_update(func),
00100 option_limits(NULL),
00101 m_allow_empty_value(true)
00102 {}
00103 virtual ~sys_var() {}
00104
00105 void setName(const std::string &name_in)
00106 {
00107 name= name_in;
00108 }
00109
00117 inline const std::string &getName() const
00118 {
00119 return name;
00120 }
00125 const std::vector<std::string>& getAliases() const
00126 {
00127 return empty_aliases;
00128 }
00132 inline struct option *getOptionLimits() const
00133 {
00134 return option_limits;
00135 }
00141 inline void setOptionLimits(struct option *in_option_limits)
00142 {
00143 option_limits= in_option_limits;
00144 }
00148 inline sys_after_update_func getAfterUpdateTrigger() const
00149 {
00150 return after_update;
00151 }
00152 virtual bool check(Session *session, set_var *var);
00153 bool check_enum(Session *session, set_var *var, const TYPELIB *enum_names);
00154 virtual bool update(Session *session, set_var *var)=0;
00155 virtual void set_default(Session *, sql_var_t)
00156 {}
00157 virtual SHOW_TYPE show_type()
00158 {
00159 return SHOW_UNDEF;
00160 }
00161 virtual unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00162 {
00163 return 0;
00164 }
00165 virtual bool check_type(sql_var_t type)
00166 {
00167 return type != OPT_GLOBAL;
00168 }
00169 virtual bool check_update_type(Item_result type)
00170 {
00171 return type != INT_RESULT;
00172 }
00173 virtual bool check_default(sql_var_t)
00174 {
00175 return option_limits == 0;
00176 }
00177 Item *item(Session *session, sql_var_t type, const LEX_STRING *base);
00178 virtual bool is_readonly() const
00179 {
00180 return 0;
00181 }
00182 };
00183
00188 class DRIZZLED_API sys_var_global: public sys_var
00189 {
00190 protected:
00191 pthread_mutex_t *guard;
00192 public:
00193 sys_var_global(const char *name_arg,
00194 sys_after_update_func after_update_arg,
00195 pthread_mutex_t *guard_arg)
00196 :
00197 sys_var(name_arg, after_update_arg),
00198 guard(guard_arg)
00199 {}
00200 };
00201
00202 class DRIZZLED_API sys_var_uint32_t_ptr :public sys_var
00203 {
00204 uint32_t *value;
00205 public:
00206 sys_var_uint32_t_ptr(const char *name_arg,
00207 uint32_t *value_ptr_arg)
00208 :sys_var(name_arg),value(value_ptr_arg)
00209 { }
00210 sys_var_uint32_t_ptr(const char *name_arg,
00211 uint32_t *value_ptr_arg,
00212 sys_after_update_func func)
00213 :sys_var(name_arg,func), value(value_ptr_arg)
00214 { }
00215 bool check(Session *session, set_var *var);
00216 bool update(Session *session, set_var *var);
00217 void set_default(Session *session, sql_var_t type);
00218 SHOW_TYPE show_type() { return SHOW_INT; }
00219 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00220 { return (unsigned char*) value; }
00221 };
00222
00223 class DRIZZLED_API sys_var_uint32_t_ptr_readonly :
00224 public sys_var_uint32_t_ptr
00225 {
00226 public:
00227 sys_var_uint32_t_ptr_readonly(const char *name_arg,
00228 uint32_t *value_ptr_arg) :
00229 sys_var_uint32_t_ptr(name_arg, value_ptr_arg)
00230 {}
00231
00232 sys_var_uint32_t_ptr_readonly(const char *name_arg,
00233 uint32_t *value_ptr_arg,
00234 sys_after_update_func func) :
00235 sys_var_uint32_t_ptr(name_arg, value_ptr_arg, func)
00236 {}
00237
00238 bool is_readonly() const
00239 {
00240 return true;
00241 }
00242 };
00243
00244
00245 class DRIZZLED_API sys_var_uint64_t_ptr :public sys_var
00246 {
00247 uint64_t *value;
00248 const uint64_t default_value;
00249 bool have_default_value;
00250 public:
00251 sys_var_uint64_t_ptr(const char *name_arg, uint64_t *value_ptr_arg) :
00252 sys_var(name_arg),
00253 value(value_ptr_arg),
00254 default_value(0),
00255 have_default_value(false)
00256 { }
00257
00258 sys_var_uint64_t_ptr(const char *name_arg,
00259 uint64_t *value_ptr_arg,
00260 const uint64_t default_value_in) :
00261 sys_var(name_arg),
00262 value(value_ptr_arg),
00263 default_value(default_value_in),
00264 have_default_value(true)
00265 { }
00266
00267 sys_var_uint64_t_ptr(const char *name_arg,
00268 uint64_t *value_ptr_arg,
00269 sys_after_update_func func) :
00270 sys_var(name_arg,func),
00271 value(value_ptr_arg),
00272 default_value(0),
00273 have_default_value(false)
00274 { }
00275
00276 sys_var_uint64_t_ptr(const char *name_arg,
00277 uint64_t *value_ptr_arg,
00278 sys_after_update_func func,
00279 const uint64_t default_value_in) :
00280 sys_var(name_arg,func),
00281 value(value_ptr_arg),
00282 default_value(default_value_in),
00283 have_default_value(true)
00284 { }
00285
00286 bool update(Session *session, set_var *var);
00287 void set_default(Session *session, sql_var_t type);
00288 virtual bool check_default(sql_var_t)
00289 {
00290 return (not have_default_value) && option_limits == 0;
00291 }
00292 SHOW_TYPE show_type() { return SHOW_LONGLONG; }
00293 unsigned char *value_ptr(Session *, sql_var_t,
00294 const LEX_STRING *)
00295 { return (unsigned char*) value; }
00296 };
00297
00298 class DRIZZLED_API sys_var_size_t_ptr :public sys_var
00299 {
00300 size_t *value;
00301 public:
00302 sys_var_size_t_ptr(const char *name_arg, size_t *value_ptr_arg)
00303 :sys_var(name_arg),value(value_ptr_arg)
00304 { }
00305 sys_var_size_t_ptr(const char *name_arg, size_t *value_ptr_arg,
00306 sys_after_update_func func)
00307 :sys_var(name_arg,func), value(value_ptr_arg)
00308 { }
00309 bool update(Session *session, set_var *var);
00310 void set_default(Session *session, sql_var_t type);
00311 SHOW_TYPE show_type() { return SHOW_SIZE; }
00312 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00313 { return (unsigned char*) value; }
00314 };
00315
00316 class DRIZZLED_API sys_var_size_t_ptr_readonly :public sys_var_size_t_ptr
00317 {
00318 public:
00319 sys_var_size_t_ptr_readonly(const char *name_arg,
00320 size_t *value_arg)
00321 :sys_var_size_t_ptr(name_arg, value_arg)
00322 {}
00323 bool is_readonly() const { return 1; }
00324 };
00325
00326 class DRIZZLED_API sys_var_bool_ptr :public sys_var
00327 {
00328 bool default_value;
00329 public:
00330 bool *value;
00331 sys_var_bool_ptr(const std::string &name_arg, bool *value_arg,
00332 sys_after_update_func func= NULL) :
00333 sys_var(name_arg, func), default_value(*value_arg), value(value_arg)
00334 { }
00335 bool check(Session *session, set_var *var);
00336 virtual bool check_default(sql_var_t)
00337 {
00338 return false;
00339 }
00340 bool update(Session *session, set_var *var);
00341 void set_default(Session *session, sql_var_t type);
00342 SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
00343 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00344 { return (unsigned char*) value; }
00345 bool check_update_type(Item_result)
00346 { return 0; }
00347 };
00348
00349 class DRIZZLED_API sys_var_bool_ptr_readonly :public sys_var_bool_ptr
00350 {
00351 public:
00352 sys_var_bool_ptr_readonly(const char *name_arg,
00353 bool *value_arg)
00354 :sys_var_bool_ptr(name_arg, value_arg)
00355 {}
00356 bool is_readonly() const { return 1; }
00357 };
00358
00359
00360 class DRIZZLED_API sys_var_str :public sys_var
00361 {
00362 public:
00363 char *value;
00364 uint32_t value_length;
00365 sys_update_func update_func;
00366 sys_set_default_func set_default_func;
00367 sys_var_str(const char *name_arg,
00368 sys_check_func check_func_arg,
00369 sys_update_func update_func_arg,
00370 sys_set_default_func set_default_func_arg,
00371 char *value_arg) :
00372 sys_var(name_arg, NULL, check_func_arg),
00373 value(value_arg),
00374 update_func(update_func_arg),
00375 set_default_func(set_default_func_arg)
00376 { }
00377 bool check(Session *session, set_var *var);
00378 bool update(Session *session, set_var *var)
00379 {
00380 return (*update_func)(session, var);
00381 }
00382 void set_default(Session *session, sql_var_t type)
00383 {
00384 (*set_default_func)(session, type);
00385 }
00386 SHOW_TYPE show_type() { return SHOW_CHAR; }
00387 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00388 { return (unsigned char*) value; }
00389 bool check_update_type(Item_result type)
00390 {
00391 return type != STRING_RESULT;
00392 }
00393 bool check_default(sql_var_t)
00394 { return 0; }
00395 };
00396
00397
00398 class DRIZZLED_API sys_var_fs_path :
00399 public sys_var
00400 {
00401 const boost::filesystem::path &value;
00402 public:
00403 sys_var_fs_path(const char *name_arg,
00404 const boost::filesystem::path& value_arg) :
00405 sys_var(name_arg),
00406 value(value_arg)
00407 { }
00408
00409 inline void set(char *)
00410 { }
00411
00412 bool check(Session *, set_var *)
00413 {
00414 return true;
00415 }
00416 bool update(Session *, set_var *)
00417 {
00418 return true;
00419 }
00420 SHOW_TYPE show_type() { return SHOW_CHAR; }
00421 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00422 {
00423 return (unsigned char*)(value.file_string().c_str());
00424 }
00425 bool check_update_type(Item_result)
00426 {
00427 return true;
00428 }
00429 bool check_default(sql_var_t) { return true; }
00430 bool is_readonly() const { return true; }
00431 };
00432
00433 template<class T>
00434 class sys_var_constrained_value :
00435 public sys_var
00436 {
00437 constrained_value<T> &value;
00438 T basic_value;
00439 T default_value;
00440 public:
00441 sys_var_constrained_value(const char *name_arg,
00442 constrained_value<T> &value_arg) :
00443 sys_var(name_arg),
00444 value(value_arg),
00445 default_value(value_arg.get())
00446 { }
00447
00448 sys_var_constrained_value(const char *name_arg,
00449 constrained_value<T> &value_arg,
00450 sys_after_update_func after_update_func_arg) :
00451 sys_var(name_arg, after_update_func_arg),
00452 value(value_arg),
00453 default_value(value_arg.get())
00454 { }
00455
00456 sys_var_constrained_value(const char *name_arg,
00457 constrained_value<T> &value_arg,
00458 sys_check_func check_func_arg) :
00459 sys_var(name_arg, NULL, check_func_arg),
00460 value(value_arg),
00461 default_value(value_arg.get())
00462 { }
00463
00464 public:
00465 bool is_readonly() const
00466 {
00467 return false;
00468 }
00469
00470 SHOW_TYPE show_type() { return SHOW_INT; }
00471
00472 bool update(Session *, set_var *var)
00473 {
00474 value= uint32_t(var->getInteger());
00475 return false;
00476 }
00477
00478 bool check_default(sql_var_t)
00479 {
00480 return false;
00481 }
00482
00483 void set_default(Session *, sql_var_t)
00484 {
00485 value= default_value;
00486 }
00487
00488 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00489 {
00490 basic_value= value.get();
00491 return (unsigned char*)&basic_value;
00492 }
00493 };
00494
00495 template<>
00496 inline SHOW_TYPE sys_var_constrained_value<uint64_t>::show_type()
00497 {
00498 return SHOW_LONGLONG;
00499 }
00500
00501 template<>
00502 inline SHOW_TYPE sys_var_constrained_value<int64_t>::show_type()
00503 {
00504 return SHOW_LONGLONG;
00505 }
00506
00507 template<>
00508 inline SHOW_TYPE sys_var_constrained_value<uint32_t>::show_type()
00509 {
00510 return SHOW_INT;
00511 }
00512
00513 template<>
00514 inline SHOW_TYPE sys_var_constrained_value<int32_t>::show_type()
00515 {
00516 return SHOW_LONG;
00517 }
00518
00519 template<>
00520 inline bool sys_var_constrained_value<uint64_t>::update(Session *, set_var *var)
00521 {
00522 value= var->getInteger();
00523 return false;
00524 }
00525
00526 template<>
00527 inline bool sys_var_constrained_value<uint32_t>::update(Session *, set_var *var)
00528 {
00529 value= uint32_t(var->getInteger());
00530 return false;
00531 }
00532
00533 template<class T>
00534 class sys_var_constrained_value_readonly :
00535 public sys_var_constrained_value<T>
00536 {
00537 public:
00538 sys_var_constrained_value_readonly(const char *name_arg,
00539 constrained_value<T> &value_arg) :
00540 sys_var_constrained_value<T>(name_arg, value_arg)
00541 { }
00542
00543 sys_var_constrained_value_readonly(const char *name_arg,
00544 constrained_value<T> &value_arg,
00545 T default_value_arg) :
00546 sys_var_constrained_value<T>(name_arg, value_arg, default_value_arg)
00547 { }
00548
00549 public:
00550 bool is_readonly() const
00551 {
00552 return true;
00553 }
00554 };
00555
00556 class DRIZZLED_API sys_var_std_string :
00557 public sys_var
00558 {
00559 std::string &value;
00560 sys_check_func check_func;
00561 sys_update_func update_func;
00562 sys_set_default_func set_default_func;
00563 public:
00564 sys_var_std_string(const std::string &name_arg,
00565 std::string &value_arg,
00566 sys_check_func check_func_arg= NULL,
00567 sys_update_func update_func_arg= NULL) :
00568 sys_var(name_arg),
00569 value(value_arg),
00570 check_func(check_func_arg),
00571 update_func(update_func_arg)
00572 { }
00573
00574 inline void set(char *val_in)
00575 {
00576 value= val_in;
00577 }
00578
00579 void set_check_func(sys_check_func check_func_arg= NULL)
00580 {
00581 check_func= check_func_arg;
00582 }
00583
00584 void set_update_func(sys_update_func update_func_arg= NULL)
00585 {
00586 update_func= update_func_arg;
00587 }
00588
00589 bool check(Session *session, set_var *var);
00590
00591 bool update(Session *session, set_var *var)
00592 {
00593 if (update_func != NULL)
00594 {
00595 return (*update_func)(session, var);
00596 }
00597 return false;
00598 }
00599 SHOW_TYPE show_type() { return SHOW_CHAR; }
00600 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00601 {
00602 return (unsigned char*)(value.c_str());
00603 }
00604 bool check_update_type(Item_result type)
00605 {
00606 return type != STRING_RESULT;
00607 }
00608 bool check_default(sql_var_t)
00609 { return true; }
00610 bool is_readonly() const { return false; }
00611 };
00612
00613 class DRIZZLED_API sys_var_const_string :
00614 public sys_var
00615 {
00616 const std::string &value;
00617 public:
00618 sys_var_const_string(const char *name_arg,
00619 const std::string& value_arg) :
00620 sys_var(name_arg),
00621 value(value_arg)
00622 { }
00623
00624 inline void set(char *)
00625 { }
00626
00627 bool check(Session *, set_var *)
00628 {
00629 return true;
00630 }
00631 bool update(Session *, set_var *)
00632 {
00633 return true;
00634 }
00635 SHOW_TYPE show_type() { return SHOW_CHAR; }
00636 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00637 {
00638 return (unsigned char*)(value.c_str());
00639 }
00640 bool check_update_type(Item_result)
00641 {
00642 return true;
00643 }
00644 bool check_default(sql_var_t) { return true; }
00645 bool is_readonly() const { return true; }
00646 };
00647
00648 class DRIZZLED_API sys_var_const_string_val :
00649 public sys_var
00650 {
00651 const std::string value;
00652 public:
00653 sys_var_const_string_val(const char *name_arg,
00654 const std::string& value_arg) :
00655 sys_var(name_arg),
00656 value(value_arg)
00657 { }
00658
00659 inline void set(char *)
00660 { }
00661
00662 bool check(Session *, set_var *)
00663 {
00664 return true;
00665 }
00666 bool update(Session *, set_var *)
00667 {
00668 return true;
00669 }
00670 SHOW_TYPE show_type() { return SHOW_CHAR; }
00671 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00672 {
00673 return (unsigned char*)(value.c_str());
00674 }
00675 bool check_update_type(Item_result)
00676 {
00677 return true;
00678 }
00679 bool check_default(sql_var_t) { return true; }
00680 bool is_readonly() const { return true; }
00681 };
00682
00683 class DRIZZLED_API sys_var_const_str :public sys_var
00684 {
00685 char *value;
00686 public:
00687 sys_var_const_str(const char *name_arg,
00688 const char *value_arg)
00689 :sys_var(name_arg), value((char*) value_arg)
00690 { }
00691 inline void set (char *new_value)
00692 {
00693 value= new_value;
00694 }
00695 bool check(Session *, set_var *)
00696 {
00697 return 1;
00698 }
00699 bool update(Session *, set_var *)
00700 {
00701 return 1;
00702 }
00703 SHOW_TYPE show_type() { return SHOW_CHAR; }
00704 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00705 {
00706 return (unsigned char*) value;
00707 }
00708 bool check_update_type(Item_result)
00709 {
00710 return 1;
00711 }
00712 bool check_default(sql_var_t)
00713 { return 1; }
00714 bool is_readonly() const { return 1; }
00715 };
00716
00717
00718 class DRIZZLED_API sys_var_const_str_ptr :public sys_var
00719 {
00720 char **value;
00721 public:
00722 sys_var_const_str_ptr(const char *name_arg, char **value_arg)
00723 :sys_var(name_arg),value(value_arg)
00724 { }
00725 bool check(Session *, set_var *)
00726 {
00727 return 1;
00728 }
00729 bool update(Session *, set_var *)
00730 {
00731 return 1;
00732 }
00733 SHOW_TYPE show_type() { return SHOW_CHAR; }
00734 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
00735 {
00736 return (unsigned char*) *value;
00737 }
00738 bool check_update_type(Item_result)
00739 {
00740 return 1;
00741 }
00742 bool check_default(sql_var_t)
00743 { return 1; }
00744 bool is_readonly(void) const { return 1; }
00745 };
00746
00747
00748 class DRIZZLED_API sys_var_session :public sys_var
00749 {
00750 public:
00751 sys_var_session(const char *name_arg,
00752 sys_after_update_func func= NULL)
00753 :sys_var(name_arg, func)
00754 {}
00755 bool check_type(sql_var_t)
00756 { return 0; }
00757 bool check_default(sql_var_t type)
00758 {
00759 return type == OPT_GLOBAL && !option_limits;
00760 }
00761 };
00762
00763 class DRIZZLED_API sys_var_session_uint32_t :public sys_var_session
00764 {
00765 sys_check_func check_func;
00766 public:
00767 uint32_t drizzle_system_variables::*offset;
00768 sys_var_session_uint32_t(const char *name_arg,
00769 uint32_t drizzle_system_variables::*offset_arg,
00770 sys_check_func c_func= NULL,
00771 sys_after_update_func au_func= NULL)
00772 :sys_var_session(name_arg, au_func), check_func(c_func),
00773 offset(offset_arg)
00774 { }
00775 bool check(Session *session, set_var *var);
00776 bool update(Session *session, set_var *var);
00777 void set_default(Session *session, sql_var_t type);
00778 SHOW_TYPE show_type() { return SHOW_INT; }
00779 unsigned char *value_ptr(Session *session, sql_var_t type,
00780 const LEX_STRING *base);
00781 };
00782
00783
00784 class DRIZZLED_API sys_var_session_ha_rows :public sys_var_session
00785 {
00786 public:
00787 ha_rows drizzle_system_variables::*offset;
00788 sys_var_session_ha_rows(const char *name_arg,
00789 ha_rows drizzle_system_variables::*offset_arg)
00790 :sys_var_session(name_arg), offset(offset_arg)
00791 { }
00792 sys_var_session_ha_rows(const char *name_arg,
00793 ha_rows drizzle_system_variables::*offset_arg,
00794 sys_after_update_func func)
00795 :sys_var_session(name_arg,func), offset(offset_arg)
00796 { }
00797 bool update(Session *session, set_var *var);
00798 void set_default(Session *session, sql_var_t type);
00799 SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
00800 unsigned char *value_ptr(Session *session, sql_var_t type,
00801 const LEX_STRING *base);
00802 };
00803
00804
00805 class DRIZZLED_API sys_var_session_uint64_t :public sys_var_session
00806 {
00807 sys_check_func check_func;
00808 public:
00809 uint64_t drizzle_system_variables::*offset;
00810 bool only_global;
00811 sys_var_session_uint64_t(
00812 const char *name_arg,
00813 uint64_t drizzle_system_variables::*offset_arg,
00814 sys_after_update_func au_func= NULL,
00815 sys_check_func c_func= NULL)
00816 :sys_var_session(name_arg, au_func),
00817 check_func(c_func),
00818 offset(offset_arg)
00819 { }
00820 sys_var_session_uint64_t(const char *name_arg,
00821 uint64_t drizzle_system_variables::*offset_arg,
00822 sys_after_update_func func,
00823 bool only_global_arg,
00824 sys_check_func cfunc= NULL)
00825 :sys_var_session(name_arg, func),
00826 check_func(cfunc),
00827 offset(offset_arg),
00828 only_global(only_global_arg)
00829 { }
00830 bool update(Session *session, set_var *var);
00831 void set_default(Session *session, sql_var_t type);
00832 SHOW_TYPE show_type() { return SHOW_LONGLONG; }
00833 unsigned char *value_ptr(Session *session, sql_var_t type,
00834 const LEX_STRING *base);
00835 bool check(Session *session, set_var *var);
00836 bool check_default(sql_var_t type)
00837 {
00838 return type == OPT_GLOBAL && !option_limits;
00839 }
00840 bool check_type(sql_var_t type)
00841 {
00842 return (only_global && type != OPT_GLOBAL);
00843 }
00844 };
00845
00846 class DRIZZLED_API sys_var_session_size_t :public sys_var_session
00847 {
00848 sys_check_func check_func;
00849 public:
00850 size_t drizzle_system_variables::*offset;
00851 bool only_global;
00852 sys_var_session_size_t(const char *name_arg,
00853 size_t drizzle_system_variables::*offset_arg,
00854 sys_after_update_func au_func= NULL,
00855 sys_check_func c_func= NULL)
00856 :sys_var_session(name_arg, au_func),
00857 check_func(c_func),
00858 offset(offset_arg)
00859 { }
00860 sys_var_session_size_t(const char *name_arg,
00861 size_t drizzle_system_variables::*offset_arg,
00862 sys_after_update_func func,
00863 bool only_global_arg,
00864 sys_check_func cfunc= NULL)
00865 :sys_var_session(name_arg, func),
00866 check_func(cfunc),
00867 offset(offset_arg),
00868 only_global(only_global_arg)
00869 { }
00870 bool update(Session *session, set_var *var);
00871 void set_default(Session *session, sql_var_t type);
00872 SHOW_TYPE show_type() { return SHOW_SIZE; }
00873 unsigned char *value_ptr(Session *session, sql_var_t type,
00874 const LEX_STRING *base);
00875 bool check(Session *session, set_var *var);
00876 bool check_default(sql_var_t type)
00877 {
00878 return type == OPT_GLOBAL && !option_limits;
00879 }
00880 bool check_type(sql_var_t type)
00881 {
00882 return (only_global && type != OPT_GLOBAL);
00883 }
00884 };
00885
00886
00887 class DRIZZLED_API sys_var_session_bool :public sys_var_session
00888 {
00889 public:
00890 bool drizzle_system_variables::*offset;
00891 sys_var_session_bool(const char *name_arg, bool drizzle_system_variables::*offset_arg)
00892 :sys_var_session(name_arg), offset(offset_arg)
00893 { }
00894 sys_var_session_bool(const char *name_arg, bool drizzle_system_variables::*offset_arg,
00895 sys_after_update_func func)
00896 :sys_var_session(name_arg,func), offset(offset_arg)
00897 { }
00898 bool update(Session *session, set_var *var);
00899 void set_default(Session *session, sql_var_t type);
00900 SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
00901 unsigned char *value_ptr(Session *session, sql_var_t type,
00902 const LEX_STRING *base);
00903 bool check(Session *session, set_var *var);
00904 bool check_update_type(Item_result)
00905 { return 0; }
00906 };
00907
00908
00909 class DRIZZLED_API sys_var_session_enum :public sys_var_session
00910 {
00911 protected:
00912 uint32_t drizzle_system_variables::*offset;
00913 TYPELIB *enum_names;
00914 sys_check_func check_func;
00915 public:
00916 sys_var_session_enum(const char *name_arg,
00917 uint32_t drizzle_system_variables::*offset_arg, TYPELIB *typelib,
00918 sys_after_update_func func= NULL,
00919 sys_check_func check_f= NULL)
00920 :sys_var_session(name_arg, func), offset(offset_arg),
00921 enum_names(typelib), check_func(check_f)
00922 { }
00923 bool check(Session *session, set_var *var)
00924 {
00925 int ret= 0;
00926 if (check_func)
00927 ret= (*check_func)(session, var);
00928 return ret ? ret : check_enum(session, var, enum_names);
00929 }
00930 bool update(Session *session, set_var *var);
00931 void set_default(Session *session, sql_var_t type);
00932 SHOW_TYPE show_type() { return SHOW_CHAR; }
00933 unsigned char *value_ptr(Session *session, sql_var_t type,
00934 const LEX_STRING *base);
00935 bool check_update_type(Item_result)
00936 { return 0; }
00937 };
00938
00939
00940 class DRIZZLED_API sys_var_session_storage_engine :public sys_var_session
00941 {
00942 protected:
00943 plugin::StorageEngine *drizzle_system_variables::*offset;
00944 public:
00945 sys_var_session_storage_engine(const char *name_arg,
00946 plugin::StorageEngine *drizzle_system_variables::*offset_arg)
00947 :sys_var_session(name_arg), offset(offset_arg)
00948 { }
00949 SHOW_TYPE show_type() { return SHOW_CHAR; }
00950 bool check_update_type(Item_result type)
00951 {
00952 return type != STRING_RESULT;
00953 }
00954 void set_default(Session *session, sql_var_t type);
00955 bool update(Session *session, set_var *var);
00956 unsigned char *value_ptr(Session *session, sql_var_t type,
00957 const LEX_STRING *base);
00958 };
00959
00960 class DRIZZLED_API sys_var_session_bit :public sys_var_session
00961 {
00962 sys_check_func check_func;
00963 sys_update_func update_func;
00964 public:
00965 uint64_t bit_flag;
00966 bool reverse;
00967 sys_var_session_bit(const char *name_arg,
00968 sys_check_func c_func, sys_update_func u_func,
00969 uint64_t bit, bool reverse_arg=0)
00970 :sys_var_session(name_arg, NULL), check_func(c_func),
00971 update_func(u_func), bit_flag(bit), reverse(reverse_arg)
00972 { }
00973 bool check(Session *session, set_var *var);
00974 bool update(Session *session, set_var *var);
00975 bool check_update_type(Item_result)
00976 { return 0; }
00977 bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
00978 SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
00979 unsigned char *value_ptr(Session *session, sql_var_t type,
00980 const LEX_STRING *base);
00981 };
00982
00983
00984
00985 class DRIZZLED_API sys_var_timestamp :public sys_var
00986 {
00987 public:
00988 sys_var_timestamp(const char *name_arg)
00989 :sys_var(name_arg, NULL)
00990 { }
00991 bool update(Session *session, set_var *var);
00992 void set_default(Session *session, sql_var_t type);
00993 bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
00994 bool check_default(sql_var_t)
00995 { return 0; }
00996 SHOW_TYPE show_type(void) { return SHOW_LONG; }
00997 unsigned char *value_ptr(Session *session, sql_var_t type,
00998 const LEX_STRING *base);
00999 };
01000
01001
01002 class DRIZZLED_API sys_var_last_insert_id :public sys_var
01003 {
01004 public:
01005 sys_var_last_insert_id(const char *name_arg)
01006 :sys_var(name_arg, NULL)
01007 { }
01008 bool update(Session *session, set_var *var);
01009 bool check_type(sql_var_t type) { return type == OPT_GLOBAL; }
01010 SHOW_TYPE show_type() { return SHOW_LONGLONG; }
01011 unsigned char *value_ptr(Session *session, sql_var_t type,
01012 const LEX_STRING *base);
01013 };
01014
01015
01016 class DRIZZLED_API sys_var_collation :public sys_var_session
01017 {
01018 public:
01019 sys_var_collation(const char *name_arg)
01020 :sys_var_session(name_arg, NULL)
01021 { }
01022 SHOW_TYPE show_type() { return SHOW_CHAR; }
01023 bool check_update_type(Item_result type)
01024 {
01025 return ((type != STRING_RESULT) && (type != INT_RESULT));
01026 }
01027 bool check_default(sql_var_t) { return 0; }
01028 virtual void set_default(Session *session, sql_var_t type)= 0;
01029 };
01030
01031 class DRIZZLED_API sys_var_collation_sv :public sys_var_collation
01032 {
01033 const CHARSET_INFO *drizzle_system_variables::*offset;
01034 const CHARSET_INFO **global_default;
01035 public:
01036 sys_var_collation_sv(const char *name_arg,
01037 const CHARSET_INFO *drizzle_system_variables::*offset_arg,
01038 const CHARSET_INFO **global_default_arg)
01039 :sys_var_collation(name_arg),
01040 offset(offset_arg), global_default(global_default_arg)
01041 {
01042
01043 }
01044 bool update(Session *session, set_var *var);
01045 void set_default(Session *session, sql_var_t type);
01046 unsigned char *value_ptr(Session *session, sql_var_t type,
01047 const LEX_STRING *base);
01048 };
01049
01050
01051
01052 class DRIZZLED_API sys_var_readonly: public sys_var
01053 {
01054 public:
01055 sql_var_t var_type;
01056 SHOW_TYPE show_type_value;
01057 sys_value_ptr_func value_ptr_func;
01058 sys_var_readonly(const char *name_arg, sql_var_t type,
01059 SHOW_TYPE show_type_arg,
01060 sys_value_ptr_func value_ptr_func_arg)
01061 :sys_var(name_arg), var_type(type),
01062 show_type_value(show_type_arg), value_ptr_func(value_ptr_func_arg)
01063 { }
01064 bool update(Session *, set_var *)
01065 { return 1; }
01066 bool check_default(sql_var_t)
01067 { return 1; }
01068 bool check_type(sql_var_t type) { return type != var_type; }
01069 bool check_update_type(Item_result)
01070 { return 1; }
01071 unsigned char *value_ptr(Session *session, sql_var_t,
01072 const LEX_STRING *)
01073 {
01074 return (*value_ptr_func)(session);
01075 }
01076 SHOW_TYPE show_type(void) { return show_type_value; }
01077 bool is_readonly(void) const { return 1; }
01078 };
01079
01080 class DRIZZLED_API sys_var_microseconds :public sys_var_session
01081 {
01082 uint64_t drizzle_system_variables::*offset;
01083 public:
01084 sys_var_microseconds(const char *name_arg,
01085 uint64_t drizzle_system_variables::*offset_arg):
01086 sys_var_session(name_arg), offset(offset_arg)
01087 { }
01088 bool check(Session *, set_var *) {return 0;}
01089 bool update(Session *session, set_var *var);
01090 void set_default(Session *session, sql_var_t type);
01091 SHOW_TYPE show_type() { return SHOW_DOUBLE; }
01092 bool check_update_type(Item_result type)
01093 {
01094 return (type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT);
01095 }
01096 };
01097
01098 class DRIZZLED_API sys_var_session_lc_time_names :public sys_var_session
01099 {
01100 public:
01101 sys_var_session_lc_time_names(const char *name_arg)
01102 : sys_var_session(name_arg, NULL)
01103 {
01104
01105 }
01106 SHOW_TYPE show_type() { return SHOW_CHAR; }
01107 bool check_update_type(Item_result type)
01108 {
01109 return ((type != STRING_RESULT) && (type != INT_RESULT));
01110 }
01111 bool check_default(sql_var_t)
01112 { return 0; }
01113 bool update(Session *session, set_var *var);
01114 unsigned char *value_ptr(Session *session, sql_var_t type,
01115 const LEX_STRING *base);
01116 virtual void set_default(Session *session, sql_var_t type);
01117 };
01118
01119
01120
01121
01122 struct sys_var_with_base
01123 {
01124 sys_var *var;
01125 LEX_STRING base_name;
01126 };
01127
01128
01129
01130
01131
01132 drizzle_show_var* enumerate_sys_vars(Session *session);
01133 void add_sys_var_to_list(sys_var *var, struct option *long_options);
01134 void add_sys_var_to_list(sys_var *var);
01135 sys_var *find_sys_var(const std::string &name);
01136 extern sys_var_session_bit sys_autocommit;
01137 const CHARSET_INFO *get_old_charset_by_name(const char *old_name);
01138
01139 extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
01140
01141 }
01142