diff options
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r-- | sql/set_var.cc | 91 |
1 files changed, 78 insertions, 13 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc index 49e0be3f0db..53205c48a1d 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -128,9 +128,11 @@ static void fix_net_read_timeout(THD *thd, enum_var_type type); static void fix_net_write_timeout(THD *thd, enum_var_type type); static void fix_net_retry_count(THD *thd, enum_var_type type); static void fix_max_join_size(THD *thd, enum_var_type type); -static void fix_query_cache_size(THD *thd, enum_var_type type); #ifdef HAVE_QUERY_CACHE +static void fix_query_cache_size(THD *thd, enum_var_type type); static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type); +static int check_query_cache_type(THD *thd, set_var *var); +static void fix_query_cache_type(THD *thd, enum_var_type type); #endif static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type); @@ -565,9 +567,6 @@ static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment", &SV::div_precincrement); static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank", &rpl_recovery_rank); -static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size", - &query_cache_size, - fix_query_cache_size); static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size", &SV::range_alloc_block_size); @@ -635,14 +634,20 @@ sys_var_enum_const sys_thread_handling(&vars, "thread_handling", &thread_handling_typelib); #ifdef HAVE_QUERY_CACHE +static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size", + &query_cache_size, + fix_query_cache_size); static sys_var_long_ptr sys_query_cache_limit(&vars, "query_cache_limit", - &query_cache.query_cache_limit); -static sys_var_long_ptr sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit", - &query_cache_min_res_unit, - fix_query_cache_min_res_unit); + &query_cache.query_cache_limit); +static sys_var_long_ptr + sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit", + &query_cache_min_res_unit, + fix_query_cache_min_res_unit); static sys_var_thd_enum sys_query_cache_type(&vars, "query_cache_type", &SV::query_cache_type, - &query_cache_type_typelib); + &query_cache_type_typelib, + fix_query_cache_type, + check_query_cache_type); static sys_var_thd_bool sys_query_cache_wlock_invalidate(&vars, "query_cache_wlock_invalidate", &SV::query_cache_wlock_invalidate); @@ -938,6 +943,8 @@ static sys_var_const_str_ptr sys_log_basename(&vars, "log_basename", #ifndef EMBEDDED_LIBRARY static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host); static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user); +static sys_var_bool_ptr sys_query_cache_strip_comments(&vars, "query_cache_strip_comments", + &opt_query_cache_strip_comments); static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password); static uchar *slave_get_report_port(THD *thd) @@ -1227,10 +1234,9 @@ static void fix_net_retry_count(THD *thd __attribute__((unused)), {} #endif /* HAVE_REPLICATION */ - +#ifdef HAVE_QUERY_CACHE static void fix_query_cache_size(THD *thd, enum_var_type type) { -#ifdef HAVE_QUERY_CACHE ulong new_cache_size= query_cache.resize(query_cache_size); /* @@ -1244,11 +1250,60 @@ static void fix_query_cache_size(THD *thd, enum_var_type type) query_cache_size, new_cache_size); query_cache_size= new_cache_size; -#endif } -#ifdef HAVE_QUERY_CACHE +/** + Trigger before query_cache_type variable is updated. + @param thd Thread handler + @param var Pointer to the new variable status + + @return Status code + @retval TRUE Failure + @retval FALSE Success +*/ + +static int check_query_cache_type(THD *thd, set_var *var) +{ + /* + Don't allow changes of the query_cache_type if the query cache + is disabled. + */ + if (query_cache.is_disable_in_progress()) + { + my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0)); + return TRUE; + } + if (var->type != OPT_GLOBAL && + global_system_variables.query_cache_type == 0 && + var->value->val_int() != 0) + { + my_error(ER_QUERY_CACHE_IS_GLOBALY_DISABLED, MYF(0)); + return TRUE; + } + + return FALSE; +} + + +static void fix_query_cache_type(THD *thd, enum_var_type type) +{ + if (type == OPT_GLOBAL) + { + if (global_system_variables.query_cache_type != 0 && + query_cache.is_disabled()) + { + /* if disabling in progress variable will not be set */ + DBUG_ASSERT(!query_cache.is_disable_in_progress()); + /* Enable query cache because it was disabled */ + fix_query_cache_size(thd, type); + } + else if (global_system_variables.query_cache_type == 0) + query_cache.disable_query_cache(); + } +} + + static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type) { query_cache_min_res_unit= @@ -3672,6 +3727,16 @@ bool not_all_support_one_shot(List<set_var_base> *var_list) Functions to handle SET mysql_internal_variable=const_expr *****************************************************************************/ +/** + Verify that the supplied value is correct. + + @param thd Thread handler + + @return status code + @retval -1 Failure + @retval 0 Success +*/ + int set_var::check(THD *thd) { if (var->is_readonly()) |