aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeSort.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-01-29 00:39:20 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-01-29 00:39:20 +0000
commit0d54d6ac44444c05f7c0f5058d3d3f32cc188b48 (patch)
treecccee5d61e1afc1982c363ed3e4876a09ed82b52 /src/backend/executor/nodeSort.c
parent51cd0377460839d25a5fc5f2a2499de43126a3b2 (diff)
downloadpostgresql-0d54d6ac44444c05f7c0f5058d3d3f32cc188b48.tar.gz
postgresql-0d54d6ac44444c05f7c0f5058d3d3f32cc188b48.zip
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.
Diffstat (limited to 'src/backend/executor/nodeSort.c')
-rw-r--r--src/backend/executor/nodeSort.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c
index 99bd3b76437..b8c057c3397 100644
--- a/src/backend/executor/nodeSort.c
+++ b/src/backend/executor/nodeSort.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.30 2001/01/24 19:42:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.31 2001/01/29 00:39:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -172,7 +172,6 @@ ExecSort(Sort *node)
break;
tuplesort_puttuple(tuplesortstate, (void *) slot->val);
- ExecClearTuple(slot);
}
/* ----------------
@@ -188,11 +187,10 @@ ExecSort(Sort *node)
estate->es_direction = dir;
/* ----------------
- * make sure the tuple descriptor is up to date
+ * make sure the tuple descriptor is up to date (is this needed?)
* ----------------
*/
- slot = (TupleTableSlot *) sortstate->csstate.cstate.cs_ResultTupleSlot;
- slot->ttc_tupleDescriptor = tupDesc;
+ ExecAssignResultType(&sortstate->csstate.cstate, tupDesc, false);
/* ----------------
* finally set the sorted flag to true
@@ -201,8 +199,6 @@ ExecSort(Sort *node)
sortstate->sort_Done = true;
SO1_printf(stderr, "ExecSort: sorting done.\n");
}
- else
- slot = (TupleTableSlot *) sortstate->csstate.cstate.cs_ResultTupleSlot;
SO1_printf("ExecSort: %s\n",
"retrieving tuple from tuplesort");
@@ -216,6 +212,7 @@ ExecSort(Sort *node)
ScanDirectionIsForward(dir),
&should_free);
+ slot = sortstate->csstate.cstate.cs_ResultTupleSlot;
return ExecStoreTuple(heapTuple, slot, InvalidBuffer, should_free);
}
@@ -347,6 +344,12 @@ ExecEndSort(Sort *node)
tuplesort_end((Tuplesortstate *) sortstate->tuplesortstate);
sortstate->tuplesortstate = NULL;
+ if (sortstate->sort_Keys != NULL)
+ pfree(sortstate->sort_Keys);
+
+ pfree(sortstate);
+ node->sortstate = NULL;
+
SO1_printf("ExecEndSort: %s\n",
"sort node shutdown");
}