Re: [HACKERS] 6.5.0 - Overflow bug in AVG( )

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] 6.5.0 - Overflow bug in AVG( )
Дата
Msg-id 24898.929543873@sss.pgh.pa.us
обсуждение исходный текст
Ответ на 6.5.0 - Overflow bug in AVG( )  ("Gene Sokolov" <hook@aktrad.ru>)
Список pgsql-hackers
"Gene Sokolov" <hook@aktrad.ru> writes:
> test1=>  select count(*), max("ID"), min("ID"), avg("ID") from "ItemsBars";
>  count|    max|  min| avg
> ------+-------+-----+----
> 677719|3075717|61854|-251

> Overflow, perhaps?

sum() and avg() for int fields use int accumulators.  You might want
to use avg(float8(field)) to get a less-likely-to-overflow result.

Someday it'd be a good idea to revise the sum() and avg() aggregates
to use float or numeric accumulators in all cases.  This'd require
inventing a few more cross-data-type operators...
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: [HACKERS] decimal & numeric report bug
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] 6.5.0 - Overflow bug in AVG( )