| 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 |
--source include/have_innodb.inc |
| 6 |
|
| 7 |
create table bug53592(a int) engine=innodb row_format=compact; |
| 8 |
|
| 9 |
alter table bug53592 add column b text charset utf8; |
| 10 |
|
| 11 |
alter table bug53592 add column c blob not null; |
| 12 |
|
| 13 |
# Create a non-unique nonclustered index |
| 14 |
create index bug53592_b on bug53592(b(81)); |
| 15 |
|
| 16 |
# Create a unique index, this unique index should have smaller |
| 17 |
# index number than bug53592_b, since unique index ranks higher |
| 18 |
# than regular index does |
| 19 |
create unique index bug53592_c on bug53592(c(1)); |
| 20 |
|
| 21 |
# This will trigger a dup key error and will require fetching |
| 22 |
# the index number through a index structure for the error reporting. |
| 23 |
# To get the correct index number, the code should go through index |
| 24 |
# translation table. Otherwise, it will get the wrong index |
| 25 |
# number and later trigger a server crash. |
| 26 |
set statement sql_mode = '' for |
| 27 |
replace into bug53592 values (),(); |
| 28 |
|
| 29 |
check table bug53592; |
| 30 |
|
| 31 |
drop table bug53592; |
| 32 |
|
| 33 |
# Test a dup key reported by foreign key constriant. |
| 34 |
CREATE TABLE bug53592_1( |
| 35 |
col1 int, col2 int, |
| 36 |
PRIMARY KEY (col1, col2) |
| 37 |
) ENGINE=InnoDB; |
| 38 |
|
| 39 |
CREATE TABLE bug53592_2 ( |
| 40 |
col int PRIMARY KEY, |
| 41 |
FOREIGN KEY (col) REFERENCES bug53592_1 (col1) |
| 42 |
ON DELETE CASCADE ON UPDATE CASCADE |
| 43 |
) ENGINE=InnoDB; |
| 44 |
|
| 45 |
INSERT INTO bug53592_1 VALUES (1, 2); |
| 46 |
INSERT INTO bug53592_1 VALUES (3, 4); |
| 47 |
|
| 48 |
INSERT INTO bug53592_2 VALUES (1); |
| 49 |
INSERT INTO bug53592_2 VALUES (3); |
| 50 |
|
| 51 |
--error ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO |
| 52 |
UPDATE bug53592_1 SET col1 = 3 WHERE col2 = 2; |
| 53 |
|
| 54 |
drop table bug53592_2; |
| 55 |
drop table bug53592_1; |