------------------------------------------------------------------ * ExecShareInputScan * Retrieve a tuple from the ShareInputScan * ------------------------------------------------------------------ */
| 344 | * ------------------------------------------------------------------ |
| 345 | */ |
| 346 | static TupleTableSlot * |
| 347 | ExecShareInputScan(PlanState *pstate) |
| 348 | { |
| 349 | ShareInputScanState *node = castNode(ShareInputScanState, pstate); |
| 350 | ShareInputScan *sisc = (ShareInputScan *) pstate->plan; |
| 351 | EState *estate; |
| 352 | ScanDirection dir; |
| 353 | bool forward; |
| 354 | TupleTableSlot *slot; |
| 355 | |
| 356 | /* |
| 357 | * get state info from node |
| 358 | */ |
| 359 | estate = pstate->state; |
| 360 | dir = estate->es_direction; |
| 361 | forward = ScanDirectionIsForward(dir); |
| 362 | |
| 363 | if (sisc->this_slice_id != currentSliceId && estate->es_plannedstmt->numSlices != 1) |
| 364 | elog(ERROR, "cannot execute alien Share Input Scan"); |
| 365 | |
| 366 | /* if first time call, need to initialize the tuplestore state. */ |
| 367 | if (!node->isready) |
| 368 | init_tuplestore_state(node); |
| 369 | |
| 370 | /* |
| 371 | * Return NULL when necessary. |
| 372 | * This could help improve performance, especially when tuplestore is huge, because ShareInputScan |
| 373 | * do not need to read tuple from tuplestore when discard_output is true, which means current |
| 374 | * ShareInputScan is one but not the last one of Sequence's subplans. |
| 375 | */ |
| 376 | if (sisc->discard_output) |
| 377 | return NULL; |
| 378 | |
| 379 | slot = node->ss.ps.ps_ResultTupleSlot; |
| 380 | |
| 381 | Assert(!node->local_state->closed); |
| 382 | |
| 383 | tuplestore_select_read_pointer(node->ts_state, node->ts_pos); |
| 384 | while(1) |
| 385 | { |
| 386 | bool gotOK; |
| 387 | |
| 388 | gotOK = tuplestore_gettupleslot(node->ts_state, forward, false, slot); |
| 389 | |
| 390 | if (!gotOK) |
| 391 | return NULL; |
| 392 | |
| 393 | SIMPLE_FAULT_INJECTOR("execshare_input_next"); |
| 394 | |
| 395 | return slot; |
| 396 | } |
| 397 | |
| 398 | Assert(!"should not be here"); |
| 399 | return NULL; |
| 400 | } |
| 401 | |
| 402 | /* ------------------------------------------------------------------ |
| 403 | * ExecInitShareInputScan |
nothing calls this directly
no test coverage detected