From 0c50d5b1cd824b6c066e9eeb531b77aa3762a026 Mon Sep 17 00:00:00 2001 From: Frank Cizmich Date: Mon, 23 Mar 2015 14:00:01 -0300 Subject: [PATCH] pt-duplicate-key-checker skipped reporting when verbose option on --- bin/pt-duplicate-key-checker | 78 +++++++++---------- t/pt-duplicate-key-checker/basics.t | 6 +- .../samples/simple_dupe_bug_1217013.txt | 4 + 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 6600b7c9..38f31548 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -4972,46 +4972,44 @@ sub main { print_all_keys($keys, $tbl, \%seen_tbl) if $keys; print_all_keys($fks, $tbl, \%seen_tbl) if $fks; } - else { - PTDEBUG && _d('Getting duplicate keys on', - $tbl->{db}, $tbl->{tbl}); - if ( $keys ) { - $dk->get_duplicate_keys( - $keys, - clustered_key => $clustered_key, - tbl_info => $tbl, - callback => \&print_duplicate_key, - %tp_opts, - # get_duplicate_keys() ignores these args but passes them - # to the callback: - dbh => $dbh, - is_fk => 0, - o => $o, - ks => $ks, - tp => $tp, - q => $q, - seen_tbl => \%seen_tbl, - summary => \%summary, - ); - } - if ( $fks ) { - $dk->get_duplicate_fks( - $fks, - tbl_info => $tbl, - callback => \&print_duplicate_key, - %tp_opts, - # get_duplicate_fks() ignores these args but passes them - # to the callback: - dbh => $dbh, - is_fk => 1, - o => $o, - ks => $ks, - tp => $tp, - q => $q, - seen_tbl => \%seen_tbl, - summary => \%summary, - ); - } + PTDEBUG && _d('Getting duplicate keys on', + $tbl->{db}, $tbl->{tbl}); + if ( $keys ) { + $dk->get_duplicate_keys( + $keys, + clustered_key => $clustered_key, + tbl_info => $tbl, + callback => \&print_duplicate_key, + %tp_opts, + # get_duplicate_keys() ignores these args but passes them + # to the callback: + dbh => $dbh, + is_fk => 0, + o => $o, + ks => $ks, + tp => $tp, + q => $q, + seen_tbl => \%seen_tbl, + summary => \%summary, + ); + } + if ( $fks ) { + $dk->get_duplicate_fks( + $fks, + tbl_info => $tbl, + callback => \&print_duplicate_key, + %tp_opts, + # get_duplicate_fks() ignores these args but passes them + # to the callback: + dbh => $dbh, + is_fk => 1, + o => $o, + ks => $ks, + tp => $tp, + q => $q, + seen_tbl => \%seen_tbl, + summary => \%summary, + ); } # Always count Total Keys so print_key_summary won't die diff --git a/t/pt-duplicate-key-checker/basics.t b/t/pt-duplicate-key-checker/basics.t index 3999ee78..ac730a0e 100644 --- a/t/pt-duplicate-key-checker/basics.t +++ b/t/pt-duplicate-key-checker/basics.t @@ -136,14 +136,16 @@ ok( # ############################################################################# # Exact unique dupes # https://bugs.launchpad.net/percona-toolkit/+bug/1217013 +# Also added --verbose option (-v) to test for: +# https://bugs.launchpad.net/percona-toolkit/+bug/1402730 # ############################################################################# $sb->load_file('master', 't/lib/samples/dupekeys/simple_dupe_bug_1217013.sql', 'test'); ok( no_diff( - sub { pt_duplicate_key_checker::main(@args, qw(-t test.domains)) }, - "$sample/simple_dupe_bug_1217013.txt"), + sub { pt_duplicate_key_checker::main(@args, qw(-t test.domains -v)) }, + "$sample/simple_dupe_bug_1217013.txt", keep_output=>1), 'Exact unique dupes (bug 1217013)' ) or diag($test_diff); diff --git a/t/pt-duplicate-key-checker/samples/simple_dupe_bug_1217013.txt b/t/pt-duplicate-key-checker/samples/simple_dupe_bug_1217013.txt index 628b1a61..b8a73b69 100644 --- a/t/pt-duplicate-key-checker/samples/simple_dupe_bug_1217013.txt +++ b/t/pt-duplicate-key-checker/samples/simple_dupe_bug_1217013.txt @@ -2,6 +2,10 @@ # test.domains # ######################################################################## +# unique_key_domain (`domain`) +# domain (`domain`) +# PRIMARY (`id`) + # Uniqueness of domain ignored because unique_key_domain is a duplicate constraint # domain is a duplicate of unique_key_domain # Key definitions: