#50318 [Opn->Asn]: multiple statments result exception
| From: | felipe@php.net | Date: | Sun, 29 Nov 2009 14:35:01 +0000 |
| Subject: | #50318 [Opn->Asn]: multiple statments result exception | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-145186@lists.php.net to get a copy of this message | ||
ID: 50318
Updated by: felipe@php.net
Reported By: yury at nix dot co dot il
-Status: Open
+Status: Assigned
Bug Type: PDO related
Operating System: FreeBSD 7.2-STABLE
PHP Version: 5.2.11
-Assigned To:
+Assigned To: mysql
Previous Comments:
------------------------------------------------------------------------
[2009-11-28 12:18:29] yury at nix dot co dot il
I have just checked out the code of mysql_driver.c in 5_3,
it seems that the issue handled there, however I do not understand why
to
mysql_store_result() and then mysql_free_result(), it seems to work
with my solution as well... ( checked only on 5.2.11 )
------------------------------------------------------------------------
[2009-11-28 12:08:55] yury at nix dot co dot il
Description:
------------
When using multiple statments in a single $pdo->execute(),
php throws an exception, however the staments bieng executed anyway.
( example: http://pastebin.com/f6aec645c )
I think the mysql server expects the resultset to be advanced even if
it's empty, as shown in the c-api example here:
http://dev.mysql.com/doc/refman/5.1/en/c-api-multiple-queries.html
I think the follwing will resolve the issue
( diff against svn 5_2 )
*** mysql_driver.c Sat Nov 28 13:13:07 2009
--- /home/yury/php-5.2.11/ext/pdo_mysql/mysql_driver.c Fri Nov 27
13:55:46 2009
***************
*** 252,261 ****
--- 252,262 ----
my_ulonglong c = mysql_affected_rows(H->server);
if (c == (my_ulonglong) -1) {
pdo_mysql_error(dbh);
return (H->einfo.errcode ? -1 : 0);
} else {
+ while ( 0 == mysql_next_result( H->server ) );
return c;
}
}
}
Reproduce code:
---------------
http://pastebin.com/f6aec645c
Expected result:
----------------
throw exception and not commit
-or-
commit and not throw exception
Actual result:
--------------
The follwing exception thrown:
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.
But the data IS commited to the database.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50318&edit=1