Bug #66878 [Opn->Ver]: Multiple rowsets not returned unless PDO statement object is unset()
| From: | nikic@php.net | Date: | Tue, 08 Dec 2020 10:49:18 +0000 |
| Subject: | Bug #66878 [Opn->Ver]: Multiple rowsets not returned unless PDO statement object is unset() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230931@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66878&edit=1
ID: 66878
Updated by: nikic@php.net
Reported by: wiktor dot janas at tensquaregames dot com
Summary: Multiple rowsets not returned unless PDO statement
object is unset()
-Status: Open
+Status: Verified
Type: Bug
Package: PDO MySQL
Operating System: Linux
PHP Version: 5.4.26
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2014-03-10 11:59:14] 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)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66878&edit=1