mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-02 02:34:19 +00:00
Fix timestamp. Make DSNs inherit from master DSN.
This commit is contained in:
@@ -1420,13 +1420,17 @@ sub new {
|
||||
my ($dp, $o) = @args{@required_args};
|
||||
|
||||
my $dsn_defaults = $dp->parse_options($o);
|
||||
|
||||
my $dsn = $args{dsn};
|
||||
my $prev_dsn = $args{prev_dsn};
|
||||
my $dsn = $args{dsn};
|
||||
if ( !$dsn ) {
|
||||
$args{dsn_string} ||= 'h=' . ($dsn_defaults->{h} || 'localhost');
|
||||
|
||||
$dsn = $dp->parse(
|
||||
$args{dsn_string}, $args{prev_dsn}, $dsn_defaults);
|
||||
$args{dsn_string}, $prev_dsn, $dsn_defaults);
|
||||
}
|
||||
elsif ( $prev_dsn ) {
|
||||
$dsn = $dp->copy($prev_dsn, $dsn);
|
||||
$dsn->{n} = $dp->as_string($dsn, [qw(h P S F)]);
|
||||
}
|
||||
|
||||
my $self = {
|
||||
@@ -5495,16 +5499,18 @@ sub main {
|
||||
OptionParser => $o,
|
||||
DSNParser => $dp,
|
||||
Quoter => $q,
|
||||
make_cxn => $make_cxn,
|
||||
make_cxn => sub {
|
||||
return $make_cxn->(@_, prev_dsn => $master_cxn->dsn());
|
||||
},
|
||||
);
|
||||
MKDEBUG && _d(scalar @$slaves, 'slaves found');
|
||||
|
||||
if ( $o->get('check-slave-lag') ) {
|
||||
MKDEBUG && _d('Will use --check-slave-lag to check for slave lag');
|
||||
# OptionParser can't auto-copy DSN vals from a cmd line DSN
|
||||
# to an opt DSN, so we copy them manually.
|
||||
my $dsn = $dp->copy($master_dsn, $o->get('check-slave-lag'));
|
||||
my $cxn = $make_cxn->(dsn => $dsn);
|
||||
my $cxn = $make_cxn->(
|
||||
dsn_string => $o->get('check-slave-lag'),
|
||||
prev_dsn => $master_cxn->dsn(),
|
||||
);
|
||||
$slave_lag_cxns = [ $cxn ];
|
||||
}
|
||||
else {
|
||||
@@ -6164,7 +6170,7 @@ sub main {
|
||||
sub ts {
|
||||
my ($msg) = @_;
|
||||
my ($s, $m, $h, $d, $M) = localtime;
|
||||
my $ts = sprintf('%02d-%02dT%02d:%02d:%02d', $d, $M+1, $h, $m, $s);
|
||||
my $ts = sprintf('%02d-%02dT%02d:%02d:%02d', $M+1, $d, $h, $m, $s);
|
||||
return $msg ? "$ts $msg" : $ts;
|
||||
}
|
||||
|
||||
@@ -6908,7 +6914,7 @@ disable the checks. See also L<"--replicate-database">.
|
||||
|
||||
=item --check-slave-lag
|
||||
|
||||
type: DSN; group: Throttle
|
||||
type: string; group: Throttle
|
||||
|
||||
Pause checksumming until the specified slave's lag is less than L<"--max-lag">.
|
||||
|
||||
@@ -7495,6 +7501,12 @@ dsn: charset; copy: yes
|
||||
|
||||
Default character set.
|
||||
|
||||
=item * D
|
||||
|
||||
copy: no
|
||||
|
||||
DSN table database.
|
||||
|
||||
=item * F
|
||||
|
||||
dsn: mysql_read_default_file; copy: no
|
||||
@@ -7525,6 +7537,12 @@ dsn: mysql_socket; copy: no
|
||||
|
||||
Socket file to use for connection.
|
||||
|
||||
=item * t
|
||||
|
||||
copy: no
|
||||
|
||||
DSN table table.
|
||||
|
||||
=item * u
|
||||
|
||||
dsn: user; copy: yes
|
||||
|
17
lib/Cxn.pm
17
lib/Cxn.pm
@@ -64,8 +64,8 @@ sub new {
|
||||
# are default values; they're used in the DSN if the DSN doesn't
|
||||
# explicate the corresponding part (h=--host, P=--port, etc.).
|
||||
my $dsn_defaults = $dp->parse_options($o);
|
||||
|
||||
my $dsn = $args{dsn};
|
||||
my $prev_dsn = $args{prev_dsn};
|
||||
my $dsn = $args{dsn};
|
||||
if ( !$dsn ) {
|
||||
# If there's no DSN and no DSN string, then the user probably ran
|
||||
# the tool without specifying a DSN or any default connection options.
|
||||
@@ -76,7 +76,18 @@ sub new {
|
||||
$args{dsn_string} ||= 'h=' . ($dsn_defaults->{h} || 'localhost');
|
||||
|
||||
$dsn = $dp->parse(
|
||||
$args{dsn_string}, $args{prev_dsn}, $dsn_defaults);
|
||||
$args{dsn_string}, $prev_dsn, $dsn_defaults);
|
||||
}
|
||||
elsif ( $prev_dsn ) {
|
||||
# OptionParser doesn't make DSN type options inherit values from
|
||||
# a command line DSN because it doesn't know which ARGV from the
|
||||
# command line are DSNs or other things. So if the caller wants
|
||||
# DSNs to inherit values from a prev DSN (i.e. one from the
|
||||
# command line), then they must pass it as the prev_dsn and we
|
||||
# copy values from it into this new DSN, resulting in a new DSN
|
||||
# with values from both sources.
|
||||
$dsn = $dp->copy($prev_dsn, $dsn);
|
||||
$dsn->{n} = $dp->as_string($dsn, [qw(h P S F)]);
|
||||
}
|
||||
|
||||
my $self = {
|
||||
|
@@ -66,7 +66,7 @@ is(
|
||||
);
|
||||
|
||||
$exit_status = pt_table_checksum::main(@args, qw(-t sakila.city --quiet),
|
||||
qw(--no-replicate-check), '--check-slave-lag', 'h=127.1,P=12347');
|
||||
qw(--no-replicate-check), '--check-slave-lag', 'P=12347');
|
||||
|
||||
is(
|
||||
$exit_status,
|
||||
|
Reference in New Issue
Block a user