Bug #66878 [Ver->Csd]: Multiple rowsets not returned unless PDO statement object is unset()
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: Verified
+Status: Closed
Type: Bug
Package: PDO MySQL
Operating System: Linux
PHP Version: 5.4.26
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2020-12-08 10:49:18] 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.
------------------------------------------------------------------------
[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
Thread (3 messages)