Re: [HACKERS] 6.5.0 - Overflow bug in AVG( )

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>, Gene Sokolov <hook(at)aktrad(dot)ru>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] 6.5.0 - Overflow bug in AVG( )
Date: 1999-06-16 15:47:04
Message-ID: 3767C6F8.2083C35A@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> This would seem to give license for the result of AVG() on an int4 field
> to be NUMERIC with a fraction part, but not FLOAT. But I suspect we
> could get away with making it be FLOAT anyway.

Sure, that can't be worse in practice than what we do now. But it is
interesting that we are currently SQL92 conforming (except for that
nasty overflow business; they probably don't mention that ;).

For int2/int4, we could bump the accumulator to int8 (certainly faster
than our numeric implementation?), but there are a very few platforms
which don't support int8 and we shouldn't break the aggregates for
them. We could get around that by defining explicit routines to be
used in the aggregates, and then having some #ifdef alternate code if
int8 is not available...

Tom, do you think that a hack in the aggregate support code which
compares the pointer returned to the pointer input, then pfree'ing the
input area if they differ, would fix the major leakage? We could even
have a backend global variable which enables/disables the feature to
allow performance tuning.

- Thomas

--
Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
South Pasadena, California

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-06-16 15:56:39 Re: [HACKERS] SET QUERY_LIMIT bug report
Previous Message José Soares 1999-06-16 15:44:48 Re: [HACKERS] having bug report