From: Thies C. Arntzen Date: Sun, 10 Feb 2002 12:41:52 +0000 (+0000) Subject: only rollback at script end if there is something to rollback. X-Git-Tag: php-4.2.0RC1~382 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1d54bf97e09fbb94142aba7424fd8eb70f631f05;p=php only rollback at script end if there is something to rollback. --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 0e258b90d3..f46bfa4512 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -39,7 +39,6 @@ * - have one ocifree() call. * - make it possible to have persistent statements? * - implement connection pooling in ZTS mode. - * - implement automatic commit *OR* rollback on script end * - failover * - change all the lob stuff to work without classes (optional)! * - make sure that the callbacks terminate the strings with \0 @@ -51,7 +50,6 @@ * - add Collection iterator object for INDEX BY tables * - make auto-rollabck only happen if we have an outstanding transaction * - implement ocidisconnect - * - add bind patch */ /* {{{ includes & stuff */ @@ -804,13 +802,20 @@ _oci_conn_list_dtor(oci_connection *connection TSRMLS_DC) oci_debug("START _oci_conn_list_dtor: id=%d",connection->id); if (connection->pServiceContext) { - CALL_OCI_RETURN(connection->error,OCITransRollback( - connection->pServiceContext, - connection->pError, - (ub4)0)); - - if (connection->error) { - oci_error(connection->pError, "failed to rollback outstanding transactions!", connection->error); + + if (connection->needs_commit) { + oci_debug("OCITransRollback"); + CALL_OCI_RETURN(connection->error,OCITransRollback( + connection->pServiceContext, + connection->pError, + (ub4)0)); + + if (connection->error) { + oci_error(connection->pError, "failed to rollback outstanding transactions!", connection->error); + } + connection->needs_commit = 0; + } else { + oci_debug("nothing to do.."); } CALL_OCI(OCIHandleFree( @@ -1461,6 +1466,7 @@ oci_execute(oci_statement *statement, char *func,ub4 mode) mode)); statement->error = oci_error(statement->pError, "OCIStmtExecute", error); + if (statement->binds) { zend_hash_apply(statement->binds, (apply_func_t) _oci_bind_post_exec TSRMLS_CC); } @@ -1470,6 +1476,12 @@ oci_execute(oci_statement *statement, char *func,ub4 mode) if (statement->error) { return 0; } + + if (mode & OCI_COMMIT_ON_SUCCESS) { + statement->conn->needs_commit = 0; + } else { + statement->conn->needs_commit = 1; + } } if ((statement->stmttype == OCI_STMT_SELECT) && (statement->executed == 0)) { @@ -3523,11 +3535,17 @@ PHP_FUNCTION(ocirollback) OCI_GET_CONN(connection,conn); + oci_debug("error, OCITransRollback( connection->pServiceContext, connection->pError, (ub4) 0)); + connection->needs_commit = 0; + + oci_debug(">OCITransRollback"); + if (connection->error) { oci_error(connection->pError, "OCIRollback", connection->error); oci_handle_error(connection, connection->error); @@ -3560,6 +3578,8 @@ PHP_FUNCTION(ocicommit) connection->pError, (ub4) 0)); + connection->needs_commit = 0; + oci_debug(">OCITransCommit"); if (connection->error) { diff --git a/ext/oci8/php_oci8.h b/ext/oci8/php_oci8.h index 0f6f657686..07fdc8e9dc 100644 --- a/ext/oci8/php_oci8.h +++ b/ext/oci8/php_oci8.h @@ -79,6 +79,7 @@ typedef struct { OCISvcCtx *pServiceContext; sword error; OCIError *pError; + int needs_commit; } oci_connection; typedef struct {