Bug #61207 [Asn->Csd]: PDO::nextRowset() after a multi-statement query doesn't always work
| From: | johannes@php.net | Date: | Mon, 05 Mar 2012 23:38:29 +0000 |
| Subject: | Bug #61207 [Asn->Csd]: PDO::nextRowset() after a multi-statement query doesn't always work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-168181@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61207&edit=1
ID: 61207
Updated by: johannes@php.net
Reported by: acabal at ucla dot edu
Summary: PDO::nextRowset() after a multi-statement query
doesn't always work
-Status: Assigned
+Status: Closed
Type: Bug
Package: PDO related
Operating System: Ubuntu 11.10 64-bit
PHP Version: 5.4.0RC8
Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2012-03-05 23:38:07] johannes@php.net
Automatic comment from SVN on behalf of johannes
Revision: http://svn.php.net/viewvc/?view=revision&revision=323928
Log: Fix Bug #61207 PDO::nextRowset() after a multi-statement query doesn't always work
------------------------------------------------------------------------
[2012-02-29 12:22:27] johannes@php.net
The attached patch should fix it, but needs some tests for PDO weirdness.
------------------------------------------------------------------------
[2012-02-29 12:21:48] johannes@php.net
The following patch has been added/updated:
Patch Name: bug61207.diff
Revision: 1330518108
URL: https://bugs.php.net/patch-display.php?bug=61207&patch=bug61207.diff&revision=1330518108
------------------------------------------------------------------------
[2012-02-29 05:57:00] acabal at ucla dot edu
Oops, a small typo in the linked example script: In the bugged example, I typed $handle1 instead of
$handle4 in the do loop. Interestingly the script still produces the same bugged output even with
the typo.
------------------------------------------------------------------------
[2012-02-29 05:45:49] acabal at ucla dot edu
Description:
------------
After executing a single multi-statement query in PDO in which the statements are INSERT, followed
by UPDATE, followed by SELECT, then trying to loop over the results using PDO::nextRowset(), the
function returns FALSE (i.e. no more rowsets) after the UPDATE rowset, but before reaching the
SELECT rowset. Thus the SELECT rowset is lost.
I tried several permutations of multi-statement queries. INSERT, then SELECT, then UPDATE works;
SELECT then UPDATE works; UPDATE then SELECT works; only INSERT, then UPDATE, then SELECT fails.
See the below code for those examples plus the bugged example.
I originally ran in to this problem on PHP 5.3.5, but it still appears in PHP 5.4.0RC8.
Test script:
---------------
First create the following MySQL test db/table:
create database
testcharacter set utf8 collate utf8_general_ci;
create table test.testtable( id int );
Next check this example code to see the bug in action. There are four examples in the code, the
first three work, and the last one is the bug.
http://pastebin.com/EKePD6e2
The bug tracker suggested a link for code longer than 20 lines, though I can provide the example
script directly in this bug report if that would be helpful.
Expected result:
----------------
Handle 1:
Rowset 1
Rowset 2
Results detected
Handle 2:
Rowset 1
Results detected
Handle 3:
Rowset 1
Rowset 2
Results detected
Handle 4:
Rowset 1
Rowset 2
Results detected
Actual result:
--------------
Handle 1:
Rowset 1
Rowset 2
Results detected
Handle 2:
Rowset 1
Results detected
Handle 3:
Rowset 1
Rowset 2
Results detected
Handle 4:
Rowset 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61207&edit=1