Merge fix-pqd-distill-bug-821690.

This commit is contained in:
Daniel Nichter
2013-08-03 14:21:27 -07:00
4 changed files with 26 additions and 15 deletions

View File

@@ -2962,6 +2962,7 @@ sub distill_verbs {
eval $QueryParser::tbl_ident;
my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
if ( $dds) {
$query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
$obj = uc $obj if $obj;
PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);

View File

@@ -298,6 +298,8 @@ sub distill_verbs {
eval $QueryParser::tbl_ident;
my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
if ( $dds) {
# https://bugs.launchpad.net/percona-toolkit/+bug/821690
$query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
$obj = uc $obj if $obj;
PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);

View File

@@ -1440,6 +1440,20 @@ is(
"distill REPLACE without INTO (bug 984053)"
);
# IF EXISTS
# https://bugs.launchpad.net/percona-toolkit/+bug/821690
is(
$qr->distill("DROP TABLE IF EXISTS foo"),
"DROP TABLE foo",
"distill DROP TABLE IF EXISTS foo (bug 821690)"
);
is(
$qr->distill("CREATE TABLE IF NOT EXISTS foo"),
"CREATE TABLE foo",
"distill CREATE TABLE IF NOT EXISTS foo",
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -27,9 +27,6 @@ my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 3;
}
my @args = qw(-F /tmp/12345/my.sandbox.cnf --processlist h=127.1 --report-format query_report);
@@ -58,21 +55,18 @@ my $output = output(
# the usual stddev. -- stddev doesn't matter much. It's the other vals
# that indicate that --processlist works.
$exec =~ s/(\S+) 3s$/786ms 3s/;
TODO: {
local $::TODO = "This is a timing-related test, which may occasionally fail";
ok(
no_diff(
$exec,
"t/pt-query-digest/samples/proclist001.txt",
cmd_output => 1,
),
"--processlist correctly observes and measures multiple queries"
);
}
ok(
no_diff(
$exec,
"t/pt-query-digest/samples/proclist001.txt",
cmd_output => 1,
),
"--processlist correctly observes and measures multiple queries"
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;
done_testing;