Commit 60bd2133 authored by Michael Widenius's avatar Michael Widenius

Fixed compile failure when we don't use system zlib

Fixed crash when setting query_cache_type to 0.

client/Makefile.am:
  Added zlib include (needed by checksum.c)
sql/set_var.cc:
  Updated call to disable_query_cache()
sql/sql_cache.cc:
  Don't give warning if we start mysqld with --query_cache_type=0 --query_cache-size=0
  Fixed crash when setting query_cache_type to 0 (we shouldn't call query_cache.disable_query_cache() when there is no current_thd)
sql/sql_cache.h:
  Added THD to disable_query_cache()
parent 163d7acc
...@@ -24,6 +24,7 @@ endif ...@@ -24,6 +24,7 @@ endif
INCLUDES = -I$(top_builddir)/include \ INCLUDES = -I$(top_builddir)/include \
-I$(top_srcdir)/include \ -I$(top_srcdir)/include \
-I$(top_srcdir)/regex \ -I$(top_srcdir)/regex \
@ZLIB_INCLUDES@ \
$(openssl_includes) $(openssl_includes)
LIBS = @CLIENT_LIBS@ LIBS = @CLIENT_LIBS@
......
...@@ -1288,7 +1288,7 @@ static void fix_query_cache_type(THD *thd, enum_var_type type) ...@@ -1288,7 +1288,7 @@ static void fix_query_cache_type(THD *thd, enum_var_type type)
fix_query_cache_size(thd, type); fix_query_cache_size(thd, type);
} }
else if (global_system_variables.query_cache_type == 0) else if (global_system_variables.query_cache_type == 0)
query_cache.disable_query_cache(); query_cache.disable_query_cache(thd);
} }
} }
......
...@@ -1277,7 +1277,8 @@ ulong Query_cache::resize(ulong query_cache_size_arg) ...@@ -1277,7 +1277,8 @@ 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)
{ {
my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0)); if (query_cache_size_arg != 0)
my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -2318,7 +2319,7 @@ void Query_cache::destroy() ...@@ -2318,7 +2319,7 @@ void Query_cache::destroy()
} }
void Query_cache::disable_query_cache(void) void Query_cache::disable_query_cache(THD *thd)
{ {
m_cache_status= DISABLE_REQUEST; m_cache_status= DISABLE_REQUEST;
/* /*
...@@ -2326,7 +2327,7 @@ void Query_cache::disable_query_cache(void) ...@@ -2326,7 +2327,7 @@ void Query_cache::disable_query_cache(void)
try_lock(TRY) will exit immediately if there is lock. try_lock(TRY) will exit immediately if there is lock.
unlock() should free block. unlock() should free block.
*/ */
if (m_requests_in_progress == 0 && !try_lock(current_thd, TRY)) if (m_requests_in_progress == 0 && !try_lock(thd, TRY))
unlock(); unlock();
} }
...@@ -2346,14 +2347,16 @@ void Query_cache::init() ...@@ -2346,14 +2347,16 @@ void Query_cache::init()
initialized = 1; initialized = 1;
query_state_map= default_charset_info->state_map; query_state_map= default_charset_info->state_map;
/* /*
If we explicitly turn off query cache from the command line query cache will If we explicitly turn off query cache from the command line query
be disabled for the reminder of the server life time. This is because we cache will be disabled for the reminder of the server life
want to avoid locking the QC specific mutex if query cache isn't going to time. This is because we want to avoid locking the QC specific
be used. mutex if query cache isn't going to be used.
*/ */
if (global_system_variables.query_cache_type == 0) if (global_system_variables.query_cache_type == 0)
query_cache.disable_query_cache(); {
free_cache();
m_cache_status= DISABLED;
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -499,7 +499,7 @@ class Query_cache ...@@ -499,7 +499,7 @@ class Query_cache
void lock_and_suspend(void); void lock_and_suspend(void);
void unlock(void); void unlock(void);
void disable_query_cache(void); void disable_query_cache(THD *thd);
}; };
extern Query_cache query_cache; extern Query_cache query_cache;
......
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