Sum aggregate calculation for single precsion real

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Sum aggregate calculation for single precsion real
Date: 2017-02-13 11:13:41
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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';
(1 row)

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

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:
The Russian Postgres Company


Browse pgsql-hackers by date

  From Date Subject
Next Message Stas Kelvich 2017-02-13 11:55:31 Walsender crash
Previous Message Amit Langote 2017-02-13 10:57:59 Re: Documentation improvements for partitioning