From 2ec0f46b88bc5f1d565d65025b7a868c6943ab0c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 16 Jan 2012 21:06:23 +0100 Subject: query cache sysvar fixes sql/share/errmsg-utf8.txt: correct the error message, as query_cache_type variable is not read-ony anymore sql/sql_cache.cc: the caller should verify that query cache resize is possible, before trying it sql/sys_vars.cc: * test if qc resize is possible in the sysvar on_check() funntion, not in the on_update() function. * use the error message that better describes the problem --- sql/sys_vars.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'sql/sys_vars.cc') diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 7cdd5b3f65e..9da2393a0ad 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1819,6 +1819,17 @@ static Sys_var_enum Sys_thread_handling( thread_handling_names, DEFAULT(0)); #ifdef HAVE_QUERY_CACHE +static bool check_query_cache_size(sys_var *self, THD *thd, set_var *var) +{ + if (global_system_variables.query_cache_type == 0 && + var->value && var->value->val_int() != 0) + { + my_error(ER_QUERY_CACHE_DISABLED, MYF(0)); + return true; + } + + return false; +} static bool fix_query_cache_size(sys_var *self, THD *thd, enum_var_type type) { ulong new_cache_size= query_cache.resize(query_cache_size); @@ -1839,7 +1850,7 @@ static Sys_var_ulonglong Sys_query_cache_size( "The memory allocated to store results from old queries", GLOBAL_VAR(query_cache_size), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(0), BLOCK_SIZE(1024), - NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_query_cache_size), ON_UPDATE(fix_query_cache_size)); static Sys_var_ulong Sys_query_cache_limit( @@ -1867,7 +1878,7 @@ static bool check_query_cache_type(sys_var *self, THD *thd, set_var *var) { if (query_cache.is_disable_in_progress()) { - my_error(ER_QUERY_CACHE_DISABLED, MYF(0)); + my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0)); return true; } if (var->type != OPT_GLOBAL && -- cgit v1.2.1