php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61207 PDO::nextRowset() after a multi-statement query doesn't always work
Submitted: 2012-02-29 05:45 UTC Modified: 2012-03-05 23:38 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: acabal at ucla dot edu Assigned: mysql
Status: Closed Package: PDO related
PHP Version: 5.4.0RC8 OS: Ubuntu 11.10 64-bit
Private report: No CVE-ID:
 [2012-02-29 05:45 UTC] 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 `test`character 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

Patches

bug61207.diff (last revision 2012-02-29 12:21 UTC) by johannes@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-29 05:57 UTC] 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 12:21 UTC] 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 12:22 UTC] johannes@php.net
The attached patch should fix it, but needs some tests for PDO weirdness.
 [2012-02-29 12:22 UTC] johannes@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: mysql
 [2012-03-05 23:38 UTC] 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-03-05 23:38 UTC] johannes@php.net
-Status: Assigned +Status: Closed
 [2012-03-05 23:38 UTC] johannes@php.net
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.


 [2012-04-18 09:45 UTC] laruence@php.net
Automatic comment on behalf of johannes
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5c896b344a761c597a2decda14e25375f3b69ef3
Log: Fix Bug #61207 PDO::nextRowset() after a multi-statement query doesn't always work
 [2012-07-24 23:36 UTC] rasmus@php.net
Automatic comment on behalf of johannes
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5c896b344a761c597a2decda14e25375f3b69ef3
Log: Fix Bug #61207 PDO::nextRowset() after a multi-statement query doesn't always work
 [2013-11-17 09:33 UTC] laruence@php.net
Automatic comment on behalf of johannes
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5c896b344a761c597a2decda14e25375f3b69ef3
Log: Fix Bug #61207 PDO::nextRowset() after a multi-statement query doesn't always work
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 22:02:16 2014 UTC