Bug #71059 [NEW]: Undetected error in PDO
| From: | tobias dot marstaller at enlifor dot com | Date: | Tue, 08 Dec 2015 12:09:07 +0000 |
| Subject: | Bug #71059 [NEW]: Undetected error in PDO | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-197692@lists.php.net to get a copy of this message | ||
From: tobias dot marstaller at enlifor dot com
Operating system: Windows 8.1 Enterprise
PHP version: 5.6.16
Package: PDO MySQL
Bug Type: Bug
Bug description:Undetected error in PDO
Description:
------------
Szenario Setup:
- A MySQL table with a column TINYINT(4) NOT NULL DEFAULT 0 (lets call
it col in the context of this bug report)
- A PDO connection to the MySQL Server with that table that has been set
up with these attributes:
$pdo->setAttribute(PDO::ATTR_EMULATE_PERPARES, 0);
If you now try to insert a row into that table and pass that column a
value of 0 as PDO::PARAM_BOOL, the row is not inserted.
PDOStatement::execute() returns false. However,
PDOStatement::errorInfo() does not indicate an error and no exception is
thrown, regardless of PDO::ATTR_ERRMODE.
NOTE: TINYINT columns are frequently used as boolean columns which is
the reason for PDO::PARAM_BOOL.
Test script:
---------------
CREATE TABLE
s.a (
col tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=InnoDB
$pdo = new PDO("mysql:localhost", "username", "password");
$stmt = $pdo->prepare("INSERT INTO s.a (col) VALUES (?)");
$stmt->bindValue(1, 0, PDO::PARAM_BOOL);
assertFalse($stmt->execute());
$errorInfo = $stmt->errorInfo();
assertEquals($errorInfo, ["00000", NULL, NULL]);
Expected result:
----------------
I expect PDO to throw an exception when PDO::ATTR_ERRMODE is
PDO::ERRMODE_EXCEPTION instead of silently returning false from
PDOStatement::execute().
Actual result:
--------------
PDOStatement::execute() sucessfully determines that the statement did
not succeed (returns false). However, it does not throw an Exception
despite PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION
--
Edit bug report at https://bugs.php.net/bug.php?id=71059&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71059&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71059&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71059&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71059&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71059&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71059&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71059&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71059&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71059&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71059&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71059&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71059&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71059&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71059&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71059&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71059&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71059&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71059&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71059&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71059&r=mysqlcfg