#43967 [NEW]: SUM query on null value provides error in result with PDO_MYSQL driver

From: Date: Tue, 29 Jan 2008 15:29:52 +0000
Subject: #43967 [NEW]: SUM query on null value provides error in result with PDO_MYSQL driver
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121737@lists.php.net to get a copy of this message
From: emilien dot colotte at free dot fr Operating system: Vista PHP version: 5.2.5 PHP Bug Type: PDO related Bug description: SUM query on null value provides error in result with PDO_MYSQL driver Description: ------------ I made a simple sum query on a table column. The column contains some integer values and some null values. By executing the query throught the PDO MySQL driver, the result is wrong. By using the classic mysql library in PHP, the result is ok. I think there is a bug in PDO MySQL driver. More informations: - MySQL Version: 5.0.45 - PHP version: 5.2.4 Reproduce code: --------------- CREATE TABLE TEST ( ID_TEST int(10) NOT NULL AUTO_INCREMENT, VALUE int(10) default NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; INSERT INTO TEST (ID_TEST, VALUE) VALUES (1, NULL); INSERT INTO TEST (ID_TEST, VALUE) VALUES (2, -1); SELECT SUM(VALUE) AS TOTAL FROM TEST; Expected result: ---------------- The value returned by the query must be -1. Actual result: -------------- By executing the query from PDO, the value returned is NULL By executing the query from MySQL library, the value returned is -1 -- Edit bug report at http://bugs.php.net/?id=43967&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43967&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43967&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43967&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43967&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43967&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43967&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43967&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43967&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43967&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43967&r=support Expected behavior: http://bugs.php.net/fix.php?id=43967&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43967&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43967&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43967&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43967&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43967&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43967&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43967&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43967&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43967&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43967&r=mysqlcfg

« previous php.bugs (#121737) next »