Bug #69902 [NEW]: PDO_DBLIB No Exception or warning thrown on divide by zero statement
| From: | maxiwheat at gmail dot com | Date: | Mon, 22 Jun 2015 17:08:33 +0000 |
| Subject: | Bug #69902 [NEW]: PDO_DBLIB No Exception or warning thrown on divide by zero statement | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-193763@lists.php.net to get a copy of this message | ||
From: maxiwheat at gmail dot com
Operating system: Linux Slackware 14.1
PHP version: 5.6.10
Package: PDO DBlib
Bug Type: Bug
Bug description:PDO_DBLIB No Exception or warning thrown on divide by zero statement
Description:
------------
When executing queries on Microsoft SQL Server (tested on 2008 and
2014), some queries that should fail and produce an exception (or a
warning depending on PDO::ATTR_ERRMODE) just fail silently. This is a
problem since we cannot catch or detect and handle them (logging etc.)
I know of "Divide by zero" errors that produce this unexpected behavior,
there might be other ones.
However, some other types of SQL errors produce exceptions as expected,
there seem to be some specific kind that don't get thrown.
Test script:
---------------
// Make sure all errors are displayed
ini_set('display_errors', '1');
error_reporting(E_ALL);
$dbh = new PDO
("dblib:host=myserver;dbname=MyDB","myUsername","MyPass");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Dividing by zero should throw an exception
$stmt = $dbh->prepare("SELECT 1/0;");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_BOTH);
var_dump($result);
Expected result:
----------------
An exception should be thrown.
Actual result:
--------------
No exception thrown
--
Edit bug report at https://bugs.php.net/bug.php?id=69902&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69902&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69902&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69902&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69902&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69902&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69902&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69902&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69902&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69902&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69902&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69902&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69902&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69902&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69902&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69902&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69902&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69902&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69902&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69902&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69902&r=mysqlcfg