I am trying to debug a problem in DBD::ODBC. DBD::ODBC which has an attribute named odbc_err_handler which when set to a subroutine reference gets called whenever there is an error. Unfortunately, when odbc_err_handler is reset to undef, the error handler still gets called. The actual C code fragment is:
int
dbd_db_STORE_attrib(dbh, imp_dbh, keysv, valuesv)
SV *dbh;
imp_dbh_t *imp_dbh;
SV *keysv;
SV *valuesv;
{
switch(pars->fOption)
{
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;
I have verified that when I set $database_handle->{odbc_error_handler} it gets into the code above but always ends up in the else statement. The problem is that DBD::ODBC uses (if imp_dbh->odbc_error_handler) to test whether it should call the error handler and even after setting to undef, it is set. If I add the following to the start of the if it works:
if(!SvOK(valuesv)) {
imp_dbh->odbc_err_handler = NULL;
}
My problem is that I do not understand what the first 2 original if tests and following statements do and I though &sv_undef should be &PL_sv_undef anyway (not that this helps).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.