~percona-toolkit-dev/percona-toolkit/fix-zombie-bug-919819

« back to all changes in this revision

Viewing changes to lib/Transformers.pm

  • Committer: Daniel Nichter
  • Date: 2012-01-19 19:46:56 UTC
  • Revision ID: daniel@percona.com-20120119194656-3l1nzgtq1p7xvigo
Replace MKDEBUG with PTDEBUG in modules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
use strict;
26
26
use warnings FATAL => 'all';
27
27
use English qw(-no_match_vars);
28
 
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
 
28
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
29
29
 
30
30
use Time::Local qw(timegm timelocal);
31
31
use Digest::MD5 qw(md5_hex);
230
230
         : $suffix eq 'h' ? $n * 3600     # Hours
231
231
         : $suffix eq 'd' ? $n * 86400    # Days
232
232
         :                  $n;           # default: Seconds
233
 
      MKDEBUG && _d('ts is now - N[shmd]:', $n);
 
233
      PTDEBUG && _d('ts is now - N[shmd]:', $n);
234
234
      return time - $n;
235
235
   }
236
236
   elsif ( $val =~ m/^\d{9,}/ ) {
237
237
      # unix timestamp 100000000 is roughly March, 1973, so older
238
238
      # dates won't be caught here; they'll probably be mistaken
239
239
      # for a MySQL slow log timestamp.
240
 
      MKDEBUG && _d('ts is already a unix timestamp');
 
240
      PTDEBUG && _d('ts is already a unix timestamp');
241
241
      return $val;
242
242
   }
243
243
   elsif ( my ($ymd, $hms) = $val =~ m/^(\d{6})(?:\s+(\d+:\d+:\d+))?/ ) {
244
 
      MKDEBUG && _d('ts is MySQL slow log timestamp');
 
244
      PTDEBUG && _d('ts is MySQL slow log timestamp');
245
245
      $val .= ' 00:00:00' unless $hms;
246
246
      return unix_timestamp(parse_timestamp($val));
247
247
   }
248
248
   elsif ( ($ymd, $hms) = $val =~ m/^(\d{4}-\d\d-\d\d)(?:[T ](\d+:\d+:\d+))?/) {
249
 
      MKDEBUG && _d('ts is properly formatted timestamp');
 
249
      PTDEBUG && _d('ts is properly formatted timestamp');
250
250
      $val .= ' 00:00:00' unless $hms;
251
251
      return unix_timestamp($val);
252
252
   }
253
253
   else {
254
 
      MKDEBUG && _d('ts is MySQL expression');
 
254
      PTDEBUG && _d('ts is MySQL expression');
255
255
      return $callback->($val) if $callback && ref $callback eq 'CODE';
256
256
   }
257
257
 
258
 
   MKDEBUG && _d('Unknown ts type:', $val);
 
258
   PTDEBUG && _d('Unknown ts type:', $val);
259
259
   return;
260
260
}
261
261
 
263
263
sub make_checksum {
264
264
   my ( $val ) = @_;
265
265
   my $checksum = uc substr(md5_hex($val), -16);
266
 
   MKDEBUG && _d($checksum, 'checksum for', $val);
 
266
   PTDEBUG && _d($checksum, 'checksum for', $val);
267
267
   return $checksum;
268
268
}
269
269