Bug #56845 mysqldumpslow.pl broken for Windows slow query logs
Submitted: 17 Sep 2010 15:49
Reporter: Todd Farmer (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:5.1.50 OS:Microsoft Windows (XP)
Assigned to: CPU Architecture:Any
Tags: Contribution

[17 Sep 2010 15:49] Todd Farmer
Description:
It appears that the slow query log format for Windows builds differs from that of other builds, which makes mysqldumpslow.pl unusable for processing slow query logs originating from Windows platforms.  Specifically, mysqldumpslow.pl looks for a header entry line which starts with "\" and contains "Version:...".  With Windows deployments, this condition is not met:

bin\mysqld, Version: 5.1.50-enterprise-commercial-pro-log (MySQL Enterprise Server - Pro Edition (Commercial)). started with:
TCP Port: 3309, Named Pipe: (null)
...

The result is that parsing fails, and the following output is produced:

D:\Documents and Settings\todd>\mysql-enterprise-5.1.50-win32\scripts\mysqldumpslow.pl \mysql-enterprise-5.1.50-win32\data\slow.txt

Reading mysql slow query log from \mysql-enterprise-5.1.50-win32\data\slow.txt
Count: 1  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), 0users@0hosts
  bin\mysqld, Version: N.N.N-enterprise-commercial-pro-log (MySQL Enterprise Server - Pro Edition (Commercial)). started with:
  TCP Port: N, Named Pipe: (null)
  bin\mysqld.exe, Version: N.N.N-enterprise-commercial-pro-log (MySQL Enterprise Server - Pro Edition (Commercial)). started with:
  TCP Port: N, Named Pipe: (null)
  # Time: N  N:N:N
  # User@Host: root[root] @ localhost [N.N.N.N]
  # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N
  SET timestamp=N;
  select sleep(N)

How to repeat:
Attempt to process Windows-produced slow query logs with mysqldumpslow.pl.

Suggested fix:
Change line 76 from:

    my @chunks = split /^\/.*Version.*started with[\000-\377]*?Time.*Id.*Command.*Argument.*\n/m;

to:

    my @chunks = split /^\/?.*Version.*started with[\000-\377]*?Time.*Id.*Command.*Argument.*\n/m;
[17 Sep 2010 15:55] Todd Farmer
Patch, if it's needed

Attachment: diff.txt (text/plain), 680 bytes.