---------------------------------------------------------------- * IndexOnlyNext * * Retrieve a tuple from the IndexOnlyScan node's index. * ---------------------------------------------------------------- */
| 58 | * ---------------------------------------------------------------- |
| 59 | */ |
| 60 | static TupleTableSlot * |
| 61 | IndexOnlyNext(IndexOnlyScanState *node) |
| 62 | { |
| 63 | EState *estate; |
| 64 | ExprContext *econtext; |
| 65 | ScanDirection direction; |
| 66 | IndexScanDesc scandesc; |
| 67 | TupleTableSlot *slot; |
| 68 | ItemPointer tid; |
| 69 | |
| 70 | /* |
| 71 | * extract necessary information from index scan node |
| 72 | */ |
| 73 | estate = node->ss.ps.state; |
| 74 | direction = estate->es_direction; |
| 75 | /* flip direction if this is an overall backward scan */ |
| 76 | if (ScanDirectionIsBackward(((IndexOnlyScan *) node->ss.ps.plan)->indexorderdir)) |
| 77 | { |
| 78 | if (ScanDirectionIsForward(direction)) |
| 79 | direction = BackwardScanDirection; |
| 80 | else if (ScanDirectionIsBackward(direction)) |
| 81 | direction = ForwardScanDirection; |
| 82 | } |
| 83 | scandesc = node->ioss_ScanDesc; |
| 84 | econtext = node->ss.ps.ps_ExprContext; |
| 85 | slot = node->ss.ss_ScanTupleSlot; |
| 86 | |
| 87 | if (scandesc == NULL) |
| 88 | { |
| 89 | /* |
| 90 | * We reach here if the index only scan is not parallel, or if we're |
| 91 | * serially executing an index only scan that was planned to be |
| 92 | * parallel. |
| 93 | */ |
| 94 | scandesc = index_beginscan(node->ss.ss_currentRelation, |
| 95 | node->ioss_RelationDesc, |
| 96 | estate->es_snapshot, |
| 97 | node->ioss_NumScanKeys, |
| 98 | node->ioss_NumOrderByKeys); |
| 99 | |
| 100 | node->ioss_ScanDesc = scandesc; |
| 101 | |
| 102 | |
| 103 | /* Set it up for index-only scan */ |
| 104 | node->ioss_ScanDesc->xs_want_itup = true; |
| 105 | node->ioss_VMBuffer = InvalidBuffer; |
| 106 | |
| 107 | /* |
| 108 | * If no run-time keys to calculate or they are ready, go ahead and |
| 109 | * pass the scankeys to the index AM. |
| 110 | */ |
| 111 | if (node->ioss_NumRuntimeKeys == 0 || node->ioss_RuntimeKeysReady) |
| 112 | index_rescan(scandesc, |
| 113 | node->ioss_ScanKeys, |
| 114 | node->ioss_NumScanKeys, |
| 115 | node->ioss_OrderByKeys, |
| 116 | node->ioss_NumOrderByKeys); |
| 117 | } |
nothing calls this directly
no test coverage detected