mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 21:51:21 +00:00
Merge fix-pqd-distill-bug-821690.
This commit is contained in:
@@ -2962,6 +2962,7 @@ sub distill_verbs {
|
|||||||
eval $QueryParser::tbl_ident;
|
eval $QueryParser::tbl_ident;
|
||||||
my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
|
my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
|
||||||
if ( $dds) {
|
if ( $dds) {
|
||||||
|
$query =~ s/\s+IF(?:\s+NOT)?\s+EXISTS/ /i;
|
||||||
my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
|
my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
|
||||||
$obj = uc $obj if $obj;
|
$obj = uc $obj if $obj;
|
||||||
PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
|
PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
|
||||||
|
@@ -298,6 +298,8 @@ sub distill_verbs {
|
|||||||
eval $QueryParser::tbl_ident;
|
eval $QueryParser::tbl_ident;
|
||||||
my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
|
my ( $dds ) = $query =~ /^\s*($QueryParser::data_def_stmts)\b/i;
|
||||||
if ( $dds) {
|
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;
|
my ( $obj ) = $query =~ m/$dds.+(DATABASE|TABLE)\b/i;
|
||||||
$obj = uc $obj if $obj;
|
$obj = uc $obj if $obj;
|
||||||
PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
|
PTDEBUG && _d('Data def statment:', $dds, 'obj:', $obj);
|
||||||
|
@@ -1440,6 +1440,20 @@ is(
|
|||||||
"distill REPLACE without INTO (bug 984053)"
|
"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.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -27,9 +27,6 @@ my $dbh = $sb->get_dbh_for('master');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
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);
|
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
|
# the usual stddev. -- stddev doesn't matter much. It's the other vals
|
||||||
# that indicate that --processlist works.
|
# that indicate that --processlist works.
|
||||||
$exec =~ s/(\S+) 3s$/786ms 3s/;
|
$exec =~ s/(\S+) 3s$/786ms 3s/;
|
||||||
TODO: {
|
ok(
|
||||||
local $::TODO = "This is a timing-related test, which may occasionally fail";
|
no_diff(
|
||||||
ok(
|
$exec,
|
||||||
no_diff(
|
"t/pt-query-digest/samples/proclist001.txt",
|
||||||
$exec,
|
cmd_output => 1,
|
||||||
"t/pt-query-digest/samples/proclist001.txt",
|
),
|
||||||
cmd_output => 1,
|
"--processlist correctly observes and measures multiple queries"
|
||||||
),
|
);
|
||||||
"--processlist correctly observes and measures multiple queries"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($dbh);
|
$sb->wipe_clean($dbh);
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
exit;
|
done_testing;
|
||||||
|
Reference in New Issue
Block a user