mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-20 01:16:14 +00:00
Fix SchemaIterator by replacing recursion with double nested while loops.
This commit is contained in:
@@ -334,13 +334,14 @@ sub _iterate_dbh {
|
|||||||
$self->{dbs} = \@dbs;
|
$self->{dbs} = \@dbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DATABASE:
|
||||||
|
while ( $self->{db} || defined(my $db = shift @{$self->{dbs}}) ) {
|
||||||
if ( !$self->{db} ) {
|
if ( !$self->{db} ) {
|
||||||
$self->{db} = shift @{$self->{dbs}};
|
PTDEBUG && _d('Next database:', $db);
|
||||||
PTDEBUG && _d('Next database:', $self->{db});
|
$self->{db} = $db;
|
||||||
return unless $self->{db};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !defined $self->{tbls} ) {
|
if ( !$self->{tbls} ) {
|
||||||
my $sql = 'SHOW /*!50002 FULL*/ TABLES FROM ' . $q->quote($self->{db});
|
my $sql = 'SHOW /*!50002 FULL*/ TABLES FROM ' . $q->quote($self->{db});
|
||||||
PTDEBUG && _d($sql);
|
PTDEBUG && _d($sql);
|
||||||
my @tbls = map {
|
my @tbls = map {
|
||||||
@@ -357,6 +358,7 @@ sub _iterate_dbh {
|
|||||||
$self->{tbls} = \@tbls;
|
$self->{tbls} = \@tbls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TABLE:
|
||||||
while ( my $tbl = shift @{$self->{tbls}} ) {
|
while ( my $tbl = shift @{$self->{tbls}} ) {
|
||||||
my $ddl = eval { $tp->get_create_table($dbh, $self->{db}, $tbl) };
|
my $ddl = eval { $tp->get_create_table($dbh, $self->{db}, $tbl) };
|
||||||
if ( my $e = $EVAL_ERROR ) {
|
if ( my $e = $EVAL_ERROR ) {
|
||||||
@@ -366,13 +368,14 @@ sub _iterate_dbh {
|
|||||||
# do about it; If the table is missing, just PTDEBUG it, but
|
# do about it; If the table is missing, just PTDEBUG it, but
|
||||||
# otherwise, warn with the error.
|
# otherwise, warn with the error.
|
||||||
if ( $e =~ /\QTable '$table_name' doesn't exist/ ) {
|
if ( $e =~ /\QTable '$table_name' doesn't exist/ ) {
|
||||||
PTDEBUG && _d("Skipping $table_name because it no longer exists");
|
PTDEBUG && _d("$table_name no longer exists");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
warn "Skipping $table_name because SHOW CREATE TABLE failed: $e";
|
warn "Skipping $table_name because SHOW CREATE TABLE failed: $e";
|
||||||
}
|
}
|
||||||
next;
|
next TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $tbl_struct = $tp->parse($ddl);
|
my $tbl_struct = $tp->parse($ddl);
|
||||||
if ( $self->engine_is_allowed($tbl_struct->{engine}) ) {
|
if ( $self->engine_is_allowed($tbl_struct->{engine}) ) {
|
||||||
return {
|
return {
|
||||||
@@ -388,10 +391,10 @@ sub _iterate_dbh {
|
|||||||
PTDEBUG && _d('No more tables in database', $self->{db});
|
PTDEBUG && _d('No more tables in database', $self->{db});
|
||||||
$self->{db} = undef;
|
$self->{db} = undef;
|
||||||
$self->{tbls} = undef;
|
$self->{tbls} = undef;
|
||||||
|
} # DATABASE
|
||||||
|
|
||||||
# Recurse to get the next database. If there's no next db, then the
|
PTDEBUG && _d('No more databases');
|
||||||
# call will return undef and we'll return undef, too.
|
return;
|
||||||
return $self->_iterate_dbh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub database_is_allowed {
|
sub database_is_allowed {
|
||||||
|
Reference in New Issue
Block a user