Re: Oracle patch [files]

From: Date: Mon, 10 Jul 2000 11:36:59 +0000
Subject: Re: Oracle patch [files]
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-24053@lists.php.net to get a copy of this message
On Mon, Jul 10, 2000 at 03:25:03PM +0400, Kirill Maximov wrote: > > Oh, forget this. i'll apply this later. it needs some changes though: global variables are your enimy in a multi-threaded environment. so the PHP 4 version of the patch needs to be made thread-safe. (see the usage of ORA() macro to see how that is done). i also like to make the code consistent with the indention we use in the rest of the module (and most of the rest of PHP). regards, tc > > -- > ---- ----- ----- ----- ----- ----- ----- ----- > Kirill Maximov maxkir@email.com > ICQ: 14796643 > Index: functions/oracle.c > =================================================================== > RCS file: /repository/php3/functions/oracle.c,v > retrieving revision 1.118 > diff -u -r1.118 oracle.c > --- functions/oracle.c 2000/02/22 15:13:57 1.118 > +++ functions/oracle.c 2000/07/10 11:06:09 > @@ -174,6 +174,10 @@ > /* 61, 62 */ (text *) "unused", (text *) "OBNDRA" > }; > > +/* This variable is to store error information in the case > + * when there was connection error */ > +static oraConnection db_err_conn; > + > #if COMPILE_DL > DLEXPORT php3_module_entry *get_module() { return &oracle_module_entry; }; > #endif > @@ -456,7 +460,12 @@ > #endif > php3_error(E_WARNING, "Unable to connect to ORACLE (%s)", > ora_error(&db_conn->lda)); > - if (persistent) > + > + /* The next line is to provide error information > + * for OraError && OraErrorCode calls */ > + db_err_conn = *db_conn; > + > + if (persistent) > free(db_conn); > else > efree(db_conn); > @@ -510,7 +519,12 @@ > if(orlon(&db_conn->lda, db_conn->hda, user, > strlen(user), pwd, strlen(pwd), 0)) { > #endif > - php3_error(E_WARNING, "Unable to reconnect to ORACLE (%s)", > + > + /* The next line is to provide error information > + * for OraError && OraErrorCode calls */ > + db_err_conn = *db_conn; > + > + php3_error(E_WARNING, "Unable to reconnect to ORACLE (%s)", > ora_error(&db_conn->lda)); > /* Delete list entry for this connection */ > php3_plist_delete(id); > @@ -1557,7 +1571,12 @@ > return_value->type = IS_STRING; > return_value->value.str.val = estrdup(ora_error(&conn->lda)); > return_value->value.str.len = strlen(return_value->value.str.val); > - } > + } else /* connection error */ > + { > + return_value->type = IS_STRING; > + return_value->value.str.val = estrdup(ora_error(&db_err_conn.lda)); > + return_value->value.str.len = strlen(return_value->value.str.val); > + } > } > /* }}} */ > > @@ -1579,6 +1598,11 @@ > } else if ((conn = ora_get_conn(list,plist, arg->value.lval)) != NULL) { > RETURN_LONG(conn->lda.rc); > } > + else /* connection error */ > + { > + RETURN_LONG(db_err_conn.lda.rc); > + } > + > } > /* }}} */ > > Index: ext/oracle/oracle.c > =================================================================== > RCS file: /repository/php4/ext/oracle/oracle.c,v > retrieving revision 1.51 > diff -u -r1.51 oracle.c > --- ext/oracle/oracle.c 2000/06/24 15:31:10 1.51 > +++ ext/oracle/oracle.c 2000/07/10 10:59:03 > @@ -177,6 +177,10 @@ > /* 61, 62 */ (text *) "unused", (text *) "OBNDRA" > }; > > +/* This variable is to store error information in the case > + * when there was connection error */ > +static oraConnection db_err_conn; > + > #ifdef COMPILE_DL_ORACLE > ZEND_GET_MODULE(oracle) > #endif > @@ -425,6 +429,10 @@ > ) { > php_error(E_WARNING, "Unable to connect to ORACLE > (%s)",ora_error(&db_conn->lda)); > > + /* The next line is to provide error information > + * for OraError && OraErrorCode calls */ > + db_err_conn = *db_conn; > + > if (persistent) { > free(db_conn); > } else { > @@ -515,6 +523,11 @@ > orlon(&db_conn->lda, db_conn->hda, user,strlen(user), passwd, strlen(passwd), 0) > #endif > ) { > + > + /* The next line is to provide error information > + * for OraError && OraErrorCode calls */ > + db_err_conn = *db_conn; > + > php_error(E_WARNING,"Oracle: Connection Failed: > %s\n",ora_error(&db_conn->lda)); > efree(hashed_details); > efree(db_conn); > @@ -1464,9 +1477,23 @@ > if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { > WRONG_PARAM_COUNT; > } > - res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, > le_pconn, le_cursor); > - ZEND_VERIFY_RESOURCE(res); > > + > + res = zend_fetch_resource(arg, > -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor); > + > + if (!res) > + { > + convert_to_long_ex(arg); > + if ( !(*arg)->value.lval ) // Zero index, connection error > + { > + RETURN_STRING(ora_error(&db_err_conn.lda),1); > + } > + else > + { > + RETURN_NULL(); > + } > + } > + > if (what == le_cursor) { > cursor = (oraCursor *) res; > RETURN_STRING(ora_error(&cursor->cda),1); > @@ -1490,9 +1517,22 @@ > if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { > WRONG_PARAM_COUNT; > } > - res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, > le_pconn, le_cursor); > - ZEND_VERIFY_RESOURCE(res); > > + res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, > le_pconn, le_cursor); > + > + if (!res) // No such resource > + { > + convert_to_long_ex(arg); > + if ( !(*arg)->value.lval ) // Zero index, connection error > + { > + RETURN_STRING(ora_error(&db_err_conn.lda),1); > + } > + else > + { > + RETURN_NULL(); > + } > + } > + > if (what == le_cursor) { > cursor = (oraCursor *) res; > RETURN_LONG(cursor->cda.rc); > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.dev (#24053) next »