diff --git a/bin/pt-archiver b/bin/pt-archiver index 23e59574..69648fdd 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -39,7 +39,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -1544,16 +1544,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; @@ -2544,12 +2548,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } diff --git a/bin/pt-config-diff b/bin/pt-config-diff index 5dacd027..9a330f2e 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -38,7 +38,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } diff --git a/bin/pt-deadlock-logger b/bin/pt-deadlock-logger index 0c36e487..5a029349 100755 --- a/bin/pt-deadlock-logger +++ b/bin/pt-deadlock-logger @@ -36,7 +36,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -1756,12 +1756,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } diff --git a/bin/pt-diskstats b/bin/pt-diskstats index 0c0a257f..39c18518 100755 --- a/bin/pt-diskstats +++ b/bin/pt-diskstats @@ -38,7 +38,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index cd9f240b..e22fa454 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -39,7 +39,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -90,12 +90,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } @@ -188,16 +194,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; diff --git a/bin/pt-find b/bin/pt-find index 448c90fb..4e4b95f7 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -35,7 +35,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -1488,12 +1488,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } @@ -1586,16 +1592,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; diff --git a/bin/pt-fk-error-logger b/bin/pt-fk-error-logger index 08d30e90..e6fe64b6 100755 --- a/bin/pt-fk-error-logger +++ b/bin/pt-fk-error-logger @@ -35,7 +35,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -1111,12 +1111,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index 64a7ec78..49756217 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -37,7 +37,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -2426,12 +2426,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } @@ -2524,16 +2530,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; diff --git a/bin/pt-index-usage b/bin/pt-index-usage index 192380ba..fa55a5e5 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -45,7 +45,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -473,12 +473,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } @@ -2784,16 +2790,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; diff --git a/bin/pt-kill b/bin/pt-kill index fad8e2be..a9e6d589 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -43,7 +43,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -4149,12 +4149,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index a2aa96f5..1a57c7b7 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -50,7 +50,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } diff --git a/bin/pt-query-advisor b/bin/pt-query-advisor index f488586a..6e8d6f14 100755 --- a/bin/pt-query-advisor +++ b/bin/pt-query-advisor @@ -46,7 +46,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -1499,12 +1499,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } @@ -5286,16 +5292,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 29e0d785..87fe7700 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -64,7 +64,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -492,12 +492,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } @@ -8103,16 +8109,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; diff --git a/bin/pt-slave-delay b/bin/pt-slave-delay index 4e94c9cf..b7b8dc52 100755 --- a/bin/pt-slave-delay +++ b/bin/pt-slave-delay @@ -36,7 +36,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } diff --git a/bin/pt-slave-restart b/bin/pt-slave-restart index f97080e1..c5c816c1 100755 --- a/bin/pt-slave-restart +++ b/bin/pt-slave-restart @@ -37,7 +37,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -88,12 +88,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 771e306e..f6f6cc67 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -53,7 +53,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -3235,7 +3235,6 @@ use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); use Scalar::Util qw(blessed); - use constant { PTDEBUG => $ENV{PTDEBUG} || 0, PERCONA_TOOLKIT_TEST_USE_DSN_NAMES => $ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} || 0, @@ -3508,12 +3507,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } diff --git a/bin/pt-table-sync b/bin/pt-table-sync index 27e6c0be..61251aaa 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -51,7 +51,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } diff --git a/bin/pt-upgrade b/bin/pt-upgrade index 8d1abe3f..9f4d2322 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -58,7 +58,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } @@ -464,16 +464,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; @@ -893,12 +897,18 @@ sub quote_val { sub split_unquote { my ( $self, $db_tbl, $default_db ) = @_; - $db_tbl =~ s/`//g; my ( $db, $tbl ) = split(/[.]/, $db_tbl); if ( !$tbl ) { $tbl = $db; $db = $default_db; } + for ($db, $tbl) { + next unless $_; + s/\A`//; + s/`\z//; + s/``/`/g; + } + return ($db, $tbl); } diff --git a/bin/pt-variable-advisor b/bin/pt-variable-advisor index 15972544..c339ff53 100755 --- a/bin/pt-variable-advisor +++ b/bin/pt-variable-advisor @@ -40,7 +40,7 @@ BEGIN { # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } diff --git a/lib/Percona/Toolkit.pm b/lib/Percona/Toolkit.pm index 86fd6156..37300d4c 100644 --- a/lib/Percona/Toolkit.pm +++ b/lib/Percona/Toolkit.pm @@ -19,7 +19,7 @@ # ########################################################################### { package Percona::Toolkit; -our $VERSION = '2.1.5'; +our $VERSION = '2.1.6'; 1; } diff --git a/t/lib/Percona/Toolkit.t b/t/lib/Percona/Toolkit.t index 9a69cacf..38e2da36 100644 --- a/t/lib/Percona/Toolkit.t +++ b/t/lib/Percona/Toolkit.t @@ -10,11 +10,15 @@ use strict; use warnings FATAL => 'all'; use Test::More; +use IPC::Cmd qw(run can_run); + use PerconaTest; use Percona::Toolkit; my $version = $Percona::Toolkit::VERSION; +my $perl = $^X; + use File::Basename qw(basename); my @vc_tools = grep { chomp; basename($_) =~ /\A[a-z-]+\z/ } glob("$trunk/bin/*"); @@ -28,9 +32,36 @@ foreach my $tool ( @vc_tools ) { $version, "$base --version and Percona::Toolkit::VERSION agree" ); -} -use IPC::Cmd qw(can_run); + # Now let's check that lib/Percona/Toolkit.pm and each tool's + # $Percona::Toolkit::VERSION agree, sow e can avoid the 2.1.4 pt-table-sync + # debacle + open my $tmp_fh, q{<}, $tool or die "$!"; + my $is_perl = scalar(<$tmp_fh>) =~ /perl/; + close $tmp_fh; + + next unless $is_perl; + + my ($success, undef, $full_buf) = + run( + command => [ $perl, '-le', "require q{$tool}; print \$Percona::Toolkit::VERSION"] + ); + + if ( !$success ) { + fail("Failed to get \$Percona::Toolkit::VERSION from $base: $full_buf") + } + else { + chomp(@$full_buf); + my $out = join "", @$full_buf; + if ($out) { + is( + "@$full_buf", + $version, + "$base and lib/Percona/Toolkit.pm agree" + ); + } + } +} my $bzr = can_run('bzr'); SKIP: {