asks for confirmation when using alter-foreign-key-method none - issue 1329422

This commit is contained in:
Frank Cizmich
2014-06-30 13:36:25 -03:00
parent 885cdce7bf
commit 8eebecf559
2 changed files with 15 additions and 1 deletions

View File

@@ -7860,6 +7860,16 @@ sub main {
$o->save_error("Invalid --alter-foreign-keys-method value: $alter_fk_method");
}
# Issue a strong warning if alter-foreign-keys-method = none
if ( $alter_fk_method eq 'none' && !$o->get('force') ) {
print STDERR "WARNING! Using alter-foreign-keys-method = \"none\". This will typically cause foreign key violations!\nThis method of handling foreign key constraints is only provided so that the database administrator can disable the tools built-in functionality if desired.\n\nContinue anyway? (y/N)";
my $response;
chomp($response = <STDIN>);
if ($response !~ /y|(yes)/i) {
exit 1;
}
}
if ( $alter_fk_method eq 'drop_swap' && !$o->get('drop-new-table') ) {
$o->save_error("--alter-foreign-keys-method=drop_swap does not work with --no-drop-new-table.");
}
@@ -11025,6 +11035,10 @@ only perform some safety checks and exit. This helps ensure that you have read
documentation and understand how to use this tool. If you have not read the
documentation, then do not specify this option.
=item --force
This options bypasses confirmation in case of using alter-foreign-keys-method = none , which might break foreign key constraints.
=item --help
Show help and exit.

View File

@@ -591,7 +591,7 @@ test_alter_table(
test_type => "new_engine",
new_engine => "innodb",
cmds => [
qw(--execute --alter-foreign-keys-method none --alter ENGINE=INNODB)
qw(--execute --alter-foreign-keys-method none --force --alter ENGINE=INNODB)
],
);