* Get reference to the SharedFileSet used to hold all the tuplestore files. * * This is exported so that it can also be used by the INITPLAN function * tuplestores. */
| 746 | * tuplestores. |
| 747 | */ |
| 748 | SharedFileSet * |
| 749 | get_shareinput_fileset(void) |
| 750 | { |
| 751 | dsm_handle handle; |
| 752 | |
| 753 | if (shareinput_Xslice_fileset == NULL) |
| 754 | { |
| 755 | dsm_segment *seg; |
| 756 | |
| 757 | LWLockAcquire(ShareInputScanLock, LW_EXCLUSIVE); |
| 758 | |
| 759 | handle = *shareinput_Xslice_dsm_handle_ptr; |
| 760 | |
| 761 | if (handle) |
| 762 | { |
| 763 | seg = dsm_attach(handle); |
| 764 | if (seg == NULL) |
| 765 | elog(ERROR, "could not attach to ShareInputScan DSM segment"); |
| 766 | dsm_pin_mapping(seg); |
| 767 | |
| 768 | shareinput_Xslice_fileset = dsm_segment_address(seg); |
| 769 | } |
| 770 | else |
| 771 | { |
| 772 | seg = dsm_create(sizeof(SharedFileSet), 0); |
| 773 | dsm_pin_segment(seg); |
| 774 | *shareinput_Xslice_dsm_handle_ptr = dsm_segment_handle(seg); |
| 775 | dsm_pin_mapping(seg); |
| 776 | |
| 777 | shareinput_Xslice_fileset = dsm_segment_address(seg); |
| 778 | } |
| 779 | |
| 780 | if (shareinput_Xslice_fileset->refcnt == 0) |
| 781 | SharedFileSetInit(shareinput_Xslice_fileset, seg); |
| 782 | else |
| 783 | SharedFileSetAttach(shareinput_Xslice_fileset, seg); |
| 784 | |
| 785 | LWLockRelease(ShareInputScanLock); |
| 786 | } |
| 787 | |
| 788 | return shareinput_Xslice_fileset; |
| 789 | } |
| 790 | |
| 791 | /* |
| 792 | * Get a reference to slot in shared memory for this shared scan. |
no test coverage detected