mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-07 12:58:45 +00:00
PT-136 pt-table-checksum shows diffs when table has columns with different collation/charset
This commit is contained in:
@@ -5831,17 +5831,29 @@ sub make_row_checksum {
|
||||
$sep =~ s/'//g;
|
||||
$sep ||= '#';
|
||||
|
||||
my @converted_cols;
|
||||
for my $col(@{$cols->{select}}) {
|
||||
my $colname = $col;
|
||||
$colname =~ s/`//g;
|
||||
my $type = $tbl_struct->{type_for}->{$colname} || '';
|
||||
if ($type =~ m/^(CHAR|VARCHAR|BINARY|VARBINARY|BLOB|TEXT|ENUM|SET|JSON)$/i) {
|
||||
push @converted_cols, "convert($col using utf8mb4)";
|
||||
} else {
|
||||
push @converted_cols, "$col";
|
||||
}
|
||||
}
|
||||
|
||||
my @nulls = grep { $cols->{allowed}->{$_} } @{$tbl_struct->{null_cols}};
|
||||
if ( @nulls ) {
|
||||
my $bitmap = "CONCAT("
|
||||
. join(', ', map { 'ISNULL(' . $q->quote($_) . ')' } @nulls)
|
||||
. ")";
|
||||
push @{$cols->{select}}, $bitmap;
|
||||
push @converted_cols, $bitmap;
|
||||
}
|
||||
|
||||
$query .= @{$cols->{select}} > 1
|
||||
? "$func(CONCAT_WS('$sep', " . join(', ', @{$cols->{select}}) . '))'
|
||||
: "$func($cols->{select}->[0])";
|
||||
$query .= scalar @converted_cols > 1
|
||||
? "$func(CONCAT_WS('$sep', " . join(', ', @converted_cols) . '))'
|
||||
: "$func($converted_cols[0])";
|
||||
}
|
||||
else {
|
||||
my $fnv_func = uc $func;
|
||||
|
Reference in New Issue
Block a user