#At file:///home/thek/Development/cpp/mysqlbzr/mysql-5.1-bugteam/
2768 Kristofer Pettersson 2008-10-09
Bug#38551 query cache can still consume [very little] cpu time even when it is off.
When the query cache size is zero, all query cache functionallity should be
skipped.
By checking query_cache_size before attempting to invalidate a table or
db we avoid grabbing the query cache mutex. If the rare cases the query cache
size would change so we get a false read the cache has either been cleared or
modified:
sql/sql_cache.cc
per-file messages:
sql/sql_cache.cc
* Added checks to see if the query cache is enabled before attempting to
take the query cache mutex.
=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc 2008-09-30 13:47:01 +0000
+++ b/sql/sql_cache.cc 2008-10-09 11:10:30 +0000
@@ -327,6 +327,7 @@ TODO list:
*/
#include "mysql_priv.h"
+
#ifdef HAVE_QUERY_CACHE
#include <m_ctype.h>
#include <my_dir.h>
@@ -1638,6 +1639,9 @@ void Query_cache::invalidate(char *db)
bool restart= FALSE;
DBUG_ENTER("Query_cache::invalidate (db)");
+ if (query_cache_size == 0)
+ DBUG_VOID_RETURN;
+
STRUCT_LOCK(&structure_guard_mutex);
bool interrupt;
wait_while_table_flush_is_in_progress(&interrupt);
@@ -2528,6 +2532,9 @@ void Query_cache::invalidate_table(THD *
void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length)
{
+ if (query_cache_size == 0)
+ return;
+
bool interrupt;
STRUCT_LOCK(&structure_guard_mutex);
wait_while_table_flush_is_in_progress(&interrupt);