Debian Codegraph @

mysql-test/suite/storage_engine/alter_tablespace.test

raw
1 #
2 # IMPORT / DISCARD TABLESPACE
3 #
4 # The test might require additional engine options,
5 # e.g. for InnoDB it is --innodb-file-per-table
6
7 --source have_engine.inc
8
9 --disable_warnings
10 DROP TABLE IF EXISTS t1, t2;
11 --enable_warnings
12
13 --let $create_definition = a $int_col
14 --source create_table.inc
15
16 --let $alter_definition = DISCARD TABLESPACE
17
18 --source alter_table.inc
19 if ($mysql_errname)
20 {
21 --let $my_last_stmt = $alter_statement
22 --let $functionality = Tablespace operations
23 --source unexpected_result.inc
24 }
25 if (!$mysql_errname)
26 {
27 DROP TABLE t1;
28
29 --let $create_definition = a $int_col
30 --source create_table.inc
31 INSERT INTO t1 (a) VALUES (1),(2);
32 --sorted_result
33 SELECT a FROM t1;
34
35 # http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/partial.restoring.single.html
36 # To get a "clean" backup we need to either use innobackup, or to monitor show engine innodb status,
37 # and the documented conditions do not look exactly feasible. So, we will go a simple way:
38 # just restart the server, and take the backup while the server is down.
39 # (And we need to have a really clean backup, see MySQL:65429 / LP:1004910)
40
41 --let $datadir = `SELECT @@datadir`
42
43 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
44 restart
45 wait
46 EOF
47
48 --enable_reconnect
49 --shutdown_server
50
51 --source include/wait_until_disconnected.inc
52
53 --replace_result $datadir <DATADIR>
54 --copy_file $datadir/test/t1.ibd $datadir/test/t1.ibd.save
55
56 --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
57 restart
58 EOF
59
60 --source include/wait_until_connected_again.inc
61
62 --let $alter_definition = DISCARD TABLESPACE
63 --source alter_table.inc
64
65 --let $error_codes = ER_TABLESPACE_DISCARDED
66 --replace_result $storage_engine <STORAGE_ENGINE>
67 SELECT a FROM t1;
68 --source check_errors.inc
69 if ($mysql_errname != ER_TABLESPACE_DISCARDED)
70 {
71 --let $functionality = Tablespace operations
72 --source unexpected_result.inc
73 }
74
75 --move_file $datadir/test/t1.ibd.save $datadir/test/t1.ibd
76 --let $alter_definition = IMPORT TABLESPACE
77 --source alter_table.inc
78 --sorted_result
79 SELECT a FROM t1;
80
81 # Adding a warning suppression based on what InnoDB currently does
82 # when it attempts to access a table without an *.ibd file
83 --disable_query_log
84 eval CALL mtr.add_suppression('$storage_engine: Error:');
85 --enable_query_log
86
87 # The sleep below is a very bad style, but so far there seems to be
88 # no reliable way to prevent a failure on Windows, which is caused
89 # by the fact that the error message that we added the above suppression for,
90 # on Windows appears in the error log with a delay, so MTR
91 # thinks the error was raised on server shutdown, and the suppression
92 # does not work. Adding it globally is not an option because
93 # it must be caught in other tests which do not produce the failure
94 # intentionally
95
96 --sleep 1
97 }
98
99 DROP TABLE t1;
100
101 --source cleanup_engine.inc
102