Re: BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient
Date
Msg-id 29738.1150081389@sss.pgh.pa.us
Whole thread Raw
In response to BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient  ("John Rylander" <rylander@prolexia.com>)
List pgsql-bugs
"John Rylander" <rylander@prolexia.com> writes:
> When for some reason I did a sum/count instead of an avg, the result was
> always an integer (either 0 or 1):

What's your point?  Postgres has always defined division of integers as
yielding an integer result.  AFAICS this choice is fully sanctioned by
the SQL standard:

         1) If the data type of both operands of a dyadic arithmetic opera-
            tor is exact numeric, then the data type of the result is exact
            numeric, with precision and scale determined as follows:
            ...
            d) The precision and scale of the result of division is
              implementation-defined.

(SQL92 6.12 <numeric value expression> syntax rule 1)

> Yet another maddening PostgreSQL bug/idiosyncrasy.  Time for this boy to go
> to Oracle

Sayonara.  Last I checked, they had a few idiosyncrasies too.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Alexander Cordeiro"
Date:
Subject: BUG #2476: Instalation problem
Next
From: "Jim C. Nasby"
Date:
Subject: Re: BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient