Fix version check instances in pt-config-diff and pt-table-sync.

This commit is contained in:
Daniel Nichter
2012-08-28 08:58:54 -06:00
parent 6eee6ac6f6
commit 8afb9ea5ff
2 changed files with 23 additions and 9 deletions

View File

@@ -4028,6 +4028,7 @@ sub main {
my $last_dsn; my $last_dsn;
my @configs; # MySQLConfig objects my @configs; # MySQLConfig objects
my @config_names; # Human-readable names for those ^ objs my @config_names; # Human-readable names for those ^ objs
my @cxn;
foreach my $config_src ( @ARGV ) { foreach my $config_src ( @ARGV ) {
if ( -f $config_src ) { if ( -f $config_src ) {
PTDEBUG && _d('Config source', $config_src, 'is a file'); PTDEBUG && _d('Config source', $config_src, 'is a file');
@@ -4054,6 +4055,7 @@ sub main {
%common_modules, %common_modules,
); );
push @config_names, $cxn->name(); push @config_names, $cxn->name();
push @cxn, $cxn;
} }
} }
@@ -4077,7 +4079,7 @@ sub main {
# ######################################################################## # ########################################################################
if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) {
Pingback::version_check( Pingback::version_check(
map { +{ dbh => $_->{dbh}, dsn => $_->{dsn} } } @configs map { +{ dbh => $_->dbh, dsn => $_->dsn } } @cxn
); );
} }

View File

@@ -9533,17 +9533,29 @@ sub main {
# ######################################################################## # ########################################################################
# Do the version-check # Do the version-check
# ######################################################################## # ########################################################################
# This tool has way too many dbhs and doesn't use Cxn, so we have to
# manually disconnect them else they'll throw a warning. Also, it
# creates some dbh late, so here we need to create a dbh and then
# disconnect it only if we created it, i.e. don't disconnect the few
# dbh created early by the tool.
my @vc_dbhs;
my @instances = map {
my $dsn = $_;
my $dbh = $dsn->{dbh};
if ( !$dbh ) {
$dbh = get_cxn($dsn, %modules);
push @vc_dbhs, $dbh; # disconnect this dbh after version check
}
+{ dbh => $dbh, dsn => $dsn }
} @dsns;
if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { if ( $o->get('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) {
Pingback::version_check( Pingback::version_check(@instances);
map {
+{
dbh => $_->{dbh} || get_cxn($_, %args),
dsn => $_,
}
} @dsns
);
} }
map { $_->disconnect } @vc_dbhs; # disconnect dbh created for version check
# ######################################################################## # ########################################################################
# Sync! # Sync!
# ######################################################################## # ########################################################################