Currently, long get_info() return values (e.g. SQL_KEYWORDS)
are truncated.
That's because the buffer has a static size of 256.
The attached patch allocates the buffer dynamically and
reallocates it if needed.
Steffen
*** DBD-ODBC-0.38-orig/dbdimp.c Tue Feb 12 19:11:56 2002
--- dbdimp.c Mon Mar 04 22:37:54 2002
***************
*** 2415,2431 ****
RETCODE rc;
SV *retsv = NULL;
int i;
! char rgbInfoValue[256];
SWORD cbInfoValue = -2;
/* See fancy logic below */
for (i = 0; i < 6; i++)
rgbInfoValue[i] = 0xFF;
! rc = SQLGetInfo(imp_dbh->hdbc, ftype,
! rgbInfoValue, sizeof(rgbInfoValue)-1, &cbInfoValue);
if (!SQL_ok(rc)) {
dbd_error(dbh, rc, "odbc_get_info/SQLGetInfo");
/* patched 2/12/02, thanks to Steffen Goldner */
return &sv_undef;
/* return Nullsv; */
--- 2415,2438 ----
RETCODE rc;
SV *retsv = NULL;
int i;
! int size = 256;
! char* rgbInfoValue;
SWORD cbInfoValue = -2;
+ New(0, rgbInfoValue, size, char);
+
/* See fancy logic below */
for (i = 0; i < 6; i++)
rgbInfoValue[i] = 0xFF;
! rc = SQLGetInfo(imp_dbh->hdbc, ftype, rgbInfoValue, size-1, &cbInfoValue);
! if (cbInfoValue > size-1) {
! Renew(rgbInfoValue, cbInfoValue+1, char);
! rc = SQLGetInfo(imp_dbh->hdbc, ftype, rgbInfoValue, cbInfoValue, &cbInfoValue);
! }
if (!SQL_ok(rc)) {
dbd_error(dbh, rc, "odbc_get_info/SQLGetInfo");
+ Safefree(rgbInfoValue);
/* patched 2/12/02, thanks to Steffen Goldner */
return &sv_undef;
/* return Nullsv; */
***************
*** 2449,2454 ****
--- 2456,2462 ----
PerlIO_printf(DBILOGFP, "SQLGetInfo: ftype %d, cbInfoValue %d: %s\n",
ftype, cbInfoValue, neatsvpv(retsv,0));
+ Safefree(rgbInfoValue);
return sv_2mortal(retsv);
}