Bug #69023 "Questions" output in COM_STATISTICS wraps at 2^32
Submitted: 21 Apr 2013 12:39
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version:5.6.12 OS:Windows
Assigned to: CPU Architecture:Any

[21 Apr 2013 12:39] Shane Bester
Description:
The "Questions" value in the statistics output (\s in client) rolls over at 2^32:

--------------
Uptime:        3 hours 11 min 53 sec

Threads: 8  Questions: 4293710732  Slow queries: 0  Opens: 73369  Flush tables: 1  Open tables: 88  Queries per second avg: 372944.561
--------------

seconds later:

--------------
Uptime:        3 hours 11 min 54 sec

Threads: 8  Questions: 3180834  Slow queries: 0  Opens: 73369  Flush tables: 1  Open tables: 88  Queries per second avg: 373297.562

How to repeat:
Read the code in COM_STATISTICS case in sql_parse.cc

length= my_snprintf(buff, buff_len - 1,
      "Uptime: %lu  Threads: %d  Questions: %lu  "

thd->query_id is 64-bit, but %lu is incorrect specifier for that.

Testcase :)

drop procedure if exists p1;
delimiter $
create procedure p1() 
begin
 declare id bigint default 0;
 repeat 
   set id:=id+1;
   if id % 1000000 = 0 then select id; end if;
 until 1=2 end repeat;
end $

delimiter ;
call p1();

Monitor "\s" output in mysql client as it runs over.

Suggested fix:
print 64-bit values correctly.