Re: [HACKERS] Sum aggregate calculation for single precsion real - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Sum aggregate calculation for single precsion real
Date
Msg-id 12546.1487133938@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Sum aggregate calculation for single precsion real  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: [HACKERS] Sum aggregate calculation for single precsion real  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> Well put.  Although it's worth noting that we aren't 100% consistent
> about this stuff: sum(smallint), sum(integer), and sum(bigint) all use
> an output data type different from the input data type, but other
> versions of sum() don't.

In those cases I believe the main reason for the different output type is
that there's a significant risk of overflow if we don't.  See commits
bec98a31c and 5f7c2bdb5 for some history.

You could perhaps make an argument that sum(float4) would have less risk
of overflow if it accumulated in and returned float8, but frankly that
seems a bit thin.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [HACKERS] parallelize queries containing subplans
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] operator_precedence_warning vs make installcheck