Commit 41d89b7d authored by Peter Shchuchkin's avatar Peter Shchuchkin Committed by Sergey Vojtovich

Added HITS column to QUERY_CACHE_INFO table

Updated qc_info tests, added new test that checks HITS is incremented.
parent cf3a74eb
......@@ -26,15 +26,29 @@ set time_zone=@new_time_zone,default_week_format=4,character_set_client='binary'
select * from t1;
set time_zone= @time_zone, default_week_format= @default_week_format, character_set_client= @character_set_client,character_set_results= @character_set_results, sql_mode= @sql_mode, div_precision_increment= @div_precision_increment, lc_time_names= @lc_time_names, autocommit= @autocommit, group_concat_max_len= @group_concat_max_len, max_sort_length= @max_sort_length;
select * from information_schema.query_cache_info;
STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED LIMIT MAX_SORT_LENGTH GROUP_CONCAT_MAX_LENGTH CHARACTER_SET_CLIENT CHARACTER_SET_RESULT COLLATION TIMEZONE DEFAULT_WEEK_FORMAT DIV_PRECISION_INCREMENT SQL_MODE LC_TIME_NAMES CLIENT_LONG_FLAG CLIENT_PROTOCOL_41 PROTOCOL_TYPE MORE_RESULTS_EXISTS IN_TRANS AUTOCOMMIT PACKET_NUMBER
test select * from t1 1 512 # -1 1011 513 binary utf32 utf32_bin Europe/Moscow 4 7 STRICT_ALL_TABLES ar_SD 1 1 # 0 0 0 #
test select * from t1 1 512 # -1 1024 1048576 latin1 latin1 latin1_swedish_ci SYSTEM 0 4 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION en_US 1 1 # 0 0 1 #
STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED LIMIT MAX_SORT_LENGTH GROUP_CONCAT_MAX_LENGTH CHARACTER_SET_CLIENT CHARACTER_SET_RESULT COLLATION TIMEZONE DEFAULT_WEEK_FORMAT DIV_PRECISION_INCREMENT SQL_MODE LC_TIME_NAMES CLIENT_LONG_FLAG CLIENT_PROTOCOL_41 PROTOCOL_TYPE MORE_RESULTS_EXISTS IN_TRANS AUTOCOMMIT PACKET_NUMBER HITS
test select * from t1 1 512 # -1 1011 513 binary utf32 utf32_bin Europe/Moscow 4 7 STRICT_ALL_TABLES ar_SD 1 1 # 0 0 0 # 0
test select * from t1 1 512 # -1 1024 1048576 latin1 latin1 latin1_swedish_ci SYSTEM 0 4 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION en_US 1 1 # 0 0 1 # 0
reset query cache;
select * from t1;
a
1
2
3
select * from t1;
a
1
2
3
select hits, statement_text from information_schema.query_cache_info;
hits statement_text
1 select * from t1
drop table t1;
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info;
statement_schema statement_text result_blocks_count result_blocks_size
set global query_cache_size = 0;
select * from information_schema.query_cache_info;
STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED LIMIT MAX_SORT_LENGTH GROUP_CONCAT_MAX_LENGTH CHARACTER_SET_CLIENT CHARACTER_SET_RESULT COLLATION TIMEZONE DEFAULT_WEEK_FORMAT DIV_PRECISION_INCREMENT SQL_MODE LC_TIME_NAMES CLIENT_LONG_FLAG CLIENT_PROTOCOL_41 PROTOCOL_TYPE MORE_RESULTS_EXISTS IN_TRANS AUTOCOMMIT PACKET_NUMBER
STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED LIMIT MAX_SORT_LENGTH GROUP_CONCAT_MAX_LENGTH CHARACTER_SET_CLIENT CHARACTER_SET_RESULT COLLATION TIMEZONE DEFAULT_WEEK_FORMAT DIV_PRECISION_INCREMENT SQL_MODE LC_TIME_NAMES CLIENT_LONG_FLAG CLIENT_PROTOCOL_41 PROTOCOL_TYPE MORE_RESULTS_EXISTS IN_TRANS AUTOCOMMIT PACKET_NUMBER HITS
set global query_cache_size= default;
set global query_cache_type=default;
show query_cache_info;
......
......@@ -26,9 +26,9 @@ set time_zone=@new_time_zone,default_week_format=4,character_set_client='binary'
select * from t1;
set time_zone= @time_zone, default_week_format= @default_week_format, character_set_client= @character_set_client,character_set_results= @character_set_results, sql_mode= @sql_mode, div_precision_increment= @div_precision_increment, lc_time_names= @lc_time_names, autocommit= @autocommit, group_concat_max_len= @group_concat_max_len, max_sort_length= @max_sort_length;
select * from information_schema.query_cache_info;
STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED LIMIT MAX_SORT_LENGTH GROUP_CONCAT_MAX_LENGTH CHARACTER_SET_CLIENT CHARACTER_SET_RESULT COLLATION TIMEZONE DEFAULT_WEEK_FORMAT DIV_PRECISION_INCREMENT SQL_MODE LC_TIME_NAMES CLIENT_LONG_FLAG CLIENT_PROTOCOL_41 PROTOCOL_TYPE MORE_RESULTS_EXISTS IN_TRANS AUTOCOMMIT PACKET_NUMBER
test select * from t1 1 512 # -1 1011 513 binary utf32 utf32_bin Europe/Moscow 4 7 STRICT_ALL_TABLES ar_SD 1 1 # 0 0 0 #
test select * from t1 1 512 # -1 1024 1048576 latin1 latin1 latin1_swedish_ci SYSTEM 0 4 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION en_US 1 1 # 0 0 1 #
STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED LIMIT MAX_SORT_LENGTH GROUP_CONCAT_MAX_LENGTH CHARACTER_SET_CLIENT CHARACTER_SET_RESULT COLLATION TIMEZONE DEFAULT_WEEK_FORMAT DIV_PRECISION_INCREMENT SQL_MODE LC_TIME_NAMES CLIENT_LONG_FLAG CLIENT_PROTOCOL_41 PROTOCOL_TYPE MORE_RESULTS_EXISTS IN_TRANS AUTOCOMMIT PACKET_NUMBER HITS
test select * from t1 1 512 # -1 1011 513 binary utf32 utf32_bin Europe/Moscow 4 7 STRICT_ALL_TABLES ar_SD 1 1 # 0 0 0 # 0
test select * from t1 1 512 # -1 1024 1048576 latin1 latin1 latin1_swedish_ci SYSTEM 0 4 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION en_US 1 1 # 0 0 1 # 0
create user mysqltest;
connect conn1,localhost,mysqltest,,;
connection conn1;
......
--source qc_info_init.inc
# test that hits are correctly incremented
reset query cache;
select * from t1;
select * from t1;
select hits, statement_text from information_schema.query_cache_info;
drop table t1;
# the query was invalidated
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info;
......
......@@ -77,6 +77,7 @@ bool schema_table_store_record(THD *thd, TABLE *table);
#define COLUMN_IN_TRANS 20
#define COLUMN_AUTOCOMMIT 21
#define COLUMN_PKT_NR 22
#define COLUMN_HITS 23
/* ST_FIELD_INFO is defined in table.h */
static ST_FIELD_INFO qc_info_fields[]=
......@@ -104,6 +105,7 @@ static ST_FIELD_INFO qc_info_fields[]=
{"IN_TRANS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_TINY, 0, 0, 0, 0},
{"AUTOCOMMIT", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_TINY, 0, 0, 0, 0},
{"PACKET_NUMBER", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_TINY, 0, 0, 0, 0},
{"HITS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
};
......@@ -216,6 +218,7 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
table->field[COLUMN_IN_TRANS]->store(flags.in_trans, 0);
table->field[COLUMN_AUTOCOMMIT]->store(flags.autocommit, 0);
table->field[COLUMN_PKT_NR]->store(flags.pkt_nr, 0);
table->field[COLUMN_HITS]->store(query_cache_query->hits(), 0);
/* The database against which the statement is executed is part of the
query cache query key
......
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