mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
First stage of reclaiming memory in executor by resetting short-term
memory contexts. Currently, only leaks in expressions executed as quals or projections are handled. Clean up some old dead cruft in executor while at it --- unused fields in state nodes, that sort of thing.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.60 2000/07/03 23:09:11 wieck Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.61 2000/07/12 02:36:46 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -141,11 +141,10 @@ gistbuild(PG_FUNCTION_ARGS)
|
||||
{
|
||||
tupleTable = ExecCreateTupleTable(1);
|
||||
slot = ExecAllocTableSlot(tupleTable);
|
||||
econtext = makeNode(ExprContext);
|
||||
FillDummyExprContext(econtext, slot, hd, InvalidBuffer);
|
||||
ExecSetSlotDescriptor(slot, hd);
|
||||
econtext = MakeExprContext(slot, TransactionCommandContext);
|
||||
}
|
||||
else
|
||||
/* shut the compiler up */
|
||||
{
|
||||
tupleTable = NULL;
|
||||
slot = NULL;
|
||||
@@ -161,13 +160,13 @@ gistbuild(PG_FUNCTION_ARGS)
|
||||
{
|
||||
nh++;
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/*
|
||||
* If oldPred != NULL, this is an EXTEND INDEX command, so skip
|
||||
* this tuple if it was already in the existing partial index
|
||||
*/
|
||||
if (oldPred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/* SetSlotContents(slot, htup); */
|
||||
slot->val = htup;
|
||||
if (ExecQual((List *) oldPred, econtext, false))
|
||||
@@ -175,7 +174,6 @@ gistbuild(PG_FUNCTION_ARGS)
|
||||
ni++;
|
||||
continue;
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -184,13 +182,12 @@ gistbuild(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
if (pred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/* SetSlotContents(slot, htup); */
|
||||
slot->val = htup;
|
||||
if (!ExecQual((List *) pred, econtext, false))
|
||||
continue;
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
ni++;
|
||||
|
||||
@@ -262,13 +259,13 @@ gistbuild(PG_FUNCTION_ARGS)
|
||||
/* okay, all heap tuples are indexed */
|
||||
heap_endscan(scan);
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
if (pred != NULL || oldPred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
ExecDropTupleTable(tupleTable, true);
|
||||
pfree(econtext);
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
FreeExprContext(econtext);
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
/*
|
||||
* Since we just counted the tuples in the heap, we update its stats
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.40 2000/06/17 23:41:13 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.41 2000/07/12 02:36:46 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains only the public interface routines.
|
||||
@@ -102,15 +102,14 @@ hashbuild(PG_FUNCTION_ARGS)
|
||||
{
|
||||
tupleTable = ExecCreateTupleTable(1);
|
||||
slot = ExecAllocTableSlot(tupleTable);
|
||||
econtext = makeNode(ExprContext);
|
||||
FillDummyExprContext(econtext, slot, htupdesc, InvalidBuffer);
|
||||
ExecSetSlotDescriptor(slot, htupdesc);
|
||||
econtext = MakeExprContext(slot, TransactionCommandContext);
|
||||
}
|
||||
else
|
||||
/* quiet the compiler */
|
||||
{
|
||||
tupleTable = NULL;
|
||||
slot = NULL;
|
||||
econtext = NULL;
|
||||
tupleTable = 0;
|
||||
slot = 0;
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
@@ -122,9 +121,9 @@ hashbuild(PG_FUNCTION_ARGS)
|
||||
|
||||
while (HeapTupleIsValid(htup = heap_getnext(hscan, 0)))
|
||||
{
|
||||
|
||||
nhtups++;
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/*
|
||||
* If oldPred != NULL, this is an EXTEND INDEX command, so skip
|
||||
* this tuple if it was already in the existing partial index
|
||||
@@ -132,14 +131,12 @@ hashbuild(PG_FUNCTION_ARGS)
|
||||
if (oldPred != NULL)
|
||||
{
|
||||
/* SetSlotContents(slot, htup); */
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
slot->val = htup;
|
||||
if (ExecQual((List *) oldPred, econtext, false))
|
||||
{
|
||||
nitups++;
|
||||
continue;
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -148,13 +145,12 @@ hashbuild(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
if (pred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/* SetSlotContents(slot, htup); */
|
||||
slot->val = htup;
|
||||
if (!ExecQual((List *) pred, econtext, false))
|
||||
continue;
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
nitups++;
|
||||
|
||||
@@ -221,13 +217,13 @@ hashbuild(PG_FUNCTION_ARGS)
|
||||
/* okay, all heap tuples are indexed */
|
||||
heap_endscan(hscan);
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
if (pred != NULL || oldPred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
ExecDropTupleTable(tupleTable, true);
|
||||
pfree(econtext);
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
FreeExprContext(econtext);
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
/*
|
||||
* Since we just counted the tuples in the heap, we update its stats
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.38 2000/06/19 03:54:22 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.39 2000/07/12 02:36:48 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -27,6 +27,10 @@
|
||||
* that work on 32-bit or wider datatypes can't just return "a - b".
|
||||
* That could overflow and give the wrong answer.
|
||||
*
|
||||
* NOTE: these routines must not leak memory, since memory allocated
|
||||
* during an index access won't be recovered till end of query. This
|
||||
* primarily affects comparison routines for toastable datatypes;
|
||||
* they have to be careful to free any detoasted copy of an input datum.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -230,18 +234,23 @@ bttextcmp(PG_FUNCTION_ARGS)
|
||||
} while (res == 0 && len != 0);
|
||||
}
|
||||
|
||||
if (res == 0 && VARSIZE(a) != VARSIZE(b))
|
||||
{
|
||||
/*
|
||||
* The two strings are the same in the first len bytes,
|
||||
* and they are of different lengths.
|
||||
*/
|
||||
if (VARSIZE(a) < VARSIZE(b))
|
||||
res = -1;
|
||||
else
|
||||
res = 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (res != 0 || VARSIZE(a) == VARSIZE(b))
|
||||
PG_RETURN_INT32(res);
|
||||
/* Avoid leaking memory when handed toasted input. */
|
||||
PG_FREE_IF_COPY(a, 0);
|
||||
PG_FREE_IF_COPY(b, 1);
|
||||
|
||||
/*
|
||||
* The two strings are the same in the first len bytes, and they are
|
||||
* of different lengths.
|
||||
*/
|
||||
|
||||
if (VARSIZE(a) < VARSIZE(b))
|
||||
PG_RETURN_INT32(-1);
|
||||
else
|
||||
PG_RETURN_INT32(1);
|
||||
PG_RETURN_INT32(res);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.59 2000/06/17 23:41:16 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.60 2000/07/12 02:36:48 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -121,8 +121,8 @@ btbuild(PG_FUNCTION_ARGS)
|
||||
{
|
||||
tupleTable = ExecCreateTupleTable(1);
|
||||
slot = ExecAllocTableSlot(tupleTable);
|
||||
econtext = makeNode(ExprContext);
|
||||
FillDummyExprContext(econtext, slot, htupdesc, InvalidBuffer);
|
||||
ExecSetSlotDescriptor(slot, htupdesc);
|
||||
econtext = MakeExprContext(slot, TransactionCommandContext);
|
||||
|
||||
/*
|
||||
* we never want to use sort/build if we are extending an existing
|
||||
@@ -151,14 +151,13 @@ btbuild(PG_FUNCTION_ARGS)
|
||||
{
|
||||
nhtups++;
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/*
|
||||
* If oldPred != NULL, this is an EXTEND INDEX command, so skip
|
||||
* this tuple if it was already in the existing partial index
|
||||
*/
|
||||
if (oldPred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
|
||||
/* SetSlotContents(slot, htup); */
|
||||
slot->val = htup;
|
||||
if (ExecQual((List *) oldPred, econtext, false))
|
||||
@@ -166,7 +165,6 @@ btbuild(PG_FUNCTION_ARGS)
|
||||
nitups++;
|
||||
continue;
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -175,13 +173,12 @@ btbuild(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
if (pred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/* SetSlotContents(slot, htup); */
|
||||
slot->val = htup;
|
||||
if (!ExecQual((List *) pred, econtext, false))
|
||||
continue;
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
nitups++;
|
||||
|
||||
@@ -260,13 +257,13 @@ btbuild(PG_FUNCTION_ARGS)
|
||||
/* okay, all heap tuples are indexed */
|
||||
heap_endscan(hscan);
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
if (pred != NULL || oldPred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
ExecDropTupleTable(tupleTable, true);
|
||||
pfree(econtext);
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
FreeExprContext(econtext);
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
/*
|
||||
* if we are doing bottom-up btree build, finish the build by (1)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.50 2000/06/17 23:41:22 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.51 2000/07/12 02:36:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -136,14 +136,14 @@ rtbuild(PG_FUNCTION_ARGS)
|
||||
{
|
||||
tupleTable = ExecCreateTupleTable(1);
|
||||
slot = ExecAllocTableSlot(tupleTable);
|
||||
econtext = makeNode(ExprContext);
|
||||
FillDummyExprContext(econtext, slot, hd, InvalidBuffer);
|
||||
ExecSetSlotDescriptor(slot, hd);
|
||||
econtext = MakeExprContext(slot, TransactionCommandContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
econtext = NULL;
|
||||
tupleTable = NULL;
|
||||
slot = NULL;
|
||||
econtext = NULL;
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
@@ -156,13 +156,13 @@ rtbuild(PG_FUNCTION_ARGS)
|
||||
{
|
||||
nh++;
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/*
|
||||
* If oldPred != NULL, this is an EXTEND INDEX command, so skip
|
||||
* this tuple if it was already in the existing partial index
|
||||
*/
|
||||
if (oldPred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/* SetSlotContents(slot, htup); */
|
||||
slot->val = htup;
|
||||
if (ExecQual((List *) oldPred, econtext, false))
|
||||
@@ -170,7 +170,6 @@ rtbuild(PG_FUNCTION_ARGS)
|
||||
ni++;
|
||||
continue;
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -179,13 +178,12 @@ rtbuild(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
if (pred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
/* SetSlotContents(slot, htup); */
|
||||
slot->val = htup;
|
||||
if (!ExecQual((List *) pred, econtext, false))
|
||||
continue;
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
ni++;
|
||||
|
||||
@@ -239,13 +237,13 @@ rtbuild(PG_FUNCTION_ARGS)
|
||||
/* okay, all heap tuples are indexed */
|
||||
heap_endscan(scan);
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
if (pred != NULL || oldPred != NULL)
|
||||
{
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
ExecDropTupleTable(tupleTable, true);
|
||||
pfree(econtext);
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
FreeExprContext(econtext);
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
|
||||
/*
|
||||
* Since we just counted the tuples in the heap, we update its stats
|
||||
|
||||
Reference in New Issue
Block a user