* Add Motions to the subpath of a ModifyTable path, so that data * is modified on the correct segments. * * The input to a ModifyTable node must be distributed according to the * DISTRIBUTED BY of the target table. Add Motion paths to the child * plans for that. Returns a locus to represent the distribution of the * ModifyTable node itself. */
| 5943 | * ModifyTable node itself. |
| 5944 | */ |
| 5945 | static CdbPathLocus |
| 5946 | adjust_modifytable_subpath(PlannerInfo *root, CmdType operation, |
| 5947 | int resultRelationRTI, Path **pSubpath, |
| 5948 | bool splitUpdate) |
| 5949 | { |
| 5950 | /* |
| 5951 | * The input plans must be distributed correctly. |
| 5952 | */ |
| 5953 | bool all_subplans_entry = true, |
| 5954 | all_subplans_replicated = true; |
| 5955 | int numsegments = -1; |
| 5956 | |
| 5957 | |
| 5958 | { |
| 5959 | int rti = resultRelationRTI; |
| 5960 | Path *subpath = *pSubpath; |
| 5961 | RangeTblEntry *rte = rt_fetch(rti, root->parse->rtable); |
| 5962 | GpPolicy *targetPolicy; |
| 5963 | GpPolicyType targetPolicyType; |
| 5964 | |
| 5965 | Assert(rte->rtekind == RTE_RELATION); |
| 5966 | |
| 5967 | targetPolicy = GpPolicyFetch(rte->relid); |
| 5968 | targetPolicyType = targetPolicy->ptype; |
| 5969 | |
| 5970 | numsegments = Max(targetPolicy->numsegments, numsegments); |
| 5971 | |
| 5972 | if (targetPolicyType == POLICYTYPE_PARTITIONED) |
| 5973 | { |
| 5974 | all_subplans_entry = false; |
| 5975 | all_subplans_replicated = false; |
| 5976 | } |
| 5977 | else if (targetPolicyType == POLICYTYPE_ENTRY) |
| 5978 | { |
| 5979 | /* Master-only table */ |
| 5980 | all_subplans_replicated = false; |
| 5981 | } |
| 5982 | else if (targetPolicyType == POLICYTYPE_REPLICATED) |
| 5983 | { |
| 5984 | all_subplans_entry = false; |
| 5985 | } |
| 5986 | else |
| 5987 | elog(ERROR, "unrecognized policy type %u", targetPolicyType); |
| 5988 | |
| 5989 | if (operation == CMD_INSERT) |
| 5990 | { |
| 5991 | subpath = create_motion_path_for_insert(root, targetPolicy, subpath); |
| 5992 | } |
| 5993 | else if (operation == CMD_DELETE) |
| 5994 | { |
| 5995 | subpath = create_motion_path_for_upddel(root, rti, targetPolicy, subpath); |
| 5996 | } |
| 5997 | else if (operation == CMD_UPDATE) |
| 5998 | { |
| 5999 | if (splitUpdate) |
| 6000 | subpath = create_split_update_path(root, rti, targetPolicy, subpath); |
| 6001 | else |
| 6002 | subpath = create_motion_path_for_upddel(root, rti, targetPolicy, subpath); |
no test coverage detected