Remove pt-table-sync/issue_79.t (it was broken but coincidentally working) and write better tests in filters.t. Add subs to Sandbox and PerconaTest to clear and parse tables used from the general logs. Set log=genlog in the sandbox configs.

This commit is contained in:
Daniel Nichter
2012-06-07 12:38:45 -04:00
parent 8d4354090e
commit 79c716d358
9 changed files with 203 additions and 175 deletions

View File

@@ -753,6 +753,27 @@ sub full_output {
return ($output, $status);
}
sub tables_used {
my ($file) = @_;
local $INPUT_RECORD_SEPARATOR = '';
open my $fh, '<', $file or die "Cannot open $file: $OS_ERROR";
my %tables;
while ( defined(my $chunk = <$fh>) ) {
map {
my $db_tbl = $_;
$db_tbl =~ s/^\s*`?//; # strip leading space and `
$db_tbl =~ s/\s*`?$//; # strip trailing space and `
$db_tbl =~ s/`\.`/./; # strip inner `.`
$tables{$db_tbl} = 1;
}
grep {
m/(?:\w\.\w|`\.`)/ # only db.tbl, not just db
}
$chunk =~ m/(?:FROM|INTO|UPDATE)\s+(\S+)/gi;
}
return [ sort keys %tables ];
}
1;
}
# ###########################################################################