Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

config: always skip the system databases #225

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lightning/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func NewConfig() *Config {
PostRestore: PostRestore{
Checksum: true,
},
BWList: &filter.Rules{},
}
}

Expand Down Expand Up @@ -318,6 +319,13 @@ func (cfg *Config) Adjust() error {
return errors.Annotate(err, "invalid config: `mydumper.tidb.sql_mode` must be a valid SQL_MODE")
}

cfg.BWList.IgnoreDBs = append(cfg.BWList.IgnoreDBs,
"mysql",
"information_schema",
"performance_schema",
"sys",
)

for _, rule := range cfg.Routes {
if !cfg.Mydumper.CaseSensitive {
rule.ToLower()
Expand Down
1 change: 1 addition & 0 deletions tests/black-white-list/data/mysql-schema-create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create database mysql;
1 change: 1 addition & 0 deletions tests/black-white-list/data/mysql.testtable-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table `testtable` (a int primary key);
4 changes: 4 additions & 0 deletions tests/black-white-list/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ check_not_contains 'Database: seconddb'
run_sql 'SHOW TABLES IN firstdb;'
check_contains 'Tables_in_firstdb: first'
check_contains 'Tables_in_firstdb: second'
run_sql 'SHOW TABLES IN mysql;'
check_not_contains 'Tables_in_mysql: testtable'

run_sql 'DROP DATABASE IF EXISTS firstdb;'
run_sql 'DROP DATABASE IF EXISTS seconddb;'
Expand All @@ -39,3 +41,5 @@ check_contains 'Tables_in_firstdb: second'
run_sql 'SHOW TABLES IN seconddb;'
check_not_contains 'Tables_in_seconddb: third'
check_contains 'Tables_in_seconddb: fourth'
run_sql 'SHOW TABLES IN mysql;'
check_not_contains 'Tables_in_mysql: testtable'