* fake_outer_params * helper function to fake the nestloop's nestParams * so that prefetch inner or prefetch joinqual will * not encounter NULL pointer reference issue. It is * only invoked in ExecNestLoop and ExecPrefetchJoinQual * when the join is a nestloop join. */
| 1460 | * when the join is a nestloop join. |
| 1461 | */ |
| 1462 | void |
| 1463 | fake_outer_params(JoinState *node) |
| 1464 | { |
| 1465 | ExprContext *econtext = node->ps.ps_ExprContext; |
| 1466 | PlanState *inner = innerPlanState(node); |
| 1467 | TupleTableSlot *outerTupleSlot = econtext->ecxt_outertuple; |
| 1468 | NestLoop *nl = (NestLoop *) (node->ps.plan); |
| 1469 | ListCell *lc = NULL; |
| 1470 | |
| 1471 | /* only nestloop contains nestParams */ |
| 1472 | Assert(IsA(node->ps.plan, NestLoop)); |
| 1473 | |
| 1474 | /* econtext->ecxt_outertuple must have been set fakely. */ |
| 1475 | Assert(outerTupleSlot != NULL); |
| 1476 | /* |
| 1477 | * fetch the values of any outer Vars that must be passed to the |
| 1478 | * inner scan, and store them in the appropriate PARAM_EXEC slots. |
| 1479 | */ |
| 1480 | foreach(lc, nl->nestParams) |
| 1481 | { |
| 1482 | NestLoopParam *nlp = (NestLoopParam *) lfirst(lc); |
| 1483 | int paramno = nlp->paramno; |
| 1484 | ParamExecData *prm; |
| 1485 | |
| 1486 | prm = &(econtext->ecxt_param_exec_vals[paramno]); |
| 1487 | /* Param value should be an OUTER_VAR var */ |
| 1488 | Assert(IsA(nlp->paramval, Var)); |
| 1489 | Assert(nlp->paramval->varno == OUTER_VAR); |
| 1490 | Assert(nlp->paramval->varattno > 0); |
| 1491 | prm->value = slot_getattr(outerTupleSlot, |
| 1492 | nlp->paramval->varattno, |
| 1493 | &(prm->isnull)); |
| 1494 | /* Flag parameter value as changed */ |
| 1495 | inner->chgParam = bms_add_member(inner->chgParam, |
| 1496 | paramno); |
| 1497 | } |
| 1498 | } |
| 1499 | |
| 1500 | /* |
| 1501 | * Prefetch JoinQual or NonJoinQual to prevent motion hazard. |
no test coverage detected