---------------------------------------------------------------- * Scan Support * ---------------------------------------------------------------- */ ---------------------------------------------------------------- * FunctionNext * * This is a workhorse for ExecFunctionScan * ---------------------------------------------------------------- */
| 68 | * ---------------------------------------------------------------- |
| 69 | */ |
| 70 | static TupleTableSlot * |
| 71 | FunctionNext_guts(FunctionScanState *node) |
| 72 | { |
| 73 | EState *estate; |
| 74 | ScanDirection direction; |
| 75 | TupleTableSlot *scanslot; |
| 76 | bool alldone; |
| 77 | int64 oldpos; |
| 78 | int funcno; |
| 79 | int att; |
| 80 | |
| 81 | /* |
| 82 | * get information from the estate and scan state |
| 83 | */ |
| 84 | estate = node->ss.ps.state; |
| 85 | direction = estate->es_direction; |
| 86 | scanslot = node->ss.ss_ScanTupleSlot; |
| 87 | |
| 88 | /* |
| 89 | * FunctionNext read tuple from tuplestore instead |
| 90 | * of executing the real function. |
| 91 | * Tuplestore is filled by the FunctionScan's initplan. |
| 92 | */ |
| 93 | if(node->resultInTupleStore) |
| 94 | { |
| 95 | bool gotOK = false; |
| 96 | bool forward = true; |
| 97 | |
| 98 | /* |
| 99 | * Setup tuplestore reader on first call. |
| 100 | * |
| 101 | * The tuplestore should have been created by preprocess_initplans() |
| 102 | * already, we just read it here. |
| 103 | */ |
| 104 | if (!node->ts_state) |
| 105 | { |
| 106 | char rwfile_prefix[100]; |
| 107 | function_scan_create_bufname_prefix(rwfile_prefix, sizeof(rwfile_prefix), node->initplanId); |
| 108 | |
| 109 | node->ts_state = tuplestore_open_shared(get_shareinput_fileset(), |
| 110 | rwfile_prefix); |
| 111 | } |
| 112 | |
| 113 | gotOK = tuplestore_gettupleslot(node->ts_state, forward, false, |
| 114 | scanslot); |
| 115 | |
| 116 | if(!gotOK) |
| 117 | { |
| 118 | return NULL; |
| 119 | } |
| 120 | return scanslot; |
| 121 | } |
| 122 | |
| 123 | if (node->simple) |
| 124 | { |
| 125 | /* |
| 126 | * Fast path for the trivial case: the function return type and scan |
| 127 | * result type are the same, so we fetch the function result straight |
no test coverage detected