| Bug #33027 | misleading error message for FK referencing non InnoDB table | ||
|---|---|---|---|
| Submitted: | 6 Dec 2007 1:55 | Modified: | 14 Dec 2007 9:19 |
| Reporter: | Kolbe Kegel | ||
| Status: | Verified | ||
| Category: | Server: InnoDB | Severity: | S4 (Feature request) |
| Version: | 5.1.22 | OS: | Any |
| Assigned to: | Heikki Tuuri | Target Version: | |
| Tags: | innodb, foreign keys, error | ||
| Triage: | Triaged: D5 (Feature request) | ||
[6 Dec 2007 1:55]
Kolbe Kegel
[6 Dec 2007 2:17]
Kolbe Kegel
A similar error is issued if trying to add a foreign key to an existing partitioned InnoDB table. create table t1 (id int not null primary key) engine=innodb partition by hash(id) partitions 2; create table t2 (id int not null primary key) engine=innodb partition by hash(id) partitions 2; alter table t2 add foreign key (id) references t1 (id); mysql 5.1.22-rc (root) [test]> create table t1 (id int not null primary key) engine=innodb partition by hash(id) partitions 2; Query OK, 0 rows affected (0.02 sec) mysql 5.1.22-rc (root) [test]> create table t2 (id int not null primary key) engine=innodb partition by hash(id) partitions 2; Query OK, 0 rows affected (0.00 sec) mysql 5.1.22-rc (root) [test]> alter table t2 add foreign key (id) references t1 (id); ERROR 1005 (HY000): Can't create table 'test.#sql-5d4a_2' (errno: 1) mysql 5.1.22-rc (root) [test]> show engine innodb status\G [...] ------------------------ LATEST FOREIGN KEY ERROR ------------------------ 071205 17:16:59 Error in foreign key constraint of table test/#sql-5d4a_2#P#p0: foreign key (id) references t1 (id): Cannot resolve table name close to: (id)
[6 Dec 2007 20:45]
Calvin Sun
looks like a duplicate of 32948.
[6 Dec 2007 20:48]
Kolbe Kegel
This is not a duplicate of 32948, really. This bug is about a misleading error message; the other bug is about behavior that is currently allowed but *should* produce an error message (better than those discussed in this bug, ideally).
[13 Dec 2007 11:36]
Mattias Jonsson
Not a partitioning bug, since the result is the same if you try to create a foreign key from a InnoDB table to a non InnoDB table. (A partitioned innodb does not use innodb storage engine at the table level and it is documented as not supported, just like MyISAM). 5.1.23: CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=MyISAM; CREATE TABLE t2 (a INT, FOREIGN KEY (a) REFERENCES t1 (a)) ENGINE=InnoDB; ERROR HY000: Can't create table 'test.t2' (errno: 150)
[13 Dec 2007 16:35]
Kolbe Kegel
... I wouldn't make any attempt to dispute what you said, since it makes perfect sense. You've simply explained why I originally opened the bug in the "Server: InnoDB" category. Why it was later changed to "Server: Partitioning" is a mystery to me, but I don't see how that by itself makes this "Not a bug".
[14 Dec 2007 9:19]
Mattias Jonsson
This is not related to Bug#32948. The bug is: When referencing a FK to a non InnoDb table (or partitioned InnoDB table) it gives a misleading error message: RROR HY000: Can't create table 'test.t2' (errno: 150) It would be better if it could return something that showed that it failed on FK referencing table. Changing back to Server: InnoDB. (I have updated the Synopsis, and changed it back to P4)
[17 Dec 2007 14:26]
Heikki Tuuri
Hmm... InnoDB could check if a partition table t1#p1 or something exists. When Konstantin's foreign key implementation for MySQL is completed, it may give a more descriptive error message.
