1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-15 03:41:20 +03:00

sum() on int2 and int4 columns now uses an int8, not numeric, accumulator

for speed reasons; its result type also changes to int8.  avg() on these
datatypes now accumulates the running sum in int8 for speed; but we still
deliver the final result as numeric, so that fractional accuracy is
preserved.

count() now counts and returns in int8, not int4.  I am a little nervous
about this possibly breaking users' code, but there didn't seem to be
a strong sentiment for avoiding the problem.  If we get complaints during
beta, we can change count back to int4 and add a "count8" aggregate.
For that matter, users can do it for themselves with a simple CREATE
AGGREGATE command; the int4inc function is still present, so no C hacking
is needed.

Also added max() and min() aggregates for OID that do proper unsigned
comparison, instead of piggybacking on int4 aggregates.

initdb forced.
This commit is contained in:
Tom Lane
2001-08-14 22:21:59 +00:00
parent 6f2943b52e
commit 5f7c2bdb53
13 changed files with 210 additions and 54 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.53 2001/06/01 02:41:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.54 2001/08/14 22:21:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1414,10 +1414,24 @@ fmgr(Oid procedureId,...)
Datum
Int64GetDatum(int64 X)
{
#ifndef INT64_IS_BUSTED
int64 *retval = (int64 *) palloc(sizeof(int64));
*retval = X;
return PointerGetDatum(retval);
#else /* INT64_IS_BUSTED */
/*
* On a machine with no 64-bit-int C datatype, sizeof(int64) will not be
* 8, but we want Int64GetDatum to return an 8-byte object anyway, with
* zeroes in the unused bits. This is needed so that, for example,
* hash join of int8 will behave properly.
*/
int64 *retval = (int64 *) palloc(Max(sizeof(int64), 8));
MemSet(retval, 0, Max(sizeof(int64), 8));
*retval = X;
return PointerGetDatum(retval);
#endif /* INT64_IS_BUSTED */
}
Datum