#42499 [Opn]: After multi-statement execution via PDO::exec() connection becomes unusable
by Suhachov At Gmail Dot Com other posts by this author
Sep 3 2007 12:01PM messages near this date
#42499 [Opn->Fbk]: PDO_MYSQL: multi-statement execution via PDO::exec() makes connection unusable
|
#42499 [Fbk->Opn]: After multi-statement execution via PDO::exec() connection becomes unusable
ID: 42499
User updated by: suhachov at gmail dot com
Reported By: suhachov at gmail dot com
Status: Open
Bug Type: PDO related
Operating System: FC
PHP Version: 5.2.4
New Comment:
# 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
Previous Comments:
------------------------------------------------------------------------
[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] jani@[...].net
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
Thread:
Suhachov At Gmail Dot Com
Stormi At Laposte Dot Net
uw
uw
johannes
Kingoleg At Mail Dot Ru
Mgrdinic At Sledxchange Dot Com
Suhachov At Gmail Dot Com
jani
jani
Suhachov At Gmail Dot Com
Suhachov At Gmail Dot Com
jani
|