mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
Added warning about size of fulltext keys not being computed, if present. Sort key report by key name for ease of testing.
This commit is contained in:
@@ -4881,7 +4881,7 @@ my $hdr_fmt = "# %-${hdr_width}s\n";
|
|||||||
sub main {
|
sub main {
|
||||||
local @ARGV = @_; # set global ARGV for this package
|
local @ARGV = @_; # set global ARGV for this package
|
||||||
|
|
||||||
my %summary = ( 'Total Indexes' => 0 );
|
my %summary = ( 'items' => {'Total Indexes' => 0} );
|
||||||
my %seen_tbl;
|
my %seen_tbl;
|
||||||
|
|
||||||
my $q = new Quoter();
|
my $q = new Quoter();
|
||||||
@@ -5014,7 +5014,7 @@ sub main {
|
|||||||
|
|
||||||
# Always count Total Keys so print_key_summary won't die
|
# Always count Total Keys so print_key_summary won't die
|
||||||
# because %summary is empty.
|
# because %summary is empty.
|
||||||
$summary{'Total Indexes'} += (scalar keys %$keys)
|
$summary{items}->{'Total Indexes'} += (scalar keys %$keys)
|
||||||
+ (scalar keys %$fks)
|
+ (scalar keys %$fks)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -5042,7 +5042,8 @@ sub print_all_keys {
|
|||||||
printf $hdr_fmt, "$db.$tbl";
|
printf $hdr_fmt, "$db.$tbl";
|
||||||
printf $hdr_fmt, ('#' x $hdr_width);
|
printf $hdr_fmt, ('#' x $hdr_width);
|
||||||
}
|
}
|
||||||
foreach my $key ( values %$keys ) {
|
# Print keys sorted by name (easier to test)
|
||||||
|
foreach my $key ( sort {$a->{name} cmp $b->{name}} values %$keys ) {
|
||||||
print "\n# $key->{name} ($key->{colnames})";
|
print "\n# $key->{name} ($key->{colnames})";
|
||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
@@ -5067,6 +5068,10 @@ sub print_duplicate_key {
|
|||||||
my $summary = $args{summary};
|
my $summary = $args{summary};
|
||||||
my $struct = $tp->parse($args{tbl_info}->{ddl});
|
my $struct = $tp->parse($args{tbl_info}->{ddl});
|
||||||
|
|
||||||
|
if ($dupe->{ddl} =~ /FULLTEXT/) {
|
||||||
|
$summary->{has_fulltext_dupe}++;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !$seen_tbl->{"$db$tbl"}++ ) {
|
if ( !$seen_tbl->{"$db$tbl"}++ ) {
|
||||||
printf $hdr_fmt, ('#' x $hdr_width);
|
printf $hdr_fmt, ('#' x $hdr_width);
|
||||||
printf $hdr_fmt, "$db.$tbl";
|
printf $hdr_fmt, "$db.$tbl";
|
||||||
@@ -5109,7 +5114,7 @@ sub print_duplicate_key {
|
|||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
if ( $o->get('summary') && $summary ) {
|
if ( $o->get('summary') && $summary ) {
|
||||||
$summary->{'Total Duplicate Indexes'} += 1;
|
$summary->{'items'}->{'Total Duplicate Indexes'} += 1;
|
||||||
my ($size, $chosen_key) = $ks->get_key_size(
|
my ($size, $chosen_key) = $ks->get_key_size(
|
||||||
name => $dupe->{key},
|
name => $dupe->{key},
|
||||||
cols => $dupe->{cols},
|
cols => $dupe->{cols},
|
||||||
@@ -5126,7 +5131,7 @@ sub print_duplicate_key {
|
|||||||
$size ||= 0;
|
$size ||= 0;
|
||||||
|
|
||||||
# Create Size Duplicate Keys summary even if there's no valid keys.
|
# Create Size Duplicate Keys summary even if there's no valid keys.
|
||||||
$summary->{'Size Duplicate Indexes'} += $size;
|
$summary->{'items'}->{'Size Duplicate Indexes'} += $size;
|
||||||
|
|
||||||
if ( $size ) {
|
if ( $size ) {
|
||||||
if ( $chosen_key && $chosen_key ne $dupe->{key} ) {
|
if ( $chosen_key && $chosen_key ne $dupe->{key} ) {
|
||||||
@@ -5141,14 +5146,19 @@ sub print_duplicate_key {
|
|||||||
|
|
||||||
sub print_key_summary {
|
sub print_key_summary {
|
||||||
my ( %summary ) = @_;
|
my ( %summary ) = @_;
|
||||||
|
my $items = $summary{items};
|
||||||
printf $hdr_fmt, ('#' x $hdr_width);
|
printf $hdr_fmt, ('#' x $hdr_width);
|
||||||
printf $hdr_fmt, 'Summary of indexes';
|
printf $hdr_fmt, 'Summary of indexes';
|
||||||
printf $hdr_fmt, ('#' x $hdr_width);
|
printf $hdr_fmt, ('#' x $hdr_width);
|
||||||
print "\n";
|
print "\n";
|
||||||
my $max_item = max(map { length($_) } keys %summary);
|
my $max_item = max(map { length($_) } keys %$items);
|
||||||
my $line_fmt = "# %-${max_item}s %-s\n";
|
my $line_fmt = "# %-${max_item}s %-s";
|
||||||
foreach my $item ( sort keys %summary ) {
|
foreach my $item ( sort keys %$items ) {
|
||||||
printf $line_fmt, $item, $summary{$item};
|
printf $line_fmt, $item, $items->{$item};
|
||||||
|
if ( $item eq 'Size Duplicate Indexes' && $summary{has_fulltext_dupe} ) {
|
||||||
|
print ' (not including FULLTEXT indexes)';
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -136,8 +136,6 @@ ok(
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Exact unique dupes
|
# Exact unique dupes
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1217013
|
# 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');
|
$sb->load_file('master', 't/lib/samples/dupekeys/simple_dupe_bug_1217013.sql', 'test');
|
||||||
@@ -149,6 +147,19 @@ ok(
|
|||||||
'Exact unique dupes (bug 1217013)'
|
'Exact unique dupes (bug 1217013)'
|
||||||
) or diag($test_diff);
|
) or diag($test_diff);
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Same thing, but added --verbose option to test for:
|
||||||
|
# https://bugs.launchpad.net/percona-toolkit/+bug/1402730
|
||||||
|
# #############################################################################
|
||||||
|
|
||||||
|
ok(
|
||||||
|
no_diff(
|
||||||
|
sub { pt_duplicate_key_checker::main(@args, qw(-t test.domains --verbose)) },
|
||||||
|
"$sample/simple_dupe_bug_1217013.txt", keep_output=>1),
|
||||||
|
q[--verbose option doesn't skip dupes reporting (bug 1402730)]
|
||||||
|
) or diag($test_diff);
|
||||||
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
# test.domains
|
# test.domains
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
|
|
||||||
# unique_key_domain (`domain`)
|
|
||||||
# domain (`domain`)
|
|
||||||
# PRIMARY (`id`)
|
# PRIMARY (`id`)
|
||||||
|
# domain (`domain`)
|
||||||
|
# unique_key_domain (`domain`)
|
||||||
|
|
||||||
# Uniqueness of domain ignored because unique_key_domain is a duplicate constraint
|
# Uniqueness of domain ignored because unique_key_domain is a duplicate constraint
|
||||||
# domain is a duplicate of unique_key_domain
|
# domain is a duplicate of unique_key_domain
|
||||||
|
Reference in New Issue
Block a user