From d5c1c3ba6e32451b11d2d5cf9465dc818e102180 Mon Sep 17 00:00:00 2001 From: aykut-bozkurt <51649454+aykut-bozkurt@users.noreply.github.com> Date: Fri, 17 Feb 2023 14:15:09 +0300 Subject: [PATCH] fix single tuple result memory leak (#6724) We should not omit to free PGResult when we receive single tuple result from an internal backend. Single tuple results are normally freed by our ReceiveResults for `tupleDescriptor != NULL` flow but not for those with `tupleDescriptor == NULL`. See PR #6722 for details. DESCRIPTION: Fixes memory leak issue with query results that returns single row. --- src/backend/distributed/executor/adaptive_executor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/distributed/executor/adaptive_executor.c b/src/backend/distributed/executor/adaptive_executor.c index 8369878b720..b9b1163e493 100644 --- a/src/backend/distributed/executor/adaptive_executor.c +++ b/src/backend/distributed/executor/adaptive_executor.c @@ -4777,6 +4777,7 @@ ReceiveResults(WorkerSession *session, bool storeRows) TupleDesc tupleDescriptor = tupleDest->tupleDescForQuery(tupleDest, queryIndex); if (tupleDescriptor == NULL) { + PQclear(result); continue; }