Bug #69902 [Com]: PDO_DBLIB No Exception or warning thrown on divide by zero statement

From: Date: Wed, 14 Sep 2016 21:56:21 +0000
Subject: Bug #69902 [Com]: PDO_DBLIB No Exception or warning thrown on divide by zero statement
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204047@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69902&edit=1 ID: 69902 Comment by: adambaratz@php.net Reported by: maxiwheat at gmail dot com Summary: PDO_DBLIB No Exception or warning thrown on divide by zero statement Status: Open Type: Bug Package: PDO DBlib Operating System: Linux Slackware 14.1 PHP Version: 5.6.10 Block user comment: N Private report: N New Comment: I did some testing with MSSQL + FreeTDS (TDS 7.2). The query result includes the "divide by zero" message, but it's labeled as a result (with a NULL value) rather than an error. This is why an exception doesn't bubble up. I'm following up with the FreeTDS team to get a better understanding of why this is and where the fix should be applied. Previous Comments: ------------------------------------------------------------------------ [2015-06-22 17:08:32] maxiwheat at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=69902&edit=1

« previous php.bugs (#204047) next »