You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by hu...@apache.org on 2015/10/19 04:12:31 UTC

incubator-hawq git commit: HAWQ-62. Incorrect calculation of locus describing of hash table introduce core dump in OLAP query

Repository: incubator-hawq
Updated Branches:
  refs/heads/master 35e6832a2 -> c3003ec5e


HAWQ-62. Incorrect calculation of locus describing of hash table introduce core dump in OLAP query


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/c3003ec5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/c3003ec5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/c3003ec5

Branch: refs/heads/master
Commit: c3003ec5e1c017528c0b787b5190da83d93c6023
Parents: 35e6832
Author: hzhang2 <zh...@163.com>
Authored: Thu Oct 15 17:48:40 2015 +0800
Committer: hzhang2 <zh...@163.com>
Committed: Mon Oct 19 10:12:02 2015 +0800

----------------------------------------------------------------------
 src/backend/cdb/cdbpathlocus.c | 75 ++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c3003ec5/src/backend/cdb/cdbpathlocus.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbpathlocus.c b/src/backend/cdb/cdbpathlocus.c
index 2471fd4..a84debf 100644
--- a/src/backend/cdb/cdbpathlocus.c
+++ b/src/backend/cdb/cdbpathlocus.c
@@ -272,45 +272,44 @@ cdbpathlocus_from_baserel(struct PlannerInfo   *root,
     GpPolicy   *policy = rel->cdbpolicy;
     bool allocatedResource = root->glob->allocatedResource;
 	
-	if ( Gp_role != GP_ROLE_DISPATCH )
-	{
-		CdbPathLocus_MakeEntry(&result);
-		return result;
-	}
-
-    if (policy &&
-        policy->ptype == POLICYTYPE_PARTITIONED)
+    if ( Gp_role != GP_ROLE_DISPATCH )
     {
-        /* Are the rows distributed by hashing on specified columns? */
-    			bool isRelationRuntimeHash =true;
-    			if(root->glob->resource !=NULL && root->glob->relsType !=NIL){
-    				List* relsType = root->glob->relsType;
-    				Oid baseRelOid = 0;
-    				ListCell *lc;
-    				int pindex=1;
-    				foreach(lc, root->parse->rtable)
-    				{
-    					if(rel->relid == pindex){
-    						RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
-    						baseRelOid = rte->relid;
-    					}
-    				}
-    				foreach(lc, relsType)
-    				{
-    					CurrentRelType *relType = (CurrentRelType *) lfirst(lc);
-    					if(relType->relid == baseRelOid){
-    						isRelationRuntimeHash =relType->isHash;
-    					}
-    				}
-    			}
-        if (isRelationRuntimeHash && (policy->nattrs > 0) && allocatedResource &&
-            (list_length(root->glob->resource->segments) == (policy->bucketnum)))
-        {
-	        List *partkey = cdb_build_distribution_pathkeys(root,
-	                                                        rel,
-	                                                        policy->nattrs,
-	                                                        policy->attrs);
-	        CdbPathLocus_MakeHashed(&result, partkey);
+    	    CdbPathLocus_MakeEntry(&result);
+    		  return result;
+    }
+
+    if (policy && policy->ptype == POLICYTYPE_PARTITIONED)
+    {
+		    /* Are the rows distributed by hashing on specified columns? */
+		    bool isRelationRuntimeHash = true;
+		    if (root->glob->resource != NULL && root->glob->relsType != NIL) {
+			      List* relsType = root->glob->relsType;
+			      Oid baseRelOid = 0;
+			      ListCell *lc;
+			      int pindex = 1;
+			      foreach(lc, root->parse->rtable)
+			      {
+				        if (rel->relid == pindex) {
+					          RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
+					          baseRelOid = rte->relid;
+					          break;
+				        }
+				        pindex++;
+			      }
+			      foreach(lc, relsType)
+			      {
+				        CurrentRelType *relType = (CurrentRelType *) lfirst(lc);
+				        if (relType->relid == baseRelOid) {
+					          isRelationRuntimeHash = relType->isHash;
+				        }
+			      }
+		    }
+    	    /* we determine the runtime table distribution type here*/
+    	    if (isRelationRuntimeHash && (policy->nattrs > 0) &&
+    	    	((allocatedResource && list_length(root->glob->resource->segments) == policy->bucketnum) || !allocatedResource))
+    	    {
+	          List *partkey = cdb_build_distribution_pathkeys(root,rel, policy->nattrs, policy->attrs);
+	          CdbPathLocus_MakeHashed(&result, partkey);
         }
         /* Rows are distributed on an unknown criterion (uniformly, we hope!) */
         else