I got the error: 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. But:
- PDO::MYSQL_ATTR_USE_BUFFERED_QUERY is ON
- I don't use pdo's query() just exec().
I think there is a Problem with "ANALYZE TABLE". It returns a resultset with on row. I don't need this information. I can't change the order of the sql commands because in real that a different batches that a called in the night by a cron job...
A test code:
pdo()->exec("TRUNCATE TABLE test;");
pdo()->exec("INSERT INTO test SELECT id FROM data");
// pdo()->exec("INSERT INTO test VALUES (1)"); if only VALUES(..) is used no error thrown
pdo()->exec("ANALYZE TABLE test"); // this returns 1 row
pdo()->beginTransaction(); // here comes the exception!
The connection settings:
PDO::ATTR_EMULATE_PREPARES => 1
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 1
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8, lc_time_names = 'de_DE',sql_mode ='STRICT_ALL_TABLES,PIPES_AS_CONCAT', group_concat_max_len=1000000" ;
PDO::MYSQL_ATTR_COMPRESS => 1
My actual Workarround is:
$cmd = pdo()->query("ANALYZE TABLE test");
$cmd->closeCursor();
unset($cmd);
Is there any missconfiguration or is this a bug in 10.2.22-MariaDB-log or PHP Version 7.2.10?