*** pgsql/src/backend/executor/nodeSubplan.c 2008/01/01 19:45:49 1.92 --- pgsql/src/backend/executor/nodeSubplan.c 2010/07/28 04:51:14 1.92.2.1 *************** *** 7,13 **** * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.91 2007/11/15 21:14:35 momjian Exp $ * *------------------------------------------------------------------------- */ --- 7,13 ---- * 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 $ * *------------------------------------------------------------------------- */ *************** ExecHashSubPlan(SubPlanState *node, *** 78,84 **** { SubPlan *subplan = (SubPlan *) node->xprstate.expr; PlanState *planstate = node->planstate; - ExprContext *innerecontext = node->innerecontext; TupleTableSlot *slot; /* Shouldn't have any direct correlation Vars */ --- 78,83 ---- *************** ExecHashSubPlan(SubPlanState *node, *** 116,127 **** */ /* - * 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 * partly-null table to see if there are any rows that aren't provably --- 115,120 ---- *************** buildSubPlanHash(SubPlanState *node, Exp *** 427,433 **** 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; --- 420,425 ---- *************** buildSubPlanHash(SubPlanState *node, Exp *** 449,455 **** * 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); node->hashtable = NULL; node->hashnulls = NULL; node->havehashrows = false; --- 441,447 ---- * 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->hashtablecxt); node->hashtable = NULL; node->hashnulls = NULL; node->havehashrows = false; *************** buildSubPlanHash(SubPlanState *node, Exp *** 465,472 **** node->tab_hash_funcs, nbuckets, sizeof(TupleHashEntryData), ! node->tablecxt, ! tempcxt); if (!subplan->unknownEqFalse) { --- 457,464 ---- node->tab_hash_funcs, nbuckets, sizeof(TupleHashEntryData), ! node->hashtablecxt, ! node->hashtempcxt); if (!subplan->unknownEqFalse) { *************** buildSubPlanHash(SubPlanState *node, Exp *** 484,491 **** node->tab_hash_funcs, nbuckets, sizeof(TupleHashEntryData), ! node->tablecxt, ! tempcxt); } /* --- 476,483 ---- node->tab_hash_funcs, nbuckets, sizeof(TupleHashEntryData), ! node->hashtablecxt, ! node->hashtempcxt); } /* *************** buildSubPlanHash(SubPlanState *node, Exp *** 544,550 **** /* * Reset innerecontext after each inner tuple to free any memory used ! * in hash computation or comparison routines. */ ResetExprContext(innerecontext); } --- 536,542 ---- /* * Reset innerecontext after each inner tuple to free any memory used ! * during ExecProject. */ ResetExprContext(innerecontext); } *************** ExecInitSubPlan(SubPlan *subplan, PlanSt *** 669,675 **** sstate->projRight = NULL; sstate->hashtable = NULL; sstate->hashnulls = NULL; ! sstate->tablecxt = NULL; sstate->innerecontext = NULL; sstate->keyColIdx = NULL; sstate->tab_hash_funcs = NULL; --- 661,668 ---- sstate->projRight = NULL; sstate->hashtable = NULL; sstate->hashnulls = NULL; ! sstate->hashtablecxt = NULL; ! sstate->hashtempcxt = NULL; sstate->innerecontext = NULL; sstate->keyColIdx = NULL; sstate->tab_hash_funcs = NULL; *************** ExecInitSubPlan(SubPlan *subplan, PlanSt *** 717,728 **** ListCell *l; /* We need a memory context to hold the hash table(s) */ ! sstate->tablecxt = AllocSetContextCreate(CurrentMemoryContext, "Subplan HashTable Context", ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE); /* and a short-lived exprcontext for function evaluation */ sstate->innerecontext = CreateExprContext(estate); /* Silly little array of column numbers 1..n */ --- 710,728 ---- ListCell *l; /* We need a memory context to hold the hash table(s) */ ! 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 */