Bug #69479 mysql.utilities.common.parser.SlowQueryLog fails if host contains dots or dashes
Submitted: 14 Jun 2013 19:13 Modified: 21 Jun 2013 1:41
Reporter: Ilya Kazakevich Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Utilities Severity:S3 (Non-critical)
Version:gpl-5.2.47-win32 OS:Any
Assigned to: CPU Architecture:Any
Tags: python

[14 Jun 2013 19:13] Ilya Kazakevich
Description:
My slow query log contains records

# User@Host: root[root] @ foo.example.com [10.10.10.1]
# User@Host: a-b[a-b] @ my-host [10.10.10.1]

Trying to parse with mysql.utilities.common.parser.SlowQueryLog leads to error

with   File "C:\Python27\lib\mysql\utilities\common\parser.py", line 546, in _parse_line
    line[:30])
mysql.utilities.exception.LogParserError: ('Failed parsing Slow Query line: # User@Host: root[root] @ foo', 0)

When I use host with out of dot it works perfectly.

I am sure regular expression is wrong

How to repeat:
Open your slow query log. Change host name so it contains dots.
For example
# User@Host: root[root] @ foo.example.com [10.10.10.1]

Install mysql package for python from MySQL workbench.

Run the following python script:

from mysql.utilities.common import parser
for entry in parser.SlowQueryLog(open("c:/temp/1.log")):
    print entry.query

Suggested fix:
Fix regex. Add dashes and dots to user name group and host group

34,35c34,35
<                        r"(?:([\w\d]+))?\s*"
<                        r"\[\s*([\w\d]+)\s*\]\s*"
---
>                        r"(?:([-\w\d]+))?\s*"
>                        r"\[\s*([-\w\d]+)\s*\]\s*"
37c37
<                        r"([\w\d]*)\s*"
---
>                        r"([-\w.\d]*)\s*"
[21 Jun 2013 1:41] Chuck Bell
confirmed fixed in release-1.2.3