diff options
author | Sergei Golubchik <serg@mariadb.org> | 2014-08-27 20:32:32 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2014-10-10 22:27:41 +0200 |
commit | 28ebc2a72485c4b2956531010bd3ee247ae91df2 (patch) | |
tree | d89e1f85319a7b7610cee10ea850470879877dc2 /sql | |
parent | 051c132635555371c57b4dea3d1f9f1ad037342c (diff) | |
download | mariadb-git-28ebc2a72485c4b2956531010bd3ee247ae91df2.tar.gz |
cleanup: sysvar, only one common check_update_type()
Diffstat (limited to 'sql')
-rw-r--r-- | sql/set_var.h | 26 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 22 | ||||
-rw-r--r-- | sql/sys_vars.h | 53 |
3 files changed, 31 insertions, 70 deletions
diff --git a/sql/set_var.h b/sql/set_var.h index a8981937fce..6dcf478a341 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -132,7 +132,31 @@ public: bool is_struct() { return option.var_type & GET_ASK_ADDR; } bool is_written_to_binlog(enum_var_type type) { 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) { switch (scope()) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index e254d4330f7..979b6db7f79 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -273,7 +273,6 @@ public: plugin_var(plugin_var_arg) { plugin_var->name= name_arg; } sys_var_pluginvar *cast_pluginvar() { return this; } - bool check_update_type(Item_result type); SHOW_TYPE show_type(); uchar* real_value_ptr(THD *thd, enum_var_type type); TYPELIB* plugin_var_typelib(void); @@ -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) { DBUG_ASSERT(thd || (type == OPT_GLOBAL)); diff --git a/sql/sys_vars.h b/sql/sys_vars.h index 6cdb2ebf724..062f049befa 100644 --- a/sql/sys_vars.h +++ b/sql/sys_vars.h @@ -208,8 +208,6 @@ public: global_var(T)= static_cast<T>(var->save_result.ulonglong_value); return false; } - bool check_update_type(Item_result type) - { return type != INT_RESULT; } void session_save_default(THD *thd, set_var *var) { var->save_result.ulonglong_value= (ulonglong)*(T*)global_value_ptr(thd, 0); } void global_save_default(THD *thd, set_var *var) @@ -284,8 +282,6 @@ public: return false; } - bool check_update_type(Item_result type) - { return type != INT_RESULT && type != STRING_RESULT; } }; /** @@ -499,8 +495,6 @@ public: var->save_result.string_value.str= ptr; 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 @@ public: { DBUG_ASSERT(FALSE); } void global_save_default(THD *thd, set_var *var) { DBUG_ASSERT(FALSE); } - bool check_update_type(Item_result type) - { return true; } protected: virtual uchar *session_value_ptr(THD *thd, LEX_STRING *base) { @@ -580,9 +572,6 @@ public: { 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) { DBUG_ASSERT(FALSE); } @@ -665,7 +654,7 @@ public: 0, VARIABLE_NOT_IN_BINLOG, on_check_func, on_update_func, 0),max_length(max_length_arg) { - option.var_type= GET_NO_ARG; + option.var_type= GET_STR; SYSVAR_ASSERT(scope() == ONLY_SESSION) *const_cast<SHOW_TYPE*>(&show_val_type)= SHOW_LEX_STRING; } @@ -725,14 +714,12 @@ public: DBUG_ASSERT(FALSE); return NULL; } - bool check_update_type(Item_result type) - { return type != STRING_RESULT; } }; #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: if its value is not assigned in the session, it "points" to the global @@ -757,7 +744,7 @@ public: getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock, binlog_status_arg, on_check_func, on_update_func, substitute) - { option.var_type= GET_NO_ARG; } + { option.var_type= GET_STR; } bool do_check(THD *thd, set_var *var) { char buff[STRING_BUFFER_USUAL_SIZE]; @@ -803,8 +790,6 @@ public: DBUG_EXPLAIN_INITIAL(buf, sizeof(buf)); return (uchar*) thd->strdup(buf); } - bool check_update_type(Item_result type) - { return type != STRING_RESULT; } }; #endif @@ -1031,10 +1016,6 @@ public: global_var(double)= var->save_result.double_value; 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) { var->save_result.double_value= global_var(double); } void global_save_default(THD *thd, set_var *var) @@ -1408,8 +1389,6 @@ public: 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) { plugin_ref plugin= session_var(thd, plugin_ref); @@ -1445,7 +1424,7 @@ public: substitute) { SYSVAR_ASSERT(scope() == ONLY_SESSION); - option.var_type= GET_NO_ARG; + option.var_type= GET_STR; } bool do_check(THD *thd, set_var *var) { @@ -1487,8 +1466,6 @@ public: DBUG_ASSERT(FALSE); return 0; } - bool check_update_type(Item_result type) - { return type != STRING_RESULT; } }; #endif /* defined(ENABLED_DEBUG_SYNC) */ @@ -1747,7 +1724,6 @@ public: { 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 @@ public: substitute), 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 charsets) the name cannot be immediately resolved, but only after all @@ -1814,8 +1790,6 @@ public: void **default_value= reinterpret_cast<void**>(option.def_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 *ptr= session_var(thd, uchar*); @@ -1856,6 +1830,7 @@ public: { SYSVAR_ASSERT(getopt.id < 0); SYSVAR_ASSERT(size == sizeof(Time_zone *)); + option.var_type= GET_STR; } bool do_check(THD *thd, set_var *var) { @@ -1910,8 +1885,6 @@ public: { return (uchar *)(global_var(Time_zone*)->get_name()->ptr()); } - bool check_update_type(Item_result type) - { return type != STRING_RESULT; } }; /** @@ -2092,10 +2065,6 @@ public: DBUG_ASSERT(false); return true; } - bool check_update_type(Item_result type) { - DBUG_ASSERT(false); - return false; - } void session_save_default(THD *thd, set_var *var) { DBUG_ASSERT(false); @@ -2143,10 +2112,6 @@ public: DBUG_ASSERT(false); return true; } - bool check_update_type(Item_result type) { - DBUG_ASSERT(false); - return false; - } void session_save_default(THD *thd, set_var *var) { DBUG_ASSERT(false); @@ -2186,7 +2151,6 @@ public: return true; } 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) { DBUG_ASSERT(false); @@ -2227,7 +2191,6 @@ public: return true; } 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) { DBUG_ASSERT(false); @@ -2275,10 +2238,6 @@ public: DBUG_ASSERT(false); return true; } - bool check_update_type(Item_result type) { - DBUG_ASSERT(false); - return false; - } void session_save_default(THD *thd, set_var *var) { DBUG_ASSERT(false); |