Merge lp:~percona-toolkit-dev/percona-toolkit/pt-osc-asks-for-confirmation-when-alter-foreign-key-method-none-1329422 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.9

Proposed by Frank Cizmich
Status: Merged
Merged at revision: 612
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-osc-asks-for-confirmation-when-alter-foreign-key-method-none-1329422
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.9
Diff against target: 43 lines (+15/-1)
2 files modified
bin/pt-online-schema-change (+14/-0)
t/pt-online-schema-change/basics.t (+1/-1)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-osc-asks-for-confirmation-when-alter-foreign-key-method-none-1329422
Reviewer Review Type Date Requested Status
Percona Toolkit developers Pending
Review via email: mp+225058@code.launchpad.net

Description of the change

Issues a warning and asks for confirmation when alter-foreign-key-method = none
Can be overriden with --force

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-online-schema-change'
2--- bin/pt-online-schema-change 2014-06-05 07:24:48 +0000
3+++ bin/pt-online-schema-change 2014-06-30 17:03:42 +0000
4@@ -7860,6 +7860,16 @@
5 $o->save_error("Invalid --alter-foreign-keys-method value: $alter_fk_method");
6 }
7
8+ # Issue a strong warning if alter-foreign-keys-method = none
9+ if ( $alter_fk_method eq 'none' && !$o->get('force') ) {
10+ 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 tool’s built-in functionality if desired.\n\nContinue anyway? (y/N)";
11+ my $response;
12+ chomp($response = <STDIN>);
13+ if ($response !~ /y|(yes)/i) {
14+ exit 1;
15+ }
16+ }
17+
18 if ( $alter_fk_method eq 'drop_swap' && !$o->get('drop-new-table') ) {
19 $o->save_error("--alter-foreign-keys-method=drop_swap does not work with --no-drop-new-table.");
20 }
21@@ -11025,6 +11035,10 @@
22 documentation and understand how to use this tool. If you have not read the
23 documentation, then do not specify this option.
24
25+=item --force
26+
27+This options bypasses confirmation in case of using alter-foreign-keys-method = none , which might break foreign key constraints.
28+
29 =item --help
30
31 Show help and exit.
32
33=== modified file 't/pt-online-schema-change/basics.t'
34--- t/pt-online-schema-change/basics.t 2013-11-27 00:27:49 +0000
35+++ t/pt-online-schema-change/basics.t 2014-06-30 17:03:42 +0000
36@@ -591,7 +591,7 @@
37 test_type => "new_engine",
38 new_engine => "innodb",
39 cmds => [
40- qw(--execute --alter-foreign-keys-method none --alter ENGINE=INNODB)
41+ qw(--execute --alter-foreign-keys-method none --force --alter ENGINE=INNODB)
42 ],
43 );
44

Subscribers

People subscribed via source and target branches

to all changes: