fixed BUG in query cahe statistic counting
mysql-test/r/grant_cache.result: right results in query cache mysql-test/t/grant_cache.test: proving new results sql/sql_cache.cc: fixed statistic calculating in query cahe
This commit is contained in:
parent
331ff0d8f5
commit
91bac76e03
@ -41,17 +41,53 @@ grant SELECT on mysqltest.* to mysqltest_1@localhost;
|
|||||||
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
|
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
|
||||||
grant SELECT on test.t1 to mysqltest_2@localhost;
|
grant SELECT on test.t1 to mysqltest_2@localhost;
|
||||||
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
|
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 6
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 0
|
||||||
|
show status like "Qcache_not_cached";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_not_cached 0
|
||||||
select "user1";
|
select "user1";
|
||||||
user1
|
user1
|
||||||
user1
|
user1
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 6
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 0
|
||||||
|
show status like "Qcache_not_cached";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_not_cached 1
|
||||||
select * from t1;
|
select * from t1;
|
||||||
a b c
|
a b c
|
||||||
1 1 1
|
1 1 1
|
||||||
2 2 2
|
2 2 2
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 6
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 1
|
||||||
|
show status like "Qcache_not_cached";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_not_cached 1
|
||||||
select a from t1 ;
|
select a from t1 ;
|
||||||
a
|
a
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 6
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 2
|
||||||
|
show status like "Qcache_not_cached";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_not_cached 1
|
||||||
select c from t1;
|
select c from t1;
|
||||||
c
|
c
|
||||||
1
|
1
|
||||||
@ -94,7 +130,7 @@ Variable_name Value
|
|||||||
Qcache_hits 7
|
Qcache_hits 7
|
||||||
show status like "Qcache_not_cached";
|
show status like "Qcache_not_cached";
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Qcache_not_cached 3
|
Qcache_not_cached 2
|
||||||
select "user3";
|
select "user3";
|
||||||
user3
|
user3
|
||||||
user3
|
user3
|
||||||
@ -118,7 +154,7 @@ Variable_name Value
|
|||||||
Qcache_hits 7
|
Qcache_hits 7
|
||||||
show status like "Qcache_not_cached";
|
show status like "Qcache_not_cached";
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Qcache_not_cached 8
|
Qcache_not_cached 7
|
||||||
select "user4";
|
select "user4";
|
||||||
user4
|
user4
|
||||||
user4
|
user4
|
||||||
@ -144,7 +180,7 @@ Variable_name Value
|
|||||||
Qcache_hits 8
|
Qcache_hits 8
|
||||||
show status like "Qcache_not_cached";
|
show status like "Qcache_not_cached";
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Qcache_not_cached 9
|
Qcache_not_cached 8
|
||||||
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||||
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||||
delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||||
|
@ -40,10 +40,22 @@ grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
|
|||||||
# The following queries should be fetched from cache
|
# The following queries should be fetched from cache
|
||||||
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,master.sock);
|
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,master.sock);
|
||||||
connection user1;
|
connection user1;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
show status like "Qcache_not_cached";
|
||||||
select "user1";
|
select "user1";
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
show status like "Qcache_not_cached";
|
||||||
select * from t1;
|
select * from t1;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
show status like "Qcache_not_cached";
|
||||||
# The pre and end space are intentional
|
# The pre and end space are intentional
|
||||||
select a from t1 ;
|
select a from t1 ;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
show status like "Qcache_not_cached";
|
||||||
select c from t1;
|
select c from t1;
|
||||||
show status like "Qcache_queries_in_cache";
|
show status like "Qcache_queries_in_cache";
|
||||||
show status like "Qcache_hits";
|
show status like "Qcache_hits";
|
||||||
|
@ -589,7 +589,6 @@ void query_cache_insert(NET *net, const char *packet, ulong length)
|
|||||||
if (!query_cache.append_result_data(&result, length, (gptr) packet,
|
if (!query_cache.append_result_data(&result, length, (gptr) packet,
|
||||||
query_block))
|
query_block))
|
||||||
{
|
{
|
||||||
query_cache.refused++;
|
|
||||||
DBUG_PRINT("warning", ("Can't append data"));
|
DBUG_PRINT("warning", ("Can't append data"));
|
||||||
header->result(result);
|
header->result(result);
|
||||||
DBUG_PRINT("qcache", ("free query 0x%lx", (ulong) query_block));
|
DBUG_PRINT("qcache", ("free query 0x%lx", (ulong) query_block));
|
||||||
@ -845,7 +844,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
statistic_increment(refused, &structure_guard_mutex);
|
if (thd->lex.sql_command == SQLCOM_SELECT)
|
||||||
|
statistic_increment(refused, &structure_guard_mutex);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
@ -981,7 +981,6 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
|
|||||||
DBUG_PRINT("qcache",
|
DBUG_PRINT("qcache",
|
||||||
("probably no SELECT access to %s.%s => return to normal processing",
|
("probably no SELECT access to %s.%s => return to normal processing",
|
||||||
table_list.db, table_list.alias));
|
table_list.db, table_list.alias));
|
||||||
refused++; // This is actually a hit
|
|
||||||
STRUCT_UNLOCK(&structure_guard_mutex);
|
STRUCT_UNLOCK(&structure_guard_mutex);
|
||||||
thd->safe_to_cache_query=0; // Don't try to cache this
|
thd->safe_to_cache_query=0; // Don't try to cache this
|
||||||
BLOCK_UNLOCK_RD(query_block);
|
BLOCK_UNLOCK_RD(query_block);
|
||||||
@ -1610,6 +1609,12 @@ void Query_cache::free_query(Query_cache_block *query_block)
|
|||||||
*/
|
*/
|
||||||
if (result_block != 0)
|
if (result_block != 0)
|
||||||
{
|
{
|
||||||
|
if (result_block->type != Query_cache_block::RESULT)
|
||||||
|
{
|
||||||
|
// removing unfinished query
|
||||||
|
refused++;
|
||||||
|
inserts--;
|
||||||
|
}
|
||||||
Query_cache_block *block = result_block;
|
Query_cache_block *block = result_block;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1618,6 +1623,12 @@ void Query_cache::free_query(Query_cache_block *query_block)
|
|||||||
free_memory_block(current);
|
free_memory_block(current);
|
||||||
} while (block != result_block);
|
} while (block != result_block);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// removing unfinished query
|
||||||
|
refused++;
|
||||||
|
inserts--;
|
||||||
|
}
|
||||||
|
|
||||||
query->unlock_n_destroy();
|
query->unlock_n_destroy();
|
||||||
free_memory_block(query_block);
|
free_memory_block(query_block);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user