From 0ecf32f75044c42113acdd389dab95e20dd1cf59 Mon Sep 17 00:00:00 2001 From: Zak Greant Date: Wed, 9 Oct 2002 12:33:40 +0000 Subject: 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 --- ext/mysql/php_mysql.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'ext/mysql/php_mysql.c') diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 6a14bfd98f..71f4277ef5 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -229,7 +229,7 @@ void timeout(int sig); 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 @@ static int _restore_connection_defaults(zend_rsrc_list_entry *rsrc TSRMLS_DC) 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 -- cgit v1.2.1