lurcher Mon Apr 2 08:18:47 2001 EDT
Modified files:
/php4 NEWS
/php4/ext/odbc php_odbc.c
Log:
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.
Index: php4/NEWS
diff -u php4/NEWS:1.625 php4/NEWS:1.626
--- php4/NEWS:1.625 Sun Apr 1 07:13:09 2001
+++ php4/NEWS Mon Apr 2 08:18:46 2001
@@ -2,6 +2,9 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 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)
Index: php4/ext/odbc/php_odbc.c
diff -u php4/ext/odbc/php_odbc.c:1.75 php4/ext/odbc/php_odbc.c:1.76
--- php4/ext/odbc/php_odbc.c:1.75 Tue Mar 27 07:46:27 2001
+++ php4/ext/odbc/php_odbc.c Mon Apr 2 08:18:47 2001
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_odbc.c,v 1.75 2001/03/27 15:46:27 kalowsky Exp $ */
+/* $Id: php_odbc.c,v 1.76 2001/04/02 15:18:47 lurcher Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -169,17 +169,29 @@
}
}
+/*
+ * 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 @@
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 @@
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;
}
--
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]