Bug #72828 Connection.GetSchema doesn't identify primary keys by name
Submitted: 1 Jun 2014 22:49 Modified: 17 Nov 2014 10:33
Reporter: Colin Paterson Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.8.3, 6.9.3 OS:Microsoft Windows (7 x64)
Assigned to: CPU Architecture:Any
Tags: Connection, GetSchema, meta-data

[1 Jun 2014 22:49] Colin Paterson
Description:
When calling the GetSchema method of the connection object passing in the "Indexes" or the "IndexColumns" collection name, you are returned a DataTable with indexes including the PrimaryKeys. This is the only way to get primary key information as there is no PrimaryKeys collection. In either case the column INDEX_NAME contains the name of the index/constraint for the other index/constraint types. For Primary Keys however the value in the INDEX_NAME field always contains the string "PRIMARY" and not the name of the constraint as you would expect.

How to repeat:
Call the following on any connection to a database that has a table with a Primary Key

_connection.GetSchema("IndexColumns");
_connection.GetSchema("Indexes");

Where _connection is a MySqlConnection object.

Suggested fix:
The INDEX_NAME column should contain the name given to the Primary Key constrain on creation.
[17 Nov 2014 10:33] Chiranjeevi Battula
Hello  Colin Paterson,

Thank you for the bug report and test case.
Verified this behavior on Visual Studio 2013 (C#.Net) with  MySQL Connector/Net 6.9.3.

Thanks,
Chiranjeevi