From cbe16169b4329631355be27b13523e11b5e46aad Mon Sep 17 00:00:00 2001 From: Marco Slot Date: Tue, 12 Sep 2017 09:51:42 -0700 Subject: [PATCH] Free per-tuple COPY memory in INSERT...SELECT --- src/backend/distributed/commands/multi_copy.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/distributed/commands/multi_copy.c b/src/backend/distributed/commands/multi_copy.c index e1dd6dc13..7266f6a72 100644 --- a/src/backend/distributed/commands/multi_copy.c +++ b/src/backend/distributed/commands/multi_copy.c @@ -2010,6 +2010,14 @@ CitusCopyDestReceiverReceive(TupleTableSlot *slot, DestReceiver *dest) copyDest->tuplesSent++; + /* + * Release per tuple memory allocated in this function. If we're writing + * the results of an INSERT ... SELECT then the SELECT execution will use + * its own executor state and reset the per tuple expression context + * separately. + */ + ResetPerTupleExprContext(executorState); + return true; }