-------------------------------- * ExecResetTupleTable * * This releases any resources (buffer pins, tupdesc refcounts) * held by the tuple table, and optionally releases the memory * occupied by the tuple table data structure. * It is expected that this routine be called by ExecEndPlan(). * -------------------------------- */
| 1205 | * -------------------------------- |
| 1206 | */ |
| 1207 | void |
| 1208 | ExecResetTupleTable(List *tupleTable, /* tuple table */ |
| 1209 | bool shouldFree) /* true if we should free memory */ |
| 1210 | { |
| 1211 | ListCell *lc; |
| 1212 | |
| 1213 | foreach(lc, tupleTable) |
| 1214 | { |
| 1215 | TupleTableSlot *slot = lfirst_node(TupleTableSlot, lc); |
| 1216 | |
| 1217 | /* Always release resources and reset the slot to empty */ |
| 1218 | ExecClearTuple(slot); |
| 1219 | slot->tts_ops->release(slot); |
| 1220 | if (slot->tts_tupleDescriptor) |
| 1221 | { |
| 1222 | ReleaseTupleDesc(slot->tts_tupleDescriptor); |
| 1223 | slot->tts_tupleDescriptor = NULL; |
| 1224 | } |
| 1225 | |
| 1226 | /* If shouldFree, release memory occupied by the slot itself */ |
| 1227 | if (shouldFree) |
| 1228 | { |
| 1229 | if (!TTS_FIXED(slot)) |
| 1230 | { |
| 1231 | if (slot->tts_values) |
| 1232 | pfree(slot->tts_values); |
| 1233 | if (slot->tts_isnull) |
| 1234 | pfree(slot->tts_isnull); |
| 1235 | } |
| 1236 | pfree(slot); |
| 1237 | } |
| 1238 | } |
| 1239 | |
| 1240 | /* If shouldFree, release the list structure */ |
| 1241 | if (shouldFree) |
| 1242 | list_free(tupleTable); |
| 1243 | } |
| 1244 | |
| 1245 | /* -------------------------------- |
| 1246 | * MakeSingleTupleTableSlot |
no test coverage detected