cvs: php4(PHP_4_2_0) /ext/mysql php_mysql.c
| From: | Georg Richter | Date: | Sun, 21 Jul 2002 22:19:51 +0000 |
| Subject: | cvs: php4(PHP_4_2_0) /ext/mysql php_mysql.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-12925@lists.php.net to get a copy of this message | ||
georg Sun Jul 21 18:19:51 2002 EDT
Modified files: (Branch: PHP_4_2_0)
/php4/ext/mysql php_mysql.c
Log:
Automatic rollback for non committed transactions
Index: php4/ext/mysql/php_mysql.c
diff -u php4/ext/mysql/php_mysql.c:1.116 php4/ext/mysql/php_mysql.c:1.116.2.1
--- php4/ext/mysql/php_mysql.c:1.116 Thu Feb 28 03:26:25 2002
+++ php4/ext/mysql/php_mysql.c Sun Jul 21 18:19:51 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mysql.c,v 1.116 2002/02/28 08:26:25 sebastian Exp $ */
+/* $Id: php_mysql.c,v 1.116.2.1 2002/07/21 22:19:51 georg Exp $ */
/* TODO:
@@ -215,6 +215,26 @@
void timeout(int sig);
#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING, "MySQL: A link to the server
could not be established"); RETURN_FALSE; } }
+/* {{{ _rollback_mysql_transactions
+ */
+static int _rollback_mysql_transactions(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+{
+ php_mysql_conn *link;
+ char query[128];
+
+ /* check if its a persistent link */
+ if (Z_TYPE_P(rsrc) != le_plink)
+ return 0;
+
+ link = (php_mysql_conn *) rsrc->ptr;
+
+ /* rollback possible transactions */
+ strcpy (query, "ROLLBACK");
+ mysql_real_query(&link->conn, query, strlen(query));
+
+ return 0;
+}
+/* }}} */
/* {{{ _free_mysql_result
* This wrapper is required since mysql_free_result() returns an integer, and
@@ -385,6 +405,8 @@
*/
PHP_RSHUTDOWN_FUNCTION(mysql)
{
+ zend_hash_apply(&EG(persistent_list), (apply_func_t) _rollback_mysql_transactions TSRMLS_CC);
+
if (MySG(connect_error)!=NULL) {
efree(MySG(connect_error));
}