Bug #71851 General Query Log Parser does not handle multi-line queries with blank line.
Submitted: 26 Feb 2014 23:27 Modified: 23 May 2014 5:45
Reporter: Feifei Xue Email Updates:
Status: Closed Impact on me:
Category:MySQL Utilities Severity:S2 (Serious)
Version:1.3.5 and 1.4.1 OS:Any
Assigned to: Paulo Jesus CPU Architecture:Any
Tags: generalquerylog, logparser, parser, utilities

[26 Feb 2014 23:27] Feifei Xue
The General Query Log may include multi-line queries that include blank lines. Here's an example log file snippet:

140101  1:00:00	 1000 Connect	user@localhost on
		 1000 Query	# First line is a comment.

SELECT * FROM foo WHERE bar = 'Third line is a query.';
		 1000 Quit

Although MySQL Utilities parser.py intends to handle mult-line arguments for Query and Prepare commands, it exits the loop when it encounters the blank second line.

How to repeat:
Either start with a fake log file containing the above snippet, or execute the above multi-line Query and then use the actual log file.  The following Python snippet will throw a LogParserError because the third line in the snippet fails to fit the expected pattern of a new command.

with open(your_log_file_name, 'r') as log_file:
    log_entries = parser.GeneralQueryLog(log_file)
    for entry in log_entries:
      print entry.get('argument')

Suggested fix:
In mysql/utilities/common/parser.py's definition of _handle_multi_line(), change

while line:


while line == '' or line:
[31 Mar 2014 11:00] Paulo Jesus
Thank you for reporting this issue.

The problem has been verified as described.
[12 May 2014 14:53] Chuck Bell
Fixed in release-1.4.3
[23 May 2014 5:45] Philip Olson
Fixed as of the upcoming MySQL Utilities 1.4.3 release, and here's the changelog entry:

The "mysql/utilities/common/parser.py" script would stop processing when a
blank line was encountered. However, the General Query Log may include
multi-line statements that include blank lines.

Thank you for the bug report.