PT-136 pt-table-checksum shows diffs when table has columns with different collation/charset

This commit is contained in:
Carlos Salguero
2017-05-25 17:59:25 -03:00
parent c6b5c14776
commit bd6e381494
7 changed files with 81 additions and 8 deletions

View File

@@ -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;