From d881fa0b35b064bc247917adc521d70b6fe4f64c Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Wed, 14 Sep 2011 10:40:42 -0600 Subject: [PATCH] Change --chunk-size to type size. Make TIME column %.3f. Make OptionParser report invalid sizes. --- bin/pt-table-checksum | 6 +++--- lib/OptionParser.pm | 2 +- t/lib/OptionParser.t | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index a42fe21d..edf1676c 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -5229,7 +5229,7 @@ sub exec_nibble { { my $print_header = 1; -my $line_fmt = "%6s %6s %7s %7s %7s %6s %-s\n"; +my $line_fmt = "%6s %6s %7s %7s %7s %7s %-s\n"; sub print_checksum_results { my (%args) = @_; @@ -5251,7 +5251,7 @@ sub print_checksum_results { $res->{n_rows} || 0, $res->{n_chunks} || 0, $res->{skipped} || 0, - int(time - ($res->{start_time} || 0)), + sprintf('%.3f', time - ($res->{start_time} || 0)), "$tbl->{db}.$tbl->{tbl}"; return; @@ -5928,7 +5928,7 @@ checksumming only a single table, not an entire server. =item --chunk-size -type: string; default: 1000 +type: size; default: 1000 Approximate number of rows or size of data to checksum at a time. Allowable suffixes are k, M, G. diff --git a/lib/OptionParser.pm b/lib/OptionParser.pm index 4b5fbef6..77dced1d 100644 --- a/lib/OptionParser.pm +++ b/lib/OptionParser.pm @@ -1263,7 +1263,7 @@ sub _parse_size { $opt->{value} = ($pre || '') . $num; } else { - $self->save_error("Invalid size for --$opt->{long}"); + $self->save_error("Invalid size for --$opt->{long}: $val"); } return; } diff --git a/t/lib/OptionParser.t b/t/lib/OptionParser.t index 0533b166..dcc78766 100644 --- a/t/lib/OptionParser.t +++ b/t/lib/OptionParser.t @@ -1138,7 +1138,7 @@ is_deeply( $o->get_opts(); is_deeply( $o->errors(), - ['Invalid size for --size'], + ['Invalid size for --size: 5z'], 'Bad size argument sets an error', ); @@ -1958,7 +1958,7 @@ $o = new OptionParser( description => 'OptionParser.t parses command line options.', usage => "$PROGRAM_NAME " ); -$o->get_specs("$trunk/bin/pt-table-checksum"); +$o->get_specs("$trunk/bin/pt-fifo-split"); @ARGV = (); $o->get_opts(); is(