*** pgsql/src/backend/utils/adt/numeric.c 2010/01/07 04:53:34 1.121 --- pgsql/src/backend/utils/adt/numeric.c 2010/02/08 20:39:51 1.122 *************** *** 14,20 **** * Copyright (c) 1998-2010, PostgreSQL Global Development Group * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.120 2010/01/02 16:57:54 momjian Exp $ * *------------------------------------------------------------------------- */ --- 14,20 ---- * Copyright (c) 1998-2010, PostgreSQL Global Development Group * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.121 2010/01/07 04:53:34 tgl Exp $ * *------------------------------------------------------------------------- */ *************** int2_sum(PG_FUNCTION_ARGS) *** 2679,2694 **** } /* ! * If we're invoked by nodeAgg, we can cheat and modify our first * parameter in-place to avoid palloc overhead. If not, we need to return * the new value of the transition variable. (If int8 is pass-by-value, * then of course this is useless as well as incorrect, so just ifdef it * out.) */ #ifndef USE_FLOAT8_BYVAL /* controls int8 too */ ! if (fcinfo->context && ! (IsA(fcinfo->context, AggState) || ! IsA(fcinfo->context, WindowAggState))) { int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); --- 2679,2692 ---- } /* ! * If we're invoked as an aggregate, we can cheat and modify our first * parameter in-place to avoid palloc overhead. If not, we need to return * the new value of the transition variable. (If int8 is pass-by-value, * then of course this is useless as well as incorrect, so just ifdef it * out.) */ #ifndef USE_FLOAT8_BYVAL /* controls int8 too */ ! if (AggCheckCallContext(fcinfo, NULL)) { int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); *************** int4_sum(PG_FUNCTION_ARGS) *** 2730,2745 **** } /* ! * If we're invoked by nodeAgg, we can cheat and modify our first * parameter in-place to avoid palloc overhead. If not, we need to return * the new value of the transition variable. (If int8 is pass-by-value, * then of course this is useless as well as incorrect, so just ifdef it * out.) */ #ifndef USE_FLOAT8_BYVAL /* controls int8 too */ ! if (fcinfo->context && ! (IsA(fcinfo->context, AggState) || ! IsA(fcinfo->context, WindowAggState))) { int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); --- 2728,2741 ---- } /* ! * If we're invoked as an aggregate, we can cheat and modify our first * parameter in-place to avoid palloc overhead. If not, we need to return * the new value of the transition variable. (If int8 is pass-by-value, * then of course this is useless as well as incorrect, so just ifdef it * out.) */ #ifndef USE_FLOAT8_BYVAL /* controls int8 too */ ! if (AggCheckCallContext(fcinfo, NULL)) { int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); *************** int8_sum(PG_FUNCTION_ARGS) *** 2782,2788 **** } /* ! * Note that we cannot special-case the nodeAgg case here, as we do for * int2_sum and int4_sum: numeric is of variable size, so we cannot modify * our first parameter in-place. */ --- 2778,2784 ---- } /* ! * Note that we cannot special-case the aggregate case here, as we do for * int2_sum and int4_sum: numeric is of variable size, so we cannot modify * our first parameter in-place. */ *************** int2_avg_accum(PG_FUNCTION_ARGS) *** 2820,2832 **** Int8TransTypeData *transdata; /* ! * If we're invoked by nodeAgg, we can cheat and modify our first * parameter in-place to reduce palloc overhead. Otherwise we need to make * a copy of it before scribbling on it. */ ! if (fcinfo->context && ! (IsA(fcinfo->context, AggState) || ! IsA(fcinfo->context, WindowAggState))) transarray = PG_GETARG_ARRAYTYPE_P(0); else transarray = PG_GETARG_ARRAYTYPE_P_COPY(0); --- 2816,2826 ---- Int8TransTypeData *transdata; /* ! * If we're invoked as an aggregate, we can cheat and modify our first * parameter in-place to reduce palloc overhead. Otherwise we need to make * a copy of it before scribbling on it. */ ! if (AggCheckCallContext(fcinfo, NULL)) transarray = PG_GETARG_ARRAYTYPE_P(0); else transarray = PG_GETARG_ARRAYTYPE_P_COPY(0); *************** int4_avg_accum(PG_FUNCTION_ARGS) *** 2850,2862 **** Int8TransTypeData *transdata; /* ! * If we're invoked by nodeAgg, we can cheat and modify our first * parameter in-place to reduce palloc overhead. Otherwise we need to make * a copy of it before scribbling on it. */ ! if (fcinfo->context && ! (IsA(fcinfo->context, AggState) || ! IsA(fcinfo->context, WindowAggState))) transarray = PG_GETARG_ARRAYTYPE_P(0); else transarray = PG_GETARG_ARRAYTYPE_P_COPY(0); --- 2844,2854 ---- Int8TransTypeData *transdata; /* ! * If we're invoked as an aggregate, we can cheat and modify our first * parameter in-place to reduce palloc overhead. Otherwise we need to make * a copy of it before scribbling on it. */ ! if (AggCheckCallContext(fcinfo, NULL)) transarray = PG_GETARG_ARRAYTYPE_P(0); else transarray = PG_GETARG_ARRAYTYPE_P_COPY(0);