mje has asked for the wisdom of the Perl Monks concerning the following question:
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: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;
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).if(!SvOK(valuesv)) { imp_dbh->odbc_err_handler = NULL; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: testing for undef in perl XS code (in DBD::ODBC)
by salva (Canon) on Nov 05, 2007 at 22:44 UTC | |
by mje (Curate) on Nov 06, 2007 at 11:23 UTC | |
by syphilis (Archbishop) on Nov 06, 2007 at 12:59 UTC | |
by salva (Canon) on Nov 06, 2007 at 17:19 UTC | |
by syphilis (Archbishop) on Nov 07, 2007 at 06:39 UTC | |
by salva (Canon) on Nov 06, 2007 at 11:58 UTC |