Debian Codegraph @

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

raw
1 # Testcase for Bug #53592 - "crash replacing duplicates into
2 # table after fast alter table added unique key". The fix is to make
3 # sure index number lookup should go through "index translation table".
4
5
6 # Use FIC for index creation
7 set old_alter_table=0;
8
9 create table bug53592(a int) engine=innodb row_format=compact;
10
11 alter table bug53592 add column b text charset utf8;
12
13 alter table bug53592 add column c blob not null;
14
15 # Create a non-unique nonclustered index
16 create index bug53592_b on bug53592(b(81));
17
18 # Create a unique index, this unique index should have smaller
19 # index number than bug53592_b, since unique index ranks higher
20 # than regular index does
21 create unique index bug53592_c on bug53592(c(1));
22
23 # This will trigger a dup key error and will require fetching
24 # the index number through a index structure for the error reporting.
25 # To get the correct index number, the code should go through index
26 # translation table. Otherwise, it will get the wrong index
27 # number and later trigger a server crash.
28 SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
29 replace into bug53592 values (),();
30 SET sql_mode = default;
31
32 check table bug53592;
33
34 drop table bug53592;
35
36 # Running the same set of test when "old_alter_table" is turned on
37 set old_alter_table=1;
38
39 create table bug53592(a int) engine=innodb row_format=compact;
40
41 alter table bug53592 add column b text charset utf8;
42
43 alter table bug53592 add column c blob not null;
44
45 # Create a non-unique nonclustered index
46 create index bug53592_b on bug53592(b(81));
47
48 # Create a unique index
49 create unique index bug53592_c on bug53592(c(1));
50
51 # This will trigger a dup key error and will require fetching
52 # the index number through a index structure for the error reporting.
53 # To get the correct index number, the code should go through index
54 # translation table. Otherwise, it will get the wrong index
55 # number and later trigger a server crash.
56 SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
57 replace into bug53592 values (),();
58 SET sql_mode = default;
59
60 check table bug53592;
61 drop table bug53592;
62
63 # Test a dup key reported by foreign key constriant.
64 CREATE TABLE bug53592_1(
65 col1 int, col2 int,
66 PRIMARY KEY (col1, col2)
67 ) ENGINE=InnoDB;
68
69 CREATE TABLE bug53592_2 (
70 col int PRIMARY KEY,
71 FOREIGN KEY (col) REFERENCES bug53592_1 (col1)
72 ON DELETE CASCADE ON UPDATE CASCADE
73 ) ENGINE=InnoDB;
74
75 INSERT INTO bug53592_1 VALUES (1, 2);
76 INSERT INTO bug53592_1 VALUES (3, 4);
77
78 INSERT INTO bug53592_2 VALUES (1);
79 INSERT INTO bug53592_2 VALUES (3);
80
81 --error ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO
82 UPDATE bug53592_1 SET col1 = 3 WHERE col2 = 2;
83
84 drop table bug53592_2;
85 drop table bug53592_1;