From: Pavan Deolasee Date: Fri, 19 Feb 2016 09:50:31 +0000 (+0530) Subject: Handle case correctly when collection function is not defined. X-Git-Tag: XL9_5_R1BETA2~50 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=47e4fe6425ee44bbd3fdbf2f7327787db64928ae;p=postgres-xl.git Handle case correctly when collection function is not defined. Also, make sure some other missed out responses are handled correctly during receiving responses --- diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 02385e0720..30d6efacb2 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -604,29 +604,32 @@ initialize_aggregate(AggState *aggstate, AggStatePerAgg peraggstate, * (into the aggcontext) since we will pfree the collectValue later. * collection type is same as transition type. */ - if (peraggstate->initCollectValueIsNull) - pergroupstate->collectValue = peraggstate->initCollectValue; - else + if (OidIsValid(peraggstate->collectfn_oid)) { - MemoryContext oldContext; + if (peraggstate->initCollectValueIsNull) + pergroupstate->collectValue = peraggstate->initCollectValue; + else + { + MemoryContext oldContext; - oldContext = MemoryContextSwitchTo( - aggstate->aggcontexts[aggstate->current_set]->ecxt_per_tuple_memory); - pergroupstate->collectValue = datumCopy(peraggstate->initCollectValue, - peraggstate->transtypeByVal, - peraggstate->transtypeLen); - MemoryContextSwitchTo(oldContext); - } - pergroupstate->collectValueIsNull = peraggstate->initCollectValueIsNull; + oldContext = MemoryContextSwitchTo( + aggstate->aggcontexts[aggstate->current_set]->ecxt_per_tuple_memory); + pergroupstate->collectValue = datumCopy(peraggstate->initCollectValue, + peraggstate->transtypeByVal, + peraggstate->transtypeLen); + MemoryContextSwitchTo(oldContext); + } + pergroupstate->collectValueIsNull = peraggstate->initCollectValueIsNull; - /* - * If the initial value for the transition state doesn't exist in the - * pg_aggregate table then we will let the first non-NULL value - * returned from the outer procNode become the initial value. (This is - * useful for aggregates like max() and min().) The noTransValue flag - * signals that we still need to do this. - */ - pergroupstate->noCollectValue = peraggstate->initCollectValueIsNull; + /* + * If the initial value for the transition state doesn't exist in the + * pg_aggregate table then we will let the first non-NULL value + * returned from the outer procNode become the initial value. (This is + * useful for aggregates like max() and min().) The noTransValue flag + * signals that we still need to do this. + */ + pergroupstate->noCollectValue = peraggstate->initCollectValueIsNull; + } #endif /* PGXC */ } diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index dcc3aeafe2..626e6b6292 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -1580,10 +1580,14 @@ pgxc_node_receive_responses(const int conn_count, PGXCNodeHandle ** connections, case RESPONSE_ASSIGN_GXID: break; + case RESPONSE_TUPDESC: + case RESPONSE_DATAROW: + break; + default: /* Inconsistent responses */ add_error_message(to_receive[i], "Unexpected response from the Datanodes"); - elog(ERROR, "Unexpected response from the Datanodes, result = %d, request type %d", result, combiner->request_type); + elog(DEBUG1, "Unexpected response from the Datanodes, result = %d, request type %d", result, combiner->request_type); /* Stop tracking and move last connection in place */ count--; if (i < count)