1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Use the new List API function names throughout the backend, and disable the

list compatibility API by default. While doing this, I decided to keep
the llast() macro around and introduce llast_int() and llast_oid() variants.
This commit is contained in:
Neil Conway
2004-05-30 23:40:41 +00:00
parent ec0b1f2716
commit 72b6ad6313
83 changed files with 798 additions and 828 deletions

View File

@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.232 2004/05/26 04:41:14 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.233 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -524,7 +524,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
ResultRelInfo *resultRelInfo;
ListCell *l;
numResultRelations = length(resultRelations);
numResultRelations = list_length(resultRelations);
resultRelInfos = (ResultRelInfo *)
palloc(numResultRelations * sizeof(ResultRelInfo));
resultRelInfo = resultRelInfos;
@ -590,7 +590,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
foreach(l, parseTree->rowMarks)
{
Index rti = lfirsti(l);
Index rti = lfirst_int(l);
Oid relid = getrelid(rti, rangeTable);
Relation relation;
execRowMark *erm;
@ -614,7 +614,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
int nSlots = ExecCountSlotsNode(plan);
if (parseTree->resultRelations != NIL)
nSlots += length(parseTree->resultRelations);
nSlots += list_length(parseTree->resultRelations);
else
nSlots += 1;
estate->es_tupleTable = ExecCreateTupleTable(nSlots);
@ -2067,7 +2067,7 @@ EvalPlanQualStart(evalPlanQual *epq, EState *estate, evalPlanQual *priorepq)
int rtsize;
MemoryContext oldcontext;
rtsize = length(estate->es_range_table);
rtsize = list_length(estate->es_range_table);
epq->estate = epqstate = CreateExecutorState();

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.160 2004/05/26 04:41:15 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.161 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -760,7 +760,7 @@ init_fcache(Oid foid, FuncExprState *fcache, MemoryContext fcacheCxt)
aclcheck_error(aclresult, ACL_KIND_PROC, get_func_name(foid));
/* Safety check (should never fail, as parser should check sooner) */
if (length(fcache->args) > FUNC_MAX_ARGS)
if (list_length(fcache->args) > FUNC_MAX_ARGS)
elog(ERROR, "too many arguments");
/* Set up the primary fmgr lookup information */
@ -1958,7 +1958,7 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
int i = 0;
ndims = 1;
nelems = length(astate->elements);
nelems = list_length(astate->elements);
/* Shouldn't happen here, but if length is 0, return NULL */
if (nelems == 0)
@ -1999,7 +1999,7 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
char *dat = NULL;
Size ndatabytes = 0;
int nbytes;
int outer_nelems = length(astate->elements);
int outer_nelems = list_length(astate->elements);
int elem_ndims = 0;
int *elem_dims = NULL;
int *elem_lbs = NULL;
@ -2128,7 +2128,7 @@ ExecEvalRow(RowExprState *rstate,
*isDone = ExprSingleResult;
/* Allocate workspace */
nargs = length(rstate->args);
nargs = list_length(rstate->args);
if (nargs == 0) /* avoid palloc(0) if no fields */
nargs = 1;
values = (Datum *) palloc(nargs * sizeof(Datum));
@ -3170,7 +3170,7 @@ int
ExecTargetListLength(List *targetlist)
{
/* This used to be more complex, but fjoins are dead */
return length(targetlist);
return list_length(targetlist);
}
/*

View File

@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.78 2004/05/26 04:41:15 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.79 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -610,7 +610,7 @@ ExecTypeFromExprList(List *exprList)
int cur_resno = 1;
char fldname[NAMEDATALEN];
typeInfo = CreateTemplateTupleDesc(length(exprList), false);
typeInfo = CreateTemplateTupleDesc(list_length(exprList), false);
foreach(l, exprList)
{

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.111 2004/05/26 04:41:15 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.112 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -249,7 +249,7 @@ FreeExecutorState(EState *estate)
while (estate->es_exprcontexts)
{
/* XXX: seems there ought to be a faster way to implement this
* than repeated lremove(), no?
* than repeated list_delete(), no?
*/
FreeExprContext((ExprContext *) linitial(estate->es_exprcontexts));
/* FreeExprContext removed the list link for us */
@ -355,7 +355,7 @@ FreeExprContext(ExprContext *econtext)
MemoryContextDelete(econtext->ecxt_per_tuple_memory);
/* Unlink self from owning EState */
estate = econtext->ecxt_estate;
estate->es_exprcontexts = lremove(econtext, estate->es_exprcontexts);
estate->es_exprcontexts = list_delete_ptr(estate->es_exprcontexts, econtext);
/* And delete the ExprContext node */
pfree(econtext);
}
@ -656,7 +656,7 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo)
* Get cached list of index OIDs
*/
indexoidlist = RelationGetIndexList(resultRelation);
len = length(indexoidlist);
len = list_length(indexoidlist);
if (len == 0)
return;
@ -676,7 +676,7 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo)
i = 0;
foreach(l, indexoidlist)
{
Oid indexOid = lfirsto(l);
Oid indexOid = lfirst_oid(l);
Relation indexDesc;
IndexInfo *ii;
@ -713,7 +713,7 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo)
i++;
}
freeList(indexoidlist);
list_free(indexoidlist);
}
/* ----------------------------------------------------------------

View File

@ -45,7 +45,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.120 2004/05/26 04:41:15 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.121 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -1120,7 +1120,7 @@ ExecInitAgg(Agg *node, EState *estate)
* get the count of aggregates in targetlist and quals
*/
numaggs = aggstate->numaggs;
Assert(numaggs == length(aggstate->aggs));
Assert(numaggs == list_length(aggstate->aggs));
if (numaggs <= 0)
{
/*

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.57 2004/05/26 04:41:15 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.58 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -155,7 +155,7 @@ ExecInitAppend(Append *node, EState *estate)
/*
* Set up empty vector of subplan states
*/
nplans = length(node->appendplans);
nplans = list_length(node->appendplans);
appendplanstates = (PlanState **) palloc0(nplans * sizeof(PlanState *));
@ -215,7 +215,7 @@ ExecInitAppend(Append *node, EState *estate)
appendstate->as_whichplan = i;
exec_append_initialize_next(appendstate);
initNode = (Plan *) nth(i, node->appendplans);
initNode = (Plan *) list_nth(node->appendplans, i);
appendplanstates[i] = ExecInitNode(initNode, estate);
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.84 2004/05/26 04:41:15 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.85 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -240,17 +240,17 @@ ExecHashTableCreate(Hash *node, List *hashOperators)
/*
* Get info about the hash functions to be used for each hash key.
*/
nkeys = length(hashOperators);
nkeys = list_length(hashOperators);
hashtable->hashfunctions = (FmgrInfo *) palloc(nkeys * sizeof(FmgrInfo));
i = 0;
foreach(ho, hashOperators)
{
Oid hashfn;
hashfn = get_op_hash_function(lfirsto(ho));
hashfn = get_op_hash_function(lfirst_oid(ho));
if (!OidIsValid(hashfn))
elog(ERROR, "could not find hash function for hash operator %u",
lfirsto(ho));
lfirst_oid(ho));
fmgr_info(hashfn, &hashtable->hashfunctions[i]);
i++;
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.61 2004/05/26 04:41:15 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.62 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -429,7 +429,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
Assert(IsA(hclause, OpExpr));
lclauses = lappend(lclauses, linitial(fstate->args));
rclauses = lappend(rclauses, lsecond(fstate->args));
hoperators = lappendo(hoperators, hclause->opno);
hoperators = lappend_oid(hoperators, hclause->opno);
}
hjstate->hj_OuterHashKeys = lclauses;
hjstate->hj_InnerHashKeys = rclauses;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.94 2004/05/26 04:41:16 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.95 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -720,7 +720,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
* get the index node information
*/
indxid_item = list_head(node->indxid);
numIndices = length(node->indxid);
numIndices = list_length(node->indxid);
indexPtr = -1;
CXT1_printf("ExecInitIndexScan: context is %d\n", CurrentMemoryContext);
@ -772,7 +772,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
indxsubtype = lnext(indxsubtype);
lossyflags = (List *) lfirst(indxlossy);
indxlossy = lnext(indxlossy);
n_keys = length(quals);
n_keys = list_length(quals);
scan_keys = (n_keys <= 0) ? NULL :
(ScanKey) palloc(n_keys * sizeof(ScanKeyData));
run_keys = (n_keys <= 0) ? NULL :
@ -804,11 +804,11 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
*/
clause = (OpExpr *) lfirst(qual_cell);
qual_cell = lnext(qual_cell);
strategy = lfirsti(strategy_cell);
strategy = lfirst_int(strategy_cell);
strategy_cell = lnext(strategy_cell);
subtype = lfirsto(subtype_cell);
subtype = lfirst_oid(subtype_cell);
subtype_cell = lnext(subtype_cell);
lossy = lfirsti(lossyflag_cell);
lossy = lfirst_int(lossyflag_cell);
lossyflag_cell = lnext(lossyflag_cell);
if (!IsA(clause, OpExpr))
@ -892,17 +892,18 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
scanvalue); /* constant */
/*
* If this operator is lossy, add its indxqualorig expression
* to the list of quals to recheck. The nth() calls here could
* be avoided by chasing the lists in parallel to all the other
* lists, but since lossy operators are very uncommon, it's
* probably a waste of time to do so.
* If this operator is lossy, add its indxqualorig
* expression to the list of quals to recheck. The
* list_nth() calls here could be avoided by chasing the
* lists in parallel to all the other lists, but since
* lossy operators are very uncommon, it's probably a
* waste of time to do so.
*/
if (lossy)
{
List *qualOrig = indexstate->indxqualorig;
lossyQuals[i] = lappend(lossyQuals[i],
nth(j,
(List *) nth(i, indexstate->indxqualorig)));
list_nth((List *) list_nth(qualOrig, i), j));
}
}
@ -980,7 +981,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
*/
for (i = 0; i < numIndices; i++)
{
Oid indexOid = lfirsto(indxid_item);
Oid indexOid = lfirst_oid(indxid_item);
indexDescs[i] = index_open(indexOid);
scanDescs[i] = index_beginscan(currentRelation,

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.65 2004/05/26 04:41:16 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.66 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -188,7 +188,7 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
/*
* We can't run out of one list before the other
*/
Assert(length(compareQual) == length(eqQual));
Assert(list_length(compareQual) == list_length(eqQual));
forboth(clause, compareQual, eqclause, eqQual)
{

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.62 2004/05/26 04:41:16 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.63 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -228,7 +228,7 @@ 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.)
*/
Assert(length(subplan->parParam) == length(node->args));
Assert(list_length(subplan->parParam) == list_length(node->args));
forboth(l, subplan->parParam, pvar, node->args)
{
@ -341,7 +341,7 @@ ExecScanSubPlan(SubPlanState *node,
* For ALL, ANY, and MULTIEXPR sublinks, iterate over combining
* operators for columns of tuple.
*/
Assert(length(node->exprs) == length(subplan->paramIds));
Assert(list_length(node->exprs) == list_length(subplan->paramIds));
forboth(l, node->exprs, plst, subplan->paramIds)
{
@ -469,7 +469,7 @@ buildSubPlanHash(SubPlanState *node)
{
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
PlanState *planstate = node->planstate;
int ncols = length(node->exprs);
int ncols = list_length(node->exprs);
ExprContext *innerecontext = node->innerecontext;
MemoryContext tempcxt = innerecontext->ecxt_per_tuple_memory;
MemoryContext oldcontext;
@ -566,7 +566,7 @@ buildSubPlanHash(SubPlanState *node)
*/
foreach(plst, subplan->paramIds)
{
int paramid = lfirsti(plst);
int paramid = lfirst_int(plst);
ParamExecData *prmdata;
prmdata = &(innerecontext->ecxt_param_exec_vals[paramid]);
@ -739,7 +739,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
foreach(lst, subplan->setParam)
{
int paramid = lfirsti(lst);
int paramid = lfirst_int(lst);
ParamExecData *prm = &(estate->es_param_exec_vals[paramid]);
prm->execPlan = node;
@ -773,7 +773,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
/* and a short-lived exprcontext for function evaluation */
node->innerecontext = CreateExprContext(estate);
/* Silly little array of column numbers 1..n */
ncols = length(node->exprs);
ncols = list_length(node->exprs);
node->keyColIdx = (AttrNumber *) palloc(ncols * sizeof(AttrNumber));
for (i = 0; i < ncols; i++)
node->keyColIdx[i] = i + 1;
@ -810,7 +810,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
Assert(IsA(fstate, FuncExprState));
Assert(IsA(opexpr, OpExpr));
Assert(length(fstate->args) == 2);
Assert(list_length(fstate->args) == 2);
/* Process lefthand argument */
exstate = (ExprState *) linitial(fstate->args);
@ -992,7 +992,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
*/
foreach(l, subplan->setParam)
{
int paramid = lfirsti(l);
int paramid = lfirst_int(l);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
prm->execPlan = NULL;
@ -1017,7 +1017,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
{
foreach(l, subplan->setParam)
{
int paramid = lfirsti(l);
int paramid = lfirst_int(l);
ParamExecData *prm = &(econtext->ecxt_param_exec_vals[paramid]);
prm->execPlan = NULL;
@ -1091,7 +1091,7 @@ ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
*/
foreach(l, subplan->setParam)
{
int paramid = lfirsti(l);
int paramid = lfirst_int(l);
ParamExecData *prm = &(estate->es_param_exec_vals[paramid]);
prm->execPlan = node;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.38 2004/05/26 04:41:16 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.39 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -48,7 +48,7 @@ TidListCreate(TidScanState *tidstate)
ListCell *l;
tidList = (ItemPointerData *)
palloc(length(tidstate->tss_tideval) * sizeof(ItemPointerData));
palloc(list_length(tidstate->tss_tideval) * sizeof(ItemPointerData));
foreach(l, evalList)
{

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.114 2004/05/26 04:41:16 neilc Exp $
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.115 2004/05/30 23:40:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -740,7 +740,7 @@ SPI_cursor_open(const char *name, void *plan, Datum *Values, const char *Nulls)
int k;
/* Ensure that the plan contains only one regular SELECT query */
if (length(ptlist) != 1 || length(qtlist) != 1)
if (list_length(ptlist) != 1 || list_length(qtlist) != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
errmsg("cannot open multi-query plan as cursor")));
@ -821,8 +821,8 @@ SPI_cursor_open(const char *name, void *plan, Datum *Values, const char *Nulls)
PortalDefineQuery(portal,
NULL, /* unfortunately don't have sourceText */
"SELECT", /* cursor's query is always a SELECT */
makeList1(queryTree),
makeList1(planTree),
list_make1(queryTree),
list_make1(planTree),
PortalGetHeapMemory(portal));
MemoryContextSwitchTo(oldcontext);
@ -951,7 +951,7 @@ SPI_is_cursor_plan(void *plan)
}
qtlist = spiplan->qtlist;
if (length(spiplan->ptlist) == 1 && length(qtlist) == 1)
if (list_length(spiplan->ptlist) == 1 && list_length(qtlist) == 1)
{
Query *queryTree = (Query *) linitial((List *) linitial(qtlist));