From badce86a2c327b40c6146242526d1523455d64a6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 12 Jul 2000 02:37:39 +0000 Subject: 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. --- src/include/executor/executor.h | 31 +++++++++++++++++-------------- src/include/executor/hashjoin.h | 14 +++++++++++--- src/include/executor/nodeGroup.h | 5 +++-- src/include/executor/nodeHash.h | 12 +++++++----- src/include/executor/nodeSubplan.h | 2 +- 5 files changed, 39 insertions(+), 25 deletions(-) (limited to 'src/include/executor') diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 703c907e12..b835b29044 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.45 2000/06/18 22:44:28 tgl Exp $ + * $Id: executor.h,v 1.46 2000/07/12 02:37:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -72,19 +72,16 @@ extern void ExecEndNode(Plan *node, Plan *parent); /* * prototypes from functions in execQual.c */ -extern bool execConstByVal; -extern int execConstLen; - -extern Datum ExecExtractResult(TupleTableSlot *slot, AttrNumber attnum, - bool *isNull); extern Datum ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull); - extern char *GetAttributeByNum(TupleTableSlot *slot, AttrNumber attrno, bool *isNull); -extern char *GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull); -extern Datum ExecEvalExpr(Node *expression, ExprContext *econtext, bool *isNull, - bool *isDone); +extern char *GetAttributeByName(TupleTableSlot *slot, char *attname, + bool *isNull); +extern Datum ExecEvalExpr(Node *expression, ExprContext *econtext, + bool *isNull, bool *isDone); +extern Datum ExecEvalExprSwitchContext(Node *expression, ExprContext *econtext, + bool *isNull, bool *isDone); extern bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull); extern int ExecTargetListLength(List *targetlist); extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo, bool *isDone); @@ -92,7 +89,9 @@ extern TupleTableSlot *ExecProject(ProjectionInfo *projInfo, bool *isDone); /* * prototypes from functions in execScan.c */ -extern TupleTableSlot *ExecScan(Scan *node, TupleTableSlot *(*accessMtd) ()); +typedef TupleTableSlot *(*ExecScanAccessMtd) (Scan *node); + +extern TupleTableSlot *ExecScan(Scan *node, ExecScanAccessMtd accessMtd); /* * prototypes from functions in execTuples.c @@ -121,8 +120,6 @@ extern void SetChangedParamList(Plan *node, List *newchg); * prototypes from functions in execUtils.c */ extern void ResetTupleCount(void); -extern void ExecAssignNodeBaseInfo(EState *estate, CommonState *basenode, - Plan *parent); extern void ExecAssignExprContext(EState *estate, CommonState *commonstate); extern void ExecAssignResultType(CommonState *commonstate, TupleDesc tupDesc); @@ -133,7 +130,6 @@ extern TupleDesc ExecGetResultType(CommonState *commonstate); extern void ExecAssignProjectionInfo(Plan *node, CommonState *commonstate); extern void ExecFreeProjectionInfo(CommonState *commonstate); extern void ExecFreeExprContext(CommonState *commonstate); -extern void ExecFreeTypeInfo(CommonState *commonstate); extern TupleDesc ExecGetScanType(CommonScanState *csstate); extern void ExecAssignScanType(CommonScanState *csstate, TupleDesc tupDesc); @@ -141,6 +137,13 @@ extern void ExecAssignScanTypeFromOuterPlan(Plan *node, CommonScanState *csstate); extern Form_pg_attribute ExecGetTypeInfo(Relation relDesc); +extern ExprContext *MakeExprContext(TupleTableSlot *slot, + MemoryContext queryContext); +extern void FreeExprContext(ExprContext *econtext); + +#define ResetExprContext(econtext) \ + MemoryContextReset((econtext)->ecxt_per_tuple_memory) + extern void ExecOpenIndices(RelationInfo *resultRelationInfo); extern void ExecCloseIndices(RelationInfo *resultRelationInfo); extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid, diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h index 285bb314d3..8d4cb98469 100644 --- a/src/include/executor/hashjoin.h +++ b/src/include/executor/hashjoin.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hashjoin.h,v 1.17 2000/06/28 03:33:05 tgl Exp $ + * $Id: hashjoin.h,v 1.18 2000/07/12 02:37:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -21,8 +21,8 @@ * hash-join hash table structures * * Each active hashjoin has a HashJoinTable control block which is - * palloc'd in the executor's context. All other storage needed for - * the hashjoin is kept in private memory contexts, two for each hashjoin. + * palloc'd in the executor's per-query context. All other storage needed + * for the hashjoin is kept in private memory contexts, two for each hashjoin. * This makes it easy and fast to release the storage when we don't need it * anymore. * @@ -68,6 +68,14 @@ typedef struct HashTableData long *innerBatchSize; /* count of tuples in each inner batch * file */ + /* + * Info about the datatype being hashed. We assume that the inner + * and outer sides of the hash are the same type, or at least + * binary-compatible types. + */ + bool typByVal; + int typLen; + /* * During 1st scan of inner relation, we get tuples from executor. If * nbatch > 0 then tuples that don't belong in first nbuckets logical diff --git a/src/include/executor/nodeGroup.h b/src/include/executor/nodeGroup.h index 303516b167..71bd3b52ff 100644 --- a/src/include/executor/nodeGroup.h +++ b/src/include/executor/nodeGroup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeGroup.h,v 1.16 2000/04/12 17:16:33 momjian Exp $ + * $Id: nodeGroup.h,v 1.17 2000/07/12 02:37:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,8 @@ extern bool execTuplesMatch(HeapTuple tuple1, TupleDesc tupdesc, int numCols, AttrNumber *matchColIdx, - FmgrInfo *eqfunctions); + FmgrInfo *eqfunctions, + MemoryContext evalContext); extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc, int numCols, AttrNumber *matchColIdx); diff --git a/src/include/executor/nodeHash.h b/src/include/executor/nodeHash.h index b61ced7cdc..5fabe7d253 100644 --- a/src/include/executor/nodeHash.h +++ b/src/include/executor/nodeHash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeHash.h,v 1.16 2000/04/18 05:43:00 tgl Exp $ + * $Id: nodeHash.h,v 1.17 2000/07/12 02:37:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -25,10 +25,12 @@ extern int ExecCountSlotsHash(Hash *node); extern void ExecEndHash(Hash *node); extern HashJoinTable ExecHashTableCreate(Hash *node); extern void ExecHashTableDestroy(HashJoinTable hashtable); -extern void ExecHashTableInsert(HashJoinTable hashtable, ExprContext *econtext, - Var *hashkey); -extern int ExecHashGetBucket(HashJoinTable hashtable, ExprContext *econtext, - Var *hashkey); +extern void ExecHashTableInsert(HashJoinTable hashtable, + ExprContext *econtext, + Node *hashkey); +extern int ExecHashGetBucket(HashJoinTable hashtable, + ExprContext *econtext, + Node *hashkey); extern HeapTuple ExecScanHashBucket(HashJoinState *hjstate, List *hjclauses, ExprContext *econtext); extern void ExecHashTableReset(HashJoinTable hashtable, long ntuples); diff --git a/src/include/executor/nodeSubplan.h b/src/include/executor/nodeSubplan.h index a56ae216f5..f7c46c3ca9 100644 --- a/src/include/executor/nodeSubplan.h +++ b/src/include/executor/nodeSubplan.h @@ -13,7 +13,7 @@ extern Datum ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull); extern bool ExecInitSubPlan(SubPlan *node, EState *estate, Plan *parent); extern void ExecReScanSetParamPlan(SubPlan *node, Plan *parent); -extern void ExecSetParamPlan(SubPlan *node); +extern void ExecSetParamPlan(SubPlan *node, ExprContext *econtext); extern void ExecEndSubPlan(SubPlan *node); #endif /* NODESUBPLAN_H */ -- cgit v1.2.1