---------------------------------------------------------------- * ValuesNext * * This is a workhorse for ExecValuesScan * ---------------------------------------------------------------- */
| 47 | * ---------------------------------------------------------------- |
| 48 | */ |
| 49 | static TupleTableSlot * |
| 50 | ValuesNext(ValuesScanState *node) |
| 51 | { |
| 52 | TupleTableSlot *slot; |
| 53 | EState *estate; |
| 54 | ExprContext *econtext; |
| 55 | ScanDirection direction; |
| 56 | int curr_idx; |
| 57 | |
| 58 | /* |
| 59 | * get information from the estate and scan state |
| 60 | */ |
| 61 | estate = node->ss.ps.state; |
| 62 | direction = estate->es_direction; |
| 63 | slot = node->ss.ss_ScanTupleSlot; |
| 64 | econtext = node->rowcontext; |
| 65 | |
| 66 | /* |
| 67 | * Get the next tuple. Return NULL if no more tuples. |
| 68 | */ |
| 69 | if (ScanDirectionIsForward(direction)) |
| 70 | { |
| 71 | if (node->curr_idx < node->array_len) |
| 72 | node->curr_idx++; |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | if (node->curr_idx >= 0) |
| 77 | node->curr_idx--; |
| 78 | } |
| 79 | |
| 80 | /* |
| 81 | * Always clear the result slot; this is appropriate if we are at the end |
| 82 | * of the data, and if we're not, we still need it as the first step of |
| 83 | * the store-virtual-tuple protocol. It seems wise to clear the slot |
| 84 | * before we reset the context it might have pointers into. |
| 85 | */ |
| 86 | ExecClearTuple(slot); |
| 87 | |
| 88 | curr_idx = node->curr_idx; |
| 89 | if (curr_idx >= 0 && curr_idx < node->array_len) |
| 90 | { |
| 91 | List *exprlist = node->exprlists[curr_idx]; |
| 92 | List *exprstatelist = node->exprstatelists[curr_idx]; |
| 93 | MemoryContext oldContext; |
| 94 | Datum *values; |
| 95 | bool *isnull; |
| 96 | ListCell *lc; |
| 97 | int resind; |
| 98 | |
| 99 | /* |
| 100 | * Get rid of any prior cycle's leftovers. We use ReScanExprContext |
| 101 | * not just ResetExprContext because we want any registered shutdown |
| 102 | * callbacks to be called. |
| 103 | */ |
| 104 | ReScanExprContext(econtext); |
| 105 | |
| 106 | /* |
nothing calls this directly
no test coverage detected