After doing some testing and then comparing the odbc driver to the other
drivers (pgsql, oracle, etc). I noticed
what appears to be a bug in the ODBC driver. For getting binary data
(in odbc_datum_get), it is using the
/void *data/ argument differently than the other drivers--it is copying
over the contents pointed to by the data pointer
instead of assigning the pointer address into the location of the data
pointer. The first patch below shows the change
that fixes it to be like the other drivers. (Oracle and the other
drivers all do something like: '/*(char**)data = (char*)entry;/".)
I tested this and it seems to fix it to work like the other drivers (at
least the pgsql driver--that is the one I have tested
for comparison).
The second patch below fixes it to (silently) return zero rows if that
is what is selected within the odbc_pbquery function.
It does not seem proper to me to report a (noisy) error if no rows are
selected--that could be the point of the query after all.
*** apr_dbd_odbc.c.orig 2010-07-19 10:52:17.000000000 -0500
--- apr_dbd_odbc.c 2010-07-19 11:01:54.000000000 -0500
***************
*** 1323,1329 ****
return APR_ENOENT; /* SQL NULL value */
if (len < 0)
! strcpy(data, p);
else
memcpy(data, p, len);
--- 1323,1329 ----
return APR_ENOENT; /* SQL NULL value */
if (len < 0)
! *(char**)data = (char *)p;
else
memcpy(data, p, len);
***************
*** 1557,1565 ****
if (SQL_SUCCEEDED(rc)) {
rc = SQLExecute(statement->stmt);
! CHECK_ERROR(handle, "SQLExecute", rc, SQL_HANDLE_STMT,
statement->stmt);
}
if (SQL_SUCCEEDED(rc)) {
SQLLEN rowcount;
--- 1557,1569 ----
if (SQL_SUCCEEDED(rc)) {
rc = SQLExecute(statement->stmt);
! if (rc == SQL_NO_DATA) {
! *nrows = (int) 0;
! } else {
! CHECK_ERROR(handle, "SQLExecute", rc, SQL_HANDLE_STMT,
statement->stmt);
}
+ }
if (SQL_SUCCEEDED(rc)) {
SQLLEN rowcount;
------------------------------------------end
patch--------------------------
Brian Dunford-Shore
--
? (? _? )
PsiLambda LLC
2430 Tesson Ferry Road #203
Saint Louis, Missouri 63128-2702