PT-1747 Updated MySQL version check

This commit is contained in:
Carlos Salguero
2019-11-26 10:04:56 -03:00
parent 2f36e5816a
commit e97d80cde0
4 changed files with 21 additions and 14 deletions

View File

@@ -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<IGNORE> on C<DELETE> triggers.
This is an special case that affects forign keys handling. Since C<DELETE> 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

View File

@@ -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",

View File

@@ -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';
}

View File

@@ -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'],
],