Call DestReceiver rDestroy before it goes out of scope

CitusCopyDestReceiverDestroy: call hash_destroy on shardStateHash & connectionStateHash
pull/3168/head
Philip Dubé 2019-11-07 22:34:53 +00:00 committed by Philip Dubé
parent adc6ca6100
commit 48552bfffe
2 changed files with 15 additions and 0 deletions

View File

@ -1343,6 +1343,7 @@ CopyLocalDataIntoShards(Oid distributedRelationId)
/* finish writing into the shards */
copyDest->rShutdown(copyDest);
copyDest->rDestroy(copyDest);
/* free memory and close the relation */
ExecDropSingleTupleTableSlot(slot);

View File

@ -598,6 +598,7 @@ CopyToExistingShards(CopyStmt *copyStatement, char *completionTag)
/* finish the COPY commands */
dest->rShutdown(dest);
dest->rDestroy(dest);
ExecDropSingleTupleTableSlot(tupleTableSlot);
FreeExecutorState(executorState);
@ -2692,6 +2693,9 @@ ShutdownCopyConnectionState(CopyConnectionState *connectionState,
}
/*
* CitusCopyDestReceiverDestroy frees the DestReceiver
*/
static void
CitusCopyDestReceiverDestroy(DestReceiver *destReceiver)
{
@ -2712,6 +2716,16 @@ CitusCopyDestReceiverDestroy(DestReceiver *destReceiver)
pfree(copyDest->columnCoercionPaths);
}
if (copyDest->shardStateHash)
{
hash_destroy(copyDest->shardStateHash);
}
if (copyDest->connectionStateHash)
{
hash_destroy(copyDest->connectionStateHash);
}
pfree(copyDest);
}