Commit ad84fb5c authored by Annamalai Gurusami's avatar Annamalai Gurusami

Bug #13117023: Innodb increments handler_read_key when it should not

The counter handler_read_key (SSV::ha_read_key_count) is incremented 
incorrectly.

The mysql server maintains a per thread system_status_var (SSV)
object.  This object contains among other things the counter
SSV::ha_read_key_count. The purpose of this counter is to measure the
number of requests to read a row based on a key (or the number of
index lookups).

This counter was wrongly incremented in the
ha_innobase::innobase_get_index(). The fix removes
this increment statement (for both innodb and innodb_plugin).

The various callers of the innobase_get_index() was checked to
determine if anybody must increment this counter (if they first call
innobase_get_index() and then perform an index lookup).  It was found
that no caller of innobase_get_index() needs to worry about the
SSV::ha_read_key_count counter.
parent 3d58fd69
......@@ -2365,3 +2365,8 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
set storage_engine=MyISAM;
Variable_name Value
Handler_read_key 0
f1
Variable_name Value
Handler_read_key 1
......@@ -1389,6 +1389,17 @@ eval set storage_engine=$default;
-- disable_query_log
SET GLOBAL innodb_thread_concurrency = @innodb_thread_concurrency_orig;
#
# Test fix for bug 13117023. InnoDB increments HA_READ_KEY_COUNT (aka
# HANDLER_READ_KEY) when it should not.
#
create table t1 (f1 integer primary key) engine=innodb;
flush status;
show status like "handler_read_key";
select f1 from t1;
show status like "handler_read_key";
drop table t1;
#######################################################################
# #
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
......
......@@ -3257,3 +3257,14 @@ Handler_update 1
Variable_name Value
Handler_delete 1
DROP TABLE bug58912;
create table t1 (f1 integer primary key) engine=innodb;
flush status;
show status like "handler_read_key";
Variable_name Value
Handler_read_key 0
select f1 from t1;
f1
show status like "handler_read_key";
Variable_name Value
Handler_read_key 1
drop table t1;
......@@ -2571,6 +2571,17 @@ SET GLOBAL innodb_thread_concurrency = @innodb_thread_concurrency_orig;
# Clean up after the Bug#55284/Bug#58912 test case.
DROP TABLE bug58912;
#
# Test fix for bug 13117023. InnoDB increments HA_READ_KEY_COUNT (aka
# HANDLER_READ_KEY) when it should not.
#
create table t1 (f1 integer primary key) engine=innodb;
flush status;
show status like "handler_read_key";
select f1 from t1;
show status like "handler_read_key";
drop table t1;
#######################################################################
# #
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
......
......@@ -4802,7 +4802,6 @@ ha_innobase::innobase_get_index(
dict_index_t* index = 0;
DBUG_ENTER("innobase_get_index");
ha_statistic_increment(&SSV::ha_read_key_count);
ut_ad(user_thd == ha_thd());
ut_a(prebuilt->trx == thd_to_trx(user_thd));
......
2011-12-13 The InnoDB Team
* handler/ha_innodb.cc, innodb.test, innodb.result:
Fix Bug#13117023: InnoDB was incrementing the handler_read_key,
also the SSV::ha_read_key_count, at the wrong place.
2011-12-10 The InnoDB Team
* include/page0page.h, page/page0page.c:
......
......@@ -5520,7 +5520,6 @@ ha_innobase::innobase_get_index(
dict_index_t* index = 0;
DBUG_ENTER("innobase_get_index");
ha_statistic_increment(&SSV::ha_read_key_count);
if (keynr != MAX_KEY && table->s->keys > 0) {
key = table->key_info + keynr;
......
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