From: Joe Conway <mail@joeconway.com>
Date: Thu, 10 May 2012 05:51:17 +0000 (-0700)
Subject: PL/pgSQL RETURN NEXT was leaking converted tuples, causing
X-Git-Tag: REL9_0_8~20
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a96a0a8cf8cea3c5737fec9d37a75f012302f60;p=postgresql

PL/pgSQL RETURN NEXT was leaking converted tuples, causing
out of memory when looping through large numbers of rows.
Flag the converted tuples to be freed. Complaint and patch
by Joe.
---

diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 2f8468336f..0e77284d48 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -2243,6 +2243,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate,
 					{
 						tuple = do_convert_tuple(tuple, tupmap);
 						free_conversion_map(tupmap);
+						free_tuple = true;
 					}
 				}
 				break;