mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Reimplement the linked list data structure used throughout the backend.
In the past, we used a 'Lispy' linked list implementation: a "list" was merely a pointer to the head node of the list. The problem with that design is that it makes lappend() and length() linear time. This patch fixes that problem (and others) by maintaining a count of the list length and a pointer to the tail node along with each head node pointer. A "list" is now a pointer to a structure containing some meta-data about the list; the head and tail pointers in that structure refer to ListCell structures that maintain the actual linked list of nodes. The function names of the list API have also been changed to, I hope, be more logically consistent. By default, the old function names are still available; they will be disabled-by-default once the rest of the tree has been updated to use the new API names.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.78 2004/03/02 18:56:15 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.79 2004/05/26 04:41:14 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -64,11 +64,11 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
|
||||
/* If we have changed parameters, propagate that info */
|
||||
if (node->chgParam != NULL)
|
||||
{
|
||||
List *lst;
|
||||
ListCell *l;
|
||||
|
||||
foreach(lst, node->initPlan)
|
||||
foreach(l, node->initPlan)
|
||||
{
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(lst);
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(l);
|
||||
PlanState *splan = sstate->planstate;
|
||||
|
||||
if (splan->plan->extParam != NULL) /* don't care about child
|
||||
@ -77,9 +77,9 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
|
||||
if (splan->chgParam != NULL)
|
||||
ExecReScanSetParamPlan(sstate, node);
|
||||
}
|
||||
foreach(lst, node->subPlan)
|
||||
foreach(l, node->subPlan)
|
||||
{
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(lst);
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(l);
|
||||
PlanState *splan = sstate->planstate;
|
||||
|
||||
if (splan->plan->extParam != NULL)
|
||||
@ -315,7 +315,7 @@ ExecSupportsBackwardScan(Plan *node)
|
||||
|
||||
case T_Append:
|
||||
{
|
||||
List *l;
|
||||
ListCell *l;
|
||||
|
||||
foreach(l, ((Append *) node)->appendplans)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.39 2004/04/07 18:46:12 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.40 2004/05/26 04:41:14 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -68,7 +68,7 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType,
|
||||
int len,
|
||||
cleanLength;
|
||||
TupleDesc cleanTupType;
|
||||
List *t;
|
||||
ListCell *t;
|
||||
TargetEntry *tle;
|
||||
Resdom *resdom,
|
||||
*cleanResdom;
|
||||
@ -184,7 +184,7 @@ ExecGetJunkAttribute(JunkFilter *junkfilter,
|
||||
bool *isNull)
|
||||
{
|
||||
List *targetList;
|
||||
List *t;
|
||||
ListCell *t;
|
||||
AttrNumber resno;
|
||||
TupleDesc tupType;
|
||||
HeapTuple tuple;
|
||||
|
@ -26,7 +26,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.231 2004/05/11 17:36:12 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.232 2004/05/26 04:41:14 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -353,11 +353,11 @@ ExecutorRewind(QueryDesc *queryDesc)
|
||||
void
|
||||
ExecCheckRTPerms(List *rangeTable)
|
||||
{
|
||||
List *lp;
|
||||
ListCell *l;
|
||||
|
||||
foreach(lp, rangeTable)
|
||||
foreach(l, rangeTable)
|
||||
{
|
||||
RangeTblEntry *rte = lfirst(lp);
|
||||
RangeTblEntry *rte = lfirst(l);
|
||||
|
||||
ExecCheckRTEPerms(rte);
|
||||
}
|
||||
@ -427,7 +427,7 @@ ExecCheckRTEPerms(RangeTblEntry *rte)
|
||||
static void
|
||||
ExecCheckXactReadOnly(Query *parsetree)
|
||||
{
|
||||
List *lp;
|
||||
ListCell *l;
|
||||
|
||||
/*
|
||||
* CREATE TABLE AS or SELECT INTO?
|
||||
@ -438,9 +438,9 @@ ExecCheckXactReadOnly(Query *parsetree)
|
||||
goto fail;
|
||||
|
||||
/* Fail if write permissions are requested on any non-temp table */
|
||||
foreach(lp, parsetree->rtable)
|
||||
foreach(l, parsetree->rtable)
|
||||
{
|
||||
RangeTblEntry *rte = lfirst(lp);
|
||||
RangeTblEntry *rte = lfirst(l);
|
||||
|
||||
if (rte->rtekind == RTE_SUBQUERY)
|
||||
{
|
||||
@ -521,20 +521,20 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
* Multiple result relations (due to inheritance)
|
||||
* parseTree->resultRelations identifies them all
|
||||
*/
|
||||
ResultRelInfo *resultRelInfo;
|
||||
ResultRelInfo *resultRelInfo;
|
||||
ListCell *l;
|
||||
|
||||
numResultRelations = length(resultRelations);
|
||||
resultRelInfos = (ResultRelInfo *)
|
||||
palloc(numResultRelations * sizeof(ResultRelInfo));
|
||||
resultRelInfo = resultRelInfos;
|
||||
while (resultRelations != NIL)
|
||||
foreach(l, resultRelations)
|
||||
{
|
||||
initResultRelInfo(resultRelInfo,
|
||||
lfirsti(resultRelations),
|
||||
lfirst_int(l),
|
||||
rangeTable,
|
||||
operation);
|
||||
resultRelInfo++;
|
||||
resultRelations = lnext(resultRelations);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -586,7 +586,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
estate->es_rowMark = NIL;
|
||||
if (parseTree->rowMarks != NIL)
|
||||
{
|
||||
List *l;
|
||||
ListCell *l;
|
||||
|
||||
foreach(l, parseTree->rowMarks)
|
||||
{
|
||||
@ -651,7 +651,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
|
||||
*/
|
||||
{
|
||||
bool junk_filter_needed = false;
|
||||
List *tlist;
|
||||
ListCell *tlist;
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
@ -950,7 +950,7 @@ ExecEndPlan(PlanState *planstate, EState *estate)
|
||||
{
|
||||
ResultRelInfo *resultRelInfo;
|
||||
int i;
|
||||
List *l;
|
||||
ListCell *l;
|
||||
|
||||
/*
|
||||
* shut down any PlanQual processing we were doing
|
||||
@ -1132,7 +1132,7 @@ lnext: ;
|
||||
}
|
||||
else if (estate->es_rowMark != NIL)
|
||||
{
|
||||
List *l;
|
||||
ListCell *l;
|
||||
|
||||
lmark: ;
|
||||
foreach(l, estate->es_rowMark)
|
||||
@ -1785,7 +1785,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
|
||||
relation = estate->es_result_relation_info->ri_RelationDesc;
|
||||
else
|
||||
{
|
||||
List *l;
|
||||
ListCell *l;
|
||||
|
||||
relation = NULL;
|
||||
foreach(l, estate->es_rowMark)
|
||||
|
@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.42 2004/03/02 22:17:34 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.43 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -119,7 +119,7 @@ ExecInitNode(Plan *node, EState *estate)
|
||||
{
|
||||
PlanState *result;
|
||||
List *subps;
|
||||
List *subp;
|
||||
ListCell *l;
|
||||
|
||||
/*
|
||||
* do nothing when we get to the end of a leaf on tree.
|
||||
@ -224,9 +224,9 @@ ExecInitNode(Plan *node, EState *estate)
|
||||
* them in a separate list for us.
|
||||
*/
|
||||
subps = NIL;
|
||||
foreach(subp, node->initPlan)
|
||||
foreach(l, node->initPlan)
|
||||
{
|
||||
SubPlan *subplan = (SubPlan *) lfirst(subp);
|
||||
SubPlan *subplan = (SubPlan *) lfirst(l);
|
||||
SubPlanState *sstate;
|
||||
|
||||
Assert(IsA(subplan, SubPlan));
|
||||
@ -242,9 +242,9 @@ ExecInitNode(Plan *node, EState *estate)
|
||||
* do this after initializing initPlans, in case their arguments
|
||||
* contain subPlans (is that actually possible? perhaps not).
|
||||
*/
|
||||
foreach(subp, result->subPlan)
|
||||
foreach(l, result->subPlan)
|
||||
{
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(subp);
|
||||
SubPlanState *sstate = (SubPlanState *) lfirst(l);
|
||||
|
||||
Assert(IsA(sstate, SubPlanState));
|
||||
ExecInitSubPlan(sstate, estate);
|
||||
@ -483,7 +483,7 @@ ExecCountSlotsNode(Plan *node)
|
||||
void
|
||||
ExecEndNode(PlanState *node)
|
||||
{
|
||||
List *subp;
|
||||
ListCell *subp;
|
||||
|
||||
/*
|
||||
* do nothing when we get to the end of a leaf on tree.
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.159 2004/05/10 22:44:43 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.160 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -217,7 +217,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate,
|
||||
ArrayType *array_source;
|
||||
ArrayType *resultArray;
|
||||
bool isAssignment = (arrayRef->refassgnexpr != NULL);
|
||||
List *elt;
|
||||
ListCell *l;
|
||||
int i = 0,
|
||||
j = 0;
|
||||
IntArray upper,
|
||||
@ -258,9 +258,9 @@ ExecEvalArrayRef(ArrayRefExprState *astate,
|
||||
array_source = NULL;
|
||||
}
|
||||
|
||||
foreach(elt, astate->refupperindexpr)
|
||||
foreach(l, astate->refupperindexpr)
|
||||
{
|
||||
ExprState *eltstate = (ExprState *) lfirst(elt);
|
||||
ExprState *eltstate = (ExprState *) lfirst(l);
|
||||
|
||||
if (i >= MAXDIM)
|
||||
ereport(ERROR,
|
||||
@ -284,9 +284,9 @@ ExecEvalArrayRef(ArrayRefExprState *astate,
|
||||
|
||||
if (astate->reflowerindexpr != NIL)
|
||||
{
|
||||
foreach(elt, astate->reflowerindexpr)
|
||||
foreach(l, astate->reflowerindexpr)
|
||||
{
|
||||
ExprState *eltstate = (ExprState *) lfirst(elt);
|
||||
ExprState *eltstate = (ExprState *) lfirst(l);
|
||||
|
||||
if (j >= MAXDIM)
|
||||
ereport(ERROR,
|
||||
@ -798,7 +798,7 @@ ExecEvalFuncArgs(FunctionCallInfo fcinfo,
|
||||
{
|
||||
ExprDoneCond argIsDone;
|
||||
int i;
|
||||
List *arg;
|
||||
ListCell *arg;
|
||||
|
||||
argIsDone = ExprSingleResult; /* default assumption */
|
||||
|
||||
@ -1070,7 +1070,7 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache,
|
||||
bool *isNull,
|
||||
ExprDoneCond *isDone)
|
||||
{
|
||||
List *arg;
|
||||
ListCell *arg;
|
||||
Datum result;
|
||||
FunctionCallInfoData fcinfo;
|
||||
int i;
|
||||
@ -1703,7 +1703,7 @@ static Datum
|
||||
ExecEvalNot(BoolExprState *notclause, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone)
|
||||
{
|
||||
ExprState *clause = lfirst(notclause->args);
|
||||
ExprState *clause = linitial(notclause->args);
|
||||
Datum expr_value;
|
||||
|
||||
if (isDone)
|
||||
@ -1734,7 +1734,7 @@ ExecEvalOr(BoolExprState *orExpr, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone)
|
||||
{
|
||||
List *clauses = orExpr->args;
|
||||
List *clause;
|
||||
ListCell *clause;
|
||||
bool AnyNull;
|
||||
|
||||
if (isDone)
|
||||
@ -1786,7 +1786,7 @@ ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone)
|
||||
{
|
||||
List *clauses = andExpr->args;
|
||||
List *clause;
|
||||
ListCell *clause;
|
||||
bool AnyNull;
|
||||
|
||||
if (isDone)
|
||||
@ -1802,6 +1802,7 @@ ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext,
|
||||
* when you interpret NULL as "don't know", using the same sort of
|
||||
* reasoning as for OR, above.
|
||||
*/
|
||||
|
||||
foreach(clause, clauses)
|
||||
{
|
||||
ExprState *clausestate = (ExprState *) lfirst(clause);
|
||||
@ -1838,7 +1839,7 @@ ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone)
|
||||
{
|
||||
List *clauses = caseExpr->args;
|
||||
List *clause;
|
||||
ListCell *clause;
|
||||
Datum save_datum;
|
||||
bool save_isNull;
|
||||
|
||||
@ -1938,7 +1939,7 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
|
||||
{
|
||||
ArrayExpr *arrayExpr = (ArrayExpr *) astate->xprstate.expr;
|
||||
ArrayType *result;
|
||||
List *element;
|
||||
ListCell *element;
|
||||
Oid element_type = arrayExpr->element_typeid;
|
||||
int ndims = 0;
|
||||
int dims[MAXDIM];
|
||||
@ -2118,7 +2119,7 @@ ExecEvalRow(RowExprState *rstate,
|
||||
Datum *values;
|
||||
char *nulls;
|
||||
int nargs;
|
||||
List *arg;
|
||||
ListCell *arg;
|
||||
int i;
|
||||
|
||||
/* Set default values for result flags: non-null, not a set result */
|
||||
@ -2161,7 +2162,7 @@ static Datum
|
||||
ExecEvalCoalesce(CoalesceExprState *coalesceExpr, ExprContext *econtext,
|
||||
bool *isNull, ExprDoneCond *isDone)
|
||||
{
|
||||
List *arg;
|
||||
ListCell *arg;
|
||||
|
||||
if (isDone)
|
||||
*isDone = ExprSingleResult;
|
||||
@ -2390,7 +2391,7 @@ ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext,
|
||||
{
|
||||
CoerceToDomain *ctest = (CoerceToDomain *) cstate->xprstate.expr;
|
||||
Datum result;
|
||||
List *l;
|
||||
ListCell *l;
|
||||
|
||||
result = ExecEvalExpr(cstate->arg, econtext, isNull, isDone);
|
||||
|
||||
@ -2826,14 +2827,14 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
CaseExpr *caseexpr = (CaseExpr *) node;
|
||||
CaseExprState *cstate = makeNode(CaseExprState);
|
||||
FastList outlist;
|
||||
List *inlist;
|
||||
ListCell *l;
|
||||
|
||||
cstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalCase;
|
||||
cstate->arg = ExecInitExpr(caseexpr->arg, parent);
|
||||
FastListInit(&outlist);
|
||||
foreach(inlist, caseexpr->args)
|
||||
foreach(l, caseexpr->args)
|
||||
{
|
||||
CaseWhen *when = (CaseWhen *) lfirst(inlist);
|
||||
CaseWhen *when = (CaseWhen *) lfirst(l);
|
||||
CaseWhenState *wstate = makeNode(CaseWhenState);
|
||||
|
||||
Assert(IsA(when, CaseWhen));
|
||||
@ -2853,13 +2854,13 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
ArrayExpr *arrayexpr = (ArrayExpr *) node;
|
||||
ArrayExprState *astate = makeNode(ArrayExprState);
|
||||
FastList outlist;
|
||||
List *inlist;
|
||||
ListCell *l;
|
||||
|
||||
astate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalArray;
|
||||
FastListInit(&outlist);
|
||||
foreach(inlist, arrayexpr->elements)
|
||||
foreach(l, arrayexpr->elements)
|
||||
{
|
||||
Expr *e = (Expr *) lfirst(inlist);
|
||||
Expr *e = (Expr *) lfirst(l);
|
||||
ExprState *estate;
|
||||
|
||||
estate = ExecInitExpr(e, parent);
|
||||
@ -2879,13 +2880,13 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
RowExpr *rowexpr = (RowExpr *) node;
|
||||
RowExprState *rstate = makeNode(RowExprState);
|
||||
List *outlist;
|
||||
List *inlist;
|
||||
ListCell *l;
|
||||
|
||||
rstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalRow;
|
||||
outlist = NIL;
|
||||
foreach(inlist, rowexpr->args)
|
||||
foreach(l, rowexpr->args)
|
||||
{
|
||||
Expr *e = (Expr *) lfirst(inlist);
|
||||
Expr *e = (Expr *) lfirst(l);
|
||||
ExprState *estate;
|
||||
|
||||
estate = ExecInitExpr(e, parent);
|
||||
@ -2912,13 +2913,13 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
CoalesceExpr *coalesceexpr = (CoalesceExpr *) node;
|
||||
CoalesceExprState *cstate = makeNode(CoalesceExprState);
|
||||
FastList outlist;
|
||||
List *inlist;
|
||||
ListCell *l;
|
||||
|
||||
cstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalCoalesce;
|
||||
FastListInit(&outlist);
|
||||
foreach(inlist, coalesceexpr->args)
|
||||
foreach(l, coalesceexpr->args)
|
||||
{
|
||||
Expr *e = (Expr *) lfirst(inlist);
|
||||
Expr *e = (Expr *) lfirst(l);
|
||||
ExprState *estate;
|
||||
|
||||
estate = ExecInitExpr(e, parent);
|
||||
@ -2984,13 +2985,13 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
||||
case T_List:
|
||||
{
|
||||
FastList outlist;
|
||||
List *inlist;
|
||||
ListCell *l;
|
||||
|
||||
FastListInit(&outlist);
|
||||
foreach(inlist, (List *) node)
|
||||
foreach(l, (List *) node)
|
||||
{
|
||||
FastAppend(&outlist,
|
||||
ExecInitExpr((Expr *) lfirst(inlist),
|
||||
ExecInitExpr((Expr *) lfirst(l),
|
||||
parent));
|
||||
}
|
||||
/* Don't fall through to the "common" code below */
|
||||
@ -3101,7 +3102,7 @@ ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
|
||||
{
|
||||
bool result;
|
||||
MemoryContext oldContext;
|
||||
List *qlist;
|
||||
ListCell *l;
|
||||
|
||||
/*
|
||||
* debugging stuff
|
||||
@ -3131,9 +3132,9 @@ ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
|
||||
*/
|
||||
result = true;
|
||||
|
||||
foreach(qlist, qual)
|
||||
foreach(l, qual)
|
||||
{
|
||||
ExprState *clause = (ExprState *) lfirst(qlist);
|
||||
ExprState *clause = (ExprState *) lfirst(l);
|
||||
Datum expr_value;
|
||||
bool isNull;
|
||||
|
||||
@ -3179,7 +3180,7 @@ int
|
||||
ExecCleanTargetListLength(List *targetlist)
|
||||
{
|
||||
int len = 0;
|
||||
List *tl;
|
||||
ListCell *tl;
|
||||
|
||||
foreach(tl, targetlist)
|
||||
{
|
||||
@ -3219,7 +3220,7 @@ ExecTargetList(List *targetlist,
|
||||
ExprDoneCond *isDone)
|
||||
{
|
||||
MemoryContext oldContext;
|
||||
List *tl;
|
||||
ListCell *tl;
|
||||
bool isNull;
|
||||
bool haveDoneSets;
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.30 2004/01/22 02:23:21 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.31 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -195,6 +195,7 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc
|
||||
int numattrs = tupdesc->natts;
|
||||
int attrno;
|
||||
bool hasoid;
|
||||
ListCell *tlist_item = list_head(tlist);
|
||||
|
||||
/* Check the tlist attributes */
|
||||
for (attrno = 1; attrno <= numattrs; attrno++)
|
||||
@ -202,9 +203,9 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc
|
||||
Form_pg_attribute att_tup = tupdesc->attrs[attrno - 1];
|
||||
Var *var;
|
||||
|
||||
if (tlist == NIL)
|
||||
if (tlist_item == NULL)
|
||||
return false; /* tlist too short */
|
||||
var = (Var *) ((TargetEntry *) lfirst(tlist))->expr;
|
||||
var = (Var *) ((TargetEntry *) lfirst(tlist_item))->expr;
|
||||
if (!var || !IsA(var, Var))
|
||||
return false; /* tlist item not a Var */
|
||||
Assert(var->varno == varno);
|
||||
@ -216,10 +217,10 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc
|
||||
Assert(var->vartype == att_tup->atttypid);
|
||||
Assert(var->vartypmod == att_tup->atttypmod);
|
||||
|
||||
tlist = lnext(tlist);
|
||||
tlist_item = lnext(tlist_item);
|
||||
}
|
||||
|
||||
if (tlist)
|
||||
if (tlist_item)
|
||||
return false; /* tlist too long */
|
||||
|
||||
/*
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.77 2004/05/10 22:44:44 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.78 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -569,7 +569,7 @@ static TupleDesc
|
||||
ExecTypeFromTLInternal(List *targetList, bool hasoid, bool skipjunk)
|
||||
{
|
||||
TupleDesc typeInfo;
|
||||
List *l;
|
||||
ListCell *l;
|
||||
int len;
|
||||
int cur_resno = 1;
|
||||
|
||||
@ -606,7 +606,7 @@ TupleDesc
|
||||
ExecTypeFromExprList(List *exprList)
|
||||
{
|
||||
TupleDesc typeInfo;
|
||||
List *l;
|
||||
ListCell *l;
|
||||
int cur_resno = 1;
|
||||
char fldname[NAMEDATALEN];
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.110 2004/03/17 20:48:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.111 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -248,7 +248,10 @@ FreeExecutorState(EState *estate)
|
||||
*/
|
||||
while (estate->es_exprcontexts)
|
||||
{
|
||||
FreeExprContext((ExprContext *) lfirst(estate->es_exprcontexts));
|
||||
/* XXX: seems there ought to be a faster way to implement this
|
||||
* than repeated lremove(), no?
|
||||
*/
|
||||
FreeExprContext((ExprContext *) linitial(estate->es_exprcontexts));
|
||||
/* FreeExprContext removed the list link for us */
|
||||
}
|
||||
|
||||
@ -636,8 +639,8 @@ void
|
||||
ExecOpenIndices(ResultRelInfo *resultRelInfo)
|
||||
{
|
||||
Relation resultRelation = resultRelInfo->ri_RelationDesc;
|
||||
List *indexoidlist,
|
||||
*indexoidscan;
|
||||
List *indexoidlist;
|
||||
ListCell *l;
|
||||
int len,
|
||||
i;
|
||||
RelationPtr relationDescs;
|
||||
@ -671,9 +674,9 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo)
|
||||
* For each index, open the index relation and save pg_index info.
|
||||
*/
|
||||
i = 0;
|
||||
foreach(indexoidscan, indexoidlist)
|
||||
foreach(l, indexoidlist)
|
||||
{
|
||||
Oid indexOid = lfirsto(indexoidscan);
|
||||
Oid indexOid = lfirsto(l);
|
||||
Relation indexDesc;
|
||||
IndexInfo *ii;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.80 2004/04/02 23:14:08 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.81 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -92,7 +92,7 @@ init_execution_state(List *queryTree_list)
|
||||
{
|
||||
execution_state *firstes = NULL;
|
||||
execution_state *preves = NULL;
|
||||
List *qtl_item;
|
||||
ListCell *qtl_item;
|
||||
|
||||
foreach(qtl_item, queryTree_list)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.119 2004/03/13 00:54:10 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.120 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1033,7 +1033,7 @@ ExecInitAgg(Agg *node, EState *estate)
|
||||
ExprContext *econtext;
|
||||
int numaggs,
|
||||
aggno;
|
||||
List *alist;
|
||||
ListCell *l;
|
||||
|
||||
/*
|
||||
* create state structure
|
||||
@ -1187,9 +1187,9 @@ ExecInitAgg(Agg *node, EState *estate)
|
||||
* result entry by giving them duplicate aggno values.
|
||||
*/
|
||||
aggno = -1;
|
||||
foreach(alist, aggstate->aggs)
|
||||
foreach(l, aggstate->aggs)
|
||||
{
|
||||
AggrefExprState *aggrefstate = (AggrefExprState *) lfirst(alist);
|
||||
AggrefExprState *aggrefstate = (AggrefExprState *) lfirst(l);
|
||||
Aggref *aggref = (Aggref *) aggrefstate->xprstate.expr;
|
||||
AggStatePerAgg peraggstate;
|
||||
Oid inputType;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.56 2004/01/22 02:23:21 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.57 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -237,7 +237,7 @@ ExecInitAppend(Append *node, EState *estate)
|
||||
int
|
||||
ExecCountSlotsAppend(Append *node)
|
||||
{
|
||||
List *plan;
|
||||
ListCell *plan;
|
||||
int nSlots = 0;
|
||||
|
||||
foreach(plan, node->appendplans)
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.24 2004/04/01 21:28:44 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.25 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -201,7 +201,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate)
|
||||
else if (functyptype == 'b' || functyptype == 'd')
|
||||
{
|
||||
/* Must be a base data type, i.e. scalar */
|
||||
char *attname = strVal(lfirst(rte->eref->colnames));
|
||||
char *attname = strVal(linitial(rte->eref->colnames));
|
||||
|
||||
tupdesc = CreateTemplateTupleDesc(1, false);
|
||||
TupleDescInitEntry(tupdesc,
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.83 2004/03/17 01:02:23 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.84 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -202,7 +202,7 @@ ExecHashTableCreate(Hash *node, List *hashOperators)
|
||||
int nbatch;
|
||||
int nkeys;
|
||||
int i;
|
||||
List *ho;
|
||||
ListCell *ho;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
/*
|
||||
@ -518,7 +518,7 @@ ExecHashGetBucket(HashJoinTable hashtable,
|
||||
{
|
||||
uint32 hashkey = 0;
|
||||
int bucketno;
|
||||
List *hk;
|
||||
ListCell *hk;
|
||||
int i = 0;
|
||||
MemoryContext oldContext;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.60 2004/01/07 18:56:26 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.61 2004/05/26 04:41:15 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -311,7 +311,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
|
||||
List *lclauses;
|
||||
List *rclauses;
|
||||
List *hoperators;
|
||||
List *hcl;
|
||||
ListCell *l;
|
||||
|
||||
/*
|
||||
* create state structure
|
||||
@ -419,15 +419,15 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
|
||||
lclauses = NIL;
|
||||
rclauses = NIL;
|
||||
hoperators = NIL;
|
||||
foreach(hcl, hjstate->hashclauses)
|
||||
foreach(l, hjstate->hashclauses)
|
||||
{
|
||||
FuncExprState *fstate = (FuncExprState *) lfirst(hcl);
|
||||
FuncExprState *fstate = (FuncExprState *) lfirst(l);
|
||||
OpExpr *hclause;
|
||||
|
||||
Assert(IsA(fstate, FuncExprState));
|
||||
hclause = (OpExpr *) fstate->xprstate.expr;
|
||||
Assert(IsA(hclause, OpExpr));
|
||||
lclauses = lappend(lclauses, lfirst(fstate->args));
|
||||
lclauses = lappend(lclauses, linitial(fstate->args));
|
||||
rclauses = lappend(rclauses, lsecond(fstate->args));
|
||||
hoperators = lappendo(hoperators, hclause->opno);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.93 2004/04/21 18:24:26 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.94 2004/05/26 04:41:16 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -146,7 +146,7 @@ IndexNext(IndexScanState *node)
|
||||
if (estate->es_evTuple != NULL &&
|
||||
estate->es_evTuple[scanrelid - 1] != NULL)
|
||||
{
|
||||
List *qual;
|
||||
ListCell *qual;
|
||||
|
||||
if (estate->es_evTupleNull[scanrelid - 1])
|
||||
return slot; /* return empty slot */
|
||||
@ -164,7 +164,7 @@ IndexNext(IndexScanState *node)
|
||||
if (ExecQual((List *) lfirst(qual), econtext, false))
|
||||
break;
|
||||
}
|
||||
if (qual == NIL) /* would not be returned by indices */
|
||||
if (qual == NULL) /* would not be returned by indices */
|
||||
slot->val = NULL;
|
||||
|
||||
/* Flag for the next call that no more tuples */
|
||||
@ -283,11 +283,11 @@ IndexNext(IndexScanState *node)
|
||||
{
|
||||
bool prev_matches = false;
|
||||
int prev_index;
|
||||
List *qual;
|
||||
ListCell *qual;
|
||||
|
||||
econtext->ecxt_scantuple = slot;
|
||||
ResetExprContext(econtext);
|
||||
qual = node->indxqualorig;
|
||||
qual = list_head(node->indxqualorig);
|
||||
for (prev_index = 0;
|
||||
prev_index < node->iss_IndexPtr;
|
||||
prev_index++)
|
||||
@ -641,11 +641,11 @@ IndexScanState *
|
||||
ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
{
|
||||
IndexScanState *indexstate;
|
||||
List *indxqual;
|
||||
List *indxstrategy;
|
||||
List *indxsubtype;
|
||||
List *indxlossy;
|
||||
List *indxid;
|
||||
ListCell *indxqual;
|
||||
ListCell *indxstrategy;
|
||||
ListCell *indxsubtype;
|
||||
ListCell *indxlossy;
|
||||
ListCell *indxid_item;
|
||||
int i;
|
||||
int numIndices;
|
||||
int indexPtr;
|
||||
@ -719,8 +719,8 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
/*
|
||||
* get the index node information
|
||||
*/
|
||||
indxid = node->indxid;
|
||||
numIndices = length(indxid);
|
||||
indxid_item = list_head(node->indxid);
|
||||
numIndices = length(node->indxid);
|
||||
indexPtr = -1;
|
||||
|
||||
CXT1_printf("ExecInitIndexScan: context is %d\n", CurrentMemoryContext);
|
||||
@ -745,28 +745,32 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
/*
|
||||
* build the index scan keys from the index qualification
|
||||
*/
|
||||
indxqual = node->indxqual;
|
||||
indxstrategy = node->indxstrategy;
|
||||
indxsubtype = node->indxsubtype;
|
||||
indxlossy = node->indxlossy;
|
||||
indxqual = list_head(node->indxqual);
|
||||
indxstrategy = list_head(node->indxstrategy);
|
||||
indxsubtype = list_head(node->indxsubtype);
|
||||
indxlossy = list_head(node->indxlossy);
|
||||
for (i = 0; i < numIndices; i++)
|
||||
{
|
||||
List *quals;
|
||||
List *strategies;
|
||||
List *subtypes;
|
||||
List *lossyflags;
|
||||
ListCell *qual_cell;
|
||||
ListCell *strategy_cell;
|
||||
ListCell *subtype_cell;
|
||||
ListCell *lossyflag_cell;
|
||||
int n_keys;
|
||||
ScanKey scan_keys;
|
||||
ExprState **run_keys;
|
||||
int j;
|
||||
|
||||
quals = lfirst(indxqual);
|
||||
quals = (List *) lfirst(indxqual);
|
||||
indxqual = lnext(indxqual);
|
||||
strategies = lfirst(indxstrategy);
|
||||
strategies = (List *) lfirst(indxstrategy);
|
||||
indxstrategy = lnext(indxstrategy);
|
||||
subtypes = lfirst(indxsubtype);
|
||||
subtypes = (List *) lfirst(indxsubtype);
|
||||
indxsubtype = lnext(indxsubtype);
|
||||
lossyflags = lfirst(indxlossy);
|
||||
lossyflags = (List *) lfirst(indxlossy);
|
||||
indxlossy = lnext(indxlossy);
|
||||
n_keys = length(quals);
|
||||
scan_keys = (n_keys <= 0) ? NULL :
|
||||
@ -778,6 +782,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
* for each opclause in the given qual, convert each qual's
|
||||
* opclause into a single scan key
|
||||
*/
|
||||
qual_cell = list_head(quals);
|
||||
strategy_cell = list_head(strategies);
|
||||
subtype_cell = list_head(subtypes);
|
||||
lossyflag_cell = list_head(lossyflags);
|
||||
for (j = 0; j < n_keys; j++)
|
||||
{
|
||||
OpExpr *clause; /* one clause of index qual */
|
||||
@ -794,14 +802,14 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
/*
|
||||
* extract clause information from the qualification
|
||||
*/
|
||||
clause = (OpExpr *) lfirst(quals);
|
||||
quals = lnext(quals);
|
||||
strategy = lfirsti(strategies);
|
||||
strategies = lnext(strategies);
|
||||
subtype = lfirsto(subtypes);
|
||||
subtypes = lnext(subtypes);
|
||||
lossy = lfirsti(lossyflags);
|
||||
lossyflags = lnext(lossyflags);
|
||||
clause = (OpExpr *) lfirst(qual_cell);
|
||||
qual_cell = lnext(qual_cell);
|
||||
strategy = lfirsti(strategy_cell);
|
||||
strategy_cell = lnext(strategy_cell);
|
||||
subtype = lfirsto(subtype_cell);
|
||||
subtype_cell = lnext(subtype_cell);
|
||||
lossy = lfirsti(lossyflag_cell);
|
||||
lossyflag_cell = lnext(lossyflag_cell);
|
||||
|
||||
if (!IsA(clause, OpExpr))
|
||||
elog(ERROR, "indxqual is not an OpExpr");
|
||||
@ -972,7 +980,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
*/
|
||||
for (i = 0; i < numIndices; i++)
|
||||
{
|
||||
Oid indexOid = lfirsto(indxid);
|
||||
Oid indexOid = lfirsto(indxid_item);
|
||||
|
||||
indexDescs[i] = index_open(indexOid);
|
||||
scanDescs[i] = index_beginscan(currentRelation,
|
||||
@ -980,7 +988,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
|
||||
estate->es_snapshot,
|
||||
numScanKeys[i],
|
||||
scanKeys[i]);
|
||||
indxid = lnext(indxid);
|
||||
indxid_item = lnext(indxid_item);
|
||||
}
|
||||
|
||||
indexstate->iss_RelationDescs = indexDescs;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.64 2004/03/17 01:02:23 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.65 2004/05/26 04:41:16 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -104,10 +104,10 @@ static void
|
||||
MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals,
|
||||
PlanState *parent)
|
||||
{
|
||||
List *ltexprs,
|
||||
*gtexprs,
|
||||
*ltcdr,
|
||||
*gtcdr;
|
||||
List *ltexprs,
|
||||
*gtexprs;
|
||||
ListCell *ltcdr,
|
||||
*gtcdr;
|
||||
|
||||
/*
|
||||
* Make modifiable copies of the qualList.
|
||||
@ -119,8 +119,7 @@ MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals,
|
||||
* Scan both lists in parallel, so that we can update the operators
|
||||
* with the minimum number of syscache searches.
|
||||
*/
|
||||
ltcdr = ltexprs;
|
||||
foreach(gtcdr, gtexprs)
|
||||
forboth(ltcdr, ltexprs, gtcdr, gtexprs)
|
||||
{
|
||||
OpExpr *ltop = (OpExpr *) lfirst(ltcdr);
|
||||
OpExpr *gtop = (OpExpr *) lfirst(gtcdr);
|
||||
@ -140,8 +139,6 @@ MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals,
|
||||
>op->opno,
|
||||
<op->opfuncid,
|
||||
>op->opfuncid);
|
||||
|
||||
ltcdr = lnext(ltcdr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -173,8 +170,8 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
|
||||
{
|
||||
bool result;
|
||||
MemoryContext oldContext;
|
||||
List *clause;
|
||||
List *eqclause;
|
||||
ListCell *clause;
|
||||
ListCell *eqclause;
|
||||
|
||||
/*
|
||||
* Do expression eval in short-lived context.
|
||||
@ -188,8 +185,12 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
|
||||
*/
|
||||
result = false; /* assume 'false' result */
|
||||
|
||||
eqclause = eqQual;
|
||||
foreach(clause, compareQual)
|
||||
/*
|
||||
* We can't run out of one list before the other
|
||||
*/
|
||||
Assert(length(compareQual) == length(eqQual));
|
||||
|
||||
forboth(clause, compareQual, eqclause, eqQual)
|
||||
{
|
||||
ExprState *clauseexpr = (ExprState *) lfirst(clause);
|
||||
ExprState *eqclauseexpr = (ExprState *) lfirst(eqclause);
|
||||
@ -220,8 +221,6 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
|
||||
|
||||
if (!DatumGetBool(const_value) || isNull)
|
||||
break; /* return false */
|
||||
|
||||
eqclause = lnext(eqclause);
|
||||
}
|
||||
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.61 2004/03/17 01:02:23 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.62 2004/05/26 04:41:16 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -212,8 +212,8 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
TupleTableSlot *slot;
|
||||
Datum result;
|
||||
bool found = false; /* TRUE if got at least one subplan tuple */
|
||||
List *pvar;
|
||||
List *lst;
|
||||
ListCell *pvar;
|
||||
ListCell *l;
|
||||
ArrayBuildState *astate = NULL;
|
||||
|
||||
/*
|
||||
@ -228,21 +228,19 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
* calculation we have to do is done in the parent econtext, since the
|
||||
* Param values don't need to have per-query lifetime.)
|
||||
*/
|
||||
pvar = node->args;
|
||||
foreach(lst, subplan->parParam)
|
||||
Assert(length(subplan->parParam) == length(node->args));
|
||||
|
||||
forboth(l, subplan->parParam, pvar, node->args)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirst_int(l);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
Assert(pvar != NIL);
|
||||
prm->value = ExecEvalExprSwitchContext((ExprState *) lfirst(pvar),
|
||||
econtext,
|
||||
&(prm->isnull),
|
||||
NULL);
|
||||
pvar = lnext(pvar);
|
||||
planstate->chgParam = bms_add_member(planstate->chgParam, paramid);
|
||||
}
|
||||
Assert(pvar == NIL);
|
||||
|
||||
ExecReScan(planstate, NULL);
|
||||
|
||||
@ -278,7 +276,7 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
Datum rowresult = BoolGetDatum(!useOr);
|
||||
bool rownull = false;
|
||||
int col = 1;
|
||||
List *plst;
|
||||
ListCell *plst;
|
||||
|
||||
if (subLinkType == EXISTS_SUBLINK)
|
||||
{
|
||||
@ -343,11 +341,12 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
* For ALL, ANY, and MULTIEXPR sublinks, iterate over combining
|
||||
* operators for columns of tuple.
|
||||
*/
|
||||
plst = subplan->paramIds;
|
||||
foreach(lst, node->exprs)
|
||||
Assert(length(node->exprs) == length(subplan->paramIds));
|
||||
|
||||
forboth(l, node->exprs, plst, subplan->paramIds)
|
||||
{
|
||||
ExprState *exprstate = (ExprState *) lfirst(lst);
|
||||
int paramid = lfirsti(plst);
|
||||
ExprState *exprstate = (ExprState *) lfirst(l);
|
||||
int paramid = lfirst_int(plst);
|
||||
ParamExecData *prmdata;
|
||||
Datum expresult;
|
||||
bool expnull;
|
||||
@ -400,7 +399,6 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
}
|
||||
}
|
||||
|
||||
plst = lnext(plst);
|
||||
col++;
|
||||
}
|
||||
|
||||
@ -559,7 +557,7 @@ buildSubPlanHash(SubPlanState *node)
|
||||
HeapTuple tup = slot->val;
|
||||
TupleDesc tdesc = slot->ttc_tupleDescriptor;
|
||||
int col = 1;
|
||||
List *plst;
|
||||
ListCell *plst;
|
||||
bool isnew;
|
||||
|
||||
/*
|
||||
@ -737,7 +735,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
*/
|
||||
if (subplan->setParam != NIL)
|
||||
{
|
||||
List *lst;
|
||||
ListCell *lst;
|
||||
|
||||
foreach(lst, subplan->setParam)
|
||||
{
|
||||
@ -762,8 +760,8 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
List *lefttlist,
|
||||
*righttlist,
|
||||
*leftptlist,
|
||||
*rightptlist,
|
||||
*lexpr;
|
||||
*rightptlist;
|
||||
ListCell *lexpr;
|
||||
|
||||
/* We need a memory context to hold the hash table(s) */
|
||||
node->tablecxt =
|
||||
@ -815,7 +813,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
|
||||
Assert(length(fstate->args) == 2);
|
||||
|
||||
/* Process lefthand argument */
|
||||
exstate = (ExprState *) lfirst(fstate->args);
|
||||
exstate = (ExprState *) linitial(fstate->args);
|
||||
expr = exstate->expr;
|
||||
tle = makeTargetEntry(makeResdom(i,
|
||||
exprType((Node *) expr),
|
||||
@ -914,7 +912,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
SubLinkType subLinkType = subplan->subLinkType;
|
||||
MemoryContext oldcontext;
|
||||
TupleTableSlot *slot;
|
||||
List *lst;
|
||||
ListCell *l;
|
||||
bool found = false;
|
||||
ArrayBuildState *astate = NULL;
|
||||
|
||||
@ -941,7 +939,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
if (subLinkType == EXISTS_SUBLINK)
|
||||
{
|
||||
/* There can be only one param... */
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
int paramid = linitial_int(subplan->setParam);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = NULL;
|
||||
@ -992,9 +990,9 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
/*
|
||||
* Now set all the setParam params from the columns of the tuple
|
||||
*/
|
||||
foreach(lst, subplan->setParam)
|
||||
foreach(l, subplan->setParam)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirsti(l);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = NULL;
|
||||
@ -1008,7 +1006,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
if (subLinkType == EXISTS_SUBLINK)
|
||||
{
|
||||
/* There can be only one param... */
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
int paramid = linitial_int(subplan->setParam);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = NULL;
|
||||
@ -1017,9 +1015,9 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(lst, subplan->setParam)
|
||||
foreach(l, subplan->setParam)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirsti(l);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = NULL;
|
||||
@ -1031,7 +1029,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
else if (subLinkType == ARRAY_SUBLINK)
|
||||
{
|
||||
/* There can be only one param... */
|
||||
int paramid = lfirsti(subplan->setParam);
|
||||
int paramid = linitial_int(subplan->setParam);
|
||||
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
|
||||
|
||||
Assert(astate != NULL);
|
||||
@ -1074,7 +1072,7 @@ ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
|
||||
PlanState *planstate = node->planstate;
|
||||
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
|
||||
EState *estate = parent->state;
|
||||
List *lst;
|
||||
ListCell *l;
|
||||
|
||||
/* sanity checks */
|
||||
if (subplan->parParam != NIL)
|
||||
@ -1091,9 +1089,9 @@ ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
|
||||
/*
|
||||
* Mark this subplan's output parameters as needing recalculation
|
||||
*/
|
||||
foreach(lst, subplan->setParam)
|
||||
foreach(l, subplan->setParam)
|
||||
{
|
||||
int paramid = lfirsti(lst);
|
||||
int paramid = lfirsti(l);
|
||||
ParamExecData *prm = &(estate->es_param_exec_vals[paramid]);
|
||||
|
||||
prm->execPlan = node;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.37 2004/04/21 18:24:26 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.38 2004/05/26 04:41:16 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -45,18 +45,18 @@ TidListCreate(TidScanState *tidstate)
|
||||
ExprContext *econtext = tidstate->ss.ps.ps_ExprContext;
|
||||
ItemPointerData *tidList;
|
||||
int numTids = 0;
|
||||
List *lst;
|
||||
ListCell *l;
|
||||
|
||||
tidList = (ItemPointerData *)
|
||||
palloc(length(tidstate->tss_tideval) * sizeof(ItemPointerData));
|
||||
|
||||
foreach(lst, evalList)
|
||||
foreach(l, evalList)
|
||||
{
|
||||
ItemPointer itemptr;
|
||||
bool isNull;
|
||||
|
||||
itemptr = (ItemPointer)
|
||||
DatumGetPointer(ExecEvalExprSwitchContext(lfirst(lst),
|
||||
DatumGetPointer(ExecEvalExprSwitchContext(lfirst(l),
|
||||
econtext,
|
||||
&isNull,
|
||||
NULL));
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.113 2004/04/01 21:28:44 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.114 2004/05/26 04:41:16 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -744,8 +744,8 @@ SPI_cursor_open(const char *name, void *plan, Datum *Values, const char *Nulls)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
|
||||
errmsg("cannot open multi-query plan as cursor")));
|
||||
queryTree = (Query *) lfirst((List *) lfirst(qtlist));
|
||||
planTree = (Plan *) lfirst(ptlist);
|
||||
queryTree = (Query *) linitial((List *) linitial(qtlist));
|
||||
planTree = (Plan *) linitial(ptlist);
|
||||
|
||||
if (queryTree->commandType != CMD_SELECT)
|
||||
ereport(ERROR,
|
||||
@ -953,7 +953,7 @@ SPI_is_cursor_plan(void *plan)
|
||||
qtlist = spiplan->qtlist;
|
||||
if (length(spiplan->ptlist) == 1 && length(qtlist) == 1)
|
||||
{
|
||||
Query *queryTree = (Query *) lfirst((List *) lfirst(qtlist));
|
||||
Query *queryTree = (Query *) linitial((List *) linitial(qtlist));
|
||||
|
||||
if (queryTree->commandType == CMD_SELECT && queryTree->into == NULL)
|
||||
return true;
|
||||
@ -1062,7 +1062,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
|
||||
List *raw_parsetree_list;
|
||||
List *query_list_list;
|
||||
List *plan_list;
|
||||
List *list_item;
|
||||
ListCell *list_item;
|
||||
ErrorContextCallback spierrcontext;
|
||||
int nargs = 0;
|
||||
Oid *argtypes = NULL;
|
||||
@ -1110,7 +1110,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
|
||||
{
|
||||
Node *parsetree = (Node *) lfirst(list_item);
|
||||
List *query_list;
|
||||
List *query_list_item;
|
||||
ListCell *query_list_item;
|
||||
|
||||
query_list = pg_analyze_and_rewrite(parsetree, argtypes, nargs);
|
||||
|
||||
@ -1207,8 +1207,8 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
|
||||
bool useCurrentSnapshot, int tcount)
|
||||
{
|
||||
List *query_list_list = plan->qtlist;
|
||||
List *plan_list = plan->ptlist;
|
||||
List *query_list_list_item;
|
||||
ListCell *plan_list_item = list_head(plan->ptlist);
|
||||
ListCell *query_list_list_item;
|
||||
ErrorContextCallback spierrcontext;
|
||||
int nargs = plan->nargs;
|
||||
int res = 0;
|
||||
@ -1254,7 +1254,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
|
||||
foreach(query_list_list_item, query_list_list)
|
||||
{
|
||||
List *query_list = lfirst(query_list_list_item);
|
||||
List *query_list_item;
|
||||
ListCell *query_list_item;
|
||||
|
||||
/* Reset state for each original parsetree */
|
||||
/* (at most one of its querytrees will be marked canSetTag) */
|
||||
@ -1270,8 +1270,8 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
|
||||
QueryDesc *qdesc;
|
||||
DestReceiver *dest;
|
||||
|
||||
planTree = lfirst(plan_list);
|
||||
plan_list = lnext(plan_list);
|
||||
planTree = lfirst(plan_list_item);
|
||||
plan_list_item = lnext(plan_list_item);
|
||||
|
||||
dest = CreateDestReceiver(queryTree->canSetTag ? SPI : None, NULL);
|
||||
if (queryTree->commandType == CMD_UTILITY)
|
||||
|
Reference in New Issue
Block a user