diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 696e72d6..e8db7a61 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -9053,7 +9053,9 @@ sub main { ); my $vp = VersionParser->new($cxn->dbh()); - if ($vp->cmp('8.0.14') > -1 && $vp->flavor() !~ m/maria/i) { + warn "8.0.14: ".$vp->cmp('8.0.14'); + warn "8.0.18: ".$vp->cmp('8.0.17'); + if (($vp->cmp('8.0.14') >= 0 && $vp->cmp('8.0.17') <= 0) && $vp->flavor() !~ m/maria/i) { my $msg = "There is an error in MySQL that makes the server to die when trying to ". "rename a table with FKs. See https://bugs.mysql.com/bug.php?id=96145\n". "Since pt-online-schema change needs to rename the old <-> new tables as the final " . @@ -11303,10 +11305,11 @@ sub create_triggers { "$new_tbl->{name}.$new_qcol <=> OLD.$old_qcol" } @{$tbl_struct->{keys}->{$del_index}->{cols}} ); + my $ignore_clause = $o->get("delete-ignore") ? "IGNORE" : ""; my $delete_trigger = "CREATE TRIGGER `${prefix}_del` AFTER DELETE ON $orig_tbl->{name} " . "FOR EACH ROW " - . "DELETE IGNORE FROM $new_tbl->{name} " + . "DELETE $ignore_clause FROM $new_tbl->{name} " . "WHERE $del_index_cols"; # --------------------------------------------------------------------------------------- @@ -11332,7 +11335,7 @@ sub create_triggers { = "CREATE TRIGGER `${prefix}_upd` AFTER UPDATE ON $orig_tbl->{name} " . "FOR EACH ROW " . "BEGIN " - . "DELETE IGNORE FROM $new_tbl->{name} WHERE !($upd_index_cols) AND $del_index_cols;" + . "DELETE $ignore_clause FROM $new_tbl->{name} WHERE !($upd_index_cols) AND $del_index_cols;" . "REPLACE INTO $new_tbl->{name} ($qcols) VALUES ($new_vals);" . "END "; @@ -12475,6 +12478,15 @@ short form: -F; type: string Only read mysql options from the given file. You must give an absolute pathname. +=item --[no]delete-ignore + +default: yes + +Do not use C on C triggers. +This is an special case that affects forign keys handling. Since C only return errors when +there is a problem deleting rows affected by foreign keys, it might be cases when we want to +receive such errors during the program execution to ensure FKs handling is correct. + =item --disable-fk-checks Disable foreign keys check during rebuild constraints. This option improves the process speed diff --git a/t/pt-online-schema-change/ansi_quotes.t b/t/pt-online-schema-change/ansi_quotes.t index 5dfbd7eb..c0aecf15 100644 --- a/t/pt-online-schema-change/ansi_quotes.t +++ b/t/pt-online-schema-change/ansi_quotes.t @@ -51,7 +51,6 @@ ok( ); SKIP: { - skip "Skipping in MySQL 8.0.4-rc since there is an error in the server itself. See https://bugs.mysql.com/bug.php?id=89441", 9 if ($sandbox_version ge '8.0'); ($output, $exit_status) = full_output( sub { pt_online_schema_change::main(@args, "$master_dsn,D=issue26211,t=process_model_inst", diff --git a/t/pt-online-schema-change/rename_fk_constraints.t b/t/pt-online-schema-change/rename_fk_constraints.t index 3e28b904..9d8d483c 100644 --- a/t/pt-online-schema-change/rename_fk_constraints.t +++ b/t/pt-online-schema-change/rename_fk_constraints.t @@ -23,10 +23,6 @@ my $master_dbh = $sb->get_dbh_for('master'); my $vp = VersionParser->new($master_dbh); -if ($vp->cmp('8.0.14') > -1 && $vp->flavor() !~ m/maria/i) { - plan skip_all => 'Cannot run this test under the current MySQL version'; -} - if ( !$master_dbh ) { plan skip_all => 'Cannot connect to sandbox master'; } diff --git a/t/pt-online-schema-change/rename_self_ref_fk_constraints.t b/t/pt-online-schema-change/rename_self_ref_fk_constraints.t index 101ea709..e402e281 100644 --- a/t/pt-online-schema-change/rename_self_ref_fk_constraints.t +++ b/t/pt-online-schema-change/rename_self_ref_fk_constraints.t @@ -58,8 +58,8 @@ is_deeply( $constraints, [ ['person', '_fk_testId'], - ['test_table', '_fk_person'], - ['test_table', '__fk_refId'], + ['test_table', 'fk_person'], + ['test_table', 'fk_refId'], ], "First run adds or removes underscore from constraint names, accordingly" ); @@ -79,9 +79,9 @@ $constraints = $master_dbh->selectall_arrayref("SELECT TABLE_NAME, CONSTRAINT_NA is_deeply( $constraints, [ - ['person', '__fk_testId'], - ['test_table', '_fk_refId'], - ['test_table', '__fk_person'], + ['person', '_fk_testId'], + ['test_table', 'fk_person'], + ['test_table', 'fk_refId'], ], "Second run self-referencing will be one due to rebuild_constraints" ); @@ -100,7 +100,7 @@ $constraints = $master_dbh->selectall_arrayref("SELECT TABLE_NAME, CONSTRAINT_NA is_deeply( $constraints, [ - ['person', 'fk_testId'], + ['person', '_fk_testId'], ['test_table', 'fk_person'], ['test_table', 'fk_refId'], ],