summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2015-02-05 13:54:55 +0400
committerSergey Vojtovich <svoj@mariadb.org>2015-02-05 13:54:55 +0400
commit451e9b7a50ccbced8beca81e53ae5427fac5e594 (patch)
tree6c880952219324395ac0ede7af0cc2031c55cdfe
parentb08126aad1a33ec0ad3491b061e888908d1edfe5 (diff)
downloadmariadb-git-451e9b7a50ccbced8beca81e53ae5427fac5e594.tar.gz
MDEV-7499 - System variables have broken default values on big endian
INFORMATION_SCHEMA.SYSTEM_VARIABLES.DEFAULT_VALUE had broken values on big endian. Default value is internally stored as longlong, while I_S references it's pointer (longlong *) according to variable type (e.g. int, my_bool, etc). This works well on little endian, but on big endian we always get 0 for such variables.
-rw-r--r--sql/sql_class.h3
-rw-r--r--sql/sql_plugin.cc26
-rw-r--r--sql/sys_vars.h31
3 files changed, 59 insertions, 1 deletions
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<int, GET_INT, SHOW_SINT> Sys_var_int;
@@ -229,6 +230,31 @@ typedef Sys_var_integer<ulonglong, GET_ULL, SHOW_ULONGLONG> Sys_var_ulonglong;
typedef Sys_var_integer<long, GET_LONG, SHOW_SLONG> 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;
+ }
};
/**