------------------------------------------------------------------ * ExecEndShareInputScan * ------------------------------------------------------------------ */
| 544 | * ------------------------------------------------------------------ |
| 545 | */ |
| 546 | void |
| 547 | ExecEndShareInputScan(ShareInputScanState *node) |
| 548 | { |
| 549 | EState *estate = node->ss.ps.state; |
| 550 | ShareInputScan *sisc = (ShareInputScan *) node->ss.ps.plan; |
| 551 | shareinput_local_state *local_state = node->local_state; |
| 552 | |
| 553 | /* clean up tuple table */ |
| 554 | ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); |
| 555 | |
| 556 | if (node->ref) |
| 557 | { |
| 558 | if (sisc->this_slice_id == currentSliceId || estate->es_plannedstmt->numSlices == 1) |
| 559 | { |
| 560 | /* |
| 561 | * The producer needs to wait for all the consumers to finish. |
| 562 | * Consumers signal the producer that they're done reading, |
| 563 | * but are free to exit immediately after that. |
| 564 | */ |
| 565 | if (currentSliceId == sisc->producer_slice_id) |
| 566 | { |
| 567 | if (!local_state->ready) |
| 568 | init_tuplestore_state(node); |
| 569 | shareinput_writer_waitdone(node->ref, sisc->nconsumers); |
| 570 | } |
| 571 | else |
| 572 | { |
| 573 | if (!local_state->closed) |
| 574 | { |
| 575 | shareinput_reader_notifydone(node->ref, sisc->nconsumers); |
| 576 | local_state->closed = true; |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | release_shareinput_reference(node->ref, false); |
| 581 | node->ref = NULL; |
| 582 | } |
| 583 | |
| 584 | if (local_state && local_state->ts_state) |
| 585 | { |
| 586 | tuplestore_end(local_state->ts_state); |
| 587 | local_state->ts_state = NULL; |
| 588 | } |
| 589 | |
| 590 | /* |
| 591 | * shutdown subplan. First scanner of underlying share input will |
| 592 | * do the shutdown, all other scanners are no-op because outerPlanState |
| 593 | * is NULL |
| 594 | */ |
| 595 | ExecEndNode(outerPlanState(node)); |
| 596 | } |
| 597 | |
| 598 | /* ------------------------------------------------------------------ |
| 599 | * ExecReScanShareInputScan |
no test coverage detected