Hi,
I started trying to convert all the DBIc_ERR etc calls to
DBIh_SET_ERR_CHAR. I made a mistake and ended up debugging a test case
in DBD::ODBC which is supposed to fail but failed for the wrong reason.
The test is supposed to fail because multiple concurrent statements is
not allowed (at this point in the test) and actually fails because the
odbc_err_handler still exists and this uses an uninitialised variable.
So I changed the test case to reset the odbc_err_handler to undef:
$dbh->{odbc_err_handler} = undef;
but then I discovered the odbc_err_handler was still being called! It
seems to be down to the following code in dbd_db_STORE_attrib:
case ODBC_ERR_HANDLER:
bSetSQLConnectionOption = FALSE;
/* This was taken from DBD::Sybase 0.21 */
if(valuesv == &sv_undef) {
imp_dbh->odbc_err_handler = NULL;
} else if(imp_dbh->odbc_err_handler == (SV*)NULL) {
imp_dbh->odbc_err_handler = newSVsv(valuesv);
} else {
sv_setsv(imp_dbh->odbc_err_handler, valuesv);
}
break;
which works when I add:
if(!SvOK(valuesv)) {
imp_dbh->odbc_err_handler = NULL;
}
to the start of the if tests. It appears the "else" is always being hit
even when setting odbc_err_handler to undef and then when DBD::ODBC
tests dbh->odbc_err_handler it is not null and it attempts to run it.
Anyone have any idea what is wrong with the original if test. Shouldn't
that be &PL_sv_undef for a start? (not that that helps) Apparently this
code is copied from DBD::Sybase.
Thanks
Martin