mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 07:30:02 +00:00
Get CRC function once, not per-table.
This commit is contained in:
@@ -3246,37 +3246,34 @@ sub make_chunk_checksum {
|
||||
if ( !$args{dbh} && !($args{func} && $args{crc_width} && $args{crc_type}) ) {
|
||||
die "I need a dbh argument"
|
||||
}
|
||||
|
||||
my ($tbl) = @args{@required_args};
|
||||
my $o = $self->{OptionParser};
|
||||
my $q = $self->{Quoter};
|
||||
my $o = $self->{OptionParser};
|
||||
my $q = $self->{Quoter};
|
||||
|
||||
my $func = $args{func} || $self->_get_hash_func(%args);
|
||||
my $crc_width = $args{crc_width}|| $self->_get_crc_width(%args, func=>$func);
|
||||
my $crc_type = $args{crc_type} || $self->_get_crc_type(%args, func=>$func);
|
||||
my %crc_args = $self->get_crc_args(%args);
|
||||
my $opt_slice;
|
||||
if ( $o->get('optimize-xor') ) {
|
||||
if ( $crc_type !~ m/int$/ ) {
|
||||
$opt_slice = $self->_optimize_xor(%args, func => $func);
|
||||
if ( $crc_args{crc_type} !~ m/int$/ ) {
|
||||
$opt_slice = $self->_optimize_xor(%args, %crc_args);
|
||||
warn "Cannot use --optimize-xor" unless defined $opt_slice;
|
||||
}
|
||||
}
|
||||
MKDEBUG && _d("Checksum strat:", $func, $crc_width, $crc_type, $opt_slice);
|
||||
MKDEBUG && _d("Checksum strat:", Dumper(\%crc_args));
|
||||
|
||||
my $row_checksum = $self->make_row_checksum(
|
||||
%args,
|
||||
func => $func,
|
||||
%crc_args,
|
||||
no_cols => 1
|
||||
);
|
||||
my $crc;
|
||||
if ( $crc_type =~ m/int$/ ) {
|
||||
if ( $crc_args{crc_type} =~ m/int$/ ) {
|
||||
$crc = "COALESCE(LOWER(CONV(BIT_XOR(CAST($row_checksum AS UNSIGNED)), "
|
||||
. "10, 16)), 0)";
|
||||
}
|
||||
else {
|
||||
my $slices = $self->_make_xor_slices(
|
||||
row_checksum => $row_checksum,
|
||||
crc_width => $crc_width
|
||||
%crc_args,
|
||||
);
|
||||
$crc = "COALESCE(LOWER(CONCAT($slices)), 0)";
|
||||
}
|
||||
@@ -3286,6 +3283,18 @@ sub make_chunk_checksum {
|
||||
return $select;
|
||||
}
|
||||
|
||||
sub get_crc_args {
|
||||
my ($self, %args) = @_;
|
||||
my $func = $args{func} || $self->_get_hash_func(%args);
|
||||
my $crc_width = $args{crc_width}|| $self->_get_crc_width(%args, func=>$func);
|
||||
my $crc_type = $args{crc_type} || $self->_get_crc_type(%args, func=>$func);
|
||||
return (
|
||||
func => $func,
|
||||
crc_width => $crc_width,
|
||||
crc_type => $crc_type,
|
||||
);
|
||||
}
|
||||
|
||||
sub _get_hash_func {
|
||||
my ( $self, %args ) = @_;
|
||||
my @required_args = qw(dbh);
|
||||
@@ -4944,6 +4953,7 @@ sub main {
|
||||
# ########################################################################
|
||||
# Checksum query statementn and sths to update the checksum table.
|
||||
# ########################################################################
|
||||
my %crc_args = $rc->get_crc_args(dbh => $dbh);
|
||||
my $checksum_dms = "REPLACE INTO $repl_table "
|
||||
. "(db, tbl, chunk, boundaries, this_cnt, this_crc) "
|
||||
. "SELECT ?, ?, ?, ?,";
|
||||
@@ -5008,7 +5018,11 @@ sub main {
|
||||
# be saved here. print_checksum_results() uses this info.
|
||||
$tbl->{checksum_results}->{exit_status} = 0;
|
||||
|
||||
my $checksum_cols = $rc->make_chunk_checksum(dbh => $dbh, tbl => $tbl);
|
||||
my $checksum_cols = $rc->make_chunk_checksum(
|
||||
dbh => $dbh,
|
||||
tbl => $tbl,
|
||||
%crc_args
|
||||
);
|
||||
my $nibble_iter = new NibbleIterator(
|
||||
dbh => $dbh,
|
||||
tbl => $tbl,
|
||||
|
Reference in New Issue
Block a user