zak             Wed Oct  9 08:33:41 2002 EDT

  Modified files:              
    /php4/ext/mysql     php_mysql.c 
  Log:
  Possible fix for bug #19529 (thanks Rasmus, Arjen and Monty)
  
  Major changes to _restore_connection_defaults
   - added code block to finds and releases the active mysql result (if any)
   - this should prevent the 'Commands out of sync' error that would be
     raised when a query is made when unfreed results exist
     
  Minor changes to _restore_connection_defaults
   - replaced calls to mysql_real_query with mysql_query
     - we probably should not be using mysql_real_query without checking to
       see if we have a version that supports the function.
     - given that we control the query strings here and do not need to 
       worry about binary safety, I am using mysql_query instead
     - see the bug report for further discussion
  
  
  
Index: php4/ext/mysql/php_mysql.c
diff -u php4/ext/mysql/php_mysql.c:1.164 php4/ext/mysql/php_mysql.c:1.165
--- php4/ext/mysql/php_mysql.c:1.164    Wed Oct  9 03:34:48 2002
+++ php4/ext/mysql/php_mysql.c  Wed Oct  9 08:33:40 2002
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
  
-/* $Id: php_mysql.c,v 1.164 2002/10/09 07:34:48 zak Exp $ */
+/* $Id: php_mysql.c,v 1.165 2002/10/09 12:33:40 zak Exp $ */
 
 /* TODO:
  *
@@ -229,7 +229,7 @@
 static int _restore_connection_defaults(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
        php_mysql_conn *link;
-       char    query[128];
+       char    query[17];              /* Increase size if query length increases */
        char    user[128];
        char    passwd[128];
 
@@ -239,13 +239,27 @@
 
        link = (php_mysql_conn *) rsrc->ptr;
 
+       /* Find the active result set and free it */
+       if (link->active_result_id) {
+               int type;
+               MYSQL_RES *mysql_result;
+
+               mysql_result = (MYSQL_RES *) zend_list_find(link->active_result_id, 
+&type);
+               if (mysql_result && type==le_result) {
+                       zend_list_delete(link->active_result_id);
+                       link->active_result_id = 0;
+               }
+       }
+
        /* rollback possible transactions */
        strcpy (query, "ROLLBACK");
-       mysql_real_query(&link->conn, query, strlen(query));
+       /* Binary safe query not required here */
+       mysql_query(&link->conn, query);
 
        /* restore session variable "autocommit" to default (=1) */
        strcpy (query, "SET AUTOCOMMIT=1");
-       mysql_real_query(&link->conn, query, strlen(query));
+       /* Binary safe query not required here */
+       mysql_query(&link->conn, query);
 
        /* unset the current selected db */
 #if MYSQL_VERSION_ID > 32329



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to