#34499 [Asn->Bgs]: pdo::exec fails when executing sequential 'OPTIMIZE TABLE' queries
| From: | iliaa@php.net | Date: | Wed, 14 Sep 2005 16:50:26 +0000 |
| Subject: | #34499 [Asn->Bgs]: pdo::exec fails when executing sequential 'OPTIMIZE TABLE' queries | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-85046@lists.php.net to get a copy of this message | ||
ID: 34499
Updated by: iliaa@php.net
Reported By: maesa at email dot it
-Status: Assigned
+Status: Bogus
Bug Type: PDO related
Operating System: Windows XP SP2
PHP Version: 5.1.0RC1
Assigned To: wez
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Error reporting issue was addressed, but for optimize query you really
should be using the query() and not the exec() method.
Previous Comments:
------------------------------------------------------------------------
[2005-09-14 16:58:41] wez@php.net
OPTIMIZE TABLE is a query that returns rows.
You should use PDO::query() instead.
I'll see about handling this user error more gracefully.
------------------------------------------------------------------------
[2005-09-14 13:47:29] sniper@php.net
Assigned to the maintainer
------------------------------------------------------------------------
[2005-09-14 13:25:13] maesa at email dot it
I've installed the snapshot package for windows and got it running but
the problem persist...
------------------------------------------------------------------------
[2005-09-14 11:52:29] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Several fixes were committed since RC1 was released..
------------------------------------------------------------------------
[2005-09-14 11:44:34] maesa at email dot it
Description:
------------
A pdo::exec call fails when i try to execute sequential query (
'OPTIMIZE TABLE' queries )
Reproduce code:
---------------
$dsn = 'mysql:dbname=my_database;host=localhost';
$user = 'root';
$password = '';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$dbh->exec( 'OPTIMIZE TABLE my_table' );
print_r($dbh->errorInfo());
$dbh->exec( 'OPTIMIZE TABLE my_table_1' );
print_r($dbh->errorInfo());
Expected result:
----------------
I expected that the second call to $dbh->exec will be successful as the
first one, but the second fails.
Actual result:
--------------
Printing the array returned from $dbh->errorInfo() i obtain for the
first call to pdo::exec
Array
(
[0] => 00000
)
but for the second call
Array
(
[0] => HY000
[1] => 2014
[2] => 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.
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34499&edit=1