diff options
Diffstat (limited to 'mysql-test/t/mysqldump.test')
-rw-r--r-- | mysql-test/t/mysqldump.test | 223 |
1 files changed, 215 insertions, 8 deletions
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 6dba0a590d0..0e4e9989ffa 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -15,7 +15,7 @@ drop view if exists v1, v2, v3; # XML output -CREATE TABLE t1(a int); +CREATE TABLE t1(a int, key (a)) key_block_size=1024; INSERT INTO t1 VALUES (1), (2); --exec $MYSQL_DUMP --skip-create --skip-comments -X test t1 DROP TABLE t1; @@ -798,9 +798,10 @@ drop table t1, t2; drop database db1; use test; -# -# dump of view -# +--echo # +--echo # dump of view +--echo # + create table t1(a int); create view v1 as select * from t1; --exec $MYSQL_DUMP --skip-comments test @@ -983,7 +984,7 @@ CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11) RETURN a+b // CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT) BEGIN SELECT a+b INTO c; end // -create function bug9056_func2(f1 char binary) returns char binary +create function bug9056_func2(f1 char binary) returns char begin set f1= concat( 'hello', f1 ); return f1; @@ -1086,7 +1087,6 @@ create view v2 as select * from v0; select * from v2; --exec $MYSQL_DUMP -x --skip-comments --databases test - drop view v2; drop view v0; drop view v1; @@ -1348,7 +1348,9 @@ grant RELOAD on *.* to mysqltest_1@localhost; grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; # Execute mysqldump, should now succeed +--disable_result_log --exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 +--enable_result_log # Clean up drop table t1; @@ -1499,8 +1501,6 @@ drop database bug23491_original; drop database bug23491_restore; use test; - - --echo # --echo # Bug 27293: mysqldump crashes when dumping routines --echo # defined by a different user @@ -1596,3 +1596,210 @@ DROP TABLE t1,t2; --echo # --echo # End of 5.0 tests --echo # + +# Check new --replace option + +--disable_warnings +drop table if exists t1; +--enable_warnings + +CREATE TABLE t1(a int, b int); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t1 VALUES (2,3); +INSERT INTO t1 VALUES (3,4), (4,5); +--exec $MYSQL_DUMP --replace --skip-comments test t1 +DROP TABLE t1; + +# +# Added for use-thread option +# +create table t1 (a text , b text); +create table t2 (a text , b text); +insert t1 values ("Duck, Duck", "goose"); +insert t1 values ("Duck, Duck", "pidgeon"); +insert t2 values ("We the people", "in order to perform"); +insert t2 values ("a more perfect", "union"); +select * from t1; +select * from t2; +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t2.sql +# The first load tests the pausing code +--exec $MYSQL_IMPORT --use-threads=1 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt +# Now we test with multiple threads! +--exec $MYSQL_IMPORT --silent --use-threads=5 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt +select * from t1; +select * from t2; +# Now we test with multiple threads, but less threads than files. +create table words(a varchar(255)); +create table words2(b varchar(255)); +--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data_ln/words.dat $MYSQLTEST_VARDIR/std_data_ln/words2.dat +select * from t1; +select * from t2; +select * from words; +select * from words2; + +# Drop table "words" and run with threads, should fail +drop table words; +--replace_regex /.*mysqlimport(\.exe)*/mysql-import/ +--error 1 +--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data_ln/words.dat $MYSQLTEST_VARDIR/std_data_ln/words2.dat 2>&1 + +drop table t1; +drop table t2; + +drop table words2; + +--echo # +--echo # BUG# 16853: mysqldump doesn't show events +--echo # + +create database first; +use first; +set time_zone = 'UTC'; + +## prove one works (with spaces and tabs on the end) +create event ee1 on schedule at '2035-12-31 20:01:23' do set @a=5; +show events; +show create event ee1; +--exec $MYSQL_DUMP --events first > $MYSQLTEST_VARDIR/tmp/bug16853-1.sql +drop database first; + +create database second; +use second; +--exec $MYSQL second < $MYSQLTEST_VARDIR/tmp/bug16853-1.sql +show events; +show create event ee1; + +## prove three works (with spaces and tabs on the end) +# start with one from the previous restore +create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5; +create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5; +show events; +--exec $MYSQL_DUMP --events second > $MYSQLTEST_VARDIR/tmp/bug16853-2.sql +drop database second; + +create database third; +use third; +--exec $MYSQL third < $MYSQLTEST_VARDIR/tmp/bug16853-2.sql +show events; +drop database third; + +# revert back to normal settings +set time_zone = 'SYSTEM'; +use test; + +--echo # +--echo # BUG#17201 Spurious 'DROP DATABASE' in output, +--echo # also confusion between tables and views. +--echo # Example code from Markus Popp +--echo # + +create database mysqldump_test_db; +use mysqldump_test_db; +create table t1 (id int); +create view v1 as select * from t1; +insert into t1 values (1232131); +insert into t1 values (4711); +insert into t1 values (3231); +insert into t1 values (0815); +--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_test_db +drop view v1; +drop table t1; +drop database mysqldump_test_db; + +# +# BUG#26121 mysqldump includes LOCK TABLES general_log WRITE +# +--exec $MYSQL_DUMP --all-databases > $MYSQLTEST_VARDIR/tmp/bug26121.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug26121.sql +--remove_file $MYSQLTEST_VARDIR/tmp/bug26121.sql + +########################################################################### + +--echo # +--echo # Bug #30027: mysqldump does not dump views properly. +--echo # + +--echo +--echo # Cleanup. + +--disable_warnings +DROP DATABASE IF EXISTS mysqldump_test_db; +--enable_warnings + +--echo +--echo # Create objects. + +CREATE DATABASE mysqldump_test_db; + +set names koi8r; + +CREATE VIEW mysqldump_test_db.v2 AS SELECT 1 AS колонка1; +CREATE VIEW mysqldump_test_db.v1 AS SELECT колонка1 FROM mysqldump_test_db.v2; + +set names latin1; + +--echo +--echo # Dump mysqldump_test_db to bug30027.sql. + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=latin1 --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30027.sql + +--echo +--echo # Drop mysqldump_test_db. + +DROP DATABASE mysqldump_test_db; + +--echo +--echo # Restore mysqldump_test_db from bug30027.sql. + +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug30027.sql + +--echo +--echo # Check the view. + +set names utf8; + +SHOW CREATE VIEW mysqldump_test_db.v1; +SHOW CREATE VIEW mysqldump_test_db.v2; + +set names latin1; + +--echo +--echo # Cleanup. + +DROP DATABASE mysqldump_test_db; + +########################################################################### + +--echo # +--echo # BUG#29938: wrong behavior of mysqldump --skip-events +--echo # with --all-databases +--echo # + +TRUNCATE mysql.event; + +USE test; +CREATE event e29938 ON SCHEDULE AT '2035-12-31 20:01:23' DO SET @bug29938=29938; +SHOW EVENTS; +--exec $MYSQL_DUMP --skip-events --all-databases > $MYSQLTEST_VARDIR/tmp/bug29938.sql + +TRUNCATE mysql.event; +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29938.sql +SHOW EVENTS; + + +--echo # +--echo # Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names +--echo # +create database `test-database`; +use `test-database`; +create table test (a int); +--exec $MYSQL_DUMP --compact --opt --quote-names test-database +drop database `test-database`; +use test; + + +--echo # +--echo # End of 5.1 tests +--echo # |