mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-29 09:32:47 +00:00
Remove new-table options and enhance error msg if creating new table fails.
This commit is contained in:
@@ -29,7 +29,7 @@ if ( !$master_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 42;
|
||||
plan tests => 43;
|
||||
}
|
||||
|
||||
my $q = new Quoter();
|
||||
@@ -48,13 +48,9 @@ my $rows;
|
||||
$sb->load_file('master', "$sample/basic_no_fks.sql");
|
||||
PerconaTest::wait_for_table($slave_dbh, "pt_osc.t", "id=20");
|
||||
|
||||
# --new-table really ensures the tool exists before doing stuff because
|
||||
# setting up the new table is the first thing the tool does and this would
|
||||
# cause an error because mysql.user already exists. To prove this, add
|
||||
# --dry-run and the test will fail because the code doesn't exit early.
|
||||
$output = output(
|
||||
sub { $exit = pt_online_schema_change::main(@args, "$dsn,t=pt_osc.t",
|
||||
qw(--new-table mysql.user)) }
|
||||
'--alter', 'drop column id') }
|
||||
);
|
||||
|
||||
like(
|
||||
@@ -63,6 +59,13 @@ like(
|
||||
"Doesn't run without --execute (bug 933232)"
|
||||
);
|
||||
|
||||
my $ddl = $master_dbh->selectrow_arrayref("show create table pt_osc.t");
|
||||
like(
|
||||
$ddl->[1],
|
||||
qr/^\s+`id`/m,
|
||||
"Did not alter the table"
|
||||
);
|
||||
|
||||
is(
|
||||
$exit,
|
||||
0,
|
||||
|
@@ -29,7 +29,7 @@ if ( !$master_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 4;
|
||||
plan tests => 5;
|
||||
}
|
||||
|
||||
my $q = new Quoter();
|
||||
@@ -85,6 +85,27 @@ throws_ok(
|
||||
"Original table must have a PK or unique index"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Checks for the new table.
|
||||
# #############################################################################
|
||||
|
||||
$sb->load_file('master', "$sample/basic_no_fks.sql");
|
||||
PerconaTest::wait_for_table($slave_dbh, "pt_osc.t", "id=20");
|
||||
$master_dbh->do("USE pt_osc");
|
||||
$slave_dbh->do("USE pt_osc");
|
||||
|
||||
for my $i ( 1..10 ) {
|
||||
my $table = ('_' x $i) . 't_new';
|
||||
$master_dbh->do("create table $table (id int)");
|
||||
}
|
||||
|
||||
throws_ok(
|
||||
sub { pt_online_schema_change::main(@args,
|
||||
"$dsn,t=pt_osc.t", qw(--quiet --dry-run)) },
|
||||
qr/Failed to find a unique new table name/,
|
||||
"Doesn't try forever to find a new table name"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
Reference in New Issue
Block a user