Test, update modules, and fix bug 873598 in pt-online-schema-change.

This commit is contained in:
Daniel Nichter
2012-02-21 09:06:08 -07:00
parent 17fe96f361
commit 75457eaadd
3 changed files with 236 additions and 421 deletions

View File

@@ -25,7 +25,7 @@ if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 18;
plan tests => 22;
}
my $output = "";
@@ -232,6 +232,51 @@ is(
"Updated child table foreign key constraint (drop_old_table method)"
);
# #############################################################################
# Alter tables with columns with resvered words and spaces.
# #############################################################################
sub test_table {
my (%args) = @_;
my ($file, $name) = @args{qw(file name)};
$sb->load_file('master', "t/lib/samples/osc/$file");
PerconaTest::wait_for_table($dbh, "osc.t", "id=5");
PerconaTest::wait_for_table($dbh, "osc.__new_t");
$dbh->do('use osc');
$dbh->do("DROP TABLE IF EXISTS osc.__new_t");
$org_rows = $dbh->selectall_arrayref('select * from osc.t order by id');
output(
sub { $exit = pt_online_schema_change::main(@args,
'D=osc,t=t', qw(--alter ENGINE=InnoDB)) },
);
$new_rows = $dbh->selectall_arrayref('select * from osc.t order by id');
is_deeply(
$new_rows,
$org_rows,
"$name rows"
);
is(
$exit,
0,
"$name exit status 0"
);
}
test_table(
file => "tbl002.sql",
name => "Reserved word column",
);
test_table(
file => "tbl003.sql",
name => "Space column",
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -29,7 +29,6 @@ else {
my $vp = new VersionParser();
my $q = new Quoter();
my $tp = new TableParser(Quoter => $q);
my $du = new MySQLDump();
my $chunker = new TableChunker(Quoter => $q, TableParser => $tp);
my $o = new OptionParser();
@@ -40,7 +39,7 @@ pt_online_schema_change::__set_quiet(1);
$sb->load_file('master', "t/pt-online-schema-change/samples/small_table.sql");
$dbh->do('use mkosc');
my $old_tbl_struct = $tp->parse($du->get_create_table($dbh, $q, 'mkosc', 'a'));
my $old_tbl_struct = $tp->parse($tp->get_create_table($dbh, 'mkosc', 'a'));
my %args = (
dbh => $dbh,
@@ -53,7 +52,6 @@ my %args = (
TableParser => $tp,
OptionParser => $o,
TableChunker => $chunker,
MySQLDump => $du,
);
my %tbl_info = pt_online_schema_change::check_tables(%args);
@@ -112,7 +110,7 @@ throws_ok(
$dbh->do('DROP TRIGGER mkosc.foo');
$dbh->do('ALTER TABLE mkosc.a DROP COLUMN i');
my $tmp_struct = $tp->parse($du->get_create_table($dbh, $q, 'mkosc', 'a'));
my $tmp_struct = $tp->parse($tp->get_create_table($dbh, 'mkosc', 'a'));
throws_ok(
sub { pt_online_schema_change::check_tables(
%args,