Merged fix-1059732-ptc-hash-functions

This commit is contained in:
Brian Fraser
2012-11-02 01:23:59 -03:00
3 changed files with 20 additions and 2 deletions

View File

@@ -5291,6 +5291,7 @@ sub _get_hash_func {
if ( $EVAL_ERROR && $EVAL_ERROR =~ m/failed: (.*?) at \S+ line/ ) { if ( $EVAL_ERROR && $EVAL_ERROR =~ m/failed: (.*?) at \S+ line/ ) {
$error .= qq{$func cannot be used because "$1"\n}; $error .= qq{$func cannot be used because "$1"\n};
PTDEBUG && _d($func, 'cannot be used because', $1); PTDEBUG && _d($func, 'cannot be used because', $1);
next;
} }
PTDEBUG && _d('Chosen hash func:', $result); PTDEBUG && _d('Chosen hash func:', $result);
return $func; return $func;

View File

@@ -274,7 +274,7 @@ sub _get_hash_func {
} }
my ($dbh) = @args{@required_args}; my ($dbh) = @args{@required_args};
my $o = $self->{OptionParser}; 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') ) { if ( my $func = $o->get('function') ) {
unshift @funcs, $func; unshift @funcs, $func;
@@ -290,11 +290,12 @@ sub _get_hash_func {
if ( $EVAL_ERROR && $EVAL_ERROR =~ m/failed: (.*?) at \S+ line/ ) { if ( $EVAL_ERROR && $EVAL_ERROR =~ m/failed: (.*?) at \S+ line/ ) {
$error .= qq{$func cannot be used because "$1"\n}; $error .= qq{$func cannot be used because "$1"\n};
PTDEBUG && _d($func, 'cannot be used because', $1); PTDEBUG && _d($func, 'cannot be used because', $1);
next;
} }
PTDEBUG && _d('Chosen hash func:', $result); PTDEBUG && _d('Chosen hash func:', $result);
return $func; return $func;
} }
die $error || 'No hash functions (CRC32, MD5, etc.) are available'; die($error || 'No hash functions (CRC32, MD5, etc.) are available');
} }
# Returns how wide/long, in characters, a CRC function is. # Returns how wide/long, in characters, a CRC function is.

View File

@@ -461,6 +461,22 @@ like(
'Dies if all columns are ignored by --columns' 'Dies if all columns are ignored by --columns'
); );
# #############################################################################
# pt-table-checksum doesn't test all hash functions
# https://bugs.launchpad.net/percona-toolkit/+bug/1059732
# #############################################################################
@ARGV = qw(--function FALSEFUNC);
$o->get_opts();
unlike(
$c->_get_hash_func(
dbh => $dbh,
),
qr/FALSEFUNC/,
"_get_hash_func doesn't return failed functions",
);
# ############################################################################ # ############################################################################
# Done. # Done.
# ############################################################################ # ############################################################################