Minor refactor of cdbpathlocus_for_insert.
Function `cdbpathlocus_for_insert` is only invoked by
`create_motion_path_for_insert` and `create_split_update_path`.
Besides, the invokation of `cdbpathlocus_for_insert` is
always under a condition branch with policy type partitioned.
So this commit refactors `cdbpathlocus_for_insert` to add
Assert in it.
@@ -192,6 +192,10 @@ cdb_build_distribution_keys(PlannerInfo *root, Index rti, GpPolicy *policy)
* If the target table is distributed, but the distribution keys cannot be
* represented as Equivalence Classes (because a datatype is missing merge
* opfamilies), returns a NULL locus.
+ *
+ * Currently, this function is only invoked by `create_motion_path_for_insert`
+ * and `create_split_update_path`, and under the condition that policy type
+ * is always partitioned type.
*/
CdbPathLocus
cdbpathlocus_for_insert(PlannerInfo *root, GpPolicy *policy,
@@ -199,8 +203,8 @@ cdbpathlocus_for_insert(PlannerInfo *root, GpPolicy *policy,
{
CdbPathLocus targetLocus;
- if (policy->ptype == POLICYTYPE_PARTITIONED)
- {
+ Assert(policy->ptype == POLICYTYPE_PARTITIONED);
+
/* rows are distributed by hashing on specified columns */
List *distkeys = NIL;
Index maxRef = 0;
@@ -287,17 +291,6 @@ cdbpathlocus_for_insert(PlannerInfo *root, GpPolicy *policy,
/* DISTRIBUTED RANDOMLY */
CdbPathLocus_MakeStrewn(&targetLocus, policy->numsegments);
}
- }
- else if (policy->ptype == POLICYTYPE_ENTRY)
- {
- CdbPathLocus_MakeEntry(&targetLocus);
- }
- else if (policy->ptype == POLICYTYPE_REPLICATED)
- {
- CdbPathLocus_MakeReplicated(&targetLocus, policy->numsegments);
- }
- else
- elog(ERROR, "unrecognized policy type %u", policy->ptype);
return targetLocus;
}
