php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59644 sum() on integer returns 0
Submitted: 2011-03-02 12:25 UTC Modified: 2017-10-24 08:41 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:0 (0.0%)
From: p dot frost at kent dot ac dot uk Assigned:
Status: Suspended Package: ingres (PECL)
PHP Version: 5.3.2 OS: Solaris 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: p dot frost at kent dot ac dot uk
New email:
PHP Version: OS:

 

 [2011-03-02 12:25 UTC] p dot frost at kent dot ac dot uk
Description:
------------
For some reason, when we do a sum() on a column which returns an integer, the driver always returns 0. For instance:

$sql = "SELECT sum(module_component_key) FROM b_module_components WHERE ukc = 'xxx' AND module_code = 'BI500' AND module_component_key = 97289";

In this rather contrived example, module_component_key is a 4-byte integer in the database. The sum() should return 97289 but it returns 0. When we run the same SQL in isql it works perfectly.

The following works fine in PHP:


$sql = "SELECT float4(sum(module_component_key)) FROM b_module_components WHERE ukc = 'xxx' AND module_code = 'BI500' AND module_component_key = 97289";

It returns 97289.

So it seems that as long as the result is a float rather than an int, the driver returns the correct value. I haven't yet tested with other aggregate functions.

We have another box which is still using driver 2.0.2 and that displays the same symptom.


Hardware is a Sun T5120

Ingres version is 9.2. Version.rel:

II 9.2.0 (su9.us5/143)
13691

PHPInfo:

PHP Version => 5.3.2

System => SunOS portia 5.10 Generic_144488-02 sun4v
Build Date => Aug 16 2010 13:20:32
Configure Command =>  './configure'  '--with-libexpat-dir=/usr/local' '--with-freetype-dir=/usr/local' '--with-mysql=/usr/local' '--with-imap=/usr/local' '--prefix=/usr/local' '--with-regex=php' '--with-g
d=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-zlib-dir=/usr/local' '--with-xpm-dir=/usr/local' '--with-iconv=/usr/local' '--with-ldap=/usr/local' '--with-libxml-dir=/usr/l
ocal' '--with-curl=/usr/local' '--with-openssl=/usr/local' '--with-config-file-path=/usr/local/etc/' '--enable-mbstring' '--enable-bcmath' '--enable-gd-native-ttf' '--enable-inline-optimization' '--enable
-shmop' '--enable-sockets' '--enable-wddx' '--with-pear' '--with-pspell' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-xsl' '--with-pdo-mysql=/usr/local' '--with-oci8=shared,instantclient,/usr/lo
cal/lib' '--with-pdo-oci=shared,instantclient,/usr/local/lib,10.1' '--with-mysqli'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc/
Loaded Configuration File => /usr/local/etc/apache2/CONFIG/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20090626
PHP Extension => 20090626
Zend Extension => 220090626
Zend Extension Build => API220090626,NTS
PHP Extension Build => API20090626,NTS
Debug Build => no
Thread Safety => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, zip, phar  
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters => zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

ingres

Ingres Support => enabled
Ingres Extension Version => 2.2.2
Revision => $Revision: 300312 $
Ingres OpenAPI Version => 6
Active Persistent Links => 0
Active Links => 0

Directive => Local Value => Master Value
ingres.allow_persistent => On => On
ingres.array_index_start => 1 => 1
ingres.auto => On => On
ingres.blob_segment_length => 4096 => 4096
ingres.cursor_mode => 1 => 1
ingres.default_database => no value => no value
ingres.default_password => no value => no value
ingres.default_user => no value => no value
ingres.describe => On => On
ingres.fetch_buffer_size => 100 => 100
ingres.max_links => Unlimited => Unlimited
ingres.max_persistent => Unlimited => Unlimited
ingres.reuse_connection => On => On
ingres.scrollable => On => On
ingres.trace => Off => Off
ingres.trace_connect => Off => Off
ingres.utf8 => On => On

Reproduce code:
---------------
$sql = "SELECT sum(module_component_key) FROM b_module_components WHERE ukc = 'xxx' AND module_code = 'BI500' AND module_component_key = '97289'";


$conn = ingres_connect("cordelia::studev", "wwwuser", "");

$res = ingres_query($conn, $sql);

while ($row = ingres_fetch_row($res)) {
    echo $row[1];
}

Expected result:
----------------
97289

Actual result:
--------------
0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-24 08:41 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-10-24 08:41 UTC] kalle@php.net
The ingres package has not had any activity for 4 years, so its safe to say that its no longer in active development, if activity picks backup then the maintainer can re-open this report
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 12:01:29 2024 UTC