Bug #45954 Foreign keys: crash if alter adding self-reference
Submitted: 5 Jul 2009 23:56 Modified: 20 Dec 2013 6:51
Reporter: Trudy Pelzer Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:6.1.0-alpha-debug OS:Linux (SUSE 10.2)
Assigned to: CPU Architecture:Any

[5 Jul 2009 23:56] Trudy Pelzer
Description:
I'm using mysql-6.1-fk-stage.
I start the server with mysqld --foreign-key-all-engines=1.

I create a parent table and a child table.

I use ALTER to add two columns.
The second added column refers to the first added column.
Crash.

How to repeat:
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (s1 CHAR(5) PRIMARY KEY) engine=innodb;
CREATE TABLE t2 (s1 CHAR(5)) engine=innodb;
ALTER TABLE t2 ADD COLUMN s3 CHAR(5) PRIMARY KEY,
               ADD COLUMN s4 CHAR(5) REFERENCES t2(s3);
[7 Jul 2009 7:00] Dmitry Lenev
Verified as described.
[7 Jul 2009 10:45] Dmitry Lenev
Hello!

The same crash is reproducible without any foreign keys with the help of the following test case:

--source include/have_innodb.inc

DROP TABLE IF EXISTS t2;
CREATE TABLE t2 (s1 CHAR(5)) engine=innodb;
ALTER TABLE t2 ADD COLUMN s3 CHAR(5) PRIMARY KEY,
               ADD COLUMN s4 CHAR(5), ADD KEY (s4);

Moreover it can be reproduced using mysql-6.0-runtime which means that is not related to new foreign key implementation.

Additional investigation shows that this bug is a duplicate of already known
bug #45052 "ALTER TABLE ADD COLUMN crashes server with multiple foreign key columns" which was fixed in mysql-azalea tree.

(Not closing as Duplicate yet, as it is not clear when fix for this bug will be merged into mysql-6.1-fk).
[20 Dec 2013 6:51] Erlend Dahl
6.x project was abandoned years ago.