php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50941 pdo throws "unbuffered queries" error when use a sp and ATTR_EMULATE_PREPARES
Submitted: 2010-02-05 19:15 UTC Modified: 2010-03-24 12:37 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ies_clan at hotmail dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.3.1 OS: Windows XP home
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ies_clan at hotmail dot com
New email:
PHP Version: OS:

 

 [2010-02-05 19:15 UTC] ies_clan at hotmail dot com
Description:
------------
if u call a stored procedure and then a normal sql statement, while u use ATTR_EMULATE_PREPARES = false, u got an error like:
General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.

to set PDO::MYSQL_ATTR_USE_BUFFERED_QUERY have no effect.

uf u use closeCursor(); u got that error:
Packets out of order

Reproduce code:
---------------
/*
-- 
-- Table structure for table `testtabelle`
-- 

DROP TABLE IF EXISTS `testtabelle`;
CREATE TABLE `testtabelle` (
  `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(45) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

INSERT INTO `testtabelle` VALUES (1,'test'),(2,'test'),(3,'test'),(4,'test'),(5,'tesfsst');

DELIMITER $$

DROP PROCEDURE IF EXISTS `myTestProd` $$
CREATE PROCEDURE `myTestProd` ()
BEGIN
SELECT * FROM testtabelle;
END $$

DELIMITER ;
 */

$Database = new PDO('mysql:dbname='.DATABASE.';host='.DATABASE_SERVER,
    DATABASE_USER,
    DATABASE_PASSWORD,
    array(
        PDO::ATTR_EMULATE_PREPARES => false,
        PDO::ATTR_PERSISTENT => false,
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
        PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
    )
);

$Query1 = $Database->prepare('CALL myTestProd()');
$Query1->execute();
print_r($Query1->fetchAll());
$Query1->closeCursor();

$Query2 = $Database->prepare('SELECT * FROM testtabelle');
$Query2->execute();
print_r($Query2->fetchAll());
$Query1->closeCursor();  

Expected result:
----------------
Array
(
    [0] => Array
        (
            [ID] => 1
            [0] => 1
            [Name] => test
            [1] => test
        )

    [1] => Array
        (
            [ID] => 2
            [0] => 2
            [Name] => test
            [1] => test
        )

    [2] => Array
        (
            [ID] => 3
            [0] => 3
            [Name] => test
            [1] => test
        )

    [3] => Array
        (
            [ID] => 4
            [0] => 4
            [Name] => test
            [1] => test
        )

    [4] => Array
        (
            [ID] => 5
            [0] => 5
            [Name] => tesfsst
            [1] => tesfsst
        )

)
Array
(
    [0] => Array
        (
            [ID] => 1
            [0] => 1
            [Name] => test
            [1] => test
        )

    [1] => Array
        (
            [ID] => 2
            [0] => 2
            [Name] => test
            [1] => test
        )

    [2] => Array
        (
            [ID] => 3
            [0] => 3
            [Name] => test
            [1] => test
        )

    [3] => Array
        (
            [ID] => 4
            [0] => 4
            [Name] => test
            [1] => test
        )

    [4] => Array
        (
            [ID] => 5
            [0] => 5
            [Name] => tesfsst
            [1] => tesfsst
        )

)


Actual result:
--------------
Array
(
    [0] => Array
        (
            [ID] => 1
            [0] => 1
            [Name] => test
            [1] => test
        )

    [1] => Array
        (
            [ID] => 2
            [0] => 2
            [Name] => test
            [1] => test
        )

    [2] => Array
        (
            [ID] => 3
            [0] => 3
            [Name] => test
            [1] => test
        )

    [3] => Array
        (
            [ID] => 4
            [0] => 4
            [Name] => test
            [1] => test
        )

    [4] => Array
        (
            [ID] => 5
            [0] => 5
            [Name] => tesfsst
            [1] => tesfsst
        )

)
. Expected 1 received 11. Packet size=7

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-24 12:37 UTC] uw@php.net
-Status: Open +Status: Bogus
 [2010-03-24 12:37 UTC] uw@php.net
No bug here. Everything works fine if you use the API as you should. Your code lacks calls to stmt->nextrowset():

do {
print_r($Query1->fetchAll());
} while ($Query1->nextrowset());
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC