~percona-toolkit-dev/percona-toolkit/pt-table-checksum-fails-on-BINARY-field-in-PK-1381280

« back to all changes in this revision

Viewing changes to bin/pt-archiver

  • Committer: Brian Fraser
  • Date: 2012-12-12 19:19:06 UTC
  • mto: This revision was merged to the branch mainline in revision 527.
  • Revision ID: brian.fraser@percona.com-20121212191906-yl1wb72dywu4vabt
Update all modules that use Quoter

Show diffs side-by-side

added added

removed removed

Lines of Context:
2589
2589
 
2590
2590
   return $args[0] if @args == 1 && !defined $args[0];
2591
2591
 
2592
 
   die "Cannot serialize multiple values with undef/NULL"
2593
 
      if grep { !defined $_ } @args;
2594
 
 
2595
 
   return join ',', map { quotemeta } @args;
 
2592
   return join ',', map {
 
2593
         my $c = $_;
 
2594
         if ( defined($c) ) {
 
2595
            $c =~ s/([^A-Za-z0-9])/\\$1/g;
 
2596
            $c
 
2597
         }
 
2598
         else {
 
2599
            '\\N'
 
2600
         }
 
2601
      } @args;
2596
2602
}
2597
2603
 
2598
2604
sub deserialize_list {
2614
2620
 
2615
2621
   my @unescaped_parts = map {
2616
2622
      my $part = $_;
2617
 
 
2618
 
      my $char_class = utf8::is_utf8($part)  # If it's a UTF-8 string,
2619
 
                     ? qr/(?=\p{ASCII})\W/   # We only care about non-word
2620
 
                     : qr/(?=\p{ASCII})\W|[\x{80}-\x{FF}]/; # Otherwise,
2621
 
      $part =~ s/\\($char_class)/$1/g;
2622
 
      $part;
 
2623
      if ($part eq '\\N') {
 
2624
         undef
 
2625
      }
 
2626
      else {
 
2627
         $part =~ s/\\([^A-Za-z0-9])/$1/g;
 
2628
         $part;
 
2629
      }
2623
2630
   } @escaped_parts;
2624
 
 
 
2631
   
2625
2632
   return @unescaped_parts;
2626
2633
}
2627
2634