summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc67
1 files changed, 30 insertions, 37 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index ee3b8aa79fe..1d217cbe54c 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -523,7 +523,8 @@ void Query_cache_query::init_n_lock()
my_rwlock_init(&lock, NULL);
lock_writing();
DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
- ((byte*) this)-ALIGN_SIZE(sizeof(Query_cache_block))));
+ (long) (((byte*) this) -
+ ALIGN_SIZE(sizeof(Query_cache_block)))));
DBUG_VOID_RETURN;
}
@@ -532,7 +533,8 @@ void Query_cache_query::unlock_n_destroy()
{
DBUG_ENTER("Query_cache_query::unlock_n_destroy");
DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx",
- ((byte*)this)-ALIGN_SIZE(sizeof(Query_cache_block))));
+ (long) (((byte*) this) -
+ ALIGN_SIZE(sizeof(Query_cache_block)))));
/*
The following call is not needed on system where one can destroy an
active semaphore
@@ -698,6 +700,7 @@ void query_cache_abort(NET *net)
void query_cache_end_of_result(THD *thd)
{
+ Query_cache_block *query_block;
DBUG_ENTER("query_cache_end_of_result");
/* See the comment on double-check locking usage above. */
@@ -713,13 +716,9 @@ void query_cache_end_of_result(THD *thd)
if (unlikely(query_cache.query_cache_size == 0 ||
query_cache.flush_in_progress))
- {
- STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
- DBUG_VOID_RETURN;
- }
+ goto end;
- Query_cache_block *query_block= ((Query_cache_block*)
- thd->net.query_cache_query);
+ query_block= ((Query_cache_block*) thd->net.query_cache_query);
if (query_block)
{
DUMP(&query_cache);
@@ -738,27 +737,21 @@ void query_cache_end_of_result(THD *thd)
header->query()));
query_cache.wreck(__LINE__, "");
- STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
-
- DBUG_VOID_RETURN;
+ BLOCK_UNLOCK_WR(query_block);
+ goto end;
}
#endif
header->found_rows(current_thd->limit_found_rows);
header->result()->type= Query_cache_block::RESULT;
header->writer(0);
thd->net.query_cache_query= 0;
+ BLOCK_UNLOCK_WR(query_block);
DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1););
- STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
-
- BLOCK_UNLOCK_WR(query_block);
- }
- else
- {
- // Cache was flushed or resized and query was deleted => do nothing
- STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
}
+end:
+ STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
DBUG_VOID_RETURN;
}
@@ -875,8 +868,8 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
flags.character_set_client_num,
flags.character_set_results_num,
flags.collation_connection_num,
- flags.limit,
- (ulong)flags.time_zone,
+ (ulong) flags.limit,
+ (ulong) flags.time_zone,
flags.sql_mode,
flags.max_sort_length,
flags.group_concat_max_len));
@@ -1119,8 +1112,8 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
flags.character_set_client_num,
flags.character_set_results_num,
flags.collation_connection_num,
- flags.limit,
- (ulong)flags.time_zone,
+ (ulong) flags.limit,
+ (ulong) flags.time_zone,
flags.sql_mode,
flags.max_sort_length,
flags.group_concat_max_len));
@@ -1257,7 +1250,7 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
#ifndef EMBEDDED_LIBRARY
do
{
- DBUG_PRINT("qcache", ("Results (len %lu, used %lu, headers %lu)",
+ DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %u)",
result_block->length, result_block->used,
result_block->headers_len()+
ALIGN_SIZE(sizeof(Query_cache_result))));
@@ -2034,7 +2027,7 @@ Query_cache::append_result_data(Query_cache_block **current_block,
{
DBUG_ENTER("Query_cache::append_result_data");
DBUG_PRINT("qcache", ("append %lu bytes to 0x%lx query",
- data_len, query_block));
+ data_len, (long) query_block));
if (query_block->query()->add(data_len) > query_cache_limit)
{
@@ -3043,10 +3036,10 @@ Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex,
OPTION_TO_QUERY_CACHE))) &&
lex->safe_to_cache_query)
{
- DBUG_PRINT("qcache", ("options %lx %lx, type %u",
- OPTION_TO_QUERY_CACHE,
- lex->select_lex.options,
- (int) thd->variables.query_cache_type));
+ DBUG_PRINT("qcache", ("options: %lx %lx type: %u",
+ OPTION_TO_QUERY_CACHE,
+ (long) lex->select_lex.options,
+ (int) thd->variables.query_cache_type));
if (!(table_count= process_and_count_tables(tables_used, tables_type)))
DBUG_RETURN(0);
@@ -3062,10 +3055,10 @@ Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex,
}
DBUG_PRINT("qcache",
- ("not interesting query: %d or not cacheable, options %lx %lx, type %u",
+ ("not interesting query: %d or not cacheable, options %lx %lx type: %u",
(int) lex->sql_command,
OPTION_TO_QUERY_CACHE,
- lex->select_lex.options,
+ (long) lex->select_lex.options,
(int) thd->variables.query_cache_type));
DBUG_RETURN(0);
}
@@ -3656,7 +3649,8 @@ void Query_cache::queries_dump()
DBUG_PRINT("qcache", ("F:%u C:%u L:%lu T:'%s' (%u) '%s' '%s'",
flags.client_long_flag,
flags.character_set_client_num,
- (ulong)flags.limit, flags.time_zone->get_name(),
+ (ulong)flags.limit,
+ flags.time_zone->get_name()->ptr(),
len, str, strend(str)+1));
DBUG_PRINT("qcache", ("-b- 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx", (ulong) block,
(ulong) block->next, (ulong) block->prev,
@@ -3876,9 +3870,8 @@ my_bool Query_cache::check_integrity(bool locked)
break;
}
default:
- DBUG_PRINT("error",
- ("block 0x%lx have incorrect type %u",
- block, block->type));
+ DBUG_PRINT("error", ("block 0x%lx have incorrect type %u",
+ (long) block, block->type));
result = 1;
}
@@ -3976,8 +3969,8 @@ my_bool Query_cache::check_integrity(bool locked)
} while (block != bins[i].free_blocks);
if (count != bins[i].number)
{
- DBUG_PRINT("error", ("bin[%d].number is %d, but bin have %d blocks",
- bins[i].number, count));
+ DBUG_PRINT("error", ("bins[%d].number = %d, but bin have %d blocks",
+ i, bins[i].number, count));
result = 1;
}
}