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);
13
use Time::HiRes qw(sleep);
15
$ENV{PTTEST_FAKE_TS} = 1;
16
$ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
20
require "$trunk/bin/pt-online-schema-change";
21
require VersionParser;
24
$Data::Dumper::Indent = 1;
25
$Data::Dumper::Sortkeys = 1;
26
$Data::Dumper::Quotekeys = 0;
28
my $dp = new DSNParser(opts=>$dsn_opts);
29
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
30
my $master_dbh = $sb->get_dbh_for('master');
31
my $slave_dbh = $sb->get_dbh_for('slave1');
34
plan skip_all => 'Cannot connect to sandbox master';
36
elsif ( !$slave_dbh ) {
37
plan skip_all => 'Cannot connect to sandbox slave';
41
my $tp = new TableParser(Quoter => $q);
42
my @args = qw(--set-vars innodb_lock_wait_timeout=3);
44
my $dsn = "h=127.1,P=12345,u=msandbox,p=msandbox";
46
my $sample = "t/pt-online-schema-change/samples";
50
# #############################################################################
52
# Failed to detect child tables in other schema, and falsely identified
53
# child tables in own schema
54
# #############################################################################
56
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
57
$sb->load_file('master', "$sample/bug-1315130.sql");
58
($output, $exit) = full_output(
59
sub { pt_online_schema_change::main(@args, "$dsn,D=bug_1315130_a,t=parent_table",
61
'--alter', "add column c varchar(16)",
62
'--alter-foreign-keys-method', 'auto'),
65
print STDERR "[$output]\n";
68
qr/Child tables:\s*`bug_1315130_a`\.`child_table_in_same_schema` \(approx\. 1 rows\)\s*`bug_1315130_b`\.`child_table_in_second_schema` \(approx\. 1 rows\)[^`]*?Will/s,
69
"Correctly identify child tables from other schemas and ignores tables from same schema referencig same named parent in other schema.",
71
# clear databases with their foreign keys
72
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
75
# #############################################################################
76
$sb->wipe_clean($master_dbh);
77
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");