diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index aa17e21aaf4..74335f76f5c 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -3413,11 +3413,11 @@ numeric_combine(PG_FUNCTION_ARGS) PG_RETURN_POINTER(state1); } + state1->N += state2->N; + state1->NaNcount += state2->NaNcount; + if (state2->N > 0) { - state1->N += state2->N; - state1->NaNcount += state2->NaNcount; - /* * These are currently only needed for moving aggregates, but let's do * the right thing anyway... @@ -3501,11 +3501,11 @@ numeric_avg_combine(PG_FUNCTION_ARGS) PG_RETURN_POINTER(state1); } + state1->N += state2->N; + state1->NaNcount += state2->NaNcount; + if (state2->N > 0) { - state1->N += state2->N; - state1->NaNcount += state2->NaNcount; - /* * These are currently only needed for moving aggregates, but let's do * the right thing anyway...