mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +00:00
Fix get_tables() for LOAD DATA.
This commit is contained in:
@@ -98,7 +98,7 @@ sub get_tables {
|
|||||||
|
|
||||||
# These keywords may appear between UPDATE or SELECT and the table refs.
|
# 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.
|
# They need to be removed so that they are not mistaken for tables.
|
||||||
$query =~ s/ (?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN|DELAYED) / /ig;
|
$query =~ s/(?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN|DELAYED)\s+/ /ig;
|
||||||
|
|
||||||
# Another special case: LOCK TABLES tbl [[AS] alias] READ|WRITE, etc.
|
# Another special case: LOCK TABLES tbl [[AS] alias] READ|WRITE, etc.
|
||||||
# We strip the LOCK TABLES stuff and append "FROM" to fake a SELECT
|
# We strip the LOCK TABLES stuff and append "FROM" to fake a SELECT
|
||||||
@@ -116,11 +116,16 @@ sub get_tables {
|
|||||||
|
|
||||||
# INSERT and REPLACE without INTO
|
# INSERT and REPLACE without INTO
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/984053
|
# https://bugs.launchpad.net/percona-toolkit/+bug/984053
|
||||||
if ( $query =~ m/\A\s*(?:INSERT|REPLACE)\s+(?!INTO)/i ) {
|
if ( $query =~ m/\A\s*(?:INSERT|REPLACE)(?!\s+INTO)/i ) {
|
||||||
# Add INTO so the reset of the code work as usual.
|
# Add INTO so the reset of the code work as usual.
|
||||||
$query =~ s/\A\s*((?:INSERT|REPLACE))\s+/$1 INTO /i;
|
$query =~ s/\A\s*((?:INSERT|REPLACE))\s+/$1 INTO /i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $query =~ m/\A\s*LOAD DATA/i ) {
|
||||||
|
my ($tbl) = $query =~ m/INTO TABLE\s+(\S+)/i;
|
||||||
|
return $tbl;
|
||||||
|
}
|
||||||
|
|
||||||
my @tables;
|
my @tables;
|
||||||
foreach my $tbls ( $query =~ m/$tbl_regex/gio ) {
|
foreach my $tbls ( $query =~ m/$tbl_regex/gio ) {
|
||||||
PTDEBUG && _d('Match tables:', $tbls);
|
PTDEBUG && _d('Match tables:', $tbls);
|
||||||
|
@@ -828,6 +828,12 @@ is_deeply(
|
|||||||
[qw(t1 t2)], 'get_tables works for lowercased LOCK TABLES',
|
[qw(t1 t2)], 'get_tables works for lowercased LOCK TABLES',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
is_deeply(
|
||||||
|
[ $qp->get_tables("LOAD DATA INFILE '/tmp/foo.txt' INTO TABLE db.tbl") ],
|
||||||
|
[qw(db.tbl)],
|
||||||
|
"LOAD DATA db.tbl"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
Reference in New Issue
Block a user