aboutsummaryrefslogtreecommitdiff
path: root/src/pl/tcl/pltcl.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-10-19 22:10:58 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-10-19 22:10:58 +0000
commit4a67565b37ef4fae12c341d069b1145cfae10144 (patch)
tree63755e34ce59feddff4a9fbeafb0c3d716b9c58f /src/pl/tcl/pltcl.c
parent30c2b5ec7212c7b6881a7a25ca604ffe5229059d (diff)
downloadpostgresql-4a67565b37ef4fae12c341d069b1145cfae10144.tar.gz
postgresql-4a67565b37ef4fae12c341d069b1145cfae10144.zip
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/tcl/pltcl.c')
-rw-r--r--src/pl/tcl/pltcl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index f2bf14ab92b..0210dfd8174 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.65 2002/10/14 04:20:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.66 2002/10/19 22:10:58 tgl Exp $
*
**********************************************************************/
@@ -1285,7 +1285,7 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
else if (strcmp(argv[1], "NOTICE") == 0)
level = NOTICE;
else if (strcmp(argv[1], "WARNING") == 0)
- level = ERROR;
+ level = WARNING;
else if (strcmp(argv[1], "ERROR") == 0)
level = ERROR;
else if (strcmp(argv[1], "FATAL") == 0)
@@ -1837,7 +1837,8 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
}
/************************************************************
- * Save the plan
+ * Save the plan into permanent memory (right now it's in the
+ * SPI procCxt, which will go away at function end).
************************************************************/
qdesc->plan = SPI_saveplan(plan);
if (qdesc->plan == NULL)
@@ -1866,6 +1867,8 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
elog(ERROR, "pltcl: SPI_saveplan() failed - %s", reason);
}
+ /* Release the procCxt copy to avoid within-function memory leak */
+ SPI_freeplan(plan);
/************************************************************
* Insert a hashtable entry for the plan and return