Debian Codegraph @

mysql-test/suite/innodb/t/instant_ddl_import_old.test

raw
1 ##########################################################################
2 # Test script to test EXPORT/IMPORT for a table in older version having
3 # INSTANT ADD columns.
4 ##########################################################################
5
6 --source include/have_innodb_16k.inc
7
8 --write_file $MYSQLTEST_VARDIR/tmp/export.inc EOF
9 FLUSH TABLE t1 FOR EXPORT;
10 --echo # Copy cfg/ibd files into temp location
11 --copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/t1.cfg_back
12 --copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/t1.ibd_back
13 UNLOCK TABLES;
14 EOF
15
16 --write_file $MYSQLTEST_VARDIR/tmp/import.inc EOF
17 eval ALTER TABLE $target_table DISCARD TABLESPACE;
18 --echo # Copy cfg/ibd files from temp location
19 --copy_file $MYSQL_TMP_DIR/old_instant_comp/t1.cfg $MYSQLD_DATADIR/test/$target_table.cfg
20 --copy_file $MYSQL_TMP_DIR/old_instant_comp/t1.ibd $MYSQLD_DATADIR/test/$target_table.ibd
21 --error $error_num
22 eval ALTER TABLE $target_table IMPORT TABLESPACE;
23 EOF
24
25 let $MYSQLD_DATADIR = `SELECT @@datadir`;
26
27 --echo # ------------------------------------------------------------
28 --echo # Exported table t1 (in older version) having
29 --echo # c1, c2 normal columns
30 --echo # c3 INSTANT ADD column with default def_c3.
31 --echo # c4 INSTANT ADD column with default def_c4.
32 --echo # +------+------+--------+--------+
33 --echo # | c1 | c2 | c3 | c4 |
34 --echo # +------+------+--------+--------+
35 --echo # | r1c1 | r1c2 | c3_def | c4_def |
36 --echo # | r2c1 | r2c2 | r2c3 | c4_def |
37 --echo # | r3c1 | r3c2 | r3c3 | r3c4 |
38 --echo # +------+------+--------+--------+
39 --echo # ------------------------------------------------------------
40
41 --echo # Copy and unzip the ibd/cfg files.
42 --copy_file $MYSQLTEST_VARDIR/std_data/instant_ddl/old_instant_comp.zip $MYSQL_TMP_DIR/old_instant_comp.zip
43 --file_exists $MYSQL_TMP_DIR/old_instant_comp.zip
44 --exec unzip -qo $MYSQL_TMP_DIR/old_instant_comp.zip -d $MYSQL_TMP_DIR
45 --echo # listing MYSQL_TMP_DIR/old_instant_comp
46 --list_files $MYSQL_TMP_DIR/old_instant_comp
47
48 --echo # ------------------------------------------------------------
49 --echo # Scenario 1 : No INSTANT ADD/DROP Columns in target table
50 --echo # ------------------------------------------------------------
51 create table t1 (c1 char(10), c2 char(10), c3 char(10), c4 char(10)) row_format=compact;
52 --let $table_name=t1
53 --source suite/innodb/include/print_instant_metadata.inc
54
55 --echo # IMPORT
56 --let $target_table=t1
57 --let $error_num=0
58 --source $MYSQLTEST_VARDIR/tmp/import.inc
59
60 SELECT * FROM t1 ORDER BY c1;
61
62 --let $table_name=t1
63 --source suite/innodb/include/print_instant_metadata.inc
64
65 --echo # Cleanup
66 DROP TABLE t1;
67
68 --echo # ------------------------------------------------------------
69 --echo # Scenario 2 : No INSTANT ADD/DROP. Column mismatch
70 --echo # ------------------------------------------------------------
71 create table t1 (c1 char(10), c2 char(20), c3 char(10), c4 char(10)) row_format=compact;
72
73 --echo # IMPORT
74 --let $target_table=t1
75 --let $error_num=1808
76 --source $MYSQLTEST_VARDIR/tmp/import.inc
77
78 --echo # Cleanup
79 --remove_file $MYSQLD_DATADIR/test/t1.cfg
80 --remove_file $MYSQLD_DATADIR/test/t1.ibd
81 DROP TABLE t1;
82
83 --echo # ------------------------------------------------------------
84 --echo # Scenario 3 : INSTANT ADD/DROP Columns in target table
85 --echo # ------------------------------------------------------------
86 create table t1 (c1 char(10), c2 char(10)) row_format=compact;
87 ALTER TABLE t1 ADD COLUMN c3 char(10) DEFAULT "c3_def", ADD COLUMN c4 char(10) DEFAULT "c4_def", ALGORITHM=INSTANT;
88
89 --let $table_name=t1
90 --source suite/innodb/include/print_instant_metadata.inc
91
92 --echo # IMPORT
93 --let $target_table=t1
94 --let $error_num=1808
95 --source $MYSQLTEST_VARDIR/tmp/import.inc
96
97 --echo # Cleanup
98 --remove_file $MYSQLD_DATADIR/test/t1.cfg
99 --remove_file $MYSQLD_DATADIR/test/t1.ibd
100 DROP TABLE t1;
101
102 --echo # ------------------------------------------------------------
103 --echo # Scenario 4 : INSTANT ADD/DROP. Column mismatch
104 --echo # ------------------------------------------------------------
105 create table t1 (c1 char(10), c2 char(10)) row_format=compact;
106 ALTER TABLE t1 ADD COLUMN c3 char(20) DEFAULT "c3_def", ADD COLUMN c4 char(10) DEFAULT "c4_def", ALGORITHM=INSTANT;
107
108 --let $table_name=t1
109 --source suite/innodb/include/print_instant_metadata.inc
110
111 --echo # IMPORT
112 --let $target_table=t1
113 --let $error_num=1808
114 --source $MYSQLTEST_VARDIR/tmp/import.inc
115
116 --echo # Cleanup
117 DROP TABLE t1;
118 --remove_file $MYSQLD_DATADIR/test/t1.cfg
119 --remove_file $MYSQLD_DATADIR/test/t1.ibd
120
121 --echo # ------------------------------------------------------------
122 --echo # Scenario 5 : INSTANT ADD/DROP. Default value mismatch
123 --echo # ------------------------------------------------------------
124 create table t1 (c1 char(10), c2 char(10)) row_format=compact;
125 ALTER TABLE t1 ADD COLUMN c3 char(10) DEFAULT "def_c3", ADD COLUMN c4 char(10) DEFAULT "c4_def", ALGORITHM=INSTANT;
126
127 --let $table_name=t1
128 --source suite/innodb/include/print_instant_metadata.inc
129
130 --echo # IMPORT
131 --let $target_table=t1
132 --let $error_num=1808
133 --source $MYSQLTEST_VARDIR/tmp/import.inc
134
135 --echo # Cleanup
136 DROP TABLE t1;
137 --remove_file $MYSQLD_DATADIR/test/t1.cfg
138 --remove_file $MYSQLD_DATADIR/test/t1.ibd
139
140 --echo ###########
141 --echo # CLEANUP #
142 --echo ###########
143 --force-rmdir $MYSQL_TMP_DIR/old_instant_comp
144 --remove_file $MYSQL_TMP_DIR/old_instant_comp.zip
145 --remove_file $MYSQLTEST_VARDIR/tmp/import.inc
146 --remove_file $MYSQLTEST_VARDIR/tmp/export.inc