Fix QueryParser and QueryRewriter to handle LOAD DATA and INSERT/REPLACE without INTO.

This commit is contained in:
Daniel Nichter
2013-08-03 11:19:40 -07:00
parent cce1420736
commit a742090177
2 changed files with 19 additions and 4 deletions

View File

@@ -98,7 +98,7 @@ sub get_tables {
# These keywords may appear between UPDATE or SELECT and the table refs.
# They need to be removed so that they are not mistaken for tables.
$query =~ s/ (?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN)//ig;
$query =~ s/ (?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN|DELAYED) / /ig;
# Another special case: LOCK TABLES tbl [[AS] alias] READ|WRITE, etc.
# We strip the LOCK TABLES stuff and append "FROM" to fake a SELECT
@@ -110,9 +110,16 @@ sub get_tables {
$query = "FROM $query";
}
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
$query =~ s/\\["']//g; # quoted strings
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
# INSERT and REPLACE without INTO
# https://bugs.launchpad.net/percona-toolkit/+bug/984053
if ( $query =~ m/\A\s*(?:INSERT|REPLACE)\s+(?!INTO)/i ) {
# Add INTO so the reset of the code work as usual.
$query =~ s/\A\s*((?:INSERT|REPLACE))\s+/$1 INTO /i;
}
my @tables;
foreach my $tbls ( $query =~ m/$tbl_regex/gio ) {