Oracle patch

From: Date: Sat, 01 Jul 2000 21:52:26 +0000
Subject: Oracle patch
Groups: php.dev 
Request: Send a blank email to php-dev+get-23176@lists.php.net to get a copy of this message
hi, I've prepared a couple of patches that fixes one small problem in Oracle module. The problem is that when connection to Oracle failed, functions ora_error and ora_errorcode don't work (but they should, according to the documetation for ora_logon function). So, I tried to fix this problem and seems to succeed. Patches are for the current development CVS for PHP3/4. Best regards, KIR P.S. Sorry if I did something wrong ...

Index: ext/oracle/oracle.c =================================================================== RCS file: /repository/php4/ext/oracle/oracle.c,v retrieving revision 1.51 diff -c -u -r1.51 oracle.c --- ext/oracle/oracle.c 2000/06/24 15:31:10 1.51 +++ ext/oracle/oracle.c 2000/07/01 21:42:55 @@ -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 { @@ -1464,7 +1472,14 @@ 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); + + convert_to_long_ex(arg); + if ( !(*arg)->value.lval ) // Zero index, connection error + { + RETURN_STRING(ora_error(&db_err_conn.lda),1); + } + + res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor); ZEND_VERIFY_RESOURCE(res); if (what == le_cursor) { @@ -1490,6 +1505,13 @@ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { WRONG_PARAM_COUNT; } + + convert_to_long_ex(arg); + if ( !(*arg)->value.lval ) // Zero index, connection error + { + RETURN_LONG(db_err_conn.lda.rc); + } + res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor); ZEND_VERIFY_RESOURCE(res); Index: functions/oracle.c =================================================================== RCS file: /repository/php3/functions/oracle.c,v retrieving revision 1.118 diff -c -C4 -r1.118 oracle.c *** functions/oracle.c 2000/02/22 15:13:57 1.118 --- functions/oracle.c 2000/07/01 20:55:10 *************** *** 173,180 **** --- 173,184 ---- /* 59, 60 */ (text *) "unused", (text *) "ODESCR", /* 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 *************** *** 455,463 **** strlen(user), pwd, strlen(pwd), 0)) { #endif php3_error(E_WARNING, "Unable to connect to ORACLE (%s)", ora_error(&db_conn->lda)); ! if (persistent) free(db_conn); else efree(db_conn); efree(hashed_details); --- 459,472 ---- strlen(user), pwd, strlen(pwd), 0)) { #endif php3_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 efree(db_conn); efree(hashed_details); *************** *** 1556,1564 **** } else if ((conn = ora_get_conn(list,plist, arg->value.lval)) != NULL) { 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); ! } } /* }}} */ /* {{{ proto int ora_errorcode(int cursor_or_connection) --- 1565,1578 ---- } else if ((conn = ora_get_conn(list,plist, arg->value.lval)) != NULL) { 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); ! } } /* }}} */ /* {{{ proto int ora_errorcode(int cursor_or_connection) *************** *** 1578,1585 **** --- 1592,1604 ---- RETURN_LONG(cursor->cda.rc); } 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); + } + } /* }}} */ void php3_info_oracle(ZEND_MODULE_INFO_FUNC_ARGS)
« previous php.dev (#23176) next »