ID: 42499 Updated by: [EMAIL PROTECTED] -Summary: After multi-statement execution via PDO::exec() connection becomes unusable Reported By: suhachov at gmail dot com -Status: Open +Status: Feedback Bug Type: PDO related Operating System: FC PHP Version: 5.2.4 New Comment:
First of all: Check your tone. You're not dealing with people who get paid for reading insults and/or aggressive tone. That is the best way to get your report totally ignored. If I had "brushed aside" this report, I wouldn't have bothered writing anything, this would be bogus right now.. Patches are more than welcome but we'd like to get them as files (this bug system sucks, I know) so provide an url to the unified diff. And make the patch against latest CVS snapshot rather than release, it's lot easier to review and apply it then. Previous Comments: ------------------------------------------------------------------------ [2007-09-03 19:00:49] suhachov at gmail dot com # tar xjf php-5.2.4.tar.bz2 # cd php-5.2.4 # ./configure --disable-all --with-pdo-mysql --enable-pdo --enable-cli --disable-cgi # make # sapi/cli/php -n pdo-mysql-bug.php Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in /home/andrew/src/php-5.2.4/pdo-mysql-bug.php on line 14 ------------------------------------------------------------------------ [2007-09-03 18:58:51] suhachov at gmail dot com How about _you_ check this issue instead of brushing aside? This bug is reproduced with ANY versions of PHP (5.1.6 - 5.2.4) ------------------------------------------------------------------------ [2007-09-03 09:15:32] [EMAIL PROTECTED] You report the bug with version 5.2.4, yet you seem to be using 5.1.6?! How about you try with 5.2.4 first? ------------------------------------------------------------------------ [2007-08-31 16:00:05] suhachov at gmail dot com Description: ------------ $dbh = PDO('mysql:...',...); $dbh->exec("SET some_var='value';SET names 'utf8'"); $dbh->query("SELECT NOW()"); # Error: Cannot execute queries while other unbuffered queries are active. ... PDO::MYSQL_ATTR_USE_BUFFERED_QUERY doesn't help. I found that in mysql_handle_doer() multi-results aren't freed. I'm not a MySQL C API professional, but this patch seems to solve this problem: --- php-5.1.6/ext/pdo_mysql/mysql_driver.c 2007-08-31 19:47:15.000000000 +0400 +++ php-5.1.6/ext/pdo_mysql/mysql_driver.c 2007-08-31 19:50:09.000000000 +0400 @@ -243,36 +243,20 @@ static long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) { - int ret_val; pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; if (mysql_real_query(H->server, sql, sql_len)) { pdo_mysql_error(dbh); - ret_val = -1; + return -1; } else { - // !! my_ulonglong c = mysql_affected_rows(H->server); if (c == (my_ulonglong) -1) { pdo_mysql_error(dbh); - ret_val = (H->einfo.errcode ? -1 : 0); + return (H->einfo.errcode ? -1 : 0); } else { - ret_val = c; - } + return c; } - -#if HAVE_MYSQL_NEXT_RESULT - while (mysql_more_results(H->server)) { - MYSQL_RES *res; - if (mysql_next_result(H->server) != 0) { - break; } - res = mysql_store_result(H->server); - if (res) { - mysql_free_result(res); - } - } -#endif - return ret_val; } static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned int *len TSRMLS_DC) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42499&edit=1