Bug #6202 DROP TABLE failure with misleading error message
Submitted: 21 Oct 2004 18:57 Modified: 15 Feb 2005 16:27
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: CPU Architecture:Any

[21 Oct 2004 18:57] Peter Gulutzan
Description:
I have a table TPK with a primary key. I have a table TFK with a foreign key, referencing 
TPK. I try to drop TPK. The drop fails. Good -- it should fail! But the error message is: 
"Unknown table '...'". This is misleading. The table is known. The error message should be: 
"There is a foreign-key '...' table that references '...'". 
 

How to repeat:
mysql> create table tpk (s1 int, primary key (s1)) engine=innodb; 
Query OK, 0 rows affected (0.40 sec) 
 
mysql> create table tfk (s1 int, foreign key (s1) references tpk (s1)) engine=innodb; 
Query OK, 0 rows affected (0.36 sec) 
 
mysql> drop table tpk; 
ERROR 1051 (42S02): Unknown table 'tpk'
[21 Oct 2004 19:21] MySQL Verification Team
Verified against latest BK source.
[18 Nov 2004 23:01] Chad Funk
I agree with Peter.  I had to search the bug database to figure out what was wrong.  I had a drop table if exists and it says "unknown" ...  frustrating. Thanks, --Chad
[19 Nov 2004 14:30] Heikki Tuuri
Hi!

This was fixed in 4.1.6.

The fix has probably propagated to 5.0, too.

Regards,

Heikki

InnoDB: Change error code to HA_ERR_ROW_IS_REFERENCED if we cannot DROP a parent table referenced by a FOREIGN KEY constraint; this error number is less misleading than the previous number HA_ERR_CANNOT_ADD_FOREIGN, but misleading still.
[15 Feb 2005 13:41] Alexander Barkov
It looks this bug was fixed while ago, but noone closed
the bug report.

Dear doc team, please verify whether it was documented.
[15 Feb 2005 16:27] Paul DuBois
It was documented in the 4.1.6 change notes but there
was no bug number. I added it.