mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / mysqldump_restore.test
blob835ee3ee9e937fa1d2a05371d0421e8936dfe96a
1 ###############################################################################
2 # mysqldump_restore.test
4 # Purpose:  Tests if mysqldump output can be used to successfully restore
5 #           tables and data.  
6 #           We CREATE a table, mysqldump it to a file, ALTER the original
7 #           table's name, recreate the table from the mysqldump file, then
8 #           utilize include/diff_tables to compare the original and recreated
9 #           tables.
11 #           We use several examples from mysqldump.test here and include
12 #           the relevant bug numbers and headers from that test.
14 # NOTE:     This test is not currently complete and offers only basic
15 #           cases of mysqldump output being restored. 
16 #           Also, does NOT work with -X (xml) output!
17 #           
18 # Author:   pcrews
19 # Created:  2009-05-21
20 # Last Change:
21 # Change date:
22 ###############################################################################
24 # Embedded server doesn't support external clients
25 --source include/not_embedded.inc
26 --source include/have_log_bin.inc
28 --echo # Set concurrent_insert = 0 to prevent random errors
29 --echo # will reset to original value at the end of the test
30 SET @old_concurrent_insert = @@global.concurrent_insert;
31 SET @@global.concurrent_insert = 0;
33 # Define mysqldumpfile here.  It is used to capture mysqldump output
34 # in order to test the output's ability to restore an exact copy of the table
35 let $mysqldumpfile = $MYSQLTEST_VARDIR/tmp/mysqldumpfile.sql;
37 --echo # Pre-test cleanup
38 --disable_warnings
39 DROP TABLE IF EXISTS t1;
40 --enable_warnings
42 --echo # Begin tests
43 --echo #
44 --echo # Bug#2005 Long decimal comparison bug.
45 --echo #
46 CREATE TABLE t1 (a DECIMAL(64, 20));
47 INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
48 ("0987654321098765432109876543210987654321");
49 --exec $MYSQL_DUMP --compact test t1 > $mysqldumpfile
50 let $table_name = test.t1;
51 --source include/mysqldump.inc
53 --echo #
54 --echo # Bug#3361 mysqldump quotes DECIMAL values inconsistently
55 --echo #
56 CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT);
57 # Check at first how mysql work with quoted decimal
58 INSERT INTO t1 VALUES (1.2345, 2.3456);
59 INSERT INTO t1 VALUES ('1.2345', 2.3456);
60 INSERT INTO t1 VALUES ("1.2345", 2.3456);
61 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI_QUOTES';
62 INSERT INTO t1 VALUES (1.2345, 2.3456);
63 INSERT INTO t1 VALUES ('1.2345', 2.3456);
64 --error ER_BAD_FIELD_ERROR
65 INSERT INTO t1 VALUES ("1.2345", 2.3456);
66 SET SQL_MODE=@OLD_SQL_MODE;
68 # check how mysqldump make quoting
69 --exec $MYSQL_DUMP --compact test t1 > $mysqldumpfile
70 let $table_name = test.t1;
71 --source include/mysqldump.inc
73 --echo #
74 --echo # Bug#1994 mysqldump does not correctly dump UCS2 data
75 --echo # Bug#4261 mysqldump 10.7 (mysql 4.1.2) --skip-extended-insert drops NULL from inserts
76 --echo #
77 CREATE TABLE t1 (a  VARCHAR(255)) DEFAULT CHARSET koi8r;
78 INSERT INTO t1  VALUES (_koi8r x'C1C2C3C4C5'), (NULL);
79 --exec $MYSQL_DUMP --skip-comments --skip-extended-insert test t1 > $mysqldumpfile
80 let $table_name = test.t1;
81 --source include/mysqldump.inc
83 --echo #
84 --echo # WL#2319 Exclude Tables from dump
85 --echo #
86 CREATE TABLE t1 (a INT);
87 CREATE TABLE t2 (a INT);
88 INSERT INTO t1 VALUES (1),(2),(3);
89 INSERT INTO t2 VALUES (4),(5),(6);
90 --exec $MYSQL_DUMP --skip-comments --ignore-table=test.t1 test > $mysqldumpfile
91 let $table_name = test.t2;
92 --source include/mysqldump.inc
93 DROP TABLE t1;
95 --echo #
96 --echo # Bug#8830 mysqldump --skip-extended-insert causes --hex-blob to dump wrong values
97 --echo #
98 CREATE TABLE t1 (`b` blob);
99 INSERT INTO `t1` VALUES (0x602010000280100005E71A);
100 --exec $MYSQL_DUMP --skip-extended-insert --hex-blob test --skip-comments t1 > $mysqldumpfile
101 let $table_name = test.t1;
102 --source include/mysqldump.inc
104 --echo # End tests
106 --echo # Cleanup
107 --echo # Reset concurrent_insert to its original value
108 SET @@global.concurrent_insert = @old_concurrent_insert;
109 --echo # remove mysqldumpfile
110 --error 0,1
111 --remove_file $mysqldumpfile