Skip Menu |
 

This queue is for tickets about the DBD-ODBC CPAN distribution.

Report information
The Basics
Id: 5378
Status: resolved
Priority: 0/
Queue: DBD-ODBC

People
Owner: Nobody in particular
Requestors: kshepherd [...] scarletline.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Attachments


Subject: Fix for SQLForeignKeys
Download (untitled) / with headers
text/plain 1.5k
Please include the attached fix in future versions of DBD-ODBC. I have used your package extensively, with great success. I hit a minor problem when trying to list foreign keys, and am sending you the fix in the hope that it can help all of us. In order to find all of the foreign keys from a given table in ODBC, it is necessary to use NULL as a wildcard, e.g.: SQLForeignKeys(H, 0, 0, 0, 0, 0, 0, "Catalog", SQL_NTS, "Schema", SQL_NTS, "Table", SQL_NTS); Unfortunately, dbdimp.c rewuires valid char * s, and any undef s get changed to the empty string. I have tested the below code, which works with DBD-ODBC-1.06 /* KAS Start line 3736 DBD-ODBC-1.06/dbdimp.c SQLForeignKeys uses NULL as a wildcard, so must allow NULLs to get through: */ if (PK_CatalogName && PK_CatalogName[0] == 0) PK_CatalogName = 0; if (PK_SchemaName && PK_SchemaName[0] == 0) PK_SchemaName = 0; if (PK_TableName && PK_TableName[0] == 0) PK_TableName = 0; if (FK_CatalogName && FK_CatalogName[0] == 0) FK_CatalogName = 0; if (FK_SchemaName && FK_SchemaName[0] == 0) FK_SchemaName = 0; if (FK_TableName && FK_TableName[0] == 0) FK_TableName = 0; rc = SQLForeignKeys(imp_sth->hstmt, PK_CatalogName, PK_CatalogName?strlen(PK_CatalogName):0, PK_SchemaName, PK_SchemaName?strlen(PK_SchemaName):0, PK_TableName, PK_TableName?strlen(PK_TableName):0, FK_CatalogName, FK_CatalogName?strlen(FK_CatalogName):0, FK_SchemaName, FK_SchemaName?strlen(FK_SchemaName):0, FK_TableName, FK_TableName?strlen(FK_TableName):0); /* KAS End */
Download fkeys_fix.c
text/x-csrc 925b
/* KAS Start line 3736 DBD-ODBC-1.06/dbdimp.c SQLForeignKeys uses NULL as a wildcard, so must allow NULLs to get through: */ if (PK_CatalogName && PK_CatalogName[0] == 0) PK_CatalogName = 0; if (PK_SchemaName && PK_SchemaName[0] == 0) PK_SchemaName = 0; if (PK_TableName && PK_TableName[0] == 0) PK_TableName = 0; if (FK_CatalogName && FK_CatalogName[0] == 0) FK_CatalogName = 0; if (FK_SchemaName && FK_SchemaName[0] == 0) FK_SchemaName = 0; if (FK_TableName && FK_TableName[0] == 0) FK_TableName = 0; rc = SQLForeignKeys(imp_sth->hstmt, PK_CatalogName, PK_CatalogName?strlen(PK_CatalogName):0, PK_SchemaName, PK_SchemaName?strlen(PK_SchemaName):0, PK_TableName, PK_TableName?strlen(PK_TableName):0, FK_CatalogName, FK_CatalogName?strlen(FK_CatalogName):0, FK_SchemaName, FK_SchemaName?strlen(FK_SchemaName):0, FK_TableName, FK_TableName?strlen(FK_TableName):0); /* KAS End */


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.