mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 03:09:00 +00:00
Fix --resume --ignore-tables.
This commit is contained in:
@@ -4265,8 +4265,10 @@ sub new {
|
||||
|
||||
my %resume;
|
||||
if ( my $table = $args{resume} ) {
|
||||
MKDEBUG && _d('Will resume from', $table);
|
||||
MKDEBUG && _d('Will resume from or after', $table);
|
||||
my ($db, $tbl) = $args{Quoter}->split_unquote($table);
|
||||
die "Resume table must be database-qualified: $table"
|
||||
unless $db && $tbl;
|
||||
$resume{db} = $db;
|
||||
$resume{tbl} = $tbl;
|
||||
}
|
||||
@@ -4337,6 +4339,16 @@ sub _make_filters {
|
||||
sub next {
|
||||
my ( $self ) = @_;
|
||||
|
||||
if ( !$self->{initialized} ) {
|
||||
$self->{initialized} = 1;
|
||||
if ( $self->{resume}->{tbl}
|
||||
&& !$self->table_is_allowed(@{$self->{resume}}{qw(db tbl)}) ) {
|
||||
MKDEBUG && _d('Will resume after',
|
||||
join('.', @{$self->{resume}}{qw(db tbl)}));
|
||||
$self->{resume}->{after} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
my $schema_obj;
|
||||
if ( $self->{file_itr} ) {
|
||||
$schema_obj= $self->_iterate_files();
|
||||
@@ -4399,8 +4411,8 @@ sub _iterate_files {
|
||||
my ($tbl) = $chunk =~ m/$tbl_name/;
|
||||
$tbl =~ s/^\s*`//;
|
||||
$tbl =~ s/`\s*$//;
|
||||
if ( $self->table_is_allowed($self->{db}, $tbl)
|
||||
&& $self->_resume_from_table($tbl) ) {
|
||||
if ( $self->_resume_from_table($tbl)
|
||||
&& $self->table_is_allowed($self->{db}, $tbl) ) {
|
||||
my ($ddl) = $chunk =~ m/^(?:$open_comment)?(CREATE TABLE.+?;)$/ms;
|
||||
if ( !$ddl ) {
|
||||
warn "Failed to parse CREATE TABLE from\n" . $chunk;
|
||||
@@ -4459,8 +4471,9 @@ sub _iterate_dbh {
|
||||
}
|
||||
grep {
|
||||
my ($tbl, $type) = @$_;
|
||||
$self->table_is_allowed($self->{db}, $tbl)
|
||||
&& (!$type || ($type ne 'VIEW'));
|
||||
(!$type || ($type ne 'VIEW'))
|
||||
&& $self->_resume_from_table($tbl)
|
||||
&& $self->table_is_allowed($self->{db}, $tbl);
|
||||
}
|
||||
@{$dbh->selectall_arrayref($sql)};
|
||||
MKDEBUG && _d('Found', scalar @tbls, 'tables in database', $self->{db});
|
||||
@@ -4468,8 +4481,6 @@ sub _iterate_dbh {
|
||||
}
|
||||
|
||||
while ( my $tbl = shift @{$self->{tbls}} ) {
|
||||
next unless $self->_resume_from_table($tbl);
|
||||
|
||||
my $tbl_status;
|
||||
if ( $self->{filters}->{'engines'}
|
||||
|| $self->{filters}->{'ignore-engines'}
|
||||
@@ -4637,9 +4648,15 @@ sub _resume_from_table {
|
||||
return 1 unless $self->{resume}->{tbl};
|
||||
|
||||
if ( $tbl eq $self->{resume}->{tbl} ) {
|
||||
MKDEBUG && _d('At resume table', $tbl);
|
||||
delete $self->{resume}->{tbl};
|
||||
return 1;
|
||||
if ( !$self->{resume}->{after} ) {
|
||||
MKDEBUG && _d('Resuming from table', $tbl);
|
||||
delete $self->{resume}->{tbl};
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
MKDEBUG && _d('Resuming after table', $tbl);
|
||||
delete $self->{resume}->{tbl};
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -5909,6 +5926,23 @@ sub main {
|
||||
);
|
||||
}
|
||||
|
||||
my $schema_iter = new SchemaIterator(
|
||||
dbh => $master_dbh,
|
||||
resume => $last_chunk ? $q->quote(@{$last_chunk}{qw(db tbl)})
|
||||
: "",
|
||||
keep_tbl_status => 1,
|
||||
OptionParser => $o,
|
||||
TableParser => $tp,
|
||||
Quoter => $q,
|
||||
);
|
||||
|
||||
if ( $last_chunk &&
|
||||
!$schema_iter->table_is_allowed(@{$last_chunk}{qw(db tbl)}) ) {
|
||||
MKDEBUG && _d('Ignoring last table', @{$last_chunk}{qw(db tbl)},
|
||||
'and resuming from next table');
|
||||
$last_chunk = undef;
|
||||
}
|
||||
|
||||
# ########################################################################
|
||||
# Various variables and modules for checksumming the tables.
|
||||
# ########################################################################
|
||||
@@ -6297,15 +6331,6 @@ sub main {
|
||||
# ########################################################################
|
||||
# Checksum each table.
|
||||
# ########################################################################
|
||||
my $schema_iter = new SchemaIterator(
|
||||
dbh => $master_dbh,
|
||||
resume => $last_chunk ? $q->quote(@{$last_chunk}{qw(db tbl)})
|
||||
: "",
|
||||
keep_tbl_status => 1,
|
||||
OptionParser => $o,
|
||||
TableParser => $tp,
|
||||
Quoter => $q,
|
||||
);
|
||||
|
||||
TABLE:
|
||||
while ( $oktorun && (my $tbl = $schema_iter->next()) ) {
|
||||
|
Reference in New Issue
Block a user