thies Mon Feb 12 06:36:28 2001 EDT Modified files: /php4/ext/oci8 oci8.c Log: @- Improved OCI8 dead-session detection. (Patch by: George Schlossnagle)
Index: php4/ext/oci8/oci8.c diff -u php4/ext/oci8/oci8.c:1.105 php4/ext/oci8/oci8.c:1.106 --- php4/ext/oci8/oci8.c:1.105 Sun Jan 7 03:43:07 2001 +++ php4/ext/oci8/oci8.c Mon Feb 12 06:36:28 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.105 2001/01/07 11:43:07 thies Exp $ */ +/* $Id: oci8.c,v 1.106 2001/02/12 14:36:28 thies Exp $ */ /* TODO list: * @@ -109,6 +109,7 @@ PHP_RSHUTDOWN_FUNCTION(oci); PHP_MINFO_FUNCTION(oci); +static ub4 oci_handle_error(oci_connection *connection, ub4 errcode); static ub4 oci_error(OCIError *err_p, char *what, sword status); static int oci_ping(oci_server *server); static void oci_debug(const char *format, ...); @@ -488,7 +489,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.105 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.106 $"); #ifndef PHP_WIN32 php_info_print_table_row(2, "Oracle Version", PHP_OCI8_VERSION ); php_info_print_table_row(2, "Compile-time ORACLE_HOME", PHP_OCI8_DIR ); @@ -730,6 +731,28 @@ } /* }}} */ + +static ub4 +oci_handle_error(oci_connection *connection, ub4 errcode) +{ + switch (errcode) { + case 0: + return 0; + break; + case 22: /* ORA-00022 Invalid session id */ + case 1012: /* ORA-01012: */ + case 3113: /* ORA-03113: end-of-file on communication channel */ + connection->open = 0; + connection->session->open = 0; + connection->session->server->open = 0; + return 0; + break; + default: + return 0; + break; + } +} + /* {{{ oci_error() */ static ub4 @@ -937,7 +960,9 @@ (dvoid **) 0); if (OCI(error)) { - oci_error(OCI(pError),"OCIDescriptorAlloc %d",OCI(error)); + ub4 error; + error = oci_error(OCI(pError),"OCIDescriptorAlloc %d",OCI(error)); + oci_handle_error(connection, error); return 0; } @@ -1060,6 +1085,9 @@ 0, OCI_ATTR_PREFETCH_MEMORY, statement->pError)); + if (statement->error) { + oci_handle_error(statement->conn, statement->error); + } prefetch = size; statement->error = oci_error(statement->pError, @@ -1070,6 +1098,9 @@ 0, OCI_ATTR_PREFETCH_ROWS, statement->pError)); + if (statement->error) { + oci_handle_error(statement->conn, statement->error); + } return 1; } @@ -1109,6 +1140,7 @@ OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT); OCIHandleFree(statement->pError, OCI_HTYPE_ERROR); efree(statement); + oci_handle_error(connection, connection->error); return 0; } } @@ -1162,6 +1194,7 @@ statement->pError)); if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; } @@ -1190,26 +1223,11 @@ NULL, NULL, mode)); - if (statement->binds) { zend_hash_apply(statement->binds, (int (*)(void *)) _oci_bind_post_exec); - } - - switch (statement->error) { - case 0: - break; - - case 3113: /* ORA-03113: end-of-file on communication channel */ - statement->conn->open = 0; - statement->conn->session->open = 0; - statement->conn->session->server->open = 0; - return 0; - break; - - default: - return 0; - break; } + oci_handle_error(statement->conn, statement->error); + return 0; } if (stmttype == OCI_STMT_SELECT && (statement->executed == 0)) { @@ -1231,6 +1249,7 @@ OCI_ATTR_PARAM_COUNT, statement->pError)); if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; /* XXX we loose memory!!! */ } @@ -1258,6 +1277,7 @@ (dvoid**)¶m, counter)); if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; /* XXX we loose memory!!! */ } @@ -1271,6 +1291,7 @@ OCI_ATTR_DATA_TYPE, statement->pError)); if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; /* XXX we loose memory!!! */ } @@ -1285,6 +1306,7 @@ OCI_ATTR_DATA_SIZE, statement->pError)); if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; /* XXX we loose memory!!! */ } @@ -1301,6 +1323,7 @@ OCI_ATTR_SCALE, statement->pError)); if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; /* XXX we lose memory!!! */ } @@ -1314,6 +1337,7 @@ OCI_ATTR_PRECISION, statement->pError)); if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; /* XXX we lose memory!!! */ } @@ -1327,6 +1351,7 @@ (ub4)OCI_ATTR_NAME, statement->pError)); if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; /* XXX we loose memory!!! */ } @@ -1433,6 +1458,7 @@ OCI_DEFAULT)); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */ } if (statement->error) { + oci_handle_error(statement->conn, statement->error); return 0; /* XXX we loose memory!!! */ } } @@ -1545,6 +1571,7 @@ } oci_error(statement->pError, func, statement->error); + oci_handle_error(statement->conn, statement->error); return 0; } @@ -1571,6 +1598,7 @@ OCI_FILE_READONLY); if (connection->error) { oci_error(connection->pError, "OCILobFileOpen",connection->error); + oci_handle_error(connection, connection->error); return -1; } } @@ -1583,6 +1611,7 @@ if (connection->error) { oci_error(connection->pError, "OCILobFileOpen",connection->error); + oci_handle_error(connection, connection->error); return -1; } @@ -1615,6 +1644,7 @@ if (connection->error) { oci_error(connection->pError, "OCILobRead", connection->error); + oci_handle_error(connection, connection->error); efree(buf); return -1; } @@ -1626,6 +1656,7 @@ mydescr->ocidescr); if (connection->error) { oci_error(connection->pError, "OCILobFileClose", connection->error); + oci_handle_error(connection, connection->error); efree(buf); return -1; } @@ -2538,6 +2569,7 @@ if (statement->error != OCI_SUCCESS) { oci_error(statement->pError, "OCIBindByName", statement->error); + oci_handle_error(statement->conn, statement->error); RETURN_FALSE; } @@ -2551,6 +2583,7 @@ if (statement->error != OCI_SUCCESS) { oci_error(statement->pError, "OCIBindDynamic", statement->error); + oci_handle_error(statement->conn, statement->error); RETURN_FALSE; } @@ -2660,6 +2693,7 @@ if (connection->error) { oci_error(connection->pError, "OCILobWrite", connection->error); + oci_handle_error(connection, connection->error); RETURN_FALSE; } @@ -2735,6 +2769,7 @@ if (connection->error) { oci_error(connection->pError, "OCILobWrite", connection->error); + oci_handle_error(connection, connection->error); close(fp); RETURN_FALSE; } @@ -2847,6 +2882,7 @@ if (connection->error) { oci_error(connection->pError, "OCILobGetLength", connection->error); + oci_handle_error(connection, connection->error); goto bail; } @@ -2858,6 +2894,7 @@ OCI_FILE_READONLY); if (connection->error) { oci_error(connection->pError, "OCILobFileOpen",connection->error); + oci_handle_error(connection, connection->error); goto bail; } } @@ -2910,6 +2947,7 @@ if (connection->error) { oci_error(connection->pError, "OCILobRead", connection->error); + oci_handle_error(connection, connection->error); goto bail; } @@ -2943,6 +2981,7 @@ descr->ocidescr); if (connection->error) { oci_error(connection->pError, "OCILobFileClose", connection->error); + oci_handle_error(connection, connection->error); goto bail; } } @@ -3012,6 +3051,7 @@ if (connection->error) { oci_error(connection->pError, "OCIRollback", connection->error); + oci_handle_error(connection, connection->error); RETURN_FALSE; } @@ -3045,6 +3085,7 @@ if (connection->error) { oci_error(connection->pError, "OCICommit", connection->error); + oci_handle_error(connection, connection->error); RETURN_FALSE; } @@ -3801,6 +3842,7 @@ if (connection->error != OCI_SUCCESS) { oci_error(connection->pError, "OCIServerVersion", connection->error); + oci_handle_error(connection, connection->error); RETURN_FALSE; } @@ -3835,6 +3877,7 @@ statement->pError); if (statement->error != OCI_SUCCESS) { oci_error(statement->pError, "OCIStatementType", statement->error); + oci_handle_error(statement->conn, statement->error); RETURN_FALSE; } @@ -3896,6 +3939,7 @@ if (statement->error != OCI_SUCCESS) { oci_error(statement->pError, "OCIRowCount", statement->error); + oci_handle_error(statement->conn, statement->error); RETURN_FALSE; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]