diff --git a/sql/sql_class.h b/sql/sql_class.h index 1f80494c974..bd145bd4d28 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2731,10 +2731,13 @@ public: union { my_bool my_bool_value; + int int_value; + uint uint_value; long long_value; ulong ulong_value; ulonglong ulonglong_value; double double_value; + void *ptr_value; } sys_var_tmp; struct { diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 900167c1fab..30f840301ba 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3253,7 +3253,31 @@ sys_var_pluginvar::sys_var_pluginvar(sys_var_chain *chain, const char *name_arg, uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) { if (type == OPT_DEFAULT) - return (uchar*)&option.def_value; + { + switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) { + case PLUGIN_VAR_BOOL: + thd->sys_var_tmp.my_bool_value= option.def_value; + return (uchar*) &thd->sys_var_tmp.my_bool_value; + case PLUGIN_VAR_INT: + thd->sys_var_tmp.int_value= option.def_value; + return (uchar*) &thd->sys_var_tmp.int_value; + case PLUGIN_VAR_LONG: + case PLUGIN_VAR_ENUM: + thd->sys_var_tmp.long_value= option.def_value; + return (uchar*) &thd->sys_var_tmp.long_value; + case PLUGIN_VAR_LONGLONG: + case PLUGIN_VAR_SET: + return (uchar*) &option.def_value; + case PLUGIN_VAR_STR: + thd->sys_var_tmp.ptr_value= (void*) option.def_value; + return (uchar*) &thd->sys_var_tmp.ptr_value; + case PLUGIN_VAR_DOUBLE: + thd->sys_var_tmp.double_value= getopt_ulonglong2double(option.def_value); + return (uchar*) &thd->sys_var_tmp.double_value; + default: + DBUG_ASSERT(0); + } + } DBUG_ASSERT(thd || (type == OPT_GLOBAL)); if (plugin_var->flags & PLUGIN_VAR_THDLOCAL) diff --git a/sql/sys_vars.h b/sql/sys_vars.h index 6ec051dd13c..a19102be6ec 100644 --- a/sql/sys_vars.h +++ b/sql/sys_vars.h @@ -219,6 +219,7 @@ public: return scope() == SESSION ? (T*)(((uchar*)&max_system_variables) + offset) : 0; } + uchar *default_value_ptr(THD *thd) { return (uchar*) &option.def_value; } }; typedef Sys_var_integer Sys_var_int; @@ -229,6 +230,31 @@ typedef Sys_var_integer Sys_var_ulonglong; typedef Sys_var_integer Sys_var_long; +template<> uchar *Sys_var_int::default_value_ptr(THD *thd) +{ + thd->sys_var_tmp.int_value= option.def_value; + return (uchar*) &thd->sys_var_tmp.int_value; +} + +template<> uchar *Sys_var_uint::default_value_ptr(THD *thd) +{ + thd->sys_var_tmp.uint_value= option.def_value; + return (uchar*) &thd->sys_var_tmp.uint_value; +} + +template<> uchar *Sys_var_long::default_value_ptr(THD *thd) +{ + thd->sys_var_tmp.long_value= option.def_value; + return (uchar*) &thd->sys_var_tmp.long_value; +} + +template<> uchar *Sys_var_ulong::default_value_ptr(THD *thd) +{ + thd->sys_var_tmp.ulong_value= option.def_value; + return (uchar*) &thd->sys_var_tmp.ulong_value; +} + + /** Helper class for variables that take values from a TYPELIB */ @@ -386,6 +412,11 @@ public: { var->save_result.ulonglong_value= (ulonglong)*(my_bool *)global_value_ptr(thd, 0); } void global_save_default(THD *thd, set_var *var) { var->save_result.ulonglong_value= option.def_value; } + uchar *default_value_ptr(THD *thd) + { + thd->sys_var_tmp.my_bool_value= option.def_value; + return (uchar*) &thd->sys_var_tmp.my_bool_value; + } }; /**