~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to mysql-test/suite/innodb/t/innodb_misc1.test

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- source include/have_innodb.inc
 
2
 
 
3
let $MYSQLD_DATADIR= `select @@datadir`;
 
4
 
 
5
# Save the original values of some variables in order to be able to
 
6
# estimate how much they have changed during the tests. Previously this
 
7
# test assumed that e.g. rows_deleted is 0 here and after deleting 23
 
8
# rows it expected that rows_deleted will be 23. Now we do not make
 
9
# assumptions about the values of the variables at the beginning, e.g.
 
10
# rows_deleted should be 23 + "rows_deleted before the test". This allows
 
11
# the test to be run multiple times without restarting the mysqld server.
 
12
# See Bug#43309 Test main.innodb can't be run twice
 
13
-- disable_query_log
 
14
SET @innodb_thread_concurrency_orig = @@innodb_thread_concurrency;
 
15
-- enable_query_log
 
16
 
 
17
--disable_warnings
 
18
drop table if exists t1,t2,t3,t4;
 
19
drop database if exists mysqltest;
 
20
--enable_warnings
 
21
 
 
22
# InnoDB specific varchar tests
 
23
create table t1 (v varchar(16384)) engine=innodb;
 
24
drop table t1;
 
25
 
 
26
#
 
27
# BUG#11039 Wrong key length in min()
 
28
#
 
29
 
 
30
create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
 
31
insert into t1 values ('8', '6'), ('4', '7');
 
32
select min(a) from t1;
 
33
select min(b) from t1 where a='8';
 
34
drop table t1;
 
35
 
 
36
#
 
37
# Bug #11080 & #11005  Multi-row REPLACE fails on a duplicate key error
 
38
#
 
39
 
 
40
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
 
41
insert into t1 (b) values (1);
 
42
replace into t1 (b) values (2), (1), (3);
 
43
select * from t1;
 
44
truncate table t1;
 
45
insert into t1 (b) values (1);
 
46
replace into t1 (b) values (2);
 
47
replace into t1 (b) values (1);
 
48
replace into t1 (b) values (3);
 
49
select * from t1;
 
50
drop table t1;
 
51
 
 
52
create table t1 (rowid int not null auto_increment, val int not null,primary
 
53
key (rowid), unique(val)) engine=innodb;
 
54
replace into t1 (val) values ('1'),('2');
 
55
replace into t1 (val) values ('1'),('2');
 
56
--error ER_DUP_ENTRY
 
57
insert into t1 (val) values ('1'),('2');
 
58
select * from t1;
 
59
drop table t1;
 
60
 
 
61
#
 
62
# Test that update does not change internal auto-increment value
 
63
#
 
64
 
 
65
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
 
66
insert into t1 (val) values (1);
 
67
update t1 set a=2 where a=1;
 
68
# We should get the following error because InnoDB does not update the counter
 
69
--error ER_DUP_ENTRY
 
70
insert into t1 (val) values (1);
 
71
select * from t1;
 
72
drop table t1;
 
73
#
 
74
# Bug #10465
 
75
#
 
76
 
 
77
--disable_warnings
 
78
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
 
79
--enable_warnings
 
80
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
 
81
SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
 
82
SELECT GRADE  FROM t1 WHERE GRADE= 151;
 
83
DROP TABLE t1;
 
84
 
 
85
#
 
86
# Bug #12340 multitable delete deletes only one record
 
87
#
 
88
create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
 
89
create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
 
90
insert into t2 values ('aa','cc');
 
91
insert into t1 values ('aa','bb'),('aa','cc');
 
92
delete t1 from t1,t2 where f1=f3 and f4='cc';
 
93
select * from t1;
 
94
drop table t1,t2;
 
95
 
 
96
#
 
97
# Test that the slow TRUNCATE implementation resets autoincrement columns
 
98
# (bug #11946)
 
99
#
 
100
 
 
101
CREATE TABLE t1 (
 
102
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
 
103
) ENGINE=InnoDB;
 
104
 
 
105
CREATE TABLE t2 (
 
106
id INTEGER NOT NULL,
 
107
FOREIGN KEY (id) REFERENCES t1 (id)
 
108
) ENGINE=InnoDB;
 
109
 
 
110
INSERT INTO t1 (id) VALUES (NULL);
 
111
SELECT * FROM t1;
 
112
--error ER_TRUNCATE_ILLEGAL_FK
 
113
TRUNCATE t1;
 
114
INSERT INTO t1 (id) VALUES (NULL);
 
115
SELECT * FROM t1;
 
116
 
 
117
# continued from above; test that doing a slow TRUNCATE on a table with 0
 
118
# rows resets autoincrement columns
 
119
DELETE FROM t1;
 
120
--error ER_TRUNCATE_ILLEGAL_FK
 
121
TRUNCATE t1;
 
122
INSERT INTO t1 (id) VALUES (NULL);
 
123
SELECT * FROM t1;
 
124
DROP TABLE t2, t1;
 
125
 
 
126
# Test that foreign keys in temporary tables are not accepted (bug #12084)
 
127
CREATE TABLE t1
 
128
(
 
129
 id INT PRIMARY KEY
 
130
) ENGINE=InnoDB;
 
131
 
 
132
--error 1005,1005
 
133
CREATE TEMPORARY TABLE t2
 
134
(
 
135
 id INT NOT NULL PRIMARY KEY,
 
136
 b INT,
 
137
 FOREIGN KEY (b) REFERENCES test.t1(id)
 
138
) ENGINE=InnoDB;
 
139
DROP TABLE t1;
 
140
 
 
141
#
 
142
# Test that index column max sizes are honored (bug #13315)
 
143
#
 
144
 
 
145
# prefix index
 
146
create table t1 (col1 varchar(2000), index (col1(767)))
 
147
 character set = latin1 engine = innodb;
 
148
 
 
149
# normal indexes
 
150
create table t2 (col1 char(255), index (col1))
 
151
 character set = latin1 engine = innodb;
 
152
create table t3 (col1 binary(255), index (col1))
 
153
 character set = latin1 engine = innodb;
 
154
create table t4 (col1 varchar(767), index (col1))
 
155
 character set = latin1 engine = innodb;
 
156
create table t5 (col1 varchar(767) primary key)
 
157
 character set = latin1 engine = innodb;
 
158
create table t6 (col1 varbinary(767) primary key)
 
159
 character set = latin1 engine = innodb;
 
160
create table t7 (col1 text, index(col1(767)))
 
161
 character set = latin1 engine = innodb;
 
162
create table t8 (col1 blob, index(col1(767)))
 
163
 character set = latin1 engine = innodb;
 
164
 
 
165
# multi-column indexes are allowed to be longer
 
166
create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
 
167
 character set = latin1 engine = innodb;
 
168
 
 
169
show create table t9;
 
170
 
 
171
drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
 
172
 
 
173
# these should have their index length trimmed
 
174
create table t1 (col1 varchar(768), index(col1))
 
175
 character set = latin1 engine = innodb;
 
176
create table t2 (col1 varbinary(768), index(col1))
 
177
 character set = latin1 engine = innodb;
 
178
create table t3 (col1 text, index(col1(768)))
 
179
 character set = latin1 engine = innodb;
 
180
create table t4 (col1 blob, index(col1(768)))
 
181
 character set = latin1 engine = innodb;
 
182
 
 
183
show create table t1;
 
184
 
 
185
drop table t1, t2, t3, t4;
 
186
 
 
187
# these should be refused
 
188
--error 1071
 
189
create table t1 (col1 varchar(768) primary key)
 
190
 character set = latin1 engine = innodb;
 
191
--error 1071
 
192
create table t2 (col1 varbinary(768) primary key)
 
193
 character set = latin1 engine = innodb;
 
194
--error 1071
 
195
create table t3 (col1 text, primary key(col1(768)))
 
196
 character set = latin1 engine = innodb;
 
197
--error 1071
 
198
create table t4 (col1 blob, primary key(col1(768)))
 
199
 character set = latin1 engine = innodb;
 
200
 
 
201
#
 
202
# Test improved foreign key error messages (bug #3443)
 
203
#
 
204
 
 
205
CREATE TABLE t1
 
206
(
 
207
 id INT PRIMARY KEY
 
208
) ENGINE=InnoDB;
 
209
 
 
210
CREATE TABLE t2
 
211
(
 
212
 v INT,
 
213
 CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
 
214
) ENGINE=InnoDB;
 
215
 
 
216
--error 1452
 
217
INSERT INTO t2 VALUES(2);
 
218
 
 
219
INSERT INTO t1 VALUES(1);
 
220
INSERT INTO t2 VALUES(1);
 
221
 
 
222
--error 1451
 
223
DELETE FROM t1 WHERE id = 1;
 
224
 
 
225
--error 1217
 
226
DROP TABLE t1;
 
227
 
 
228
SET FOREIGN_KEY_CHECKS=0;
 
229
DROP TABLE t1;
 
230
SET FOREIGN_KEY_CHECKS=1;
 
231
 
 
232
--error 1452
 
233
INSERT INTO t2 VALUES(3);
 
234
 
 
235
DROP TABLE t2;
 
236
#
 
237
# Test that checksum table uses a consistent read Bug #12669
 
238
#
 
239
connect (a,localhost,root,,);
 
240
connect (b,localhost,root,,);
 
241
connection a;
 
242
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
 
243
insert into t1 values (1),(2);
 
244
set autocommit=0;
 
245
checksum table t1;
 
246
connection b;
 
247
insert into t1 values(3);
 
248
connection a;
 
249
#
 
250
# Here checksum should not see insert
 
251
#
 
252
checksum table t1;
 
253
connection a;
 
254
commit;
 
255
checksum table t1;
 
256
commit;
 
257
drop table t1;
 
258
#
 
259
# autocommit = 1
 
260
#
 
261
connection a;
 
262
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
 
263
insert into t1 values (1),(2);
 
264
set autocommit=1;
 
265
checksum table t1;
 
266
connection b;
 
267
set autocommit=1;
 
268
insert into t1 values(3);
 
269
connection a;
 
270
#
 
271
# Here checksum sees insert
 
272
#
 
273
checksum table t1;
 
274
drop table t1;
 
275
 
 
276
connection default;
 
277
disconnect a;
 
278
disconnect b;
 
279
 
 
280
# tests for bugs #9802 and #13778
 
281
 
 
282
# test that FKs between invalid types are not accepted
 
283
 
 
284
set foreign_key_checks=0;
 
285
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
 
286
# Embedded server doesn't chdir to data directory
 
287
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
 
288
-- error 1005
 
289
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
 
290
set foreign_key_checks=1;
 
291
drop table t2;
 
292
 
 
293
# test that FKs between different charsets are not accepted in CREATE even
 
294
# when f_k_c is 0
 
295
 
 
296
set foreign_key_checks=0;
 
297
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
 
298
# Embedded server doesn't chdir to data directory
 
299
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
 
300
-- error 1005
 
301
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
 
302
set foreign_key_checks=1;
 
303
drop table t1;
 
304
 
 
305
# test that invalid datatype conversions with ALTER are not allowed
 
306
 
 
307
set foreign_key_checks=0;
 
308
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
 
309
create table t1(a varchar(10) primary key) engine = innodb;
 
310
-- error 1025,1025
 
311
alter table t1 modify column a int;
 
312
set foreign_key_checks=1;
 
313
drop table t2,t1;
 
314
 
 
315
# test that charset conversions with ALTER are allowed when f_k_c is 0
 
316
 
 
317
set foreign_key_checks=0;
 
318
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
 
319
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
 
320
alter table t1 convert to character set utf8;
 
321
set foreign_key_checks=1;
 
322
drop table t2,t1;
 
323
 
 
324
# test that RENAME does not allow invalid charsets when f_k_c is 0
 
325
 
 
326
set foreign_key_checks=0;
 
327
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
 
328
create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
 
329
# Embedded server doesn't chdir to data directory
 
330
--replace_result $MYSQLD_DATADIR ./ master-data/ ''
 
331
-- error 1025
 
332
rename table t3 to t1;
 
333
set foreign_key_checks=1;
 
334
drop table t2,t3;
 
335
 
 
336
# test that foreign key errors are reported correctly (Bug #15550)
 
337
 
 
338
create table t1(a int primary key) row_format=redundant engine=innodb;
 
339
create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
 
340
create table t3(a int primary key) row_format=compact engine=innodb;
 
341
create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
 
342
 
 
343
insert into t1 values(1);
 
344
insert into t3 values(1);
 
345
-- error 1452
 
346
insert into t2 values(2);
 
347
-- error 1452
 
348
insert into t4 values(2);
 
349
insert into t2 values(1);
 
350
insert into t4 values(1);
 
351
-- error 1451
 
352
update t1 set a=2;
 
353
-- error 1452
 
354
update t2 set a=2;
 
355
-- error 1451
 
356
update t3 set a=2;
 
357
-- error 1452
 
358
update t4 set a=2;
 
359
--error ER_TRUNCATE_ILLEGAL_FK
 
360
truncate t1;
 
361
--error ER_TRUNCATE_ILLEGAL_FK
 
362
truncate t3;
 
363
truncate t2;
 
364
truncate t4;
 
365
--error ER_TRUNCATE_ILLEGAL_FK
 
366
truncate t1;
 
367
--error ER_TRUNCATE_ILLEGAL_FK
 
368
truncate t3;
 
369
 
 
370
drop table t4,t3,t2,t1;
 
371
 
 
372
 
 
373
#
 
374
# Test that we can create a large (>1K) key
 
375
#
 
376
create table t1 (a varchar(255) character set utf8,
 
377
                 b varchar(255) character set utf8,
 
378
                 c varchar(255) character set utf8,
 
379
                 d varchar(255) character set utf8,
 
380
                 key (a,b,c,d)) engine=innodb;
 
381
drop table t1;
 
382
--error ER_TOO_LONG_KEY
 
383
create table t1 (a varchar(255) character set utf8,
 
384
                 b varchar(255) character set utf8,
 
385
                 c varchar(255) character set utf8,
 
386
                 d varchar(255) character set utf8,
 
387
                 e varchar(255) character set utf8,
 
388
                 key (a,b,c,d,e)) engine=innodb;
 
389
 
 
390
 
 
391
# test the padding of BINARY types and collations (Bug #14189)
 
392
 
 
393
create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
 
394
create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
 
395
create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
 
396
create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
 
397
 
 
398
insert into t1 values (0x41),(0x4120),(0x4100);
 
399
-- error ER_DUP_ENTRY
 
400
insert into t2 values (0x41),(0x4120),(0x4100);
 
401
insert into t2 values (0x41),(0x4120);
 
402
-- error ER_DUP_ENTRY
 
403
insert into t3 values (0x41),(0x4120),(0x4100);
 
404
insert into t3 values (0x41),(0x4100);
 
405
-- error ER_DUP_ENTRY
 
406
insert into t4 values (0x41),(0x4120),(0x4100);
 
407
insert into t4 values (0x41),(0x4100);
 
408
select hex(s1) from t1;
 
409
select hex(s1) from t2;
 
410
select hex(s1) from t3;
 
411
select hex(s1) from t4;
 
412
drop table t1,t2,t3,t4;
 
413
 
 
414
create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
 
415
create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
 
416
 
 
417
insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
 
418
-- error 1452
 
419
insert into t2 values(0x42);
 
420
insert into t2 values(0x41);
 
421
select hex(s1) from t2;
 
422
update t1 set s1=0x123456 where a=2;
 
423
select hex(s1) from t2;
 
424
-- error 1451
 
425
update t1 set s1=0x12 where a=1;
 
426
-- error 1451
 
427
update t1 set s1=0x12345678 where a=1;
 
428
-- error 1451
 
429
update t1 set s1=0x123457 where a=1;
 
430
update t1 set s1=0x1220 where a=1;
 
431
select hex(s1) from t2;
 
432
update t1 set s1=0x1200 where a=1;
 
433
select hex(s1) from t2;
 
434
update t1 set s1=0x4200 where a=1;
 
435
select hex(s1) from t2;
 
436
-- error 1451
 
437
delete from t1 where a=1;
 
438
delete from t1 where a=2;
 
439
update t2 set s1=0x4120;
 
440
-- error 1451
 
441
delete from t1;
 
442
delete from t1 where a!=3;
 
443
select a,hex(s1) from t1;
 
444
select hex(s1) from t2;
 
445
 
 
446
drop table t2,t1;
 
447
 
 
448
create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
 
449
create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
 
450
 
 
451
insert into t1 values(1,0x4100),(2,0x41);
 
452
insert into t2 values(0x41);
 
453
select hex(s1) from t2;
 
454
update t1 set s1=0x1234 where a=1;
 
455
select hex(s1) from t2;
 
456
update t1 set s1=0x12 where a=2;
 
457
select hex(s1) from t2;
 
458
delete from t1 where a=1;
 
459
-- error 1451
 
460
delete from t1 where a=2;
 
461
select a,hex(s1) from t1;
 
462
select hex(s1) from t2;
 
463
 
 
464
drop table t2,t1;
 
465
# Ensure that <tablename>_ibfk_0 is not mistreated as a
 
466
# generated foreign key identifier.  (Bug #16387)
 
467
 
 
468
CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
 
469
CREATE TABLE t2(a INT) ENGINE=InnoDB;
 
470
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
 
471
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
 
472
ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
 
473
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
 
474
SHOW CREATE TABLE t2;
 
475
DROP TABLE t2,t1;
 
476
 
 
477
#
 
478
# Test case for bug #16229: MySQL/InnoDB uses full explicit table locks in trigger processing
 
479
#
 
480
 
 
481
connect (a,localhost,root,,);
 
482
connect (b,localhost,root,,);
 
483
connection a;
 
484
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
485
insert into t1(a) values (1),(2),(3);
 
486
commit;
 
487
delimiter |;
 
488
# in 5.5+, this needs to be created before the UPDATE due to meta-data locking
 
489
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
 
490
delimiter ;|
 
491
connection b;
 
492
set autocommit = 0;
 
493
update t1 set b = 5 where a = 2;
 
494
connection a;
 
495
set autocommit = 0;
 
496
connection a;
 
497
insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
 
498
(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
 
499
(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
 
500
(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
 
501
(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
 
502
connection b;
 
503
commit;
 
504
connection a;
 
505
commit;
 
506
drop trigger t1t;
 
507
drop table t1;
 
508
disconnect a;
 
509
disconnect b;
 
510
#
 
511
# Another trigger test
 
512
#
 
513
connect (a,localhost,root,,);
 
514
connect (b,localhost,root,,);
 
515
connection a;
 
516
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
517
create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
518
create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
519
create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
520
create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
521
insert into t1(a) values (1),(2),(3);
 
522
insert into t2(a) values (1),(2),(3);
 
523
insert into t3(a) values (1),(2),(3);
 
524
insert into t4(a) values (1),(2),(3);
 
525
insert into t3(a) values (5),(7),(8);
 
526
insert into t4(a) values (5),(7),(8);
 
527
insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
 
528
 
 
529
delimiter |;
 
530
create trigger t1t before insert on t1 for each row begin
 
531
    INSERT INTO t2 SET a = NEW.a;
 
532
end |
 
533
 
 
534
create trigger t2t before insert on t2 for each row begin
 
535
    DELETE FROM t3 WHERE a = NEW.a;
 
536
end |
 
537
 
 
538
create trigger t3t before delete on t3 for each row begin
 
539
    UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
 
540
end |
 
541
 
 
542
create trigger t4t before update on t4 for each row begin
 
543
    UPDATE t5 SET b = b + 1 where a = NEW.a;
 
544
end |
 
545
delimiter ;|
 
546
commit;
 
547
set autocommit = 0;
 
548
update t1 set b = b + 5 where a = 1;
 
549
update t2 set b = b + 5 where a = 1;
 
550
update t3 set b = b + 5 where a = 1;
 
551
update t4 set b = b + 5 where a = 1;
 
552
insert into t5(a) values(20);
 
553
connection b;
 
554
set autocommit = 0;
 
555
insert into t1(a) values(7);
 
556
insert into t2(a) values(8);
 
557
delete from t2 where a = 3;
 
558
update t4 set b = b + 1 where a = 3;
 
559
commit;
 
560
connection a;
 
561
drop trigger t1t;
 
562
drop trigger t2t;
 
563
drop trigger t3t;
 
564
drop trigger t4t;
 
565
drop table t1, t2, t3, t4, t5;
 
566
connection default;
 
567
disconnect a;
 
568
disconnect b;
 
569
 
 
570
#
 
571
# Test that cascading updates leading to duplicate keys give the correct
 
572
# error message (bug #9680)
 
573
#
 
574
 
 
575
CREATE TABLE t1 (
 
576
  field1 varchar(8) NOT NULL DEFAULT '',
 
577
  field2 varchar(8) NOT NULL DEFAULT '',
 
578
  PRIMARY KEY  (field1, field2)
 
579
) ENGINE=InnoDB;
 
580
 
 
581
CREATE TABLE t2 (
 
582
  field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
 
583
  FOREIGN KEY (field1) REFERENCES t1 (field1)
 
584
    ON DELETE CASCADE ON UPDATE CASCADE
 
585
) ENGINE=InnoDB;
 
586
 
 
587
INSERT INTO t1 VALUES ('old', 'somevalu');
 
588
INSERT INTO t1 VALUES ('other', 'anyvalue');
 
589
 
 
590
INSERT INTO t2 VALUES ('old');
 
591
INSERT INTO t2 VALUES ('other');
 
592
 
 
593
--error ER_FOREIGN_DUPLICATE_KEY
 
594
UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
 
595
 
 
596
DROP TABLE t2;
 
597
DROP TABLE t1;
 
598
 
 
599
#
 
600
# Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE
 
601
#
 
602
create table t1 (
 
603
  c1 bigint not null,
 
604
  c2 bigint not null,
 
605
  primary key (c1),
 
606
  unique  key (c2)
 
607
) engine=innodb;
 
608
#
 
609
create table t2 (
 
610
  c1 bigint not null,
 
611
  primary key (c1)
 
612
) engine=innodb;
 
613
#
 
614
alter table t1 add constraint c2_fk foreign key (c2)
 
615
  references t2(c1) on delete cascade;
 
616
show create table t1;
 
617
#
 
618
alter table t1 drop foreign key c2_fk;
 
619
show create table t1;
 
620
#
 
621
drop table t1, t2;
 
622
 
 
623
#
 
624
# Bug #14360: problem with intervals
 
625
#
 
626
 
 
627
create table t1(a date) engine=innodb;
 
628
create table t2(a date, key(a)) engine=innodb;
 
629
insert into t1 values('2005-10-01');
 
630
insert into t2 values('2005-10-01');
 
631
select * from t1, t2
 
632
  where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
 
633
drop table t1, t2;
 
634
 
 
635
create table t1 (id int not null, f_id int not null, f int not null,
 
636
primary key(f_id, id)) engine=innodb;
 
637
create table t2 (id int not null,s_id int not null,s varchar(200),
 
638
primary key(id)) engine=innodb;
 
639
INSERT INTO t1 VALUES (8, 1, 3);
 
640
INSERT INTO t1 VALUES (1, 2, 1);
 
641
INSERT INTO t2 VALUES (1, 0, '');
 
642
INSERT INTO t2 VALUES (8, 1, '');
 
643
commit;
 
644
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
 
645
WHERE mm.id IS NULL;
 
646
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
 
647
where mm.id is null lock in share mode;
 
648
drop table t1,t2;
 
649
 
 
650
#
 
651
# Test case where X-locks on unused rows should be released in a
 
652
# update (because READ COMMITTED isolation level)
 
653
#
 
654
 
 
655
connect (a,localhost,root,,);
 
656
connect (b,localhost,root,,);
 
657
connection a;
 
658
create table t1(a int not null, b int, primary key(a)) engine=innodb;
 
659
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
 
660
commit;
 
661
SET binlog_format='MIXED';
 
662
set autocommit = 0;
 
663
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
664
update t1 set b = 5 where b = 1;
 
665
connection b;
 
666
SET binlog_format='MIXED';
 
667
set autocommit = 0;
 
668
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
669
#
 
670
# X-lock to record (7,3) should be released in a update
 
671
#
 
672
select * from t1 where a = 7 and b = 3 for update;
 
673
connection a;
 
674
commit;
 
675
connection b;
 
676
commit;
 
677
drop table t1;
 
678
connection default;
 
679
disconnect a;
 
680
disconnect b;
 
681
 
 
682
#
 
683
# Test case where no locks should be released (because we are not
 
684
# using READ COMMITTED isolation level)
 
685
#
 
686
 
 
687
connect (a,localhost,root,,);
 
688
connect (b,localhost,root,,);
 
689
connection a;
 
690
create table t1(a int not null, b int, primary key(a)) engine=innodb;
 
691
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
 
692
commit;
 
693
set autocommit = 0;
 
694
select * from t1 lock in share mode;
 
695
update t1 set b = 5 where b = 1;
 
696
connection b;
 
697
set autocommit = 0;
 
698
#
 
699
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
 
700
#
 
701
--error 1205
 
702
select * from t1 where a = 2 and b = 2 for update;
 
703
#
 
704
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
 
705
#
 
706
--error 1205
 
707
connection a;
 
708
commit;
 
709
connection b;
 
710
commit;
 
711
connection default;
 
712
disconnect a;
 
713
disconnect b;
 
714
drop table t1;
 
715
 
 
716
#
 
717
# Consistent read should be used in following selects
 
718
#
 
719
# 1) INSERT INTO ... SELECT
 
720
# 2) UPDATE ... = ( SELECT ...)
 
721
# 3) CREATE ... SELECT
 
722
 
 
723
connect (a,localhost,root,,);
 
724
connect (b,localhost,root,,);
 
725
connection a;
 
726
create table t1(a int not null, b int, primary key(a)) engine=innodb;
 
727
insert into t1 values (1,2),(5,3),(4,2);
 
728
create table t2(d int not null, e int, primary key(d)) engine=innodb;
 
729
insert into t2 values (8,6),(12,1),(3,1);
 
730
commit;
 
731
set autocommit = 0;
 
732
select * from t2 for update;
 
733
connection b;
 
734
SET binlog_format='MIXED';
 
735
set autocommit = 0;
 
736
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
737
insert into t1 select * from t2;
 
738
update t1 set b = (select e from t2 where a = d);
 
739
create table t3(d int not null, e int, primary key(d)) engine=innodb
 
740
select * from t2;
 
741
commit;
 
742
connection a;
 
743
commit;
 
744
connection default;
 
745
disconnect a;
 
746
disconnect b;
 
747
drop table t1, t2, t3;
 
748
 
 
749
#
 
750
# Consistent read should not be used if
 
751
#
 
752
# (a) isolation level is serializable OR
 
753
# (b) select ... lock in share mode OR
 
754
# (c) select ... for update
 
755
#
 
756
# in following queries:
 
757
#
 
758
# 1) INSERT INTO ... SELECT
 
759
# 2) UPDATE ... = ( SELECT ...)
 
760
# 3) CREATE ... SELECT
 
761
 
 
762
connect (a,localhost,root,,);
 
763
connect (b,localhost,root,,);
 
764
connect (c,localhost,root,,);
 
765
connect (d,localhost,root,,);
 
766
connect (e,localhost,root,,);
 
767
connect (f,localhost,root,,);
 
768
connect (g,localhost,root,,);
 
769
connect (h,localhost,root,,);
 
770
connect (i,localhost,root,,);
 
771
connect (j,localhost,root,,);
 
772
connection a;
 
773
create table t1(a int not null, b int, primary key(a)) engine=innodb;
 
774
insert into t1 values (1,2),(5,3),(4,2);
 
775
create table t2(a int not null, b int, primary key(a)) engine=innodb;
 
776
insert into t2 values (8,6),(12,1),(3,1);
 
777
create table t3(d int not null, b int, primary key(d)) engine=innodb;
 
778
insert into t3 values (8,6),(12,1),(3,1);
 
779
create table t5(a int not null, b int, primary key(a)) engine=innodb;
 
780
insert into t5 values (1,2),(5,3),(4,2);
 
781
create table t6(d int not null, e int, primary key(d)) engine=innodb;
 
782
insert into t6 values (8,6),(12,1),(3,1);
 
783
create table t8(a int not null, b int, primary key(a)) engine=innodb;
 
784
insert into t8 values (1,2),(5,3),(4,2);
 
785
create table t9(d int not null, e int, primary key(d)) engine=innodb;
 
786
insert into t9 values (8,6),(12,1),(3,1);
 
787
commit;
 
788
set autocommit = 0;
 
789
select * from t2 for update;
 
790
connection b;
 
791
SET binlog_format='MIXED';
 
792
set autocommit = 0;
 
793
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 
794
--send
 
795
insert into t1 select * from t2;
 
796
connection c;
 
797
SET binlog_format='MIXED';
 
798
set autocommit = 0;
 
799
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 
800
--send
 
801
update t3 set b = (select b from t2 where a = d);
 
802
connection d;
 
803
SET binlog_format='MIXED';
 
804
set autocommit = 0;
 
805
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 
806
--send
 
807
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
 
808
connection e;
 
809
SET binlog_format='MIXED';
 
810
set autocommit = 0;
 
811
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
812
--send
 
813
insert into t5 (select * from t2 lock in share mode);
 
814
connection f;
 
815
SET binlog_format='MIXED';
 
816
set autocommit = 0;
 
817
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
818
--send
 
819
update t6 set e = (select b from t2 where a = d lock in share mode);
 
820
connection g;
 
821
SET binlog_format='MIXED';
 
822
set autocommit = 0;
 
823
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
824
--send
 
825
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
 
826
connection h;
 
827
SET binlog_format='MIXED';
 
828
set autocommit = 0;
 
829
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
830
--send
 
831
insert into t8 (select * from t2 for update);
 
832
connection i;
 
833
SET binlog_format='MIXED';
 
834
set autocommit = 0;
 
835
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
836
--send
 
837
update t9 set e = (select b from t2 where a = d for update);
 
838
connection j;
 
839
SET binlog_format='MIXED';
 
840
set autocommit = 0;
 
841
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
842
--send
 
843
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
 
844
 
 
845
connection b;
 
846
--error 1205
 
847
reap;
 
848
 
 
849
connection c;
 
850
--error 1205
 
851
reap;
 
852
 
 
853
connection d;
 
854
--error 1205
 
855
reap;
 
856
 
 
857
connection e;
 
858
--error 1205
 
859
reap;
 
860
 
 
861
connection f;
 
862
--error 1205
 
863
reap;
 
864
 
 
865
connection g;
 
866
--error 1205
 
867
reap;
 
868
 
 
869
connection h;
 
870
--error 1205
 
871
reap;
 
872
 
 
873
connection i;
 
874
--error 1205
 
875
reap;
 
876
 
 
877
connection j;
 
878
--error 1205
 
879
reap;
 
880
 
 
881
connection a;
 
882
commit;
 
883
 
 
884
connection default;
 
885
disconnect a;
 
886
disconnect b;
 
887
disconnect c;
 
888
disconnect d;
 
889
disconnect e;
 
890
disconnect f;
 
891
disconnect g;
 
892
disconnect h;
 
893
disconnect i;
 
894
disconnect j;
 
895
drop table t1, t2, t3, t5, t6, t8, t9;
 
896
 
 
897
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
 
898
--error ER_WRONG_COLUMN_NAME
 
899
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
 
900
 
 
901
#
 
902
# Bug #17152: Wrong result with BINARY comparison on aliased column
 
903
#
 
904
 
 
905
CREATE TABLE t1 (
 
906
   a BIGINT(20) NOT NULL,
 
907
    PRIMARY KEY  (a)
 
908
 ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
 
909
 
 
910
CREATE TABLE t2 (
 
911
  a BIGINT(20) NOT NULL,
 
912
  b VARCHAR(128) NOT NULL,
 
913
  c TEXT NOT NULL,
 
914
  PRIMARY KEY  (a,b),
 
915
  KEY idx_t2_b_c (b,c(200)),
 
916
  CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a)
 
917
   ON DELETE CASCADE
 
918
 ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
 
919
 
 
920
INSERT INTO t1 VALUES (1);
 
921
INSERT INTO t2 VALUES (1, 'bar', 'vbar');
 
922
INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
 
923
INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
 
924
INSERT INTO t2 VALUES (1, 'customer_over', '1');
 
925
 
 
926
SELECT * FROM t2 WHERE b = 'customer_over';
 
927
SELECT * FROM t2 WHERE BINARY b = 'customer_over';
 
928
SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
 
929
/* Bang: Empty result set, above was expected: */
 
930
SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
 
931
SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
 
932
 
 
933
drop table t2, t1;
 
934
 
 
935
#
 
936
# Test optimize on table with open transaction
 
937
#
 
938
 
 
939
CREATE TABLE t1 ( a int ) ENGINE=innodb;
 
940
BEGIN;
 
941
INSERT INTO t1 VALUES (1);
 
942
OPTIMIZE TABLE t1;
 
943
DROP TABLE t1;
 
944
 
 
945
#
 
946
# Bug #24741 (existing cascade clauses disappear when adding foreign keys)
 
947
#
 
948
 
 
949
CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
 
950
 
 
951
CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
 
952
  CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
 
953
  ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
 
954
 
 
955
ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
 
956
DELETE CASCADE ON UPDATE CASCADE;
 
957
 
 
958
SHOW CREATE TABLE t2;
 
959
DROP TABLE t2, t1;
 
960
 
 
961
#
 
962
# Bug #25927: Prevent ALTER TABLE ... MODIFY ... NOT NULL on columns
 
963
# for which there is a foreign key constraint ON ... SET NULL.
 
964
#
 
965
 
 
966
CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
 
967
CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
 
968
INSERT INTO t1 VALUES (1);
 
969
INSERT INTO t2 VALUES (1);
 
970
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
 
971
# mysqltest first does replace_regex, then replace_result
 
972
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
 
973
# Embedded server doesn't chdir to data directory
 
974
--replace_result $MYSQLD_DATADIR ./ master-data/ ''
 
975
--error 1025
 
976
ALTER TABLE t2 MODIFY a INT NOT NULL;
 
977
DELETE FROM t1;
 
978
DROP TABLE t2,t1;
 
979
 
 
980
#
 
981
# Bug #26835: table corruption after delete+insert
 
982
#
 
983
 
 
984
CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
 
985
ENGINE=InnoDB;
 
986
INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
 
987
DELETE FROM t1;
 
988
INSERT INTO t1 VALUES ('DDD');
 
989
SELECT * FROM t1;
 
990
DROP TABLE t1;
 
991
 
 
992
#
 
993
# Bug #23313 (AUTO_INCREMENT=# not reported back for InnoDB tables)
 
994
# Bug #21404 (AUTO_INCREMENT value reset when Adding FKEY (or ALTER?))
 
995
#
 
996
 
 
997
CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
 
998
AUTO_INCREMENT=42;
 
999
 
 
1000
INSERT INTO t1 VALUES (0),(347),(0);
 
1001
SELECT * FROM t1;
 
1002
 
 
1003
SHOW CREATE TABLE t1;
 
1004
 
 
1005
CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
 
1006
INSERT INTO t2 VALUES(42),(347),(348);
 
1007
ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
 
1008
SHOW CREATE TABLE t1;
 
1009
 
 
1010
DROP TABLE t1,t2;
 
1011
 
 
1012
#
 
1013
# Bug #21101 (Prints wrong error message if max row size is too large)
 
1014
#
 
1015
SET innodb_strict_mode=ON;
 
1016
--error 1118
 
1017
CREATE TABLE t1 (
 
1018
        c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
 
1019
        c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
 
1020
        c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
 
1021
        c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
 
1022
        c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
 
1023
        c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
 
1024
        c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
 
1025
        c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
 
1026
        ) ENGINE = InnoDB;
 
1027
SET innodb_strict_mode=OFF;
 
1028
 
 
1029
#
 
1030
# Bug #31860 InnoDB assumes AUTOINC values can only be positive.
 
1031
#
 
1032
DROP TABLE IF EXISTS t1;
 
1033
CREATE TABLE t1(
 
1034
        id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
 
1035
        ) ENGINE=InnoDB;
 
1036
INSERT INTO t1 VALUES(-10);
 
1037
SELECT * FROM t1;
 
1038
#
 
1039
# NOTE: The server really needs to be restarted at this point
 
1040
# for the test to be useful.
 
1041
#
 
1042
# Without the fix InnoDB would trip over an assertion here.
 
1043
INSERT INTO t1 VALUES(NULL);
 
1044
# The next value should be 1 and not -9 or a -ve number
 
1045
SELECT * FROM t1;
 
1046
DROP TABLE t1;
 
1047
 
 
1048
#
 
1049
# Bug #21409 Incorrect result returned when in READ-COMMITTED with
 
1050
# query_cache ON
 
1051
#
 
1052
CONNECT (c1,localhost,root,,);
 
1053
CONNECT (c2,localhost,root,,);
 
1054
CONNECTION c1;
 
1055
SET binlog_format='MIXED';
 
1056
SET TX_ISOLATION='read-committed';
 
1057
SET AUTOCOMMIT=0;
 
1058
DROP TABLE IF EXISTS t1, t2;
 
1059
CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
 
1060
CREATE TABLE t2 LIKE t1;
 
1061
SELECT * FROM t2;
 
1062
CONNECTION c2;
 
1063
SET binlog_format='MIXED';
 
1064
SET TX_ISOLATION='read-committed';
 
1065
SET AUTOCOMMIT=0;
 
1066
INSERT INTO t1 VALUES (1);
 
1067
COMMIT;
 
1068
CONNECTION c1;
 
1069
SELECT * FROM t1 WHERE a=1;
 
1070
DISCONNECT c1;
 
1071
DISCONNECT c2;
 
1072
CONNECT (c1,localhost,root,,);
 
1073
CONNECT (c2,localhost,root,,);
 
1074
CONNECTION c1;
 
1075
SET binlog_format='MIXED';
 
1076
SET TX_ISOLATION='read-committed';
 
1077
SET AUTOCOMMIT=0;
 
1078
SELECT * FROM t2;
 
1079
CONNECTION c2;
 
1080
SET binlog_format='MIXED';
 
1081
SET TX_ISOLATION='read-committed';
 
1082
SET AUTOCOMMIT=0;
 
1083
INSERT INTO t1 VALUES (2);
 
1084
COMMIT;
 
1085
CONNECTION c1;
 
1086
# The result set below should be the same for both selects
 
1087
SELECT * FROM t1 WHERE a=2;
 
1088
SELECT * FROM t1 WHERE a=2;
 
1089
DROP TABLE t1;
 
1090
DROP TABLE t2;
 
1091
DISCONNECT c1;
 
1092
DISCONNECT c2;
 
1093
CONNECTION default;
 
1094
 
 
1095
#
 
1096
# Bug #29157 UPDATE, changed rows incorrect
 
1097
#
 
1098
create table t1 (i int, j int) engine=innodb;
 
1099
insert into t1 (i, j) values (1, 1), (2, 2);
 
1100
--enable_info
 
1101
update t1 set j = 2;
 
1102
--disable_info
 
1103
drop table t1;
 
1104
 
 
1105
#
 
1106
# Bug #32440 InnoDB free space info does not appear in SHOW TABLE STATUS or
 
1107
# I_S
 
1108
#
 
1109
create table t1 (id int) comment='this is a comment' engine=innodb;
 
1110
select table_comment, data_free > 0 as data_free_is_set
 
1111
  from information_schema.tables
 
1112
  where table_schema='test' and table_name = 't1';
 
1113
drop table t1;
 
1114
 
 
1115
#
 
1116
# Bug 34920 test
 
1117
#
 
1118
CONNECTION default;
 
1119
CREATE TABLE t1 (
 
1120
        c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 
1121
        c2 VARCHAR(128) NOT NULL,
 
1122
        PRIMARY KEY(c1)
 
1123
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
 
1124
 
 
1125
CREATE TABLE t2 (
 
1126
        c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 
1127
        c2 INT(10) UNSIGNED DEFAULT NULL,
 
1128
        PRIMARY KEY(c1)
 
1129
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
 
1130
 
 
1131
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
 
1132
ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
 
1133
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
 
1134
DROP TABLE t2;
 
1135
DROP TABLE t1;
 
1136
# End 34920 test
 
1137
#
 
1138
# Bug #29507 TRUNCATE shows to many rows effected
 
1139
#
 
1140
CONNECTION default;
 
1141
CREATE TABLE t1 (c1 int default NULL,
 
1142
                 c2 int default NULL
 
1143
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
1144
 
 
1145
--enable_info
 
1146
TRUNCATE TABLE t1;
 
1147
 
 
1148
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
 
1149
TRUNCATE TABLE t1;
 
1150
 
 
1151
--disable_info
 
1152
DROP TABLE t1;
 
1153
#
 
1154
# Bug#35537 Innodb doesn't increment handler_update and handler_delete.
 
1155
#
 
1156
-- disable_query_log
 
1157
-- disable_result_log
 
1158
 
 
1159
CONNECT (c1,localhost,root,,);
 
1160
 
 
1161
DROP TABLE IF EXISTS bug35537;
 
1162
CREATE TABLE bug35537 (
 
1163
  c1 int
 
1164
) ENGINE=InnoDB;
 
1165
 
 
1166
INSERT INTO bug35537 VALUES (1);
 
1167
 
 
1168
-- enable_result_log
 
1169
 
 
1170
SHOW SESSION STATUS LIKE 'Handler_update%';
 
1171
SHOW SESSION STATUS LIKE 'Handler_delete%';
 
1172
 
 
1173
UPDATE bug35537 SET c1 = 2 WHERE c1 = 1;
 
1174
DELETE FROM bug35537 WHERE c1 = 2;
 
1175
 
 
1176
SHOW SESSION STATUS LIKE 'Handler_update%';
 
1177
SHOW SESSION STATUS LIKE 'Handler_delete%';
 
1178
 
 
1179
DROP TABLE bug35537;
 
1180
 
 
1181
DISCONNECT c1;
 
1182
CONNECTION default;
 
1183
 
 
1184
SET GLOBAL innodb_thread_concurrency = @innodb_thread_concurrency_orig;