---------------------------------------------------------------- * ExecResult(node) * * returns the tuples from the outer plan which satisfy the * qualification clause. Since result nodes with right * subtrees are never planned, we ignore the right subtree * entirely (for now).. -cim 10/7/89 * * The qualification containing only constant clauses are * checked first before any proc
| 74 | * ---------------------------------------------------------------- |
| 75 | */ |
| 76 | static TupleTableSlot * |
| 77 | ExecResult(PlanState *pstate) |
| 78 | { |
| 79 | ResultState *node = castNode(ResultState, pstate); |
| 80 | TupleTableSlot *outerTupleSlot; |
| 81 | PlanState *outerPlan; |
| 82 | ExprContext *econtext; |
| 83 | |
| 84 | CHECK_FOR_INTERRUPTS(); |
| 85 | |
| 86 | econtext = node->ps.ps_ExprContext; |
| 87 | |
| 88 | /* |
| 89 | * check constant qualifications like (2 > 1), if not already done |
| 90 | */ |
| 91 | if (node->rs_checkqual) |
| 92 | { |
| 93 | bool qualResult = ExecQual(node->resconstantqual, econtext); |
| 94 | |
| 95 | node->rs_checkqual = false; |
| 96 | if (!qualResult) |
| 97 | { |
| 98 | node->rs_done = true; |
| 99 | return NULL; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /* |
| 104 | * Reset per-tuple memory context to free any expression evaluation |
| 105 | * storage allocated in the previous tuple cycle. |
| 106 | */ |
| 107 | ResetExprContext(econtext); |
| 108 | |
| 109 | /* |
| 110 | * if rs_done is true then it means that we were asked to return a |
| 111 | * constant tuple and we already did the last time ExecResult() was |
| 112 | * called, OR that we failed the constant qual check. Either way, now we |
| 113 | * are through. |
| 114 | */ |
| 115 | while (!node->rs_done) |
| 116 | { |
| 117 | outerPlan = outerPlanState(node); |
| 118 | |
| 119 | if (outerPlan != NULL) |
| 120 | { |
| 121 | /* |
| 122 | * retrieve tuples from the outer plan until there are no more. |
| 123 | */ |
| 124 | outerTupleSlot = ExecProcNode(outerPlan); |
| 125 | |
| 126 | if (TupIsNull(outerTupleSlot)) |
| 127 | return NULL; |
| 128 | |
| 129 | /* |
| 130 | * prepare to compute projection expressions, which will expect to |
| 131 | * access the input tuples as varno OUTER. |
| 132 | */ |
| 133 | econtext->ecxt_outertuple = outerTupleSlot; |
nothing calls this directly
no test coverage detected