Add a missing .* to the backtracking explosion fix for 823431

This commit is contained in:
Brian Fraser
2012-12-07 19:20:29 -03:00
parent e82f062156
commit 9f4ce57301
3 changed files with 11 additions and 11 deletions

View File

@@ -1229,7 +1229,7 @@ sub print_usage {
$desc .= ". Optional suffix s=seconds, m=minutes, h=hours, "
. "d=days; if no suffix, $s is used.";
}
$desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol})(?:\s+|$)/g);
$desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol}(?!\W))(?:\s+|(?<=\W)|$)/g);
$desc =~ s/ +$//mg;
if ( $short ) {
$usage .= sprintf(" --%-${maxs}s -%s %s\n", $long, $short, $desc);
@@ -4505,7 +4505,7 @@ sub parse_insert {
}
if ( my @into = ($query =~ m/
(?=VALUE|SE(?:T|LECT)) # Avoid a backtracking explosion
(?=.*?(?:VALUE|SE(?:T|LECT))) # Avoid a backtracking explosion
(?:INTO\s+)? # INTO, optional
(.+?)\s+ # table ref
(\([^\)]+\)\s+)? # column list, optional

View File

@@ -371,7 +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
(?=.*?(?:VALUE|SE(?:T|LECT))) # Avoid a backtracking explosion
(?:INTO\s+)? # INTO, optional
(.+?)\s+ # table ref
(\([^\)]+\)\s+)? # column list, optional

View File

@@ -11,8 +11,6 @@ use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use File::Spec;
use PerconaTest;
require "$trunk/bin/pt-query-advisor";
@@ -47,18 +45,20 @@ like(
my $exit_status;
$output = output(
sub { $exit_status = pt_query_advisor::main(@args,
File::Spec->catfile($sample, "bug_823431.log"))
});
"$sample/bug_823431.log")
},
stderr => 1
);
ok(
!$exit_status,
"Bug 823431: pqa doesn't hang on a big query"
"Bug 823431: ptqa doesn't hang on a big query"
);
like(
is(
$output,
qr/COL.002/,
"Bug 823431: pqa doesn't hang on a big query and finds the correct rule"
'',
"Bug 823431: ptqa doesn't hang on a big query and doesn't find an incorrect rule"
);
# #############################################################################