Merge pull request #211 from percona/PT-132

PT-132 pt-online-schema-change should imply --no-drop-new-table when --no-swap-tables and --no-drop-triggers used
This commit is contained in:
Carlos Salguero
2017-05-05 12:59:11 -03:00
committed by GitHub
2 changed files with 25 additions and 0 deletions

View File

@@ -8195,6 +8195,10 @@ sub main {
# Explicit --chunk-size disable auto chunk sizing.
$o->set('chunk-time', 0) if $o->got('chunk-size');
if (!$o->get('swap-tables') && !$o->get('drop-triggers')) {
PTDEBUG && _d('Enabling no-drop-new-table since no-swap-tables & no-drop-triggers were specified');
$o->set('drop-new-table', 0);
}
foreach my $opt ( qw(max-load critical-load) ) {
next unless $o->has($opt);

View File

@@ -68,6 +68,27 @@ is_deeply(
"no swap-tables, drop-triggers, drop-new-table: tables"
) or diag(Dumper($tables), $output);
# #############################################################################
# --no-swap-tables --no-drop-triggers implies --no-drop-new-table
# #############################################################################
$sb->load_file('master', "$sample/basic_no_fks_innodb.sql");
$output = output(
sub { pt_online_schema_change::main(
"$master_dsn,D=pt_osc,t=t",
'--alter', 'ADD COLUMN d INT',
qw(--execute --no-swap-tables --no-drop-triggers))
},
stderr => 1,
);
$tables = $dbh1->selectall_arrayref("SHOW TABLES FROM pt_osc");
is_deeply(
$tables,
[ ['_t_new'], ['t'] ],
"no swap-tables, --no-drop-triggers implies --no-drop-new-table"
) or diag(Dumper($tables), $output);
# #############################################################################
# Done.
# #############################################################################