diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 5f92d279..50feedf8 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -5281,7 +5281,7 @@ sub _get_hash_func { } my ($dbh) = @args{@required_args}; my $o = $self->{OptionParser}; - my @funcs = qw(CRC32 FNV1A_64 FNV_64 MD5 SHA1); + my @funcs = qw(CRC32 FNV1A_64 FNV_64 MURMUR_HASH MD5 SHA1); if ( my $func = $o->get('function') ) { unshift @funcs, $func; @@ -5302,7 +5302,7 @@ sub _get_hash_func { PTDEBUG && _d('Chosen hash func:', $result); return $func; } - die $error || 'No hash functions (CRC32, MD5, etc.) are available'; + die($error || 'No hash functions (CRC32, MD5, etc.) are available'); } sub _get_crc_width { @@ -6782,9 +6782,10 @@ sub _iterate_dbh { } if ( !$self->{db} ) { - do { + while ( @{$self->{dbs}} ) { $self->{db} = shift @{$self->{dbs}}; - } until $self->_resume_from_database($self->{db}); + last if $self->_resume_from_database($self->{db}); + } PTDEBUG && _d('Next database:', $self->{db}); return unless $self->{db}; } diff --git a/lib/SchemaIterator.pm b/lib/SchemaIterator.pm index 3cb320f3..f64d9192 100644 --- a/lib/SchemaIterator.pm +++ b/lib/SchemaIterator.pm @@ -327,9 +327,10 @@ sub _iterate_dbh { } if ( !$self->{db} ) { - do { + while ( @{$self->{dbs}} ) { $self->{db} = shift @{$self->{dbs}}; - } until $self->_resume_from_database($self->{db}); + last if $self->_resume_from_database($self->{db}); + } PTDEBUG && _d('Next database:', $self->{db}); return unless $self->{db}; } diff --git a/t/lib/SchemaIterator.t b/t/lib/SchemaIterator.t index 62ef3f4a..db24fe4a 100644 --- a/t/lib/SchemaIterator.t +++ b/t/lib/SchemaIterator.t @@ -9,7 +9,7 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Test::More tests => 30; +use Test::More; use SchemaIterator; use FileIterator; @@ -77,20 +77,22 @@ sub test_so { my $res = ""; my @objs; - while ( my $obj = $si->next() ) { - if ( $args{return_objs} ) { - push @objs, $obj; - } - else { - if ( $result_file || $args{ddl} ) { - $res .= "$obj->{db}.$obj->{tbl}\n"; - $res .= "$obj->{ddl}\n\n" if $args{ddl} || $tp; + eval { + while ( my $obj = $si->next() ) { + if ( $args{return_objs} ) { + push @objs, $obj; } else { - $res .= "$obj->{db}.$obj->{tbl} "; + if ( $result_file || $args{ddl} ) { + $res .= "$obj->{db}.$obj->{tbl}\n"; + $res .= "$obj->{ddl}\n\n" if $args{ddl} || $tp; + } + else { + $res .= "$obj->{db}.$obj->{tbl} "; + } } } - } + }; return \@objs if $args{return_objs}; @@ -114,6 +116,9 @@ sub test_so { $args{test_name}, ); } + elsif ( $args{lives_ok} ) { + is($EVAL_ERROR, '', $args{test_name}); + } else { is( $res, @@ -406,8 +411,23 @@ test_so( test_name => "Resume from ignored table" ); +# ############################################################################ +# pt-table-checksum v2 fails when --resume + --ignore-database is used +# https://bugs.launchpad.net/percona-toolkit/+bug/911385 +# ############################################################################ + +# Actually, the important bit here si that it doesn't die, not the results. + +test_so( + filters => ['--ignore-databases', 'sakila,mysql'], + result => "", # hack; uses lives_ok instead + lives_ok => 1, + test_name => "Bug 911385: pt-table-checksum v2 fails when --resume + --ignore-database is used" +); + # ############################################################################# # Done. # ############################################################################# ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); +done_testing; exit;