Bug #71145 [NEW]: Multiple statements in init command triggers unbuffered query error

From: Date: Thu, 17 Dec 2015 04:03:19 +0000
Subject: Bug #71145 [NEW]: Multiple statements in init command triggers unbuffered query error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197951@lists.php.net to get a copy of this message
From: php at ontheroad dot net dot nz Operating system: Amazon Linux PHP version: 5.6.16 Package: PDO MySQL Bug Type: Bug Bug description:Multiple statements in init command triggers unbuffered query error Description: ------------ Using an PDO::MYSQL_ATTR_INIT_COMMAND with multiple statements separated by a semicolon triggers "General error: 2014 Cannot execute queries while other unbuffered queries are active.". The example below shows my situation. I want to ensure that UTF8 is handled correctly *and* enforce more strict MySQL behaviour, but it seems I can only set one or the other without triggering this bug. The application I've ran across this is being upgraded from PHP 5.4 using the old mysql library to PHP 5.6 with mysqlnd. Versions * PHP 5.6.14 * phpinfo() mysql Client API version => mysqlnd 5.0.11-dev * Amazon Linux mysql lib - php56-mysqlnd-5.6.14-1.119.amzn1.x86_64 Test script: --------------- <?php $options = array( PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, // This is the default, but here to be explicit PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;SET SESSION sql_mode=traditional', ); $dbo = new PDO( 'mysql:host=myhost.rds.amazonaws.com;port=3306;dbname=mydb;', 'user', 'password', $options ); $dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbo->prepare('SELECT foo FROM bar'); $stmt->execute(); Expected result: ---------------- Statement prepared and executed. Actual result: -------------- PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: 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.' in /home/foo/minimum.php:18 Stack trace: #0 /home/foo/minimum.php(18): PDOStatement->execute() #1 {main} thrown in /home/foo/minimum.php on line 18 -- Edit bug report at https://bugs.php.net/bug.php?id=71145&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71145&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71145&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71145&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71145&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71145&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71145&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71145&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71145&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71145&r=support Expected behavior: https://bugs.php.net/fix.php?id=71145&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71145&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71145&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71145&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71145&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71145&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71145&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71145&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71145&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71145&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71145&r=mysqlcfg

« previous php.bugs (#197951) next »