mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-21 18:24:38 +00:00
Merge pull request #861 from hpoettker/PT-2377_table_sync_with_utf8_json
PT-2377 - fixed pt-table-sync for JSON utf8 strings
This commit is contained in:
@@ -324,6 +324,16 @@ sub make_UPDATE {
|
||||
@cols = $self->sort_cols($row);
|
||||
}
|
||||
my $types = $self->{tbl_struct}->{type_for};
|
||||
|
||||
# MySQL uses utf8mb4 for all strings in JSON, but
|
||||
# DBD::mysql does not decode it accordingly
|
||||
foreach my $col ( @cols ) {
|
||||
my $is_json = ($types->{$col} || '') =~ m/json/i;
|
||||
if ( $is_json && defined $row->{$col} ) {
|
||||
utf8::decode($row->{$col});
|
||||
}
|
||||
}
|
||||
|
||||
return "UPDATE $self->{dst_db_tbl} SET "
|
||||
. join(', ', map {
|
||||
my $is_hex = ($types->{$_} || '') =~ m/^0x[0-9a-fA-F]+$/i;
|
||||
@@ -403,6 +413,15 @@ sub make_row {
|
||||
my $q = $self->{Quoter};
|
||||
my $type_for = $self->{tbl_struct}->{type_for};
|
||||
|
||||
# MySQL uses utf8mb4 for all strings in JSON, but
|
||||
# DBD::mysql does not decode it accordingly
|
||||
foreach my $col ( @cols ) {
|
||||
my $is_json = ($type_for->{$col} || '') =~ m/json/i;
|
||||
if ( $is_json && defined $row->{$col} ) {
|
||||
utf8::decode($row->{$col});
|
||||
}
|
||||
}
|
||||
|
||||
return "$verb INTO $self->{dst_db_tbl}("
|
||||
. join(', ', map { $q->quote($_) } @cols)
|
||||
. ') VALUES ('
|
||||
|
Reference in New Issue
Block a user