Debian Codegraph @

mysql-test/suite/innodb_zip/include/atomic_truncate_table_error.inc

raw
1 #
2 # WL#6501: make truncate table atomic
3 #
4
5 --source include/have_debug.inc
6
7 --disable_query_log
8 # suppress expected warnings
9 call mtr.add_suppression("Unable to truncate FTS index for table");
10 call mtr.add_suppression("Unable to assign a new identifier to table "
11 "`.*`\.`.*` after truncating it");
12 call mtr.add_suppression("Flagged corruption of .* in table "
13 "`.*`\.`.*` in TRUNCATE TABLE");
14 call mtr.add_suppression("Parent table of FTS auxiliary table "
15 ".*\/.* not found");
16 --enable_query_log
17 ################################################################################
18 #
19 # Will test following scenarios:
20 # 1. Error in assigning undo logs for truncate action.
21 # 2. Error while preparing for truncate.
22 # 3. Error while dropping/creating indexes.
23 # 4. Error while completing truncate of table involving FTS.
24 # 5. Error while updating sys-tables.
25 #
26 ################################################################################
27
28 #-----------------------------------------------------------------------------
29 #
30 # create test-bed
31 #
32 let $per_table = `select @@innodb_file_per_table`;
33
34 eval set global innodb_file_per_table = on;
35 let $WL6501_TMP_DIR = `select @@tmpdir`;
36 let $WL6501_DATA_DIR = `select @@datadir`;
37 set innodb_strict_mode=off;
38
39 #-----------------------------------------------------------------------------
40 #
41 # 1. Error in assigning undo logs for truncate action.
42 #
43 --echo "1. Error in assigning undo logs for truncate action."
44 eval set global innodb_file_per_table = $wl6501_file_per_table;
45 --disable_warnings
46 eval create $wl6501_temp table t (
47 i int, f float, c char,
48 primary key pk(i), unique findex(f), index ck(c))
49 engine = innodb row_format = $wl6501_row_fmt
50 key_block_size = $wl6501_kbs;
51 --enable_warnings
52 insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
53 select * from t;
54 #check table t;
55 #
56 set session debug = "+d,ib_err_trunc_assigning_undo_log";
57 --error ER_GET_ERRNO
58 truncate table t;
59 set session debug = "-d,ib_err_trunc_assigning_undo_log";
60 #
61 #check table t;
62 select * from t;
63 drop table t;
64
65 #-----------------------------------------------------------------------------
66 #
67 # 2. Error while preparing for truncate.
68 #
69 --echo "2. Error while preparing for truncate."
70 eval set global innodb_file_per_table = $wl6501_file_per_table;
71 --disable_warnings
72 eval create $wl6501_temp table t (
73 i int, f float, c char,
74 primary key pk(i), unique findex(f), index ck(c))
75 engine = innodb row_format = $wl6501_row_fmt
76 key_block_size = $wl6501_kbs;
77 --enable_warnings
78 insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
79 select * from t;
80 #check table t;
81 #
82 set session debug = "+d,ib_err_trunc_preparing_for_truncate";
83 --error ER_GET_ERRNO
84 truncate table t;
85 set session debug = "-d,ib_err_trunc_preparing_for_truncate";
86 #
87 #check table t;
88 select * from t;
89 drop table t;
90
91 #-----------------------------------------------------------------------------
92 #
93 # 3. Error while dropping/creating indexes
94 #
95 --echo "3. Error while dropping/creating indexes"
96 eval set global innodb_file_per_table = $wl6501_file_per_table;
97 --disable_warnings
98 eval create $wl6501_temp table t (
99 i int, f float, c char,
100 primary key pk(i), unique findex(f), index ck(c))
101 engine = innodb row_format = $wl6501_row_fmt
102 key_block_size = $wl6501_kbs;
103 --enable_warnings
104 insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
105 select * from t;
106 #check table t;
107 #
108 set session debug = "+d,ib_err_trunc_drop_index";
109 --error ER_GET_ERRNO
110 truncate table t;
111 set session debug = "-d,ib_err_trunc_drop_index";
112 #
113 #check table t;
114 --error ER_TABLE_CORRUPT
115 select * from t;
116 drop table t;
117 #
118 #
119 eval set global innodb_file_per_table = $wl6501_file_per_table;
120 --disable_warnings
121 eval create $wl6501_temp table t (
122 i int, f float, c char,
123 primary key pk(i), unique findex(f), index ck(c))
124 engine = innodb row_format = $wl6501_row_fmt
125 key_block_size = $wl6501_kbs;
126 --enable_warnings
127 insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
128 select * from t;
129 #check table t;
130 #
131 set session debug = "+d,ib_err_trunc_create_index";
132 --error ER_GET_ERRNO
133 truncate table t;
134 set session debug = "-d,ib_err_trunc_create_index";
135 #
136 #check table t;
137 --error ER_TABLE_CORRUPT
138 select * from t;
139 drop table t;
140 #
141 #
142 eval set global innodb_file_per_table = $wl6501_file_per_table;
143 --disable_warnings
144 eval create temporary table t (
145 i int, f float, c char,
146 primary key pk(i), unique findex(f), index ck(c))
147 engine = innodb row_format = $wl6501_row_fmt
148 key_block_size = $wl6501_kbs;
149 --enable_warnings
150 insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
151 select * from t;
152 #check table t;
153 #
154 set session debug = "+d,ib_err_trunc_temp_recreate_index";
155 --error ER_GET_ERRNO
156 truncate table t;
157 set session debug = "-d,ib_err_trunc_temp_recreate_index";
158 #
159 #check table t;
160 --error ER_TABLE_CORRUPT
161 select * from t;
162 drop table t;
163
164 #-----------------------------------------------------------------------------
165 #
166 # 4. Error while completing truncate of table involving FTS.
167 #
168 --echo "4. Error while completing truncate of table involving FTS."
169 eval set global innodb_file_per_table = $wl6501_file_per_table;
170 --disable_warnings
171 eval create $wl6501_temp table t (i int, f float, c char(100),
172 primary key pk(i), index fk(f), fulltext index ck(c))
173 engine=innodb row_format=$wl6501_row_fmt
174 key_block_size=$wl6501_kbs;
175 --enable_warnings
176 insert into t values (1, 1.1, 'mysql is now oracle company'),
177 (2, 2.2, 'innodb is part of mysql'),
178 (3, 3.3, 'innodb is default storage engine of mysql');
179 select * from t;
180 #check table t;
181 #
182 set session debug = "+d,ib_err_trunc_during_fts_trunc";
183 --error ER_GET_ERRNO
184 truncate table t;
185 set session debug = "-d,ib_err_trunc_during_fts_trunc";
186 #
187 #check table t;
188 --error ER_TABLE_CORRUPT
189 select * from t;
190 drop table t;
191
192 #-----------------------------------------------------------------------------
193 #
194 # 5. Error while updating sys-tables.
195 #
196 --echo "5. Error while updating sys-tables."
197 eval set global innodb_file_per_table = $wl6501_file_per_table;
198 --disable_warnings
199 eval create $wl6501_temp table t (i int, f float, c char(100),
200 primary key pk(i), index fk(f), fulltext index ck(c))
201 engine=innodb row_format=$wl6501_row_fmt
202 key_block_size=$wl6501_kbs;
203 --enable_warnings
204 insert into t values (1, 1.1, 'mysql is now oracle company'),
205 (2, 2.2, 'innodb is part of mysql'),
206 (3, 3.3, 'innodb is default storage engine of mysql');
207 select * from t order by i;
208 #check table t;
209 #
210 set session debug = "+d,ib_err_trunc_during_sys_table_update";
211 --error ER_GET_ERRNO
212 truncate table t;
213 set session debug = "-d,ib_err_trunc_during_sys_table_update";
214 #
215 #check table t;
216 --error ER_TABLE_CORRUPT
217 select * from t order by i;
218 drop table t;
219
220 #-----------------------------------------------------------------------------
221 #
222 # remove test-bed
223 #
224 eval set global innodb_file_per_table = $per_table;