diff --git a/bin/pt-upgrade b/bin/pt-upgrade index 2bdcd659..1417bf81 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -5328,7 +5328,7 @@ sub exec_event { my $t1 = time - $t0; $results->{query_time} = sprintf('%.6f', $t1); $results->{sth} = $sth; - $results->{warnings} = $self->get_warnings(host => $host); + $results->{warnings} = $self->get_warnings(dbh => $host->dbh); }; if ( $EVAL_ERROR ) { PTDEBUG && _d($EVAL_ERROR); @@ -5341,12 +5341,12 @@ sub exec_event { sub get_warnings { my ($self, %args) = @_; - my @required_args = qw(host); + my @required_args = qw(dbh); foreach my $arg ( @required_args ) { die "I need a $arg argument" unless $args{$arg}; } - my $host = $args{host}; - my $warnings = $host->dbh->selectall_hashref('SHOW WARNINGS', 'code'); + my $dbh = $args{dbh}; + my $warnings = $dbh->selectall_hashref('SHOW WARNINGS', 'code'); return $warnings; } diff --git a/lib/EventExecutor.pm b/lib/EventExecutor.pm index 62dc62ca..8c263d01 100644 --- a/lib/EventExecutor.pm +++ b/lib/EventExecutor.pm @@ -82,7 +82,7 @@ sub exec_event { my $t1 = time - $t0; $results->{query_time} = sprintf('%.6f', $t1); $results->{sth} = $sth; - $results->{warnings} = $self->get_warnings(host => $host); + $results->{warnings} = $self->get_warnings(dbh => $host->dbh); }; if ( $EVAL_ERROR ) { PTDEBUG && _d($EVAL_ERROR); @@ -95,12 +95,12 @@ sub exec_event { sub get_warnings { my ($self, %args) = @_; - my @required_args = qw(host); + my @required_args = qw(dbh); foreach my $arg ( @required_args ) { die "I need a $arg argument" unless $args{$arg}; } - my $host = $args{host}; - my $warnings = $host->dbh->selectall_hashref('SHOW WARNINGS', 'code'); + my $dbh = $args{dbh}; + my $warnings = $dbh->selectall_hashref('SHOW WARNINGS', 'code'); return $warnings; } diff --git a/t/pt-upgrade/diff_rows.t b/t/pt-upgrade/diff_rows.t index afabf194..75e9608a 100644 --- a/t/pt-upgrade/diff_rows.t +++ b/t/pt-upgrade/diff_rows.t @@ -68,16 +68,16 @@ test_diff ( query1 => "select user from mysql.user order by user ASC", query2 => "select user from mysql.user order by user DESC", expect => [ - { - row_number => 1, - sth1_rows => [qw(msandbox)], - sth2_rows => [qw(root)], - }, - { - row_number => 2, - sth1_rows => [qw(root)], - sth2_rows => [qw(msandbox)], - } + [ + 1, + [qw(msandbox)], + [qw(root)], + ], + [ + 2, + [qw(root)], + [qw(msandbox)], + ] ], ); diff --git a/t/pt-upgrade/diff_warnings.t b/t/pt-upgrade/diff_warnings.t index 331ca8b1..90cc6586 100644 --- a/t/pt-upgrade/diff_warnings.t +++ b/t/pt-upgrade/diff_warnings.t @@ -39,8 +39,9 @@ sub clear_warnings { $dbh1->do("INSERT INTO test.t VALUES (2, '', 123456789)"); $dbh2->do("INSERT INTO test.t VALUES (3, '', 123456789)"); -my $w1 = pt_upgrade::get_warnings(dbh => $dbh1); -my $w2 = pt_upgrade::get_warnings(dbh => $dbh2); +my $event_exec = EventExecutor->new(); +my $w1 = $event_exec->get_warnings(dbh => $dbh1); +my $w2 = $event_exec->get_warnings(dbh => $dbh2); my $error_1264 = { code => '1264', @@ -65,8 +66,8 @@ is_deeply( ) or diag(Dumper($w2)); my $diffs = pt_upgrade::diff_warnings( - host1_warnings => $w1, - host2_warnings => $w2, + warnings1 => $w1, + warnings2 => $w2, ); is_deeply( @@ -76,17 +77,18 @@ is_deeply( ) or diag(Dumper($diffs)); $diffs = pt_upgrade::diff_warnings( - host1_warnings => {}, - host2_warnings => $w2, + warnings1 => {}, + warnings2 => $w2, ); is_deeply( $diffs, [ - { - host1 => undef, - host2 => $error_1264, - }, + [ + 1264, + undef, + $error_1264, + ], ], "host1 doesn't have the warning" ) or diag(Dumper($diffs)); @@ -97,8 +99,8 @@ is_deeply( $diffs = pt_upgrade::diff_warnings( ignore_warnings => { 1264 => 1 }, - host1_warnings => $w1, - host2_warnings => $w2, + warnings1 => $w1, + warnings2 => $w2, ); is_deeply(