* Apache Cloudberry Changes: * In the case where this is running on the dispatcher, and it's a parallel * dispatch subplan, we need to dispatch the query to the qExecs as well, like * in ExecutorRun. Except in this case we don't have to worry about insert * statements. */
| 1096 | * statements. |
| 1097 | */ |
| 1098 | void |
| 1099 | ExecSetParamPlan(SubPlanState *node, ExprContext *econtext, QueryDesc *queryDesc) |
| 1100 | { |
| 1101 | SubPlan *subplan = node->subplan; |
| 1102 | PlanState *planstate = node->planstate; |
| 1103 | SubLinkType subLinkType = subplan->subLinkType; |
| 1104 | EState *estate = planstate->state; |
| 1105 | ScanDirection dir = estate->es_direction; |
| 1106 | volatile MemoryContext oldcontext = NULL; |
| 1107 | TupleTableSlot *slot; |
| 1108 | ListCell *pvar; |
| 1109 | ListCell *l; |
| 1110 | bool found = false; |
| 1111 | ArrayBuildState *astate pg_attribute_unused() = NULL; |
| 1112 | Size savepeakspace = MemoryContextGetPeakSpace(planstate->state->es_query_cxt); |
| 1113 | |
| 1114 | bool needDtx; |
| 1115 | bool shouldDispatch = false; |
| 1116 | volatile bool explainRecvStats = false; |
| 1117 | |
| 1118 | if (Gp_role == GP_ROLE_DISPATCH && |
| 1119 | planstate != NULL && |
| 1120 | planstate->plan != NULL && |
| 1121 | queryDesc) |
| 1122 | { |
| 1123 | int subsliceIndex = queryDesc->plannedstmt->subplan_sliceIds[subplan->plan_id - 1]; |
| 1124 | ExecSlice *subslice; |
| 1125 | |
| 1126 | subslice = &estate->es_sliceTable->slices[subsliceIndex]; |
| 1127 | |
| 1128 | if (subslice->gangType != GANGTYPE_UNALLOCATED || subslice->children) |
| 1129 | shouldDispatch = true; |
| 1130 | } |
| 1131 | |
| 1132 | /* |
| 1133 | * Reset memory high-water mark so EXPLAIN ANALYZE can report each |
| 1134 | * root slice's usage separately. |
| 1135 | */ |
| 1136 | MemoryContextSetPeakSpace(planstate->state->es_query_cxt, 0); |
| 1137 | |
| 1138 | /* |
| 1139 | * Need a try/catch block here so that if an ereport is called from |
| 1140 | * within ExecutePlan, we can clean up by calling cdbdisp_checkDispatchResult. |
| 1141 | * This cleans up the asynchronous commands running through the threads launched from |
| 1142 | * CdbDispatchCommand. |
| 1143 | */ |
| 1144 | PG_TRY(); |
| 1145 | { |
| 1146 | if (shouldDispatch) |
| 1147 | { |
| 1148 | needDtx = isCurrentDtxActivated(); |
| 1149 | |
| 1150 | /* |
| 1151 | * This call returns after launching the threads that send the |
| 1152 | * command to the appropriate segdbs. It does not wait for them |
| 1153 | * to finish unless an error is detected before all are dispatched. |
| 1154 | */ |
| 1155 | CdbDispatchPlan(queryDesc, |
no test coverage detected