what data type should be returned by sum(float4)

From: Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)com>
To: PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: what data type should be returned by sum(float4)
Date: 2014-09-08 00:10:57
Message-ID: 9A28C8860F777E439AA12E8AEA7694F8FD7BA5@BPXM15GP.gisp.nec.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

http://www.postgresql.org/docs/devel/static/functions-aggregate.html

The documentation says that return type of sum(expression) is...
bigint for smallint or int arguments, numeric for bigint arguments,
double precision for floating-point arguments, otherwise the same
as the argument data type

Does it expect sum(float4) returns float8, doesn't it?

On the other hand, catalog definition seems to me it returns float4.

postgres=# select * from pg_aggregate where aggfnoid in (2110, 2111);
aggfnoid | aggkind | aggnumdirectargs | aggtransfn | aggfinalfn | aggmtra
nsfn | aggminvtransfn | aggmfinalfn | aggfinalextra | aggmfinalextra | aggsortop
| aggtranstype | aggtransspace | aggmtranstype | aggmtransspace | agginitval |
aggminitval
----------------+---------+------------------+------------+------------+--------
-----+----------------+-------------+---------------+----------------+----------
-+--------------+---------------+---------------+----------------+------------+-
------------
pg_catalog.sum | n | 0 | float4pl | - | -
| - | - | f | f | 0
| 700 | 0 | 0 | 0 | |
pg_catalog.sum | n | 0 | float8pl | - | -
| - | - | f | f | 0
| 701 | 0 | 0 | 0 | |
(2 rows)

Which one shall be fixed?

Thanks,
--
NEC OSS Promotion Center / PG-Strom Project
KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-09-08 02:20:31 Re: what data type should be returned by sum(float4)
Previous Message Shigeru HANADA 2014-09-07 23:27:26 Re: Join push-down support for foreign tables