From 0d54d6ac44444c05f7c0f5058d3d3f32cc188b48 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 29 Jan 2001 00:39:20 +0000 Subject: Clean up handling of tuple descriptors so that result-tuple descriptors allocated by plan nodes are not leaked at end of query. This doesn't really matter for normal queries, but it sure does for queries invoked repetitively inside SQL functions. Clean up some other grotty code associated with tupdescs, and fix a few other memory leaks exposed by tests with simple SQL functions. --- src/backend/executor/execQual.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/backend/executor/execQual.c') diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index f0721f57bd5..bab2851df9d 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.82 2001/01/24 19:42:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.83 2001/01/29 00:39:18 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -328,25 +328,19 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull) /* * If the attribute number is invalid, then we are supposed to return * the entire tuple, we give back a whole slot so that callers know - * what the tuple looks like. + * what the tuple looks like. XXX why copy? Couldn't we just give + * back the existing slot? */ if (attnum == InvalidAttrNumber) { - TupleTableSlot *tempSlot; + TupleTableSlot *tempSlot = MakeTupleTableSlot(); TupleDesc td; HeapTuple tup; - tempSlot = makeNode(TupleTableSlot); - tempSlot->ttc_shouldFree = false; - tempSlot->ttc_descIsNew = true; - tempSlot->ttc_tupleDescriptor = (TupleDesc) NULL; - tempSlot->ttc_buffer = InvalidBuffer; - tup = heap_copytuple(heapTuple); td = CreateTupleDescCopy(tuple_type); - ExecSetSlotDescriptor(tempSlot, td); - + ExecSetSlotDescriptor(tempSlot, td, true); ExecStoreTuple(tup, tempSlot, InvalidBuffer, true); return PointerGetDatum(tempSlot); } -- cgit v1.2.3