php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66878 Multiple rowsets not returned unless PDO statement object is unset()
Submitted: 2014-03-10 11:59 UTC Modified: 2020-12-08 10:49 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: wiktor dot janas at tensquaregames dot com Assigned:
Status: Closed Package: PDO MySQL
PHP Version: 5.4.26 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wiktor dot janas at tensquaregames dot com
New email:
PHP Version: OS:

 

 [2014-03-10 11:59 UTC] wiktor dot janas at tensquaregames dot com
Description:
------------
Hey,

Only the first multiple-result-set query on a given pdo connection works as expected; subsequent queries always claim to have only one result-set (although they have many). This does not happen if PDOStatement used to issue the query is unset(). The communication with the database is correct (checked with wireshark); this is an api issue.

Test script:
---------------
$sql = 'SELECT 123; SELECT 42; SELECT 999';
$pdo = new PDO('mysql:dbname=xxx;host=xxx', 'xxx', 'xxx');

$stmt = $pdo->query($sql);
var_dump($stmt->nextRowset()); /* returns true, as expected */
var_dump($stmt->nextRowset()); /* returns true, as expected */
var_dump($stmt->nextRowset()); /* returns false, as expected */
$stmt->closeCursor();
/* unset($stmt); uncomment this line to make stuff "work" */

$stmt = $pdo->query($sql);
var_dump($stmt->nextRowset()); /* expected: true; got: false */
var_dump($stmt->nextRowset()); /* expected: true; got: false */
var_dump($stmt->nextRowset());
$stmt->closeCursor();
/* unset($stmt); uncomment this line to make stuff "work" */

Expected result:
----------------
bool(true)
bool(true)
bool(false)
bool(true)
bool(true)
bool(false)

Actual result:
--------------
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-08 10:49 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2020-12-08 10:49 UTC] nikic@php.net
The problem is this code: https://github.com/php/php-src/blob/748d553c241b1379ff7f01a335d5f97332013f01/ext/pdo_mysql/mysql_statement.c#L90-L99

It flushes any remaining results / result sets, but at this point they will be the result sets for the second query.
 [2020-12-09 15:38 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fcfa7fd06b8b298b6946ec0bf2b2440dd8f5d895
Log: Fixed bug #66878
 [2020-12-09 15:38 UTC] nikic@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC