Re: BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "John Rylander" <rylander(at)prolexia(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient
Date: 2006-06-12 03:03:09
Message-ID: 29738.1150081389@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"John Rylander" <rylander(at)prolexia(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jim C. Nasby 2006-06-12 15:48:18 Re: BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient
Previous Message John Rylander 2006-06-11 21:08:00 BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient