mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 17:04:00 +00:00
Updated tests for schema iterator
This commit is contained in:
@@ -3491,7 +3491,7 @@ sub database_is_allowed {
|
|||||||
|
|
||||||
my $filter = $self->{filters};
|
my $filter = $self->{filters};
|
||||||
|
|
||||||
if ( $db =~ m/information_schema|performance_schema|lost\+found/ ) {
|
if ( $db =~ m/information_schema|performance_schema|lost\+found|percona|percona_schema/ ) {
|
||||||
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3534,12 +3534,20 @@ sub table_is_allowed {
|
|||||||
|
|
||||||
return 0 if $db eq 'mysql' && $tbl =~ m/^(?:
|
return 0 if $db eq 'mysql' && $tbl =~ m/^(?:
|
||||||
general_log
|
general_log
|
||||||
|slow_log
|
|gtid_execution
|
||||||
|innodb_index_stats
|
|innodb_index_stats
|
||||||
|innodb_table_stats
|
|innodb_table_stats
|
||||||
|
|inventory
|
||||||
|
|plugin
|
||||||
|
|proc
|
||||||
|slave_master_info
|
|slave_master_info
|
||||||
|slave_relay_log_info
|
|slave_relay_log_info
|
||||||
|slave_worker_info
|
|slave_worker_info
|
||||||
|
|slow_log
|
||||||
|
)$/x;
|
||||||
|
|
||||||
|
return 0 if $db eq 'sys' && $tbl =~ m/^(?:
|
||||||
|
sys_config
|
||||||
)$/x;
|
)$/x;
|
||||||
|
|
||||||
if ( $filter->{'ignore-tables'}->{'*'}->{$tbl}
|
if ( $filter->{'ignore-tables'}->{'*'}->{$tbl}
|
||||||
|
@@ -4269,7 +4269,7 @@ sub database_is_allowed {
|
|||||||
|
|
||||||
my $filter = $self->{filters};
|
my $filter = $self->{filters};
|
||||||
|
|
||||||
if ( $db =~ m/information_schema|performance_schema|lost\+found/ ) {
|
if ( $db =~ m/information_schema|performance_schema|lost\+found|percona|percona_schema/ ) {
|
||||||
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -4312,12 +4312,20 @@ sub table_is_allowed {
|
|||||||
|
|
||||||
return 0 if $db eq 'mysql' && $tbl =~ m/^(?:
|
return 0 if $db eq 'mysql' && $tbl =~ m/^(?:
|
||||||
general_log
|
general_log
|
||||||
|slow_log
|
|gtid_execution
|
||||||
|innodb_index_stats
|
|innodb_index_stats
|
||||||
|innodb_table_stats
|
|innodb_table_stats
|
||||||
|
|inventory
|
||||||
|
|plugin
|
||||||
|
|proc
|
||||||
|slave_master_info
|
|slave_master_info
|
||||||
|slave_relay_log_info
|
|slave_relay_log_info
|
||||||
|slave_worker_info
|
|slave_worker_info
|
||||||
|
|slow_log
|
||||||
|
)$/x;
|
||||||
|
|
||||||
|
return 0 if $db eq 'sys' && $tbl =~ m/^(?:
|
||||||
|
sys_config
|
||||||
)$/x;
|
)$/x;
|
||||||
|
|
||||||
if ( $filter->{'ignore-tables'}->{'*'}->{$tbl}
|
if ( $filter->{'ignore-tables'}->{'*'}->{$tbl}
|
||||||
|
@@ -7614,7 +7614,7 @@ sub database_is_allowed {
|
|||||||
|
|
||||||
my $filter = $self->{filters};
|
my $filter = $self->{filters};
|
||||||
|
|
||||||
if ( $db =~ m/information_schema|performance_schema|lost\+found|percona|percona_schema|test/ ) {
|
if ( $db =~ m/information_schema|performance_schema|lost\+found|percona|percona_schema/ ) {
|
||||||
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -7672,6 +7672,7 @@ sub table_is_allowed {
|
|||||||
return 0 if $db eq 'sys' && $tbl =~ m/^(?:
|
return 0 if $db eq 'sys' && $tbl =~ m/^(?:
|
||||||
sys_config
|
sys_config
|
||||||
)$/x;
|
)$/x;
|
||||||
|
|
||||||
if ( $filter->{'ignore-tables'}->{'*'}->{$tbl}
|
if ( $filter->{'ignore-tables'}->{'*'}->{$tbl}
|
||||||
|| $filter->{'ignore-tables'}->{$db}->{$tbl}) {
|
|| $filter->{'ignore-tables'}->{$db}->{$tbl}) {
|
||||||
PTDEBUG && _d('Table', $tbl, 'is in --ignore-tables list');
|
PTDEBUG && _d('Table', $tbl, 'is in --ignore-tables list');
|
||||||
|
@@ -7825,7 +7825,7 @@ sub database_is_allowed {
|
|||||||
|
|
||||||
my $filter = $self->{filters};
|
my $filter = $self->{filters};
|
||||||
|
|
||||||
if ( $db =~ m/information_schema|performance_schema|lost\+found/ ) {
|
if ( $db =~ m/information_schema|performance_schema|lost\+found|percona|percona_schema/ ) {
|
||||||
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -7868,12 +7868,20 @@ sub table_is_allowed {
|
|||||||
|
|
||||||
return 0 if $db eq 'mysql' && $tbl =~ m/^(?:
|
return 0 if $db eq 'mysql' && $tbl =~ m/^(?:
|
||||||
general_log
|
general_log
|
||||||
|slow_log
|
|gtid_execution
|
||||||
|innodb_index_stats
|
|innodb_index_stats
|
||||||
|innodb_table_stats
|
|innodb_table_stats
|
||||||
|
|inventory
|
||||||
|
|plugin
|
||||||
|
|proc
|
||||||
|slave_master_info
|
|slave_master_info
|
||||||
|slave_relay_log_info
|
|slave_relay_log_info
|
||||||
|slave_worker_info
|
|slave_worker_info
|
||||||
|
|slow_log
|
||||||
|
)$/x;
|
||||||
|
|
||||||
|
return 0 if $db eq 'sys' && $tbl =~ m/^(?:
|
||||||
|
sys_config
|
||||||
)$/x;
|
)$/x;
|
||||||
|
|
||||||
if ( $filter->{'ignore-tables'}->{'*'}->{$tbl}
|
if ( $filter->{'ignore-tables'}->{'*'}->{$tbl}
|
||||||
|
@@ -405,7 +405,7 @@ sub database_is_allowed {
|
|||||||
|
|
||||||
my $filter = $self->{filters};
|
my $filter = $self->{filters};
|
||||||
|
|
||||||
if ( $db =~ m/information_schema|performance_schema|lost\+found|percona|percona_schema|test/ ) {
|
if ( $db =~ m/information_schema|performance_schema|lost\+found|percona|percona_schema/ ) {
|
||||||
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More tests => 43;
|
use Test::More tests => 42;
|
||||||
|
|
||||||
use SchemaIterator;
|
use SchemaIterator;
|
||||||
use FileIterator;
|
use FileIterator;
|
||||||
@@ -349,7 +349,7 @@ SKIP: {
|
|||||||
|
|
||||||
test_so(
|
test_so(
|
||||||
files => ["$in/dump001.txt"],
|
files => ["$in/dump001.txt"],
|
||||||
result => "",
|
result => "test.a test.b test2.a ",
|
||||||
test_name => "Iterate schema in dump001.txt",
|
test_name => "Iterate schema in dump001.txt",
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ test_so(
|
|||||||
|
|
||||||
test_so(
|
test_so(
|
||||||
files => ["$in/dump001.txt", "$in/dump001.txt"],
|
files => ["$in/dump001.txt", "$in/dump001.txt"],
|
||||||
result => "",
|
result => "$out/multiple-files.txt",
|
||||||
ddl => 1,
|
ddl => 1,
|
||||||
test_name => "Iterate schema in multiple files",
|
test_name => "Iterate schema in multiple files",
|
||||||
);
|
);
|
||||||
@@ -370,7 +370,7 @@ test_so(
|
|||||||
test_so(
|
test_so(
|
||||||
files => ["$in/dump001.txt"],
|
files => ["$in/dump001.txt"],
|
||||||
filters => [qw(--databases TEST2)],
|
filters => [qw(--databases TEST2)],
|
||||||
result => "",
|
result => "$out/all-dbs-dump001.txt",
|
||||||
test_name => "Filter dump file by --databases",
|
test_name => "Filter dump file by --databases",
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -591,7 +591,7 @@ my $si = new SchemaIterator(
|
|||||||
Quoter => $q,
|
Quoter => $q,
|
||||||
TableParser => $tp,
|
TableParser => $tp,
|
||||||
);
|
);
|
||||||
for my $db (qw( information_schema performance_schema|lost\+found percona percona_schema test )) {
|
for my $db (qw( information_schema performance_schema|lost\+found percona percona_schema )) {
|
||||||
is(
|
is(
|
||||||
$si->database_is_allowed($db),
|
$si->database_is_allowed($db),
|
||||||
0,
|
0,
|
||||||
|
6
t/lib/samples/SchemaIterator/all-dbs-dump001.txt
Normal file
6
t/lib/samples/SchemaIterator/all-dbs-dump001.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
test2.a
|
||||||
|
CREATE TABLE `a` (
|
||||||
|
`c1` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`c2` varchar(45) NOT NULL
|
||||||
|
);
|
||||||
|
|
38
t/lib/samples/SchemaIterator/multiple-files.txt
Normal file
38
t/lib/samples/SchemaIterator/multiple-files.txt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
test.a
|
||||||
|
CREATE TABLE `a` (
|
||||||
|
`c1` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`c2` varchar(45) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
test.b
|
||||||
|
CREATE TABLE `b` (
|
||||||
|
`c1` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`c2` varchar(45) NOT NULL,
|
||||||
|
`c3` varchar(45) NOT NULL,
|
||||||
|
);
|
||||||
|
|
||||||
|
test2.a
|
||||||
|
CREATE TABLE `a` (
|
||||||
|
`c1` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`c2` varchar(45) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
test.a
|
||||||
|
CREATE TABLE `a` (
|
||||||
|
`c1` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`c2` varchar(45) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
test.b
|
||||||
|
CREATE TABLE `b` (
|
||||||
|
`c1` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`c2` varchar(45) NOT NULL,
|
||||||
|
`c3` varchar(45) NOT NULL,
|
||||||
|
);
|
||||||
|
|
||||||
|
test2.a
|
||||||
|
CREATE TABLE `a` (
|
||||||
|
`c1` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`c2` varchar(45) NOT NULL
|
||||||
|
);
|
||||||
|
|
@@ -8,7 +8,7 @@ use test;
|
|||||||
create table aaa (
|
create table aaa (
|
||||||
`STOP_ARCHIVE` int(11) NOT NULL default '1',
|
`STOP_ARCHIVE` int(11) NOT NULL default '1',
|
||||||
UNIQUE KEY `STOP_ARCHIVE` (`STOP_ARCHIVE`)
|
UNIQUE KEY `STOP_ARCHIVE` (`STOP_ARCHIVE`)
|
||||||
) ENGINE=MyISAM;
|
);
|
||||||
|
|
||||||
insert into aaa values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
insert into aaa values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user