Re: [BUGS] agregate function sum error - Mailing list pgsql-hackers

From sferac@bo.nettuno.it
Subject Re: [BUGS] agregate function sum error
Date
Msg-id Pine.LNX.3.96.980216102604.11072C-100000@nero
Whole thread Raw
List pgsql-hackers
On Sun, 15 Feb 1998, Marin D wrote:

>
> Hi!
>
> You can try to typecast to float8
>
> I have no idea how MySql is doing SUM() - probably it uses unsigned int
> for SUM() so this gives u twice bigger upper limit - try it with MySql
> with sum exceeding 2^32. I suppose the result will be negative ...
>

Well, I asked this question to MySql mailing list:

> sferac> What's meaning "inf" as a result during a SUM() ?
> sferac> Is it an overflow warning, and if so what's the max range of SUM()
> sferac> before to have an overflow ?
>
> mysql> update t set myfloat=myfloat*9.1;
> sferac> Query OK, 1415 rows affected (4.94 sec)
>
> mysql> select sum(myfloat) from t;
> sferac> 1 row in set (0.04 sec)
>
> sferac> +--------------+
> sferac> | sum(myfloat) |
> sferac> +--------------+
> sferac> |          Inf |
> sferac> +--------------+
>
> mysqld does all normal calculation with doubles (bit functions are
> done with longlong);  The range of a double is typical something like:
>
> #define       DBL_MAX         1.7976931348623157E+308
> #define       DBL_MIN         2.2250738585072014E-308
>
> Yours,
> Monty

Isn't it a good solution to implement PostgreSQL SUM() function ?
What do you think about ?

____________________________Jose' Soares Da Silva_____________________________
           Via Bazzanese, 69      ),,,(          www.sferacarta.com
    Casalecchio R.(BO) Italy     +|o o|+         sferac@bo.nettuno.it
        Fax. ++39 51 6131537      /. .\          Tel. ++39 51  591054
---------------------------------(_---_)--------------------------------------
"...when men cease to destroy the animal race the lion
 and the lamb can dwell together..." (Joseph Smith)


pgsql-hackers by date:

Previous
From: Zeugswetter Andreas SARZ
Date:
Subject: AW: [HACKERS] Re: Subselects open issue Nr. 5
Next
From: Jordan Henderson
Date:
Subject: Re: [HACKERS] spin locks