--source include/not_embedded.inc --source include/have_innodb.inc # Basic test case for --table (restore single table) create table t1(i int); insert t1 values(100); create view v1 as select 1; --mkdir $MYSQLTEST_VARDIR/tmp/dump --exec $MYSQL_DUMP --dir=$MYSQLTEST_VARDIR/tmp/dump test drop table t1; --exec $MYSQL_IMPORT --table=test.t1 --dir=$MYSQLTEST_VARDIR/tmp/dump select * from t1; --rmdir $MYSQLTEST_VARDIR/tmp/dump # Test cases for --dir # test --all-databases --mkdir $MYSQLTEST_VARDIR/tmp/dump --exec $MYSQL_DUMP --dir=$MYSQLTEST_VARDIR/tmp/dump --all-databases --echo # Content of dump directory --list_files $MYSQLTEST_VARDIR/tmp/dump --echo # Content of 'test' dump subdirectory --list_files $MYSQLTEST_VARDIR/tmp/dump/test --echo # Content of 'mysql' dump subdirectory --list_files $MYSQLTEST_VARDIR/tmp/dump/mysql --echo # Content of 'mtr' dump subdirectory --list_files $MYSQLTEST_VARDIR/tmp/dump/mtr # Test --dir --replace_result $MYSQLTEST_VARDIR vardir # Ignore mtr.test_suppressions (may have suppressions or now), mysql.proc is smaller without perfschema/sys schema --exec $MYSQL_IMPORT --local --verbose --dir $MYSQLTEST_VARDIR/tmp/dump --ignore-table=mtr.test_suppressions --ignore-table=mysql.proc drop table t1; drop view v1; --rmdir $MYSQLTEST_VARDIR/tmp/dump # Test foreign keys create database db2; use db2; CREATE TABLE parent ( id INT NOT NULL, PRIMARY KEY (id) ) ENGINE=INNODB; CREATE TABLE child ( id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE ) ENGINE=INNODB; insert into parent values(1),(2); insert into child values (1,1),(1,2),(2,1),(2,2); --mkdir $MYSQLTEST_VARDIR/tmp/dump --exec $MYSQL_DUMP --dir=$MYSQLTEST_VARDIR/tmp/dump --all-databases drop database db2; --replace_result $MYSQLTEST_VARDIR vardir --exec $MYSQL_IMPORT --local --silent --dir $MYSQLTEST_VARDIR/tmp/dump --database=db2 --parallel=2 use db2; select * from parent; select * from child; drop table child; drop table parent; --rmdir $MYSQLTEST_VARDIR/tmp/dump # Test with triggers (using https://mariadb.com/kb/en/trigger-overview/ example) CREATE TABLE animals (id mediumint(9) NOT NULL AUTO_INCREMENT, name char(30) NOT NULL, PRIMARY KEY (`id`)); CREATE TABLE animal_count (animals int); INSERT INTO animal_count (animals) VALUES(0); CREATE TRIGGER increment_animal AFTER INSERT ON animals FOR EACH ROW UPDATE animal_count SET animal_count.animals = animal_count.animals+1; INSERT INTO animals (name) VALUES('aardvark'); INSERT INTO animals (name) VALUES('baboon'); --echo # Content of tables before backup select * from animals; select * from animal_count; --mkdir $MYSQLTEST_VARDIR/tmp/dump --exec $MYSQL_DUMP --dir=$MYSQLTEST_VARDIR/tmp/dump db2 use test; drop database db2; --replace_result $MYSQLTEST_VARDIR vardir --exec $MYSQL_IMPORT --local --verbose --dir $MYSQLTEST_VARDIR/tmp/dump use db2; --echo # Content of tables after import select * from animals; select * from animal_count; drop table animals; drop table animal_count; # Test VIEW create table t1 as select 1 as val; create view a1 as select * from t1; --rmdir $MYSQLTEST_VARDIR/tmp/dump --mkdir $MYSQLTEST_VARDIR/tmp/dump --exec $MYSQL_DUMP --dir=$MYSQLTEST_VARDIR/tmp/dump db2 use test; drop database db2; --replace_result $MYSQLTEST_VARDIR vardir --exec $MYSQL_IMPORT --local --verbose --dir $MYSQLTEST_VARDIR/tmp/dump use db2; select * from t1; select * from a1; drop database db2; --rmdir $MYSQLTEST_VARDIR/tmp/dump use test; # Test --ignore-database # Do full backup, drop one db, restore with --ignore-database=db # Check that database does not exist anymore create database db; use db; create table t1 as select 1 as val; --mkdir $MYSQLTEST_VARDIR/tmp/dump --exec $MYSQL_DUMP --dir=$MYSQLTEST_VARDIR/tmp/dump --all-databases use test; drop database db; --replace_result $MYSQLTEST_VARDIR vardir --exec $MYSQL_IMPORT --local --silent --dir $MYSQLTEST_VARDIR/tmp/dump --ignore-database=db --error ER_BAD_DB_ERROR use db; use test; --echo # Test non-existing --dir --replace_result mariadb-import.exe mariadb-import $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1 --exec $MYSQL_IMPORT --dir $MYSQLTEST_VARDIR/tmp/non_existing 2>&1 --echo # Test too many threads, builtin limit 256 --replace_result mariadb-import.exe mariadb-import $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1 --exec $MYSQL_IMPORT --dir $MYSQLTEST_VARDIR/tmp/dump --parallel=300 2>&1 --rmdir $MYSQLTEST_VARDIR/tmp/dump