Remove new-table options and enhance error msg if creating new table fails.

This commit is contained in:
Daniel Nichter
2012-03-25 12:24:27 -06:00
parent 3589ec2c7c
commit 82aa518774
3 changed files with 75 additions and 108 deletions

View File

@@ -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,

View File

@@ -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.
# #############################################################################