[HACKERS] Sum aggregate calculation for single precsion real

Поиск
Список
Период
Сортировка
От Konstantin Knizhnik
Тема [HACKERS] Sum aggregate calculation for single precsion real
Дата
Msg-id d18bcff9-1bc1-3ef9-9093-7eafdc05173e@postgrespro.ru
обсуждение исходный текст
Ответы Re: [HACKERS] Sum aggregate calculation for single precsion real  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi hackers,

I wonder why SUM aggregate is calculated for real (float4) type using 
floating point accumulator?
It cause very confusing and unexpected behavior:

-- postgres=# select sum(l_quantity)  from lineitem where l_shipdate <= '1998-12-01';     sum
------------- 1.52688e+09
(1 row)

postgres=# select sum(l_quantity+0.0)  from lineitem where l_shipdate <= '1998-12-01';    sum
------------ 1529738036


It is specified in any SQL standard how aggregates should be calculated?
At least Oracle and MS-SQL are calculating SUM for single precision type in different (and more natual) way.
Are there are reasons of using float4pl function for SUM aggregate instead of float4_accum?



Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company




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

Предыдущее
От: Amit Langote
Дата:
Сообщение: Re: [HACKERS] Documentation improvements for partitioning
Следующее
От: Stas Kelvich
Дата:
Сообщение: [HACKERS] Walsender crash