Merge lp:~percona-toolkit-dev/percona-toolkit/fix-option-parser-bug-1199589-2.1 into lp:percona-toolkit/2.1

Proposed by Daniel Nichter
Status: Superseded
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-option-parser-bug-1199589-2.1
Merge into: lp:percona-toolkit/2.1
Diff against target: 2615 lines (+1601/-86)
31 files modified
bin/pt-archiver (+51/-1)
bin/pt-config-diff (+51/-1)
bin/pt-deadlock-logger (+51/-1)
bin/pt-diskstats (+51/-1)
bin/pt-duplicate-key-checker (+51/-1)
bin/pt-fifo-split (+51/-1)
bin/pt-find (+51/-1)
bin/pt-fingerprint (+51/-1)
bin/pt-fk-error-logger (+51/-1)
bin/pt-heartbeat (+51/-1)
bin/pt-index-usage (+51/-1)
bin/pt-kill (+51/-1)
bin/pt-log-player (+51/-1)
bin/pt-online-schema-change (+51/-1)
bin/pt-query-advisor (+51/-1)
bin/pt-query-digest (+51/-1)
bin/pt-show-grants (+51/-1)
bin/pt-slave-delay (+51/-1)
bin/pt-slave-find (+51/-1)
bin/pt-slave-restart (+51/-1)
bin/pt-table-checksum (+51/-1)
bin/pt-table-sync (+51/-1)
bin/pt-table-usage (+57/-10)
bin/pt-tcp-model (+51/-1)
bin/pt-trend (+51/-1)
bin/pt-upgrade (+51/-1)
bin/pt-variable-advisor (+51/-1)
bin/pt-visual-explain (+57/-10)
lib/OptionParser.pm (+52/-40)
t/lib/OptionParser.t (+53/-0)
t/pt-archiver/bugs.t (+56/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-option-parser-bug-1199589-2.1
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+180024@code.launchpad.net

This proposal has been superseded by a proposal from 2013-08-14.

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Unmerged revisions

544. By Daniel Nichter

Apply t/pt-archiver/bugs.t.

543. By Daniel Nichter

Update OptionParser in all tools.

542. By Daniel Nichter

Apply fixed OptionParser.pm and tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-archiver'
--- bin/pt-archiver 2013-07-18 17:31:04 +0000
+++ bin/pt-archiver 2013-08-14 00:47:54 +0000
@@ -65,6 +65,7 @@
6565
66use List::Util qw(max);66use List::Util qw(max);
67use Getopt::Long;67use Getopt::Long;
68use Data::Dumper;
6869
69my $POD_link_re = '[LC]<"?([^">]+)"?>';70my $POD_link_re = '[LC]<"?([^">]+)"?>';
7071
@@ -460,11 +461,21 @@
460 my $long = exists $self->{opts}->{$opt} ? $opt461 my $long = exists $self->{opts}->{$opt} ? $opt
461 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}462 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
462 : die "Getopt::Long gave a nonexistent option: $opt";463 : die "Getopt::Long gave a nonexistent option: $opt";
463
464 $opt = $self->{opts}->{$long};464 $opt = $self->{opts}->{$long};
465 if ( $opt->{is_cumulative} ) {465 if ( $opt->{is_cumulative} ) {
466 $opt->{value}++;466 $opt->{value}++;
467 }467 }
468 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
469 my $next_opt = $1;
470 if ( exists $self->{opts}->{$next_opt}
471 || exists $self->{short_opts}->{$next_opt} ) {
472 $self->save_error("--$long requires a string value");
473 return;
474 }
475 else {
476 $opt->{value} = $val;
477 }
478 }
468 else {479 else {
469 $opt->{value} = $val;480 $opt->{value} = $val;
470 }481 }
@@ -1048,6 +1059,45 @@
1048 );1059 );
1049};1060};
10501061
1062sub set_vars {
1063 my ($self, $file) = @_;
1064 $file ||= $self->{file} || __FILE__;
1065
1066 my %user_vars;
1067 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1068 if ( $user_vars ) {
1069 foreach my $var_val ( @$user_vars ) {
1070 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1071 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1072 $user_vars{$var} = {
1073 val => $val,
1074 default => 0,
1075 };
1076 }
1077 }
1078
1079 my %default_vars;
1080 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1081 if ( $default_vars ) {
1082 %default_vars = map {
1083 my $var_val = $_;
1084 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1085 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1086 $var => {
1087 val => $val,
1088 default => 1,
1089 };
1090 } split("\n", $default_vars);
1091 }
1092
1093 my %vars = (
1094 %default_vars, # first the tool's defaults
1095 %user_vars, # then the user's which overwrite the defaults
1096 );
1097 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1098 return \%vars;
1099}
1100
1051sub _d {1101sub _d {
1052 my ($package, undef, $line) = caller 0;1102 my ($package, undef, $line) = caller 0;
1053 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1103 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10541104
=== modified file 'bin/pt-config-diff'
--- bin/pt-config-diff 2013-07-18 17:31:04 +0000
+++ bin/pt-config-diff 2013-08-14 00:47:54 +0000
@@ -64,6 +64,7 @@
6464
65use List::Util qw(max);65use List::Util qw(max);
66use Getopt::Long;66use Getopt::Long;
67use Data::Dumper;
6768
68my $POD_link_re = '[LC]<"?([^">]+)"?>';69my $POD_link_re = '[LC]<"?([^">]+)"?>';
6970
@@ -459,11 +460,21 @@
459 my $long = exists $self->{opts}->{$opt} ? $opt460 my $long = exists $self->{opts}->{$opt} ? $opt
460 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}461 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
461 : die "Getopt::Long gave a nonexistent option: $opt";462 : die "Getopt::Long gave a nonexistent option: $opt";
462
463 $opt = $self->{opts}->{$long};463 $opt = $self->{opts}->{$long};
464 if ( $opt->{is_cumulative} ) {464 if ( $opt->{is_cumulative} ) {
465 $opt->{value}++;465 $opt->{value}++;
466 }466 }
467 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
468 my $next_opt = $1;
469 if ( exists $self->{opts}->{$next_opt}
470 || exists $self->{short_opts}->{$next_opt} ) {
471 $self->save_error("--$long requires a string value");
472 return;
473 }
474 else {
475 $opt->{value} = $val;
476 }
477 }
467 else {478 else {
468 $opt->{value} = $val;479 $opt->{value} = $val;
469 }480 }
@@ -1047,6 +1058,45 @@
1047 );1058 );
1048};1059};
10491060
1061sub set_vars {
1062 my ($self, $file) = @_;
1063 $file ||= $self->{file} || __FILE__;
1064
1065 my %user_vars;
1066 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1067 if ( $user_vars ) {
1068 foreach my $var_val ( @$user_vars ) {
1069 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1070 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1071 $user_vars{$var} = {
1072 val => $val,
1073 default => 0,
1074 };
1075 }
1076 }
1077
1078 my %default_vars;
1079 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1080 if ( $default_vars ) {
1081 %default_vars = map {
1082 my $var_val = $_;
1083 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1084 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1085 $var => {
1086 val => $val,
1087 default => 1,
1088 };
1089 } split("\n", $default_vars);
1090 }
1091
1092 my %vars = (
1093 %default_vars, # first the tool's defaults
1094 %user_vars, # then the user's which overwrite the defaults
1095 );
1096 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1097 return \%vars;
1098}
1099
1050sub _d {1100sub _d {
1051 my ($package, undef, $line) = caller 0;1101 my ($package, undef, $line) = caller 0;
1052 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1102 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10531103
=== modified file 'bin/pt-deadlock-logger'
--- bin/pt-deadlock-logger 2013-07-18 17:31:04 +0000
+++ bin/pt-deadlock-logger 2013-08-14 00:47:54 +0000
@@ -62,6 +62,7 @@
6262
63use List::Util qw(max);63use List::Util qw(max);
64use Getopt::Long;64use Getopt::Long;
65use Data::Dumper;
6566
66my $POD_link_re = '[LC]<"?([^">]+)"?>';67my $POD_link_re = '[LC]<"?([^">]+)"?>';
6768
@@ -457,11 +458,21 @@
457 my $long = exists $self->{opts}->{$opt} ? $opt458 my $long = exists $self->{opts}->{$opt} ? $opt
458 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}459 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
459 : die "Getopt::Long gave a nonexistent option: $opt";460 : die "Getopt::Long gave a nonexistent option: $opt";
460
461 $opt = $self->{opts}->{$long};461 $opt = $self->{opts}->{$long};
462 if ( $opt->{is_cumulative} ) {462 if ( $opt->{is_cumulative} ) {
463 $opt->{value}++;463 $opt->{value}++;
464 }464 }
465 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
466 my $next_opt = $1;
467 if ( exists $self->{opts}->{$next_opt}
468 || exists $self->{short_opts}->{$next_opt} ) {
469 $self->save_error("--$long requires a string value");
470 return;
471 }
472 else {
473 $opt->{value} = $val;
474 }
475 }
465 else {476 else {
466 $opt->{value} = $val;477 $opt->{value} = $val;
467 }478 }
@@ -1045,6 +1056,45 @@
1045 );1056 );
1046};1057};
10471058
1059sub set_vars {
1060 my ($self, $file) = @_;
1061 $file ||= $self->{file} || __FILE__;
1062
1063 my %user_vars;
1064 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1065 if ( $user_vars ) {
1066 foreach my $var_val ( @$user_vars ) {
1067 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1068 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1069 $user_vars{$var} = {
1070 val => $val,
1071 default => 0,
1072 };
1073 }
1074 }
1075
1076 my %default_vars;
1077 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1078 if ( $default_vars ) {
1079 %default_vars = map {
1080 my $var_val = $_;
1081 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1082 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1083 $var => {
1084 val => $val,
1085 default => 1,
1086 };
1087 } split("\n", $default_vars);
1088 }
1089
1090 my %vars = (
1091 %default_vars, # first the tool's defaults
1092 %user_vars, # then the user's which overwrite the defaults
1093 );
1094 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1095 return \%vars;
1096}
1097
1048sub _d {1098sub _d {
1049 my ($package, undef, $line) = caller 0;1099 my ($package, undef, $line) = caller 0;
1050 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1100 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10511101
=== modified file 'bin/pt-diskstats'
--- bin/pt-diskstats 2013-07-18 17:31:04 +0000
+++ bin/pt-diskstats 2013-08-14 00:47:54 +0000
@@ -64,6 +64,7 @@
6464
65use List::Util qw(max);65use List::Util qw(max);
66use Getopt::Long;66use Getopt::Long;
67use Data::Dumper;
6768
68my $POD_link_re = '[LC]<"?([^">]+)"?>';69my $POD_link_re = '[LC]<"?([^">]+)"?>';
6970
@@ -459,11 +460,21 @@
459 my $long = exists $self->{opts}->{$opt} ? $opt460 my $long = exists $self->{opts}->{$opt} ? $opt
460 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}461 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
461 : die "Getopt::Long gave a nonexistent option: $opt";462 : die "Getopt::Long gave a nonexistent option: $opt";
462
463 $opt = $self->{opts}->{$long};463 $opt = $self->{opts}->{$long};
464 if ( $opt->{is_cumulative} ) {464 if ( $opt->{is_cumulative} ) {
465 $opt->{value}++;465 $opt->{value}++;
466 }466 }
467 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
468 my $next_opt = $1;
469 if ( exists $self->{opts}->{$next_opt}
470 || exists $self->{short_opts}->{$next_opt} ) {
471 $self->save_error("--$long requires a string value");
472 return;
473 }
474 else {
475 $opt->{value} = $val;
476 }
477 }
467 else {478 else {
468 $opt->{value} = $val;479 $opt->{value} = $val;
469 }480 }
@@ -1047,6 +1058,45 @@
1047 );1058 );
1048};1059};
10491060
1061sub set_vars {
1062 my ($self, $file) = @_;
1063 $file ||= $self->{file} || __FILE__;
1064
1065 my %user_vars;
1066 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1067 if ( $user_vars ) {
1068 foreach my $var_val ( @$user_vars ) {
1069 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1070 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1071 $user_vars{$var} = {
1072 val => $val,
1073 default => 0,
1074 };
1075 }
1076 }
1077
1078 my %default_vars;
1079 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1080 if ( $default_vars ) {
1081 %default_vars = map {
1082 my $var_val = $_;
1083 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1084 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1085 $var => {
1086 val => $val,
1087 default => 1,
1088 };
1089 } split("\n", $default_vars);
1090 }
1091
1092 my %vars = (
1093 %default_vars, # first the tool's defaults
1094 %user_vars, # then the user's which overwrite the defaults
1095 );
1096 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1097 return \%vars;
1098}
1099
1050sub _d {1100sub _d {
1051 my ($package, undef, $line) = caller 0;1101 my ($package, undef, $line) = caller 0;
1052 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1102 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10531103
=== modified file 'bin/pt-duplicate-key-checker'
--- bin/pt-duplicate-key-checker 2013-07-18 17:31:04 +0000
+++ bin/pt-duplicate-key-checker 2013-08-14 00:47:54 +0000
@@ -979,6 +979,7 @@
979979
980use List::Util qw(max);980use List::Util qw(max);
981use Getopt::Long;981use Getopt::Long;
982use Data::Dumper;
982983
983my $POD_link_re = '[LC]<"?([^">]+)"?>';984my $POD_link_re = '[LC]<"?([^">]+)"?>';
984985
@@ -1374,11 +1375,21 @@
1374 my $long = exists $self->{opts}->{$opt} ? $opt1375 my $long = exists $self->{opts}->{$opt} ? $opt
1375 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}1376 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
1376 : die "Getopt::Long gave a nonexistent option: $opt";1377 : die "Getopt::Long gave a nonexistent option: $opt";
1377
1378 $opt = $self->{opts}->{$long};1378 $opt = $self->{opts}->{$long};
1379 if ( $opt->{is_cumulative} ) {1379 if ( $opt->{is_cumulative} ) {
1380 $opt->{value}++;1380 $opt->{value}++;
1381 }1381 }
1382 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
1383 my $next_opt = $1;
1384 if ( exists $self->{opts}->{$next_opt}
1385 || exists $self->{short_opts}->{$next_opt} ) {
1386 $self->save_error("--$long requires a string value");
1387 return;
1388 }
1389 else {
1390 $opt->{value} = $val;
1391 }
1392 }
1382 else {1393 else {
1383 $opt->{value} = $val;1394 $opt->{value} = $val;
1384 }1395 }
@@ -1962,6 +1973,45 @@
1962 );1973 );
1963};1974};
19641975
1976sub set_vars {
1977 my ($self, $file) = @_;
1978 $file ||= $self->{file} || __FILE__;
1979
1980 my %user_vars;
1981 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1982 if ( $user_vars ) {
1983 foreach my $var_val ( @$user_vars ) {
1984 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1985 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1986 $user_vars{$var} = {
1987 val => $val,
1988 default => 0,
1989 };
1990 }
1991 }
1992
1993 my %default_vars;
1994 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1995 if ( $default_vars ) {
1996 %default_vars = map {
1997 my $var_val = $_;
1998 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1999 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
2000 $var => {
2001 val => $val,
2002 default => 1,
2003 };
2004 } split("\n", $default_vars);
2005 }
2006
2007 my %vars = (
2008 %default_vars, # first the tool's defaults
2009 %user_vars, # then the user's which overwrite the defaults
2010 );
2011 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
2012 return \%vars;
2013}
2014
1965sub _d {2015sub _d {
1966 my ($package, undef, $line) = caller 0;2016 my ($package, undef, $line) = caller 0;
1967 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }2017 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
19682018
=== modified file 'bin/pt-fifo-split'
--- bin/pt-fifo-split 2013-07-18 17:31:04 +0000
+++ bin/pt-fifo-split 2013-08-14 00:47:54 +0000
@@ -36,6 +36,7 @@
3636
37use List::Util qw(max);37use List::Util qw(max);
38use Getopt::Long;38use Getopt::Long;
39use Data::Dumper;
3940
40my $POD_link_re = '[LC]<"?([^">]+)"?>';41my $POD_link_re = '[LC]<"?([^">]+)"?>';
4142
@@ -431,11 +432,21 @@
431 my $long = exists $self->{opts}->{$opt} ? $opt432 my $long = exists $self->{opts}->{$opt} ? $opt
432 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}433 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
433 : die "Getopt::Long gave a nonexistent option: $opt";434 : die "Getopt::Long gave a nonexistent option: $opt";
434
435 $opt = $self->{opts}->{$long};435 $opt = $self->{opts}->{$long};
436 if ( $opt->{is_cumulative} ) {436 if ( $opt->{is_cumulative} ) {
437 $opt->{value}++;437 $opt->{value}++;
438 }438 }
439 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
440 my $next_opt = $1;
441 if ( exists $self->{opts}->{$next_opt}
442 || exists $self->{short_opts}->{$next_opt} ) {
443 $self->save_error("--$long requires a string value");
444 return;
445 }
446 else {
447 $opt->{value} = $val;
448 }
449 }
439 else {450 else {
440 $opt->{value} = $val;451 $opt->{value} = $val;
441 }452 }
@@ -1019,6 +1030,45 @@
1019 );1030 );
1020};1031};
10211032
1033sub set_vars {
1034 my ($self, $file) = @_;
1035 $file ||= $self->{file} || __FILE__;
1036
1037 my %user_vars;
1038 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1039 if ( $user_vars ) {
1040 foreach my $var_val ( @$user_vars ) {
1041 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1042 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1043 $user_vars{$var} = {
1044 val => $val,
1045 default => 0,
1046 };
1047 }
1048 }
1049
1050 my %default_vars;
1051 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1052 if ( $default_vars ) {
1053 %default_vars = map {
1054 my $var_val = $_;
1055 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1056 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1057 $var => {
1058 val => $val,
1059 default => 1,
1060 };
1061 } split("\n", $default_vars);
1062 }
1063
1064 my %vars = (
1065 %default_vars, # first the tool's defaults
1066 %user_vars, # then the user's which overwrite the defaults
1067 );
1068 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1069 return \%vars;
1070}
1071
1022sub _d {1072sub _d {
1023 my ($package, undef, $line) = caller 0;1073 my ($package, undef, $line) = caller 0;
1024 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1074 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10251075
=== modified file 'bin/pt-find'
--- bin/pt-find 2013-07-18 17:31:04 +0000
+++ bin/pt-find 2013-08-14 00:47:54 +0000
@@ -438,6 +438,7 @@
438438
439use List::Util qw(max);439use List::Util qw(max);
440use Getopt::Long;440use Getopt::Long;
441use Data::Dumper;
441442
442my $POD_link_re = '[LC]<"?([^">]+)"?>';443my $POD_link_re = '[LC]<"?([^">]+)"?>';
443444
@@ -833,11 +834,21 @@
833 my $long = exists $self->{opts}->{$opt} ? $opt834 my $long = exists $self->{opts}->{$opt} ? $opt
834 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}835 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
835 : die "Getopt::Long gave a nonexistent option: $opt";836 : die "Getopt::Long gave a nonexistent option: $opt";
836
837 $opt = $self->{opts}->{$long};837 $opt = $self->{opts}->{$long};
838 if ( $opt->{is_cumulative} ) {838 if ( $opt->{is_cumulative} ) {
839 $opt->{value}++;839 $opt->{value}++;
840 }840 }
841 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
842 my $next_opt = $1;
843 if ( exists $self->{opts}->{$next_opt}
844 || exists $self->{short_opts}->{$next_opt} ) {
845 $self->save_error("--$long requires a string value");
846 return;
847 }
848 else {
849 $opt->{value} = $val;
850 }
851 }
841 else {852 else {
842 $opt->{value} = $val;853 $opt->{value} = $val;
843 }854 }
@@ -1421,6 +1432,45 @@
1421 );1432 );
1422};1433};
14231434
1435sub set_vars {
1436 my ($self, $file) = @_;
1437 $file ||= $self->{file} || __FILE__;
1438
1439 my %user_vars;
1440 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1441 if ( $user_vars ) {
1442 foreach my $var_val ( @$user_vars ) {
1443 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1444 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1445 $user_vars{$var} = {
1446 val => $val,
1447 default => 0,
1448 };
1449 }
1450 }
1451
1452 my %default_vars;
1453 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1454 if ( $default_vars ) {
1455 %default_vars = map {
1456 my $var_val = $_;
1457 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1458 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1459 $var => {
1460 val => $val,
1461 default => 1,
1462 };
1463 } split("\n", $default_vars);
1464 }
1465
1466 my %vars = (
1467 %default_vars, # first the tool's defaults
1468 %user_vars, # then the user's which overwrite the defaults
1469 );
1470 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1471 return \%vars;
1472}
1473
1424sub _d {1474sub _d {
1425 my ($package, undef, $line) = caller 0;1475 my ($package, undef, $line) = caller 0;
1426 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1476 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
14271477
=== modified file 'bin/pt-fingerprint'
--- bin/pt-fingerprint 2013-07-18 17:31:04 +0000
+++ bin/pt-fingerprint 2013-08-14 00:47:54 +0000
@@ -37,6 +37,7 @@
3737
38use List::Util qw(max);38use List::Util qw(max);
39use Getopt::Long;39use Getopt::Long;
40use Data::Dumper;
4041
41my $POD_link_re = '[LC]<"?([^">]+)"?>';42my $POD_link_re = '[LC]<"?([^">]+)"?>';
4243
@@ -432,11 +433,21 @@
432 my $long = exists $self->{opts}->{$opt} ? $opt433 my $long = exists $self->{opts}->{$opt} ? $opt
433 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}434 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
434 : die "Getopt::Long gave a nonexistent option: $opt";435 : die "Getopt::Long gave a nonexistent option: $opt";
435
436 $opt = $self->{opts}->{$long};436 $opt = $self->{opts}->{$long};
437 if ( $opt->{is_cumulative} ) {437 if ( $opt->{is_cumulative} ) {
438 $opt->{value}++;438 $opt->{value}++;
439 }439 }
440 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
441 my $next_opt = $1;
442 if ( exists $self->{opts}->{$next_opt}
443 || exists $self->{short_opts}->{$next_opt} ) {
444 $self->save_error("--$long requires a string value");
445 return;
446 }
447 else {
448 $opt->{value} = $val;
449 }
450 }
440 else {451 else {
441 $opt->{value} = $val;452 $opt->{value} = $val;
442 }453 }
@@ -1020,6 +1031,45 @@
1020 );1031 );
1021};1032};
10221033
1034sub set_vars {
1035 my ($self, $file) = @_;
1036 $file ||= $self->{file} || __FILE__;
1037
1038 my %user_vars;
1039 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1040 if ( $user_vars ) {
1041 foreach my $var_val ( @$user_vars ) {
1042 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1043 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1044 $user_vars{$var} = {
1045 val => $val,
1046 default => 0,
1047 };
1048 }
1049 }
1050
1051 my %default_vars;
1052 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1053 if ( $default_vars ) {
1054 %default_vars = map {
1055 my $var_val = $_;
1056 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1057 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1058 $var => {
1059 val => $val,
1060 default => 1,
1061 };
1062 } split("\n", $default_vars);
1063 }
1064
1065 my %vars = (
1066 %default_vars, # first the tool's defaults
1067 %user_vars, # then the user's which overwrite the defaults
1068 );
1069 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1070 return \%vars;
1071}
1072
1023sub _d {1073sub _d {
1024 my ($package, undef, $line) = caller 0;1074 my ($package, undef, $line) = caller 0;
1025 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1075 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10261076
=== modified file 'bin/pt-fk-error-logger'
--- bin/pt-fk-error-logger 2013-07-18 17:31:04 +0000
+++ bin/pt-fk-error-logger 2013-08-14 00:47:54 +0000
@@ -61,6 +61,7 @@
6161
62use List::Util qw(max);62use List::Util qw(max);
63use Getopt::Long;63use Getopt::Long;
64use Data::Dumper;
6465
65my $POD_link_re = '[LC]<"?([^">]+)"?>';66my $POD_link_re = '[LC]<"?([^">]+)"?>';
6667
@@ -456,11 +457,21 @@
456 my $long = exists $self->{opts}->{$opt} ? $opt457 my $long = exists $self->{opts}->{$opt} ? $opt
457 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}458 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
458 : die "Getopt::Long gave a nonexistent option: $opt";459 : die "Getopt::Long gave a nonexistent option: $opt";
459
460 $opt = $self->{opts}->{$long};460 $opt = $self->{opts}->{$long};
461 if ( $opt->{is_cumulative} ) {461 if ( $opt->{is_cumulative} ) {
462 $opt->{value}++;462 $opt->{value}++;
463 }463 }
464 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
465 my $next_opt = $1;
466 if ( exists $self->{opts}->{$next_opt}
467 || exists $self->{short_opts}->{$next_opt} ) {
468 $self->save_error("--$long requires a string value");
469 return;
470 }
471 else {
472 $opt->{value} = $val;
473 }
474 }
464 else {475 else {
465 $opt->{value} = $val;476 $opt->{value} = $val;
466 }477 }
@@ -1044,6 +1055,45 @@
1044 );1055 );
1045};1056};
10461057
1058sub set_vars {
1059 my ($self, $file) = @_;
1060 $file ||= $self->{file} || __FILE__;
1061
1062 my %user_vars;
1063 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1064 if ( $user_vars ) {
1065 foreach my $var_val ( @$user_vars ) {
1066 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1067 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1068 $user_vars{$var} = {
1069 val => $val,
1070 default => 0,
1071 };
1072 }
1073 }
1074
1075 my %default_vars;
1076 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1077 if ( $default_vars ) {
1078 %default_vars = map {
1079 my $var_val = $_;
1080 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1081 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1082 $var => {
1083 val => $val,
1084 default => 1,
1085 };
1086 } split("\n", $default_vars);
1087 }
1088
1089 my %vars = (
1090 %default_vars, # first the tool's defaults
1091 %user_vars, # then the user's which overwrite the defaults
1092 );
1093 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1094 return \%vars;
1095}
1096
1047sub _d {1097sub _d {
1048 my ($package, undef, $line) = caller 0;1098 my ($package, undef, $line) = caller 0;
1049 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1099 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10501100
=== modified file 'bin/pt-heartbeat'
--- bin/pt-heartbeat 2013-07-18 17:31:04 +0000
+++ bin/pt-heartbeat 2013-08-14 00:47:54 +0000
@@ -798,6 +798,7 @@
798798
799use List::Util qw(max);799use List::Util qw(max);
800use Getopt::Long;800use Getopt::Long;
801use Data::Dumper;
801802
802my $POD_link_re = '[LC]<"?([^">]+)"?>';803my $POD_link_re = '[LC]<"?([^">]+)"?>';
803804
@@ -1193,11 +1194,21 @@
1193 my $long = exists $self->{opts}->{$opt} ? $opt1194 my $long = exists $self->{opts}->{$opt} ? $opt
1194 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}1195 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
1195 : die "Getopt::Long gave a nonexistent option: $opt";1196 : die "Getopt::Long gave a nonexistent option: $opt";
1196
1197 $opt = $self->{opts}->{$long};1197 $opt = $self->{opts}->{$long};
1198 if ( $opt->{is_cumulative} ) {1198 if ( $opt->{is_cumulative} ) {
1199 $opt->{value}++;1199 $opt->{value}++;
1200 }1200 }
1201 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
1202 my $next_opt = $1;
1203 if ( exists $self->{opts}->{$next_opt}
1204 || exists $self->{short_opts}->{$next_opt} ) {
1205 $self->save_error("--$long requires a string value");
1206 return;
1207 }
1208 else {
1209 $opt->{value} = $val;
1210 }
1211 }
1201 else {1212 else {
1202 $opt->{value} = $val;1213 $opt->{value} = $val;
1203 }1214 }
@@ -1781,6 +1792,45 @@
1781 );1792 );
1782};1793};
17831794
1795sub set_vars {
1796 my ($self, $file) = @_;
1797 $file ||= $self->{file} || __FILE__;
1798
1799 my %user_vars;
1800 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1801 if ( $user_vars ) {
1802 foreach my $var_val ( @$user_vars ) {
1803 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1804 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1805 $user_vars{$var} = {
1806 val => $val,
1807 default => 0,
1808 };
1809 }
1810 }
1811
1812 my %default_vars;
1813 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1814 if ( $default_vars ) {
1815 %default_vars = map {
1816 my $var_val = $_;
1817 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1818 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1819 $var => {
1820 val => $val,
1821 default => 1,
1822 };
1823 } split("\n", $default_vars);
1824 }
1825
1826 my %vars = (
1827 %default_vars, # first the tool's defaults
1828 %user_vars, # then the user's which overwrite the defaults
1829 );
1830 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1831 return \%vars;
1832}
1833
1784sub _d {1834sub _d {
1785 my ($package, undef, $line) = caller 0;1835 my ($package, undef, $line) = caller 0;
1786 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1836 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
17871837
=== modified file 'bin/pt-index-usage'
--- bin/pt-index-usage 2013-07-18 17:31:04 +0000
+++ bin/pt-index-usage 2013-08-14 00:47:54 +0000
@@ -574,6 +574,7 @@
574574
575use List::Util qw(max);575use List::Util qw(max);
576use Getopt::Long;576use Getopt::Long;
577use Data::Dumper;
577578
578my $POD_link_re = '[LC]<"?([^">]+)"?>';579my $POD_link_re = '[LC]<"?([^">]+)"?>';
579580
@@ -969,11 +970,21 @@
969 my $long = exists $self->{opts}->{$opt} ? $opt970 my $long = exists $self->{opts}->{$opt} ? $opt
970 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}971 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
971 : die "Getopt::Long gave a nonexistent option: $opt";972 : die "Getopt::Long gave a nonexistent option: $opt";
972
973 $opt = $self->{opts}->{$long};973 $opt = $self->{opts}->{$long};
974 if ( $opt->{is_cumulative} ) {974 if ( $opt->{is_cumulative} ) {
975 $opt->{value}++;975 $opt->{value}++;
976 }976 }
977 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
978 my $next_opt = $1;
979 if ( exists $self->{opts}->{$next_opt}
980 || exists $self->{short_opts}->{$next_opt} ) {
981 $self->save_error("--$long requires a string value");
982 return;
983 }
984 else {
985 $opt->{value} = $val;
986 }
987 }
977 else {988 else {
978 $opt->{value} = $val;989 $opt->{value} = $val;
979 }990 }
@@ -1557,6 +1568,45 @@
1557 );1568 );
1558};1569};
15591570
1571sub set_vars {
1572 my ($self, $file) = @_;
1573 $file ||= $self->{file} || __FILE__;
1574
1575 my %user_vars;
1576 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1577 if ( $user_vars ) {
1578 foreach my $var_val ( @$user_vars ) {
1579 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1580 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1581 $user_vars{$var} = {
1582 val => $val,
1583 default => 0,
1584 };
1585 }
1586 }
1587
1588 my %default_vars;
1589 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1590 if ( $default_vars ) {
1591 %default_vars = map {
1592 my $var_val = $_;
1593 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1594 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1595 $var => {
1596 val => $val,
1597 default => 1,
1598 };
1599 } split("\n", $default_vars);
1600 }
1601
1602 my %vars = (
1603 %default_vars, # first the tool's defaults
1604 %user_vars, # then the user's which overwrite the defaults
1605 );
1606 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1607 return \%vars;
1608}
1609
1560sub _d {1610sub _d {
1561 my ($package, undef, $line) = caller 0;1611 my ($package, undef, $line) = caller 0;
1562 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1612 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
15631613
=== modified file 'bin/pt-kill'
--- bin/pt-kill 2013-07-18 17:31:04 +0000
+++ bin/pt-kill 2013-08-14 00:47:54 +0000
@@ -69,6 +69,7 @@
6969
70use List::Util qw(max);70use List::Util qw(max);
71use Getopt::Long;71use Getopt::Long;
72use Data::Dumper;
7273
73my $POD_link_re = '[LC]<"?([^">]+)"?>';74my $POD_link_re = '[LC]<"?([^">]+)"?>';
7475
@@ -464,11 +465,21 @@
464 my $long = exists $self->{opts}->{$opt} ? $opt465 my $long = exists $self->{opts}->{$opt} ? $opt
465 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}466 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
466 : die "Getopt::Long gave a nonexistent option: $opt";467 : die "Getopt::Long gave a nonexistent option: $opt";
467
468 $opt = $self->{opts}->{$long};468 $opt = $self->{opts}->{$long};
469 if ( $opt->{is_cumulative} ) {469 if ( $opt->{is_cumulative} ) {
470 $opt->{value}++;470 $opt->{value}++;
471 }471 }
472 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
473 my $next_opt = $1;
474 if ( exists $self->{opts}->{$next_opt}
475 || exists $self->{short_opts}->{$next_opt} ) {
476 $self->save_error("--$long requires a string value");
477 return;
478 }
479 else {
480 $opt->{value} = $val;
481 }
482 }
472 else {483 else {
473 $opt->{value} = $val;484 $opt->{value} = $val;
474 }485 }
@@ -1052,6 +1063,45 @@
1052 );1063 );
1053};1064};
10541065
1066sub set_vars {
1067 my ($self, $file) = @_;
1068 $file ||= $self->{file} || __FILE__;
1069
1070 my %user_vars;
1071 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1072 if ( $user_vars ) {
1073 foreach my $var_val ( @$user_vars ) {
1074 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1075 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1076 $user_vars{$var} = {
1077 val => $val,
1078 default => 0,
1079 };
1080 }
1081 }
1082
1083 my %default_vars;
1084 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1085 if ( $default_vars ) {
1086 %default_vars = map {
1087 my $var_val = $_;
1088 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1089 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1090 $var => {
1091 val => $val,
1092 default => 1,
1093 };
1094 } split("\n", $default_vars);
1095 }
1096
1097 my %vars = (
1098 %default_vars, # first the tool's defaults
1099 %user_vars, # then the user's which overwrite the defaults
1100 );
1101 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1102 return \%vars;
1103}
1104
1055sub _d {1105sub _d {
1056 my ($package, undef, $line) = caller 0;1106 my ($package, undef, $line) = caller 0;
1057 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1107 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10581108
=== modified file 'bin/pt-log-player'
--- bin/pt-log-player 2013-07-18 17:31:04 +0000
+++ bin/pt-log-player 2013-08-14 00:47:54 +0000
@@ -41,6 +41,7 @@
4141
42use List::Util qw(max);42use List::Util qw(max);
43use Getopt::Long;43use Getopt::Long;
44use Data::Dumper;
4445
45my $POD_link_re = '[LC]<"?([^">]+)"?>';46my $POD_link_re = '[LC]<"?([^">]+)"?>';
4647
@@ -436,11 +437,21 @@
436 my $long = exists $self->{opts}->{$opt} ? $opt437 my $long = exists $self->{opts}->{$opt} ? $opt
437 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}438 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
438 : die "Getopt::Long gave a nonexistent option: $opt";439 : die "Getopt::Long gave a nonexistent option: $opt";
439
440 $opt = $self->{opts}->{$long};440 $opt = $self->{opts}->{$long};
441 if ( $opt->{is_cumulative} ) {441 if ( $opt->{is_cumulative} ) {
442 $opt->{value}++;442 $opt->{value}++;
443 }443 }
444 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
445 my $next_opt = $1;
446 if ( exists $self->{opts}->{$next_opt}
447 || exists $self->{short_opts}->{$next_opt} ) {
448 $self->save_error("--$long requires a string value");
449 return;
450 }
451 else {
452 $opt->{value} = $val;
453 }
454 }
444 else {455 else {
445 $opt->{value} = $val;456 $opt->{value} = $val;
446 }457 }
@@ -1024,6 +1035,45 @@
1024 );1035 );
1025};1036};
10261037
1038sub set_vars {
1039 my ($self, $file) = @_;
1040 $file ||= $self->{file} || __FILE__;
1041
1042 my %user_vars;
1043 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1044 if ( $user_vars ) {
1045 foreach my $var_val ( @$user_vars ) {
1046 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1047 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1048 $user_vars{$var} = {
1049 val => $val,
1050 default => 0,
1051 };
1052 }
1053 }
1054
1055 my %default_vars;
1056 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1057 if ( $default_vars ) {
1058 %default_vars = map {
1059 my $var_val = $_;
1060 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1061 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1062 $var => {
1063 val => $val,
1064 default => 1,
1065 };
1066 } split("\n", $default_vars);
1067 }
1068
1069 my %vars = (
1070 %default_vars, # first the tool's defaults
1071 %user_vars, # then the user's which overwrite the defaults
1072 );
1073 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1074 return \%vars;
1075}
1076
1027sub _d {1077sub _d {
1028 my ($package, undef, $line) = caller 0;1078 my ($package, undef, $line) = caller 0;
1029 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1079 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10301080
=== modified file 'bin/pt-online-schema-change'
--- bin/pt-online-schema-change 2013-07-18 17:31:04 +0000
+++ bin/pt-online-schema-change 2013-08-14 00:47:54 +0000
@@ -77,6 +77,7 @@
7777
78use List::Util qw(max);78use List::Util qw(max);
79use Getopt::Long;79use Getopt::Long;
80use Data::Dumper;
8081
81my $POD_link_re = '[LC]<"?([^">]+)"?>';82my $POD_link_re = '[LC]<"?([^">]+)"?>';
8283
@@ -472,11 +473,21 @@
472 my $long = exists $self->{opts}->{$opt} ? $opt473 my $long = exists $self->{opts}->{$opt} ? $opt
473 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}474 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
474 : die "Getopt::Long gave a nonexistent option: $opt";475 : die "Getopt::Long gave a nonexistent option: $opt";
475
476 $opt = $self->{opts}->{$long};476 $opt = $self->{opts}->{$long};
477 if ( $opt->{is_cumulative} ) {477 if ( $opt->{is_cumulative} ) {
478 $opt->{value}++;478 $opt->{value}++;
479 }479 }
480 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
481 my $next_opt = $1;
482 if ( exists $self->{opts}->{$next_opt}
483 || exists $self->{short_opts}->{$next_opt} ) {
484 $self->save_error("--$long requires a string value");
485 return;
486 }
487 else {
488 $opt->{value} = $val;
489 }
490 }
480 else {491 else {
481 $opt->{value} = $val;492 $opt->{value} = $val;
482 }493 }
@@ -1060,6 +1071,45 @@
1060 );1071 );
1061};1072};
10621073
1074sub set_vars {
1075 my ($self, $file) = @_;
1076 $file ||= $self->{file} || __FILE__;
1077
1078 my %user_vars;
1079 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1080 if ( $user_vars ) {
1081 foreach my $var_val ( @$user_vars ) {
1082 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1083 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1084 $user_vars{$var} = {
1085 val => $val,
1086 default => 0,
1087 };
1088 }
1089 }
1090
1091 my %default_vars;
1092 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1093 if ( $default_vars ) {
1094 %default_vars = map {
1095 my $var_val = $_;
1096 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1097 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1098 $var => {
1099 val => $val,
1100 default => 1,
1101 };
1102 } split("\n", $default_vars);
1103 }
1104
1105 my %vars = (
1106 %default_vars, # first the tool's defaults
1107 %user_vars, # then the user's which overwrite the defaults
1108 );
1109 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1110 return \%vars;
1111}
1112
1063sub _d {1113sub _d {
1064 my ($package, undef, $line) = caller 0;1114 my ($package, undef, $line) = caller 0;
1065 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1115 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10661116
=== modified file 'bin/pt-query-advisor'
--- bin/pt-query-advisor 2013-07-18 17:31:04 +0000
+++ bin/pt-query-advisor 2013-08-14 00:47:54 +0000
@@ -449,6 +449,7 @@
449449
450use List::Util qw(max);450use List::Util qw(max);
451use Getopt::Long;451use Getopt::Long;
452use Data::Dumper;
452453
453my $POD_link_re = '[LC]<"?([^">]+)"?>';454my $POD_link_re = '[LC]<"?([^">]+)"?>';
454455
@@ -844,11 +845,21 @@
844 my $long = exists $self->{opts}->{$opt} ? $opt845 my $long = exists $self->{opts}->{$opt} ? $opt
845 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}846 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
846 : die "Getopt::Long gave a nonexistent option: $opt";847 : die "Getopt::Long gave a nonexistent option: $opt";
847
848 $opt = $self->{opts}->{$long};848 $opt = $self->{opts}->{$long};
849 if ( $opt->{is_cumulative} ) {849 if ( $opt->{is_cumulative} ) {
850 $opt->{value}++;850 $opt->{value}++;
851 }851 }
852 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
853 my $next_opt = $1;
854 if ( exists $self->{opts}->{$next_opt}
855 || exists $self->{short_opts}->{$next_opt} ) {
856 $self->save_error("--$long requires a string value");
857 return;
858 }
859 else {
860 $opt->{value} = $val;
861 }
862 }
852 else {863 else {
853 $opt->{value} = $val;864 $opt->{value} = $val;
854 }865 }
@@ -1432,6 +1443,45 @@
1432 );1443 );
1433};1444};
14341445
1446sub set_vars {
1447 my ($self, $file) = @_;
1448 $file ||= $self->{file} || __FILE__;
1449
1450 my %user_vars;
1451 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1452 if ( $user_vars ) {
1453 foreach my $var_val ( @$user_vars ) {
1454 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1455 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1456 $user_vars{$var} = {
1457 val => $val,
1458 default => 0,
1459 };
1460 }
1461 }
1462
1463 my %default_vars;
1464 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1465 if ( $default_vars ) {
1466 %default_vars = map {
1467 my $var_val = $_;
1468 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1469 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1470 $var => {
1471 val => $val,
1472 default => 1,
1473 };
1474 } split("\n", $default_vars);
1475 }
1476
1477 my %vars = (
1478 %default_vars, # first the tool's defaults
1479 %user_vars, # then the user's which overwrite the defaults
1480 );
1481 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1482 return \%vars;
1483}
1484
1435sub _d {1485sub _d {
1436 my ($package, undef, $line) = caller 0;1486 my ($package, undef, $line) = caller 0;
1437 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1487 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
14381488
=== modified file 'bin/pt-query-digest'
--- bin/pt-query-digest 2013-07-18 17:31:04 +0000
+++ bin/pt-query-digest 2013-08-14 00:47:54 +0000
@@ -593,6 +593,7 @@
593593
594use List::Util qw(max);594use List::Util qw(max);
595use Getopt::Long;595use Getopt::Long;
596use Data::Dumper;
596597
597my $POD_link_re = '[LC]<"?([^">]+)"?>';598my $POD_link_re = '[LC]<"?([^">]+)"?>';
598599
@@ -988,11 +989,21 @@
988 my $long = exists $self->{opts}->{$opt} ? $opt989 my $long = exists $self->{opts}->{$opt} ? $opt
989 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}990 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
990 : die "Getopt::Long gave a nonexistent option: $opt";991 : die "Getopt::Long gave a nonexistent option: $opt";
991
992 $opt = $self->{opts}->{$long};992 $opt = $self->{opts}->{$long};
993 if ( $opt->{is_cumulative} ) {993 if ( $opt->{is_cumulative} ) {
994 $opt->{value}++;994 $opt->{value}++;
995 }995 }
996 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
997 my $next_opt = $1;
998 if ( exists $self->{opts}->{$next_opt}
999 || exists $self->{short_opts}->{$next_opt} ) {
1000 $self->save_error("--$long requires a string value");
1001 return;
1002 }
1003 else {
1004 $opt->{value} = $val;
1005 }
1006 }
996 else {1007 else {
997 $opt->{value} = $val;1008 $opt->{value} = $val;
998 }1009 }
@@ -1576,6 +1587,45 @@
1576 );1587 );
1577};1588};
15781589
1590sub set_vars {
1591 my ($self, $file) = @_;
1592 $file ||= $self->{file} || __FILE__;
1593
1594 my %user_vars;
1595 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1596 if ( $user_vars ) {
1597 foreach my $var_val ( @$user_vars ) {
1598 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1599 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1600 $user_vars{$var} = {
1601 val => $val,
1602 default => 0,
1603 };
1604 }
1605 }
1606
1607 my %default_vars;
1608 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1609 if ( $default_vars ) {
1610 %default_vars = map {
1611 my $var_val = $_;
1612 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1613 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1614 $var => {
1615 val => $val,
1616 default => 1,
1617 };
1618 } split("\n", $default_vars);
1619 }
1620
1621 my %vars = (
1622 %default_vars, # first the tool's defaults
1623 %user_vars, # then the user's which overwrite the defaults
1624 );
1625 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1626 return \%vars;
1627}
1628
1579sub _d {1629sub _d {
1580 my ($package, undef, $line) = caller 0;1630 my ($package, undef, $line) = caller 0;
1581 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1631 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
15821632
=== modified file 'bin/pt-show-grants'
--- bin/pt-show-grants 2013-07-18 17:31:04 +0000
+++ bin/pt-show-grants 2013-08-14 00:47:54 +0000
@@ -37,6 +37,7 @@
3737
38use List::Util qw(max);38use List::Util qw(max);
39use Getopt::Long;39use Getopt::Long;
40use Data::Dumper;
4041
41my $POD_link_re = '[LC]<"?([^">]+)"?>';42my $POD_link_re = '[LC]<"?([^">]+)"?>';
4243
@@ -432,11 +433,21 @@
432 my $long = exists $self->{opts}->{$opt} ? $opt433 my $long = exists $self->{opts}->{$opt} ? $opt
433 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}434 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
434 : die "Getopt::Long gave a nonexistent option: $opt";435 : die "Getopt::Long gave a nonexistent option: $opt";
435
436 $opt = $self->{opts}->{$long};436 $opt = $self->{opts}->{$long};
437 if ( $opt->{is_cumulative} ) {437 if ( $opt->{is_cumulative} ) {
438 $opt->{value}++;438 $opt->{value}++;
439 }439 }
440 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
441 my $next_opt = $1;
442 if ( exists $self->{opts}->{$next_opt}
443 || exists $self->{short_opts}->{$next_opt} ) {
444 $self->save_error("--$long requires a string value");
445 return;
446 }
447 else {
448 $opt->{value} = $val;
449 }
450 }
440 else {451 else {
441 $opt->{value} = $val;452 $opt->{value} = $val;
442 }453 }
@@ -1020,6 +1031,45 @@
1020 );1031 );
1021};1032};
10221033
1034sub set_vars {
1035 my ($self, $file) = @_;
1036 $file ||= $self->{file} || __FILE__;
1037
1038 my %user_vars;
1039 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1040 if ( $user_vars ) {
1041 foreach my $var_val ( @$user_vars ) {
1042 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1043 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1044 $user_vars{$var} = {
1045 val => $val,
1046 default => 0,
1047 };
1048 }
1049 }
1050
1051 my %default_vars;
1052 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1053 if ( $default_vars ) {
1054 %default_vars = map {
1055 my $var_val = $_;
1056 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1057 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1058 $var => {
1059 val => $val,
1060 default => 1,
1061 };
1062 } split("\n", $default_vars);
1063 }
1064
1065 my %vars = (
1066 %default_vars, # first the tool's defaults
1067 %user_vars, # then the user's which overwrite the defaults
1068 );
1069 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1070 return \%vars;
1071}
1072
1023sub _d {1073sub _d {
1024 my ($package, undef, $line) = caller 0;1074 my ($package, undef, $line) = caller 0;
1025 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1075 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10261076
=== modified file 'bin/pt-slave-delay'
--- bin/pt-slave-delay 2013-07-18 17:31:04 +0000
+++ bin/pt-slave-delay 2013-08-14 00:47:54 +0000
@@ -62,6 +62,7 @@
6262
63use List::Util qw(max);63use List::Util qw(max);
64use Getopt::Long;64use Getopt::Long;
65use Data::Dumper;
6566
66my $POD_link_re = '[LC]<"?([^">]+)"?>';67my $POD_link_re = '[LC]<"?([^">]+)"?>';
6768
@@ -457,11 +458,21 @@
457 my $long = exists $self->{opts}->{$opt} ? $opt458 my $long = exists $self->{opts}->{$opt} ? $opt
458 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}459 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
459 : die "Getopt::Long gave a nonexistent option: $opt";460 : die "Getopt::Long gave a nonexistent option: $opt";
460
461 $opt = $self->{opts}->{$long};461 $opt = $self->{opts}->{$long};
462 if ( $opt->{is_cumulative} ) {462 if ( $opt->{is_cumulative} ) {
463 $opt->{value}++;463 $opt->{value}++;
464 }464 }
465 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
466 my $next_opt = $1;
467 if ( exists $self->{opts}->{$next_opt}
468 || exists $self->{short_opts}->{$next_opt} ) {
469 $self->save_error("--$long requires a string value");
470 return;
471 }
472 else {
473 $opt->{value} = $val;
474 }
475 }
465 else {476 else {
466 $opt->{value} = $val;477 $opt->{value} = $val;
467 }478 }
@@ -1045,6 +1056,45 @@
1045 );1056 );
1046};1057};
10471058
1059sub set_vars {
1060 my ($self, $file) = @_;
1061 $file ||= $self->{file} || __FILE__;
1062
1063 my %user_vars;
1064 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1065 if ( $user_vars ) {
1066 foreach my $var_val ( @$user_vars ) {
1067 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1068 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1069 $user_vars{$var} = {
1070 val => $val,
1071 default => 0,
1072 };
1073 }
1074 }
1075
1076 my %default_vars;
1077 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1078 if ( $default_vars ) {
1079 %default_vars = map {
1080 my $var_val = $_;
1081 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1082 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1083 $var => {
1084 val => $val,
1085 default => 1,
1086 };
1087 } split("\n", $default_vars);
1088 }
1089
1090 my %vars = (
1091 %default_vars, # first the tool's defaults
1092 %user_vars, # then the user's which overwrite the defaults
1093 );
1094 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1095 return \%vars;
1096}
1097
1048sub _d {1098sub _d {
1049 my ($package, undef, $line) = caller 0;1099 my ($package, undef, $line) = caller 0;
1050 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1100 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10511101
=== modified file 'bin/pt-slave-find'
--- bin/pt-slave-find 2013-07-18 17:31:04 +0000
+++ bin/pt-slave-find 2013-08-14 00:47:54 +0000
@@ -41,6 +41,7 @@
4141
42use List::Util qw(max);42use List::Util qw(max);
43use Getopt::Long;43use Getopt::Long;
44use Data::Dumper;
4445
45my $POD_link_re = '[LC]<"?([^">]+)"?>';46my $POD_link_re = '[LC]<"?([^">]+)"?>';
4647
@@ -436,11 +437,21 @@
436 my $long = exists $self->{opts}->{$opt} ? $opt437 my $long = exists $self->{opts}->{$opt} ? $opt
437 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}438 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
438 : die "Getopt::Long gave a nonexistent option: $opt";439 : die "Getopt::Long gave a nonexistent option: $opt";
439
440 $opt = $self->{opts}->{$long};440 $opt = $self->{opts}->{$long};
441 if ( $opt->{is_cumulative} ) {441 if ( $opt->{is_cumulative} ) {
442 $opt->{value}++;442 $opt->{value}++;
443 }443 }
444 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
445 my $next_opt = $1;
446 if ( exists $self->{opts}->{$next_opt}
447 || exists $self->{short_opts}->{$next_opt} ) {
448 $self->save_error("--$long requires a string value");
449 return;
450 }
451 else {
452 $opt->{value} = $val;
453 }
454 }
444 else {455 else {
445 $opt->{value} = $val;456 $opt->{value} = $val;
446 }457 }
@@ -1024,6 +1035,45 @@
1024 );1035 );
1025};1036};
10261037
1038sub set_vars {
1039 my ($self, $file) = @_;
1040 $file ||= $self->{file} || __FILE__;
1041
1042 my %user_vars;
1043 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1044 if ( $user_vars ) {
1045 foreach my $var_val ( @$user_vars ) {
1046 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1047 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1048 $user_vars{$var} = {
1049 val => $val,
1050 default => 0,
1051 };
1052 }
1053 }
1054
1055 my %default_vars;
1056 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1057 if ( $default_vars ) {
1058 %default_vars = map {
1059 my $var_val = $_;
1060 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1061 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1062 $var => {
1063 val => $val,
1064 default => 1,
1065 };
1066 } split("\n", $default_vars);
1067 }
1068
1069 my %vars = (
1070 %default_vars, # first the tool's defaults
1071 %user_vars, # then the user's which overwrite the defaults
1072 );
1073 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1074 return \%vars;
1075}
1076
1027sub _d {1077sub _d {
1028 my ($package, undef, $line) = caller 0;1078 my ($package, undef, $line) = caller 0;
1029 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1079 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10301080
=== modified file 'bin/pt-slave-restart'
--- bin/pt-slave-restart 2013-07-18 17:31:04 +0000
+++ bin/pt-slave-restart 2013-08-14 00:47:54 +0000
@@ -189,6 +189,7 @@
189189
190use List::Util qw(max);190use List::Util qw(max);
191use Getopt::Long;191use Getopt::Long;
192use Data::Dumper;
192193
193my $POD_link_re = '[LC]<"?([^">]+)"?>';194my $POD_link_re = '[LC]<"?([^">]+)"?>';
194195
@@ -584,11 +585,21 @@
584 my $long = exists $self->{opts}->{$opt} ? $opt585 my $long = exists $self->{opts}->{$opt} ? $opt
585 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}586 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
586 : die "Getopt::Long gave a nonexistent option: $opt";587 : die "Getopt::Long gave a nonexistent option: $opt";
587
588 $opt = $self->{opts}->{$long};588 $opt = $self->{opts}->{$long};
589 if ( $opt->{is_cumulative} ) {589 if ( $opt->{is_cumulative} ) {
590 $opt->{value}++;590 $opt->{value}++;
591 }591 }
592 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
593 my $next_opt = $1;
594 if ( exists $self->{opts}->{$next_opt}
595 || exists $self->{short_opts}->{$next_opt} ) {
596 $self->save_error("--$long requires a string value");
597 return;
598 }
599 else {
600 $opt->{value} = $val;
601 }
602 }
592 else {603 else {
593 $opt->{value} = $val;604 $opt->{value} = $val;
594 }605 }
@@ -1172,6 +1183,45 @@
1172 );1183 );
1173};1184};
11741185
1186sub set_vars {
1187 my ($self, $file) = @_;
1188 $file ||= $self->{file} || __FILE__;
1189
1190 my %user_vars;
1191 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1192 if ( $user_vars ) {
1193 foreach my $var_val ( @$user_vars ) {
1194 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1195 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1196 $user_vars{$var} = {
1197 val => $val,
1198 default => 0,
1199 };
1200 }
1201 }
1202
1203 my %default_vars;
1204 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1205 if ( $default_vars ) {
1206 %default_vars = map {
1207 my $var_val = $_;
1208 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1209 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1210 $var => {
1211 val => $val,
1212 default => 1,
1213 };
1214 } split("\n", $default_vars);
1215 }
1216
1217 my %vars = (
1218 %default_vars, # first the tool's defaults
1219 %user_vars, # then the user's which overwrite the defaults
1220 );
1221 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1222 return \%vars;
1223}
1224
1175sub _d {1225sub _d {
1176 my ($package, undef, $line) = caller 0;1226 my ($package, undef, $line) = caller 0;
1177 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1227 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
11781228
=== modified file 'bin/pt-table-checksum'
--- bin/pt-table-checksum 2013-07-18 17:31:04 +0000
+++ bin/pt-table-checksum 2013-08-14 00:47:54 +0000
@@ -1762,6 +1762,7 @@
17621762
1763use List::Util qw(max);1763use List::Util qw(max);
1764use Getopt::Long;1764use Getopt::Long;
1765use Data::Dumper;
17651766
1766my $POD_link_re = '[LC]<"?([^">]+)"?>';1767my $POD_link_re = '[LC]<"?([^">]+)"?>';
17671768
@@ -2157,11 +2158,21 @@
2157 my $long = exists $self->{opts}->{$opt} ? $opt2158 my $long = exists $self->{opts}->{$opt} ? $opt
2158 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}2159 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
2159 : die "Getopt::Long gave a nonexistent option: $opt";2160 : die "Getopt::Long gave a nonexistent option: $opt";
2160
2161 $opt = $self->{opts}->{$long};2161 $opt = $self->{opts}->{$long};
2162 if ( $opt->{is_cumulative} ) {2162 if ( $opt->{is_cumulative} ) {
2163 $opt->{value}++;2163 $opt->{value}++;
2164 }2164 }
2165 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
2166 my $next_opt = $1;
2167 if ( exists $self->{opts}->{$next_opt}
2168 || exists $self->{short_opts}->{$next_opt} ) {
2169 $self->save_error("--$long requires a string value");
2170 return;
2171 }
2172 else {
2173 $opt->{value} = $val;
2174 }
2175 }
2165 else {2176 else {
2166 $opt->{value} = $val;2177 $opt->{value} = $val;
2167 }2178 }
@@ -2745,6 +2756,45 @@
2745 );2756 );
2746};2757};
27472758
2759sub set_vars {
2760 my ($self, $file) = @_;
2761 $file ||= $self->{file} || __FILE__;
2762
2763 my %user_vars;
2764 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
2765 if ( $user_vars ) {
2766 foreach my $var_val ( @$user_vars ) {
2767 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
2768 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
2769 $user_vars{$var} = {
2770 val => $val,
2771 default => 0,
2772 };
2773 }
2774 }
2775
2776 my %default_vars;
2777 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
2778 if ( $default_vars ) {
2779 %default_vars = map {
2780 my $var_val = $_;
2781 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
2782 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
2783 $var => {
2784 val => $val,
2785 default => 1,
2786 };
2787 } split("\n", $default_vars);
2788 }
2789
2790 my %vars = (
2791 %default_vars, # first the tool's defaults
2792 %user_vars, # then the user's which overwrite the defaults
2793 );
2794 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
2795 return \%vars;
2796}
2797
2748sub _d {2798sub _d {
2749 my ($package, undef, $line) = caller 0;2799 my ($package, undef, $line) = caller 0;
2750 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }2800 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
27512801
=== modified file 'bin/pt-table-sync'
--- bin/pt-table-sync 2013-07-18 17:31:04 +0000
+++ bin/pt-table-sync 2013-08-14 00:47:54 +0000
@@ -78,6 +78,7 @@
7878
79use List::Util qw(max);79use List::Util qw(max);
80use Getopt::Long;80use Getopt::Long;
81use Data::Dumper;
8182
82my $POD_link_re = '[LC]<"?([^">]+)"?>';83my $POD_link_re = '[LC]<"?([^">]+)"?>';
8384
@@ -473,11 +474,21 @@
473 my $long = exists $self->{opts}->{$opt} ? $opt474 my $long = exists $self->{opts}->{$opt} ? $opt
474 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}475 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
475 : die "Getopt::Long gave a nonexistent option: $opt";476 : die "Getopt::Long gave a nonexistent option: $opt";
476
477 $opt = $self->{opts}->{$long};477 $opt = $self->{opts}->{$long};
478 if ( $opt->{is_cumulative} ) {478 if ( $opt->{is_cumulative} ) {
479 $opt->{value}++;479 $opt->{value}++;
480 }480 }
481 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
482 my $next_opt = $1;
483 if ( exists $self->{opts}->{$next_opt}
484 || exists $self->{short_opts}->{$next_opt} ) {
485 $self->save_error("--$long requires a string value");
486 return;
487 }
488 else {
489 $opt->{value} = $val;
490 }
491 }
481 else {492 else {
482 $opt->{value} = $val;493 $opt->{value} = $val;
483 }494 }
@@ -1061,6 +1072,45 @@
1061 );1072 );
1062};1073};
10631074
1075sub set_vars {
1076 my ($self, $file) = @_;
1077 $file ||= $self->{file} || __FILE__;
1078
1079 my %user_vars;
1080 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1081 if ( $user_vars ) {
1082 foreach my $var_val ( @$user_vars ) {
1083 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1084 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1085 $user_vars{$var} = {
1086 val => $val,
1087 default => 0,
1088 };
1089 }
1090 }
1091
1092 my %default_vars;
1093 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1094 if ( $default_vars ) {
1095 %default_vars = map {
1096 my $var_val = $_;
1097 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1098 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1099 $var => {
1100 val => $val,
1101 default => 1,
1102 };
1103 } split("\n", $default_vars);
1104 }
1105
1106 my %vars = (
1107 %default_vars, # first the tool's defaults
1108 %user_vars, # then the user's which overwrite the defaults
1109 );
1110 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1111 return \%vars;
1112}
1113
1064sub _d {1114sub _d {
1065 my ($package, undef, $line) = caller 0;1115 my ($package, undef, $line) = caller 0;
1066 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1116 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10671117
=== modified file 'bin/pt-table-usage'
--- bin/pt-table-usage 2013-07-18 17:31:04 +0000
+++ bin/pt-table-usage 2013-08-14 00:47:54 +0000
@@ -428,6 +428,7 @@
428428
429use List::Util qw(max);429use List::Util qw(max);
430use Getopt::Long;430use Getopt::Long;
431use Data::Dumper;
431432
432my $POD_link_re = '[LC]<"?([^">]+)"?>';433my $POD_link_re = '[LC]<"?([^">]+)"?>';
433434
@@ -449,7 +450,6 @@
449 'default' => 1,450 'default' => 1,
450 'cumulative' => 1,451 'cumulative' => 1,
451 'negatable' => 1,452 'negatable' => 1,
452 'value_is_optional' => 1,
453 );453 );
454454
455 my $self = {455 my $self = {
@@ -691,10 +691,9 @@
691 $opt->{short} = undef;691 $opt->{short} = undef;
692 }692 }
693693
694 $opt->{is_negatable} = $opt->{spec} =~ m/!/ ? 1 : 0;694 $opt->{is_negatable} = $opt->{spec} =~ m/!/ ? 1 : 0;
695 $opt->{is_cumulative} = $opt->{spec} =~ m/\+/ ? 1 : 0;695 $opt->{is_cumulative} = $opt->{spec} =~ m/\+/ ? 1 : 0;
696 $opt->{optional_value} = $opt->{spec} =~ m/:/ ? 1 : 0;696 $opt->{is_required} = $opt->{desc} =~ m/required/ ? 1 : 0;
697 $opt->{is_required} = $opt->{desc} =~ m/required/ ? 1 : 0;
698697
699 $opt->{group} ||= 'default';698 $opt->{group} ||= 'default';
700 $self->{groups}->{ $opt->{group} }->{$long} = 1;699 $self->{groups}->{ $opt->{group} }->{$long} = 1;
@@ -825,12 +824,22 @@
825 my $long = exists $self->{opts}->{$opt} ? $opt824 my $long = exists $self->{opts}->{$opt} ? $opt
826 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}825 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
827 : die "Getopt::Long gave a nonexistent option: $opt";826 : die "Getopt::Long gave a nonexistent option: $opt";
828
829 $opt = $self->{opts}->{$long};827 $opt = $self->{opts}->{$long};
830 if ( $opt->{is_cumulative} ) {828 if ( $opt->{is_cumulative} ) {
831 $opt->{value}++;829 $opt->{value}++;
832 }830 }
833 elsif ( !($opt->{optional_value} && !$val) ) {831 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
832 my $next_opt = $1;
833 if ( exists $self->{opts}->{$next_opt}
834 || exists $self->{short_opts}->{$next_opt} ) {
835 $self->save_error("--$long requires a string value");
836 return;
837 }
838 else {
839 $opt->{value} = $val;
840 }
841 }
842 else {
834 $opt->{value} = $val;843 $opt->{value} = $val;
835 }844 }
836 $opt->{got} = 1;845 $opt->{got} = 1;
@@ -1210,7 +1219,7 @@
1210 $desc .= ". Optional suffix s=seconds, m=minutes, h=hours, "1219 $desc .= ". Optional suffix s=seconds, m=minutes, h=hours, "
1211 . "d=days; if no suffix, $s is used.";1220 . "d=days; if no suffix, $s is used.";
1212 }1221 }
1213 $desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol})(?:\s+|$)/g);1222 $desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol}(?!\W))(?:\s+|(?<=\W)|$)/g);
1214 $desc =~ s/ +$//mg;1223 $desc =~ s/ +$//mg;
1215 if ( $short ) {1224 if ( $short ) {
1216 $usage .= sprintf(" --%-${maxs}s -%s %s\n", $long, $short, $desc);1225 $usage .= sprintf(" --%-${maxs}s -%s %s\n", $long, $short, $desc);
@@ -1371,12 +1380,11 @@
1371sub _parse_attribs {1380sub _parse_attribs {
1372 my ( $self, $option, $attribs ) = @_;1381 my ( $self, $option, $attribs ) = @_;
1373 my $types = $self->{types};1382 my $types = $self->{types};
1374 my $eq = $attribs->{'value_is_optional'} ? ':' : '=';
1375 return $option1383 return $option
1376 . ($attribs->{'short form'} ? '|' . $attribs->{'short form'} : '' )1384 . ($attribs->{'short form'} ? '|' . $attribs->{'short form'} : '' )
1377 . ($attribs->{'negatable'} ? '!' : '' )1385 . ($attribs->{'negatable'} ? '!' : '' )
1378 . ($attribs->{'cumulative'} ? '+' : '' )1386 . ($attribs->{'cumulative'} ? '+' : '' )
1379 . ($attribs->{'type'} ? $eq . $types->{$attribs->{type}} : '' );1387 . ($attribs->{'type'} ? '=' . $types->{$attribs->{type}} : '' );
1380}1388}
13811389
1382sub _parse_synopsis {1390sub _parse_synopsis {
@@ -1414,6 +1422,45 @@
1414 );1422 );
1415};1423};
14161424
1425sub set_vars {
1426 my ($self, $file) = @_;
1427 $file ||= $self->{file} || __FILE__;
1428
1429 my %user_vars;
1430 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1431 if ( $user_vars ) {
1432 foreach my $var_val ( @$user_vars ) {
1433 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1434 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1435 $user_vars{$var} = {
1436 val => $val,
1437 default => 0,
1438 };
1439 }
1440 }
1441
1442 my %default_vars;
1443 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1444 if ( $default_vars ) {
1445 %default_vars = map {
1446 my $var_val = $_;
1447 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1448 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1449 $var => {
1450 val => $val,
1451 default => 1,
1452 };
1453 } split("\n", $default_vars);
1454 }
1455
1456 my %vars = (
1457 %default_vars, # first the tool's defaults
1458 %user_vars, # then the user's which overwrite the defaults
1459 );
1460 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1461 return \%vars;
1462}
1463
1417sub _d {1464sub _d {
1418 my ($package, undef, $line) = caller 0;1465 my ($package, undef, $line) = caller 0;
1419 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1466 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
14201467
=== modified file 'bin/pt-tcp-model'
--- bin/pt-tcp-model 2013-07-18 17:31:04 +0000
+++ bin/pt-tcp-model 2013-08-14 00:47:54 +0000
@@ -40,6 +40,7 @@
4040
41use List::Util qw(max);41use List::Util qw(max);
42use Getopt::Long;42use Getopt::Long;
43use Data::Dumper;
4344
44my $POD_link_re = '[LC]<"?([^">]+)"?>';45my $POD_link_re = '[LC]<"?([^">]+)"?>';
4546
@@ -435,11 +436,21 @@
435 my $long = exists $self->{opts}->{$opt} ? $opt436 my $long = exists $self->{opts}->{$opt} ? $opt
436 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}437 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
437 : die "Getopt::Long gave a nonexistent option: $opt";438 : die "Getopt::Long gave a nonexistent option: $opt";
438
439 $opt = $self->{opts}->{$long};439 $opt = $self->{opts}->{$long};
440 if ( $opt->{is_cumulative} ) {440 if ( $opt->{is_cumulative} ) {
441 $opt->{value}++;441 $opt->{value}++;
442 }442 }
443 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
444 my $next_opt = $1;
445 if ( exists $self->{opts}->{$next_opt}
446 || exists $self->{short_opts}->{$next_opt} ) {
447 $self->save_error("--$long requires a string value");
448 return;
449 }
450 else {
451 $opt->{value} = $val;
452 }
453 }
443 else {454 else {
444 $opt->{value} = $val;455 $opt->{value} = $val;
445 }456 }
@@ -1023,6 +1034,45 @@
1023 );1034 );
1024};1035};
10251036
1037sub set_vars {
1038 my ($self, $file) = @_;
1039 $file ||= $self->{file} || __FILE__;
1040
1041 my %user_vars;
1042 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1043 if ( $user_vars ) {
1044 foreach my $var_val ( @$user_vars ) {
1045 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1046 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1047 $user_vars{$var} = {
1048 val => $val,
1049 default => 0,
1050 };
1051 }
1052 }
1053
1054 my %default_vars;
1055 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1056 if ( $default_vars ) {
1057 %default_vars = map {
1058 my $var_val = $_;
1059 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1060 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1061 $var => {
1062 val => $val,
1063 default => 1,
1064 };
1065 } split("\n", $default_vars);
1066 }
1067
1068 my %vars = (
1069 %default_vars, # first the tool's defaults
1070 %user_vars, # then the user's which overwrite the defaults
1071 );
1072 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1073 return \%vars;
1074}
1075
1026sub _d {1076sub _d {
1027 my ($package, undef, $line) = caller 0;1077 my ($package, undef, $line) = caller 0;
1028 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1078 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10291079
=== modified file 'bin/pt-trend'
--- bin/pt-trend 2013-07-18 17:31:04 +0000
+++ bin/pt-trend 2013-08-14 00:47:54 +0000
@@ -40,6 +40,7 @@
4040
41use List::Util qw(max);41use List::Util qw(max);
42use Getopt::Long;42use Getopt::Long;
43use Data::Dumper;
4344
44my $POD_link_re = '[LC]<"?([^">]+)"?>';45my $POD_link_re = '[LC]<"?([^">]+)"?>';
4546
@@ -435,11 +436,21 @@
435 my $long = exists $self->{opts}->{$opt} ? $opt436 my $long = exists $self->{opts}->{$opt} ? $opt
436 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}437 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
437 : die "Getopt::Long gave a nonexistent option: $opt";438 : die "Getopt::Long gave a nonexistent option: $opt";
438
439 $opt = $self->{opts}->{$long};439 $opt = $self->{opts}->{$long};
440 if ( $opt->{is_cumulative} ) {440 if ( $opt->{is_cumulative} ) {
441 $opt->{value}++;441 $opt->{value}++;
442 }442 }
443 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
444 my $next_opt = $1;
445 if ( exists $self->{opts}->{$next_opt}
446 || exists $self->{short_opts}->{$next_opt} ) {
447 $self->save_error("--$long requires a string value");
448 return;
449 }
450 else {
451 $opt->{value} = $val;
452 }
453 }
443 else {454 else {
444 $opt->{value} = $val;455 $opt->{value} = $val;
445 }456 }
@@ -1023,6 +1034,45 @@
1023 );1034 );
1024};1035};
10251036
1037sub set_vars {
1038 my ($self, $file) = @_;
1039 $file ||= $self->{file} || __FILE__;
1040
1041 my %user_vars;
1042 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1043 if ( $user_vars ) {
1044 foreach my $var_val ( @$user_vars ) {
1045 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1046 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1047 $user_vars{$var} = {
1048 val => $val,
1049 default => 0,
1050 };
1051 }
1052 }
1053
1054 my %default_vars;
1055 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1056 if ( $default_vars ) {
1057 %default_vars = map {
1058 my $var_val = $_;
1059 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1060 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1061 $var => {
1062 val => $val,
1063 default => 1,
1064 };
1065 } split("\n", $default_vars);
1066 }
1067
1068 my %vars = (
1069 %default_vars, # first the tool's defaults
1070 %user_vars, # then the user's which overwrite the defaults
1071 );
1072 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1073 return \%vars;
1074}
1075
1026sub _d {1076sub _d {
1027 my ($package, undef, $line) = caller 0;1077 my ($package, undef, $line) = caller 0;
1028 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1078 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10291079
=== modified file 'bin/pt-upgrade'
--- bin/pt-upgrade 2013-07-18 17:31:04 +0000
+++ bin/pt-upgrade 2013-08-14 00:47:54 +0000
@@ -998,6 +998,7 @@
998998
999use List::Util qw(max);999use List::Util qw(max);
1000use Getopt::Long;1000use Getopt::Long;
1001use Data::Dumper;
10011002
1002my $POD_link_re = '[LC]<"?([^">]+)"?>';1003my $POD_link_re = '[LC]<"?([^">]+)"?>';
10031004
@@ -1393,11 +1394,21 @@
1393 my $long = exists $self->{opts}->{$opt} ? $opt1394 my $long = exists $self->{opts}->{$opt} ? $opt
1394 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}1395 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
1395 : die "Getopt::Long gave a nonexistent option: $opt";1396 : die "Getopt::Long gave a nonexistent option: $opt";
1396
1397 $opt = $self->{opts}->{$long};1397 $opt = $self->{opts}->{$long};
1398 if ( $opt->{is_cumulative} ) {1398 if ( $opt->{is_cumulative} ) {
1399 $opt->{value}++;1399 $opt->{value}++;
1400 }1400 }
1401 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
1402 my $next_opt = $1;
1403 if ( exists $self->{opts}->{$next_opt}
1404 || exists $self->{short_opts}->{$next_opt} ) {
1405 $self->save_error("--$long requires a string value");
1406 return;
1407 }
1408 else {
1409 $opt->{value} = $val;
1410 }
1411 }
1401 else {1412 else {
1402 $opt->{value} = $val;1413 $opt->{value} = $val;
1403 }1414 }
@@ -1981,6 +1992,45 @@
1981 );1992 );
1982};1993};
19831994
1995sub set_vars {
1996 my ($self, $file) = @_;
1997 $file ||= $self->{file} || __FILE__;
1998
1999 my %user_vars;
2000 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
2001 if ( $user_vars ) {
2002 foreach my $var_val ( @$user_vars ) {
2003 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
2004 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
2005 $user_vars{$var} = {
2006 val => $val,
2007 default => 0,
2008 };
2009 }
2010 }
2011
2012 my %default_vars;
2013 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
2014 if ( $default_vars ) {
2015 %default_vars = map {
2016 my $var_val = $_;
2017 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
2018 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
2019 $var => {
2020 val => $val,
2021 default => 1,
2022 };
2023 } split("\n", $default_vars);
2024 }
2025
2026 my %vars = (
2027 %default_vars, # first the tool's defaults
2028 %user_vars, # then the user's which overwrite the defaults
2029 );
2030 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
2031 return \%vars;
2032}
2033
1984sub _d {2034sub _d {
1985 my ($package, undef, $line) = caller 0;2035 my ($package, undef, $line) = caller 0;
1986 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }2036 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
19872037
=== modified file 'bin/pt-variable-advisor'
--- bin/pt-variable-advisor 2013-07-18 17:31:04 +0000
+++ bin/pt-variable-advisor 2013-08-14 00:47:54 +0000
@@ -66,6 +66,7 @@
6666
67use List::Util qw(max);67use List::Util qw(max);
68use Getopt::Long;68use Getopt::Long;
69use Data::Dumper;
6970
70my $POD_link_re = '[LC]<"?([^">]+)"?>';71my $POD_link_re = '[LC]<"?([^">]+)"?>';
7172
@@ -461,11 +462,21 @@
461 my $long = exists $self->{opts}->{$opt} ? $opt462 my $long = exists $self->{opts}->{$opt} ? $opt
462 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}463 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
463 : die "Getopt::Long gave a nonexistent option: $opt";464 : die "Getopt::Long gave a nonexistent option: $opt";
464
465 $opt = $self->{opts}->{$long};465 $opt = $self->{opts}->{$long};
466 if ( $opt->{is_cumulative} ) {466 if ( $opt->{is_cumulative} ) {
467 $opt->{value}++;467 $opt->{value}++;
468 }468 }
469 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
470 my $next_opt = $1;
471 if ( exists $self->{opts}->{$next_opt}
472 || exists $self->{short_opts}->{$next_opt} ) {
473 $self->save_error("--$long requires a string value");
474 return;
475 }
476 else {
477 $opt->{value} = $val;
478 }
479 }
469 else {480 else {
470 $opt->{value} = $val;481 $opt->{value} = $val;
471 }482 }
@@ -1049,6 +1060,45 @@
1049 );1060 );
1050};1061};
10511062
1063sub set_vars {
1064 my ($self, $file) = @_;
1065 $file ||= $self->{file} || __FILE__;
1066
1067 my %user_vars;
1068 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1069 if ( $user_vars ) {
1070 foreach my $var_val ( @$user_vars ) {
1071 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1072 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1073 $user_vars{$var} = {
1074 val => $val,
1075 default => 0,
1076 };
1077 }
1078 }
1079
1080 my %default_vars;
1081 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1082 if ( $default_vars ) {
1083 %default_vars = map {
1084 my $var_val = $_;
1085 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1086 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1087 $var => {
1088 val => $val,
1089 default => 1,
1090 };
1091 } split("\n", $default_vars);
1092 }
1093
1094 my %vars = (
1095 %default_vars, # first the tool's defaults
1096 %user_vars, # then the user's which overwrite the defaults
1097 );
1098 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1099 return \%vars;
1100}
1101
1052sub _d {1102sub _d {
1053 my ($package, undef, $line) = caller 0;1103 my ($package, undef, $line) = caller 0;
1054 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1104 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
10551105
=== modified file 'bin/pt-visual-explain'
--- bin/pt-visual-explain 2013-07-18 17:31:04 +0000
+++ bin/pt-visual-explain 2013-08-14 00:47:54 +0000
@@ -711,6 +711,7 @@
711711
712use List::Util qw(max);712use List::Util qw(max);
713use Getopt::Long;713use Getopt::Long;
714use Data::Dumper;
714715
715my $POD_link_re = '[LC]<"?([^">]+)"?>';716my $POD_link_re = '[LC]<"?([^">]+)"?>';
716717
@@ -732,7 +733,6 @@
732 'default' => 1,733 'default' => 1,
733 'cumulative' => 1,734 'cumulative' => 1,
734 'negatable' => 1,735 'negatable' => 1,
735 'value_is_optional' => 1,
736 );736 );
737737
738 my $self = {738 my $self = {
@@ -974,10 +974,9 @@
974 $opt->{short} = undef;974 $opt->{short} = undef;
975 }975 }
976976
977 $opt->{is_negatable} = $opt->{spec} =~ m/!/ ? 1 : 0;977 $opt->{is_negatable} = $opt->{spec} =~ m/!/ ? 1 : 0;
978 $opt->{is_cumulative} = $opt->{spec} =~ m/\+/ ? 1 : 0;978 $opt->{is_cumulative} = $opt->{spec} =~ m/\+/ ? 1 : 0;
979 $opt->{optional_value} = $opt->{spec} =~ m/:/ ? 1 : 0;979 $opt->{is_required} = $opt->{desc} =~ m/required/ ? 1 : 0;
980 $opt->{is_required} = $opt->{desc} =~ m/required/ ? 1 : 0;
981980
982 $opt->{group} ||= 'default';981 $opt->{group} ||= 'default';
983 $self->{groups}->{ $opt->{group} }->{$long} = 1;982 $self->{groups}->{ $opt->{group} }->{$long} = 1;
@@ -1108,12 +1107,22 @@
1108 my $long = exists $self->{opts}->{$opt} ? $opt1107 my $long = exists $self->{opts}->{$opt} ? $opt
1109 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}1108 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
1110 : die "Getopt::Long gave a nonexistent option: $opt";1109 : die "Getopt::Long gave a nonexistent option: $opt";
1111
1112 $opt = $self->{opts}->{$long};1110 $opt = $self->{opts}->{$long};
1113 if ( $opt->{is_cumulative} ) {1111 if ( $opt->{is_cumulative} ) {
1114 $opt->{value}++;1112 $opt->{value}++;
1115 }1113 }
1116 elsif ( !($opt->{optional_value} && !$val) ) {1114 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
1115 my $next_opt = $1;
1116 if ( exists $self->{opts}->{$next_opt}
1117 || exists $self->{short_opts}->{$next_opt} ) {
1118 $self->save_error("--$long requires a string value");
1119 return;
1120 }
1121 else {
1122 $opt->{value} = $val;
1123 }
1124 }
1125 else {
1117 $opt->{value} = $val;1126 $opt->{value} = $val;
1118 }1127 }
1119 $opt->{got} = 1;1128 $opt->{got} = 1;
@@ -1493,7 +1502,7 @@
1493 $desc .= ". Optional suffix s=seconds, m=minutes, h=hours, "1502 $desc .= ". Optional suffix s=seconds, m=minutes, h=hours, "
1494 . "d=days; if no suffix, $s is used.";1503 . "d=days; if no suffix, $s is used.";
1495 }1504 }
1496 $desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol})(?:\s+|$)/g);1505 $desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol}(?!\W))(?:\s+|(?<=\W)|$)/g);
1497 $desc =~ s/ +$//mg;1506 $desc =~ s/ +$//mg;
1498 if ( $short ) {1507 if ( $short ) {
1499 $usage .= sprintf(" --%-${maxs}s -%s %s\n", $long, $short, $desc);1508 $usage .= sprintf(" --%-${maxs}s -%s %s\n", $long, $short, $desc);
@@ -1654,12 +1663,11 @@
1654sub _parse_attribs {1663sub _parse_attribs {
1655 my ( $self, $option, $attribs ) = @_;1664 my ( $self, $option, $attribs ) = @_;
1656 my $types = $self->{types};1665 my $types = $self->{types};
1657 my $eq = $attribs->{'value_is_optional'} ? ':' : '=';
1658 return $option1666 return $option
1659 . ($attribs->{'short form'} ? '|' . $attribs->{'short form'} : '' )1667 . ($attribs->{'short form'} ? '|' . $attribs->{'short form'} : '' )
1660 . ($attribs->{'negatable'} ? '!' : '' )1668 . ($attribs->{'negatable'} ? '!' : '' )
1661 . ($attribs->{'cumulative'} ? '+' : '' )1669 . ($attribs->{'cumulative'} ? '+' : '' )
1662 . ($attribs->{'type'} ? $eq . $types->{$attribs->{type}} : '' );1670 . ($attribs->{'type'} ? '=' . $types->{$attribs->{type}} : '' );
1663}1671}
16641672
1665sub _parse_synopsis {1673sub _parse_synopsis {
@@ -1697,6 +1705,45 @@
1697 );1705 );
1698};1706};
16991707
1708sub set_vars {
1709 my ($self, $file) = @_;
1710 $file ||= $self->{file} || __FILE__;
1711
1712 my %user_vars;
1713 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1714 if ( $user_vars ) {
1715 foreach my $var_val ( @$user_vars ) {
1716 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1717 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1718 $user_vars{$var} = {
1719 val => $val,
1720 default => 0,
1721 };
1722 }
1723 }
1724
1725 my %default_vars;
1726 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1727 if ( $default_vars ) {
1728 %default_vars = map {
1729 my $var_val = $_;
1730 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1731 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1732 $var => {
1733 val => $val,
1734 default => 1,
1735 };
1736 } split("\n", $default_vars);
1737 }
1738
1739 my %vars = (
1740 %default_vars, # first the tool's defaults
1741 %user_vars, # then the user's which overwrite the defaults
1742 );
1743 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1744 return \%vars;
1745}
1746
1700sub _d {1747sub _d {
1701 my ($package, undef, $line) = caller 0;1748 my ($package, undef, $line) = caller 0;
1702 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1749 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
17031750
=== modified file 'lib/OptionParser.pm'
--- lib/OptionParser.pm 2013-01-03 00:19:16 +0000
+++ lib/OptionParser.pm 2013-08-14 00:47:54 +0000
@@ -18,45 +18,6 @@
18# OptionParser package18# OptionParser package
19# ###########################################################################19# ###########################################################################
20{20{
21# Package: OptionParser
22# OptionParser parses command line options from a tool's POD. By default
23# it parses a description and usage from the POD's SYNOPSIS section and
24# command line options from the OPTIONS section.
25#
26# The SYNOPSIS section should look like,
27# (start code)
28# =head1 SYNOPSIS
29#
30# Usage: mk-archiver [OPTION...] --source DSN --where WHERE
31#
32# mk-archiver nibbles records from a MySQL table. The --source and --dest
33# arguments use DSN syntax; if COPY is yes, --dest defaults to the key's value
34# from --source.
35#
36# Examples:
37# ...
38# (end code)
39# The key, required parts are the "Usage:" line and the following description
40# paragraph.
41#
42# The OPTIONS section shoud look like,
43# (start code)
44# =head1 OPTIONS
45#
46# Optional rules, one per line.
47#
48# =over
49#
50# =item --analyze
51#
52# type: string
53#
54# Run ANALYZE TABLE afterwards on L<"--source"> and/or L<"--dest">.
55# ect.
56# (end code)
57# The option's full name is given as the "=item". The next, optional para
58# is the option's attributes. And the next, required para is the option's
59# description (the first period-terminated sentence).
60package OptionParser;21package OptionParser;
6122
62use strict;23use strict;
@@ -66,6 +27,7 @@
6627
67use List::Util qw(max);28use List::Util qw(max);
68use Getopt::Long;29use Getopt::Long;
30use Data::Dumper;
6931
70my $POD_link_re = '[LC]<"?([^">]+)"?>';32my $POD_link_re = '[LC]<"?([^">]+)"?>';
7133
@@ -592,12 +554,23 @@
592 my $long = exists $self->{opts}->{$opt} ? $opt554 my $long = exists $self->{opts}->{$opt} ? $opt
593 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}555 : exists $self->{short_opts}->{$opt} ? $self->{short_opts}->{$opt}
594 : die "Getopt::Long gave a nonexistent option: $opt";556 : die "Getopt::Long gave a nonexistent option: $opt";
595
596 # Reassign $opt.557 # Reassign $opt.
597 $opt = $self->{opts}->{$long};558 $opt = $self->{opts}->{$long};
598 if ( $opt->{is_cumulative} ) {559 if ( $opt->{is_cumulative} ) {
599 $opt->{value}++;560 $opt->{value}++;
600 }561 }
562 elsif ( ($opt->{type} || '') eq 's' && $val =~ m/^--?(.+)/ ) {
563 # https://bugs.launchpad.net/percona-toolkit/+bug/1199589
564 my $next_opt = $1;
565 if ( exists $self->{opts}->{$next_opt}
566 || exists $self->{short_opts}->{$next_opt} ) {
567 $self->save_error("--$long requires a string value");
568 return;
569 }
570 else {
571 $opt->{value} = $val;
572 }
573 }
601 else {574 else {
602 $opt->{value} = $val;575 $opt->{value} = $val;
603 }576 }
@@ -1318,6 +1291,45 @@
1318 );1291 );
1319};1292};
13201293
1294sub set_vars {
1295 my ($self, $file) = @_;
1296 $file ||= $self->{file} || __FILE__;
1297
1298 my %user_vars;
1299 my $user_vars = $self->has('set-vars') ? $self->get('set-vars') : undef;
1300 if ( $user_vars ) {
1301 foreach my $var_val ( @$user_vars ) {
1302 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1303 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1304 $user_vars{$var} = {
1305 val => $val,
1306 default => 0,
1307 };
1308 }
1309 }
1310
1311 my %default_vars;
1312 my $default_vars = $self->read_para_after($file, qr/MAGIC_set_vars/);
1313 if ( $default_vars ) {
1314 %default_vars = map {
1315 my $var_val = $_;
1316 my ($var, $val) = $var_val =~ m/([^\s=]+)=(\S+)/;
1317 die "Invalid --set-vars value: $var_val\n" unless $var && defined $val;
1318 $var => {
1319 val => $val,
1320 default => 1,
1321 };
1322 } split("\n", $default_vars);
1323 }
1324
1325 my %vars = (
1326 %default_vars, # first the tool's defaults
1327 %user_vars, # then the user's which overwrite the defaults
1328 );
1329 PTDEBUG && _d('--set-vars:', Dumper(\%vars));
1330 return \%vars;
1331}
1332
1321sub _d {1333sub _d {
1322 my ($package, undef, $line) = caller 0;1334 my ($package, undef, $line) = caller 0;
1323 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }1335 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
13241336
=== modified file 't/lib/OptionParser.t'
--- t/lib/OptionParser.t 2012-11-09 16:31:13 +0000
+++ t/lib/OptionParser.t 2013-08-14 00:47:54 +0000
@@ -2022,6 +2022,59 @@
2022);2022);
20232023
2024# #############################################################################2024# #############################################################################
2025# https://bugs.launchpad.net/percona-toolkit/+bug/1199589
2026# pt-archiver deletes data despite --dry-run
2027# #############################################################################
2028
2029# From the issue: "One problem is that --optimize is not being used correctly:
2030# the option takes an argument: d, s, or ds (see --analyze). The real problem
2031# is that --optimize is consuming the next option, which is --dry-run in this
2032# case. This shouldn't happen; it means the option parser is failing to notice
2033# that --dry-run is not the string val to --optimize but rather an option;
2034# it should catch this and the tool should fail to start with an error like
2035# "--optimize requires a value".
2036
2037@ARGV = qw(--optimize --dry-run --ascend-first --where 1=1 --purge --source localhost);
2038$o = new OptionParser(file => "$trunk/bin/pt-archiver");
2039$o->get_specs();
2040$o->get_opts();
2041
2042$output = output(
2043 sub { $o->usage_or_errors(undef, 1); },
2044);
2045
2046like(
2047 $output,
2048 qr/--optimize requires a string value/,
2049 "String opts don't consume the next opt (bug 1199589)"
2050);
2051
2052is(
2053 $o->get('optimize'),
2054 undef,
2055 "--optimize didn't consume --dry-run (bug 1199589)"
2056);
2057
2058@ARGV = qw(--optimize ds --dry-run --ascend-first --where 1=1 --purge --source localhost);
2059$o->get_opts();
2060
2061$output = output(
2062 sub { $o->usage_or_errors(undef, 1); },
2063);
2064
2065is(
2066 $output,
2067 '',
2068 "String opts still work (bug 1199589)"
2069);
2070
2071is(
2072 $o->get('optimize'),
2073 'ds',
2074 "--optimize got its value (bug 1199589)"
2075);
2076
2077# #############################################################################
2025# Done.2078# Done.
2026# #############################################################################2079# #############################################################################
2027{2080{
20282081
=== added file 't/pt-archiver/bugs.t'
--- t/pt-archiver/bugs.t 1970-01-01 00:00:00 +0000
+++ t/pt-archiver/bugs.t 2013-08-14 00:47:54 +0000
@@ -0,0 +1,56 @@
1#!/usr/bin/env perl
2
3BEGIN {
4 die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5 unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6 unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
7};
8
9use strict;
10use warnings FATAL => 'all';
11use English qw(-no_match_vars);
12use Test::More;
13use Data::Dumper;
14
15use PerconaTest;
16use Sandbox;
17require "$trunk/bin/pt-archiver";
18
19my $dp = new DSNParser(opts=>$dsn_opts);
20my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
21my $master_dbh = $sb->get_dbh_for('master');
22
23if ( !$master_dbh ) {
24 plan skip_all => 'Cannot connect to sandbox master';
25}
26
27my $output;
28my $cnf = "/tmp/12345/my.sandbox.cnf";
29my $cmd = "$trunk/bin/pt-archiver";
30
31$sb->create_dbs($master_dbh, ['test']);
32$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
33
34# ###########################################################################
35# pt-archiver deletes data despite --dry-run
36# https://bugs.launchpad.net/percona-toolkit/+bug/1199589
37# ###########################################################################
38
39my $rows_before = $master_dbh->selectall_arrayref("SELECT * FROM test.table_1 ORDER BY a");
40
41$output = `$cmd --optimize --dry-run --purge --where 1=1 --source D=test,t=table_1,F=$cnf 2>&1`;
42
43my $rows_after = $master_dbh->selectall_arrayref("SELECT * FROM test.table_1 ORDER BY a");
44
45is_deeply(
46 $rows_after,
47 $rows_before,
48 "--optimize does not consume --dry-run (bug 1199589)"
49) or diag(Dumper($rows_after));
50
51# #############################################################################
52# Done.
53# #############################################################################
54$sb->wipe_clean($master_dbh);
55ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
56done_testing;

Subscribers

People subscribed via source and target branches