* Detach from all shared resources. If we are last to detach, clean up. */
| 3893 | * Detach from all shared resources. If we are last to detach, clean up. |
| 3894 | */ |
| 3895 | void |
| 3896 | ExecHashTableDetach(HashJoinTable hashtable) |
| 3897 | { |
| 3898 | if (hashtable->parallel_state) |
| 3899 | { |
| 3900 | ParallelHashJoinState *pstate = hashtable->parallel_state; |
| 3901 | int i; |
| 3902 | |
| 3903 | /* Make sure any temporary files are closed. */ |
| 3904 | if (hashtable->batches) |
| 3905 | { |
| 3906 | for (i = 0; i < hashtable->nbatch; ++i) |
| 3907 | { |
| 3908 | sts_end_write(hashtable->batches[i].inner_tuples); |
| 3909 | sts_end_write(hashtable->batches[i].outer_tuples); |
| 3910 | sts_end_parallel_scan(hashtable->batches[i].inner_tuples); |
| 3911 | sts_end_parallel_scan(hashtable->batches[i].outer_tuples); |
| 3912 | } |
| 3913 | } |
| 3914 | |
| 3915 | /* If we're last to detach, clean up shared memory. */ |
| 3916 | if (BarrierDetach(&pstate->build_barrier)) |
| 3917 | { |
| 3918 | if (DsaPointerIsValid(pstate->batches)) |
| 3919 | { |
| 3920 | dsa_free(hashtable->area, pstate->batches); |
| 3921 | pstate->batches = InvalidDsaPointer; |
| 3922 | } |
| 3923 | } |
| 3924 | |
| 3925 | hashtable->parallel_state = NULL; |
| 3926 | } |
| 3927 | } |
| 3928 | |
| 3929 | /* |
| 3930 | * Get the first tuple in a given bucket identified by number. |
no test coverage detected