* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.92 2008/01/01 19:45:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.92.2.1 2010/07/28 04:51:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
PlanState *planstate = node->planstate;
- ExprContext *innerecontext = node->innerecontext;
TupleTableSlot *slot;
/* Shouldn't have any direct correlation Vars */
* it still needs to free the tuple.
*/
- /*
- * Since the hashtable routines will use innerecontext's per-tuple memory
- * as working memory, be sure to reset it for each tuple.
- */
- ResetExprContext(innerecontext);
-
/*
* If the LHS is all non-null, probe for an exact match in the main hash
* table. If we find one, the result is TRUE. Otherwise, scan the
PlanState *planstate = node->planstate;
int ncols = list_length(subplan->paramIds);
ExprContext *innerecontext = node->innerecontext;
- MemoryContext tempcxt = innerecontext->ecxt_per_tuple_memory;
MemoryContext oldcontext;
int nbuckets;
TupleTableSlot *slot;
* If it's not necessary to distinguish FALSE and UNKNOWN, then we don't
* need to store subplan output rows that contain NULL.
*/
- MemoryContextReset(node->tablecxt);
+ MemoryContextReset(node->hashtablecxt);
node->hashtable = NULL;
node->hashnulls = NULL;
node->havehashrows = false;
node->tab_hash_funcs,
nbuckets,
sizeof(TupleHashEntryData),
- node->tablecxt,
- tempcxt);
+ node->hashtablecxt,
+ node->hashtempcxt);
if (!subplan->unknownEqFalse)
{
node->tab_hash_funcs,
nbuckets,
sizeof(TupleHashEntryData),
- node->tablecxt,
- tempcxt);
+ node->hashtablecxt,
+ node->hashtempcxt);
}
/*
/*
* Reset innerecontext after each inner tuple to free any memory used
- * in hash computation or comparison routines.
+ * during ExecProject.
*/
ResetExprContext(innerecontext);
}
sstate->projRight = NULL;
sstate->hashtable = NULL;
sstate->hashnulls = NULL;
- sstate->tablecxt = NULL;
+ sstate->hashtablecxt = NULL;
+ sstate->hashtempcxt = NULL;
sstate->innerecontext = NULL;
sstate->keyColIdx = NULL;
sstate->tab_hash_funcs = NULL;
ListCell *l;
/* We need a memory context to hold the hash table(s) */
- sstate->tablecxt =
+ sstate->hashtablecxt =
AllocSetContextCreate(CurrentMemoryContext,
"Subplan HashTable Context",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
+ /* and a small one for the hash tables to use as temp storage */
+ sstate->hashtempcxt =
+ AllocSetContextCreate(CurrentMemoryContext,
+ "Subplan HashTable Temp Context",
+ ALLOCSET_SMALL_MINSIZE,
+ ALLOCSET_SMALL_INITSIZE,
+ ALLOCSET_SMALL_MAXSIZE);
/* and a short-lived exprcontext for function evaluation */
sstate->innerecontext = CreateExprContext(estate);
/* Silly little array of column numbers 1..n */
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.183 2008/01/01 19:45:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.183.2.1 2010/07/28 04:51:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
TupleHashTable hashnulls; /* hash table for rows with null(s) */
bool havehashrows; /* TRUE if hashtable is not empty */
bool havenullrows; /* TRUE if hashnulls is not empty */
- MemoryContext tablecxt; /* memory context containing tables */
- ExprContext *innerecontext; /* working context for comparisons */
+ MemoryContext hashtablecxt; /* memory context containing hash tables */
+ MemoryContext hashtempcxt; /* temp memory context for hash tables */
+ ExprContext *innerecontext; /* econtext for computing inner tuples */
AttrNumber *keyColIdx; /* control data for hash tables */
FmgrInfo *tab_hash_funcs; /* hash functions for table datatype(s) */
FmgrInfo *tab_eq_funcs; /* equality functions for table datatype(s) */