Bug #30285 Inconsistent statistic counter values when using HEAP tables
Submitted: 7 Aug 2007 20:51 Modified: 7 Aug 2007 22:13
Reporter: Sergey Petrunya Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any

[7 Aug 2007 20:51] Sergey Petrunya
Description:
Use of HEAP tables (temporary or not) produces inconsistent values of the Handler_XXX counters.

How to repeat:
Run this:

mysql> show tables;
+-------------------+
| Tables_in_pprune2 |
+-------------------+
| t1                | 
| t20               | 
+-------------------+
2 rows in set (3.13 sec)

mysql> show status like 'Handler%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| Handler_commit             | 0     | 
| Handler_delete             | 0     | 
| Handler_discover           | 0     | 
| Handler_prepare            | 0     | 
| Handler_read_first         | 0     | 
| Handler_read_key           | 0     | 
| Handler_read_next          | 0     | 
| Handler_read_prev          | 0     | 
| Handler_read_rnd           | 0     | 
| Handler_read_rnd_next      | 3     | 
| Handler_rollback           | 0     | 
| Handler_savepoint          | 0     | 
| Handler_savepoint_rollback | 0     | 
| Handler_update             | 0     | 
| Handler_write              | 2     | 
+----------------------------+-------+
15 rows in set (0.01 sec)

This piece:

| Handler_read_rnd           | 0     | 
| Handler_read_rnd_next      | 3     | 

shows that there were 3 handler->rnd_next() calls while there were 0 rnd_init(), which is not possible (table scan must be initialized before we can make reads).
 

Suggested fix:
Go through ha_heap and make sure it increments statistics counters properly.
[7 Aug 2007 22:13] Sergey Petrunya
Not a bug, because Handler_read_rnd means handler->rnd_pos(), not handler->rnd_init().