diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 9761c500..e9777c5d 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -8686,6 +8686,7 @@ sub main { ); PTDEBUG && _d(scalar @$diffs, 'checksum diffs on', $slave->name()); + $diffs = filter_tables_replicate_check_only($diffs, $o); if ( @$diffs ) { $exit_status |= 1; if ( $o->get('quiet') < 2 ) { @@ -9819,6 +9820,30 @@ sub print_checksum_diffs { } } +sub filter_tables_replicate_check_only { + my ($diffs, $o) = @_; + my @filtered_diffs; + + # SchemaIterator has the methdos to filter the dbs & tables, + # but we don't actually need a real iterator beyond that + my $filter = new SchemaIterator( + file_itr => "Fake", + OptionParser => $o, + Quoter => "Quoter", + TableParser => "TableParser", + ); + + for my $diff (@$diffs) { + my ($db, $table) = Quoter->split_unquote($diff->{table}); + next unless $filter->database_is_allowed($db) + && $filter->table_is_allowed($db, $table); + push @filtered_diffs, $diff; + + } + + return \@filtered_diffs; +} + sub check_repl_table { my ( %args ) = @_; my @required_args = qw(dbh repl_table slaves diff --git a/t/pt-table-checksum/bugs.t b/t/pt-table-checksum/bugs.t index f31e6a86..4df741dd 100644 --- a/t/pt-table-checksum/bugs.t +++ b/t/pt-table-checksum/bugs.t @@ -175,6 +175,23 @@ is( "Bug 1030031 (wrong DIFFS): 3 diffs" ); +# ############################################################################# +# pt-table-checksum does't ignore tables for --replicate-check-only +# https://bugs.launchpad.net/percona-toolkit/+bug/1074179 +# ############################################################################# + +$output = output( + sub { pt_table_checksum::main(@args, qw(--replicate-check-only --ignore-tables-regex=t)) }, + stderr => 1, +); + +chomp($output); + +is( + $output, + '', + "Bug 1074179: ignore-tables-regex works with --replicate-check-only" +); # ############################################################################# # pt-table-checksum can crash with --columns if none match # https://bugs.launchpad.net/percona-toolkit/+bug/1016131