diff options
| author | Tom Lane | 2002-10-19 22:10:58 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-10-19 22:10:58 +0000 |
| commit | 4a67565b37ef4fae12c341d069b1145cfae10144 (patch) | |
| tree | 63755e34ce59feddff4a9fbeafb0c3d716b9c58f /src/pl/plpgsql | |
| parent | 30c2b5ec7212c7b6881a7a25ca604ffe5229059d (diff) | |
Fix within-function memory leaks in the various PLs' interfaces to
SPI_prepare: they all save the prepared plan into topCxt, and so the
procCxt copy that's actually returned by SPI_prepare ought to be freed.
Diagnosis and plpython fix by Nigel Andrews, followup for other PLs
by Tom Lane.
Diffstat (limited to 'src/pl/plpgsql')
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index acddb23161e..9adf2d7a2e9 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.64 2002/09/05 00:43:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.65 2002/10/19 22:10:58 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -2018,6 +2018,7 @@ exec_prepare_plan(PLpgSQL_execstate * estate, expr->plan_simple_expr = NULL; exec_simple_check_plan(expr); + SPI_freeplan(plan); pfree(argtypes); } @@ -2544,10 +2545,14 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) * ---------- */ curplan = SPI_prepare(querystr, 0, NULL); + if (curplan == NULL) + elog(ERROR, "SPI_prepare() failed for dynamic query \"%s\"", + querystr); portal = SPI_cursor_open(curname, curplan, NULL, NULL); if (portal == NULL) elog(ERROR, "Failed to open cursor"); pfree(querystr); + SPI_freeplan(curplan); /* ---------- * Store the eventually assigned cursor name in the cursor variable |
