diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-01-29 00:39:20 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-01-29 00:39:20 +0000 |
commit | 0d54d6ac44444c05f7c0f5058d3d3f32cc188b48 (patch) | |
tree | cccee5d61e1afc1982c363ed3e4876a09ed82b52 /src/backend/commands/command.c | |
parent | 51cd0377460839d25a5fc5f2a2499de43126a3b2 (diff) | |
download | postgresql-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/commands/command.c')
-rw-r--r-- | src/backend/commands/command.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 618322645f3..30695a7a90b 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.119 2001/01/24 19:42:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.120 2001/01/29 00:39:20 tgl Exp $ * * NOTES * The PerformAddAttribute() code, like most of the relation @@ -1102,7 +1102,7 @@ AlterTableAddConstraint(char *relationName, bool successful = true; HeapScanDesc scan; ExprContext *econtext; - TupleTableSlot *slot = makeNode(TupleTableSlot); + TupleTableSlot *slot; HeapTuple tuple; RangeTblEntry *rte; List *qual; @@ -1169,28 +1169,28 @@ AlterTableAddConstraint(char *relationName, qual = makeList1(expr); + /* Make tuple slot to hold tuples */ + slot = MakeTupleTableSlot(); + ExecSetSlotDescriptor(slot, RelationGetDescr(rel), false); + /* Make an expression context for ExecQual */ + econtext = MakeExprContext(slot, CurrentMemoryContext); + /* - * Scan through the rows now, making the necessary things - * for ExecQual, and then call it to evaluate the - * expression. + * Scan through the rows now, checking the expression + * at each row. */ while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) { - slot->val = tuple; - slot->ttc_shouldFree = false; - slot->ttc_descIsNew = true; - slot->ttc_tupleDescriptor = rel->rd_att; - slot->ttc_buffer = InvalidBuffer; - - econtext = MakeExprContext(slot, CurrentMemoryContext); + ExecStoreTuple(tuple, slot, InvalidBuffer, false); if (!ExecQual(qual, econtext, true)) { successful=false; break; } - FreeExprContext(econtext); + ResetExprContext(econtext); } + FreeExprContext(econtext); pfree(slot); heap_endscan(scan); |