File: instant_ddl_import_old.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (146 lines) | stat: -rw-r--r-- 5,498 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
##########################################################################
# Test script to test EXPORT/IMPORT for a table in older version having
# INSTANT ADD columns.
##########################################################################

--source include/have_innodb_16k.inc

--write_file $MYSQLTEST_VARDIR/tmp/export.inc EOF
  FLUSH TABLE t1 FOR EXPORT;
  --echo # Copy cfg/ibd files into temp location
  --copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/t1.cfg_back
  --copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/t1.ibd_back
  UNLOCK TABLES;
EOF

--write_file $MYSQLTEST_VARDIR/tmp/import.inc EOF
  eval ALTER TABLE $target_table DISCARD TABLESPACE;
  --echo # Copy cfg/ibd files from temp location
  --copy_file $MYSQL_TMP_DIR/old_instant_comp/t1.cfg $MYSQLD_DATADIR/test/$target_table.cfg
  --copy_file $MYSQL_TMP_DIR/old_instant_comp/t1.ibd $MYSQLD_DATADIR/test/$target_table.ibd
  --error $error_num
  eval ALTER TABLE $target_table IMPORT TABLESPACE;
EOF

let $MYSQLD_DATADIR = `SELECT @@datadir`;

--echo # ------------------------------------------------------------
--echo # Exported table t1 (in older version) having
--echo #     c1, c2 normal columns
--echo #     c3 INSTANT ADD column with default def_c3.
--echo #     c4 INSTANT ADD column with default def_c4.
--echo #       +------+------+--------+--------+
--echo #       | c1   | c2   | c3     | c4     |
--echo #       +------+------+--------+--------+
--echo #       | r1c1 | r1c2 | c3_def | c4_def |
--echo #       | r2c1 | r2c2 | r2c3   | c4_def |
--echo #       | r3c1 | r3c2 | r3c3   | r3c4   |
--echo #       +------+------+--------+--------+
--echo # ------------------------------------------------------------

--echo # Copy and unzip the ibd/cfg files.
--copy_file $MYSQLTEST_VARDIR/std_data/instant_ddl/old_instant_comp.zip $MYSQL_TMP_DIR/old_instant_comp.zip
--file_exists $MYSQL_TMP_DIR/old_instant_comp.zip
--exec unzip -qo $MYSQL_TMP_DIR/old_instant_comp.zip -d $MYSQL_TMP_DIR
--echo # listing MYSQL_TMP_DIR/old_instant_comp
--list_files $MYSQL_TMP_DIR/old_instant_comp

--echo # ------------------------------------------------------------
--echo # Scenario 1 : No INSTANT ADD/DROP Columns in target table
--echo # ------------------------------------------------------------
create table t1 (c1 char(10), c2 char(10), c3 char(10), c4 char(10)) row_format=compact;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc

--echo # IMPORT
--let $target_table=t1
--let $error_num=0
--source $MYSQLTEST_VARDIR/tmp/import.inc

SELECT * FROM t1 ORDER BY c1;

--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc

--echo # Cleanup
DROP TABLE t1;

--echo # ------------------------------------------------------------
--echo # Scenario 2 : No INSTANT ADD/DROP. Column mismatch
--echo # ------------------------------------------------------------
create table t1 (c1 char(10), c2 char(20), c3 char(10), c4 char(10)) row_format=compact;

--echo # IMPORT
--let $target_table=t1
--let $error_num=1808
--source $MYSQLTEST_VARDIR/tmp/import.inc

--echo # Cleanup
--remove_file $MYSQLD_DATADIR/test/t1.cfg
--remove_file $MYSQLD_DATADIR/test/t1.ibd
DROP TABLE t1;

--echo # ------------------------------------------------------------
--echo # Scenario 3 : INSTANT ADD/DROP Columns in target table
--echo # ------------------------------------------------------------
create table t1 (c1 char(10), c2 char(10)) row_format=compact;
ALTER TABLE t1 ADD COLUMN c3 char(10) DEFAULT "c3_def", ADD COLUMN c4 char(10) DEFAULT "c4_def", ALGORITHM=INSTANT;

--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc

--echo # IMPORT
--let $target_table=t1
--let $error_num=1808
--source $MYSQLTEST_VARDIR/tmp/import.inc

--echo # Cleanup
--remove_file $MYSQLD_DATADIR/test/t1.cfg
--remove_file $MYSQLD_DATADIR/test/t1.ibd
DROP TABLE t1;

--echo # ------------------------------------------------------------
--echo # Scenario 4 : INSTANT ADD/DROP. Column mismatch
--echo # ------------------------------------------------------------
create table t1 (c1 char(10), c2 char(10)) row_format=compact;
ALTER TABLE t1 ADD COLUMN c3 char(20) DEFAULT "c3_def", ADD COLUMN c4 char(10) DEFAULT "c4_def", ALGORITHM=INSTANT;

--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc

--echo # IMPORT
--let $target_table=t1
--let $error_num=1808
--source $MYSQLTEST_VARDIR/tmp/import.inc

--echo # Cleanup
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.cfg
--remove_file $MYSQLD_DATADIR/test/t1.ibd

--echo # ------------------------------------------------------------
--echo # Scenario 5 : INSTANT ADD/DROP. Default value mismatch
--echo # ------------------------------------------------------------
create table t1 (c1 char(10), c2 char(10)) row_format=compact;
ALTER TABLE t1 ADD COLUMN c3 char(10) DEFAULT "def_c3", ADD COLUMN c4 char(10) DEFAULT "c4_def", ALGORITHM=INSTANT;

--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc

--echo # IMPORT
--let $target_table=t1
--let $error_num=1808
--source $MYSQLTEST_VARDIR/tmp/import.inc

--echo # Cleanup
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.cfg
--remove_file $MYSQLD_DATADIR/test/t1.ibd

--echo ###########
--echo # CLEANUP #
--echo ###########
--force-rmdir $MYSQL_TMP_DIR/old_instant_comp
--remove_file $MYSQL_TMP_DIR/old_instant_comp.zip
--remove_file $MYSQLTEST_VARDIR/tmp/import.inc
--remove_file $MYSQLTEST_VARDIR/tmp/export.inc