Update diff_rows.t and diff_warnings.t.

This commit is contained in:
Daniel Nichter
2013-02-18 19:27:06 -07:00
parent 6f735bfb3a
commit 36e8696479
4 changed files with 32 additions and 30 deletions

View File

@@ -5328,7 +5328,7 @@ sub exec_event {
my $t1 = time - $t0; my $t1 = time - $t0;
$results->{query_time} = sprintf('%.6f', $t1); $results->{query_time} = sprintf('%.6f', $t1);
$results->{sth} = $sth; $results->{sth} = $sth;
$results->{warnings} = $self->get_warnings(host => $host); $results->{warnings} = $self->get_warnings(dbh => $host->dbh);
}; };
if ( $EVAL_ERROR ) { if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR); PTDEBUG && _d($EVAL_ERROR);
@@ -5341,12 +5341,12 @@ sub exec_event {
sub get_warnings { sub get_warnings {
my ($self, %args) = @_; my ($self, %args) = @_;
my @required_args = qw(host); my @required_args = qw(dbh);
foreach my $arg ( @required_args ) { foreach my $arg ( @required_args ) {
die "I need a $arg argument" unless $args{$arg}; die "I need a $arg argument" unless $args{$arg};
} }
my $host = $args{host}; my $dbh = $args{dbh};
my $warnings = $host->dbh->selectall_hashref('SHOW WARNINGS', 'code'); my $warnings = $dbh->selectall_hashref('SHOW WARNINGS', 'code');
return $warnings; return $warnings;
} }

View File

@@ -82,7 +82,7 @@ sub exec_event {
my $t1 = time - $t0; my $t1 = time - $t0;
$results->{query_time} = sprintf('%.6f', $t1); $results->{query_time} = sprintf('%.6f', $t1);
$results->{sth} = $sth; $results->{sth} = $sth;
$results->{warnings} = $self->get_warnings(host => $host); $results->{warnings} = $self->get_warnings(dbh => $host->dbh);
}; };
if ( $EVAL_ERROR ) { if ( $EVAL_ERROR ) {
PTDEBUG && _d($EVAL_ERROR); PTDEBUG && _d($EVAL_ERROR);
@@ -95,12 +95,12 @@ sub exec_event {
sub get_warnings { sub get_warnings {
my ($self, %args) = @_; my ($self, %args) = @_;
my @required_args = qw(host); my @required_args = qw(dbh);
foreach my $arg ( @required_args ) { foreach my $arg ( @required_args ) {
die "I need a $arg argument" unless $args{$arg}; die "I need a $arg argument" unless $args{$arg};
} }
my $host = $args{host}; my $dbh = $args{dbh};
my $warnings = $host->dbh->selectall_hashref('SHOW WARNINGS', 'code'); my $warnings = $dbh->selectall_hashref('SHOW WARNINGS', 'code');
return $warnings; return $warnings;
} }

View File

@@ -68,16 +68,16 @@ test_diff (
query1 => "select user from mysql.user order by user ASC", query1 => "select user from mysql.user order by user ASC",
query2 => "select user from mysql.user order by user DESC", query2 => "select user from mysql.user order by user DESC",
expect => [ expect => [
{ [
row_number => 1, 1,
sth1_rows => [qw(msandbox)], [qw(msandbox)],
sth2_rows => [qw(root)], [qw(root)],
}, ],
{ [
row_number => 2, 2,
sth1_rows => [qw(root)], [qw(root)],
sth2_rows => [qw(msandbox)], [qw(msandbox)],
} ]
], ],
); );

View File

@@ -39,8 +39,9 @@ sub clear_warnings {
$dbh1->do("INSERT INTO test.t VALUES (2, '', 123456789)"); $dbh1->do("INSERT INTO test.t VALUES (2, '', 123456789)");
$dbh2->do("INSERT INTO test.t VALUES (3, '', 123456789)"); $dbh2->do("INSERT INTO test.t VALUES (3, '', 123456789)");
my $w1 = pt_upgrade::get_warnings(dbh => $dbh1); my $event_exec = EventExecutor->new();
my $w2 = pt_upgrade::get_warnings(dbh => $dbh2); my $w1 = $event_exec->get_warnings(dbh => $dbh1);
my $w2 = $event_exec->get_warnings(dbh => $dbh2);
my $error_1264 = { my $error_1264 = {
code => '1264', code => '1264',
@@ -65,8 +66,8 @@ is_deeply(
) or diag(Dumper($w2)); ) or diag(Dumper($w2));
my $diffs = pt_upgrade::diff_warnings( my $diffs = pt_upgrade::diff_warnings(
host1_warnings => $w1, warnings1 => $w1,
host2_warnings => $w2, warnings2 => $w2,
); );
is_deeply( is_deeply(
@@ -76,17 +77,18 @@ is_deeply(
) or diag(Dumper($diffs)); ) or diag(Dumper($diffs));
$diffs = pt_upgrade::diff_warnings( $diffs = pt_upgrade::diff_warnings(
host1_warnings => {}, warnings1 => {},
host2_warnings => $w2, warnings2 => $w2,
); );
is_deeply( is_deeply(
$diffs, $diffs,
[ [
{ [
host1 => undef, 1264,
host2 => $error_1264, undef,
}, $error_1264,
],
], ],
"host1 doesn't have the warning" "host1 doesn't have the warning"
) or diag(Dumper($diffs)); ) or diag(Dumper($diffs));
@@ -97,8 +99,8 @@ is_deeply(
$diffs = pt_upgrade::diff_warnings( $diffs = pt_upgrade::diff_warnings(
ignore_warnings => { 1264 => 1 }, ignore_warnings => { 1264 => 1 },
host1_warnings => $w1, warnings1 => $w1,
host2_warnings => $w2, warnings2 => $w2,
); );
is_deeply( is_deeply(