4
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
10
use warnings FATAL => 'all';
11
use English qw(-no_match_vars);
20
my $dp = new DSNParser(opts=>$dsn_opts);
21
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
23
my $dbh = $sb->get_dbh_for('master');
26
plan skip_all => "Cannot connect to sandbox master";
32
$sb->create_dbs($dbh, ['test']);
34
my $du = new MySQLDump();
39
# TODO: get_create_table() seems to return an arrayref sometimes!
42
skip 'Sandbox master does not have the sakila database', 10
43
unless @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
45
$dump = $du->dump($dbh, $q, 'sakila', 'film', 'table');
46
like($dump, qr/language_id/, 'Dump sakila.film');
48
$dump = $du->dump($dbh, $q, 'mysql', 'film', 'triggers');
49
ok(!defined $dump, 'no triggers in mysql');
51
$dump = $du->dump($dbh, $q, 'sakila', 'film', 'triggers');
52
like($dump, qr/AFTER INSERT/, 'dump triggers');
54
$dump = $du->dump($dbh, $q, 'sakila', 'customer_list', 'table');
55
like($dump, qr/CREATE TABLE/, 'Temp table def for view/table');
56
like($dump, qr/DROP TABLE/, 'Drop temp table def for view/table');
57
like($dump, qr/DROP VIEW/, 'Drop view def for view/table');
58
unlike($dump, qr/ALGORITHM/, 'No view def');
60
$dump = $du->dump($dbh, $q, 'sakila', 'customer_list', 'view');
61
like($dump, qr/DROP TABLE/, 'Drop temp table def for view');
62
like($dump, qr/DROP VIEW/, 'Drop view def for view');
63
like($dump, qr/ALGORITHM/, 'View def');
66
# #############################################################################
67
# Issue 170: mk-parallel-dump dies when table-status Data_length is NULL
68
# #############################################################################
70
# The underlying problem for issue 170 is that MySQLDump doesn't eval some
71
# of its queries so when MySQLFind uses it and hits a broken table it dies.
73
diag(`cp $trunk/t/lib/samples/broken_tbl.frm /tmp/12345/data/test/broken_tbl.frm`);
77
open STDERR, '>', \$output;
78
$dump = $du->dump($dbh, $q, 'test', 'broken_tbl', 'table');
83
'No error dumping broken table'
87
qr/table may be damaged.+selectrow_hashref failed/s,
88
'Warns about possibly damaged table'
91
$sb->wipe_clean($dbh);