Bug #5342 getImportedKeys should return a null fk_name
Submitted: 1 Sep 2004 12:38 Modified: 1 Sep 2004 16:35
Reporter: Pierre-Anroine Champin Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.0.14 OS:Linux (Debian GNU/Linux)
Assigned to: Mark Matthews CPU Architecture:Any

[1 Sep 2004 12:38] Pierre-Anroine Champin
Description:
I am working with MySQL 4.0.12

When querying the foreign keys of an InnoDB table with getImportedKeys,
the "fk_name" field contains the string "not available" for keys having no explicit name.

Since getImportedKeys is allowed to return null values in column fk_name (according to its javadoc), it would seem more logical and cleaner to return null rather than a string.

How to repeat:
Create an InnoDB table with an unnamed foreign key.
Browse the result set returned by getImportedKeys.
Check that  getString("fk_name").equals("not available") .

Suggested fix:
Return null instead of "not available"
[1 Sep 2004 16:35] Mark Matthews
I can't repeat this, and don't see how the driver can return 'not available', since that string isn't defined in the sources. The driver should return 'null' in this case. If you happen to have the output of 'SHOW CREATE TABLE', you could append it here, and I can test it.

In any case, MySQL-4.0.12 is quite old (> 1 year, 4.0.20 is the current release) and starting with MySQL-4.0.13 foreign keys always have names (if one is not supplied, the server generates one for you), if this bug indeed exists, we would most likely defer fixing it unless a large percentage of our users could not upgrade.