mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Fix KeySize to handle key=<key> but key_len=0. Add failing pt-dupe-key-checker test.
This commit is contained in:
@@ -89,7 +89,7 @@ sub get_key_size {
|
||||
# EXPLAIN rows will report only the rows that satisfy the query
|
||||
# using the key, but this is not what we want. We want total table rows.
|
||||
# In other words, we need an EXPLAIN type index, not ref or range.
|
||||
if ( scalar @cols == 1 ) {
|
||||
if ( scalar(@cols) == 1 && !$args{only_eq} ) {
|
||||
push @where_cols, "$cols[0]<>1";
|
||||
}
|
||||
$sql .= join(' OR ', @where_cols);
|
||||
@@ -113,6 +113,22 @@ sub get_key_size {
|
||||
PTDEBUG && _d('MySQL chose key:', $chosen_key, 'len:', $key_len,
|
||||
'rows:', $rows);
|
||||
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1201443
|
||||
if ( $chosen_key && $key_len eq '0' ) {
|
||||
if ( $args{recurse} ) {
|
||||
$self->{error} = "key_len = 0 in EXPLAIN:\n"
|
||||
. _explain_to_text($explain);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
return $self->get_key_size(
|
||||
%args,
|
||||
only_eq => 1,
|
||||
recurse => 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
my $key_size = 0;
|
||||
if ( $key_len && $rows ) {
|
||||
if ( $chosen_key =~ m/,/ && $key_len =~ m/,/ ) {
|
||||
|
Reference in New Issue
Block a user