From 6eee6ac6f604bec56af07720683f70bafe53de31 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Mon, 27 Aug 2012 22:30:48 -0300 Subject: [PATCH] Update the rest of the modules to use the updated version_check --- bin/pt-archiver | 2 +- bin/pt-config-diff | 5 ++++- bin/pt-deadlock-logger | 5 ++++- bin/pt-duplicate-key-checker | 2 +- bin/pt-find | 2 +- bin/pt-fk-error-logger | 5 ++++- bin/pt-heartbeat | 2 +- bin/pt-index-usage | 8 ++++++-- bin/pt-kill | 4 +++- bin/pt-online-schema-change | 17 ++++++++++------- bin/pt-query-advisor | 10 +++++++--- bin/pt-query-digest | 12 +++++++++--- bin/pt-slave-delay | 8 +++++++- bin/pt-slave-restart | 16 +++++++++------- bin/pt-table-sync | 9 ++++++++- bin/pt-upgrade | 4 +++- bin/pt-variable-advisor | 8 +++++--- 17 files changed, 83 insertions(+), 36 deletions(-) diff --git a/bin/pt-archiver b/bin/pt-archiver index 8fb703a8..687127a1 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -5393,7 +5393,7 @@ sub main { if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( { dbh => $src->{dbh}, dsn => $src->{dsn} }, - ( $dst ? { dbh => $dst->{dbh}, dsn => $dst->{dsn} } : () ) + ( $dst ? { dbh => $dst->{dbh}, dsn => $dst->{dsn} } : () ), ); } diff --git a/bin/pt-config-diff b/bin/pt-config-diff index 87a2bddf..21fa8356 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -4050,6 +4050,7 @@ sub main { push @configs, new MySQLConfig( dbh => $cxn->dbh(), + dsn => $cxn->dsn(), %common_modules, ); push @config_names, $cxn->name(); @@ -4075,7 +4076,9 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($configs[0]->{dbh}); + Pingback::version_check( + map { +{ dbh => $_->{dbh}, dsn => $_->{dsn} } } @configs + ); } # ######################################################################### diff --git a/bin/pt-deadlock-logger b/bin/pt-deadlock-logger index f6319130..6ab6a5c6 100755 --- a/bin/pt-deadlock-logger +++ b/bin/pt-deadlock-logger @@ -3600,7 +3600,10 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check( + { dbh => $dbh, dsn => $source_dsn }, + ($dest_dsn ? { dbh => $dest_dsn, dsn => $dest_dsn } : ()), + ); } # ######################################################################## diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 24875c4f..d81b287d 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -4453,7 +4453,7 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check({dbh => $dbh, dsn => $dsn}); } # ####################################################################### diff --git a/bin/pt-find b/bin/pt-find index b3ce0303..49f3cef3 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -3621,7 +3621,7 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check({dbh => $dbh, dsn => $dsn}); } # ######################################################################## diff --git a/bin/pt-fk-error-logger b/bin/pt-fk-error-logger index a59179f6..7cccdfa1 100755 --- a/bin/pt-fk-error-logger +++ b/bin/pt-fk-error-logger @@ -3245,7 +3245,10 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check( + { dbh => $dbh, dsn => $src_dsn }, + ($dst_dbh ? { dbh => $dst_dbh, dsn => $dst_dsn } : ()), + ); } # ######################################################################## diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index b696ec3d..190ff378 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -4741,7 +4741,7 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check({dbh => $dbh, dsn => $dsn}); } # ######################################################################## diff --git a/bin/pt-index-usage b/bin/pt-index-usage index aac66de0..7b343318 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -5951,6 +5951,7 @@ sub main { # but get_cxn() required a defined dsn arg so use an empty hashref. # ########################################################################## my ($dbh, $si_dbh, $res_dbh); + my $res_dsn; my $res_db; eval { my $dsn = $dp->parse_options($o) || {}; @@ -5971,7 +5972,7 @@ sub main { ); # dbh for --save-results-database - if ( my $res_dsn = $o->get('save-results-database') ) { + if ( $res_dsn = $o->get('save-results-database') ) { # To make --create-save-results-database work we have to # temporarily remove the D from the DSN to avoid the error @@ -6084,7 +6085,10 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check( + { dbh => $dbh, dsn => $dsn }, + ($res_dbh ? { dbh => $res_dbh, dsn => $res_dsn } : ()), + ); } # ######################################################################## diff --git a/bin/pt-kill b/bin/pt-kill index 1f8519e9..7f98c619 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -6233,7 +6233,9 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check( + ($dbh ? { dbh => $dbh, dsn => $cxn->dsn() } : ()) + ); } # ######################################################################## diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index f132aa08..2a2c6dbd 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -7123,13 +7123,6 @@ sub main { die "This tool requires MySQL 5.0.10 or newer.\n"; } - # ######################################################################## - # Do the version-check - # ######################################################################## - if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($cxn->dbh()); - } - # ######################################################################## # Setup lag and load monitors. # ######################################################################## @@ -7297,6 +7290,16 @@ sub main { } } + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + Pingback::version_check( + map { +{ dbh => $_->dbh(), dsn => $_->dsn() } } + $cxn, ($slaves ? @$slaves : ()) + ); + } + # ######################################################################## # Setup and check the original table. # ######################################################################## diff --git a/bin/pt-query-advisor b/bin/pt-query-advisor index f9e8dee2..c3525784 100755 --- a/bin/pt-query-advisor +++ b/bin/pt-query-advisor @@ -7187,10 +7187,11 @@ sub main { # ######################################################################### # Try to connect to MySQL. # ######################################################################### - my $dbh; + my ($dbh, $dsn); eval { + $dsn = $dp->parse_options($o); $dbh = get_cxn( - dsn => $dp->parse_options($o), + dsn => $dsn, %common_modules ); }; @@ -7460,7 +7461,10 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check( + ($review_dbh ? { dbh => $review_dbh, dsn => $review_dsn } : ()), + ($dbh ? { dbh => $dbh, dsn => $dsn } : ()), + ); } # ######################################################################### diff --git a/bin/pt-query-digest b/bin/pt-query-digest index b5b839d8..285e3982 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -13324,9 +13324,10 @@ sub main { ); } # input + my $ps_dsn; { # event my $misc; - if ( my $ps_dsn = $o->get('processlist') ) { + if ( $ps_dsn = $o->get('processlist') ) { my $ms = new MasterSlave( OptionParser => $o, DSNParser => $dp, @@ -14022,6 +14023,7 @@ sub main { } } # sample + my $ex_dsn; { # execute throttle and execute my $et; if ( my $et_args = $o->get('execute-throttle') ) { @@ -14060,7 +14062,7 @@ sub main { ); } # execute throttle - if ( my $ex_dsn = $o->get('execute') ) { + if ( $ex_dsn = $o->get('execute') ) { if ( $o->get('ask-pass') ) { $ex_dsn->{p} = OptionParser::prompt_noecho("Enter password for " . "--execute: "); @@ -14258,7 +14260,11 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($qv_dbh || $ps_dbh || $ex_dbh); + Pingback::version_check( + ($qv_dbh ? { dbh => $qv_dbh, dsn => $review_dsn } : ()), + ($ps_dbh ? { dbh => $ps_dbh, dsn => $ps_dsn } : ()), + ($ex_dbh ? { dbh => $ex_dbh, dsn => $ex_dsn } : ()), + ); } # ########################################################################## diff --git a/bin/pt-slave-delay b/bin/pt-slave-delay index f3040ee1..5b51453b 100755 --- a/bin/pt-slave-delay +++ b/bin/pt-slave-delay @@ -3639,7 +3639,13 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($slave_dbh); + my $tmp_master_dsn = $master_dsn + ? $master_dsn + : { h => $status->{master_host}, P => $status->{master_port} }; + Pingback::version_check( + { dbh => $slave_dbh, dsn => $slave_dsn }, + { dbh => $master_dbh, dsn => $tmp_master_dsn }, + ); } # If the I/O thread isn't running when the program starts, diff --git a/bin/pt-slave-restart b/bin/pt-slave-restart index d6d12a64..0bd132d4 100755 --- a/bin/pt-slave-restart +++ b/bin/pt-slave-restart @@ -4279,13 +4279,6 @@ sub main { $daemon->make_PID_file(); } - # ######################################################################## - # Do the version-check - # ######################################################################## - if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); - } - # ######################################################################## # Start monitoring the slave. # ######################################################################## @@ -4327,6 +4320,15 @@ sub main { } ); + # ######################################################################## + # Do the version-check + # ######################################################################## + if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + Pingback::version_check( + { dbh => $dbh, dsn => $dsn }, @servers_to_watch, + ); + } + # Watch each server found. my $must_fork = @servers_to_watch > 1; foreach my $host ( @servers_to_watch ) { diff --git a/bin/pt-table-sync b/bin/pt-table-sync index f59edf26..897eb381 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -9534,7 +9534,14 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dsns[0]->{dbh}); + Pingback::version_check( + map { + +{ + dbh => $_->{dbh} || get_cxn($_, %args), + dsn => $_, + } + } @dsns + ); } # ######################################################################## diff --git a/bin/pt-upgrade b/bin/pt-upgrade index aad744be..7482599c 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -11701,7 +11701,9 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($hosts->[0]->{dbh}); + Pingback::version_check( + map { +{ dbh => $_->{dbh}, dsn => $_->{dsn} } } @$hosts + ); } # ######################################################################## diff --git a/bin/pt-variable-advisor b/bin/pt-variable-advisor index 5739dba5..eebadad1 100755 --- a/bin/pt-variable-advisor +++ b/bin/pt-variable-advisor @@ -4532,10 +4532,10 @@ sub main { # ########################################################################## # Connect to MySQL if any of the input sources is mysql. # ########################################################################## - my $dbh; + my ($dbh, $dsn); if ( $need_dbh ) { my $dsn_defaults = $dp->parse_options($o); - my $dsn = $dp->parse(shift @ARGV, $dsn_defaults); + $dsn = $dp->parse(shift @ARGV, $dsn_defaults); if ( $o->get('ask-pass') ) { $dsn->{p} = OptionParser::prompt_noecho("Enter password: "); @@ -4565,7 +4565,9 @@ sub main { # Do the version-check # ######################################################################## if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { - Pingback::version_check($dbh); + Pingback::version_check( + ($dbh ? { dbh => $dbh, dsn => $dsn } : ()), + ); } # #########################################################################