Skip to content

Commit

Permalink
[WIP] Store "cache enabled" flag in EState instead of inventing a new…
Browse files Browse the repository at this point in the history
… context

struct. This reverts most of commit
0791252
  • Loading branch information
intgr committed Apr 28, 2013
1 parent ccb8876 commit c1948ce
Show file tree
Hide file tree
Showing 40 changed files with 203 additions and 212 deletions.
4 changes: 4 additions & 0 deletions src/backend/catalog/index.c
Expand Up @@ -2165,6 +2165,8 @@ IndexBuildHeapScan(Relation heapRelation,
* predicates. Also a slot to hold the current tuple.
*/
estate = CreateExecutorState();
estate->es_useCache = false;

econtext = GetPerTupleExprContext(estate);
slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));

Expand Down Expand Up @@ -2553,6 +2555,7 @@ IndexCheckExclusion(Relation heapRelation,
* predicates. Also a slot to hold the current tuple.
*/
estate = CreateExecutorState();
estate->es_useCache = false;
econtext = GetPerTupleExprContext(estate);
slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));

Expand Down Expand Up @@ -2823,6 +2826,7 @@ validate_index_heapscan(Relation heapRelation,
* predicates. Also a slot to hold the current tuple.
*/
estate = CreateExecutorState();
estate->es_useCache = false;
econtext = GetPerTupleExprContext(estate);
slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));

Expand Down
2 changes: 2 additions & 0 deletions src/backend/commands/analyze.c
Expand Up @@ -716,6 +716,8 @@ compute_index_stats(Relation onerel, double totalrows,
* sure it gets cleaned up at the bottom of the loop.
*/
estate = CreateExecutorState();
estate->es_useCache = false;

econtext = GetPerTupleExprContext(estate);
/* Need a slot to hold the current heap tuple, too */
slot = MakeSingleTupleTableSlot(RelationGetDescr(onerel));
Expand Down
1 change: 1 addition & 0 deletions src/backend/commands/constraint.c
Expand Up @@ -134,6 +134,7 @@ unique_key_recheck(PG_FUNCTION_ARGS)
indexInfo->ii_ExclusionOps != NULL)
{
estate = CreateExecutorState();
estate->es_useCache = false;
econtext = GetPerTupleExprContext(estate);
econtext->ecxt_scantuple = slot;
}
Expand Down
12 changes: 7 additions & 5 deletions src/backend/commands/copy.c
Expand Up @@ -1996,11 +1996,10 @@ CopyFrom(CopyState cstate)
Datum *values;
bool *nulls;
ResultRelInfo *resultRelInfo;
EState *estate = CreateExecutorState(); /* for ExecConstraints() */
EState *estate;
ExprContext *econtext;
TupleTableSlot *myslot;
MemoryContext oldcontext = CurrentMemoryContext;

ErrorContextCallback errcallback;
CommandId mycid = GetCurrentCommandId(true);
int hi_options = 0; /* start with default heap_insert options */
Expand All @@ -2013,6 +2012,9 @@ CopyFrom(CopyState cstate)
HeapTuple *bufferedTuples = NULL; /* initialize to silence warning */
Size bufferedTuplesSize = 0;

estate = CreateExecutorState(); /* for ExecConstraints() */
estate->es_useCache = true;

Assert(cstate->rel);

if (cstate->rel->rd_rel->relkind != RELKIND_RELATION)
Expand Down Expand Up @@ -2481,10 +2483,10 @@ BeginCopyFrom(Relation rel,
if (defexpr != NULL)
{
/* Initialize expressions in copycontext. */
// XXX?
// Assert(estate->es_useCache == true);
defexprs[num_defaults] = ExecInitExpr(
expression_planner((Expr *) defexpr),
NULL,
true);
expression_planner((Expr *) defexpr), NULL);
defmap[num_defaults] = attnum - 1;
num_defaults++;

Expand Down
2 changes: 2 additions & 0 deletions src/backend/commands/prepare.c
Expand Up @@ -217,6 +217,7 @@ ExecuteQuery(ExecuteStmt *stmt, IntoClause *intoClause,
*/
estate = CreateExecutorState();
estate->es_param_list_info = params;
estate->es_useCache = false;
paramLI = EvaluateParams(entry, stmt->params,
queryString, estate);
}
Expand Down Expand Up @@ -650,6 +651,7 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
*/
estate = CreateExecutorState();
estate->es_param_list_info = params;
estate->es_useCache = false;
paramLI = EvaluateParams(entry, execstmt->params,
queryString, estate);
}
Expand Down
7 changes: 6 additions & 1 deletion src/backend/commands/tablecmds.c
Expand Up @@ -1085,6 +1085,8 @@ ExecuteTruncate(TruncateStmt *stmt)
* each relation. We don't need to call ExecOpenIndices, though.
*/
estate = CreateExecutorState();
estate->es_useCache = false;

resultRelInfos = (ResultRelInfo *)
palloc(list_length(rels) * sizeof(ResultRelInfo));
resultRelInfo = resultRelInfos;
Expand Down Expand Up @@ -3679,6 +3681,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
*/

estate = CreateExecutorState();
estate->es_useCache = true;

/* Build the needed expression execution states */
foreach(l, tab->constraints)
Expand Down Expand Up @@ -3706,7 +3709,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
NewColumnValue *ex = lfirst(l);

/* expr already planned */
ex->exprstate = ExecInitExpr((Expr *) ex->expr, NULL, true);
Assert(estate->es_useCache == true);
ex->exprstate = ExecInitExpr((Expr *) ex->expr, NULL);
}

notnull_attrs = NIL;
Expand Down Expand Up @@ -6686,6 +6690,7 @@ validateCheckConstraint(Relation rel, HeapTuple constrtup)
constrForm = (Form_pg_constraint) GETSTRUCT(constrtup);

estate = CreateExecutorState();
estate->es_useCache = false;

/*
* XXX this tuple doesn't really come from a syscache, but this doesn't
Expand Down
1 change: 1 addition & 0 deletions src/backend/commands/trigger.c
Expand Up @@ -3555,6 +3555,7 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events,
if (estate == NULL)
{
estate = CreateExecutorState();
estate->es_useCache = false; // ???
local_estate = true;
}

Expand Down
6 changes: 5 additions & 1 deletion src/backend/commands/typecmds.c
Expand Up @@ -2621,6 +2621,7 @@ validateDomainConstraint(Oid domainoid, char *ccbin)

/* Need an EState to run ExecEvalExpr */
estate = CreateExecutorState();
estate->es_useCache = false;
econtext = GetPerTupleExprContext(estate);

/* build execution state for expr */
Expand Down Expand Up @@ -3097,7 +3098,10 @@ GetDomainConstraints(Oid typeOid)
r = makeNode(DomainConstraintState);
r->constrainttype = DOM_CONSTRAINT_CHECK;
r->name = pstrdup(NameStr(c->conname));
r->check_expr = ExecInitExpr(check_expr, NULL, false);

// XXX FIXME!
//Assert(scanstate->es_useCache == false);
r->check_expr = ExecInitExpr(check_expr, NULL);

/*
* use lcons() here because constraints of lower domains should be
Expand Down
2 changes: 2 additions & 0 deletions src/backend/executor/execMain.c
Expand Up @@ -141,6 +141,7 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags)
* Build EState, switch into per-query memory context for startup.
*/
estate = CreateExecutorState();
estate->es_useCache = true; // XXX REMOVE
queryDesc->estate = estate;

oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
Expand Down Expand Up @@ -2287,6 +2288,7 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree)
rtsize = list_length(parentestate->es_range_table);

epqstate->estate = estate = CreateExecutorState();
estate->es_useCache = true; // XXX

oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);

Expand Down

0 comments on commit c1948ce

Please sign in to comment.