Fix for 823431: pt-query-advisor hangs on big queries

This was caused by a regex backtracking itself to a halt. The solution
was to add a positive lookahead that searches for the floating but mandatory
substrings that the regex needs; if those exist, then eventually it will
match, but if they don't, it'll fail quickly.
This commit is contained in:
Brian Fraser
2012-10-31 06:48:54 -03:00
parent 64fe380986
commit dce8db5be1
3 changed files with 28 additions and 2 deletions

View File

@@ -371,6 +371,7 @@ sub parse_insert {
# Parse INTO clause. Literal "INTO" is optional.
if ( my @into = ($query =~ m/
(?=VALUE|SE(?:T|LECT)) # Avoid a backtracking explosion
(?:INTO\s+)? # INTO, optional
(.+?)\s+ # table ref
(\([^\)]+\)\s+)? # column list, optional