|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74584 Error about active unbuffered queries triggered unexpectedly
Submitted: 2017-05-12 19:07 UTC Modified: 2020-12-09 16:36 UTC
Avg. Score:4.3 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: love at sickpeople dot se Assigned:
Status: Duplicate Package: PDO MySQL
PHP Version: 7.1.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: love at sickpeople dot se
New email:
PHP Version: OS:


 [2017-05-12 19:07 UTC] love at sickpeople dot se
An exception is thrown in the test case below.

 - Emulated prepares must be OFF

 - "LOCK TABLE" triggers the error, eg "set @foo='bar'" does NOT

I see no reason why the error occurs in this case.

Test script:
// Please fill in

$host = '';
$db = '';
$user = '';
$pass = '';

$options = [];
$options[PDO::ATTR_EMULATE_PREPARES] = false; /* required */

$PDO = new PDO   ( "mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass, $options );

$PDO->exec ('create temporary table foo (bar int)');

$PDO->query ('lock table foo write');

Expected result:
No exception thrown.

Actual result:
Exception thrown.

SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOState ment::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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-12 19:11 UTC] love at sickpeople dot se
Version of Mysqlnd is 5.0.12-dev.
 [2019-07-24 14:42 UTC] yardsoftware at gmail dot com
Note : Using $PDO->exec() resolves this issue.  Also make sure you do not have a semicolon when using this method.
 [2019-07-24 20:18 UTC] love at sickpeople dot se
The main difference between exec() and query() is that exec() sends a QUERY command while query() sends PREPARE + EXECUTE + CLOSE commands. Possibly related to that?
 [2019-10-08 16:03 UTC] hadrien dot sibboni at gmail dot com
Simpler : just doing the $PDO->query ('lock table foo write'); creates the same bug for me (if you have a table). (no need to $PDO->exec ('create temporary table foo (bar int)');)

Isnt it the same as ?
 [2020-12-09 16:36 UTC]
-Status: Open +Status: Duplicate
 [2020-12-09 16:36 UTC]
Same root cause as bug #70066.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 10:01:27 2024 UTC