From: | Sferacarta Software <sferac(at)bo(dot)nettuno(dot)it> |
---|---|
To: | "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re[2]: [HACKERS] Re: bug on aggregate function AVG() |
Date: | 1998-11-04 15:00:39 |
Message-ID: | 11667.981104@bo.nettuno.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Tom,
mercoledì, 4 novembre 98, you wrote:
>> > prova=> select avg(int_2), avg(int_4), avg(int_8) from a;
>> The same on SUM():
TGL> Sure. For some reason, on most platforms integers are allowed to
TGL> overflow in Postgres. Of course, both SUM() and AVG() take a running
TGL> sum, and once they overflow you are hosed...
^^^^^
I don't know what does the word "hosed" mean Tom, I hope you don't want to tell me
there's no solution for this problem.
I see that AVG() and SUM() uses an accumulator not enough big to hold
the result of calculation, but the point is: should we consider this
thing a "terrible" bug or an acceptable feature ?
What about to convert every accumulator to float8 ?
select intero4 from a;
intero4
----------
2147483647
2147483647
2147483647
(3 rows)
select sum(inter04),sum(intero4*1.0) from a;
sum| sum
----------+----------
2147483645|6442450941
(1 row)
select avg(intero4),avg(intero4*1.0) from a;
avg| avg
---------+----------
715827881|2147483647
(1 row)
Anyway I think we need to work a little bit on aggregates:
MIN() and MAX() doesn't accept a string as parameter.
SUM() and AVG() gives a wrong result because it goes on overflow.
and none of them allows the clause DISTINCT.
What do you think about ? ;)
Jose'
From | Date | Subject | |
---|---|---|---|
Next Message | A James Lewis | 1998-11-04 15:04:02 | Re: [HACKERS] Warning!! |
Previous Message | Tom Lane | 1998-11-04 15:00:03 | Re: [HACKERS] Mixing library versions |