diff options
author | Marc G. Fournier <scrappy@hub.org> | 1997-04-03 19:56:47 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1997-04-03 19:56:47 +0000 |
commit | 9d5c0af5862cc0141ea16ca90a9e01250716af37 (patch) | |
tree | a5097449997b576fc951c5f5ca33a29df8f039fa /src/backend | |
parent | 164cd7ab342da27686f0114775a1050ad89b7437 (diff) | |
download | postgresql-9d5c0af5862cc0141ea16ca90a9e01250716af37.tar.gz postgresql-9d5c0af5862cc0141ea16ca90a9e01250716af37.zip |
From: Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
Subject: [HACKERS] Aggregate function patches
Here are the aggregate function patches I originally sent in last December.
They fix sum() and avg() behavior for ints and floats when NULL values are
involved.
I was waiting to resubmit these until I had a chance to write a v6.0->v6.1
database upgrade script to ensure that existing v6.0 databases which have
not been reloaded for v6.1 do no break with the new aggregate behavior.
These scripts are included below. It's OK with me if someone wants to do
something different with the upgrade strategy, but something like this
was discussed a few weeks ago.
Also, there were a couple of small items which cropped up in doing a clean
install of 970403 (actually 970402 + 970403 changes since the full 970403
tar file appears to be damaged or at least suspect). They are the first
two patches below and can be omitted if desired (although I think they
aren't dangerous :).
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/executor/nodeAgg.c | 7 | ||||
-rw-r--r-- | src/backend/optimizer/geqo/geqo_eval.c | 6 | ||||
-rw-r--r-- | src/backend/tcop/aclchk.c | 4 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 4f1a5902f0a..c6e5b269cde 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -368,7 +368,12 @@ ExecAgg(Agg *node) char *args[2]; AggFuncInfo *aggfns = &aggFuncInfo[i]; - if (aggfns->finalfn && nTuplesAgged > 0) { + if (noInitValue[i]) { + /* + * No values found for this agg; return current state. + * This seems to fix behavior for avg() aggregate. -tgl 12/96 + */ + } else if (aggfns->finalfn && nTuplesAgged > 0) { if (aggfns->finalfn_nargs > 1) { args[0] = (char*)value1[i]; args[1] = (char*)value2[i]; diff --git a/src/backend/optimizer/geqo/geqo_eval.c b/src/backend/optimizer/geqo/geqo_eval.c index 72a10ee9dfc..cec12ae0ea5 100644 --- a/src/backend/optimizer/geqo/geqo_eval.c +++ b/src/backend/optimizer/geqo/geqo_eval.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_eval.c,v 1.6 1997/03/03 23:26:45 scrappy Exp $ + * $Id: geqo_eval.c,v 1.7 1997/04/03 19:55:35 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,9 @@ #include <math.h> #ifdef HAVE_LIMITS_H # include <limits.h> -# define MAXINT INT_MAX +# ifndef MAXINT +# define MAXINT INT_MAX +# endif #else # include <values.h> #endif diff --git a/src/backend/tcop/aclchk.c b/src/backend/tcop/aclchk.c index 20748e16c6a..7ca6bdd33b8 100644 --- a/src/backend/tcop/aclchk.c +++ b/src/backend/tcop/aclchk.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/Attic/aclchk.c,v 1.7 1997/03/12 20:48:17 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/Attic/aclchk.c,v 1.8 1997/04/03 19:55:12 scrappy Exp $ * * NOTES * See acl.h. @@ -277,7 +277,7 @@ aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode) * the system never creates an empty ACL. */ if (num < 1) { -#ifdef ACLDEBUG_TRACE || 1 +#if ACLDEBUG_TRACE || 1 elog(DEBUG, "aclcheck: zero-length ACL, returning 1"); #endif return ACLCHECK_OK; |