diff options
author | Zak Greant <zak@php.net> | 2002-10-09 12:33:40 +0000 |
---|---|---|
committer | Zak Greant <zak@php.net> | 2002-10-09 12:33:40 +0000 |
commit | 0ecf32f75044c42113acdd389dab95e20dd1cf59 (patch) | |
tree | 04fac5dcce1fe480177c97938591645f5bde9dd2 /ext/mysql/php_mysql.c | |
parent | a15877930c0d1f60bb1c67a2220afeec0842f1d7 (diff) | |
download | php-git-0ecf32f75044c42113acdd389dab95e20dd1cf59.tar.gz |
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
Diffstat (limited to 'ext/mysql/php_mysql.c')
-rw-r--r-- | ext/mysql/php_mysql.c | 20 |
1 files changed, 17 insertions, 3 deletions
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 |