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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
let $per_table=`select @@innodb_file_per_table`;
let $format=`select @@innodb_file_format`;
let $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`;
set session innodb_strict_mode=0;
set global innodb_file_per_table=off;
set global innodb_file_format=`0`;
create table t0(a int primary key) engine=innodb row_format=compressed;
create table t00(a int primary key) engine=innodb
key_block_size=4 row_format=compressed;
create table t1(a int primary key) engine=innodb row_format=dynamic;
create table t2(a int primary key) engine=innodb row_format=redundant;
create table t3(a int primary key) engine=innodb row_format=compact;
create table t4(a int primary key) engine=innodb key_block_size=9;
create table t5(a int primary key) engine=innodb
key_block_size=1 row_format=redundant;
set global innodb_file_per_table=on;
create table t6(a int primary key) engine=innodb
key_block_size=1 row_format=redundant;
set global innodb_file_format=`1`;
create table t7(a int primary key) engine=innodb
key_block_size=1 row_format=redundant;
create table t8(a int primary key) engine=innodb
key_block_size=1 row_format=fixed;
create table t9(a int primary key) engine=innodb
key_block_size=1 row_format=compact;
create table t10(a int primary key) engine=innodb
key_block_size=1 row_format=dynamic;
create table t11(a int primary key) engine=innodb
key_block_size=1 row_format=compressed;
create table t12(a int primary key) engine=innodb
key_block_size=1;
create table t13(a int primary key) engine=innodb
row_format=compressed;
create table t14(a int primary key) engine=innodb key_block_size=9;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
alter table t1 key_block_size=0;
alter table t1 row_format=dynamic;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
alter table t1 row_format=compact;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
alter table t1 row_format=redundant;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
drop table t1;
create table t1(a int not null, b text, index(b(10))) engine=innodb
key_block_size=1;
create table t2(b text)engine=innodb;
insert into t2 values(concat('1abcdefghijklmnopqrstuvwxyz', repeat('A',5000)));
insert into t1 select 1, b from t2;
commit;
connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
begin;
update t1 set b=repeat('B',100);
connection b;
select a,left(b,40) from t1 natural join t2;
connection a;
rollback;
connection b;
select a,left(b,40) from t1 natural join t2;
connection default;
disconnect a;
disconnect b;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
drop table t1,t2;
# The following should fail in non-strict mode too.
# (The fix of Bug #50945 only affects REDUNDANT and COMPACT tables.)
SET SESSION innodb_strict_mode = off;
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1(
c TEXT NOT NULL, d TEXT NOT NULL,
PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1(
c TEXT NOT NULL, d TEXT NOT NULL,
PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 CHARSET=ASCII;
CREATE TABLE t1(
c TEXT NOT NULL, d TEXT NOT NULL,
PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 CHARSET=ASCII;
drop table t1;
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1(c TEXT, PRIMARY KEY (c(440)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
CREATE TABLE t1(c TEXT, PRIMARY KEY (c(438)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
INSERT INTO t1 VALUES(REPEAT('A',512)),(REPEAT('B',512));
DROP TABLE t1;
#
# Test blob column inheritance (mantis issue#36)
#
create table t1( c1 int not null, c2 blob, c3 blob, c4 blob,
primary key(c1, c2(22), c3(22)))
engine = innodb row_format = dynamic;
begin;
insert into t1 values(1, repeat('A', 20000), repeat('B', 20000),
repeat('C', 20000));
update t1 set c3 = repeat('D', 20000) where c1 = 1;
commit;
# one blob column which is unchanged in update and part of PK
# one blob column which is changed and part of of PK
# one blob column which is not part of PK and is unchanged
select count(*) from t1 where c2 = repeat('A', 20000);
select count(*) from t1 where c3 = repeat('D', 20000);
select count(*) from t1 where c4 = repeat('C', 20000);
update t1 set c3 = repeat('E', 20000) where c1 = 1;
drop table t1;
#
#
# Test innodb_file_format
#
set global innodb_file_format=`0`;
select @@innodb_file_format;
set global innodb_file_format=`1`;
select @@innodb_file_format;
-- error ER_WRONG_VALUE_FOR_VAR
set global innodb_file_format=`2`;
-- error ER_WRONG_VALUE_FOR_VAR
set global innodb_file_format=`-1`;
set global innodb_file_format=`Antelope`;
set global innodb_file_format=`Barracuda`;
-- error ER_WRONG_VALUE_FOR_VAR
set global innodb_file_format=`Cheetah`;
-- error ER_WRONG_VALUE_FOR_VAR
set global innodb_file_format=`abc`;
-- error ER_WRONG_VALUE_FOR_VAR
set global innodb_file_format=`1a`;
-- error ER_WRONG_VALUE_FOR_VAR
set global innodb_file_format=``;
#test strict mode.
# this does not work anymore, has been removed from mysqltest
# -- enable_errors
set global innodb_file_per_table = on;
set global innodb_file_format = `1`;
set innodb_strict_mode = off;
create table t1 (id int primary key) engine = innodb key_block_size = 0;
drop table t1;
#set strict_mode
set innodb_strict_mode = on;
#Test different values of KEY_BLOCK_SIZE
create table t1 (id int primary key) engine = innodb key_block_size = 0;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb key_block_size = 9;
show warnings;
create table t3 (id int primary key) engine = innodb key_block_size = 1;
create table t4 (id int primary key) engine = innodb key_block_size = 2;
create table t5 (id int primary key) engine = innodb key_block_size = 4;
create table t6 (id int primary key) engine = innodb key_block_size = 8;
create table t7 (id int primary key) engine = innodb key_block_size = 16;
#check various ROW_FORMAT values.
create table t8 (id int primary key) engine = innodb row_format = compressed;
create table t9 (id int primary key) engine = innodb row_format = dynamic;
create table t10(id int primary key) engine = innodb row_format = compact;
create table t11(id int primary key) engine = innodb row_format = redundant;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
drop table t1, t3, t4, t5, t6, t7, t8, t9, t10, t11;
#test different values of ROW_FORMAT with KEY_BLOCK_SIZE
create table t1 (id int primary key) engine = innodb
key_block_size = 8 row_format = compressed;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb
key_block_size = 8 row_format = redundant;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t3 (id int primary key) engine = innodb
key_block_size = 8 row_format = compact;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t4 (id int primary key) engine = innodb
key_block_size = 8 row_format = dynamic;
show warnings;
create table t5 (id int primary key) engine = innodb
key_block_size = 8 row_format = default;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
drop table t1, t5;
#test multiple errors
--error ER_CANT_CREATE_TABLE
create table t1 (id int primary key) engine = innodb
key_block_size = 9 row_format = redundant;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb
key_block_size = 9 row_format = compact;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb
key_block_size = 9 row_format = dynamic;
show warnings;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
#test valid values with innodb_file_per_table unset
set global innodb_file_per_table = off;
--error ER_CANT_CREATE_TABLE
create table t1 (id int primary key) engine = innodb key_block_size = 1;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb key_block_size = 2;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t3 (id int primary key) engine = innodb key_block_size = 4;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t4 (id int primary key) engine = innodb key_block_size = 8;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t5 (id int primary key) engine = innodb key_block_size = 16;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t6 (id int primary key) engine = innodb row_format = compressed;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t7 (id int primary key) engine = innodb row_format = dynamic;
show warnings;
create table t8 (id int primary key) engine = innodb row_format = compact;
create table t9 (id int primary key) engine = innodb row_format = redundant;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
drop table t8, t9;
#test valid values with innodb_file_format unset
set global innodb_file_per_table = on;
set global innodb_file_format = `0`;
--error ER_CANT_CREATE_TABLE
create table t1 (id int primary key) engine = innodb key_block_size = 1;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t2 (id int primary key) engine = innodb key_block_size = 2;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t3 (id int primary key) engine = innodb key_block_size = 4;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t4 (id int primary key) engine = innodb key_block_size = 8;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t5 (id int primary key) engine = innodb key_block_size = 16;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t6 (id int primary key) engine = innodb row_format = compressed;
show warnings;
--error ER_CANT_CREATE_TABLE
create table t7 (id int primary key) engine = innodb row_format = dynamic;
show warnings;
create table t8 (id int primary key) engine = innodb row_format = compact;
create table t9 (id int primary key) engine = innodb row_format = redundant;
SELECT table_schema, table_name, row_format, data_length, index_length
FROM information_schema.tables WHERE engine='innodb';
drop table t8, t9;
eval set global innodb_file_per_table=$per_table;
eval set global innodb_file_format=$format;
#
# Testing of tablespace tagging
#
-- disable_info
set global innodb_file_per_table=on;
set global innodb_file_format=`Barracuda`;
set global innodb_file_format_max=`Antelope`;
create table normal_table (
c1 int
) engine = innodb;
select @@innodb_file_format_max;
create table zip_table (
c1 int
) engine = innodb key_block_size = 8;
select @@innodb_file_format_max;
set global innodb_file_format_max=`Antelope`;
select @@innodb_file_format_max;
-- disable_result_log
show table status;
-- enable_result_log
select @@innodb_file_format_max;
drop table normal_table, zip_table;
-- disable_result_log
#
# restore environment to the state it was before this test execution
#
-- disable_query_log
eval set global innodb_file_format=$format;
eval set global innodb_file_per_table=$per_table;
eval set session innodb_strict_mode=$innodb_strict_mode_orig;
|