Handle case correctly when collection function is not defined.
authorPavan Deolasee <[email protected]>
Fri, 19 Feb 2016 09:50:31 +0000 (15:20 +0530)
committerPavan Deolasee <[email protected]>
Fri, 19 Feb 2016 09:50:31 +0000 (15:20 +0530)
Also, make sure some other missed out responses are handled correctly during
receiving responses

src/backend/executor/nodeAgg.c
src/backend/pgxc/pool/execRemote.c

index 02385e0720b06e796e6616eaf16279d5edf12df9..30d6efacb271517d8ce17eb5d17b8636b9382ce7 100644 (file)
@@ -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 */
 }
 
index dcc3aeafe2b2146f9a766630c4b5926538b6aaa7..626e6b6292121b9bd367849b6f39612ecb06b295 100644 (file)
@@ -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)