Bug #72076 [NEW]: PDO ignores MySQL errors when using server-side prepared statements

From: Date: Fri, 22 Apr 2016 11:32:15 +0000
Subject: Bug #72076 [NEW]: PDO ignores MySQL errors when using server-side prepared statements
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200687@lists.php.net to get a copy of this message
From: andre at webkr dot de Operating system: Windows + Mac PHP version: 7.0.5 Package: PDO MySQL Bug Type: Bug Bug description:PDO ignores MySQL errors when using server-side prepared statements Description: ------------ When using server-side prepared statements, MySQL errors happening during execution are not returned by PDO MySQL. This happens in PHP 5.6 and PHP 7.0. Test script: --------------- $p = new PDO('mysql:host=localhost;charset=utf8', 'root', '', array(PDO::MYSQL_ATTR_COMPRESS => false)); $p->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); // server $p->query('CREATE DATABASE IF NOT EXISTS fixture'); $p->query('DROP TABLE IF EXISTS fixture.MysqlDatabaseTest'); $p->query('CREATE TABLE fixture.MysqlDatabaseTest (MysqlDatabaseTest_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, i INT NOT NULL) ENGINE=MyISAM'); $p->query('INSERT INTO fixture.MysqlDatabaseTest SET i = 1'); $p->query('INSERT INTO fixture.MysqlDatabaseTest SET i = 42'); $s = $p->prepare('SELECT i FROM fixture.MysqlDatabaseTest WHERE i = (SELECT i FROM fixture.MysqlDatabaseTest)'); $success = $s ? $s->execute() : null;; var_dump($success, $s, $p->errorInfo()); if ($s) var_dump($s->errorInfo(), $s->fetchAll()); Expected result: ---------------- Error: Subquery returns more than 1 row Actual result: -------------- No error, $s->fetchAll() returns an empty result array. -- Edit bug report at https://bugs.php.net/bug.php?id=72076&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72076&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72076&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72076&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72076&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72076&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72076&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72076&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72076&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72076&r=support Expected behavior: https://bugs.php.net/fix.php?id=72076&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72076&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72076&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72076&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72076&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72076&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72076&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72076&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72076&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72076&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72076&r=mysqlcfg

« previous php.bugs (#200687) next »