--- dbdimp.c Thu Mar 27 11:44:34 2003 +++ dbdimp.c.new Mon Apr 21 21:49:32 2003 @@ -281,8 +281,11 @@ dump_env_to_trace(); /* "extproc" dbname is special if "ora_context" attribute also given */ - if (strEQ(dbname,"extproc") && (svp=DBD_ATTRIB_GET_SVP(attr, "ora_context", 7))) { + if (strEQ(dbname,"extproc") && (svp=DBD_ATTRIB_GET_SVP(attr, "ora_context", 11))) { IV tmp; + SV **envsvp; + SV **svcsvp; + SV **errsvp; if (!svp) croak("pointer to context SV is NULL"); if (!sv_isa(*svp, "ExtProc::OCIExtProcContext")) @@ -291,13 +294,34 @@ this_ctx = (struct OCIExtProcContext *)tmp; if (this_ctx == NULL) croak("ora_context referenced ExtProc value is NULL"); - status = OCIExtProcGetEnv(this_ctx, &imp_drh->envhp, - &imp_dbh->svchp, &imp_dbh->errhp); - if (status != OCI_SUCCESS) { - oci_error(dbh, (OCIError*)imp_dbh->envhp, status, "OCIExtProcGetEnv"); - return 0; + /* new */ + if ((envsvp=DBD_ATTRIB_GET_SVP(attr, "ora_envhp", 9)) && + (svcsvp=DBD_ATTRIB_GET_SVP(attr, "ora_svchp", 9)) && + (errsvp=DBD_ATTRIB_GET_SVP(attr, "ora_errhp", 9))) { + if (!sv_isa(*envsvp, "ExtProc::OCIEnvHandle")) + croak("ora_envhp value is not of type ExtProc::OCIEnvHandle"); + tmp = SvIV((SV*)SvRV(*envsvp)); + imp_drh->envhp = (struct OCIEnv *)tmp; + if (!sv_isa(*svcsvp, "ExtProc::OCISvcHandle")) + croak("ora_svchp value is not of type ExtProc::OCISvcHandle"); + tmp = SvIV((SV*)SvRV(*svcsvp)); + imp_dbh->svchp = (struct OCISvcCtx *)tmp; + if (!sv_isa(*errsvp, "ExtProc::OCIErrHandle")) + croak("ora_errhp value is not of type ExtProc::OCIErrHandle"); + tmp = SvIV((SV*)SvRV(*errsvp)); + imp_dbh->errhp = (struct OCIError *)tmp; + } + /* end new */ + else { + status = OCIExtProcGetEnv(this_ctx, &imp_drh->envhp, + &imp_dbh->svchp, &imp_dbh->errhp); + if (status != OCI_SUCCESS) { + oci_error(dbh, (OCIError*)imp_dbh->envhp, status, "OCIExtProcGetEnv"); + return 0; + } } imp_dbh->envhp = imp_drh->envhp; + is_extproc = 1; goto dbd_db_login6_out; } @@ -612,6 +636,7 @@ if (refcnt == 1) { if (DBIc_ACTIVE(imp_dbh)) dbd_db_disconnect(dbh, imp_dbh); + if (is_extproc) goto dbd_db_destroy_out; #ifdef OCI_V8_SYNTAX { sword status; OCIHandleFree_log_stat(imp_dbh->authp, OCI_HTYPE_SESSION,status); @@ -627,6 +652,7 @@ OCIHandleFree_log_stat(imp_dbh->errhp, OCI_HTYPE_ERROR, status); } #endif +dbd_db_destroy_out: DBIc_IMPSET_off(imp_dbh); }