diff options
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r-- | sql/set_var.cc | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc index 9b7be4afacc..4cae3827bf0 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -284,8 +284,8 @@ sys_var_thd_ulong sys_sort_buffer("sort_buffer_size", &SV::sortbuff_size); sys_var_thd_sql_mode sys_sql_mode("sql_mode", &SV::sql_mode); -sys_var_thd_enum sys_table_type("table_type", &SV::table_type, - &ha_table_typelib); +sys_var_thd_table_type sys_table_type("table_type", + &SV::table_type); sys_var_long_ptr sys_table_cache_size("table_cache", &table_cache_size); sys_var_long_ptr sys_thread_cache_size("thread_cache_size", @@ -2404,6 +2404,61 @@ int set_var_password::update(THD *thd) } /**************************************************************************** + Functions to handle table_type +****************************************************************************/ + +bool sys_var_thd_table_type::check(THD *thd, set_var *var) + /* Based upon sys_var::check_enum() */ +{ + char buff[80]; + const char *value; + String str(buff, sizeof(buff), &my_charset_latin1), *res; + + if (var->value->result_type() == STRING_RESULT) + { + if (!(res=var->value->val_str(&str)) || + !(var->save_result.ulong_value= + (ulong) ha_resolve_by_name(res->ptr(), res->length()))) + { + value= res ? res->c_ptr() : "NULL"; + goto err; + } + return 0; + } + +err: + my_error(ER_UNKNOWN_TABLE_ENGINE, MYF(0), value); + return 1; +} + +byte *sys_var_thd_table_type::value_ptr(THD *thd, enum_var_type type, + LEX_STRING *base) +{ + ulong val; + val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : + thd->variables.*offset); + const char *table_type= ha_get_table_type((enum db_type)val); + return (byte *)table_type; +} + +void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type) +{ + if (type == OPT_GLOBAL) + global_system_variables.*offset= (ulong) DB_TYPE_MYISAM; + else + thd->variables.*offset= (ulong) (global_system_variables.*offset); +} + +bool sys_var_thd_table_type::update(THD *thd, set_var *var) +{ + if (var->type == OPT_GLOBAL) + global_system_variables.*offset= var->save_result.ulong_value; + else + thd->variables.*offset= var->save_result.ulong_value; + return 0; +} + +/**************************************************************************** Functions to handle sql_mode ****************************************************************************/ |