Merge lp:~percona-toolkit-dev/percona-toolkit/dis-fk-chk-bug-976108 into lp:percona-toolkit/2.1

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 245
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/dis-fk-chk-bug-976108
Merge into: lp:percona-toolkit/2.1
Diff against target: 113 lines (+49/-40)
1 file modified
bin/pt-online-schema-change (+49/-40)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/dis-fk-chk-bug-976108
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+104936@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-online-schema-change'
--- bin/pt-online-schema-change 2012-04-26 20:56:18 +0000
+++ bin/pt-online-schema-change 2012-05-07 16:34:23 +0000
@@ -5235,50 +5235,59 @@
5235 # ########################################################################5235 # ########################################################################
5236 # Get child tables of the original table, if necessary.5236 # Get child tables of the original table, if necessary.
5237 # ########################################################################5237 # ########################################################################
5238 my $child_tables = find_child_tables(5238 my $child_tables;
5239 tbl => $orig_tbl,5239 if ( ($alter_fk_method || '') eq 'none' ) {
5240 Cxn => $cxn,5240 print "Not updating foreign keys because "
5241 Quoter => $q,5241 . "--alter-foreign-keys-method=none. Foreign keys "
5242 );5242 . "that reference the table will no longer work.\n";
5243 if ( !$child_tables ) {
5244 if ( $alter_fk_method ) {
5245 warn "No foreign keys reference $orig_tbl->{name}; ignoring "
5246 . "--alter-foreign-keys-method.\n";
5247
5248 if ( $alter_fk_method eq 'drop_swap' ) {
5249 # These opts are disabled at the start if the user specifies
5250 # the drop_swap method, but now that we know there are no
5251 # child tables, we must re-enable these to make the alter work.
5252 $o->set('swap-tables', 1);
5253 $o->set('drop-old-table', 1);
5254 }
5255
5256 $alter_fk_method = '';
5257 }
5258 # No child tables and --alter-fk-method wasn't specified,
5259 # so nothing to do.
5260 }5243 }
5261 else {5244 else {
5262 print "Child tables:\n";5245 $child_tables = find_child_tables(
5263 foreach my $child_table ( @$child_tables ) {5246 tbl => $orig_tbl,
5264 printf " %s (approx. %s rows)\n",5247 Cxn => $cxn,
5265 $child_table->{name},5248 Quoter => $q,
5266 $child_table->{row_est} || '?';5249 );
5250 if ( !$child_tables ) {
5251 if ( $alter_fk_method ) {
5252 warn "No foreign keys reference $orig_tbl->{name}; ignoring "
5253 . "--alter-foreign-keys-method.\n";
5254
5255 if ( $alter_fk_method eq 'drop_swap' ) {
5256 # These opts are disabled at the start if the user specifies
5257 # the drop_swap method, but now that we know there are no
5258 # child tables, we must re-enable these to make the alter work.
5259 $o->set('swap-tables', 1);
5260 $o->set('drop-old-table', 1);
5261 }
5262
5263 $alter_fk_method = '';
5264 }
5265 # No child tables and --alter-fk-method wasn't specified,
5266 # so nothing to do.
5267 }5267 }
5268 else {
5269 print "Child tables:\n";
5270 foreach my $child_table ( @$child_tables ) {
5271 printf " %s (approx. %s rows)\n",
5272 $child_table->{name},
5273 $child_table->{row_est} || '?';
5274 }
52685275
5269 if ( $alter_fk_method ) {5276 if ( $alter_fk_method ) {
5270 # Let the user know how we're going to update the child table fk refs.5277 # Let the user know how we're going to update the child table
5271 my $choice5278 # fk refs.
5279 my $choice
5272 = $alter_fk_method eq 'none' ? "not"5280 = $alter_fk_method eq 'none' ? "not"
5273 : $alter_fk_method eq 'auto' ? "automatically choose the method to"5281 : $alter_fk_method eq 'auto' ? "automatically choose the method to"
5274 : "use the $alter_fk_method method to";5282 : "use the $alter_fk_method method to";
5275 print "Will $choice update foreign keys.\n";5283 print "Will $choice update foreign keys.\n";
5276 }5284 }
5277 else {5285 else {
5278 print "You did not specify --alter-foreign-keys-method, but there "5286 print "You did not specify --alter-foreign-keys-method, but there "
5279 . "are foreign keys that reference the table. "5287 . "are foreign keys that reference the table. "
5280 . "Please read the tool's documentation carefully.\n";5288 . "Please read the tool's documentation carefully.\n";
5281 return 1; 5289 return 1;
5290 }
5282 }5291 }
5283 }5292 }
52845293
@@ -5909,9 +5918,9 @@
5909 if ( $child_tables ) {5918 if ( $child_tables ) {
5910 eval {5919 eval {
5911 if ( $alter_fk_method eq 'none' ) {5920 if ( $alter_fk_method eq 'none' ) {
5912 print "Not updating foreign keys because "5921 # This shouldn't happen, but in case it does we should know.
5913 . "--alter-foreign-keys-method=none. Foreign keys "5922 warn "The tool detected child tables but "
5914 . "that reference the table will no longer work.\n";5923 . "--alter-foreign-keys-method=none";
5915 }5924 }
5916 elsif ( $alter_fk_method eq 'rebuild_constraints' ) {5925 elsif ( $alter_fk_method eq 'rebuild_constraints' ) {
5917 rebuild_constraints(5926 rebuild_constraints(

Subscribers

People subscribed via source and target branches