Bug #56337 SQLForeignKeys() doesn't set PK_NAME result set column
Submitted: 27 Aug 2010 21:51 Modified: 11 Oct 2011 8:31
Reporter: Federico Omoto Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.1.6 OS:Windows (Tested on Windows, maybe other OSes too)
Assigned to: Bogdan Degtyariov CPU Architecture:Any

[27 Aug 2010 21:51] Federico Omoto
Description:
SQLForeignKeys() does not set PK_NAME result set column for foreign keys that reference a two-column index (or more).

How to repeat:
Just call SQLForeignKeys() setting only the foreign key table name function argument (FKTableName) and define in that table a foreign key that references a two-column index (or more).
You'll see that the PK_NAME result set column value is NULL instead of the key name.
[17 Sep 2010 18:51] Federico Omoto
Any updates on this?
[11 Oct 2011 8:31] Bogdan Degtyariov
The bug has been fixed in Connector/ODBC 5.1.8.
Here is the output from odbcte32 utility:

Successfully connected to DSN 'test'.
SQLForeignKeys:
In:				StatementHandle = 0x00272FE8, 
										PkCatalogName = SQL_NULL_HANDLE, NameLength1 = 0, PkSchemaName = SQL_NULL_HANDLE, NameLength2 = 0, 
										PkTableName = SQL_NULL_HANDLE, NameLength3 = 0, FkCatalogName = SQL_NULL_HANDLE, NameLength4 = 0, 
										FkSchemaName = SQL_NULL_HANDLE, NameLength5 = 0, FkTableName = "fk_tab1", NameLength6 = SQL_NTS=-3
				Return:	SQL_SUCCESS=0

Get Data All:
"PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME", "DEFERRABILITY"

"test", <Null>, "pk_tab1", "id1", "test", <Null>, "fk_tab1", "f1", 1, 3, 3, "fk1", "PRIMARY", 7
"test", <Null>, "pk_tab1", "id2", "test", <Null>, "fk_tab1", "f2", 2, 3, 3, "fk1", "PRIMARY", 7

Please note that you must not set "Don't use INFORMATION_SCHEMA for metadata"
flag. Otherwise it may return the empty result set.
2 rows fetched from 14 columns.