mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-03-24 02:00:47 +08:00
PT-1985 pt-deadlock db schema check (#502)
This commit is contained in:
@@ -4675,6 +4675,9 @@ sub main {
|
||||
$sql =~ s/deadlocks/IF NOT EXISTS $db_tbl/;
|
||||
PTDEBUG && _d($sql);
|
||||
$dst->dbh->do($sql);
|
||||
if ( $EVAL_ERROR ) {
|
||||
_die("Cannot connect to MySQL: $EVAL_ERROR", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
37
t/pt-deadlock-logger/check_schema_exists.t
Normal file
37
t/pt-deadlock-logger/check_schema_exists.t
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-deadlock-logger";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
my ($output, $exist_status) = full_output(
|
||||
sub {
|
||||
pt_deadlock_logger::main(
|
||||
"h=127.1,D=non_existent_db,u=msandbox,p=msandbox",
|
||||
qw(--clear-deadlocks non_existent_db.make_deadlock --port 12345),
|
||||
qw(--iterations 1)
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
done_testing;
|
||||
Reference in New Issue
Block a user