aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeAgg.c
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1997-04-03 19:56:47 +0000
committerMarc G. Fournier <scrappy@hub.org>1997-04-03 19:56:47 +0000
commit9d5c0af5862cc0141ea16ca90a9e01250716af37 (patch)
treea5097449997b576fc951c5f5ca33a29df8f039fa /src/backend/executor/nodeAgg.c
parent164cd7ab342da27686f0114775a1050ad89b7437 (diff)
downloadpostgresql-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/executor/nodeAgg.c')
-rw-r--r--src/backend/executor/nodeAgg.c7
1 files changed, 6 insertions, 1 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];