---------------------------------------------------------------- * ExecProjectSet(node) * * Return tuples after evaluating the targetlist (which contains set * returning functions). * ---------------------------------------------------------------- */
| 40 | * ---------------------------------------------------------------- |
| 41 | */ |
| 42 | static TupleTableSlot * |
| 43 | ExecProjectSet(PlanState *pstate) |
| 44 | { |
| 45 | ProjectSetState *node = castNode(ProjectSetState, pstate); |
| 46 | TupleTableSlot *outerTupleSlot; |
| 47 | TupleTableSlot *resultSlot; |
| 48 | PlanState *outerPlan; |
| 49 | ExprContext *econtext; |
| 50 | |
| 51 | CHECK_FOR_INTERRUPTS(); |
| 52 | |
| 53 | econtext = node->ps.ps_ExprContext; |
| 54 | |
| 55 | /* |
| 56 | * Reset per-tuple context to free expression-evaluation storage allocated |
| 57 | * for a potentially previously returned tuple. Note that the SRF argument |
| 58 | * context has a different lifetime and is reset below. |
| 59 | */ |
| 60 | ResetExprContext(econtext); |
| 61 | |
| 62 | /* |
| 63 | * Check to see if we're still projecting out tuples from a previous scan |
| 64 | * tuple (because there is a function-returning-set in the projection |
| 65 | * expressions). If so, try to project another one. |
| 66 | */ |
| 67 | if (node->pending_srf_tuples) |
| 68 | { |
| 69 | resultSlot = ExecProjectSRF(node, true); |
| 70 | |
| 71 | if (resultSlot != NULL) |
| 72 | return resultSlot; |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | * Reset argument context to free any expression evaluation storage |
| 77 | * allocated in the previous tuple cycle. Note this can't happen until |
| 78 | * we're done projecting out tuples from a scan tuple, as ValuePerCall |
| 79 | * functions are allowed to reference the arguments for each returned |
| 80 | * tuple. |
| 81 | */ |
| 82 | MemoryContextReset(node->argcontext); |
| 83 | |
| 84 | /* |
| 85 | * Get another input tuple and project SRFs from it. |
| 86 | */ |
| 87 | for (;;) |
| 88 | { |
| 89 | /* |
| 90 | * Retrieve tuples from the outer plan until there are no more. |
| 91 | */ |
| 92 | outerPlan = outerPlanState(node); |
| 93 | outerTupleSlot = ExecProcNode(outerPlan); |
| 94 | |
| 95 | if (TupIsNull(outerTupleSlot)) |
| 96 | return NULL; |
| 97 | |
| 98 | /* |
| 99 | * Prepare to compute projection expressions, which will expect to |
nothing calls this directly
no test coverage detected