* Mark an initplan as needing recalculation */
| 1510 | * Mark an initplan as needing recalculation |
| 1511 | */ |
| 1512 | void |
| 1513 | ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent) |
| 1514 | { |
| 1515 | PlanState *planstate = node->planstate; |
| 1516 | SubPlan *subplan = node->subplan; |
| 1517 | EState *estate = parent->state; |
| 1518 | ListCell *l; |
| 1519 | |
| 1520 | /* sanity checks */ |
| 1521 | if (subplan->parParam != NIL) |
| 1522 | elog(ERROR, "direct correlated subquery unsupported as initplan"); |
| 1523 | if (subplan->setParam == NIL) |
| 1524 | elog(ERROR, "setParam list of initplan is empty"); |
| 1525 | if (bms_is_empty(planstate->plan->extParam)) |
| 1526 | elog(ERROR, "extParam set of initplan is empty"); |
| 1527 | |
| 1528 | /* |
| 1529 | * Don't actually re-scan: it'll happen inside ExecSetParamPlan if needed. |
| 1530 | */ |
| 1531 | |
| 1532 | /* |
| 1533 | * Mark this subplan's output parameters as needing recalculation. |
| 1534 | * |
| 1535 | * CTE subplans are never executed via parameter recalculation; instead |
| 1536 | * they get run when called by nodeCtescan.c. So don't mark the output |
| 1537 | * parameter of a CTE subplan as dirty, but do set the chgParam bit for it |
| 1538 | * so that dependent plan nodes will get told to rescan. |
| 1539 | */ |
| 1540 | foreach(l, subplan->setParam) |
| 1541 | { |
| 1542 | int paramid = lfirst_int(l); |
| 1543 | ParamExecData *prm = &(estate->es_param_exec_vals[paramid]); |
| 1544 | |
| 1545 | if (subplan->subLinkType != CTE_SUBLINK) |
| 1546 | prm->execPlan = node; |
| 1547 | |
| 1548 | parent->chgParam = bms_add_member(parent->chgParam, paramid); |
| 1549 | } |
| 1550 | } |
no test coverage detected