Commit 28ebc2a7 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: sysvar, only one common check_update_type()

parent 051c1326
...@@ -132,7 +132,31 @@ class sys_var ...@@ -132,7 +132,31 @@ class sys_var
bool is_struct() { return option.var_type & GET_ASK_ADDR; } bool is_struct() { return option.var_type & GET_ASK_ADDR; }
bool is_written_to_binlog(enum_var_type type) bool is_written_to_binlog(enum_var_type type)
{ return type != OPT_GLOBAL && binlog_status == SESSION_VARIABLE_IN_BINLOG; } { return type != OPT_GLOBAL && binlog_status == SESSION_VARIABLE_IN_BINLOG; }
virtual bool check_update_type(Item_result type) = 0; bool check_update_type(Item_result type)
{
switch (option.var_type & GET_TYPE_MASK) {
case GET_INT:
case GET_UINT:
case GET_LONG:
case GET_ULONG:
case GET_LL:
case GET_ULL:
return type != INT_RESULT;
case GET_STR:
case GET_STR_ALLOC:
return type != STRING_RESULT;
case GET_ENUM:
case GET_BOOL:
case GET_SET:
case GET_FLAGSET:
return type != STRING_RESULT && type != INT_RESULT;
case GET_DOUBLE:
return type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT;
default:
return true;
}
}
bool check_type(enum_var_type type) bool check_type(enum_var_type type)
{ {
switch (scope()) switch (scope())
......
...@@ -273,7 +273,6 @@ class sys_var_pluginvar: public sys_var ...@@ -273,7 +273,6 @@ class sys_var_pluginvar: public sys_var
plugin_var(plugin_var_arg) plugin_var(plugin_var_arg)
{ plugin_var->name= name_arg; } { plugin_var->name= name_arg; }
sys_var_pluginvar *cast_pluginvar() { return this; } sys_var_pluginvar *cast_pluginvar() { return this; }
bool check_update_type(Item_result type);
SHOW_TYPE show_type(); SHOW_TYPE show_type();
uchar* real_value_ptr(THD *thd, enum_var_type type); uchar* real_value_ptr(THD *thd, enum_var_type type);
TYPELIB* plugin_var_typelib(void); TYPELIB* plugin_var_typelib(void);
...@@ -3251,27 +3250,6 @@ static SHOW_TYPE pluginvar_show_type(st_mysql_sys_var *plugin_var) ...@@ -3251,27 +3250,6 @@ static SHOW_TYPE pluginvar_show_type(st_mysql_sys_var *plugin_var)
} }
bool sys_var_pluginvar::check_update_type(Item_result type)
{
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) {
case PLUGIN_VAR_INT:
case PLUGIN_VAR_LONG:
case PLUGIN_VAR_LONGLONG:
return type != INT_RESULT;
case PLUGIN_VAR_STR:
return type != STRING_RESULT;
case PLUGIN_VAR_ENUM:
case PLUGIN_VAR_BOOL:
case PLUGIN_VAR_SET:
return type != STRING_RESULT && type != INT_RESULT;
case PLUGIN_VAR_DOUBLE:
return type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT;
default:
return true;
}
}
uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
{ {
DBUG_ASSERT(thd || (type == OPT_GLOBAL)); DBUG_ASSERT(thd || (type == OPT_GLOBAL));
......
...@@ -208,8 +208,6 @@ class Sys_var_integer: public sys_var ...@@ -208,8 +208,6 @@ class Sys_var_integer: public sys_var
global_var(T)= static_cast<T>(var->save_result.ulonglong_value); global_var(T)= static_cast<T>(var->save_result.ulonglong_value);
return false; return false;
} }
bool check_update_type(Item_result type)
{ return type != INT_RESULT; }
void session_save_default(THD *thd, set_var *var) void session_save_default(THD *thd, set_var *var)
{ var->save_result.ulonglong_value= (ulonglong)*(T*)global_value_ptr(thd, 0); } { var->save_result.ulonglong_value= (ulonglong)*(T*)global_value_ptr(thd, 0); }
void global_save_default(THD *thd, set_var *var) void global_save_default(THD *thd, set_var *var)
...@@ -284,8 +282,6 @@ class Sys_var_typelib: public sys_var ...@@ -284,8 +282,6 @@ class Sys_var_typelib: public sys_var
return false; return false;
} }
bool check_update_type(Item_result type)
{ return type != INT_RESULT && type != STRING_RESULT; }
}; };
/** /**
...@@ -499,8 +495,6 @@ class Sys_var_charptr: public sys_var ...@@ -499,8 +495,6 @@ class Sys_var_charptr: public sys_var
var->save_result.string_value.str= ptr; var->save_result.string_value.str= ptr;
var->save_result.string_value.length= ptr ? strlen(ptr) : 0; var->save_result.string_value.length= ptr ? strlen(ptr) : 0;
} }
bool check_update_type(Item_result type)
{ return type != STRING_RESULT; }
}; };
...@@ -536,8 +530,6 @@ class Sys_var_proxy_user: public sys_var ...@@ -536,8 +530,6 @@ class Sys_var_proxy_user: public sys_var
{ DBUG_ASSERT(FALSE); } { DBUG_ASSERT(FALSE); }
void global_save_default(THD *thd, set_var *var) void global_save_default(THD *thd, set_var *var)
{ DBUG_ASSERT(FALSE); } { DBUG_ASSERT(FALSE); }
bool check_update_type(Item_result type)
{ return true; }
protected: protected:
virtual uchar *session_value_ptr(THD *thd, LEX_STRING *base) virtual uchar *session_value_ptr(THD *thd, LEX_STRING *base)
{ {
...@@ -580,9 +572,6 @@ class Sys_var_rpl_filter: public sys_var ...@@ -580,9 +572,6 @@ class Sys_var_rpl_filter: public sys_var
{ {
return Sys_var_charptr::do_string_check(thd, var, charset(thd)); return Sys_var_charptr::do_string_check(thd, var, charset(thd));
} }
bool check_update_type(Item_result type)
{ return type != STRING_RESULT; }
void session_save_default(THD *thd, set_var *var) void session_save_default(THD *thd, set_var *var)
{ DBUG_ASSERT(FALSE); } { DBUG_ASSERT(FALSE); }
...@@ -665,7 +654,7 @@ class Sys_var_session_lexstring: public sys_var ...@@ -665,7 +654,7 @@ class Sys_var_session_lexstring: public sys_var
0, VARIABLE_NOT_IN_BINLOG, on_check_func, on_update_func, 0, VARIABLE_NOT_IN_BINLOG, on_check_func, on_update_func,
0),max_length(max_length_arg) 0),max_length(max_length_arg)
{ {
option.var_type= GET_NO_ARG; option.var_type= GET_STR;
SYSVAR_ASSERT(scope() == ONLY_SESSION) SYSVAR_ASSERT(scope() == ONLY_SESSION)
*const_cast<SHOW_TYPE*>(&show_val_type)= SHOW_LEX_STRING; *const_cast<SHOW_TYPE*>(&show_val_type)= SHOW_LEX_STRING;
} }
...@@ -725,14 +714,12 @@ class Sys_var_session_lexstring: public sys_var ...@@ -725,14 +714,12 @@ class Sys_var_session_lexstring: public sys_var
DBUG_ASSERT(FALSE); DBUG_ASSERT(FALSE);
return NULL; return NULL;
} }
bool check_update_type(Item_result type)
{ return type != STRING_RESULT; }
}; };
#ifndef DBUG_OFF #ifndef DBUG_OFF
/** /**
@@session.dbug and @@global.dbug variables. @@session.debug_dbug and @@global.debug_dbug variables.
@@dbug variable differs from other variables in one aspect: @@dbug variable differs from other variables in one aspect:
if its value is not assigned in the session, it "points" to the global if its value is not assigned in the session, it "points" to the global
...@@ -757,7 +744,7 @@ class Sys_var_dbug: public sys_var ...@@ -757,7 +744,7 @@ class Sys_var_dbug: public sys_var
getopt.arg_type, SHOW_CHAR, (intptr)def_val, getopt.arg_type, SHOW_CHAR, (intptr)def_val,
lock, binlog_status_arg, on_check_func, on_update_func, lock, binlog_status_arg, on_check_func, on_update_func,
substitute) substitute)
{ option.var_type= GET_NO_ARG; } { option.var_type= GET_STR; }
bool do_check(THD *thd, set_var *var) bool do_check(THD *thd, set_var *var)
{ {
char buff[STRING_BUFFER_USUAL_SIZE]; char buff[STRING_BUFFER_USUAL_SIZE];
...@@ -803,8 +790,6 @@ class Sys_var_dbug: public sys_var ...@@ -803,8 +790,6 @@ class Sys_var_dbug: public sys_var
DBUG_EXPLAIN_INITIAL(buf, sizeof(buf)); DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
return (uchar*) thd->strdup(buf); return (uchar*) thd->strdup(buf);
} }
bool check_update_type(Item_result type)
{ return type != STRING_RESULT; }
}; };
#endif #endif
...@@ -1031,10 +1016,6 @@ class Sys_var_double: public sys_var ...@@ -1031,10 +1016,6 @@ class Sys_var_double: public sys_var
global_var(double)= var->save_result.double_value; global_var(double)= var->save_result.double_value;
return false; return false;
} }
bool check_update_type(Item_result type)
{
return type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT;
}
void session_save_default(THD *thd, set_var *var) void session_save_default(THD *thd, set_var *var)
{ var->save_result.double_value= global_var(double); } { var->save_result.double_value= global_var(double); }
void global_save_default(THD *thd, set_var *var) void global_save_default(THD *thd, set_var *var)
...@@ -1408,8 +1389,6 @@ class Sys_var_plugin: public sys_var ...@@ -1408,8 +1389,6 @@ class Sys_var_plugin: public sys_var
var->save_result.plugin= my_plugin_lock(thd, plugin); var->save_result.plugin= my_plugin_lock(thd, plugin);
} }
} }
bool check_update_type(Item_result type)
{ return type != STRING_RESULT; }
uchar *session_value_ptr(THD *thd, LEX_STRING *base) uchar *session_value_ptr(THD *thd, LEX_STRING *base)
{ {
plugin_ref plugin= session_var(thd, plugin_ref); plugin_ref plugin= session_var(thd, plugin_ref);
...@@ -1445,7 +1424,7 @@ class Sys_var_debug_sync :public sys_var ...@@ -1445,7 +1424,7 @@ class Sys_var_debug_sync :public sys_var
substitute) substitute)
{ {
SYSVAR_ASSERT(scope() == ONLY_SESSION); SYSVAR_ASSERT(scope() == ONLY_SESSION);
option.var_type= GET_NO_ARG; option.var_type= GET_STR;
} }
bool do_check(THD *thd, set_var *var) bool do_check(THD *thd, set_var *var)
{ {
...@@ -1487,8 +1466,6 @@ class Sys_var_debug_sync :public sys_var ...@@ -1487,8 +1466,6 @@ class Sys_var_debug_sync :public sys_var
DBUG_ASSERT(FALSE); DBUG_ASSERT(FALSE);
return 0; return 0;
} }
bool check_update_type(Item_result type)
{ return type != STRING_RESULT; }
}; };
#endif /* defined(ENABLED_DEBUG_SYNC) */ #endif /* defined(ENABLED_DEBUG_SYNC) */
...@@ -1747,7 +1724,6 @@ class Sys_var_have: public sys_var ...@@ -1747,7 +1724,6 @@ class Sys_var_have: public sys_var
{ {
return (uchar*)show_comp_option_name[global_var(enum SHOW_COMP_OPTION)]; return (uchar*)show_comp_option_name[global_var(enum SHOW_COMP_OPTION)];
} }
bool check_update_type(Item_result type) { return false; }
}; };
/** /**
...@@ -1783,7 +1759,7 @@ class Sys_var_struct: public sys_var ...@@ -1783,7 +1759,7 @@ class Sys_var_struct: public sys_var
substitute), substitute),
name_offset(name_off) name_offset(name_off)
{ {
option.var_type= GET_STR; option.var_type= GET_ENUM; // because we accept INT and STRING here
/* /*
struct variables are special on the command line - often (e.g. for struct variables are special on the command line - often (e.g. for
charsets) the name cannot be immediately resolved, but only after all charsets) the name cannot be immediately resolved, but only after all
...@@ -1814,8 +1790,6 @@ class Sys_var_struct: public sys_var ...@@ -1814,8 +1790,6 @@ class Sys_var_struct: public sys_var
void **default_value= reinterpret_cast<void**>(option.def_value); void **default_value= reinterpret_cast<void**>(option.def_value);
var->save_result.ptr= *default_value; var->save_result.ptr= *default_value;
} }
bool check_update_type(Item_result type)
{ return type != INT_RESULT && type != STRING_RESULT; }
uchar *session_value_ptr(THD *thd, LEX_STRING *base) uchar *session_value_ptr(THD *thd, LEX_STRING *base)
{ {
uchar *ptr= session_var(thd, uchar*); uchar *ptr= session_var(thd, uchar*);
...@@ -1856,6 +1830,7 @@ class Sys_var_tz: public sys_var ...@@ -1856,6 +1830,7 @@ class Sys_var_tz: public sys_var
{ {
SYSVAR_ASSERT(getopt.id < 0); SYSVAR_ASSERT(getopt.id < 0);
SYSVAR_ASSERT(size == sizeof(Time_zone *)); SYSVAR_ASSERT(size == sizeof(Time_zone *));
option.var_type= GET_STR;
} }
bool do_check(THD *thd, set_var *var) bool do_check(THD *thd, set_var *var)
{ {
...@@ -1910,8 +1885,6 @@ class Sys_var_tz: public sys_var ...@@ -1910,8 +1885,6 @@ class Sys_var_tz: public sys_var
{ {
return (uchar *)(global_var(Time_zone*)->get_name()->ptr()); return (uchar *)(global_var(Time_zone*)->get_name()->ptr());
} }
bool check_update_type(Item_result type)
{ return type != STRING_RESULT; }
}; };
/** /**
...@@ -2092,10 +2065,6 @@ class Sys_var_gtid_current_pos: public sys_var ...@@ -2092,10 +2065,6 @@ class Sys_var_gtid_current_pos: public sys_var
DBUG_ASSERT(false); DBUG_ASSERT(false);
return true; return true;
} }
bool check_update_type(Item_result type) {
DBUG_ASSERT(false);
return false;
}
void session_save_default(THD *thd, set_var *var) void session_save_default(THD *thd, set_var *var)
{ {
DBUG_ASSERT(false); DBUG_ASSERT(false);
...@@ -2143,10 +2112,6 @@ class Sys_var_gtid_binlog_pos: public sys_var ...@@ -2143,10 +2112,6 @@ class Sys_var_gtid_binlog_pos: public sys_var
DBUG_ASSERT(false); DBUG_ASSERT(false);
return true; return true;
} }
bool check_update_type(Item_result type) {
DBUG_ASSERT(false);
return false;
}
void session_save_default(THD *thd, set_var *var) void session_save_default(THD *thd, set_var *var)
{ {
DBUG_ASSERT(false); DBUG_ASSERT(false);
...@@ -2186,7 +2151,6 @@ class Sys_var_gtid_slave_pos: public sys_var ...@@ -2186,7 +2151,6 @@ class Sys_var_gtid_slave_pos: public sys_var
return true; return true;
} }
bool global_update(THD *thd, set_var *var); bool global_update(THD *thd, set_var *var);
bool check_update_type(Item_result type) { return type != STRING_RESULT; }
void session_save_default(THD *thd, set_var *var) void session_save_default(THD *thd, set_var *var)
{ {
DBUG_ASSERT(false); DBUG_ASSERT(false);
...@@ -2227,7 +2191,6 @@ class Sys_var_gtid_binlog_state: public sys_var ...@@ -2227,7 +2191,6 @@ class Sys_var_gtid_binlog_state: public sys_var
return true; return true;
} }
bool global_update(THD *thd, set_var *var); bool global_update(THD *thd, set_var *var);
bool check_update_type(Item_result type) { return type != STRING_RESULT; }
void session_save_default(THD *thd, set_var *var) void session_save_default(THD *thd, set_var *var)
{ {
DBUG_ASSERT(false); DBUG_ASSERT(false);
...@@ -2275,10 +2238,6 @@ class Sys_var_last_gtid: public sys_var ...@@ -2275,10 +2238,6 @@ class Sys_var_last_gtid: public sys_var
DBUG_ASSERT(false); DBUG_ASSERT(false);
return true; return true;
} }
bool check_update_type(Item_result type) {
DBUG_ASSERT(false);
return false;
}
void session_save_default(THD *thd, set_var *var) void session_save_default(THD *thd, set_var *var)
{ {
DBUG_ASSERT(false); DBUG_ASSERT(false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment