summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pl/plpython/plpy_main.c2
-rw-r--r--src/pl/plpython/plpy_procedure.c13
2 files changed, 13 insertions, 2 deletions
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c
index 8ae02a239ae..7673b5eca7b 100644
--- a/src/pl/plpython/plpy_main.c
+++ b/src/pl/plpython/plpy_main.c
@@ -133,7 +133,7 @@ plpython3_validator(PG_FUNCTION_ARGS)
ReleaseSysCache(tuple);
/* We can't validate triggers against any particular table ... */
- PLy_procedure_get(funcoid, InvalidOid, is_trigger);
+ (void) PLy_procedure_get(funcoid, InvalidOid, is_trigger);
PG_RETURN_VOID();
}
diff --git a/src/pl/plpython/plpy_procedure.c b/src/pl/plpython/plpy_procedure.c
index 22d9ef0fe06..655ab1d09ee 100644
--- a/src/pl/plpython/plpy_procedure.c
+++ b/src/pl/plpython/plpy_procedure.c
@@ -60,7 +60,12 @@ PLy_procedure_name(PLyProcedure *proc)
*
* The reason that both fn_rel and is_trigger need to be passed is that when
* trigger functions get validated we don't know which relation(s) they'll
- * be used with, so no sensible fn_rel can be passed.
+ * be used with, so no sensible fn_rel can be passed. Also, in that case
+ * we can't make a cache entry because we can't construct the right cache key.
+ * To forestall leakage of the PLyProcedure in such cases, delete it after
+ * construction and return NULL. That's okay because the only caller that
+ * would pass that set of values is plpython3_validator, which ignores our
+ * result anyway.
*/
PLyProcedure *
PLy_procedure_get(Oid fn_oid, Oid fn_rel, PLyTrigType is_trigger)
@@ -102,6 +107,12 @@ PLy_procedure_get(Oid fn_oid, Oid fn_rel, PLyTrigType is_trigger)
proc = PLy_procedure_create(procTup, fn_oid, is_trigger);
if (use_cache)
entry->proc = proc;
+ else
+ {
+ /* Delete the proc, otherwise it's a memory leak */
+ PLy_procedure_delete(proc);
+ proc = NULL;
+ }
}
else if (!PLy_procedure_valid(proc, procTup))
{