---------------------------------------------------------------- * ExecHashTableDestroy * * destroy a hash table * ---------------------------------------------------------------- */
| 1083 | * ---------------------------------------------------------------- |
| 1084 | */ |
| 1085 | void |
| 1086 | ExecHashTableDestroy(HashState *hashState, HashJoinTable hashtable) |
| 1087 | { |
| 1088 | int i; |
| 1089 | |
| 1090 | Assert(hashtable); |
| 1091 | Assert(!hashtable->eagerlyReleased); |
| 1092 | |
| 1093 | /* |
| 1094 | * Make sure all the temp files are closed. |
| 1095 | * GPDB supports rescan of hashjoin, the batch0 can still have temp files. |
| 1096 | */ |
| 1097 | if (hashtable->innerBatchFile != NULL) |
| 1098 | { |
| 1099 | for (i = 0; i < hashtable->nbatch; i++) |
| 1100 | { |
| 1101 | if (hashtable->innerBatchFile[i]) |
| 1102 | BufFileClose(hashtable->innerBatchFile[i]); |
| 1103 | if (hashtable->outerBatchFile[i]) |
| 1104 | BufFileClose(hashtable->outerBatchFile[i]); |
| 1105 | hashtable->innerBatchFile[i] = NULL; |
| 1106 | hashtable->outerBatchFile[i] = NULL; |
| 1107 | } |
| 1108 | } |
| 1109 | |
| 1110 | if (hashtable->work_set != NULL) |
| 1111 | { |
| 1112 | workfile_mgr_close_set(hashtable->work_set); |
| 1113 | hashtable->work_set = NULL; |
| 1114 | } |
| 1115 | |
| 1116 | /* Release working memory (batchCxt is a child, so it goes away too) */ |
| 1117 | MemoryContextDelete(hashtable->hashCxt); |
| 1118 | |
| 1119 | /* |
| 1120 | * If HashJoin find that the tuple it will return is NULL, it may squelch itself and its children. |
| 1121 | * But there are some statistics(e.g. nbuckets, nbatch) maintained by the hash table being required during an explain analyze. |
| 1122 | * Squelch HashJoin will call this function so that we can't simply call pfree and set hash table to NULL here, |
| 1123 | * otherwise the statistics will be lost. |
| 1124 | */ |
| 1125 | } |
| 1126 | |
| 1127 | /* |
| 1128 | * ExecHashIncreaseNumBatches |
no test coverage detected