Skip site navigation (1) Skip section navigation (2)

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

From: "John Rylander" <rylander(at)prolexia(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient
Date: 2006-06-11 21:08:00
Message-ID: 200606112108.k5BL809v009920@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      2477
Logged by:          John Rylander
Email address:      rylander(at)prolexia(dot)com
PostgreSQL version: 8.1.4
Operating system:   Windows XP :(
Description:        Aggregate Integer divisors incorrectly yield
integer-type quotient
Details: 

When for some reason I did a sum/count instead of an avg, the result was
always an integer (either 0 or 1):

Sum(
    Case when Sign(Delta)=Sign(AvgDelta) then
       1
    else
       0
   ) / Count(*) as HitRate;

If I use "/ Count(*)::float4", or use Avg instead of Sum/Count, it works
fine.

Yet another maddening PostgreSQL bug/idiosyncrasy.  Time for this boy to go
to Oracle (not because of this, but because of the function->transaction
problem, such that a function that has nested loops that create myriad
temporary analytical tables necessarily runs out of disk space; if it
weren't for the mandatory and completely counterproductive implicit
transaction, it'd take very little space and a lot less time).  :(

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2006-06-12 03:03:09
Subject: Re: BUG #2477: Aggregate Integer divisors incorrectly yield integer-type quotient
Previous:From: Alexander CordeiroDate: 2006-06-11 18:21:26
Subject: BUG #2476: Instalation problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group