summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Gorham <lurcher@php.net>2001-04-02 15:18:47 +0000
committerNick Gorham <lurcher@php.net>2001-04-02 15:18:47 +0000
commit971d65059a63fa4b584ca6851fe3681c1a0e6b13 (patch)
treea8edc609459b9f9f3cb1c2e057a95020edde894d
parent221a5a60b60598f9398954654914758279d66d41 (diff)
downloadphp-git-971d65059a63fa4b584ca6851fe3681c1a0e6b13.tar.gz
Added small change to php_odbc module, to check for failed SQLDisconnects
and to close any outstanding transactions if the call fails, then disconnect again. This can cause chaos with SQL Server, this regards a SELECT as starting a transaction, and will leave it open if the result set is not all read.
-rw-r--r--NEWS3
-rw-r--r--ext/odbc/php_odbc.c28
2 files changed, 23 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index dd110f115f..9f102e51ed 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 200?, Version 4.0.6
+- Added small change to php_odbc module, to check for failed SQLDisconnects
+ and to close any outstanding transactions if the call fails, then disconnect
+ again (lurcher)
- Modified get_parent_class() and get_class_methods() to accept a class name as
well as a class instance. (Andrei, Zend Engine)
- Added support for UNC style paths. (\\server\share\file, //server/share/file)
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index ac65d0ee30..cb7a1cfe0e 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -169,17 +169,29 @@ static void _free_odbc_result(zend_rsrc_list_entry *rsrc)
}
}
+/*
+ * disconnect, and if it fails, then issue a rollback for any pending transaction (lurcher)
+ */
+
+static void safe_odbc_disconnect( void *handle )
+{
+ int ret;
+
+ ret = SQLDisconnect( handle );
+ if ( ret == SQL_ERROR )
+ {
+ SQLTransact( NULL, handle, SQL_ROLLBACK );
+ SQLDisconnect( handle );
+ }
+}
+
static void _close_odbc_conn(zend_rsrc_list_entry *rsrc)
{
odbc_connection *conn = (odbc_connection *)rsrc->ptr;
- /* FIXME
- * Closing a connection will fail if there are
- * pending transactions. It is in the responsibility
- * of the user to avoid this.
- */
+
ODBCLS_FETCH();
- SQLDisconnect(conn->hdbc);
+ safe_odbc_disconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
SQLFreeEnv(conn->henv);
efree(conn);
@@ -191,7 +203,7 @@ static void _close_odbc_pconn(zend_rsrc_list_entry *rsrc)
odbc_connection *conn = (odbc_connection *)rsrc->ptr;
ODBCLS_FETCH();
- SQLDisconnect(conn->hdbc);
+ safe_odbc_disconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
SQLFreeEnv(conn->henv);
free(conn);
@@ -2092,7 +2104,7 @@ try_and_get_another_connection:
if(ret != SQL_SUCCESS){
zend_hash_del(&EG(persistent_list), hashed_details, hashed_len + 1);
- SQLDisconnect(db_conn->hdbc);
+ safe_odbc_disconnect(db_conn->hdbc);
SQLFreeConnect(db_conn->hdbc);
goto try_and_get_another_connection;
}