Commit 2ec0f46b authored by Sergei Golubchik's avatar Sergei Golubchik

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
parent baca1a40
...@@ -6270,8 +6270,7 @@ ER_SLAVE_IGNORE_SERVER_IDS ...@@ -6270,8 +6270,7 @@ ER_SLAVE_IGNORE_SERVER_IDS
eng "The requested server id %d clashes with the slave startup option --replicate-same-server-id" eng "The requested server id %d clashes with the slave startup option --replicate-same-server-id"
ger "Die angeforderte Server-ID %d steht im Konflikt mit der Startoption --replicate-same-server-id für den Slave" ger "Die angeforderte Server-ID %d steht im Konflikt mit der Startoption --replicate-same-server-id für den Slave"
ER_QUERY_CACHE_DISABLED ER_QUERY_CACHE_DISABLED
eng "Query cache is disabled; restart the server with query_cache_type=1 to enable it" eng "Query cache is disabled; set query_cache_type to ON or DEMAND to enable it"
ger "Abfragen-Cache ist deaktiviert. Starten Sie den Server neu mit query_cache_type=1, um ihn zu aktivieren"
ER_SAME_NAME_PARTITION_FIELD ER_SAME_NAME_PARTITION_FIELD
eng "Duplicate partition field name '%-.192s'" eng "Duplicate partition field name '%-.192s'"
ger "Partitionsfeld '%-.192s' ist ein Duplikat" ger "Partitionsfeld '%-.192s' ist ein Duplikat"
......
...@@ -1292,6 +1292,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg) ...@@ -1292,6 +1292,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
if (global_system_variables.query_cache_type == 0) if (global_system_variables.query_cache_type == 0)
{ {
DBUG_ASSERT(query_cache_size_arg == 0);
if (query_cache_size_arg != 0) if (query_cache_size_arg != 0)
my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0)); my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0));
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -1819,6 +1819,17 @@ static Sys_var_enum Sys_thread_handling( ...@@ -1819,6 +1819,17 @@ static Sys_var_enum Sys_thread_handling(
thread_handling_names, DEFAULT(0)); thread_handling_names, DEFAULT(0));
#ifdef HAVE_QUERY_CACHE #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) 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); ulong new_cache_size= query_cache.resize(query_cache_size);
...@@ -1839,7 +1850,7 @@ static Sys_var_ulonglong Sys_query_cache_size( ...@@ -1839,7 +1850,7 @@ static Sys_var_ulonglong Sys_query_cache_size(
"The memory allocated to store results from old queries", "The memory allocated to store results from old queries",
GLOBAL_VAR(query_cache_size), CMD_LINE(REQUIRED_ARG), GLOBAL_VAR(query_cache_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(0), BLOCK_SIZE(1024), 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)); ON_UPDATE(fix_query_cache_size));
static Sys_var_ulong Sys_query_cache_limit( 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) ...@@ -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()) 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; return true;
} }
if (var->type != OPT_GLOBAL && if (var->type != OPT_GLOBAL &&
......
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